CP1251->UTF-8

This commit is contained in:
a1batross 2016-03-05 22:29:55 +03:00
parent 04c652a6f1
commit 2df8d31163
168 changed files with 44631 additions and 44631 deletions

View File

@ -1,333 +1,333 @@
/***
*
* 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>
#include "interface.h"
#include "render_api.h"
#include "mobility_int.h"
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
cl_enginefunc_t gEngfuncs;
render_api_t gRenderAPI;
mobile_engfuncs_t gMobileAPI;
CHud gHUD;
int g_iXash; // indicates a buildnum
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 );
int DLLEXPORT HUD_GetRenderInterface( int version, render_api_t *renderfuncs, render_interface_t *callback );
int DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *mobileapi );
}
/*
================================
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));
g_iXash = (int)CVAR_GET_FLOAT("build");
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();
//VGui_Startup();
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();
//Scheme_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 )
{
//ServersThink( time );
//GetClientVoiceMgr()->Frame(time);
}
/*
==========================
HUD_VoiceStatus
Called when a player starts or stops talking.
==========================
*/
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
{
//GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
}
/*
==========================
HUD_DirectorEvent
Called when a director event message was received
==========================
*/
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
{
gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
}
/*
==========================
HUD_GetRenderInterface
Called when Xash3D sends render api to us
==========================
*/
int DLLEXPORT HUD_GetRenderInterface( int version, render_api_t *renderfuncs, render_interface_t *callback )
{
if( version != CL_RENDER_INTERFACE_VERSION )
{
return false;
}
gRenderAPI = *renderfuncs;
// we didn't send callbacks to engine, because we don't use it
// *callback = renderInterface;
return true;
}
/*
========================
HUD_MobilityInterface
========================
*/
int DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *mobileapi )
{
if( mobileapi->version != MOBILITY_API_VERSION )
{
gEngfuncs.Con_Printf("Client Error: Mobile API version mismatch. Got: %i, want: %i\n", mobileapi->version, MOBILITY_API_VERSION);
return 1;
}
gMobileAPI = *mobileapi;
return 0;
}
/***
*
* 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>
#include "interface.h"
#include "render_api.h"
#include "mobility_int.h"
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
cl_enginefunc_t gEngfuncs;
render_api_t gRenderAPI;
mobile_engfuncs_t gMobileAPI;
CHud gHUD;
int g_iXash; // indicates a buildnum
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 );
int DLLEXPORT HUD_GetRenderInterface( int version, render_api_t *renderfuncs, render_interface_t *callback );
int DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *mobileapi );
}
/*
================================
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));
g_iXash = (int)CVAR_GET_FLOAT("build");
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();
//VGui_Startup();
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();
//Scheme_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 )
{
//ServersThink( time );
//GetClientVoiceMgr()->Frame(time);
}
/*
==========================
HUD_VoiceStatus
Called when a player starts or stops talking.
==========================
*/
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
{
//GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
}
/*
==========================
HUD_DirectorEvent
Called when a director event message was received
==========================
*/
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
{
gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
}
/*
==========================
HUD_GetRenderInterface
Called when Xash3D sends render api to us
==========================
*/
int DLLEXPORT HUD_GetRenderInterface( int version, render_api_t *renderfuncs, render_interface_t *callback )
{
if( version != CL_RENDER_INTERFACE_VERSION )
{
return false;
}
gRenderAPI = *renderfuncs;
// we didn't send callbacks to engine, because we don't use it
// *callback = renderInterface;
return true;
}
/*
========================
HUD_MobilityInterface
========================
*/
int DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *mobileapi )
{
if( mobileapi->version != MOBILITY_API_VERSION )
{
gEngfuncs.Con_Printf("Client Error: Mobile API version mismatch. Got: %i, want: %i\n", mobileapi->version, MOBILITY_API_VERSION);
return 1;
}
gMobileAPI = *mobileapi;
return 0;
}

View File

@ -1,292 +1,292 @@
/***
*
* 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;
static int g_currentweapon;
/*
=====================
HUD_SendWeaponAnim
Change weapon model animation
=====================
*/
void HUD_SendWeaponAnim( int iAnim, int iWeaponId, int iBody, int iForce )
{
// Don't actually change it.
if ( !g_runfuncs && !iForce )
return;
g_currentanim = iAnim;
g_currentweapon = iWeaponId;
// Tell animation system new info
gEngfuncs.pfnWeaponAnim( iAnim, iBody );
}
/*
=====================
HUD_GetWeaponAnim
Retrieve current predicted weapon animation
=====================
*/
int HUD_GetWeaponAnim( void )
{
return g_currentanim;
}
/*
=====================
HUD_GetWeapon
Retrieve current predicted weapon id
=====================
*/
int HUD_GetWeapon( void )
{
return g_currentweapon;
}
/*
=====================
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 int 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;
static int g_currentweapon;
/*
=====================
HUD_SendWeaponAnim
Change weapon model animation
=====================
*/
void HUD_SendWeaponAnim( int iAnim, int iWeaponId, int iBody, int iForce )
{
// Don't actually change it.
if ( !g_runfuncs && !iForce )
return;
g_currentanim = iAnim;
g_currentweapon = iWeaponId;
// Tell animation system new info
gEngfuncs.pfnWeaponAnim( iAnim, iBody );
}
/*
=====================
HUD_GetWeaponAnim
Retrieve current predicted weapon animation
=====================
*/
int HUD_GetWeaponAnim( void )
{
return g_currentanim;
}
/*
=====================
HUD_GetWeapon
Retrieve current predicted weapon id
=====================
*/
int HUD_GetWeapon( void )
{
return g_currentweapon;
}
/*
=====================
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 int function ) { return "func"; }
void stub_SetModel ( edict_t *e, const char *m ) {}

View File

@ -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.
*
****/
// 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 int 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 int function ) { return "func"; }
void stub_SetModel ( edict_t *e, const char *m ) {}

View File

@ -1,284 +1,284 @@
/***
*
* 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 "port.h"
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "player.h"
#include "weapons.h"
#include "nodes.h"
#include "soundent.h"
#include "skill.h"
// Globals used by game logic
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 ) { }
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 ) { }
CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName) { return 0; }
// CBaseToggle Stubs
int CBaseToggle::Restore( class CRestore & ) { return 1; }
int CBaseToggle::Save( class CSave & ) { return 1; }
void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { }
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 :: Look ( int iDistance ) { }
float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; }
int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) { return 0; }
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::ChangeYaw ( int yawSpeed ) { return 0; }
int CBaseAnimating :: LookupActivity ( int activity ) { return 0; }
int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; }
int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; }
void CBaseAnimating :: ResetSequenceInfo ( ) { }
BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; }
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { }
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; }
void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, const 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 ) { }
void CBaseMonster::ReportAIState( void ) { }
void CBaseMonster :: KeyValue( KeyValueData *pkvd ) { }
BOOL CBaseMonster :: FCheckAITrigger ( void ) { return FALSE; }
void CBaseMonster::CorpseFallThink( void ) { }
void CBaseMonster :: MonsterInitDead( void ) { }
void CBaseMonster :: TraceAttack(entvars_t *pevAttacker, float flDamage, const Vector &vecDir, TraceResult *ptr, int bitsDamageType) { }
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; }
void CBaseMonster::BecomeDead( 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 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, const Vector &vecDir, TraceResult *ptr, int bitsDamageType) { }
int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
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::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 ( const char *pszItemName ) { }
BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; }
BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; }
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 ) { }
// CS16 START
void CBasePlayer::Restart( ) { }
void CBasePlayer::ResetMaxSpeed() { }
void CBasePlayer::RoundRespawn() { }
void CBasePlayer::Blind(float flUntilTime, float flHoldTime, float flFadeTime, int iAlpha) { }
void CBasePlayer::SetProgressBarTime( int iTime ) { }
void CBasePlayer::SetBombIcon( int ) { }
void CBasePlayer::UpdateShieldCrosshair(bool bShieldDrawn) { }
void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, int pitch, bool showIcon) { }
void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage) { }
void UTIL_TraceHull(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr) { }
float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType) { return 0.0f; }
void UTIL_ScreenShake(const Vector &center, float amplitude, float frequency, float duration, float radius) { }
void UTIL_Bubbles(Vector mins, Vector maxs, int count) { }
void RemoveEntityHashValue(entvars_s *pev, const char *value, hash_types_e fieldType) { }
void AddEntityHashValue(entvars_s *pev, const char *value, hash_types_e fieldType) { }
int UTIL_PointContents(const Vector &vec) { return 0; }
void UTIL_EmitAmbientSound(edict_t *entity, const Vector &vecOrigin, const char *samp, float vol, float attenuation, int fFlags, int pitch) { }
CGrenade *CGrenade::ShootSatchelCharge(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity) { return 0; }
CGrenade *CGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time) { return 0; }
CGrenade *CGrenade::ShootTimed2(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, int iTeam, unsigned short usEvent) { return 0; }
CGrenade *CGrenade::ShootSmokeGrenade(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, unsigned short usEvent) { return 0; }
// CS16 END
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 DecalGunshot( TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars_t *pShooter, bool bHitMetal ) { }
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 ){}
/***
*
* 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 "port.h"
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "player.h"
#include "weapons.h"
#include "nodes.h"
#include "soundent.h"
#include "skill.h"
// Globals used by game logic
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 ) { }
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 ) { }
CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName) { return 0; }
// CBaseToggle Stubs
int CBaseToggle::Restore( class CRestore & ) { return 1; }
int CBaseToggle::Save( class CSave & ) { return 1; }
void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { }
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 :: Look ( int iDistance ) { }
float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; }
int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) { return 0; }
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::ChangeYaw ( int yawSpeed ) { return 0; }
int CBaseAnimating :: LookupActivity ( int activity ) { return 0; }
int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; }
int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; }
void CBaseAnimating :: ResetSequenceInfo ( ) { }
BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; }
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { }
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; }
void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, const 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 ) { }
void CBaseMonster::ReportAIState( void ) { }
void CBaseMonster :: KeyValue( KeyValueData *pkvd ) { }
BOOL CBaseMonster :: FCheckAITrigger ( void ) { return FALSE; }
void CBaseMonster::CorpseFallThink( void ) { }
void CBaseMonster :: MonsterInitDead( void ) { }
void CBaseMonster :: TraceAttack(entvars_t *pevAttacker, float flDamage, const Vector &vecDir, TraceResult *ptr, int bitsDamageType) { }
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; }
void CBaseMonster::BecomeDead( 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 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, const Vector &vecDir, TraceResult *ptr, int bitsDamageType) { }
int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
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::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 ( const char *pszItemName ) { }
BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; }
BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; }
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 ) { }
// CS16 START
void CBasePlayer::Restart( ) { }
void CBasePlayer::ResetMaxSpeed() { }
void CBasePlayer::RoundRespawn() { }
void CBasePlayer::Blind(float flUntilTime, float flHoldTime, float flFadeTime, int iAlpha) { }
void CBasePlayer::SetProgressBarTime( int iTime ) { }
void CBasePlayer::SetBombIcon( int ) { }
void CBasePlayer::UpdateShieldCrosshair(bool bShieldDrawn) { }
void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, int pitch, bool showIcon) { }
void RadiusFlash(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage) { }
void UTIL_TraceHull(const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr) { }
float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType) { return 0.0f; }
void UTIL_ScreenShake(const Vector &center, float amplitude, float frequency, float duration, float radius) { }
void UTIL_Bubbles(Vector mins, Vector maxs, int count) { }
void RemoveEntityHashValue(entvars_s *pev, const char *value, hash_types_e fieldType) { }
void AddEntityHashValue(entvars_s *pev, const char *value, hash_types_e fieldType) { }
int UTIL_PointContents(const Vector &vec) { return 0; }
void UTIL_EmitAmbientSound(edict_t *entity, const Vector &vecOrigin, const char *samp, float vol, float attenuation, int fFlags, int pitch) { }
CGrenade *CGrenade::ShootSatchelCharge(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity) { return 0; }
CGrenade *CGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time) { return 0; }
CGrenade *CGrenade::ShootTimed2(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, int iTeam, unsigned short usEvent) { return 0; }
CGrenade *CGrenade::ShootSmokeGrenade(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, unsigned short usEvent) { return 0; }
// CS16 END
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 DecalGunshot( TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars_t *pShooter, bool bHitMetal ) { }
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 ){}

View File

@ -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.
*
****/
#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"
/*
=====================
Game_AddObjects
Add game specific, client-side objects here
=====================
*/
void Game_AddObjects( 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.
*
****/
#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"
/*
=====================
Game_AddObjects
Add game specific, client-side objects here
=====================
*/
void Game_AddObjects( void )
{
}

File diff suppressed because it is too large Load Diff

View File

@ -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.
*
****/
#include "hud.h"
#include "cl_util.h"
#include "demo.h"
#include "demo_api.h"
#include <memory.h>
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
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>
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,204 +1,204 @@
/***
*
* 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;
Vector view_ofs(0, 0, 0);
idx = args->entindex;
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, int life )
{
vec3_t endpos;
VectorClear( endpos );
endpos[1] = rotation;
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, life, 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;
Vector view_ofs(0, 0, 0);
idx = args->entindex;
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, int life )
{
vec3_t endpos;
VectorClear( endpos );
endpos[1] = rotation;
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, life, 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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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();
}

File diff suppressed because it is too large Load Diff

View File

@ -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.
*
****/
#include "events.h"
/*
======================
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 )
{
HOOK_EVENT( ak47, FireAK47 );
HOOK_EVENT( aug, FireAUG );
HOOK_EVENT( awp, FireAWP );
HOOK_EVENT( createexplo, CreateExplo );
HOOK_EVENT( createsmoke, CreateSmoke );
HOOK_EVENT( deagle, FireDEAGLE );
HOOK_EVENT( decal_reset, DecalReset );
HOOK_EVENT( elite_left, FireEliteLeft );
HOOK_EVENT( elite_right, FireEliteRight );
HOOK_EVENT( famas, FireFAMAS );
HOOK_EVENT( fiveseven, Fire57 );
HOOK_EVENT( g3sg1, FireG3SG1 );
HOOK_EVENT( galil, FireGALIL );
HOOK_EVENT( glock18, Fireglock18 );
HOOK_EVENT( knife, Knife );
HOOK_EVENT( m249, FireM249 );
HOOK_EVENT( m3, FireM3 );
HOOK_EVENT( m4a1, FireM4A1 );
HOOK_EVENT( mac10, FireMAC10 );
HOOK_EVENT( mp5n, FireMP5 );
HOOK_EVENT( p228, FireP228 );
HOOK_EVENT( p90, FireP90 );
HOOK_EVENT( scout, FireScout );
HOOK_EVENT( sg550, FireSG550 );
HOOK_EVENT( sg552, FireSG552 );
HOOK_EVENT( tmp, FireTMP );
HOOK_EVENT( ump45, FireUMP45 );
HOOK_EVENT( usp, FireUSP );
HOOK_EVENT( vehicle, Vehicle );
HOOK_EVENT( xm1014, FireXM1014 );
}
/***
*
* 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 "events.h"
/*
======================
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 )
{
HOOK_EVENT( ak47, FireAK47 );
HOOK_EVENT( aug, FireAUG );
HOOK_EVENT( awp, FireAWP );
HOOK_EVENT( createexplo, CreateExplo );
HOOK_EVENT( createsmoke, CreateSmoke );
HOOK_EVENT( deagle, FireDEAGLE );
HOOK_EVENT( decal_reset, DecalReset );
HOOK_EVENT( elite_left, FireEliteLeft );
HOOK_EVENT( elite_right, FireEliteRight );
HOOK_EVENT( famas, FireFAMAS );
HOOK_EVENT( fiveseven, Fire57 );
HOOK_EVENT( g3sg1, FireG3SG1 );
HOOK_EVENT( galil, FireGALIL );
HOOK_EVENT( glock18, Fireglock18 );
HOOK_EVENT( knife, Knife );
HOOK_EVENT( m249, FireM249 );
HOOK_EVENT( m3, FireM3 );
HOOK_EVENT( m4a1, FireM4A1 );
HOOK_EVENT( mac10, FireMAC10 );
HOOK_EVENT( mp5n, FireMP5 );
HOOK_EVENT( p228, FireP228 );
HOOK_EVENT( p90, FireP90 );
HOOK_EVENT( scout, FireScout );
HOOK_EVENT( sg550, FireSG550 );
HOOK_EVENT( sg552, FireSG552 );
HOOK_EVENT( tmp, FireTMP );
HOOK_EVENT( ump45, FireUMP45 );
HOOK_EVENT( usp, FireUSP );
HOOK_EVENT( vehicle, Vehicle );
HOOK_EVENT( xm1014, FireXM1014 );
}

File diff suppressed because it is too large Load Diff

View File

@ -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;
DrawUtils::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
DrawUtils::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 -= (DrawUtils::GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
DrawUtils::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;
DrawUtils::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
DrawUtils::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 -= (DrawUtils::GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
DrawUtils::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;
}

View File

@ -1,191 +1,191 @@
/***
*
* 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 (gHUD.m_iFontHeight * 3 + (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 = gHUD.m_Ammo.m_pHud_DrawHistory_Time->value;
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
// I am too, -- a1batross
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 = gHUD.m_Ammo.m_pHud_DrawHistory_Time->value;
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;
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::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 );
}
// Draw the number
DrawUtils::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;
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
if ( !gWR.HasAmmo( weap ) )
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::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 );
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::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;
}
/***
*
* 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 (gHUD.m_iFontHeight * 3 + (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 = gHUD.m_Ammo.m_pHud_DrawHistory_Time->value;
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
// I am too, -- a1batross
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 = gHUD.m_Ammo.m_pHud_DrawHistory_Time->value;
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;
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::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 );
}
// Draw the number
DrawUtils::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;
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
if ( !gWR.HasAmmo( weap ) )
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::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 );
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::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;
}

View File

@ -1,298 +1,298 @@
/***
*
* 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>
float color[3];
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
bool bSuicide;
bool bTeamKill;
bool bNonPlayerKill;
float flDisplayTime;
float *KillerColor;
float *VictimColor;
int iHeadShotId;
};
#define MAX_DEATHNOTICES 4
static int DEATHNOTICE_DISPLAY_TIME = 6;
#define DEATHNOTICE_TOP 32
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
int CHudDeathNotice :: Init( void )
{
gHUD.AddHudElem( this );
HOOK_MESSAGE( DeathMsg );
hud_deathnotice_time = 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" );
m_HUD_d_headshot = gHUD.GetSpriteIndex("d_headshot");
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 );
// Hide when scoreboard drawing. It will break triapi
//if ( gViewPort && gViewPort->AllowedToPrintText() )
//if ( !gHUD.m_iNoConsolePrint )
{
// 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 - DrawUtils::ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
if( rgDeathNoticeList[i].iHeadShotId )
x -= gHUD.GetSpriteRect(m_HUD_d_headshot).right - gHUD.GetSpriteRect(m_HUD_d_headshot).left;
if ( !rgDeathNoticeList[i].bSuicide )
{
x -= (5 + DrawUtils::ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
// Draw killers name
if ( rgDeathNoticeList[i].KillerColor )
DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
x = 5 + DrawUtils::DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
}
r = 255; g = 80; b = 0;
if ( rgDeathNoticeList[i].bTeamKill )
{
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);
if( rgDeathNoticeList[i].iHeadShotId)
{
SPR_Set( gHUD.GetSprite(m_HUD_d_headshot), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_d_headshot));
x += (gHUD.GetSpriteRect(m_HUD_d_headshot).right - gHUD.GetSpriteRect(m_HUD_d_headshot).left);
}
// Draw victims name (if it was a player that was killed)
if (!rgDeathNoticeList[i].bNonPlayerKill)
{
if ( rgDeathNoticeList[i].VictimColor )
DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
x = DrawUtils::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 )
{
m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize );
int killer = READ_BYTE();
int victim = READ_BYTE();
int headshot = READ_BYTE();
char killedwith[32];
strncpy( killedwith, "d_", sizeof(killedwith) );
strncat( killedwith, READ_STRING(), sizeof(killedwith) );
//if (gViewPort)
// gViewPort->DeathMsg( killer, victim );
gHUD.m_Scoreboard.DeathMsg( killer, victim );
gHUD.m_Spectator.DeathMessage(victim);
int i;
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].bNonPlayerKill = true;
// Store the object's name in the Victim slot (skip the d_ bit)
strncpy( rgDeathNoticeList[i].szVictim, killedwith+2, sizeof(killedwith) );
}
else
{
if ( killer == victim || killer == 0 )
rgDeathNoticeList[i].bSuicide = true;
if ( !strncmp( killedwith, "d_teammate", sizeof(killedwith) ) )
rgDeathNoticeList[i].bTeamKill = true;
}
rgDeathNoticeList[i].iHeadShotId = headshot;
// Find the sprite in the list
int spr = gHUD.GetSpriteIndex( killedwith );
rgDeathNoticeList[i].iId = spr;
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + hud_deathnotice_time->value;
if (rgDeathNoticeList[i].bNonPlayerKill)
{
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed a " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
ConsolePrint( "\n" );
}
else
{
// record the death notice in the console
if ( rgDeathNoticeList[i].bSuicide )
{
ConsolePrint( rgDeathNoticeList[i].szVictim );
if ( !strncmp( killedwith, "d_world", sizeof(killedwith) ) )
{
ConsolePrint( " died" );
}
else
{
ConsolePrint( " killed self" );
}
}
else if ( rgDeathNoticeList[i].bTeamKill )
{
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed his teammate " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
}
else
{
if( headshot )
ConsolePrint( "*** ");
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
}
if ( killedwith && *killedwith && (*killedwith > 13 ) && strncmp( killedwith, "d_world", sizeof(killedwith) ) && !rgDeathNoticeList[i].bTeamKill )
{
if ( headshot )
ConsolePrint(" with a headshot from ");
else
ConsolePrint(" with ");
ConsolePrint( killedwith+2 ); // skip over the "d_" part
}
if( headshot ) ConsolePrint( " ***");
ConsolePrint( "\n" );
}
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.
*
****/
//
// death notice
//
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include <string.h>
#include <stdio.h>
float color[3];
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
bool bSuicide;
bool bTeamKill;
bool bNonPlayerKill;
float flDisplayTime;
float *KillerColor;
float *VictimColor;
int iHeadShotId;
};
#define MAX_DEATHNOTICES 4
static int DEATHNOTICE_DISPLAY_TIME = 6;
#define DEATHNOTICE_TOP 32
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
int CHudDeathNotice :: Init( void )
{
gHUD.AddHudElem( this );
HOOK_MESSAGE( DeathMsg );
hud_deathnotice_time = 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" );
m_HUD_d_headshot = gHUD.GetSpriteIndex("d_headshot");
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 );
// Hide when scoreboard drawing. It will break triapi
//if ( gViewPort && gViewPort->AllowedToPrintText() )
//if ( !gHUD.m_iNoConsolePrint )
{
// 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 - DrawUtils::ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
if( rgDeathNoticeList[i].iHeadShotId )
x -= gHUD.GetSpriteRect(m_HUD_d_headshot).right - gHUD.GetSpriteRect(m_HUD_d_headshot).left;
if ( !rgDeathNoticeList[i].bSuicide )
{
x -= (5 + DrawUtils::ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
// Draw killers name
if ( rgDeathNoticeList[i].KillerColor )
DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
x = 5 + DrawUtils::DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
}
r = 255; g = 80; b = 0;
if ( rgDeathNoticeList[i].bTeamKill )
{
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);
if( rgDeathNoticeList[i].iHeadShotId)
{
SPR_Set( gHUD.GetSprite(m_HUD_d_headshot), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_d_headshot));
x += (gHUD.GetSpriteRect(m_HUD_d_headshot).right - gHUD.GetSpriteRect(m_HUD_d_headshot).left);
}
// Draw victims name (if it was a player that was killed)
if (!rgDeathNoticeList[i].bNonPlayerKill)
{
if ( rgDeathNoticeList[i].VictimColor )
DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
x = DrawUtils::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 )
{
m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize );
int killer = READ_BYTE();
int victim = READ_BYTE();
int headshot = READ_BYTE();
char killedwith[32];
strncpy( killedwith, "d_", sizeof(killedwith) );
strncat( killedwith, READ_STRING(), sizeof(killedwith) );
//if (gViewPort)
// gViewPort->DeathMsg( killer, victim );
gHUD.m_Scoreboard.DeathMsg( killer, victim );
gHUD.m_Spectator.DeathMessage(victim);
int i;
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].bNonPlayerKill = true;
// Store the object's name in the Victim slot (skip the d_ bit)
strncpy( rgDeathNoticeList[i].szVictim, killedwith+2, sizeof(killedwith) );
}
else
{
if ( killer == victim || killer == 0 )
rgDeathNoticeList[i].bSuicide = true;
if ( !strncmp( killedwith, "d_teammate", sizeof(killedwith) ) )
rgDeathNoticeList[i].bTeamKill = true;
}
rgDeathNoticeList[i].iHeadShotId = headshot;
// Find the sprite in the list
int spr = gHUD.GetSpriteIndex( killedwith );
rgDeathNoticeList[i].iId = spr;
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + hud_deathnotice_time->value;
if (rgDeathNoticeList[i].bNonPlayerKill)
{
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed a " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
ConsolePrint( "\n" );
}
else
{
// record the death notice in the console
if ( rgDeathNoticeList[i].bSuicide )
{
ConsolePrint( rgDeathNoticeList[i].szVictim );
if ( !strncmp( killedwith, "d_world", sizeof(killedwith) ) )
{
ConsolePrint( " died" );
}
else
{
ConsolePrint( " killed self" );
}
}
else if ( rgDeathNoticeList[i].bTeamKill )
{
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed his teammate " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
}
else
{
if( headshot )
ConsolePrint( "*** ");
ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed " );
ConsolePrint( rgDeathNoticeList[i].szVictim );
}
if ( killedwith && *killedwith && (*killedwith > 13 ) && strncmp( killedwith, "d_world", sizeof(killedwith) ) && !rgDeathNoticeList[i].bTeamKill )
{
if ( headshot )
ConsolePrint(" with a headshot from ");
else
ConsolePrint(" with ");
ConsolePrint( killedwith+2 ); // skip over the "d_" part
}
if( headshot ) ConsolePrint( " ***");
ConsolePrint( "\n" );
}
return 1;
}

View File

@ -1,139 +1,139 @@
/***
*
* 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)
{
m_hSprite1.SetSpriteByName("flash_empty");
m_hSprite2.SetSpriteByName("flash_full");
m_hBeam.SetSpriteByName("flash_beam");
m_iWidth = m_hSprite1.rect.right - m_hSprite1.rect.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)
{
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
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)
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH);
else
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
DrawUtils::ScaleColors(r, g, b, a);
y = (m_hSprite1.rect.bottom - m_hSprite1.rect.top)/2;
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
// Draw the flashlight casing
SPR_Set(m_hSprite1.spr, r, g, b );
SPR_DrawAdditive( 0, x, y, &m_hSprite1.rect);
if ( m_fOn )
{ // draw the flashlight beam
x = ScreenWidth - m_iWidth/2;
SPR_Set( m_hBeam.spr, r, g, b );
SPR_DrawAdditive( 0, x, y, &m_hBeam.rect );
}
// 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_hSprite2.rect;
rc.left += iOffset;
SPR_Set(m_hSprite2.spr, r, g, b );
SPR_DrawAdditive( 0, x + iOffset, y, &rc);
}
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.
*
****/
//
// 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)
{
m_hSprite1.SetSpriteByName("flash_empty");
m_hSprite2.SetSpriteByName("flash_full");
m_hBeam.SetSpriteByName("flash_beam");
m_iWidth = m_hSprite1.rect.right - m_hSprite1.rect.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)
{
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
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)
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH);
else
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
DrawUtils::ScaleColors(r, g, b, a);
y = (m_hSprite1.rect.bottom - m_hSprite1.rect.top)/2;
x = ScreenWidth - m_iWidth - m_iWidth/2 ;
// Draw the flashlight casing
SPR_Set(m_hSprite1.spr, r, g, b );
SPR_DrawAdditive( 0, x, y, &m_hSprite1.rect);
if ( m_fOn )
{ // draw the flashlight beam
x = ScreenWidth - m_iWidth/2;
SPR_Set( m_hBeam.spr, r, g, b );
SPR_DrawAdditive( 0, x, y, &m_hBeam.rect );
}
// 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_hSprite2.rect;
rc.left += iOffset;
SPR_Set(m_hSprite2.spr, r, g, b );
SPR_DrawAdditive( 0, x + iOffset, y, &rc);
}
return 1;
}

View File

@ -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;
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;
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;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,215 +1,215 @@
/***
*
* 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"
#include "rain.h"
#include "com_model.h"
#include "studio.h"
#include "studio_util.h"
#include "StudioModelRenderer.h"
#include "GameStudioModelRenderer.h"
#include "com_weapons.h"
#include <cstring>
#define MAX_CLIENTS 32
extern float g_flRoundTime;
/// 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);
int CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{
CAM_ToFirstPerson();
return 1;
}
int 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;
}
g_iFreezeTimeOver = 0;
memset( g_PlayerExtraInfo, 0, sizeof(g_PlayerExtraInfo) );
ResetRain();
// reset round time
g_flRoundTime = 0.0f;
return 1;
}
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
m_Teamplay = READ_BYTE();
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;
}
int CHud::MsgFunc_ReceiveW(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int iWeatherType = READ_BYTE();
if( iWeatherType == 0 )
{
ResetRain();
return 1;
}
Rain.distFromPlayer = 500;
Rain.dripsPerSecond = 500;
Rain.windX = Rain.windY = 30;
Rain.randX = Rain.randY = 0;
Rain.weatherMode = iWeatherType - 1;
Rain.globalHeight = 100;
return 1;
}
int CHud::MsgFunc_BombDrop(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
g_PlayerExtraInfo[33].origin.x = READ_COORD();
g_PlayerExtraInfo[33].origin.y = READ_COORD();
g_PlayerExtraInfo[33].origin.z = READ_COORD();
g_PlayerExtraInfo[33].radarflashon = 1;
g_PlayerExtraInfo[33].radarflashes = 99999;
g_PlayerExtraInfo[33].radarflash = gHUD.m_flTime;
strncpy(g_PlayerExtraInfo[33].teamname, "TERRORIST", MAX_TEAM_NAME);
g_PlayerExtraInfo[33].dead = 0;
g_PlayerExtraInfo[33].nextflash = true;
int Flag = READ_BYTE();
g_PlayerExtraInfo[33].playerclass = Flag;
if( Flag ) // bomb planted
m_Timer.m_iFlags = 0;
return 1;
}
int CHud::MsgFunc_BombPickup(const char *pszName, int iSize, void *pbuf)
{
g_PlayerExtraInfo[33].radarflashon = 0;
g_PlayerExtraInfo[33].radarflash = 0.0f;
g_PlayerExtraInfo[33].radarflashes = 0;
g_PlayerExtraInfo[33].dead = 1;
return 1;
}
int CHud::MsgFunc_HostagePos(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int Flag = READ_BYTE();
int idx = READ_BYTE();
if ( idx <= MAX_HOSTAGES )
{
g_HostageInfo[idx].origin.x = READ_COORD();
g_HostageInfo[idx].origin.y = READ_COORD();
g_HostageInfo[idx].origin.z = READ_COORD();
if ( Flag == 1 )
{
g_HostageInfo[idx].radarflash = gHUD.m_flTime;
g_HostageInfo[idx].radarflashon = 1;
g_HostageInfo[idx].radarflashes = 99999;
}
strncpy(g_HostageInfo[idx].teamname, "CT", MAX_TEAM_NAME);
g_HostageInfo[idx].dead = 0;
}
return 1;
}
int CHud::MsgFunc_HostageK(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE();
if ( idx <= MAX_HOSTAGES )
{
g_HostageInfo[idx].dead = 1;
g_HostageInfo[idx].radarflash = gHUD.m_flTime;
g_HostageInfo[idx].radarflashes = 15;
}
return 1;
}
int CHud::MsgFunc_ShadowIdx(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE();
g_StudioRenderer.StudioSetShadowSprite(idx);
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"
#include "rain.h"
#include "com_model.h"
#include "studio.h"
#include "studio_util.h"
#include "StudioModelRenderer.h"
#include "GameStudioModelRenderer.h"
#include "com_weapons.h"
#include <cstring>
#define MAX_CLIENTS 32
extern float g_flRoundTime;
/// 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);
int CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{
CAM_ToFirstPerson();
return 1;
}
int 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;
}
g_iFreezeTimeOver = 0;
memset( g_PlayerExtraInfo, 0, sizeof(g_PlayerExtraInfo) );
ResetRain();
// reset round time
g_flRoundTime = 0.0f;
return 1;
}
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
m_Teamplay = READ_BYTE();
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;
}
int CHud::MsgFunc_ReceiveW(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int iWeatherType = READ_BYTE();
if( iWeatherType == 0 )
{
ResetRain();
return 1;
}
Rain.distFromPlayer = 500;
Rain.dripsPerSecond = 500;
Rain.windX = Rain.windY = 30;
Rain.randX = Rain.randY = 0;
Rain.weatherMode = iWeatherType - 1;
Rain.globalHeight = 100;
return 1;
}
int CHud::MsgFunc_BombDrop(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
g_PlayerExtraInfo[33].origin.x = READ_COORD();
g_PlayerExtraInfo[33].origin.y = READ_COORD();
g_PlayerExtraInfo[33].origin.z = READ_COORD();
g_PlayerExtraInfo[33].radarflashon = 1;
g_PlayerExtraInfo[33].radarflashes = 99999;
g_PlayerExtraInfo[33].radarflash = gHUD.m_flTime;
strncpy(g_PlayerExtraInfo[33].teamname, "TERRORIST", MAX_TEAM_NAME);
g_PlayerExtraInfo[33].dead = 0;
g_PlayerExtraInfo[33].nextflash = true;
int Flag = READ_BYTE();
g_PlayerExtraInfo[33].playerclass = Flag;
if( Flag ) // bomb planted
m_Timer.m_iFlags = 0;
return 1;
}
int CHud::MsgFunc_BombPickup(const char *pszName, int iSize, void *pbuf)
{
g_PlayerExtraInfo[33].radarflashon = 0;
g_PlayerExtraInfo[33].radarflash = 0.0f;
g_PlayerExtraInfo[33].radarflashes = 0;
g_PlayerExtraInfo[33].dead = 1;
return 1;
}
int CHud::MsgFunc_HostagePos(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int Flag = READ_BYTE();
int idx = READ_BYTE();
if ( idx <= MAX_HOSTAGES )
{
g_HostageInfo[idx].origin.x = READ_COORD();
g_HostageInfo[idx].origin.y = READ_COORD();
g_HostageInfo[idx].origin.z = READ_COORD();
if ( Flag == 1 )
{
g_HostageInfo[idx].radarflash = gHUD.m_flTime;
g_HostageInfo[idx].radarflashon = 1;
g_HostageInfo[idx].radarflashes = 99999;
}
strncpy(g_HostageInfo[idx].teamname, "CT", MAX_TEAM_NAME);
g_HostageInfo[idx].dead = 0;
}
return 1;
}
int CHud::MsgFunc_HostageK(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE();
if ( idx <= MAX_HOSTAGES )
{
g_HostageInfo[idx].dead = 1;
g_HostageInfo[idx].radarflash = gHUD.m_flTime;
g_HostageInfo[idx].radarflashes = 15;
}
return 1;
}
int CHud::MsgFunc_ShadowIdx(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE();
g_StudioRenderer.StudioSetShadowSprite(idx);
return 1;
}

View File

@ -1,175 +1,175 @@
/***
*
* 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"
#include <string.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 int m_flShotTime = 0;
// Clock was reset, reset delta
if ( m_flTimeDelta < 0 )
m_flTimeDelta = 0;
// Bring up the scoreboard during intermission
/*if (gViewPort)
{
if ( m_iIntermission && !intermission )
{
// Have to do this here so the scoreboard goes away
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
gViewPort->HideScoreBoard();
gViewPort->UpdateSpectatorPanel();
}
else if ( !m_iIntermission && intermission )
{
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
gViewPort->HideVGUIMenu();
gViewPort->ShowScoreBoard();
gViewPort->UpdateSpectatorPanel();
// Take a screenshot if the client's got the cvar set
if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
}
}*/
if (m_flShotTime && m_flShotTime < flTime)
{
gEngfuncs.pfnClientCmd("snapshot\n");
m_flShotTime = 0;
}
m_iIntermission = intermission;
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);
}
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_redraw.cpp
//
#include <math.h>
#include "hud.h"
#include "cl_util.h"
#include "triangleapi.h"
#include <string.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 int m_flShotTime = 0;
// Clock was reset, reset delta
if ( m_flTimeDelta < 0 )
m_flTimeDelta = 0;
// Bring up the scoreboard during intermission
/*if (gViewPort)
{
if ( m_iIntermission && !intermission )
{
// Have to do this here so the scoreboard goes away
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
gViewPort->HideScoreBoard();
gViewPort->UpdateSpectatorPanel();
}
else if ( !m_iIntermission && intermission )
{
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
gViewPort->HideVGUIMenu();
gViewPort->ShowScoreBoard();
gViewPort->UpdateSpectatorPanel();
// Take a screenshot if the client's got the cvar set
if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
}
}*/
if (m_flShotTime && m_flShotTime < flTime)
{
gEngfuncs.pfnClientCmd("snapshot\n");
m_flShotTime = 0;
}
m_iIntermission = intermission;
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);
}
return 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -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;
}

View File

@ -1,356 +1,356 @@
/***
*
* 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>
//#include "vgui_TeamFortressViewport.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 );
DECLARE_MESSAGE( m_Menu, VGUIMenu );
DECLARE_MESSAGE( m_Menu, BuyClose );
DECLARE_MESSAGE( m_Menu, AllowSpec );
DECLARE_COMMAND( m_Menu, OldStyleMenuOpen );
DECLARE_COMMAND( m_Menu, OldStyleMenuClose );
DECLARE_COMMAND( m_Menu, ShowVGUIMenu );
int CHudMenu :: Init( void )
{
gHUD.AddHudElem( this );
HOOK_MESSAGE( ShowMenu );
HOOK_MESSAGE( VGUIMenu );
HOOK_MESSAGE( BuyClose );
HOOK_MESSAGE( AllowSpec );
HOOK_COMMAND( "client_buy_open", OldStyleMenuOpen );
HOOK_COMMAND( "client_buy_close", OldStyleMenuClose );
HOOK_COMMAND( "showvguimenu", ShowVGUIMenu );
_extended_menus = CVAR_CREATE("_extended_menus", "0", FCVAR_ARCHIVE);
InitHUDData();
m_bAllowSpec = true; // by default, spectating is allowed
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 )
{
// 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
//if ( gViewPort && gViewPort->IsScoreBoardVisible() )
//return 1;
// draw the menu, along the left-hand side of the screen
// count the number of newlines
int nlc = 0;
int i;
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' )
{
DrawUtils::DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
y += 24;
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, *menustring;
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 )
{
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
m_iFlags &= ~HUD_ACTIVE;
ClientCmd("touch_removebutton _menu_*");
return 1;
}
menustring = READ_STRING();
// menu will be replaced by scripted touch config
// so execute it and exit
if( _extended_menus->value != 0.0f )
{
if( !strcmp(menustring, "#RadioA") )
{
ShowVGUIMenu(MENU_RADIOA);
return 1;
}
else if( !strcmp(menustring, "#RadioB"))
{
ShowVGUIMenu(MENU_RADIOB);
return 1;
}
else if( !strcmp(menustring, "#RadioC"))
{
ShowVGUIMenu(MENU_RADIOC);
return 1;
}
}
if ( !m_fWaitingForMore ) // this is the start of a new menu
{
strncpy( g_szPrelocalisedMenuString, menustring, MAX_MENU_STRING );
}
else
{ // append to the current menu string
strncat( g_szPrelocalisedMenuString, menustring, 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
strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING );
// Swap in characters
if ( KB_ConvertString( g_szMenuString, &temp ) )
{
strncpy( g_szMenuString, temp, MAX_MENU_STRING );
free( temp );
}
}
m_fMenuDisplayed = 1;
m_iFlags |= HUD_ACTIVE;
m_fWaitingForMore = NeedMore;
return 1;
}
int CHudMenu::MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ(pbuf, iSize);
int menuType = READ_BYTE();
m_bitsValidSlots = READ_SHORT(); // is ignored
ShowVGUIMenu(menuType);
return 1;
}
int CHudMenu::MsgFunc_BuyClose(const char *pszName, int iSize, void *pbuf)
{
UserCmd_OldStyleMenuClose();
ClientCmd("touch_removebutton _menu_*");
return 1;
}
int CHudMenu::MsgFunc_AllowSpec(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_bAllowSpec = !!READ_BYTE();
return 1;
}
void CHudMenu::UserCmd_OldStyleMenuOpen()
{
m_flShutoffTime = -1; // stay open until user will not close it
strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString("Buy"), MAX_MENU_STRING );
}
void CHudMenu::UserCmd_OldStyleMenuClose()
{
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
m_iFlags &= ~HUD_ACTIVE;
ClientCmd("touch_removebutton _menu_*");
}
// lol, no real VGUI here
// it's really good only for touchscreen
void CHudMenu::ShowVGUIMenu( int menuType )
{
char *szCmd;
switch(menuType)
{
case MENU_TEAM:
szCmd = "exec touch/chooseteam.cfg";
break;
case MENU_CLASS_T:
szCmd = "exec touch/chooseteam_tr.cfg";
break;
case MENU_CLASS_CT:
szCmd = "exec touch/chooseteam_ct.cfg";
break;
case MENU_BUY:
szCmd = "exec touch/buy.cfg";
break;
case MENU_BUY_PISTOL:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_pistol_t.cfg";
else szCmd = "exec touch/buy_pistol_ct.cfg";
break;
case MENU_BUY_SHOTGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_shotgun_t.cfg";
else szCmd = "exec touch/buy_shotgun_ct.cfg";
break;
case MENU_BUY_RIFLE:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_rifle_t.cfg";
else szCmd ="exec touch/buy_rifle_ct.cfg";
break;
case MENU_BUY_SUBMACHINEGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_submachinegun_t.cfg";
else szCmd = "exec touch/buy_submachinegun_ct.cfg";
break;
case MENU_BUY_MACHINEGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == 1 )
szCmd = "exec touch/buy_machinegun_t.cfg";
else szCmd = "exec touch/buy_machinegun_ct.cfg";
break;
case MENU_BUY_ITEM:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == 1 )
szCmd = "exec touch/buy_item_t.cfg";
else szCmd = "exec touch/buy_item_ct.cfg";
break;
case MENU_RADIOA:
szCmd = "exec touch/radioa.cfg";
break;
case MENU_RADIOB:
szCmd = "exec touch/radiob.cfg";
break;
case MENU_RADIOC:
szCmd = "exec touch/radioc.cfg";
break;
case MENU_RADIOSELECTOR:
szCmd = "exec touch/radioselector.cfg";
break;
default:
szCmd = "touch_removebutton _menu_*"; // back to the default touch page
m_fMenuDisplayed = 0;
break;
}
m_fMenuDisplayed = 1;
ClientCmd(szCmd);
}
void CHudMenu::UserCmd_ShowVGUIMenu()
{
if( gEngfuncs.Cmd_Argc() != 1 )
{
ConsolePrint("usage: showvguimenu <menuType>\n");
}
if( gEngfuncs.pfnGetCvarFloat("_vgui_menus") == 0.0f )
return;
int menuType = atoi(gEngfuncs.Cmd_Argv(1));
ShowVGUIMenu(menuType);
}
/***
*
* 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>
//#include "vgui_TeamFortressViewport.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 );
DECLARE_MESSAGE( m_Menu, VGUIMenu );
DECLARE_MESSAGE( m_Menu, BuyClose );
DECLARE_MESSAGE( m_Menu, AllowSpec );
DECLARE_COMMAND( m_Menu, OldStyleMenuOpen );
DECLARE_COMMAND( m_Menu, OldStyleMenuClose );
DECLARE_COMMAND( m_Menu, ShowVGUIMenu );
int CHudMenu :: Init( void )
{
gHUD.AddHudElem( this );
HOOK_MESSAGE( ShowMenu );
HOOK_MESSAGE( VGUIMenu );
HOOK_MESSAGE( BuyClose );
HOOK_MESSAGE( AllowSpec );
HOOK_COMMAND( "client_buy_open", OldStyleMenuOpen );
HOOK_COMMAND( "client_buy_close", OldStyleMenuClose );
HOOK_COMMAND( "showvguimenu", ShowVGUIMenu );
_extended_menus = CVAR_CREATE("_extended_menus", "0", FCVAR_ARCHIVE);
InitHUDData();
m_bAllowSpec = true; // by default, spectating is allowed
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 )
{
// 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
//if ( gViewPort && gViewPort->IsScoreBoardVisible() )
//return 1;
// draw the menu, along the left-hand side of the screen
// count the number of newlines
int nlc = 0;
int i;
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' )
{
DrawUtils::DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
y += 24;
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, *menustring;
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 )
{
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
m_iFlags &= ~HUD_ACTIVE;
ClientCmd("touch_removebutton _menu_*");
return 1;
}
menustring = READ_STRING();
// menu will be replaced by scripted touch config
// so execute it and exit
if( _extended_menus->value != 0.0f )
{
if( !strcmp(menustring, "#RadioA") )
{
ShowVGUIMenu(MENU_RADIOA);
return 1;
}
else if( !strcmp(menustring, "#RadioB"))
{
ShowVGUIMenu(MENU_RADIOB);
return 1;
}
else if( !strcmp(menustring, "#RadioC"))
{
ShowVGUIMenu(MENU_RADIOC);
return 1;
}
}
if ( !m_fWaitingForMore ) // this is the start of a new menu
{
strncpy( g_szPrelocalisedMenuString, menustring, MAX_MENU_STRING );
}
else
{ // append to the current menu string
strncat( g_szPrelocalisedMenuString, menustring, 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
strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING );
// Swap in characters
if ( KB_ConvertString( g_szMenuString, &temp ) )
{
strncpy( g_szMenuString, temp, MAX_MENU_STRING );
free( temp );
}
}
m_fMenuDisplayed = 1;
m_iFlags |= HUD_ACTIVE;
m_fWaitingForMore = NeedMore;
return 1;
}
int CHudMenu::MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ(pbuf, iSize);
int menuType = READ_BYTE();
m_bitsValidSlots = READ_SHORT(); // is ignored
ShowVGUIMenu(menuType);
return 1;
}
int CHudMenu::MsgFunc_BuyClose(const char *pszName, int iSize, void *pbuf)
{
UserCmd_OldStyleMenuClose();
ClientCmd("touch_removebutton _menu_*");
return 1;
}
int CHudMenu::MsgFunc_AllowSpec(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_bAllowSpec = !!READ_BYTE();
return 1;
}
void CHudMenu::UserCmd_OldStyleMenuOpen()
{
m_flShutoffTime = -1; // stay open until user will not close it
strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString("Buy"), MAX_MENU_STRING );
}
void CHudMenu::UserCmd_OldStyleMenuClose()
{
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
m_iFlags &= ~HUD_ACTIVE;
ClientCmd("touch_removebutton _menu_*");
}
// lol, no real VGUI here
// it's really good only for touchscreen
void CHudMenu::ShowVGUIMenu( int menuType )
{
char *szCmd;
switch(menuType)
{
case MENU_TEAM:
szCmd = "exec touch/chooseteam.cfg";
break;
case MENU_CLASS_T:
szCmd = "exec touch/chooseteam_tr.cfg";
break;
case MENU_CLASS_CT:
szCmd = "exec touch/chooseteam_ct.cfg";
break;
case MENU_BUY:
szCmd = "exec touch/buy.cfg";
break;
case MENU_BUY_PISTOL:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_pistol_t.cfg";
else szCmd = "exec touch/buy_pistol_ct.cfg";
break;
case MENU_BUY_SHOTGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_shotgun_t.cfg";
else szCmd = "exec touch/buy_shotgun_ct.cfg";
break;
case MENU_BUY_RIFLE:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_rifle_t.cfg";
else szCmd ="exec touch/buy_rifle_ct.cfg";
break;
case MENU_BUY_SUBMACHINEGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_submachinegun_t.cfg";
else szCmd = "exec touch/buy_submachinegun_ct.cfg";
break;
case MENU_BUY_MACHINEGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == 1 )
szCmd = "exec touch/buy_machinegun_t.cfg";
else szCmd = "exec touch/buy_machinegun_ct.cfg";
break;
case MENU_BUY_ITEM:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == 1 )
szCmd = "exec touch/buy_item_t.cfg";
else szCmd = "exec touch/buy_item_ct.cfg";
break;
case MENU_RADIOA:
szCmd = "exec touch/radioa.cfg";
break;
case MENU_RADIOB:
szCmd = "exec touch/radiob.cfg";
break;
case MENU_RADIOC:
szCmd = "exec touch/radioc.cfg";
break;
case MENU_RADIOSELECTOR:
szCmd = "exec touch/radioselector.cfg";
break;
default:
szCmd = "touch_removebutton _menu_*"; // back to the default touch page
m_fMenuDisplayed = 0;
break;
}
m_fMenuDisplayed = 1;
ClientCmd(szCmd);
}
void CHudMenu::UserCmd_ShowVGUIMenu()
{
if( gEngfuncs.Cmd_Argc() != 1 )
{
ConsolePrint("usage: showvguimenu <menuType>\n");
}
if( gEngfuncs.pfnGetCvarFloat("_vgui_menus") == 0.0f )
return;
int menuType = atoi(gEngfuncs.Cmd_Argv(1));
ShowVGUIMenu(menuType);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,372 +1,372 @@
/***
*
* 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>
#include <ctype.h>
#include "vgui_parser.h"
//#include "vgui_TeamFortressViewport.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;
//if ( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE) || !m_HUD_saytext->value )
//return 1;
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + 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;
DrawUtils::SetConsoleTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
int x = DrawUtils::DrawConsoleString( LINE_START, y, buf );
// color is reset after each string draw
DrawUtils::DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] );
}
else
{
// normal draw
DrawUtils::DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
}
}
y += line_height;
}
return 1;
}
struct CSimpleMap {
const char key[32];
const char value[64];
};
CSimpleMap sayTextFmt[] =
{
{"#Cstrike_Chat_CT", "\x02(Counter-Terrorist) %s : %s"},
{"#Cstrike_Chat_T", "\x02(Terrorist) %s : %s"},
{"#Cstrike_Chat_CT_Dead", "\x02*DEAD*(Counter-Terrorist) %s : %s"},
{"#Cstrike_Chat_T_Dead", "\x02*DEAD*(Terrorist) %s : %s"},
{"#Cstrike_Chat_Spec", "\x02(Spectator) %s : %s"},
{"#Cstrike_Chat_All", "\x02%s : %s"},
{"#Cstrike_Chat_AllDead", "\x02*DEAD* %s: %s"},
{"#Cstrike_Chat_AllSpec", "\x02*SPEC* %s: %s"},
{"#Cstrike_Name_Change", "\x02* %s changed name to %s"},
};
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
char szBuf[3][64];
strncpy( szBuf[0], READ_STRING(), sizeof(szBuf[0]));
strncpy( szBuf[1], READ_STRING(), sizeof(szBuf[1]));
strncpy( szBuf[2], READ_STRING(), sizeof(szBuf[2]));
const char *fmt = "\x02%s: %s";
int i = 0;
for( i; i < sizeof(sayTextFmt) / sizeof(CSimpleMap); i++ )
{
if( !strncmp( szBuf[0], sayTextFmt[i].key, sizeof( szBuf ) ) )
{
fmt = sayTextFmt[i].value;
break;
}
}
char dst[256];
if( i == 8 )
{
snprintf( dst, sizeof( dst ), fmt, szBuf[1], szBuf[2]);
}
else
{
GetPlayerInfo( client_index, &g_PlayerInfoList[client_index] );
const char *pName = g_PlayerInfoList[client_index].name;
snprintf( dst, sizeof( dst ), fmt, pName, szBuf[2]);
}
SayTextPrint( dst, strlen(dst), client_index );
return 1;
}
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
{
/*if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
{
// Print it straight to the console
ConsolePrint( pszBuf );
return;
}*/
// find an empty string slot
int i;
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 1
// 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 );
}
}
}
#endif
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;
DrawUtils::ConsoleStringSize(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
DrawUtils::ConsoleStringSize( 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;
}
}
}
}
/***
*
* 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>
#include <ctype.h>
#include "vgui_parser.h"
//#include "vgui_TeamFortressViewport.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;
//if ( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE) || !m_HUD_saytext->value )
//return 1;
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + 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;
DrawUtils::SetConsoleTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
int x = DrawUtils::DrawConsoleString( LINE_START, y, buf );
// color is reset after each string draw
DrawUtils::DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] );
}
else
{
// normal draw
DrawUtils::DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
}
}
y += line_height;
}
return 1;
}
struct CSimpleMap {
const char key[32];
const char value[64];
};
CSimpleMap sayTextFmt[] =
{
{"#Cstrike_Chat_CT", "\x02(Counter-Terrorist) %s : %s"},
{"#Cstrike_Chat_T", "\x02(Terrorist) %s : %s"},
{"#Cstrike_Chat_CT_Dead", "\x02*DEAD*(Counter-Terrorist) %s : %s"},
{"#Cstrike_Chat_T_Dead", "\x02*DEAD*(Terrorist) %s : %s"},
{"#Cstrike_Chat_Spec", "\x02(Spectator) %s : %s"},
{"#Cstrike_Chat_All", "\x02%s : %s"},
{"#Cstrike_Chat_AllDead", "\x02*DEAD* %s: %s"},
{"#Cstrike_Chat_AllSpec", "\x02*SPEC* %s: %s"},
{"#Cstrike_Name_Change", "\x02* %s changed name to %s"},
};
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
char szBuf[3][64];
strncpy( szBuf[0], READ_STRING(), sizeof(szBuf[0]));
strncpy( szBuf[1], READ_STRING(), sizeof(szBuf[1]));
strncpy( szBuf[2], READ_STRING(), sizeof(szBuf[2]));
const char *fmt = "\x02%s: %s";
int i = 0;
for( i; i < sizeof(sayTextFmt) / sizeof(CSimpleMap); i++ )
{
if( !strncmp( szBuf[0], sayTextFmt[i].key, sizeof( szBuf ) ) )
{
fmt = sayTextFmt[i].value;
break;
}
}
char dst[256];
if( i == 8 )
{
snprintf( dst, sizeof( dst ), fmt, szBuf[1], szBuf[2]);
}
else
{
GetPlayerInfo( client_index, &g_PlayerInfoList[client_index] );
const char *pName = g_PlayerInfoList[client_index].name;
snprintf( dst, sizeof( dst ), fmt, pName, szBuf[2]);
}
SayTextPrint( dst, strlen(dst), client_index );
return 1;
}
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
{
/*if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
{
// Print it straight to the console
ConsolePrint( pszBuf );
return;
}*/
// find an empty string slot
int i;
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 1
// 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 );
}
}
}
#endif
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;
DrawUtils::ConsoleStringSize(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
DrawUtils::ConsoleStringSize( 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;
}
}
}
}

View File

@ -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.
*
****/
//
// 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"
#include "com_weapons.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;
if( g_bInBombZone && !strcmp(m_IconList[i].szSpriteName, "c4") && ((int)(flTime * 10) % 2))
SPR_Set( m_IconList[i].spr, 255, 16, 16 );
else 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 )
{
// check to see if the sprite is in the current list
int i;
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;
strncpy( m_IconList[i].szSpriteName, pszIconName, MAX_ICONSPRITENAME_LENGTH );
// 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;
}
}
}
/***
*
* 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"
#include "com_weapons.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;
if( g_bInBombZone && !strcmp(m_IconList[i].szSpriteName, "c4") && ((int)(flTime * 10) % 2))
SPR_Set( m_IconList[i].spr, 255, 16, 16 );
else 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 )
{
// check to see if the sprite is in the current list
int i;
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;
strncpy( m_IconList[i].szSpriteName, pszIconName, MAX_ICONSPRITENAME_LENGTH );
// 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;
}
}
}

View File

@ -1,298 +1,298 @@
/***
*
* 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 );
extern float g_ColorYellow[3];
#define STATUSBAR_ID_LINE 0
inline void InsertTextMsg( char *szDst, size_t sLen, const char *szMsgName)
{
client_textmessage_t *msg = TextMessageGet(szMsgName);
if( msg )
{
strncpy( szDst, msg->pMessage, sLen );
}
else strncpy( szDst, szMsgName, sLen );
}
int CHudStatusBar :: Init( void )
{
gHUD.AddHudElem( this );
HOOK_MESSAGE( StatusText );
HOOK_MESSAGE( StatusValue );
Reset();
hud_centerid = 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
{
strncpy( szRepString, "******", MAX_PLAYER_NAME_LENGTH );
}
break;
case 'i': // number
sprintf( szRepString, "%d", indexval );
break;
case 'h': // health
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Health");
break;
case 'c':
if( indexval == 1 )
{
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Friend");
}
else if( indexval == 2 )
{
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Enemy");
}
else if( indexval == 3 )
{
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Hostage");
}
else szRepString[0] = 0;
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;
}
if( g_iUser1 > 0 )
{
// this is a spectator, so don't draw any statusbars
return 1;
}
int Y_START = ScreenHeight - YRES(32 + 4);
// Draw the status bar lines
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
{
int TextHeight, TextWidth;
DrawUtils::ConsoleStringSize( 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 &&
hud_centerid->value != 0.0f )
{
x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 );
y = (ScreenHeight / 2) + (TextHeight * hud_centerid->value );
}
if ( m_pflNameColors[i] )
DrawUtils::SetConsoleTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
DrawUtils::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 );
extern float g_ColorYellow[3];
#define STATUSBAR_ID_LINE 0
inline void InsertTextMsg( char *szDst, size_t sLen, const char *szMsgName)
{
client_textmessage_t *msg = TextMessageGet(szMsgName);
if( msg )
{
strncpy( szDst, msg->pMessage, sLen );
}
else strncpy( szDst, szMsgName, sLen );
}
int CHudStatusBar :: Init( void )
{
gHUD.AddHudElem( this );
HOOK_MESSAGE( StatusText );
HOOK_MESSAGE( StatusValue );
Reset();
hud_centerid = 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
{
strncpy( szRepString, "******", MAX_PLAYER_NAME_LENGTH );
}
break;
case 'i': // number
sprintf( szRepString, "%d", indexval );
break;
case 'h': // health
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Health");
break;
case 'c':
if( indexval == 1 )
{
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Friend");
}
else if( indexval == 2 )
{
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Enemy");
}
else if( indexval == 3 )
{
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Hostage");
}
else szRepString[0] = 0;
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;
}
if( g_iUser1 > 0 )
{
// this is a spectator, so don't draw any statusbars
return 1;
}
int Y_START = ScreenHeight - YRES(32 + 4);
// Draw the status bar lines
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
{
int TextHeight, TextWidth;
DrawUtils::ConsoleStringSize( 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 &&
hud_centerid->value != 0.0f )
{
x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 );
y = (ScreenHeight / 2) + (TextHeight * hud_centerid->value );
}
if ( m_pflNameColors[i] )
DrawUtils::SetConsoleTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
DrawUtils::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;
}

View File

@ -1,249 +1,249 @@
/***
*
* 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"
#include "vgui_parser.h"
#include "ctype.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;
}
if(clmsg->pMessage[0] == '#') strncpy(dst, Localize(clmsg->pMessage+1), sizeof( dst ));
// 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;
}
if( clmsg->pMessage[0] == '#')
return (char *)Localize( clmsg->pMessage + 1);
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 '#')
#define MAX_TEXTMSG_STRING 256
int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
int msg_dest = READ_BYTE();
static char szBuf[6][MAX_TEXTMSG_STRING];
char *msg_text = LookupString( READ_STRING(), &msg_dest );
msg_text = strncpy( szBuf[0], msg_text, MAX_TEXTMSG_STRING );
// keep reading strings and using C format strings for subsituting the strings into the localised text string
char *sstr1 = LookupString( READ_STRING() );
sstr1 = strncpy( szBuf[1], sstr1, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
char *sstr2 = LookupString( READ_STRING() );
sstr2 = strncpy( szBuf[2], sstr2, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr2 );
char *sstr3 = LookupString( READ_STRING() );
sstr3 = strncpy( szBuf[3], sstr3, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr3 );
char *sstr4 = LookupString( READ_STRING() );
sstr4 = strncpy( szBuf[4], sstr4, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr4 );
char *psz = szBuf[5];
// Remove numbers after %s.
// VALVEWHY?
if( strlen(msg_text) >= 3 )
{
for( int i = 0; i < strlen(msg_text) - 2; i++)
{
if( msg_text[i] == '%' && msg_text[i + 1] == 's' && isdigit(msg_text[i + 2]))
{
char *first = &msg_text[i + 2];
char *second = &msg_text[i + 3];
memmove( first, second, strlen( second ));
first[strlen(first)] = '\0';
}
}
}
switch ( msg_dest )
{
case HUD_PRINTCENTER:
snprintf( psz, MAX_TEXTMSG_STRING, 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
snprintf( psz+1, MAX_TEXTMSG_STRING - 1, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) );
break;
case HUD_PRINTTALK:
psz[0] = 2; // mark, so SayTextPrint will color it
snprintf( psz+1, MAX_TEXTMSG_STRING-1, msg_text, sstr1, sstr2, sstr3, sstr4 );
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
break;
case HUD_PRINTCONSOLE:
snprintf( psz, MAX_TEXTMSG_STRING, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) );
break;
case HUD_PRINTRADIO:
// For some reason, HUD_PRINTRADIO always have "1" in msg_text
for( int i = 1; i < MAX_PLAYERS; i++ )
{
if( g_PlayerInfoList[i].name && !strcmp(g_PlayerInfoList[i].name, sstr2) )
{
psz[0] = 2;
snprintf( psz + 1, MAX_TEXTMSG_STRING-1, sstr1, sstr2, sstr3, sstr4 );
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128, i );
break;
}
}
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"
#include "vgui_parser.h"
#include "ctype.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;
}
if(clmsg->pMessage[0] == '#') strncpy(dst, Localize(clmsg->pMessage+1), sizeof( dst ));
// 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;
}
if( clmsg->pMessage[0] == '#')
return (char *)Localize( clmsg->pMessage + 1);
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 '#')
#define MAX_TEXTMSG_STRING 256
int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
int msg_dest = READ_BYTE();
static char szBuf[6][MAX_TEXTMSG_STRING];
char *msg_text = LookupString( READ_STRING(), &msg_dest );
msg_text = strncpy( szBuf[0], msg_text, MAX_TEXTMSG_STRING );
// keep reading strings and using C format strings for subsituting the strings into the localised text string
char *sstr1 = LookupString( READ_STRING() );
sstr1 = strncpy( szBuf[1], sstr1, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
char *sstr2 = LookupString( READ_STRING() );
sstr2 = strncpy( szBuf[2], sstr2, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr2 );
char *sstr3 = LookupString( READ_STRING() );
sstr3 = strncpy( szBuf[3], sstr3, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr3 );
char *sstr4 = LookupString( READ_STRING() );
sstr4 = strncpy( szBuf[4], sstr4, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr4 );
char *psz = szBuf[5];
// Remove numbers after %s.
// VALVEWHY?
if( strlen(msg_text) >= 3 )
{
for( int i = 0; i < strlen(msg_text) - 2; i++)
{
if( msg_text[i] == '%' && msg_text[i + 1] == 's' && isdigit(msg_text[i + 2]))
{
char *first = &msg_text[i + 2];
char *second = &msg_text[i + 3];
memmove( first, second, strlen( second ));
first[strlen(first)] = '\0';
}
}
}
switch ( msg_dest )
{
case HUD_PRINTCENTER:
snprintf( psz, MAX_TEXTMSG_STRING, 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
snprintf( psz+1, MAX_TEXTMSG_STRING - 1, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) );
break;
case HUD_PRINTTALK:
psz[0] = 2; // mark, so SayTextPrint will color it
snprintf( psz+1, MAX_TEXTMSG_STRING-1, msg_text, sstr1, sstr2, sstr3, sstr4 );
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
break;
case HUD_PRINTCONSOLE:
snprintf( psz, MAX_TEXTMSG_STRING, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) );
break;
case HUD_PRINTRADIO:
// For some reason, HUD_PRINTRADIO always have "1" in msg_text
for( int i = 1; i < MAX_PLAYERS; i++ )
{
if( g_PlayerInfoList[i].name && !strcmp(g_PlayerInfoList[i].name, sstr2) )
{
psz[0] = 2;
snprintf( psz + 1, MAX_TEXTMSG_STRING-1, sstr1, sstr2, sstr3, sstr4 );
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128, i );
break;
}
}
break;
}
return 1;
}

View File

@ -1,217 +1,217 @@
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include "vgui_parser.h"
#include <string.h>
DECLARE_MESSAGE( m_Timer, RoundTime )
DECLARE_MESSAGE( m_Timer, ShowTimer )
int CHudTimer::Init()
{
HOOK_MESSAGE( RoundTime );
HOOK_MESSAGE( ShowTimer );
m_iFlags = 0;
m_bPanicColorChange = false;
gHUD.AddHudElem(this);
return 1;
}
int CHudTimer::VidInit()
{
m_HUD_timer = gHUD.GetSpriteIndex( "stopwatch" );
return 1;
}
int CHudTimer::Draw( float fTime )
{
if ( ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) )
return 1;
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
return 1;
int r, g, b;
// time must be positive
int minutes = max( 0, (int)( m_iTime + m_fStartTime - gHUD.m_flTime ) / 60);
int seconds = max( 0, (int)( m_iTime + m_fStartTime - gHUD.m_flTime ) - (minutes * 60));
if( minutes * 60 + seconds > 20 )
{
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH );
}
else
{
m_flPanicTime += gHUD.m_flTimeDelta;
// add 0.1 sec, so it's not flicker fast
if( m_flPanicTime > ((float)seconds / 40.0f) + 0.1f)
{
m_flPanicTime = 0;
m_bPanicColorChange = !m_bPanicColorChange;
}
DrawUtils::UnpackRGB( r, g, b, m_bPanicColorChange ? RGB_YELLOWISH : RGB_REDISH );
}
DrawUtils::ScaleColors( r, g, b, MIN_ALPHA );
int iWatchWidth = gHUD.GetSpriteRect(m_HUD_timer).right - gHUD.GetSpriteRect(m_HUD_timer).left;
int x = ScreenWidth/2;
int y = ScreenHeight - 1.5 * gHUD.m_iFontHeight ;
SPR_Set(gHUD.GetSprite(m_HUD_timer), r, g, b);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_timer));
x = DrawUtils::DrawHudNumber2( x + iWatchWidth / 4, y, false, 2, minutes, r, g, b );
// draw :
FillRGBA(x + iWatchWidth / 4, y + gHUD.m_iFontHeight / 4, 2, 2, r, g, b, 100);
FillRGBA(x + iWatchWidth / 4, y + gHUD.m_iFontHeight - gHUD.m_iFontHeight / 4, 2, 2, r, g, b, 100);
DrawUtils::DrawHudNumber2( x + iWatchWidth / 2, y, true, 2, seconds, r, g, b );
return 1;
}
int CHudTimer::MsgFunc_RoundTime(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_iTime = READ_SHORT();
m_fStartTime = gHUD.m_flTime;
m_iFlags = HUD_ACTIVE;
return 1;
}
int CHudTimer::MsgFunc_ShowTimer(const char *pszName, int iSize, void *pbuf)
{
m_iFlags = HUD_ACTIVE;
return 1;
}
#define UPDATE_BOTPROGRESS 0
#define CREATE_BOTPROGRESS 1
#define REMOVE_BOTPROGRESS 2
DECLARE_MESSAGE( m_ProgressBar, BarTime )
DECLARE_MESSAGE( m_ProgressBar, BarTime2 )
DECLARE_MESSAGE( m_ProgressBar, BotProgress )
int CHudProgressBar::Init()
{
HOOK_MESSAGE( BarTime );
HOOK_MESSAGE( BarTime2 );
HOOK_MESSAGE( BotProgress );
m_iFlags = 0;
m_szLocalizedHeader = NULL;
m_szHeader[0] = '\0';
m_fStartTime = m_fPercent = 0.0f;
gHUD.AddHudElem(this);
return 1;
}
int CHudProgressBar::VidInit()
{
return 1;
}
int CHudProgressBar::Draw( float flTime )
{
// allow only 0.0..1.0
if( (m_fPercent < 0.0f) || (m_fPercent > 1.0f) )
{
m_iFlags = 0;
m_fPercent = 0.0f;
return 1;
}
if( m_szLocalizedHeader && m_szLocalizedHeader[0] )
{
int r, g, b;
DrawUtils::UnpackRGB( r, g, b, RGB_YELLOWISH );
DrawUtils::DrawHudString( ScreenWidth / 4, ScreenHeight / 2, ScreenWidth, (char*)m_szLocalizedHeader, r, g, b );
DrawUtils::DrawRectangle( ScreenWidth/ 4, ScreenHeight / 2 + gHUD.m_scrinfo.iCharHeight, ScreenWidth/2, ScreenHeight/30 );
FillRGBA( ScreenWidth/4+2, ScreenHeight/2 + gHUD.m_scrinfo.iCharHeight + 2, m_fPercent * (ScreenWidth/2-4), ScreenHeight/30-4, 255, 140, 0, 255 );
return 1;
}
// prevent SIGFPE
if( m_iDuration != 0.0f )
{
m_fPercent = ((flTime - m_fStartTime) / m_iDuration);
}
else
{
m_fPercent = 0.0f;
m_iFlags = 0;
return 1;
}
DrawUtils::DrawRectangle( ScreenWidth/4, ScreenHeight*2/3, ScreenWidth/2, 10 );
FillRGBA( ScreenWidth/4+2, ScreenHeight*2/3+2, m_fPercent * (ScreenWidth/2-4), 6, 255, 140, 0, 255 );
return 1;
}
int CHudProgressBar::MsgFunc_BarTime(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_iDuration = READ_SHORT();
m_fPercent = 0.0f;
m_fStartTime = gHUD.m_flTime;
m_iFlags = HUD_ACTIVE;
return 1;
}
int CHudProgressBar::MsgFunc_BarTime2(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_iDuration = READ_SHORT();
m_fPercent = (float)READ_SHORT() / 100.0f;
m_fStartTime = gHUD.m_flTime;
m_iFlags = HUD_ACTIVE;
return 1;
}
int CHudProgressBar::MsgFunc_BotProgress(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_iDuration = 0.0f; // don't update our progress bar
m_iFlags = HUD_ACTIVE;
float fNewPercent;
int flag = READ_BYTE();
switch( flag )
{
case UPDATE_BOTPROGRESS:
case CREATE_BOTPROGRESS:
fNewPercent = (float)READ_BYTE() / 100.0f;
// cs behavior:
// just don't decrease percent values
if( m_fPercent < fNewPercent )
{
m_fPercent = fNewPercent;
}
strncpy(m_szHeader, READ_STRING(), sizeof(m_szHeader));
m_szLocalizedHeader = Localize(m_szHeader + 1);
break;
case REMOVE_BOTPROGRESS:
default:
m_fPercent = 0.0f;
m_szHeader[0] = '\0';
m_iFlags = 0;
m_szLocalizedHeader = NULL;
break;
}
return 1;
}
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include "vgui_parser.h"
#include <string.h>
DECLARE_MESSAGE( m_Timer, RoundTime )
DECLARE_MESSAGE( m_Timer, ShowTimer )
int CHudTimer::Init()
{
HOOK_MESSAGE( RoundTime );
HOOK_MESSAGE( ShowTimer );
m_iFlags = 0;
m_bPanicColorChange = false;
gHUD.AddHudElem(this);
return 1;
}
int CHudTimer::VidInit()
{
m_HUD_timer = gHUD.GetSpriteIndex( "stopwatch" );
return 1;
}
int CHudTimer::Draw( float fTime )
{
if ( ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) )
return 1;
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
return 1;
int r, g, b;
// time must be positive
int minutes = max( 0, (int)( m_iTime + m_fStartTime - gHUD.m_flTime ) / 60);
int seconds = max( 0, (int)( m_iTime + m_fStartTime - gHUD.m_flTime ) - (minutes * 60));
if( minutes * 60 + seconds > 20 )
{
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH );
}
else
{
m_flPanicTime += gHUD.m_flTimeDelta;
// add 0.1 sec, so it's not flicker fast
if( m_flPanicTime > ((float)seconds / 40.0f) + 0.1f)
{
m_flPanicTime = 0;
m_bPanicColorChange = !m_bPanicColorChange;
}
DrawUtils::UnpackRGB( r, g, b, m_bPanicColorChange ? RGB_YELLOWISH : RGB_REDISH );
}
DrawUtils::ScaleColors( r, g, b, MIN_ALPHA );
int iWatchWidth = gHUD.GetSpriteRect(m_HUD_timer).right - gHUD.GetSpriteRect(m_HUD_timer).left;
int x = ScreenWidth/2;
int y = ScreenHeight - 1.5 * gHUD.m_iFontHeight ;
SPR_Set(gHUD.GetSprite(m_HUD_timer), r, g, b);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_timer));
x = DrawUtils::DrawHudNumber2( x + iWatchWidth / 4, y, false, 2, minutes, r, g, b );
// draw :
FillRGBA(x + iWatchWidth / 4, y + gHUD.m_iFontHeight / 4, 2, 2, r, g, b, 100);
FillRGBA(x + iWatchWidth / 4, y + gHUD.m_iFontHeight - gHUD.m_iFontHeight / 4, 2, 2, r, g, b, 100);
DrawUtils::DrawHudNumber2( x + iWatchWidth / 2, y, true, 2, seconds, r, g, b );
return 1;
}
int CHudTimer::MsgFunc_RoundTime(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_iTime = READ_SHORT();
m_fStartTime = gHUD.m_flTime;
m_iFlags = HUD_ACTIVE;
return 1;
}
int CHudTimer::MsgFunc_ShowTimer(const char *pszName, int iSize, void *pbuf)
{
m_iFlags = HUD_ACTIVE;
return 1;
}
#define UPDATE_BOTPROGRESS 0
#define CREATE_BOTPROGRESS 1
#define REMOVE_BOTPROGRESS 2
DECLARE_MESSAGE( m_ProgressBar, BarTime )
DECLARE_MESSAGE( m_ProgressBar, BarTime2 )
DECLARE_MESSAGE( m_ProgressBar, BotProgress )
int CHudProgressBar::Init()
{
HOOK_MESSAGE( BarTime );
HOOK_MESSAGE( BarTime2 );
HOOK_MESSAGE( BotProgress );
m_iFlags = 0;
m_szLocalizedHeader = NULL;
m_szHeader[0] = '\0';
m_fStartTime = m_fPercent = 0.0f;
gHUD.AddHudElem(this);
return 1;
}
int CHudProgressBar::VidInit()
{
return 1;
}
int CHudProgressBar::Draw( float flTime )
{
// allow only 0.0..1.0
if( (m_fPercent < 0.0f) || (m_fPercent > 1.0f) )
{
m_iFlags = 0;
m_fPercent = 0.0f;
return 1;
}
if( m_szLocalizedHeader && m_szLocalizedHeader[0] )
{
int r, g, b;
DrawUtils::UnpackRGB( r, g, b, RGB_YELLOWISH );
DrawUtils::DrawHudString( ScreenWidth / 4, ScreenHeight / 2, ScreenWidth, (char*)m_szLocalizedHeader, r, g, b );
DrawUtils::DrawRectangle( ScreenWidth/ 4, ScreenHeight / 2 + gHUD.m_scrinfo.iCharHeight, ScreenWidth/2, ScreenHeight/30 );
FillRGBA( ScreenWidth/4+2, ScreenHeight/2 + gHUD.m_scrinfo.iCharHeight + 2, m_fPercent * (ScreenWidth/2-4), ScreenHeight/30-4, 255, 140, 0, 255 );
return 1;
}
// prevent SIGFPE
if( m_iDuration != 0.0f )
{
m_fPercent = ((flTime - m_fStartTime) / m_iDuration);
}
else
{
m_fPercent = 0.0f;
m_iFlags = 0;
return 1;
}
DrawUtils::DrawRectangle( ScreenWidth/4, ScreenHeight*2/3, ScreenWidth/2, 10 );
FillRGBA( ScreenWidth/4+2, ScreenHeight*2/3+2, m_fPercent * (ScreenWidth/2-4), 6, 255, 140, 0, 255 );
return 1;
}
int CHudProgressBar::MsgFunc_BarTime(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_iDuration = READ_SHORT();
m_fPercent = 0.0f;
m_fStartTime = gHUD.m_flTime;
m_iFlags = HUD_ACTIVE;
return 1;
}
int CHudProgressBar::MsgFunc_BarTime2(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_iDuration = READ_SHORT();
m_fPercent = (float)READ_SHORT() / 100.0f;
m_fStartTime = gHUD.m_flTime;
m_iFlags = HUD_ACTIVE;
return 1;
}
int CHudProgressBar::MsgFunc_BotProgress(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
m_iDuration = 0.0f; // don't update our progress bar
m_iFlags = HUD_ACTIVE;
float fNewPercent;
int flag = READ_BYTE();
switch( flag )
{
case UPDATE_BOTPROGRESS:
case CREATE_BOTPROGRESS:
fNewPercent = (float)READ_BYTE() / 100.0f;
// cs behavior:
// just don't decrease percent values
if( m_fPercent < fNewPercent )
{
m_fPercent = fNewPercent;
}
strncpy(m_szHeader, READ_STRING(), sizeof(m_szHeader));
m_szLocalizedHeader = Localize(m_szHeader + 1);
break;
case REMOVE_BOTPROGRESS:
default:
m_fPercent = 0.0f;
m_szHeader[0] = '\0';
m_iFlags = 0;
m_szLocalizedHeader = NULL;
break;
}
return 1;
}

View File

@ -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;
DrawUtils::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;
DrawUtils::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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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
#pragma once
#ifndef _CAMERA_H_
#define _CAMEA_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
#pragma once
#ifndef _CAMERA_H_
#define _CAMEA_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_

View File

@ -1,50 +1,50 @@
/***
*
* 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
#pragma once
//
// 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);
#define _cdecl
#include "util_vector.h"
#ifdef _WIN32
#define EXPORT _declspec( dllexport )
#else
#define EXPORT
#define stricmp strcasecmp
#define strnicmp strncasecmp
#define stristr strcasestr
#define strnistr strncasestr
#endif
#include "../engine/cdll_int.h"
#include "../dlls/cdll_dll.h"
#include "render_api.h"
#include "mobility_int.h"
extern cl_enginefunc_t gEngfuncs;
extern render_api_t gRenderAPI;
extern mobile_engfuncs_t gMobileAPI;
extern int g_iXash;
/***
*
* 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
#pragma once
//
// 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);
#define _cdecl
#include "util_vector.h"
#ifdef _WIN32
#define EXPORT _declspec( dllexport )
#else
#define EXPORT
#define stricmp strcasecmp
#define strnicmp strncasecmp
#define stristr strcasestr
#define strnistr strncasestr
#endif
#include "../engine/cdll_int.h"
#include "../dlls/cdll_dll.h"
#include "render_api.h"
#include "mobility_int.h"
extern cl_enginefunc_t gEngfuncs;
extern render_api_t gRenderAPI;
extern mobile_engfuncs_t gMobileAPI;
extern int g_iXash;

View File

@ -1,141 +1,141 @@
/***
*
* 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
//
#pragma once
#include "cvardef.h"
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
extern cvar_t *hud_textmode;
#ifdef _MSC_VER
#pragma warning(disable : 4244) // 'argument': conversion from 'float' to 'int', possible loss of data
#pragma warning(disable : 4101) // unreferenced local variable
#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)
#define FillRGBABlend (*gEngfuncs.pfnFillRGBABlend)
// 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)
#define TrueHeight (gHUD.m_truescrinfo.iHeight)
#define TrueWidth (gHUD.m_truescrinfo.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 float color[3]; // hud.cpp
// 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 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))
#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 )
HSPRITE LoadSprite(const char *pszName);
float *GetClientColor( int clientIndex );
void GetTeamColor( int &r, int &g, int &b, int teamIndex );
#define bound( min, num, max ) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
/***
*
* 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
//
#pragma once
#include "cvardef.h"
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
extern cvar_t *hud_textmode;
#ifdef _MSC_VER
#pragma warning(disable : 4244) // 'argument': conversion from 'float' to 'int', possible loss of data
#pragma warning(disable : 4101) // unreferenced local variable
#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)
#define FillRGBABlend (*gEngfuncs.pfnFillRGBABlend)
// 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)
#define TrueHeight (gHUD.m_truescrinfo.iHeight)
#define TrueWidth (gHUD.m_truescrinfo.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 float color[3]; // hud.cpp
// 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 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))
#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 )
HSPRITE LoadSprite(const char *pszName);
float *GetClientColor( int clientIndex );
void GetTeamColor( int &r, int &g, int &b, int teamIndex );
#define bound( min, num, max ) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))

View File

@ -1,79 +1,79 @@
//========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
// com_weapons.h
// Shared weapons common function prototypes
#if !defined( COM_WEAPONSH )
#define COM_WEAPONSH
#include "hud_iface.h"
#define PLAYER_CAN_SHOOT (1 << 0)
#define PLAYER_FREEZE_TIME_OVER ( 1 << 1 )
#define PLAYER_IN_BOMB_ZONE (1 << 2)
#define PLAYER_HOLDING_SHIELD (1 << 3)
#define CROSSHAIR_
#define ACCURACY_AIR (1 << 0) // accuracy depends on FL_ONGROUND
#define ACCURACY_SPEED (1 << 1)
#define ACCURACY_DUCK (1 << 2) // more accurate when ducking
#define ACCURACY_MULTIPLY_BY_14 (1 << 3) // accuracy multiply to 1.4
#define ACCURACY_MULTIPLY_BY_14_2 (1 << 4) // accuracy multiply to 1.4
#ifndef WPNSTATE_USP_SILENCED
#define WPNSTATE_USP_SILENCED (1<<0)
#define WPNSTATE_GLOCK18_BURST_MODE (1<<1)
#define WPNSTATE_M4A1_SILENCED (1<<2)
#define WPNSTATE_ELITE_LEFT (1<<3)
#define WPNSTATE_FAMAS_BURST_MODE (1<<4)
#define WPNSTATE_SHIELD_DRAWN (1<<5)
#endif
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 iWeaponId, int iBody, int iForce );
int HUD_GetWeapon( void );
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 int function );
void stub_SetModel ( struct edict_s *e, const char *m );
int GetWeaponAccuracyFlags( int weaponid );
extern cvar_t *cl_lw;
extern int g_runfuncs;
extern vec3_t v_angles;
extern float g_lastFOV;
extern int g_iWeaponFlags;
extern bool g_bInBombZone;
extern int g_iFreezeTimeOver;
extern bool g_bHoldingShield;
extern bool g_bHoldingKnife;
extern int g_iPlayerFlags;
extern vec3_t g_vPlayerVelocity;
extern float g_flPlayerSpeed;
extern struct local_state_s *g_curstate;
extern struct local_state_s *g_finalstate;
extern int g_iShotsFired;
#endif
//========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
// com_weapons.h
// Shared weapons common function prototypes
#if !defined( COM_WEAPONSH )
#define COM_WEAPONSH
#include "hud_iface.h"
#define PLAYER_CAN_SHOOT (1 << 0)
#define PLAYER_FREEZE_TIME_OVER ( 1 << 1 )
#define PLAYER_IN_BOMB_ZONE (1 << 2)
#define PLAYER_HOLDING_SHIELD (1 << 3)
#define CROSSHAIR_
#define ACCURACY_AIR (1 << 0) // accuracy depends on FL_ONGROUND
#define ACCURACY_SPEED (1 << 1)
#define ACCURACY_DUCK (1 << 2) // more accurate when ducking
#define ACCURACY_MULTIPLY_BY_14 (1 << 3) // accuracy multiply to 1.4
#define ACCURACY_MULTIPLY_BY_14_2 (1 << 4) // accuracy multiply to 1.4
#ifndef WPNSTATE_USP_SILENCED
#define WPNSTATE_USP_SILENCED (1<<0)
#define WPNSTATE_GLOCK18_BURST_MODE (1<<1)
#define WPNSTATE_M4A1_SILENCED (1<<2)
#define WPNSTATE_ELITE_LEFT (1<<3)
#define WPNSTATE_FAMAS_BURST_MODE (1<<4)
#define WPNSTATE_SHIELD_DRAWN (1<<5)
#endif
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 iWeaponId, int iBody, int iForce );
int HUD_GetWeapon( void );
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 int function );
void stub_SetModel ( struct edict_s *e, const char *m );
int GetWeaponAccuracyFlags( int weaponid );
extern cvar_t *cl_lw;
extern int g_runfuncs;
extern vec3_t v_angles;
extern float g_lastFOV;
extern int g_iWeaponFlags;
extern bool g_bInBombZone;
extern int g_iFreezeTimeOver;
extern bool g_bHoldingShield;
extern bool g_bHoldingKnife;
extern int g_iPlayerFlags;
extern vec3_t g_vPlayerVelocity;
extern float g_flPlayerSpeed;
extern struct local_state_s *g_curstate;
extern struct local_state_s *g_finalstate;
extern int g_iShotsFired;
#endif

View File

@ -1,26 +1,26 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( DEMOH )
#define DEMOH
// 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: $
//=============================================================================
#pragma once
#if !defined( DEMOH )
#define DEMOH
// 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

View File

@ -1,44 +1,44 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined ( EV_HLDMH )
#define EV_HLDMH
// bullet types
typedef enum
{
BULLET_NONE = 0,
BULLET_PLAYER_9MM,
BULLET_PLAYER_MP5,
BULLET_PLAYER_357,
BULLET_PLAYER_BUCKSHOT,
BULLET_PLAYER_CROWBAR,
BULLET_MONSTER_9MM,
BULLET_MONSTER_MP5,
BULLET_MONSTER_12MM,
BULLET_PLAYER_45ACP,
BULLET_PLAYER_338MAG,
BULLET_PLAYER_762MM,
BULLET_PLAYER_556MM,
BULLET_PLAYER_50AE,
BULLET_PLAYER_57MM,
BULLET_PLAYER_357SIG
}
Bullet;
void EV_HLDM_GunshotDecalTrace(pmtrace_t *pTrace, char *decalName , char chTextureType);
void EV_HLDM_DecalGunshot(pmtrace_t *pTrace, int iBulletType, float scale, int r, int g, int b, bool bCreateSparks, char cTextureType);
int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount );
void EV_HLDM_FireBullets(int idx,
float *forward, float *right, float *up,
int cShots,
float *vecSrc, float *vecDirShooting, float *vecSpread,
float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, int iPenetration);
void EV_CS16Client_KillEveryRound( struct tempent_s *te, float frametime, float currenttime );
#endif // EV_HLDMH
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined ( EV_HLDMH )
#define EV_HLDMH
// bullet types
typedef enum
{
BULLET_NONE = 0,
BULLET_PLAYER_9MM,
BULLET_PLAYER_MP5,
BULLET_PLAYER_357,
BULLET_PLAYER_BUCKSHOT,
BULLET_PLAYER_CROWBAR,
BULLET_MONSTER_9MM,
BULLET_MONSTER_MP5,
BULLET_MONSTER_12MM,
BULLET_PLAYER_45ACP,
BULLET_PLAYER_338MAG,
BULLET_PLAYER_762MM,
BULLET_PLAYER_556MM,
BULLET_PLAYER_50AE,
BULLET_PLAYER_57MM,
BULLET_PLAYER_357SIG
}
Bullet;
void EV_HLDM_GunshotDecalTrace(pmtrace_t *pTrace, char *decalName , char chTextureType);
void EV_HLDM_DecalGunshot(pmtrace_t *pTrace, int iBulletType, float scale, int r, int g, int b, bool bCreateSparks, char cTextureType);
int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount );
void EV_HLDM_FireBullets(int idx,
float *forward, float *right, float *up,
int cShots,
float *vecSrc, float *vecDirShooting, float *vecSpread,
float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, int iPenetration);
void EV_CS16Client_KillEveryRound( struct tempent_s *te, float frametime, float currenttime );
#endif // EV_HLDMH

View File

@ -1,75 +1,75 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
// 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, int life = 2.5 );
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 );
void CreateCorpse(Vector *p_vOrigin, Vector *p_vAngles, const char *pModel, float flAnimTime, int iSequence, int iBody);
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: $
//=============================================================================
#pragma once
// 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, int life = 2.5 );
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 );
void CreateCorpse(Vector *p_vOrigin, Vector *p_vAngles, const char *pModel, float flAnimTime, int iSequence, int iBody);
struct cl_entity_s *GetEntity( int idx );
struct cl_entity_s *GetViewEntity( void );
void EV_MuzzleFlash( void );
#endif // EVENTSCRIPTSH

View File

@ -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.
*
****/
#pragma once
#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.
*
****/
#pragma once
#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

View File

@ -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
//
#pragma once
// this is the max number of items in each bucket
#define MAX_WEAPON_POSITIONS 19
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
//
#pragma once
// this is the max number of items in each bucket
#define MAX_WEAPON_POSITIONS 19
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;

View File

@ -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.
*
****/
#pragma once
#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 MsgFunc_ScoreAttrib(const char *pszName, int iSize, void *pbuf);
int MsgFunc_ClCorpse(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];
float m_flTimeFlash;
int m_bitsDamage;
int DrawPain(float fTime);
int DrawDamage(float fTime);
void CalcDamageDirection(vec3_t vecFrom);
void UpdateTiles(float fTime, long bits);
void DrawPlayerLocation( 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.
*
****/
#pragma once
#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 MsgFunc_ScoreAttrib(const char *pszName, int iSize, void *pbuf);
int MsgFunc_ClCorpse(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];
float m_flTimeFlash;
int m_bitsDamage;
int DrawPain(float fTime);
int DrawDamage(float fTime);
void CalcDamageDirection(vec3_t vecFrom);
void UpdateTiles(float fTime, long bits);
void DrawPlayerLocation( void );
};

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,22 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( HUD_IFACEH )
#define HUD_IFACEH
#ifdef _WIN32
#define EXPORT _declspec( dllexport )
#define _DLLEXPORT __declspec( dllexport )
#else
#define EXPORT
#define _DLLEXPORT
#endif
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: $
//=============================================================================
#pragma once
#if !defined( HUD_IFACEH )
#define HUD_IFACEH
#ifdef _WIN32
#define EXPORT _declspec( dllexport )
#define _DLLEXPORT __declspec( dllexport )
#else
#define EXPORT
#define _DLLEXPORT
#endif
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
#include "wrect.h"
#include "../engine/cdll_int.h"
extern cl_enginefunc_t gEngfuncs;
#endif

View File

@ -1,139 +1,139 @@
//========= Copyright ? 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#ifndef SPECTATOR_H
#define SPECTATOR_H
#include "cl_entity.h"
#include "hud.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 256 // 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();
CHudMsgFunc(Spectator);
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_specmode;
cvar_t * m_drawcone;
cvar_t * m_drawstatus;
cvar_t * m_autoDirector;
float m_lastAutoDirector;
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_hsprPlayerC4;
HSPRITE m_hsprPlayerVIP;
HSPRITE m_hsprHostage;
HSPRITE m_hsprBackpack;
HSPRITE m_hsprBomb;
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: $
//=============================================================================
#pragma once
#ifndef SPECTATOR_H
#define SPECTATOR_H
#include "cl_entity.h"
#include "hud.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 256 // 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();
CHudMsgFunc(Spectator);
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_specmode;
cvar_t * m_drawcone;
cvar_t * m_drawstatus;
cvar_t * m_autoDirector;
float m_lastAutoDirector;
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_hsprPlayerC4;
HSPRITE m_hsprPlayerVIP;
HSPRITE m_hsprHostage;
HSPRITE m_hsprBackpack;
HSPRITE m_hsprBomb;
HSPRITE m_hsprPlayerBlue;
HSPRITE m_hsprPlayerRed;
HSPRITE m_hsprPlayer;
HSPRITE m_hsprCamera;
HSPRITE m_hsprPlayerDead;
HSPRITE m_hsprViewcone;
HSPRITE m_hsprUnkownMap;
HSPRITE m_hsprBeam;
HSPRITE m_hCrosshair;
wrect_t m_crosshairRect;
struct model_s * m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame
float m_flNextObserverInput;
float m_zoomDelta;
float m_moveDelta;
int m_lastPrimaryObject;
int m_lastSecondaryObject;
};
#endif // SPECTATOR_H

View File

@ -1,30 +1,30 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( IN_DEFSH )
#define IN_DEFSH
// up / down
#define PITCH 0
// left / right
#define YAW 1
// fall over
#define ROLL 2
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
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: $
//=============================================================================
#pragma once
#if !defined( IN_DEFSH )
#define IN_DEFSH
// up / down
#define PITCH 0
// left / right
#define YAW 1
// fall over
#define ROLL 2
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
typedef struct point_s{
int x;
int y;
} POINT;
#define GetCursorPos(x)
#define SetCursorPos(x,y)
#endif
#endif

View File

@ -1,17 +1,17 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( KBUTTONH )
#define KBUTTONH
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: $
//=============================================================================
#pragma once
#if !defined( KBUTTONH )
#define KBUTTONH
typedef struct kbutton_s
{
int down[2]; // key nums holding it down
int state; // low bit is down state
} kbutton_t;
#endif // !KBUTTONH

View File

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

View File

@ -1,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
//
#pragma once
#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
//
#pragma once
#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 );

View File

@ -1,82 +1,82 @@
/***
*
* Copyright (c) 1996-2004, Shambler Team. 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
* Shambler Team. All other use, distribution, or modification is prohibited
* without written permission from Shambler Team.
*
****/
/*
====== rain.h ========================================================
*/
#pragma once
#ifndef __RAIN_H__
#define __RAIN_H__
#define DRIPSPEED 900 // speed of raindrips (pixel per secs)
#define SNOWSPEED 200 // speed of snowflakes
#define SNOWFADEDIST 80
#define MAXDRIPS 2000 // max raindrops
#define MAXFX 3000 // max effects
#define DRIP_SPRITE_HALFHEIGHT 64
#define DRIP_SPRITE_HALFWIDTH 1
#define SNOW_SPRITE_HALFSIZE 3
// radius water rings
#define MAXRINGHALFSIZE 25
typedef struct
{
int dripsPerSecond;
float distFromPlayer;
float windX, windY;
float randX, randY;
int weatherMode; // 0 - snow, 1 - rain
float globalHeight;
} rain_properties;
typedef struct cl_drip
{
float birthTime;
float minHeight; // minimal height to kill raindrop
vec3_t origin;
float alpha;
float xDelta; // side speed
float yDelta;
int landInWater;
cl_drip* p_Next; // next drip in chain
cl_drip* p_Prev; // previous drip in chain
} cl_drip_t;
typedef struct cl_rainfx
{
float birthTime;
float life;
vec3_t origin;
float alpha;
cl_rainfx* p_Next; // next fx in chain
cl_rainfx* p_Prev; // previous fx in chain
} cl_rainfx_t;
extern rain_properties Rain;
extern cl_drip_t FirstChainDrip;
extern cl_rainfx_t FirstChainFX;
void ProcessRain( void );
void ProcessFXObjects( void );
void ResetRain( void );
void InitRain( void );
#endif
/***
*
* Copyright (c) 1996-2004, Shambler Team. 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
* Shambler Team. All other use, distribution, or modification is prohibited
* without written permission from Shambler Team.
*
****/
/*
====== rain.h ========================================================
*/
#pragma once
#ifndef __RAIN_H__
#define __RAIN_H__
#define DRIPSPEED 900 // speed of raindrips (pixel per secs)
#define SNOWSPEED 200 // speed of snowflakes
#define SNOWFADEDIST 80
#define MAXDRIPS 2000 // max raindrops
#define MAXFX 3000 // max effects
#define DRIP_SPRITE_HALFHEIGHT 64
#define DRIP_SPRITE_HALFWIDTH 1
#define SNOW_SPRITE_HALFSIZE 3
// radius water rings
#define MAXRINGHALFSIZE 25
typedef struct
{
int dripsPerSecond;
float distFromPlayer;
float windX, windY;
float randX, randY;
int weatherMode; // 0 - snow, 1 - rain
float globalHeight;
} rain_properties;
typedef struct cl_drip
{
float birthTime;
float minHeight; // minimal height to kill raindrop
vec3_t origin;
float alpha;
float xDelta; // side speed
float yDelta;
int landInWater;
cl_drip* p_Next; // next drip in chain
cl_drip* p_Prev; // previous drip in chain
} cl_drip_t;
typedef struct cl_rainfx
{
float birthTime;
float life;
vec3_t origin;
float alpha;
cl_rainfx* p_Next; // next fx in chain
cl_rainfx* p_Prev; // previous fx in chain
} cl_rainfx_t;
extern rain_properties Rain;
extern cl_drip_t FirstChainDrip;
extern cl_rainfx_t FirstChainFX;
void ProcessRain( void );
void ProcessFXObjects( void );
void ResetRain( void );
void InitRain( void );
#endif

View File

@ -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.
*
****/
// Big thanks to Chicken Fortress developers
// for this code.
#pragma once
#if !defined (GAMESTUDIOMODELRENDERER_H)
#define GAMESTUDIOMODELRENDERER_H
enum BoneIndex
{
BONE_HEAD,
BONE_PELVIS,
BONE_SPINE1,
BONE_SPINE2,
BONE_SPINE3,
BONE_MAX,
};
typedef struct
{
vec3_t origin;
vec3_t angles;
vec3_t realangles;
float animtime;
float frame;
int sequence;
int gaitsequence;
float framerate;
int m_fSequenceLoops;
int m_fSequenceFinished;
byte controller[4];
byte blending[2];
latchedvars_t lv;
}client_anim_state_t;
class CGameStudioModelRenderer : public CStudioModelRenderer
{
public:
CGameStudioModelRenderer(void);
public:
virtual void StudioSetupBones(void);
virtual void StudioEstimateGait(entity_state_t *pplayer);
virtual void StudioProcessGait(entity_state_t *pplayer);
virtual int StudioDrawPlayer(int flags, entity_state_t *pplayer);
virtual int _StudioDrawPlayer(int flags, entity_state_t *pplayer);
virtual void StudioFxTransform(cl_entity_t *ent, float transform[3][4]);
virtual void StudioPlayerBlend(mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch);
virtual void CalculateYawBlend(entity_state_t *pplayer);
virtual void CalculatePitchBlend(entity_state_t *pplayer);
private:
void SavePlayerState(entity_state_t *pplayer);
void SetupClientAnimation(entity_state_t *pplayer);
void RestorePlayerState(entity_state_t *pplayer);
mstudioanim_t* LookupAnimation(mstudioseqdesc_t *pseqdesc, int index);
private:
int m_nPlayerGaitSequences[MAX_CLIENTS];
bool m_bLocal;
};
extern CGameStudioModelRenderer g_StudioRenderer;
#endif
/***
*
* 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.
*
****/
// Big thanks to Chicken Fortress developers
// for this code.
#pragma once
#if !defined (GAMESTUDIOMODELRENDERER_H)
#define GAMESTUDIOMODELRENDERER_H
enum BoneIndex
{
BONE_HEAD,
BONE_PELVIS,
BONE_SPINE1,
BONE_SPINE2,
BONE_SPINE3,
BONE_MAX,
};
typedef struct
{
vec3_t origin;
vec3_t angles;
vec3_t realangles;
float animtime;
float frame;
int sequence;
int gaitsequence;
float framerate;
int m_fSequenceLoops;
int m_fSequenceFinished;
byte controller[4];
byte blending[2];
latchedvars_t lv;
}client_anim_state_t;
class CGameStudioModelRenderer : public CStudioModelRenderer
{
public:
CGameStudioModelRenderer(void);
public:
virtual void StudioSetupBones(void);
virtual void StudioEstimateGait(entity_state_t *pplayer);
virtual void StudioProcessGait(entity_state_t *pplayer);
virtual int StudioDrawPlayer(int flags, entity_state_t *pplayer);
virtual int _StudioDrawPlayer(int flags, entity_state_t *pplayer);
virtual void StudioFxTransform(cl_entity_t *ent, float transform[3][4]);
virtual void StudioPlayerBlend(mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch);
virtual void CalculateYawBlend(entity_state_t *pplayer);
virtual void CalculatePitchBlend(entity_state_t *pplayer);
private:
void SavePlayerState(entity_state_t *pplayer);
void SetupClientAnimation(entity_state_t *pplayer);
void RestorePlayerState(entity_state_t *pplayer);
mstudioanim_t* LookupAnimation(mstudioseqdesc_t *pseqdesc, int index);
private:
int m_nPlayerGaitSequences[MAX_CLIENTS];
bool m_bLocal;
};
extern CGameStudioModelRenderer g_StudioRenderer;
#endif

View File

@ -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.
*
****/
// Big thanks to Chicken Fortress developers
// for this code.
#pragma once
#ifndef STUDIOMODELRENDERER_H
#define STUDIOMODELRENDERER_H
class CStudioModelRenderer
{
public:
CStudioModelRenderer(void);
virtual ~CStudioModelRenderer(void);
public:
virtual void Init(void);
virtual int StudioDrawModel(int flags);
virtual int StudioDrawPlayer(int flags, struct entity_state_s *pplayer);
public:
virtual mstudioanim_t *StudioGetAnim(model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc);
virtual void StudioSetUpTransform(int trivial_accept);
virtual void StudioSetupBones(void);
virtual void StudioCalcAttachments(void);
virtual void StudioSaveBones(void);
virtual void StudioMergeBones(model_t *m_pSubModel);
virtual float StudioEstimateInterpolant(void);
virtual float StudioEstimateFrame(mstudioseqdesc_t *pseqdesc);
virtual void StudioFxTransform(cl_entity_t *ent, float transform[3][4]);
virtual void StudioSlerpBones(vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s);
virtual void StudioCalcBoneAdj(float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen);
virtual void StudioCalcBoneQuaterion(int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q);
virtual void StudioCalcBonePosition(int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos);
virtual void StudioCalcRotations(float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f);
virtual void StudioRenderModel(float *lightdir);
virtual void StudioRenderFinal(void);
virtual void StudioRenderFinal_Software(void);
virtual void StudioRenderFinal_Hardware(void);
virtual void StudioPlayerBlend(mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch);
virtual void StudioEstimateGait(entity_state_t *pplayer);
virtual void StudioProcessGait(entity_state_t *pplayer);
virtual void StudioSetShadowSprite(int idx);
virtual void StudioDrawShadow(Vector origin, float scale);
public:
double m_clTime;
double m_clOldTime;
int m_fDoInterp;
int m_iShadowSprite;
int m_fGaitEstimation;
int m_nFrameCount;
cvar_t *m_pCvarHiModels;
cvar_t *m_pCvarDeveloper;
cvar_t *m_pCvarDrawEntities;
cl_entity_t *m_pCurrentEntity;
model_t *m_pRenderModel;
player_info_t *m_pPlayerInfo;
int m_nPlayerIndex;
float m_flGaitMovement;
studiohdr_t *m_pStudioHeader;
mstudiobodyparts_t *m_pBodyPart;
mstudiomodel_t *m_pSubModel;
int m_nTopColor;
int m_nBottomColor;
model_t *m_pChromeSprite;
int m_nCachedBones;
char m_nCachedBoneNames[MAXSTUDIOBONES][32];
float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4];
float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4];
float m_fSoftwareXScale, m_fSoftwareYScale;
float m_vUp[3];
float m_vRight[3];
float m_vNormal[3];
float m_vRenderOrigin[3];
int *m_pStudioModelCount;
int *m_pModelsDrawn;
float (*m_protationmatrix)[3][4];
float (*m_paliastransform)[3][4];
float (*m_pbonetransform)[MAXSTUDIOBONES][3][4];
float (*m_plighttransform)[MAXSTUDIOBONES][3][4];
};
#endif
/***
*
* 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.
*
****/
// Big thanks to Chicken Fortress developers
// for this code.
#pragma once
#ifndef STUDIOMODELRENDERER_H
#define STUDIOMODELRENDERER_H
class CStudioModelRenderer
{
public:
CStudioModelRenderer(void);
virtual ~CStudioModelRenderer(void);
public:
virtual void Init(void);
virtual int StudioDrawModel(int flags);
virtual int StudioDrawPlayer(int flags, struct entity_state_s *pplayer);
public:
virtual mstudioanim_t *StudioGetAnim(model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc);
virtual void StudioSetUpTransform(int trivial_accept);
virtual void StudioSetupBones(void);
virtual void StudioCalcAttachments(void);
virtual void StudioSaveBones(void);
virtual void StudioMergeBones(model_t *m_pSubModel);
virtual float StudioEstimateInterpolant(void);
virtual float StudioEstimateFrame(mstudioseqdesc_t *pseqdesc);
virtual void StudioFxTransform(cl_entity_t *ent, float transform[3][4]);
virtual void StudioSlerpBones(vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s);
virtual void StudioCalcBoneAdj(float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen);
virtual void StudioCalcBoneQuaterion(int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q);
virtual void StudioCalcBonePosition(int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos);
virtual void StudioCalcRotations(float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f);
virtual void StudioRenderModel(float *lightdir);
virtual void StudioRenderFinal(void);
virtual void StudioRenderFinal_Software(void);
virtual void StudioRenderFinal_Hardware(void);
virtual void StudioPlayerBlend(mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch);
virtual void StudioEstimateGait(entity_state_t *pplayer);
virtual void StudioProcessGait(entity_state_t *pplayer);
virtual void StudioSetShadowSprite(int idx);
virtual void StudioDrawShadow(Vector origin, float scale);
public:
double m_clTime;
double m_clOldTime;
int m_fDoInterp;
int m_iShadowSprite;
int m_fGaitEstimation;
int m_nFrameCount;
cvar_t *m_pCvarHiModels;
cvar_t *m_pCvarDeveloper;
cvar_t *m_pCvarDrawEntities;
cl_entity_t *m_pCurrentEntity;
model_t *m_pRenderModel;
player_info_t *m_pPlayerInfo;
int m_nPlayerIndex;
float m_flGaitMovement;
studiohdr_t *m_pStudioHeader;
mstudiobodyparts_t *m_pBodyPart;
mstudiomodel_t *m_pSubModel;
int m_nTopColor;
int m_nBottomColor;
model_t *m_pChromeSprite;
int m_nCachedBones;
char m_nCachedBoneNames[MAXSTUDIOBONES][32];
float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4];
float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4];
float m_fSoftwareXScale, m_fSoftwareYScale;
float m_vUp[3];
float m_vRight[3];
float m_vNormal[3];
float m_vRenderOrigin[3];
int *m_pStudioModelCount;
int *m_pModelsDrawn;
float (*m_protationmatrix)[3][4];
float (*m_paliastransform)[3][4];
float (*m_pbonetransform)[MAXSTUDIOBONES][3][4];
float (*m_plighttransform)[MAXSTUDIOBONES][3][4];
};
#endif

View File

@ -1,38 +1,38 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( STUDIO_UTIL_H )
#define STUDIO_UTIL_H
#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: $
//=============================================================================
#pragma once
#if !defined( STUDIO_UTIL_H )
#define STUDIO_UTIL_H
#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

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +1,88 @@
/*
*
* 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 2 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#ifndef UNICODE_STR_TOOLS_H
#define UNICODE_STR_TOOLS_H
#ifdef _WIN32
typedef wchar_t uchar16;
typedef unsigned int uchar32;
#else
typedef unsigned short uchar16;
typedef wchar_t uchar32;
#endif // _WIN32
enum EStringConvertErrorPolicy
{
_STRINGCONVERTFLAG_SKIP = 1,
_STRINGCONVERTFLAG_FAIL = 2,
_STRINGCONVERTFLAG_ASSERT = 4,
STRINGCONVERT_REPLACE = 0,
STRINGCONVERT_SKIP = 1,
STRINGCONVERT_FAIL = 2,
STRINGCONVERT_ASSERT_REPLACE = 4,
STRINGCONVERT_ASSERT_SKIP = 5,
STRINGCONVERT_ASSERT_FAIL = 6,
};
bool Q_IsValidUChar32(uchar32 uVal);
int Q_UTF32ToUChar32(const uchar32 *pUTF32, uchar32 &uVal, bool &bErr);
int Q_UChar32ToUTF32Len(uchar32 uVal);
int Q_UChar32ToUTF32(uchar32 uVal, uchar32 *pUTF32);
int Q_UChar32ToUTF8Len(uchar32 uVal);
int Q_UChar32ToUTF16Len(uchar32 uVal);
int Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out);
int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out);
int Q_UTF16ToUChar32(const uchar16 *pUTF16, uchar32 &uValueOut, bool &bErrorOut);
int Q_UTF8ToUTF16(const char *pUTF8, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF8ToUTF32(const char *pUTF8, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF16ToUTF8(const uchar16 *pUTF16, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF16ToUTF32(const uchar16 *pUTF16, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF32ToUTF8(const uchar32 *pUTF32, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF32ToUTF16(const uchar32 *pUTF32, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut);
qboolean Q_UnicodeValidate(const char *pUTF8);
int Q_UnicodeLength(const char *pUTF8);
char *Q_UnicodeAdvance(char *pUTF8, int nChars);
//bool Q_IsMeanSpaceW(uchar16 wch);
bool Q_IsDeprecatedW(uchar16 wch);
uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pbStrippedAny);
qboolean Q_StripUnprintableAndSpace(char *pch);
qboolean V_UTF8ToUChar32(const char *pUTF8_, uchar32 *uValueOut);
int Q_UnicodeRepair(char *pUTF8);
wchar_t *Q_AdvanceSpace (wchar_t *start);
wchar_t *Q_ReadUToken (wchar_t *start, wchar_t *token, int tokenBufferSize, bool &quoted);
#endif // UNICODE_STR_TOOLS_H
/*
*
* 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 2 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#ifndef UNICODE_STR_TOOLS_H
#define UNICODE_STR_TOOLS_H
#ifdef _WIN32
typedef wchar_t uchar16;
typedef unsigned int uchar32;
#else
typedef unsigned short uchar16;
typedef wchar_t uchar32;
#endif // _WIN32
enum EStringConvertErrorPolicy
{
_STRINGCONVERTFLAG_SKIP = 1,
_STRINGCONVERTFLAG_FAIL = 2,
_STRINGCONVERTFLAG_ASSERT = 4,
STRINGCONVERT_REPLACE = 0,
STRINGCONVERT_SKIP = 1,
STRINGCONVERT_FAIL = 2,
STRINGCONVERT_ASSERT_REPLACE = 4,
STRINGCONVERT_ASSERT_SKIP = 5,
STRINGCONVERT_ASSERT_FAIL = 6,
};
bool Q_IsValidUChar32(uchar32 uVal);
int Q_UTF32ToUChar32(const uchar32 *pUTF32, uchar32 &uVal, bool &bErr);
int Q_UChar32ToUTF32Len(uchar32 uVal);
int Q_UChar32ToUTF32(uchar32 uVal, uchar32 *pUTF32);
int Q_UChar32ToUTF8Len(uchar32 uVal);
int Q_UChar32ToUTF16Len(uchar32 uVal);
int Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out);
int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out);
int Q_UTF16ToUChar32(const uchar16 *pUTF16, uchar32 &uValueOut, bool &bErrorOut);
int Q_UTF8ToUTF16(const char *pUTF8, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF8ToUTF32(const char *pUTF8, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF16ToUTF8(const uchar16 *pUTF16, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF16ToUTF32(const uchar16 *pUTF16, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF32ToUTF8(const uchar32 *pUTF32, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF32ToUTF16(const uchar32 *pUTF32, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut);
qboolean Q_UnicodeValidate(const char *pUTF8);
int Q_UnicodeLength(const char *pUTF8);
char *Q_UnicodeAdvance(char *pUTF8, int nChars);
//bool Q_IsMeanSpaceW(uchar16 wch);
bool Q_IsDeprecatedW(uchar16 wch);
uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pbStrippedAny);
qboolean Q_StripUnprintableAndSpace(char *pch);
qboolean V_UTF8ToUChar32(const char *pUTF8_, uchar32 *uValueOut);
int Q_UnicodeRepair(char *pUTF8);
wchar_t *Q_AdvanceSpace (wchar_t *start);
wchar_t *Q_ReadUToken (wchar_t *start, wchar_t *token, int tokenBufferSize, bool &quoted);
#endif // UNICODE_STR_TOOLS_H

View File

@ -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
//
#pragma once
// 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 int func_t; //
typedef 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
//
#pragma once
// 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 int func_t; //
typedef 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

View File

@ -1,14 +1,14 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined ( VIEWH )
#define VIEWH
void V_StartPitchDrift( void );
void V_StopPitchDrift( void );
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined ( VIEWH )
#define VIEWH
void V_StartPitchDrift( void );
void V_StopPitchDrift( void );
#endif // !VIEWH

View File

@ -1,17 +1,17 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( WRECTH )
#define WRECTH
typedef struct rect_s
{
int left, right, top, bottom;
} wrect_t;
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#pragma once
#if !defined( WRECTH )
#define WRECTH
typedef struct rect_s
{
int left, right, top, bottom;
} wrect_t;
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,160 +1,160 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "hud.h"
#include "cl_util.h"
#include "cl_entity.h"
#include "triangleapi.h"
// these are included for the math functions
#include "com_model.h"
#include "studio_util.h"
#pragma warning(disable: 4244)
//seems not used
#if 0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CHudOverview::Init()
{
gHUD.AddHudElem(this);
m_iFlags |= HUD_ACTIVE;
return 1;
}
//-----------------------------------------------------------------------------
// Purpose: Loads new icons
//-----------------------------------------------------------------------------
int CHudOverview::VidInit()
{
m_hsprPlayer = gEngfuncs.pfnSPR_Load("sprites/ring.spr");
m_hsprViewcone = gEngfuncs.pfnSPR_Load("sprites/camera.spr");
return 1;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : flTime -
// intermission -
//-----------------------------------------------------------------------------
int CHudOverview::Draw(float flTime)
{
// only draw in overview mode
if (!gEngfuncs.Overview_GetOverviewState())
return 1;
// make sure we have player info
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);
}
}
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 );
}
#endif
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "hud.h"
#include "cl_util.h"
#include "cl_entity.h"
#include "triangleapi.h"
// these are included for the math functions
#include "com_model.h"
#include "studio_util.h"
#pragma warning(disable: 4244)
//seems not used
#if 0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CHudOverview::Init()
{
gHUD.AddHudElem(this);
m_iFlags |= HUD_ACTIVE;
return 1;
}
//-----------------------------------------------------------------------------
// Purpose: Loads new icons
//-----------------------------------------------------------------------------
int CHudOverview::VidInit()
{
m_hsprPlayer = gEngfuncs.pfnSPR_Load("sprites/ring.spr");
m_hsprViewcone = gEngfuncs.pfnSPR_Load("sprites/camera.spr");
return 1;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : flTime -
// intermission -
//-----------------------------------------------------------------------------
int CHudOverview::Draw(float flTime)
{
// only draw in overview mode
if (!gEngfuncs.Overview_GetOverviewState())
return 1;
// make sure we have player info
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);
}
}
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 );
}
#endif

View File

@ -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
#include <stddef.h>
static byte *gpBuf;
static size_t giSize;
static int giRead;
static bool giBadRead;
void BEGIN_READ( void *buf, int size )
{
giRead = 0;
giBadRead = false;
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_CHAR();
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
#include <stddef.h>
static byte *gpBuf;
static size_t giSize;
static int giRead;
static bool giBadRead;
void BEGIN_READ( void *buf, int size )
{
giRead = 0;
giBadRead = false;
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_CHAR();
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));
}

View File

@ -1,405 +1,405 @@
/***
*
* Copyright (c) 2005, BUzer.
*
* Used with permission for Spirit of Half-Life 1.5
*
****/
/*
====== rain.cpp ========================================================
*/
#include <memory.h>
#include "hud.h"
#include "cl_util.h"
#include "const.h"
#include "entity_types.h"
#include "cdll_int.h"
#include "pm_defs.h"
#include "event_api.h"
#include "rain.h"
void WaterLandingEffect(cl_drip *drip);
rain_properties Rain;
cl_drip FirstChainDrip;
cl_rainfx FirstChainFX;
double rain_curtime; // current time
double rain_oldtime; // last time we have updated drips
double rain_timedelta; // difference between old time and current time
double rain_nextspawntime; // when the next drip should be spawned
int dripcounter = 0;
int fxcounter = 0;
int RainInfo = 0;
/*
=================================
ProcessRain
Must think every frame.
=================================
*/
void ProcessRain( void )
{
rain_oldtime = rain_curtime; // save old time
rain_curtime = gEngfuncs.GetClientTime();
rain_timedelta = rain_curtime - rain_oldtime;
// first frame
if (rain_oldtime == 0)
{
// fix first frame bug with nextspawntime
rain_nextspawntime = gEngfuncs.GetClientTime();
return;
}
if (Rain.dripsPerSecond == 0 && FirstChainDrip.p_Next == NULL)
{
// keep nextspawntime correct
rain_nextspawntime = rain_curtime;
return;
}
if (rain_timedelta == 0)
return; // not in pause
double timeBetweenDrips = 1 / (double)Rain.dripsPerSecond;
cl_drip* curDrip = FirstChainDrip.p_Next;
cl_drip* nextDrip = NULL;
// save debug info
float debug_lifetime = 0;
int debug_howmany = 0;
int debug_attempted = 0;
int debug_dropped = 0;
while (curDrip != NULL) // go through list
{
nextDrip = curDrip->p_Next; // save pointer to next drip
if (Rain.weatherMode == 0)
curDrip->origin.z -= rain_timedelta * DRIPSPEED; // rain
else
curDrip->origin.z -= rain_timedelta * SNOWSPEED; // snow
curDrip->origin.x += rain_timedelta * curDrip->xDelta;
curDrip->origin.y += rain_timedelta * curDrip->yDelta;
// remove drip if its origin lower than minHeight
if (curDrip->origin.z < curDrip->minHeight)
{
if (curDrip->landInWater/* && Rain.weatherMode == 0*/)
WaterLandingEffect(curDrip); // create water rings
if (RainInfo)
{
debug_lifetime += (rain_curtime - curDrip->birthTime);
debug_howmany++;
}
curDrip->p_Prev->p_Next = curDrip->p_Next; // link chain
if (nextDrip != NULL)
nextDrip->p_Prev = curDrip->p_Prev;
delete curDrip;
dripcounter--;
}
curDrip = nextDrip; // restore pointer, so we can continue moving through chain
}
int maxDelta; // maximum height randomize distance
float falltime;
if (Rain.weatherMode == 0)
{
maxDelta = DRIPSPEED * rain_timedelta; // for rain
falltime = (Rain.globalHeight + 4096) / DRIPSPEED;
}
else
{
maxDelta = SNOWSPEED * rain_timedelta; // for snow
falltime = (Rain.globalHeight + 4096) / SNOWSPEED;
}
while (rain_nextspawntime < rain_curtime)
{
rain_nextspawntime += timeBetweenDrips;
if (RainInfo)
debug_attempted++;
if (dripcounter < MAXDRIPS) // check for overflow
{
float deathHeight;
vec3_t vecStart, vecEnd;
vecStart[0] = gEngfuncs.pfnRandomFloat(gHUD.m_vecOrigin.x - Rain.distFromPlayer, gHUD.m_vecOrigin.x + Rain.distFromPlayer);
vecStart[1] = gEngfuncs.pfnRandomFloat(gHUD.m_vecOrigin.y - Rain.distFromPlayer, gHUD.m_vecOrigin.y + Rain.distFromPlayer);
vecStart[2] = Rain.globalHeight;
float xDelta = Rain.windX + gEngfuncs.pfnRandomFloat(Rain.randX * -1, Rain.randX);
float yDelta = Rain.windY + gEngfuncs.pfnRandomFloat(Rain.randY * -1, Rain.randY);
// find a point at bottom of map
vecEnd[0] = falltime * xDelta;
vecEnd[1] = falltime * yDelta;
vecEnd[2] = -4096;
pmtrace_t pmtrace;
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecStart, vecEnd, PM_STUDIO_IGNORE, -1, &pmtrace );
if (pmtrace.startsolid)
{
if (RainInfo)
debug_dropped++;
continue; // drip cannot be placed
}
// falling to water?
int contents = gEngfuncs.PM_PointContents( pmtrace.endpos, NULL );
if (contents == CONTENTS_WATER)
{
int waterEntity = gEngfuncs.PM_WaterEntity( pmtrace.endpos );
if ( waterEntity > 0 )
{
cl_entity_t *pwater = gEngfuncs.GetEntityByIndex( waterEntity );
if ( pwater && ( pwater->model != NULL ) )
{
deathHeight = pwater->curstate.maxs[2];
}
else
{
gEngfuncs.Con_Printf("Rain error: can't get water entity\n");
continue;
}
}
else
{
gEngfuncs.Con_Printf("Rain error: water is not func_water entity\n");
continue;
}
}
else
{
deathHeight = pmtrace.endpos[2];
}
// just in case..
if (deathHeight > vecStart[2])
{
gEngfuncs.Con_Printf("Rain error: can't create drip in water\n");
continue;
}
cl_drip *newClDrip = new cl_drip;
if (!newClDrip)
{
Rain.dripsPerSecond = 0; // disable rain
gEngfuncs.Con_Printf( "Rain error: failed to allocate object!\n");
return;
}
vecStart[2] -= gEngfuncs.pfnRandomFloat(0, maxDelta); // randomize a bit
newClDrip->alpha = gEngfuncs.pfnRandomFloat(0.12, 0.2);
VectorCopy(vecStart, newClDrip->origin);
newClDrip->xDelta = xDelta;
newClDrip->yDelta = yDelta;
newClDrip->birthTime = rain_curtime; // store time when it was spawned
newClDrip->minHeight = deathHeight;
if (contents == CONTENTS_WATER)
newClDrip->landInWater = 1;
else
newClDrip->landInWater = 0;
// add to first place in chain
newClDrip->p_Next = FirstChainDrip.p_Next;
newClDrip->p_Prev = &FirstChainDrip;
if (newClDrip->p_Next != NULL)
newClDrip->p_Next->p_Prev = newClDrip;
FirstChainDrip.p_Next = newClDrip;
dripcounter++;
}
else
{
gEngfuncs.Con_Printf( "Rain error: Drip limit overflow!\n" );
return;
}
}
if (RainInfo) // print debug info
{
gEngfuncs.Con_Printf( "Rain info: Drips exist: %i\n", dripcounter );
gEngfuncs.Con_Printf( "Rain info: FX's exist: %i\n", fxcounter );
gEngfuncs.Con_Printf( "Rain info: Attempted/Dropped: %i, %i\n", debug_attempted, debug_dropped);
if (debug_howmany)
{
float ave = debug_lifetime / (float)debug_howmany;
gEngfuncs.Con_Printf( "Rain info: Average drip life time: %f\n", ave);
}
else
gEngfuncs.Con_Printf( "Rain info: Average drip life time: --\n");
}
return;
}
/*
=================================
WaterLandingEffect
=================================
*/
void WaterLandingEffect(cl_drip *drip)
{
if (fxcounter >= MAXFX)
{
gEngfuncs.Con_Printf( "Rain error: FX limit overflow!\n" );
return;
}
cl_rainfx *newFX = new cl_rainfx;
if (!newFX)
{
gEngfuncs.Con_Printf( "Rain error: failed to allocate FX object!\n");
return;
}
newFX->alpha = gEngfuncs.pfnRandomFloat(0.6, 0.9);
VectorCopy(drip->origin, newFX->origin);
newFX->origin[2] = drip->minHeight; // correct position
newFX->birthTime = gEngfuncs.GetClientTime();
newFX->life = gEngfuncs.pfnRandomFloat(0.7, 1);
// add to first place in chain
newFX->p_Next = FirstChainFX.p_Next;
newFX->p_Prev = &FirstChainFX;
if (newFX->p_Next != NULL)
newFX->p_Next->p_Prev = newFX;
FirstChainFX.p_Next = newFX;
fxcounter++;
}
/*
=================================
ProcessFXObjects
Remove all fx objects with out time to live
Call every frame before ProcessRain
=================================
*/
void ProcessFXObjects( void )
{
float curtime = gEngfuncs.GetClientTime();
cl_rainfx* curFX = FirstChainFX.p_Next;
cl_rainfx* nextFX = NULL;
while (curFX != NULL) // go through FX objects list
{
nextFX = curFX->p_Next; // save pointer to next
// delete current?
if ((curFX->birthTime + curFX->life) < curtime)
{
curFX->p_Prev->p_Next = curFX->p_Next; // link chain
if (nextFX != NULL)
nextFX->p_Prev = curFX->p_Prev;
delete curFX;
fxcounter--;
}
curFX = nextFX; // restore pointer
}
}
/*
=================================
ResetRain
clear memory, delete all objects
=================================
*/
void ResetRain( void )
{
// delete all drips
cl_drip* delDrip = FirstChainDrip.p_Next;
FirstChainDrip.p_Next = NULL;
while (delDrip != NULL)
{
cl_drip* nextDrip = delDrip->p_Next; // save pointer to next drip in chain
delete delDrip;
delDrip = nextDrip; // restore pointer
dripcounter--;
}
// delete all FX objects
cl_rainfx* delFX = FirstChainFX.p_Next;
FirstChainFX.p_Next = NULL;
while (delFX != NULL)
{
cl_rainfx* nextFX = delFX->p_Next;
delete delFX;
delFX = nextFX;
fxcounter--;
}
InitRain();
return;
}
/*
=================================
InitRain
initialze system
=================================
*/
void InitRain( void )
{
Rain.dripsPerSecond = 0;
Rain.distFromPlayer = 0;
Rain.windX = 0;
Rain.windY = 0;
Rain.randX = 0;
Rain.randY = 0;
Rain.weatherMode = 0;
Rain.globalHeight = 0;
FirstChainDrip.birthTime = 0;
FirstChainDrip.minHeight = 0;
FirstChainDrip.origin[0]=0;
FirstChainDrip.origin[1]=0;
FirstChainDrip.origin[2]=0;
FirstChainDrip.alpha = 0;
FirstChainDrip.xDelta = 0;
FirstChainDrip.yDelta = 0;
FirstChainDrip.landInWater = 0;
FirstChainDrip.p_Next = NULL;
FirstChainDrip.p_Prev = NULL;
FirstChainFX.alpha = 0;
FirstChainFX.birthTime = 0;
FirstChainFX.life = 0;
FirstChainFX.origin[0] = 0;
FirstChainFX.origin[1] = 0;
FirstChainFX.origin[2] = 0;
FirstChainFX.p_Next = NULL;
FirstChainFX.p_Prev = NULL;
rain_oldtime = 0;
rain_curtime = 0;
rain_nextspawntime = 0;
return;
}
/***
*
* Copyright (c) 2005, BUzer.
*
* Used with permission for Spirit of Half-Life 1.5
*
****/
/*
====== rain.cpp ========================================================
*/
#include <memory.h>
#include "hud.h"
#include "cl_util.h"
#include "const.h"
#include "entity_types.h"
#include "cdll_int.h"
#include "pm_defs.h"
#include "event_api.h"
#include "rain.h"
void WaterLandingEffect(cl_drip *drip);
rain_properties Rain;
cl_drip FirstChainDrip;
cl_rainfx FirstChainFX;
double rain_curtime; // current time
double rain_oldtime; // last time we have updated drips
double rain_timedelta; // difference between old time and current time
double rain_nextspawntime; // when the next drip should be spawned
int dripcounter = 0;
int fxcounter = 0;
int RainInfo = 0;
/*
=================================
ProcessRain
Must think every frame.
=================================
*/
void ProcessRain( void )
{
rain_oldtime = rain_curtime; // save old time
rain_curtime = gEngfuncs.GetClientTime();
rain_timedelta = rain_curtime - rain_oldtime;
// first frame
if (rain_oldtime == 0)
{
// fix first frame bug with nextspawntime
rain_nextspawntime = gEngfuncs.GetClientTime();
return;
}
if (Rain.dripsPerSecond == 0 && FirstChainDrip.p_Next == NULL)
{
// keep nextspawntime correct
rain_nextspawntime = rain_curtime;
return;
}
if (rain_timedelta == 0)
return; // not in pause
double timeBetweenDrips = 1 / (double)Rain.dripsPerSecond;
cl_drip* curDrip = FirstChainDrip.p_Next;
cl_drip* nextDrip = NULL;
// save debug info
float debug_lifetime = 0;
int debug_howmany = 0;
int debug_attempted = 0;
int debug_dropped = 0;
while (curDrip != NULL) // go through list
{
nextDrip = curDrip->p_Next; // save pointer to next drip
if (Rain.weatherMode == 0)
curDrip->origin.z -= rain_timedelta * DRIPSPEED; // rain
else
curDrip->origin.z -= rain_timedelta * SNOWSPEED; // snow
curDrip->origin.x += rain_timedelta * curDrip->xDelta;
curDrip->origin.y += rain_timedelta * curDrip->yDelta;
// remove drip if its origin lower than minHeight
if (curDrip->origin.z < curDrip->minHeight)
{
if (curDrip->landInWater/* && Rain.weatherMode == 0*/)
WaterLandingEffect(curDrip); // create water rings
if (RainInfo)
{
debug_lifetime += (rain_curtime - curDrip->birthTime);
debug_howmany++;
}
curDrip->p_Prev->p_Next = curDrip->p_Next; // link chain
if (nextDrip != NULL)
nextDrip->p_Prev = curDrip->p_Prev;
delete curDrip;
dripcounter--;
}
curDrip = nextDrip; // restore pointer, so we can continue moving through chain
}
int maxDelta; // maximum height randomize distance
float falltime;
if (Rain.weatherMode == 0)
{
maxDelta = DRIPSPEED * rain_timedelta; // for rain
falltime = (Rain.globalHeight + 4096) / DRIPSPEED;
}
else
{
maxDelta = SNOWSPEED * rain_timedelta; // for snow
falltime = (Rain.globalHeight + 4096) / SNOWSPEED;
}
while (rain_nextspawntime < rain_curtime)
{
rain_nextspawntime += timeBetweenDrips;
if (RainInfo)
debug_attempted++;
if (dripcounter < MAXDRIPS) // check for overflow
{
float deathHeight;
vec3_t vecStart, vecEnd;
vecStart[0] = gEngfuncs.pfnRandomFloat(gHUD.m_vecOrigin.x - Rain.distFromPlayer, gHUD.m_vecOrigin.x + Rain.distFromPlayer);
vecStart[1] = gEngfuncs.pfnRandomFloat(gHUD.m_vecOrigin.y - Rain.distFromPlayer, gHUD.m_vecOrigin.y + Rain.distFromPlayer);
vecStart[2] = Rain.globalHeight;
float xDelta = Rain.windX + gEngfuncs.pfnRandomFloat(Rain.randX * -1, Rain.randX);
float yDelta = Rain.windY + gEngfuncs.pfnRandomFloat(Rain.randY * -1, Rain.randY);
// find a point at bottom of map
vecEnd[0] = falltime * xDelta;
vecEnd[1] = falltime * yDelta;
vecEnd[2] = -4096;
pmtrace_t pmtrace;
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecStart, vecEnd, PM_STUDIO_IGNORE, -1, &pmtrace );
if (pmtrace.startsolid)
{
if (RainInfo)
debug_dropped++;
continue; // drip cannot be placed
}
// falling to water?
int contents = gEngfuncs.PM_PointContents( pmtrace.endpos, NULL );
if (contents == CONTENTS_WATER)
{
int waterEntity = gEngfuncs.PM_WaterEntity( pmtrace.endpos );
if ( waterEntity > 0 )
{
cl_entity_t *pwater = gEngfuncs.GetEntityByIndex( waterEntity );
if ( pwater && ( pwater->model != NULL ) )
{
deathHeight = pwater->curstate.maxs[2];
}
else
{
gEngfuncs.Con_Printf("Rain error: can't get water entity\n");
continue;
}
}
else
{
gEngfuncs.Con_Printf("Rain error: water is not func_water entity\n");
continue;
}
}
else
{
deathHeight = pmtrace.endpos[2];
}
// just in case..
if (deathHeight > vecStart[2])
{
gEngfuncs.Con_Printf("Rain error: can't create drip in water\n");
continue;
}
cl_drip *newClDrip = new cl_drip;
if (!newClDrip)
{
Rain.dripsPerSecond = 0; // disable rain
gEngfuncs.Con_Printf( "Rain error: failed to allocate object!\n");
return;
}
vecStart[2] -= gEngfuncs.pfnRandomFloat(0, maxDelta); // randomize a bit
newClDrip->alpha = gEngfuncs.pfnRandomFloat(0.12, 0.2);
VectorCopy(vecStart, newClDrip->origin);
newClDrip->xDelta = xDelta;
newClDrip->yDelta = yDelta;
newClDrip->birthTime = rain_curtime; // store time when it was spawned
newClDrip->minHeight = deathHeight;
if (contents == CONTENTS_WATER)
newClDrip->landInWater = 1;
else
newClDrip->landInWater = 0;
// add to first place in chain
newClDrip->p_Next = FirstChainDrip.p_Next;
newClDrip->p_Prev = &FirstChainDrip;
if (newClDrip->p_Next != NULL)
newClDrip->p_Next->p_Prev = newClDrip;
FirstChainDrip.p_Next = newClDrip;
dripcounter++;
}
else
{
gEngfuncs.Con_Printf( "Rain error: Drip limit overflow!\n" );
return;
}
}
if (RainInfo) // print debug info
{
gEngfuncs.Con_Printf( "Rain info: Drips exist: %i\n", dripcounter );
gEngfuncs.Con_Printf( "Rain info: FX's exist: %i\n", fxcounter );
gEngfuncs.Con_Printf( "Rain info: Attempted/Dropped: %i, %i\n", debug_attempted, debug_dropped);
if (debug_howmany)
{
float ave = debug_lifetime / (float)debug_howmany;
gEngfuncs.Con_Printf( "Rain info: Average drip life time: %f\n", ave);
}
else
gEngfuncs.Con_Printf( "Rain info: Average drip life time: --\n");
}
return;
}
/*
=================================
WaterLandingEffect
=================================
*/
void WaterLandingEffect(cl_drip *drip)
{
if (fxcounter >= MAXFX)
{
gEngfuncs.Con_Printf( "Rain error: FX limit overflow!\n" );
return;
}
cl_rainfx *newFX = new cl_rainfx;
if (!newFX)
{
gEngfuncs.Con_Printf( "Rain error: failed to allocate FX object!\n");
return;
}
newFX->alpha = gEngfuncs.pfnRandomFloat(0.6, 0.9);
VectorCopy(drip->origin, newFX->origin);
newFX->origin[2] = drip->minHeight; // correct position
newFX->birthTime = gEngfuncs.GetClientTime();
newFX->life = gEngfuncs.pfnRandomFloat(0.7, 1);
// add to first place in chain
newFX->p_Next = FirstChainFX.p_Next;
newFX->p_Prev = &FirstChainFX;
if (newFX->p_Next != NULL)
newFX->p_Next->p_Prev = newFX;
FirstChainFX.p_Next = newFX;
fxcounter++;
}
/*
=================================
ProcessFXObjects
Remove all fx objects with out time to live
Call every frame before ProcessRain
=================================
*/
void ProcessFXObjects( void )
{
float curtime = gEngfuncs.GetClientTime();
cl_rainfx* curFX = FirstChainFX.p_Next;
cl_rainfx* nextFX = NULL;
while (curFX != NULL) // go through FX objects list
{
nextFX = curFX->p_Next; // save pointer to next
// delete current?
if ((curFX->birthTime + curFX->life) < curtime)
{
curFX->p_Prev->p_Next = curFX->p_Next; // link chain
if (nextFX != NULL)
nextFX->p_Prev = curFX->p_Prev;
delete curFX;
fxcounter--;
}
curFX = nextFX; // restore pointer
}
}
/*
=================================
ResetRain
clear memory, delete all objects
=================================
*/
void ResetRain( void )
{
// delete all drips
cl_drip* delDrip = FirstChainDrip.p_Next;
FirstChainDrip.p_Next = NULL;
while (delDrip != NULL)
{
cl_drip* nextDrip = delDrip->p_Next; // save pointer to next drip in chain
delete delDrip;
delDrip = nextDrip; // restore pointer
dripcounter--;
}
// delete all FX objects
cl_rainfx* delFX = FirstChainFX.p_Next;
FirstChainFX.p_Next = NULL;
while (delFX != NULL)
{
cl_rainfx* nextFX = delFX->p_Next;
delete delFX;
delFX = nextFX;
fxcounter--;
}
InitRain();
return;
}
/*
=================================
InitRain
initialze system
=================================
*/
void InitRain( void )
{
Rain.dripsPerSecond = 0;
Rain.distFromPlayer = 0;
Rain.windX = 0;
Rain.windY = 0;
Rain.randX = 0;
Rain.randY = 0;
Rain.weatherMode = 0;
Rain.globalHeight = 0;
FirstChainDrip.birthTime = 0;
FirstChainDrip.minHeight = 0;
FirstChainDrip.origin[0]=0;
FirstChainDrip.origin[1]=0;
FirstChainDrip.origin[2]=0;
FirstChainDrip.alpha = 0;
FirstChainDrip.xDelta = 0;
FirstChainDrip.yDelta = 0;
FirstChainDrip.landInWater = 0;
FirstChainDrip.p_Next = NULL;
FirstChainDrip.p_Prev = NULL;
FirstChainFX.alpha = 0;
FirstChainFX.birthTime = 0;
FirstChainFX.life = 0;
FirstChainFX.origin[0] = 0;
FirstChainFX.origin[1] = 0;
FirstChainFX.origin[2] = 0;
FirstChainFX.p_Next = NULL;
FirstChainFX.p_Prev = NULL;
rain_oldtime = 0;
rain_curtime = 0;
rain_nextspawntime = 0;
return;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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 );
}

View File

@ -1,312 +1,312 @@
//========= 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"
#include "rain.h"
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
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
#ifdef _MSC_VER
extern "C" {
#endif
void AngleMatrix (const float angles[3], float (*matrix)[4]);
void VectorTransform (const float in1[3], float in2[3][4], float out[3]);
#ifdef _MSC_VER
}
#endif
void SetPoint( float x, float y, float z, float (*matrix)[4])
{
vec3_t point, result;
point[0] = x;
point[1] = y;
point[2] = z;
VectorTransform(point, matrix, result);
gEngfuncs.pTriAPI->Vertex3f(result[0], result[1], result[2]);
}
/*
=================================
DrawRain
draw raindrips and snowflakes
=================================
*/
void DrawRain( void )
{
if (FirstChainDrip.p_Next == NULL)
return; // no drips to draw
float visibleHeight = Rain.globalHeight - SNOWFADEDIST;
// usual triapi stuff
HSPRITE hsprTexture;
if( Rain.weatherMode == 0 )
hsprTexture = LoadSprite("sprites/effects/rain.spr");
else
hsprTexture = LoadSprite("sprites/effects/snowflake.spr");
const model_s *pTexture = gEngfuncs.GetSpritePointer(hsprTexture);
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)pTexture, 0 );
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
// go through drips list
cl_drip* Drip = FirstChainDrip.p_Next;
cl_entity_t *player = gEngfuncs.GetLocalPlayer();
if ( Rain.weatherMode == 0 ) // draw rain
{
while (Drip != NULL)
{
cl_drip* nextdDrip = Drip->p_Next;
Vector2D toPlayer;
toPlayer.x = player->origin[0] - Drip->origin[0];
toPlayer.y = player->origin[1] - Drip->origin[1];
toPlayer = toPlayer.Normalize();
toPlayer.x *= DRIP_SPRITE_HALFWIDTH;
toPlayer.y *= DRIP_SPRITE_HALFWIDTH;
float shiftX = (Drip->xDelta / DRIPSPEED) * DRIP_SPRITE_HALFHEIGHT;
float shiftY = (Drip->yDelta / DRIPSPEED) * DRIP_SPRITE_HALFHEIGHT;
// --- draw triangle --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, Drip->alpha );
gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f( Drip->origin[0]-toPlayer.y - shiftX, Drip->origin[1]+toPlayer.x - shiftY,Drip->origin[2] + DRIP_SPRITE_HALFHEIGHT );
gEngfuncs.pTriAPI->TexCoord2f( 0.5, 1 );
gEngfuncs.pTriAPI->Vertex3f( Drip->origin[0] + shiftX, Drip->origin[1] + shiftY, Drip->origin[2]-DRIP_SPRITE_HALFHEIGHT );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f( Drip->origin[0]+toPlayer.y - shiftX, Drip->origin[1]-toPlayer.x - shiftY, Drip->origin[2]+DRIP_SPRITE_HALFHEIGHT);
gEngfuncs.pTriAPI->End();
// --- draw triangle end ----------------------
Drip = nextdDrip;
}
}
else // draw snow
{
vec3_t normal;
gEngfuncs.GetViewAngles((float*)normal);
float matrix[3][4];
AngleMatrix (normal, matrix); // calc view matrix
while (Drip != NULL)
{
cl_drip* nextdDrip = Drip->p_Next;
matrix[0][3] = Drip->origin[0]; // write origin to matrix
matrix[1][3] = Drip->origin[1];
matrix[2][3] = Drip->origin[2];
// apply start fading effect
float alpha = (Drip->origin[2] <= visibleHeight) ? Drip->alpha : ((Rain.globalHeight - Drip->origin[2]) / (float)SNOWFADEDIST) * Drip->alpha;
// --- draw quad --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, alpha );
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
SetPoint(0, SNOW_SPRITE_HALFSIZE ,SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
SetPoint(0, SNOW_SPRITE_HALFSIZE ,-SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
SetPoint(0, -SNOW_SPRITE_HALFSIZE ,-SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
SetPoint(0, -SNOW_SPRITE_HALFSIZE ,SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->End();
// --- draw quad end ----------------------
Drip = nextdDrip;
}
}
}
/*
=================================
DrawFXObjects
=================================
*/
void DrawFXObjects( void )
{
if (FirstChainFX.p_Next == NULL)
return; // no objects to draw
float curtime = gEngfuncs.GetClientTime();
// usual triapi stuff
HSPRITE hsprTexture = LoadSprite("sprites/effects/ripple.spr");
const model_s *pTexture = gEngfuncs.GetSpritePointer( hsprTexture );
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)pTexture, 0 );
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
// go through objects list
cl_rainfx* curFX = FirstChainFX.p_Next;
while (curFX != NULL)
{
cl_rainfx* nextFX = curFX->p_Next;
// fadeout
float alpha = ((curFX->birthTime + curFX->life - curtime) / curFX->life) * curFX->alpha;
float size = (curtime - curFX->birthTime) * MAXRINGHALFSIZE;
// --- draw quad --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, alpha );
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] - size, curFX->origin[1] - size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] - size, curFX->origin[1] + size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] + size, curFX->origin[1] + size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] + size, curFX->origin[1] - size, curFX->origin[2]);
gEngfuncs.pTriAPI->End();
// --- draw quad end ----------------------
curFX = nextFX;
}
}
/*
=================
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 )
{
ProcessFXObjects();
ProcessRain();
DrawRain();
DrawFXObjects();
#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"
#include "rain.h"
#ifdef _WIN32
#define DLLEXPORT __declspec( dllexport )
#else
#define DLLEXPORT
#endif
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
#ifdef _MSC_VER
extern "C" {
#endif
void AngleMatrix (const float angles[3], float (*matrix)[4]);
void VectorTransform (const float in1[3], float in2[3][4], float out[3]);
#ifdef _MSC_VER
}
#endif
void SetPoint( float x, float y, float z, float (*matrix)[4])
{
vec3_t point, result;
point[0] = x;
point[1] = y;
point[2] = z;
VectorTransform(point, matrix, result);
gEngfuncs.pTriAPI->Vertex3f(result[0], result[1], result[2]);
}
/*
=================================
DrawRain
draw raindrips and snowflakes
=================================
*/
void DrawRain( void )
{
if (FirstChainDrip.p_Next == NULL)
return; // no drips to draw
float visibleHeight = Rain.globalHeight - SNOWFADEDIST;
// usual triapi stuff
HSPRITE hsprTexture;
if( Rain.weatherMode == 0 )
hsprTexture = LoadSprite("sprites/effects/rain.spr");
else
hsprTexture = LoadSprite("sprites/effects/snowflake.spr");
const model_s *pTexture = gEngfuncs.GetSpritePointer(hsprTexture);
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)pTexture, 0 );
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
// go through drips list
cl_drip* Drip = FirstChainDrip.p_Next;
cl_entity_t *player = gEngfuncs.GetLocalPlayer();
if ( Rain.weatherMode == 0 ) // draw rain
{
while (Drip != NULL)
{
cl_drip* nextdDrip = Drip->p_Next;
Vector2D toPlayer;
toPlayer.x = player->origin[0] - Drip->origin[0];
toPlayer.y = player->origin[1] - Drip->origin[1];
toPlayer = toPlayer.Normalize();
toPlayer.x *= DRIP_SPRITE_HALFWIDTH;
toPlayer.y *= DRIP_SPRITE_HALFWIDTH;
float shiftX = (Drip->xDelta / DRIPSPEED) * DRIP_SPRITE_HALFHEIGHT;
float shiftY = (Drip->yDelta / DRIPSPEED) * DRIP_SPRITE_HALFHEIGHT;
// --- draw triangle --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, Drip->alpha );
gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f( Drip->origin[0]-toPlayer.y - shiftX, Drip->origin[1]+toPlayer.x - shiftY,Drip->origin[2] + DRIP_SPRITE_HALFHEIGHT );
gEngfuncs.pTriAPI->TexCoord2f( 0.5, 1 );
gEngfuncs.pTriAPI->Vertex3f( Drip->origin[0] + shiftX, Drip->origin[1] + shiftY, Drip->origin[2]-DRIP_SPRITE_HALFHEIGHT );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f( Drip->origin[0]+toPlayer.y - shiftX, Drip->origin[1]-toPlayer.x - shiftY, Drip->origin[2]+DRIP_SPRITE_HALFHEIGHT);
gEngfuncs.pTriAPI->End();
// --- draw triangle end ----------------------
Drip = nextdDrip;
}
}
else // draw snow
{
vec3_t normal;
gEngfuncs.GetViewAngles((float*)normal);
float matrix[3][4];
AngleMatrix (normal, matrix); // calc view matrix
while (Drip != NULL)
{
cl_drip* nextdDrip = Drip->p_Next;
matrix[0][3] = Drip->origin[0]; // write origin to matrix
matrix[1][3] = Drip->origin[1];
matrix[2][3] = Drip->origin[2];
// apply start fading effect
float alpha = (Drip->origin[2] <= visibleHeight) ? Drip->alpha : ((Rain.globalHeight - Drip->origin[2]) / (float)SNOWFADEDIST) * Drip->alpha;
// --- draw quad --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, alpha );
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
SetPoint(0, SNOW_SPRITE_HALFSIZE ,SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
SetPoint(0, SNOW_SPRITE_HALFSIZE ,-SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
SetPoint(0, -SNOW_SPRITE_HALFSIZE ,-SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
SetPoint(0, -SNOW_SPRITE_HALFSIZE ,SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->End();
// --- draw quad end ----------------------
Drip = nextdDrip;
}
}
}
/*
=================================
DrawFXObjects
=================================
*/
void DrawFXObjects( void )
{
if (FirstChainFX.p_Next == NULL)
return; // no objects to draw
float curtime = gEngfuncs.GetClientTime();
// usual triapi stuff
HSPRITE hsprTexture = LoadSprite("sprites/effects/ripple.spr");
const model_s *pTexture = gEngfuncs.GetSpritePointer( hsprTexture );
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)pTexture, 0 );
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
// go through objects list
cl_rainfx* curFX = FirstChainFX.p_Next;
while (curFX != NULL)
{
cl_rainfx* nextFX = curFX->p_Next;
// fadeout
float alpha = ((curFX->birthTime + curFX->life - curtime) / curFX->life) * curFX->alpha;
float size = (curtime - curFX->birthTime) * MAXRINGHALFSIZE;
// --- draw quad --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, alpha );
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] - size, curFX->origin[1] - size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] - size, curFX->origin[1] + size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] + size, curFX->origin[1] + size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] + size, curFX->origin[1] - size, curFX->origin[2]);
gEngfuncs.pTriAPI->End();
// --- draw quad end ----------------------
curFX = nextFX;
}
}
/*
=================
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 )
{
ProcessFXObjects();
ProcessRain();
DrawRain();
DrawFXObjects();
#if defined( TEST_IT )
// Draw_Triangles();
#endif
}

View File

@ -1,198 +1,198 @@
/***
*
* 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
//vec3_t vec3_origin( 0, 0, 0 );
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);
}
int HUD_GetSpriteIndexByName( const char *sz )
{
return gHUD.GetSpriteIndex(sz);
}
HSPRITE HUD_GetSprite( int index )
{
return gHUD.GetSprite(index);
}
wrect_t HUD_GetSpriteRect( int index )
{
return gHUD.GetSpriteRect( index );
}
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 TEAM_TERRORIST: return g_ColorRed;
case TEAM_CT: return g_ColorBlue;
case TEAM_SPECTATOR:
case TEAM_UNASSIGNED: return g_ColorYellow;
case 4: return g_ColorGreen;
default: return g_ColorGrey;
}
}
void GetTeamColor(int &r, int &g, int &b, int teamIndex)
{
r = 255;
g = 255;
b = 255;
switch( teamIndex )
{
case TEAM_TERRORIST:
r *= g_ColorRed[0];
g *= g_ColorRed[1];
b *= g_ColorRed[2];
break;
case TEAM_CT:
r *= g_ColorBlue[0];
g *= g_ColorBlue[1];
b *= g_ColorBlue[2];
break;
case TEAM_SPECTATOR:
case TEAM_UNASSIGNED:
r *= g_ColorYellow[0];
g *= g_ColorYellow[1];
b *= g_ColorYellow[2];
break;
default:
r *= g_ColorGrey[0];
g *= g_ColorGrey[1];
b *= g_ColorGrey[2];
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.
*
****/
//
// 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
//vec3_t vec3_origin( 0, 0, 0 );
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);
}
int HUD_GetSpriteIndexByName( const char *sz )
{
return gHUD.GetSpriteIndex(sz);
}
HSPRITE HUD_GetSprite( int index )
{
return gHUD.GetSprite(index);
}
wrect_t HUD_GetSpriteRect( int index )
{
return gHUD.GetSpriteRect( index );
}
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 TEAM_TERRORIST: return g_ColorRed;
case TEAM_CT: return g_ColorBlue;
case TEAM_SPECTATOR:
case TEAM_UNASSIGNED: return g_ColorYellow;
case 4: return g_ColorGreen;
default: return g_ColorGrey;
}
}
void GetTeamColor(int &r, int &g, int &b, int teamIndex)
{
r = 255;
g = 255;
b = 255;
switch( teamIndex )
{
case TEAM_TERRORIST:
r *= g_ColorRed[0];
g *= g_ColorRed[1];
b *= g_ColorRed[2];
break;
case TEAM_CT:
r *= g_ColorBlue[0];
g *= g_ColorBlue[1];
b *= g_ColorBlue[2];
break;
case TEAM_SPECTATOR:
case TEAM_UNASSIGNED:
r *= g_ColorYellow[0];
g *= g_ColorYellow[1];
b *= g_ColorYellow[2];
break;
default:
r *= g_ColorGrey[0];
g *= g_ColorGrey[1];
b *= g_ColorGrey[2];
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,64 @@
/***
*
* 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.
*
****/
#if !defined ( BEAMDEFH )
#define BEAMDEFH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
#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
/***
*
* 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.
*
****/
#if !defined ( BEAMDEFH )
#define BEAMDEFH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
#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

View File

@ -1,117 +1,117 @@
/***
*
* 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_entity.h
#if !defined( CL_ENTITYH )
#define CL_ENTITYH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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 )
#if !defined( ENTITY_STATEH )
#include "entity_state.h"
#endif
#if !defined( PROGS_H )
#include "progs.h"
#endif
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_ENTITYH
/***
*
* 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_entity.h
#if !defined( CL_ENTITYH )
#define CL_ENTITYH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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 )
#if !defined( ENTITY_STATEH )
#include "entity_state.h"
#endif
#if !defined( PROGS_H )
#include "progs.h"
#endif
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_ENTITYH

View File

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

View File

@ -1,33 +1,33 @@
/***
*
* 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.
*
****/
#if !defined( CON_NPRINTH )
#define CON_NPRINTH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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;
void Con_NPrintf( int idx, char *fmt, ... );
void Con_NXPrintf( struct con_nprint_s *info, char *fmt, ... );
#endif
/***
*
* 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.
*
****/
#if !defined( CON_NPRINTH )
#define CON_NPRINTH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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;
void Con_NPrintf( int idx, char *fmt, ... );
void Con_NXPrintf( struct con_nprint_s *info, char *fmt, ... );
#endif

View File

@ -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.
*
****/
/* crc.h */
#ifndef CRC_H
#define CRC_H
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// MD5 Hash
typedef struct
{
unsigned int buf[4];
unsigned int bits[2];
unsigned char in[64];
} MD5Context_t;
typedef unsigned long CRC32_t;
void CRC32_Init(CRC32_t *pulCRC);
CRC32_t CRC32_Final(CRC32_t pulCRC);
void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len);
void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch);
int CRC_File(CRC32_t *crcvalue, char *pszFileName);
unsigned char COM_BlockSequenceCRCByte (unsigned char *base, int length, int sequence);
void MD5Init(MD5Context_t *context);
void MD5Update(MD5Context_t *context, unsigned char const *buf,
unsigned int len);
void MD5Final(unsigned char digest[16], MD5Context_t *context);
void Transform(unsigned int buf[4], unsigned int const in[16]);
int MD5_Hash_File(unsigned char digest[16], char *pszFileName, int bUsefopen, int bSeed, unsigned int seed[4]);
char *MD5_Print(unsigned char hash[16]);
int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char *pCache, int nFileSize, int bSeed, unsigned int seed[4]);
int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName);
#endif
/***
*
* 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.
*
****/
/* crc.h */
#ifndef CRC_H
#define CRC_H
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// MD5 Hash
typedef struct
{
unsigned int buf[4];
unsigned int bits[2];
unsigned char in[64];
} MD5Context_t;
typedef unsigned long CRC32_t;
void CRC32_Init(CRC32_t *pulCRC);
CRC32_t CRC32_Final(CRC32_t pulCRC);
void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len);
void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch);
int CRC_File(CRC32_t *crcvalue, char *pszFileName);
unsigned char COM_BlockSequenceCRCByte (unsigned char *base, int length, int sequence);
void MD5Init(MD5Context_t *context);
void MD5Update(MD5Context_t *context, unsigned char const *buf,
unsigned int len);
void MD5Final(unsigned char digest[16], MD5Context_t *context);
void Transform(unsigned int buf[4], unsigned int const in[16]);
int MD5_Hash_File(unsigned char digest[16], char *pszFileName, int bUsefopen, int bSeed, unsigned int seed[4]);
char *MD5_Print(unsigned char hash[16]);
int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char *pCache, int nFileSize, int bSeed, unsigned int seed[4]);
int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName);
#endif

View File

@ -1,36 +1,36 @@
/***
*
* 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
/***
*
* 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

View File

@ -1,33 +1,33 @@
/***
*
* 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.
*
****/
#if !defined ( DEMO_APIH )
#define DEMO_APIH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
typedef struct demo_api_s
{
int ( *IsRecording ) ( void );
int ( *IsPlayingback ) ( void );
int ( *IsTimeDemo ) ( void );
void ( *WriteBuffer ) ( int size, unsigned char *buffer );
} demo_api_t;
extern demo_api_t demoapi;
#endif
/***
*
* 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.
*
****/
#if !defined ( DEMO_APIH )
#define DEMO_APIH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
typedef struct demo_api_s
{
int ( *IsRecording ) ( void );
int ( *IsPlayingback ) ( void );
int ( *IsTimeDemo ) ( void );
void ( *WriteBuffer ) ( int size, unsigned char *buffer );
} demo_api_t;
extern demo_api_t demoapi;
#endif

View File

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

View File

@ -1,35 +1,35 @@
/***
*
* 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.
*
****/
#if !defined ( DLIGHTH )
#define DLIGHTH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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
/***
*
* 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.
*
****/
#if !defined ( DLIGHTH )
#define DLIGHTH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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

View File

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

View File

@ -1,112 +1,112 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// engine/launcher interface
#if !defined( ENGINE_LAUNCHER_APIH )
#define ENGINE_LAUNCHER_APIH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
//typedef void ( *xcommand_t ) ( void );
#define RENDERTYPE_UNDEFINED 0
#define RENDERTYPE_SOFTWARE 1
#define RENDERTYPE_HARDWARE 2
#define ENGINE_LAUNCHER_API_VERSION 1
typedef struct engine_api_s
{
int version;
int rendertype;
int size;
// Functions
int ( *GetEngineState ) ( void );
void ( *Cbuf_AddText ) ( char *text ); // append cmd at end of buf
void ( *Cbuf_InsertText ) ( char *text ); // insert cmd at start of buf
void ( *Cmd_AddCommand ) ( char *cmd_name, void ( *funcname )( void ) );
int ( *Cmd_Argc ) ( void );
char *( *Cmd_Args ) ( void );
char *( *Cmd_Argv ) ( int arg );
void ( *Con_Printf ) ( char *, ... );
void ( *Con_SafePrintf ) ( char *, ... );
void ( *Cvar_Set ) ( char *var_name, char *value );
void ( *Cvar_SetValue ) ( char *var_name, float value );
int ( *Cvar_VariableInt ) ( char *var_name );
char *( *Cvar_VariableString ) ( char *var_name );
float ( *Cvar_VariableValue ) ( char *var_name );
void ( *ForceReloadProfile ) ( void );
int ( *GetGameInfo ) ( struct GameInfo_s *pGI, char *pszChannel );
void ( *GameSetBackground ) ( int bBack );
void ( *GameSetState ) ( int iState );
void ( *GameSetSubState ) ( int iState );
int ( *GetPauseState ) ( void );
int ( *Host_Frame ) ( float time, int iState, int *stateInfo );
void ( *Host_GetHostInfo ) ( float *fps, int *nActive, int *nSpectators, int *nMaxPlayers, char *pszMap );
void ( *Host_Shutdown ) ( void );
int ( *Game_Init ) ( char *lpCmdLine, unsigned char *pMem, int iSize, struct exefuncs_s *pef, void *, int );
void ( *IN_ActivateMouse ) ( void );
void ( *IN_ClearStates ) ( void );
void ( *IN_DeactivateMouse ) ( void );
void ( *IN_MouseEvent ) ( int mstate );
void ( *Keyboard_ReturnToGame ) ( void );
void ( *Key_ClearStates ) ( void );
void ( *Key_Event ) ( int key, int down );
int ( *LoadGame ) ( const char *pszSlot );
void ( *S_BlockSound ) ( void );
void ( *S_ClearBuffer ) ( void );
void ( *S_GetDSPointer ) ( struct IDirectSound **lpDS, struct IDirectSoundBuffer **lpDSBuf );
void *( *S_GetWAVPointer ) ( void );
void ( *S_UnblockSound ) ( void );
int ( *SaveGame ) ( const char *pszSlot, const char *pszComment );
void ( *SetAuth ) ( void *pobj );
void ( *SetMessagePumpDisableMode ) ( int bMode );
void ( *SetPauseState ) ( int bPause );
void ( *SetStartupMode ) ( int bMode );
void ( *SNDDMA_Shutdown ) ( void );
void ( *Snd_AcquireBuffer ) ( void );
void ( *Snd_ReleaseBuffer ) ( void );
void ( *StoreProfile ) ( void );
double ( *Sys_FloatTime ) ( void );
void ( *VID_UpdateWindowVars ) ( void *prc, int x, int y );
void ( *VID_UpdateVID ) ( struct viddef_s *pvid );
// VGUI interfaces
void ( *VGui_CallEngineSurfaceProc ) ( void* hwnd, unsigned int msg, unsigned int wparam, long lparam );
// notifications that the launcher is taking/giving focus to the engine
void ( *EngineTakingFocus ) ( void );
void ( *LauncherTakingFocus ) ( void );
#ifdef _WIN32
// Only filled in by rendertype RENDERTYPE_HARDWARE
void ( *GL_Init ) ( void );
int ( *GL_SetMode ) ( HWND hwndGame, HDC *pmaindc, HGLRC *pbaseRC, int fD3D, const char *p, const char *pszCmdLine );
void ( *GL_Shutdown ) ( HWND hwnd, HDC hdc, HGLRC hglrc );
void ( *QGL_D3DShared ) ( struct tagD3DGlobals *d3dGShared );
int ( WINAPI *glSwapBuffers ) ( HDC dc );
void ( *DirectorProc ) ( unsigned int cmd, void * params );
#else
// NOT USED IN LINUX!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void ( *GL_Init ) ( void );
void ( *GL_SetMode ) ( void );
void ( *GL_Shutdown ) ( void );
void ( *QGL_D3DShared ) ( void );
void ( *glSwapBuffers ) ( void );
void ( *DirectorProc ) ( void );
// LINUX
#endif
} engine_api_t;
#endif // ENGINE_LAUNCHER_APIH
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// engine/launcher interface
#if !defined( ENGINE_LAUNCHER_APIH )
#define ENGINE_LAUNCHER_APIH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
//typedef void ( *xcommand_t ) ( void );
#define RENDERTYPE_UNDEFINED 0
#define RENDERTYPE_SOFTWARE 1
#define RENDERTYPE_HARDWARE 2
#define ENGINE_LAUNCHER_API_VERSION 1
typedef struct engine_api_s
{
int version;
int rendertype;
int size;
// Functions
int ( *GetEngineState ) ( void );
void ( *Cbuf_AddText ) ( char *text ); // append cmd at end of buf
void ( *Cbuf_InsertText ) ( char *text ); // insert cmd at start of buf
void ( *Cmd_AddCommand ) ( char *cmd_name, void ( *funcname )( void ) );
int ( *Cmd_Argc ) ( void );
char *( *Cmd_Args ) ( void );
char *( *Cmd_Argv ) ( int arg );
void ( *Con_Printf ) ( char *, ... );
void ( *Con_SafePrintf ) ( char *, ... );
void ( *Cvar_Set ) ( char *var_name, char *value );
void ( *Cvar_SetValue ) ( char *var_name, float value );
int ( *Cvar_VariableInt ) ( char *var_name );
char *( *Cvar_VariableString ) ( char *var_name );
float ( *Cvar_VariableValue ) ( char *var_name );
void ( *ForceReloadProfile ) ( void );
int ( *GetGameInfo ) ( struct GameInfo_s *pGI, char *pszChannel );
void ( *GameSetBackground ) ( int bBack );
void ( *GameSetState ) ( int iState );
void ( *GameSetSubState ) ( int iState );
int ( *GetPauseState ) ( void );
int ( *Host_Frame ) ( float time, int iState, int *stateInfo );
void ( *Host_GetHostInfo ) ( float *fps, int *nActive, int *nSpectators, int *nMaxPlayers, char *pszMap );
void ( *Host_Shutdown ) ( void );
int ( *Game_Init ) ( char *lpCmdLine, unsigned char *pMem, int iSize, struct exefuncs_s *pef, void *, int );
void ( *IN_ActivateMouse ) ( void );
void ( *IN_ClearStates ) ( void );
void ( *IN_DeactivateMouse ) ( void );
void ( *IN_MouseEvent ) ( int mstate );
void ( *Keyboard_ReturnToGame ) ( void );
void ( *Key_ClearStates ) ( void );
void ( *Key_Event ) ( int key, int down );
int ( *LoadGame ) ( const char *pszSlot );
void ( *S_BlockSound ) ( void );
void ( *S_ClearBuffer ) ( void );
void ( *S_GetDSPointer ) ( struct IDirectSound **lpDS, struct IDirectSoundBuffer **lpDSBuf );
void *( *S_GetWAVPointer ) ( void );
void ( *S_UnblockSound ) ( void );
int ( *SaveGame ) ( const char *pszSlot, const char *pszComment );
void ( *SetAuth ) ( void *pobj );
void ( *SetMessagePumpDisableMode ) ( int bMode );
void ( *SetPauseState ) ( int bPause );
void ( *SetStartupMode ) ( int bMode );
void ( *SNDDMA_Shutdown ) ( void );
void ( *Snd_AcquireBuffer ) ( void );
void ( *Snd_ReleaseBuffer ) ( void );
void ( *StoreProfile ) ( void );
double ( *Sys_FloatTime ) ( void );
void ( *VID_UpdateWindowVars ) ( void *prc, int x, int y );
void ( *VID_UpdateVID ) ( struct viddef_s *pvid );
// VGUI interfaces
void ( *VGui_CallEngineSurfaceProc ) ( void* hwnd, unsigned int msg, unsigned int wparam, long lparam );
// notifications that the launcher is taking/giving focus to the engine
void ( *EngineTakingFocus ) ( void );
void ( *LauncherTakingFocus ) ( void );
#ifdef _WIN32
// Only filled in by rendertype RENDERTYPE_HARDWARE
void ( *GL_Init ) ( void );
int ( *GL_SetMode ) ( HWND hwndGame, HDC *pmaindc, HGLRC *pbaseRC, int fD3D, const char *p, const char *pszCmdLine );
void ( *GL_Shutdown ) ( HWND hwnd, HDC hdc, HGLRC hglrc );
void ( *QGL_D3DShared ) ( struct tagD3DGlobals *d3dGShared );
int ( WINAPI *glSwapBuffers ) ( HDC dc );
void ( *DirectorProc ) ( unsigned int cmd, void * params );
#else
// NOT USED IN LINUX!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void ( *GL_Init ) ( void );
void ( *GL_SetMode ) ( void );
void ( *GL_Shutdown ) ( void );
void ( *QGL_D3DShared ) ( void );
void ( *glSwapBuffers ) ( void );
void ( *DirectorProc ) ( void );
// LINUX
#endif
} engine_api_t;
#endif // ENGINE_LAUNCHER_APIH

View File

@ -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.
*
****/
#if !defined( ENTITY_STATEH )
#define ENTITY_STATEH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// 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[ 32 ];
} local_state_t;
#endif // !ENTITY_STATEH
/***
*
* 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.
*
****/
#if !defined( ENTITY_STATEH )
#define ENTITY_STATEH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// 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[ 32 ];
} local_state_t;
#endif // !ENTITY_STATEH

View File

@ -1,26 +1,26 @@
/***
*
* 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.
*
****/
// entity_types.h
#if !defined( ENTITY_TYPESH )
#define ENTITY_TYPESH
#define ET_NORMAL 0
#define ET_PLAYER 1
#define ET_TEMPENTITY 2
#define ET_BEAM 3
// BMODEL or SPRITE that was split across BSP nodes
#define ET_FRAGMENTED 4
#endif // !ENTITY_TYPESH
/***
*
* 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.
*
****/
// entity_types.h
#if !defined( ENTITY_TYPESH )
#define ENTITY_TYPESH
#define ET_NORMAL 0
#define ET_PLAYER 1
#define ET_TEMPENTITY 2
#define ET_BEAM 3
// BMODEL or SPRITE that was split across BSP nodes
#define ET_FRAGMENTED 4
#endif // !ENTITY_TYPESH

View File

@ -1,53 +1,53 @@
/***
*
* 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.
*
****/
#if !defined ( EVENT_APIH )
#define EVENT_APIH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
#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 );
} event_api_t;
extern event_api_t eventapi;
#endif
/***
*
* 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.
*
****/
#if !defined ( EVENT_APIH )
#define EVENT_APIH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
#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 );
} event_api_t;
extern event_api_t eventapi;
#endif

View File

@ -1,52 +1,52 @@
/***
*
* 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.
*
****/
#if !defined( EVENT_ARGSH )
#define EVENT_ARGSH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// 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
/***
*
* 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.
*
****/
#if !defined( EVENT_ARGSH )
#define EVENT_ARGSH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// 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

View File

@ -1,49 +1,49 @@
/***
*
* 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.
*
****/
#if !defined( EVENT_FLAGSH )
#define EVENT_FLAGSH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// 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
/***
*
* 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.
*
****/
#if !defined( EVENT_FLAGSH )
#define EVENT_FLAGSH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// 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

View File

@ -1,50 +1,50 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// exefuncs.h
#ifndef EXEFUNCS_H
#define EXEFUNCS_H
// Engine hands this to DLLs for functionality callbacks
typedef struct exefuncs_s
{
int fMMX;
int iCPUMhz;
void (*unused1)(void);
void (*unused2)(void);
void (*unused3)(void);
void (*unused4)(void);
void (*VID_ForceLockState)(int lk);
int (*VID_ForceUnlockedAndReturnState)(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 (*ErrorMessage)(int nLevel, const char *pszErrorMessage);
void (*unused16)(void);
void (*Sys_Printf)(char *fmt, ...);
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);
} exefuncs_t;
#endif
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// exefuncs.h
#ifndef EXEFUNCS_H
#define EXEFUNCS_H
// Engine hands this to DLLs for functionality callbacks
typedef struct exefuncs_s
{
int fMMX;
int iCPUMhz;
void (*unused1)(void);
void (*unused2)(void);
void (*unused3)(void);
void (*unused4)(void);
void (*VID_ForceLockState)(int lk);
int (*VID_ForceUnlockedAndReturnState)(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 (*ErrorMessage)(int nLevel, const char *pszErrorMessage);
void (*unused16)(void);
void (*Sys_Printf)(char *fmt, ...);
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);
} exefuncs_t;
#endif

View File

@ -1,57 +1,57 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// hltv.h
// all shared consts between server, clients and proxy
#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
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// hltv.h
// all shared consts between server, clients and proxy
#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

View File

@ -1,43 +1,43 @@
/***
*
* 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 IN_BUTTONS_H
#define IN_BUTTONS_H
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
#ifndef CONST_H
#define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4)
#define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10)
#define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14)
#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down
#endif
#endif // IN_BUTTONS_H
/***
*
* 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 IN_BUTTONS_H
#define IN_BUTTONS_H
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
#ifndef CONST_H
#define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4)
#define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10)
#define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14)
#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down
#endif
#endif // IN_BUTTONS_H

View File

@ -1,150 +1,150 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include <string.h>
#include <stdlib.h>
#include "interface.h"
#ifndef _WIN32 // LINUX
#include <dlfcn.h>
#include <unistd.h> // getcwd
#include <stdio.h> // sprintf
#endif
// ------------------------------------------------------------------------------------ //
// InterfaceReg.
// ------------------------------------------------------------------------------------ //
InterfaceReg *InterfaceReg::s_pInterfaceRegs = NULL;
InterfaceReg::InterfaceReg( InstantiateInterfaceFn fn, const char *pName ) :
m_pName(pName)
{
m_CreateFn = fn;
m_pNext = s_pInterfaceRegs;
s_pInterfaceRegs = this;
}
// ------------------------------------------------------------------------------------ //
// CreateInterface.
// ------------------------------------------------------------------------------------ //
EXPORT_FUNCTION IBaseInterface *CreateInterface( const char *pName, int *pReturnCode )
{
InterfaceReg *pCur;
for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext)
{
if(strcmp(pCur->m_pName, pName) == 0)
{
if ( pReturnCode )
{
*pReturnCode = IFACE_OK;
}
return pCur->m_CreateFn();
}
}
if ( pReturnCode )
{
*pReturnCode = IFACE_FAILED;
}
return NULL;
}
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef _WIN32
HINTERFACEMODULE Sys_LoadModule(const char *pModuleName)
{
return (HINTERFACEMODULE)LoadLibrary(pModuleName);
}
#else // LINUX
HINTERFACEMODULE Sys_LoadModule(const char *pModuleName)
{
// Linux dlopen() doesn't look in the current directory for libraries.
// We tell it to, so people don't have to 'install' libraries as root.
char szCwd[1024];
char szAbsoluteLibFilename[1024];
getcwd( szCwd, sizeof( szCwd ) );
if ( szCwd[ strlen( szCwd ) - 1 ] == '/' )
szCwd[ strlen( szCwd ) - 1 ] = 0;
sprintf( szAbsoluteLibFilename, "%s/%s", szCwd, pModuleName );
return (HINTERFACEMODULE)dlopen( szAbsoluteLibFilename, RTLD_NOW );
}
#endif
#ifdef _WIN32
void Sys_FreeModule(HINTERFACEMODULE hModule)
{
if(!hModule)
return;
FreeLibrary((HMODULE)hModule);
}
#else // LINUX
void Sys_FreeModule(HINTERFACEMODULE hModule)
{
if(!hModule)
return;
dlclose( (void *)hModule );
}
#endif
//-----------------------------------------------------------------------------
// Purpose: returns the instance of this module
// Output : interface_instance_t
//-----------------------------------------------------------------------------
CreateInterfaceFn Sys_GetFactoryThis( void )
{
return CreateInterface;
}
//-----------------------------------------------------------------------------
// Purpose: returns the instance of the named module
// Input : *pModuleName - name of the module
// Output : interface_instance_t - instance of that module
//-----------------------------------------------------------------------------
#ifdef _WIN32
CreateInterfaceFn Sys_GetFactory( HINTERFACEMODULE hModule )
{
if(!hModule)
return NULL;
return (CreateInterfaceFn)GetProcAddress((HMODULE)hModule, CREATEINTERFACE_PROCNAME);
}
#else // LINUX
CreateInterfaceFn Sys_GetFactory( HINTERFACEMODULE hModule )
{
if(!hModule)
return NULL;
return (CreateInterfaceFn)dlsym( (void *)hModule, CREATEINTERFACE_PROCNAME );
}
#endif
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include <string.h>
#include <stdlib.h>
#include "interface.h"
#ifndef _WIN32 // LINUX
#include <dlfcn.h>
#include <unistd.h> // getcwd
#include <stdio.h> // sprintf
#endif
// ------------------------------------------------------------------------------------ //
// InterfaceReg.
// ------------------------------------------------------------------------------------ //
InterfaceReg *InterfaceReg::s_pInterfaceRegs = NULL;
InterfaceReg::InterfaceReg( InstantiateInterfaceFn fn, const char *pName ) :
m_pName(pName)
{
m_CreateFn = fn;
m_pNext = s_pInterfaceRegs;
s_pInterfaceRegs = this;
}
// ------------------------------------------------------------------------------------ //
// CreateInterface.
// ------------------------------------------------------------------------------------ //
EXPORT_FUNCTION IBaseInterface *CreateInterface( const char *pName, int *pReturnCode )
{
InterfaceReg *pCur;
for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext)
{
if(strcmp(pCur->m_pName, pName) == 0)
{
if ( pReturnCode )
{
*pReturnCode = IFACE_OK;
}
return pCur->m_CreateFn();
}
}
if ( pReturnCode )
{
*pReturnCode = IFACE_FAILED;
}
return NULL;
}
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef _WIN32
HINTERFACEMODULE Sys_LoadModule(const char *pModuleName)
{
return (HINTERFACEMODULE)LoadLibrary(pModuleName);
}
#else // LINUX
HINTERFACEMODULE Sys_LoadModule(const char *pModuleName)
{
// Linux dlopen() doesn't look in the current directory for libraries.
// We tell it to, so people don't have to 'install' libraries as root.
char szCwd[1024];
char szAbsoluteLibFilename[1024];
getcwd( szCwd, sizeof( szCwd ) );
if ( szCwd[ strlen( szCwd ) - 1 ] == '/' )
szCwd[ strlen( szCwd ) - 1 ] = 0;
sprintf( szAbsoluteLibFilename, "%s/%s", szCwd, pModuleName );
return (HINTERFACEMODULE)dlopen( szAbsoluteLibFilename, RTLD_NOW );
}
#endif
#ifdef _WIN32
void Sys_FreeModule(HINTERFACEMODULE hModule)
{
if(!hModule)
return;
FreeLibrary((HMODULE)hModule);
}
#else // LINUX
void Sys_FreeModule(HINTERFACEMODULE hModule)
{
if(!hModule)
return;
dlclose( (void *)hModule );
}
#endif
//-----------------------------------------------------------------------------
// Purpose: returns the instance of this module
// Output : interface_instance_t
//-----------------------------------------------------------------------------
CreateInterfaceFn Sys_GetFactoryThis( void )
{
return CreateInterface;
}
//-----------------------------------------------------------------------------
// Purpose: returns the instance of the named module
// Input : *pModuleName - name of the module
// Output : interface_instance_t - instance of that module
//-----------------------------------------------------------------------------
#ifdef _WIN32
CreateInterfaceFn Sys_GetFactory( HINTERFACEMODULE hModule )
{
if(!hModule)
return NULL;
return (CreateInterfaceFn)GetProcAddress((HMODULE)hModule, CREATEINTERFACE_PROCNAME);
}
#else // LINUX
CreateInterfaceFn Sys_GetFactory( HINTERFACEMODULE hModule )
{
if(!hModule)
return NULL;
return (CreateInterfaceFn)dlsym( (void *)hModule, CREATEINTERFACE_PROCNAME );
}
#endif

View File

@ -1,129 +1,129 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// This header defines the interface convention used in the valve engine.
// To make an interface and expose it:
// 1. Derive from IBaseInterface.
// 2. The interface must be ALL pure virtuals, and have no data members.
// 3. Define a name for it.
// 4. In its implementation file, use EXPOSE_INTERFACE or EXPOSE_SINGLE_INTERFACE.
// Versioning
// There are two versioning cases that are handled by this:
// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case,
// you need two EXPOSE_INTERFACEs: one to expose your class as the old interface and one to expose it as the new interface.
// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface
// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and
// expose it for the old interface.
#ifndef INTERFACE_H
#define INTERFACE_H
#ifdef __cplusplus
// All interfaces derive from this.
class IBaseInterface
{
public:
virtual ~IBaseInterface() {}
};
#define CREATEINTERFACE_PROCNAME "CreateInterface"
typedef IBaseInterface* (*CreateInterfaceFn)(const char *pName, int *pReturnCode);
typedef IBaseInterface* (*InstantiateInterfaceFn)();
// Used internally to register classes.
class InterfaceReg
{
public:
InterfaceReg(InstantiateInterfaceFn fn, const char *pName);
public:
InstantiateInterfaceFn m_CreateFn;
const char *m_pName;
InterfaceReg *m_pNext; // For the global list.
static InterfaceReg *s_pInterfaceRegs;
};
// Use this to expose an interface that can have multiple instances.
// e.g.:
// EXPOSE_INTERFACE( CInterfaceImp, IInterface, "MyInterface001" )
// This will expose a class called CInterfaceImp that implements IInterface (a pure class)
// clients can receive a pointer to this class by calling CreateInterface( "MyInterface001" )
//
// In practice, the shared header file defines the interface (IInterface) and version name ("MyInterface001")
// so that each component can use these names/vtables to communicate
//
// A single class can support multiple interfaces through multiple inheritance
//
#define EXPOSE_INTERFACE_FN(functionName, interfaceName, versionName) \
static InterfaceReg __g_Create##className##_reg(functionName, versionName);
#define EXPOSE_INTERFACE(className, interfaceName, versionName) \
static IBaseInterface* __Create##className##_interface() {return (interfaceName *)new className;}\
static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName );
// Use this to expose a singleton interface with a global variable you've created.
#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName) \
static IBaseInterface* __Create##className##interfaceName##_interface() {return (interfaceName *)&globalVarName;}\
static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName);
// Use this to expose a singleton interface. This creates the global variable for you automatically.
#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName) \
static className __g_##className##_singleton;\
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton)
#ifdef WIN32
#define EXPORT_FUNCTION __declspec(dllexport)
#else
#define EXPORT_FUNCTION
#endif
// This function is automatically exported and allows you to access any interfaces exposed with the above macros.
// if pReturnCode is set, it will return one of the following values
// extend this for other error conditions/code
enum
{
IFACE_OK = 0,
IFACE_FAILED
};
extern "C"
{
EXPORT_FUNCTION IBaseInterface* CreateInterface(const char *pName, int *pReturnCode);
};
// Handle to an interface (HInterfaceModule_t* is just there for type safety).
typedef struct HInterfaceModule_t* HINTERFACEMODULE;
// Use these to load and unload a module.
extern HINTERFACEMODULE Sys_LoadModule(const char *pModuleName);
extern void Sys_FreeModule(HINTERFACEMODULE hModule);
// Use these to get the factory function from either a loaded module or the current module.
extern CreateInterfaceFn Sys_GetFactory( HINTERFACEMODULE hModule );
extern CreateInterfaceFn Sys_GetFactoryThis( void );
#endif // __cplusplus
#endif
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// This header defines the interface convention used in the valve engine.
// To make an interface and expose it:
// 1. Derive from IBaseInterface.
// 2. The interface must be ALL pure virtuals, and have no data members.
// 3. Define a name for it.
// 4. In its implementation file, use EXPOSE_INTERFACE or EXPOSE_SINGLE_INTERFACE.
// Versioning
// There are two versioning cases that are handled by this:
// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case,
// you need two EXPOSE_INTERFACEs: one to expose your class as the old interface and one to expose it as the new interface.
// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface
// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and
// expose it for the old interface.
#ifndef INTERFACE_H
#define INTERFACE_H
#ifdef __cplusplus
// All interfaces derive from this.
class IBaseInterface
{
public:
virtual ~IBaseInterface() {}
};
#define CREATEINTERFACE_PROCNAME "CreateInterface"
typedef IBaseInterface* (*CreateInterfaceFn)(const char *pName, int *pReturnCode);
typedef IBaseInterface* (*InstantiateInterfaceFn)();
// Used internally to register classes.
class InterfaceReg
{
public:
InterfaceReg(InstantiateInterfaceFn fn, const char *pName);
public:
InstantiateInterfaceFn m_CreateFn;
const char *m_pName;
InterfaceReg *m_pNext; // For the global list.
static InterfaceReg *s_pInterfaceRegs;
};
// Use this to expose an interface that can have multiple instances.
// e.g.:
// EXPOSE_INTERFACE( CInterfaceImp, IInterface, "MyInterface001" )
// This will expose a class called CInterfaceImp that implements IInterface (a pure class)
// clients can receive a pointer to this class by calling CreateInterface( "MyInterface001" )
//
// In practice, the shared header file defines the interface (IInterface) and version name ("MyInterface001")
// so that each component can use these names/vtables to communicate
//
// A single class can support multiple interfaces through multiple inheritance
//
#define EXPOSE_INTERFACE_FN(functionName, interfaceName, versionName) \
static InterfaceReg __g_Create##className##_reg(functionName, versionName);
#define EXPOSE_INTERFACE(className, interfaceName, versionName) \
static IBaseInterface* __Create##className##_interface() {return (interfaceName *)new className;}\
static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName );
// Use this to expose a singleton interface with a global variable you've created.
#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName) \
static IBaseInterface* __Create##className##interfaceName##_interface() {return (interfaceName *)&globalVarName;}\
static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName);
// Use this to expose a singleton interface. This creates the global variable for you automatically.
#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName) \
static className __g_##className##_singleton;\
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton)
#ifdef WIN32
#define EXPORT_FUNCTION __declspec(dllexport)
#else
#define EXPORT_FUNCTION
#endif
// This function is automatically exported and allows you to access any interfaces exposed with the above macros.
// if pReturnCode is set, it will return one of the following values
// extend this for other error conditions/code
enum
{
IFACE_OK = 0,
IFACE_FAILED
};
extern "C"
{
EXPORT_FUNCTION IBaseInterface* CreateInterface(const char *pName, int *pReturnCode);
};
// Handle to an interface (HInterfaceModule_t* is just there for type safety).
typedef struct HInterfaceModule_t* HINTERFACEMODULE;
// Use these to load and unload a module.
extern HINTERFACEMODULE Sys_LoadModule(const char *pModuleName);
extern void Sys_FreeModule(HINTERFACEMODULE hModule);
// Use these to get the factory function from either a loaded module or the current module.
extern CreateInterfaceFn Sys_GetFactory( HINTERFACEMODULE hModule );
extern CreateInterfaceFn Sys_GetFactoryThis( void );
#endif // __cplusplus
#endif

View File

@ -1,37 +1,37 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef IVOICETWEAK_H
#define IVOICETWEAK_H
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// 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)(); // Returns 0 on error.
void (*EndVoiceTweakMode)();
// Get/set control values.
void (*SetControlFloat)(VoiceTweakControl iControl, float value);
float (*GetControlFloat)(VoiceTweakControl iControl);
} IVoiceTweak;
#endif // IVOICETWEAK_H
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef IVOICETWEAK_H
#define IVOICETWEAK_H
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
// 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)(); // Returns 0 on error.
void (*EndVoiceTweakMode)();
// Get/set control values.
void (*SetControlFloat)(VoiceTweakControl iControl, float value);
float (*GetControlFloat)(VoiceTweakControl iControl);
} IVoiceTweak;
#endif // IVOICETWEAK_H

View File

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

View File

@ -1,156 +1,156 @@
/***
*
* 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
typedef float vec_t;
typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4]; // x,y,z,w
typedef vec_t vec5_t[5];
typedef short vec_s_t;
typedef vec_s_t vec3s_t[3];
typedef vec_s_t vec4s_t[4]; // x,y,z,w
typedef vec_s_t vec5s_t[5];
typedef int fixed4_t;
typedef int fixed8_t;
typedef int fixed16_t;
#ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#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);
int Q_log2(int val);
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
// Here are some "manual" INLINE routines for doing floating point to integer conversions
extern short new_cw, old_cw;
typedef union DLONG {
int i[2];
double d;
float f;
} DLONG;
extern DLONG dlong;
#ifdef _WIN32
void __inline set_fpu_cw(void)
{
_asm
{ wait
fnstcw old_cw
wait
mov ax, word ptr old_cw
or ah, 0xc
mov word ptr new_cw,ax
fldcw new_cw
}
}
int __inline quick_ftol(float f)
{
_asm {
// Assumes that we are already in chop mode, and only need a 32-bit int
fld DWORD PTR f
fistp DWORD PTR dlong
}
return dlong.i[0];
}
void __inline restore_fpu_cw(void)
{
_asm fldcw old_cw
}
#else
#define set_fpu_cw() /* */
#define quick_ftol(f) ftol(f)
#define restore_fpu_cw() /* */
#endif
void FloorDivMod (double numer, double denom, int *quotient,
int *rem);
fixed16_t Invert24To16(fixed16_t val);
int GreatestCommonDivisor (int i1, int i2);
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
typedef float vec_t;
typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4]; // x,y,z,w
typedef vec_t vec5_t[5];
typedef short vec_s_t;
typedef vec_s_t vec3s_t[3];
typedef vec_s_t vec4s_t[4]; // x,y,z,w
typedef vec_s_t vec5s_t[5];
typedef int fixed4_t;
typedef int fixed8_t;
typedef int fixed16_t;
#ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#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);
int Q_log2(int val);
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
// Here are some "manual" INLINE routines for doing floating point to integer conversions
extern short new_cw, old_cw;
typedef union DLONG {
int i[2];
double d;
float f;
} DLONG;
extern DLONG dlong;
#ifdef _WIN32
void __inline set_fpu_cw(void)
{
_asm
{ wait
fnstcw old_cw
wait
mov ax, word ptr old_cw
or ah, 0xc
mov word ptr new_cw,ax
fldcw new_cw
}
}
int __inline quick_ftol(float f)
{
_asm {
// Assumes that we are already in chop mode, and only need a 32-bit int
fld DWORD PTR f
fistp DWORD PTR dlong
}
return dlong.i[0];
}
void __inline restore_fpu_cw(void)
{
_asm fldcw old_cw
}
#else
#define set_fpu_cw() /* */
#define quick_ftol(f) ftol(f)
#define restore_fpu_cw() /* */
#endif
void FloorDivMod (double numer, double denom, int *quotient,
int *rem);
fixed16_t Invert24To16(fixed16_t val);
int GreatestCommonDivisor (int i1, int i2);
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)))

View File

@ -1,101 +1,101 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( NET_APIH )
#define NET_APIH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
#if !defined ( NETADRH )
#include "netadr.h"
#endif
#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;
extern net_api_t netapi;
#endif // NET_APIH
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( NET_APIH )
#define NET_APIH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
#if !defined ( NETADRH )
#include "netadr.h"
#endif
#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;
extern net_api_t netapi;
#endif // NET_APIH

View File

@ -1,42 +1,42 @@
/***
*
* 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.
*
****/
// netadr.h
#ifndef NETADR_H
#define NETADR_H
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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
/***
*
* 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.
*
****/
// netadr.h
#ifndef NETADR_H
#define NETADR_H
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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

View File

@ -1,15 +1,15 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef INC_NOWIN_H
#define INC_NOWIN_H
#ifndef _WIN32
#include <unistd.h>
#endif //!_WIN32
#endif //INC_NOWIN_H
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#ifndef INC_NOWIN_H
#define INC_NOWIN_H
#ifndef _WIN32
#include <unistd.h>
#endif //!_WIN32
#endif //INC_NOWIN_H

View File

@ -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.
*
****/
#if !defined( PARTICLEDEFH )
#define PARTICLEDEFH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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
} ptype_t;
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
typedef struct particle_s
{
// driver-usable fields
vec3_t org;
short color;
short packedColor;
// drivers never touch the following fields
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
/***
*
* 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.
*
****/
#if !defined( PARTICLEDEFH )
#define PARTICLEDEFH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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
} ptype_t;
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
typedef struct particle_s
{
// driver-usable fields
vec3_t org;
short color;
short packedColor;
// drivers never touch the following fields
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

View File

@ -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.
*
****/
#if !defined( PMTRACEH )
#define PMTRACEH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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
/***
*
* 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.
*
****/
#if !defined( PMTRACEH )
#define PMTRACEH
#ifdef _WIN32
#ifndef __MINGW32__
#pragma once
#endif /* not __MINGW32__ */
#endif
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

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