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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// cdll_int.c // cdll_int.c
// //
// this implementation handles the linking of the engine to the DLL // this implementation handles the linking of the engine to the DLL
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "netadr.h" #include "netadr.h"
extern "C" extern "C"
{ {
#include "pm_shared.h" #include "pm_shared.h"
} }
#include <string.h> #include <string.h>
#include "interface.h" #include "interface.h"
#include "render_api.h" #include "render_api.h"
#include "mobility_int.h" #include "mobility_int.h"
#ifdef _WIN32 #ifdef _WIN32
#define DLLEXPORT __declspec( dllexport ) #define DLLEXPORT __declspec( dllexport )
#else #else
#define DLLEXPORT #define DLLEXPORT
#endif #endif
cl_enginefunc_t gEngfuncs; cl_enginefunc_t gEngfuncs;
render_api_t gRenderAPI; render_api_t gRenderAPI;
mobile_engfuncs_t gMobileAPI; mobile_engfuncs_t gMobileAPI;
CHud gHUD; CHud gHUD;
int g_iXash; // indicates a buildnum int g_iXash; // indicates a buildnum
void InitInput (void); void InitInput (void);
void EV_HookEvents( void ); void EV_HookEvents( void );
void IN_Commands( void ); void IN_Commands( void );
/* /*
========================== ==========================
Initialize Initialize
Called when the DLL is first loaded. Called when the DLL is first loaded.
========================== ==========================
*/ */
extern "C" extern "C"
{ {
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ); int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
int DLLEXPORT HUD_VidInit( void ); int DLLEXPORT HUD_VidInit( void );
void DLLEXPORT HUD_Init( void ); void DLLEXPORT HUD_Init( void );
int DLLEXPORT HUD_Redraw( float flTime, int intermission ); int DLLEXPORT HUD_Redraw( float flTime, int intermission );
int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime ); int DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
void DLLEXPORT HUD_Reset ( void ); void DLLEXPORT HUD_Reset ( void );
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server ); void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove ); void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
char DLLEXPORT HUD_PlayerMoveTexture( char *name ); 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_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 ); int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
void DLLEXPORT HUD_Frame( double time ); void DLLEXPORT HUD_Frame( double time );
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking); void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf ); 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_GetRenderInterface( int version, render_api_t *renderfuncs, render_interface_t *callback );
int DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *mobileapi ); int DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *mobileapi );
} }
/* /*
================================ ================================
HUD_GetHullBounds HUD_GetHullBounds
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist. Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
================================ ================================
*/ */
int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs ) int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
{ {
int iret = 0; int iret = 0;
switch ( hullnumber ) switch ( hullnumber )
{ {
case 0: // Normal player case 0: // Normal player
mins = Vector(-16, -16, -36); mins = Vector(-16, -16, -36);
maxs = Vector(16, 16, 36); maxs = Vector(16, 16, 36);
iret = 1; iret = 1;
break; break;
case 1: // Crouched player case 1: // Crouched player
mins = Vector(-16, -16, -18 ); mins = Vector(-16, -16, -18 );
maxs = Vector(16, 16, 18 ); maxs = Vector(16, 16, 18 );
iret = 1; iret = 1;
break; break;
case 2: // Point based hull case 2: // Point based hull
mins = Vector( 0, 0, 0 ); mins = Vector( 0, 0, 0 );
maxs = Vector( 0, 0, 0 ); maxs = Vector( 0, 0, 0 );
iret = 1; iret = 1;
break; break;
} }
return iret; return iret;
} }
/* /*
================================ ================================
HUD_ConnectionlessPacket 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 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. size of the response_buffer, so you must zero it out if you choose not to respond.
================================ ================================
*/ */
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
{ {
// Parse stuff from args // Parse stuff from args
int max_buffer_size = *response_buffer_size; int max_buffer_size = *response_buffer_size;
// Zero it out since we aren't going to respond. // Zero it out since we aren't going to respond.
// If we wanted to response, we'd write data into response_buffer // If we wanted to response, we'd write data into response_buffer
*response_buffer_size = 0; *response_buffer_size = 0;
// Since we don't listen for anything here, just respond that it's a bogus message // 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. // If we didn't reject the message, we'd return 1 for success instead.
return 0; return 0;
} }
void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove ) void DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove )
{ {
PM_Init( ppmove ); PM_Init( ppmove );
} }
char DLLEXPORT HUD_PlayerMoveTexture( char *name ) char DLLEXPORT HUD_PlayerMoveTexture( char *name )
{ {
return PM_FindTextureType( name ); return PM_FindTextureType( name );
} }
void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server ) void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
{ {
PM_Move( ppmove, server ); PM_Move( ppmove, server );
} }
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ) int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{ {
gEngfuncs = *pEnginefuncs; gEngfuncs = *pEnginefuncs;
if (iVersion != CLDLL_INTERFACE_VERSION) if (iVersion != CLDLL_INTERFACE_VERSION)
return 0; return 0;
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t)); memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
g_iXash = (int)CVAR_GET_FLOAT("build"); g_iXash = (int)CVAR_GET_FLOAT("build");
EV_HookEvents(); EV_HookEvents();
return 1; return 1;
} }
/* /*
========================== ==========================
HUD_VidInit HUD_VidInit
Called when the game initializes Called when the game initializes
and whenever the vid_mode is changed and whenever the vid_mode is changed
so the HUD can reinitialize itself. so the HUD can reinitialize itself.
========================== ==========================
*/ */
int DLLEXPORT HUD_VidInit( void ) int DLLEXPORT HUD_VidInit( void )
{ {
gHUD.VidInit(); gHUD.VidInit();
//VGui_Startup(); //VGui_Startup();
return 1; return 1;
} }
/* /*
========================== ==========================
HUD_Init HUD_Init
Called whenever the client connects Called whenever the client connects
to a server. Reinitializes all to a server. Reinitializes all
the hud variables. the hud variables.
========================== ==========================
*/ */
void DLLEXPORT HUD_Init( void ) void DLLEXPORT HUD_Init( void )
{ {
InitInput(); InitInput();
gHUD.Init(); gHUD.Init();
//Scheme_Init(); //Scheme_Init();
} }
/* /*
========================== ==========================
HUD_Redraw HUD_Redraw
called every screen frame to called every screen frame to
redraw the HUD. redraw the HUD.
=========================== ===========================
*/ */
int DLLEXPORT HUD_Redraw( float time, int intermission ) int DLLEXPORT HUD_Redraw( float time, int intermission )
{ {
gHUD.Redraw( time, intermission ); gHUD.Redraw( time, intermission );
return 1; return 1;
} }
/* /*
========================== ==========================
HUD_UpdateClientData HUD_UpdateClientData
called every time shared client called every time shared client
dll/engine data gets changed, dll/engine data gets changed,
and gives the cdll a chance and gives the cdll a chance
to modify the data. to modify the data.
returns 1 if anything has been changed, 0 otherwise. returns 1 if anything has been changed, 0 otherwise.
========================== ==========================
*/ */
int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime ) int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime )
{ {
IN_Commands(); IN_Commands();
return gHUD.UpdateClientData(pcldata, flTime ); return gHUD.UpdateClientData(pcldata, flTime );
} }
/* /*
========================== ==========================
HUD_Reset HUD_Reset
Called at start and end of demos to restore to "non"HUD state. Called at start and end of demos to restore to "non"HUD state.
========================== ==========================
*/ */
void DLLEXPORT HUD_Reset( void ) void DLLEXPORT HUD_Reset( void )
{ {
gHUD.VidInit(); gHUD.VidInit();
} }
/* /*
========================== ==========================
HUD_Frame HUD_Frame
Called by engine every frame that client .dll is loaded Called by engine every frame that client .dll is loaded
========================== ==========================
*/ */
void DLLEXPORT HUD_Frame( double time ) void DLLEXPORT HUD_Frame( double time )
{ {
//ServersThink( time ); //ServersThink( time );
//GetClientVoiceMgr()->Frame(time); //GetClientVoiceMgr()->Frame(time);
} }
/* /*
========================== ==========================
HUD_VoiceStatus HUD_VoiceStatus
Called when a player starts or stops talking. Called when a player starts or stops talking.
========================== ==========================
*/ */
void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking) void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking)
{ {
//GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking); //GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
} }
/* /*
========================== ==========================
HUD_DirectorEvent HUD_DirectorEvent
Called when a director event message was received Called when a director event message was received
========================== ==========================
*/ */
void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf ) void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf )
{ {
gHUD.m_Spectator.DirectorMessage( iSize, pbuf ); gHUD.m_Spectator.DirectorMessage( iSize, pbuf );
} }
/* /*
========================== ==========================
HUD_GetRenderInterface HUD_GetRenderInterface
Called when Xash3D sends render api to us Called when Xash3D sends render api to us
========================== ==========================
*/ */
int DLLEXPORT HUD_GetRenderInterface( int version, render_api_t *renderfuncs, render_interface_t *callback ) int DLLEXPORT HUD_GetRenderInterface( int version, render_api_t *renderfuncs, render_interface_t *callback )
{ {
if( version != CL_RENDER_INTERFACE_VERSION ) if( version != CL_RENDER_INTERFACE_VERSION )
{ {
return false; return false;
} }
gRenderAPI = *renderfuncs; gRenderAPI = *renderfuncs;
// we didn't send callbacks to engine, because we don't use it // we didn't send callbacks to engine, because we don't use it
// *callback = renderInterface; // *callback = renderInterface;
return true; return true;
} }
/* /*
======================== ========================
HUD_MobilityInterface HUD_MobilityInterface
======================== ========================
*/ */
int DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *mobileapi ) int DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *mobileapi )
{ {
if( mobileapi->version != MOBILITY_API_VERSION ) 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); gEngfuncs.Con_Printf("Client Error: Mobile API version mismatch. Got: %i, want: %i\n", mobileapi->version, MOBILITY_API_VERSION);
return 1; return 1;
} }
gMobileAPI = *mobileapi; gMobileAPI = *mobileapi;
return 0; return 0;
} }

View File

@ -1,292 +1,292 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// Com_Weapons.cpp // Com_Weapons.cpp
// Shared weapons common/shared functions // Shared weapons common/shared functions
#include <stdarg.h> #include <stdarg.h>
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "com_weapons.h" #include "com_weapons.h"
#include "const.h" #include "const.h"
#include "entity_state.h" #include "entity_state.h"
#include "r_efx.h" #include "r_efx.h"
// g_runfuncs is true if this is the first time we've "predicated" a particular movement/firing // 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 // command. If it is 1, then we should play events/sounds etc., otherwise, we just will be
// updating state info, but not firing events // updating state info, but not firing events
int g_runfuncs = 0; int g_runfuncs = 0;
// During our weapon prediction processing, we'll need to reference some data that is part of // 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 // the final state passed into the postthink functionality. We'll set this pointer and then
// reset it to NULL as appropriate // reset it to NULL as appropriate
struct local_state_s *g_finalstate = NULL; struct local_state_s *g_finalstate = NULL;
/* /*
==================== ====================
COM_Log COM_Log
Log debug messages to file ( appends ) Log debug messages to file ( appends )
==================== ====================
*/ */
void COM_Log( char *pszFile, char *fmt, ...) void COM_Log( char *pszFile, char *fmt, ...)
{ {
va_list argptr; va_list argptr;
char string[1024]; char string[1024];
FILE *fp; FILE *fp;
char *pfilename; char *pfilename;
if ( !pszFile ) if ( !pszFile )
{ {
pfilename = "c:\\hllog.txt"; pfilename = "c:\\hllog.txt";
} }
else else
{ {
pfilename = pszFile; pfilename = pszFile;
} }
va_start (argptr,fmt); va_start (argptr,fmt);
vsprintf (string, fmt,argptr); vsprintf (string, fmt,argptr);
va_end (argptr); va_end (argptr);
fp = fopen( pfilename, "a+t"); fp = fopen( pfilename, "a+t");
if (fp) if (fp)
{ {
fprintf(fp, "%s", string); fprintf(fp, "%s", string);
fclose(fp); fclose(fp);
} }
} }
// remember the current animation for the view model, in case we get out of sync with // remember the current animation for the view model, in case we get out of sync with
// server. // server.
static int g_currentanim; static int g_currentanim;
static int g_currentweapon; static int g_currentweapon;
/* /*
===================== =====================
HUD_SendWeaponAnim HUD_SendWeaponAnim
Change weapon model animation Change weapon model animation
===================== =====================
*/ */
void HUD_SendWeaponAnim( int iAnim, int iWeaponId, int iBody, int iForce ) void HUD_SendWeaponAnim( int iAnim, int iWeaponId, int iBody, int iForce )
{ {
// Don't actually change it. // Don't actually change it.
if ( !g_runfuncs && !iForce ) if ( !g_runfuncs && !iForce )
return; return;
g_currentanim = iAnim; g_currentanim = iAnim;
g_currentweapon = iWeaponId; g_currentweapon = iWeaponId;
// Tell animation system new info // Tell animation system new info
gEngfuncs.pfnWeaponAnim( iAnim, iBody ); gEngfuncs.pfnWeaponAnim( iAnim, iBody );
} }
/* /*
===================== =====================
HUD_GetWeaponAnim HUD_GetWeaponAnim
Retrieve current predicted weapon animation Retrieve current predicted weapon animation
===================== =====================
*/ */
int HUD_GetWeaponAnim( void ) int HUD_GetWeaponAnim( void )
{ {
return g_currentanim; return g_currentanim;
} }
/* /*
===================== =====================
HUD_GetWeapon HUD_GetWeapon
Retrieve current predicted weapon id Retrieve current predicted weapon id
===================== =====================
*/ */
int HUD_GetWeapon( void ) int HUD_GetWeapon( void )
{ {
return g_currentweapon; return g_currentweapon;
} }
/* /*
===================== =====================
HUD_PlaySound HUD_PlaySound
Play a sound, if we are seeing this command for the first time Play a sound, if we are seeing this command for the first time
===================== =====================
*/ */
void HUD_PlaySound( char *sound, float volume ) void HUD_PlaySound( char *sound, float volume )
{ {
if ( !g_runfuncs || !g_finalstate ) if ( !g_runfuncs || !g_finalstate )
return; return;
gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin ); gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin );
} }
/* /*
===================== =====================
HUD_PlaybackEvent HUD_PlaybackEvent
Directly queue up an event on the client Directly queue up an event on the client
===================== =====================
*/ */
void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, 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 ) float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 )
{ {
vec3_t org; vec3_t org;
vec3_t ang; vec3_t ang;
if ( !g_runfuncs || !g_finalstate ) if ( !g_runfuncs || !g_finalstate )
return; return;
// Weapon prediction events are assumed to occur at the player's origin // Weapon prediction events are assumed to occur at the player's origin
org = g_finalstate->playerstate.origin; org = g_finalstate->playerstate.origin;
ang = v_angles; ang = v_angles;
gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, (float *)&org, (float *)&ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 ); gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, (float *)&org, (float *)&ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 );
} }
/* /*
===================== =====================
HUD_SetMaxSpeed HUD_SetMaxSpeed
===================== =====================
*/ */
void HUD_SetMaxSpeed( const edict_t *ed, float speed ) void HUD_SetMaxSpeed( const edict_t *ed, float speed )
{ {
} }
/* /*
===================== =====================
UTIL_WeaponTimeBase UTIL_WeaponTimeBase
Always 0.0 on client, even if not predicting weapons ( won't get called Always 0.0 on client, even if not predicting weapons ( won't get called
in that case ) in that case )
===================== =====================
*/ */
float UTIL_WeaponTimeBase( void ) float UTIL_WeaponTimeBase( void )
{ {
return 0.0; return 0.0;
} }
static unsigned int glSeed = 0; static unsigned int glSeed = 0;
unsigned int seed_table[ 256 ] = unsigned int seed_table[ 256 ] =
{ {
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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 25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847
}; };
unsigned int U_Random( void ) unsigned int U_Random( void )
{ {
glSeed *= 69069; glSeed *= 69069;
glSeed += seed_table[ glSeed & 0xff ]; glSeed += seed_table[ glSeed & 0xff ];
return ( ++glSeed & 0x0fffffff ); return ( ++glSeed & 0x0fffffff );
} }
void U_Srand( unsigned int seed ) void U_Srand( unsigned int seed )
{ {
glSeed = seed_table[ seed & 0xff ]; glSeed = seed_table[ seed & 0xff ];
} }
/* /*
===================== =====================
UTIL_SharedRandomLong UTIL_SharedRandomLong
===================== =====================
*/ */
int UTIL_SharedRandomLong( unsigned int seed, int low, int high ) int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
{ {
unsigned int range; unsigned int range;
U_Srand( (int)seed + low + high ); U_Srand( (int)seed + low + high );
range = high - low + 1; range = high - low + 1;
if ( !(range - 1) ) if ( !(range - 1) )
{ {
return low; return low;
} }
else else
{ {
int offset; int offset;
int rnum; int rnum;
rnum = U_Random(); rnum = U_Random();
offset = rnum % range; offset = rnum % range;
return (low + offset); return (low + offset);
} }
} }
/* /*
===================== =====================
UTIL_SharedRandomFloat UTIL_SharedRandomFloat
===================== =====================
*/ */
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
{ {
// //
unsigned int range; unsigned int range;
U_Srand( (int)seed + *(int *)&low + *(int *)&high ); U_Srand( (int)seed + *(int *)&low + *(int *)&high );
U_Random(); U_Random();
U_Random(); U_Random();
range = high - low; range = high - low;
if ( !range ) if ( !range )
{ {
return low; return low;
} }
else else
{ {
int tensixrand; int tensixrand;
float offset; float offset;
tensixrand = U_Random() & 65535; tensixrand = U_Random() & 65535;
offset = (float)tensixrand / 65536.0; offset = (float)tensixrand / 65536.0;
return (low + offset * range ); return (low + offset * range );
} }
} }
/* /*
====================== ======================
stub_* stub_*
stub functions for such things as precaching. So we don't have to modify weapons code that 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. is compiled into both game and client .dlls.
====================== ======================
*/ */
int stub_PrecacheModel ( char* s ) { return 0; } int stub_PrecacheModel ( char* s ) { return 0; }
int stub_PrecacheSound ( char* s ) { return 0; } int stub_PrecacheSound ( char* s ) { return 0; }
unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; } unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; }
const char *stub_NameForFunction ( unsigned int function ) { return "func"; } const char *stub_NameForFunction ( unsigned int function ) { return "func"; }
void stub_SetModel ( edict_t *e, const char *m ) {} void stub_SetModel ( edict_t *e, const char *m ) {}

View File

@ -1,278 +1,278 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// Com_Weapons.cpp // Com_Weapons.cpp
// Shared weapons common/shared functions // Shared weapons common/shared functions
#include <stdarg.h> #include <stdarg.h>
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "com_weapons.h" #include "com_weapons.h"
#include "const.h" #include "const.h"
#include "entity_state.h" #include "entity_state.h"
#include "r_efx.h" #include "r_efx.h"
// g_runfuncs is true if this is the first time we've "predicated" a particular movement/firing // 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 // command. If it is 1, then we should play events/sounds etc., otherwise, we just will be
// updating state info, but not firing events // updating state info, but not firing events
int g_runfuncs = 0; int g_runfuncs = 0;
// During our weapon prediction processing, we'll need to reference some data that is part of // 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 // the final state passed into the postthink functionality. We'll set this pointer and then
// reset it to NULL as appropriate // reset it to NULL as appropriate
struct local_state_s *g_finalstate = NULL; struct local_state_s *g_finalstate = NULL;
/* /*
==================== ====================
COM_Log COM_Log
Log debug messages to file ( appends ) Log debug messages to file ( appends )
==================== ====================
*/ */
void COM_Log( char *pszFile, char *fmt, ...) void COM_Log( char *pszFile, char *fmt, ...)
{ {
va_list argptr; va_list argptr;
char string[1024]; char string[1024];
FILE *fp; FILE *fp;
char *pfilename; char *pfilename;
if ( !pszFile ) if ( !pszFile )
{ {
pfilename = "c:\\hllog.txt"; pfilename = "c:\\hllog.txt";
} }
else else
{ {
pfilename = pszFile; pfilename = pszFile;
} }
va_start (argptr,fmt); va_start (argptr,fmt);
vsprintf (string, fmt,argptr); vsprintf (string, fmt,argptr);
va_end (argptr); va_end (argptr);
fp = fopen( pfilename, "a+t"); fp = fopen( pfilename, "a+t");
if (fp) if (fp)
{ {
fprintf(fp, "%s", string); fprintf(fp, "%s", string);
fclose(fp); fclose(fp);
} }
} }
// remember the current animation for the view model, in case we get out of sync with // remember the current animation for the view model, in case we get out of sync with
// server. // server.
static int g_currentanim; static int g_currentanim;
/* /*
===================== =====================
HUD_SendWeaponAnim HUD_SendWeaponAnim
Change weapon model animation Change weapon model animation
===================== =====================
*/ */
void HUD_SendWeaponAnim( int iAnim, int body, int force ) void HUD_SendWeaponAnim( int iAnim, int body, int force )
{ {
// Don't actually change it. // Don't actually change it.
if ( !g_runfuncs && !force ) if ( !g_runfuncs && !force )
return; return;
g_currentanim = iAnim; g_currentanim = iAnim;
// Tell animation system new info // Tell animation system new info
gEngfuncs.pfnWeaponAnim( iAnim, body ); gEngfuncs.pfnWeaponAnim( iAnim, body );
} }
/* /*
===================== =====================
HUD_GetWeaponAnim HUD_GetWeaponAnim
Retrieve current predicted weapon animation Retrieve current predicted weapon animation
===================== =====================
*/ */
int HUD_GetWeaponAnim( void ) int HUD_GetWeaponAnim( void )
{ {
return g_currentanim; return g_currentanim;
} }
/* /*
===================== =====================
HUD_PlaySound HUD_PlaySound
Play a sound, if we are seeing this command for the first time Play a sound, if we are seeing this command for the first time
===================== =====================
*/ */
void HUD_PlaySound( char *sound, float volume ) void HUD_PlaySound( char *sound, float volume )
{ {
if ( !g_runfuncs || !g_finalstate ) if ( !g_runfuncs || !g_finalstate )
return; return;
gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin ); gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin );
} }
/* /*
===================== =====================
HUD_PlaybackEvent HUD_PlaybackEvent
Directly queue up an event on the client Directly queue up an event on the client
===================== =====================
*/ */
void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, 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 ) float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 )
{ {
vec3_t org; vec3_t org;
vec3_t ang; vec3_t ang;
if ( !g_runfuncs || !g_finalstate ) if ( !g_runfuncs || !g_finalstate )
return; return;
// Weapon prediction events are assumed to occur at the player's origin // Weapon prediction events are assumed to occur at the player's origin
org = g_finalstate->playerstate.origin; org = g_finalstate->playerstate.origin;
ang = v_angles; ang = v_angles;
gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, (float *)&org, (float *)&ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 ); gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, (float *)&org, (float *)&ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 );
} }
/* /*
===================== =====================
HUD_SetMaxSpeed HUD_SetMaxSpeed
===================== =====================
*/ */
void HUD_SetMaxSpeed( const edict_t *ed, float speed ) void HUD_SetMaxSpeed( const edict_t *ed, float speed )
{ {
} }
/* /*
===================== =====================
UTIL_WeaponTimeBase UTIL_WeaponTimeBase
Always 0.0 on client, even if not predicting weapons ( won't get called Always 0.0 on client, even if not predicting weapons ( won't get called
in that case ) in that case )
===================== =====================
*/ */
float UTIL_WeaponTimeBase( void ) float UTIL_WeaponTimeBase( void )
{ {
return 0.0; return 0.0;
} }
static unsigned int glSeed = 0; static unsigned int glSeed = 0;
unsigned int seed_table[ 256 ] = unsigned int seed_table[ 256 ] =
{ {
28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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 25678, 18555, 13256, 23316, 22407, 16727, 991, 9236, 5373, 29402, 6117, 15241, 27715, 19291, 19888, 19847
}; };
unsigned int U_Random( void ) unsigned int U_Random( void )
{ {
glSeed *= 69069; glSeed *= 69069;
glSeed += seed_table[ glSeed & 0xff ]; glSeed += seed_table[ glSeed & 0xff ];
return ( ++glSeed & 0x0fffffff ); return ( ++glSeed & 0x0fffffff );
} }
void U_Srand( unsigned int seed ) void U_Srand( unsigned int seed )
{ {
glSeed = seed_table[ seed & 0xff ]; glSeed = seed_table[ seed & 0xff ];
} }
/* /*
===================== =====================
UTIL_SharedRandomLong UTIL_SharedRandomLong
===================== =====================
*/ */
int UTIL_SharedRandomLong( unsigned int seed, int low, int high ) int UTIL_SharedRandomLong( unsigned int seed, int low, int high )
{ {
unsigned int range; unsigned int range;
U_Srand( (int)seed + low + high ); U_Srand( (int)seed + low + high );
range = high - low + 1; range = high - low + 1;
if ( !(range - 1) ) if ( !(range - 1) )
{ {
return low; return low;
} }
else else
{ {
int offset; int offset;
int rnum; int rnum;
rnum = U_Random(); rnum = U_Random();
offset = rnum % range; offset = rnum % range;
return (low + offset); return (low + offset);
} }
} }
/* /*
===================== =====================
UTIL_SharedRandomFloat UTIL_SharedRandomFloat
===================== =====================
*/ */
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
{ {
// //
unsigned int range; unsigned int range;
U_Srand( (int)seed + *(int *)&low + *(int *)&high ); U_Srand( (int)seed + *(int *)&low + *(int *)&high );
U_Random(); U_Random();
U_Random(); U_Random();
range = high - low; range = high - low;
if ( !range ) if ( !range )
{ {
return low; return low;
} }
else else
{ {
int tensixrand; int tensixrand;
float offset; float offset;
tensixrand = U_Random() & 65535; tensixrand = U_Random() & 65535;
offset = (float)tensixrand / 65536.0; offset = (float)tensixrand / 65536.0;
return (low + offset * range ); return (low + offset * range );
} }
} }
/* /*
====================== ======================
stub_* stub_*
stub functions for such things as precaching. So we don't have to modify weapons code that 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. is compiled into both game and client .dlls.
====================== ======================
*/ */
int stub_PrecacheModel ( char* s ) { return 0; } int stub_PrecacheModel ( char* s ) { return 0; }
int stub_PrecacheSound ( char* s ) { return 0; } int stub_PrecacheSound ( char* s ) { return 0; }
unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; } unsigned short stub_PrecacheEvent ( int type, const char *s ) { return 0; }
const char *stub_NameForFunction ( unsigned int function ) { return "func"; } const char *stub_NameForFunction ( unsigned int function ) { return "func"; }
void stub_SetModel ( edict_t *e, const char *m ) {} void stub_SetModel ( edict_t *e, const char *m ) {}

View File

@ -1,284 +1,284 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* /*
========================== ==========================
This file contains "stubs" of class member implementations so that we can predict certain 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 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 these functions. If so, cut it from here, paste it in hl_weapons.cpp or somewhere else and
add in the functionality you need. add in the functionality you need.
========================== ==========================
*/ */
#include "port.h" #include "port.h"
#include "extdll.h" #include "extdll.h"
#include "util.h" #include "util.h"
#include "cbase.h" #include "cbase.h"
#include "player.h" #include "player.h"
#include "weapons.h" #include "weapons.h"
#include "nodes.h" #include "nodes.h"
#include "soundent.h" #include "soundent.h"
#include "skill.h" #include "skill.h"
// Globals used by game logic // Globals used by game logic
const Vector g_vecZero = Vector( 0, 0, 0 ); const Vector g_vecZero = Vector( 0, 0, 0 );
int gmsgWeapPickup = 0; int gmsgWeapPickup = 0;
enginefuncs_t g_engfuncs; enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals; globalvars_t *gpGlobals;
ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS]; 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) { } void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) { }
// CBaseEntity Stubs // CBaseEntity Stubs
int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { return 1; } int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { return 1; }
int CBaseEntity :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, 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; } CBaseEntity *CBaseEntity::GetNextTarget( void ) { return NULL; }
int CBaseEntity::Save( CSave &save ) { return 1; } int CBaseEntity::Save( CSave &save ) { return 1; }
int CBaseEntity::Restore( CRestore &restore ) { return 1; } int CBaseEntity::Restore( CRestore &restore ) { return 1; }
void CBaseEntity::SetObjectCollisionBox( void ) { } void CBaseEntity::SetObjectCollisionBox( void ) { }
int CBaseEntity :: Intersects( CBaseEntity *pOther ) { return 0; } int CBaseEntity :: Intersects( CBaseEntity *pOther ) { return 0; }
void CBaseEntity :: MakeDormant( void ) { } void CBaseEntity :: MakeDormant( void ) { }
int CBaseEntity :: IsDormant( void ) { return 0; } int CBaseEntity :: IsDormant( void ) { return 0; }
BOOL CBaseEntity :: IsInWorld( void ) { return TRUE; } BOOL CBaseEntity :: IsInWorld( void ) { return TRUE; }
int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; } int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; }
int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; } int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; }
CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; }
void CBaseEntity::SUB_Remove( void ) { } void CBaseEntity::SUB_Remove( void ) { }
// CBaseDelay Stubs // CBaseDelay Stubs
void CBaseDelay :: KeyValue( struct KeyValueData_s * ) { } void CBaseDelay :: KeyValue( struct KeyValueData_s * ) { }
int CBaseDelay::Restore( class CRestore & ) { return 1; } int CBaseDelay::Restore( class CRestore & ) { return 1; }
int CBaseDelay::Save( class CSave & ) { return 1; } int CBaseDelay::Save( class CSave & ) { return 1; }
// CBaseAnimating Stubs // CBaseAnimating Stubs
int CBaseAnimating::Restore( class CRestore & ) { return 1; } int CBaseAnimating::Restore( class CRestore & ) { return 1; }
int CBaseAnimating::Save( class CSave & ) { return 1; } int CBaseAnimating::Save( class CSave & ) { return 1; }
// DEBUG Stubs // DEBUG Stubs
edict_t *DBG_EntOfVars( const entvars_t *pev ) { return NULL; } 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) { } void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage) { }
// UTIL_* Stubs // UTIL_* Stubs
void UTIL_PrecacheOther( const char *szClassname ) { } void UTIL_PrecacheOther( const char *szClassname ) { }
void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ) { } void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ) { }
void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) { } void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ) { }
void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) { } void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ) { }
BOOL UTIL_IsValidEntity( edict_t *pent ) { return TRUE; } BOOL UTIL_IsValidEntity( edict_t *pent ) { return TRUE; }
void UTIL_SetOrigin( entvars_t *, const Vector &org ) { } void UTIL_SetOrigin( entvars_t *, const Vector &org ) { }
BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { return TRUE; } BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) { return TRUE; }
void UTIL_LogPrintf(char *,...) { } void UTIL_LogPrintf(char *,...) { }
void UTIL_ClientPrintAll( int,char const *,char const *,char const *,char const *,char const *) { } void UTIL_ClientPrintAll( int,char const *,char const *,char const *,char const *,char const *) { }
void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1, const char *param2, const char *param3, const char *param4 ) { } void 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; } CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName) { return 0; }
// CBaseToggle Stubs // CBaseToggle Stubs
int CBaseToggle::Restore( class CRestore & ) { return 1; } int CBaseToggle::Restore( class CRestore & ) { return 1; }
int CBaseToggle::Save( class CSave & ) { return 1; } int CBaseToggle::Save( class CSave & ) { return 1; }
void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { } void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { }
void UTIL_Remove( CBaseEntity *pEntity ){ } void UTIL_Remove( CBaseEntity *pEntity ){ }
struct skilldata_t gSkillData; struct skilldata_t gSkillData;
void UTIL_SetSize( entvars_t *pev, const Vector &vecMin, const Vector &vecMax ){ } void UTIL_SetSize( entvars_t *pev, const Vector &vecMin, const Vector &vecMax ){ }
CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius ){ return 0;} CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius ){ return 0;}
Vector UTIL_VecToAngles( const Vector &vec ){ return 0; } Vector UTIL_VecToAngles( const Vector &vec ){ return 0; }
CSprite *CSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate ) { return 0; } CSprite *CSprite::SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate ) { return 0; }
void CBeam::PointEntInit( const Vector &start, int endIndex ) { } void CBeam::PointEntInit( const Vector &start, int endIndex ) { }
CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { return NULL; } CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { return NULL; }
void CSprite::Expand( float scaleSpeed, float fadeSpeed ) { } void CSprite::Expand( float scaleSpeed, float fadeSpeed ) { }
CBaseEntity* CBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; } CBaseEntity* CBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; }
void CBaseMonster :: Look ( int iDistance ) { } void CBaseMonster :: Look ( int iDistance ) { }
float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; } float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; }
int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) { return 0; } int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) { return 0; }
CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) { return NULL; } CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) { return NULL; }
BOOL CBaseMonster :: FInViewCone ( CBaseEntity *pEntity ) { return FALSE; } BOOL CBaseMonster :: FInViewCone ( CBaseEntity *pEntity ) { return FALSE; }
BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin ) { return FALSE; } BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin ) { return FALSE; }
BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity ) { return FALSE; } BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity ) { return FALSE; }
BOOL CBaseEntity :: FVisible ( const Vector &vecOrigin ) { return FALSE; } BOOL CBaseEntity :: FVisible ( const Vector &vecOrigin ) { return FALSE; }
void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { } void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { }
float CBaseMonster::ChangeYaw ( int yawSpeed ) { return 0; } float CBaseMonster::ChangeYaw ( int yawSpeed ) { return 0; }
int CBaseAnimating :: LookupActivity ( int activity ) { return 0; } int CBaseAnimating :: LookupActivity ( int activity ) { return 0; }
int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; } int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; }
int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; } int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; }
void CBaseAnimating :: ResetSequenceInfo ( ) { } void CBaseAnimating :: ResetSequenceInfo ( ) { }
BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; } BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; }
void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { } void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { }
float CBaseAnimating :: SetBoneController ( int iController, float flValue ) { return 0.0; } float CBaseAnimating :: SetBoneController ( int iController, float flValue ) { return 0.0; }
void CBaseAnimating :: InitBoneControllers ( void ) { } void CBaseAnimating :: InitBoneControllers ( void ) { }
float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) { return 0; } float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) { return 0; }
void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) { } void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) { }
void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) { } void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) { }
int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; } int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; }
void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { } void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { }
void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) { } void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) { }
int CBaseAnimating :: GetBodygroup( int iGroup ) { return 0; } int CBaseAnimating :: GetBodygroup( int iGroup ) { return 0; }
void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, const Vector &vecDir, TraceResult *ptr, int bitsDamageType) { } 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::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 CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { }
void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { } void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { }
void CBaseMonster::ReportAIState( void ) { } void CBaseMonster::ReportAIState( void ) { }
void CBaseMonster :: KeyValue( KeyValueData *pkvd ) { } void CBaseMonster :: KeyValue( KeyValueData *pkvd ) { }
BOOL CBaseMonster :: FCheckAITrigger ( void ) { return FALSE; } BOOL CBaseMonster :: FCheckAITrigger ( void ) { return FALSE; }
void CBaseMonster::CorpseFallThink( void ) { } void CBaseMonster::CorpseFallThink( void ) { }
void CBaseMonster :: MonsterInitDead( void ) { } void CBaseMonster :: MonsterInitDead( void ) { }
void CBaseMonster :: TraceAttack(entvars_t *pevAttacker, float flDamage, const Vector &vecDir, TraceResult *ptr, int bitsDamageType) { } void CBaseMonster :: TraceAttack(entvars_t *pevAttacker, float flDamage, const Vector &vecDir, TraceResult *ptr, int bitsDamageType) { }
BOOL CBaseMonster :: ShouldFadeOnDeath( void ) { return FALSE; } BOOL CBaseMonster :: ShouldFadeOnDeath( void ) { return FALSE; }
void CBaseMonster :: RadiusDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } 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 :: RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { }
void CBaseMonster::FadeMonster( void ) { } void CBaseMonster::FadeMonster( void ) { }
void CBaseMonster :: GibMonster( void ) { } void CBaseMonster :: GibMonster( void ) { }
BOOL CBaseMonster :: HasHumanGibs( void ) { return FALSE; } BOOL CBaseMonster :: HasHumanGibs( void ) { return FALSE; }
BOOL CBaseMonster :: HasAlienGibs( void ) { return FALSE; } BOOL CBaseMonster :: HasAlienGibs( void ) { return FALSE; }
Activity CBaseMonster :: GetDeathActivity ( void ) { return ACT_DIE_HEADSHOT; } Activity CBaseMonster :: GetDeathActivity ( void ) { return ACT_DIE_HEADSHOT; }
void CBaseMonster::BecomeDead( void ) {} void CBaseMonster::BecomeDead( void ) {}
void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) {} void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) {}
int CBaseMonster :: TakeHealth (float flHealth, int bitsDamageType) { return 0; } int CBaseMonster :: TakeHealth (float flHealth, int bitsDamageType) { return 0; }
int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; } int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
int TrainSpeed(int iSpeed, int iMax) { return 0; } int TrainSpeed(int iSpeed, int iMax) { return 0; }
void CBasePlayer :: DeathSound( void ) { } void CBasePlayer :: DeathSound( void ) { }
int CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) { return 0; } int CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) { return 0; }
void CBasePlayer :: TraceAttack(entvars_t *pevAttacker, float flDamage, const Vector &vecDir, TraceResult *ptr, int bitsDamageType) { } 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; } int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; }
void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { } void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { }
void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { } void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { }
void CBasePlayer::WaterMove() { } void CBasePlayer::WaterMove() { }
BOOL CBasePlayer::IsOnLadder( void ) { return FALSE; } BOOL CBasePlayer::IsOnLadder( void ) { return FALSE; }
void CBasePlayer::PlayerDeathThink(void) { } void CBasePlayer::PlayerDeathThink(void) { }
void CBasePlayer::StartDeathCam( void ) { } void CBasePlayer::StartDeathCam( void ) { }
void CBasePlayer::PlayerUse ( void ) { } void CBasePlayer::PlayerUse ( void ) { }
void CBasePlayer::Jump() { } void CBasePlayer::Jump() { }
void CBasePlayer::Duck( ) { } void CBasePlayer::Duck( ) { }
int CBasePlayer::Classify ( void ) { return 0; } int CBasePlayer::Classify ( void ) { return 0; }
void CBasePlayer::PreThink(void) { } void CBasePlayer::PreThink(void) { }
void CBasePlayer::CheckTimeBasedDamage() { } void CBasePlayer::CheckTimeBasedDamage() { }
void CBasePlayer :: UpdateGeigerCounter( void ) { } void CBasePlayer :: UpdateGeigerCounter( void ) { }
void CBasePlayer::CheckSuitUpdate() { } void CBasePlayer::CheckSuitUpdate() { }
void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { } void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { }
void CBasePlayer :: UpdatePlayerSound ( void ) { } void CBasePlayer :: UpdatePlayerSound ( void ) { }
void CBasePlayer::PostThink() { } void CBasePlayer::PostThink() { }
void CBasePlayer :: Precache( void ) { } void CBasePlayer :: Precache( void ) { }
int CBasePlayer::Save( CSave &save ) { return 0; } int CBasePlayer::Save( CSave &save ) { return 0; }
void CBasePlayer::RenewItems(void) { } void CBasePlayer::RenewItems(void) { }
int CBasePlayer::Restore( CRestore &restore ) { return 0; } int CBasePlayer::Restore( CRestore &restore ) { return 0; }
void CBasePlayer::SelectNextItem( int iItem ) { } void CBasePlayer::SelectNextItem( int iItem ) { }
BOOL CBasePlayer::HasWeapons( void ) { return FALSE; } BOOL CBasePlayer::HasWeapons( void ) { return FALSE; }
void CBasePlayer::SelectPrevItem( int iItem ) { } void CBasePlayer::SelectPrevItem( int iItem ) { }
CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { return NULL; } CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { return NULL; }
BOOL CBasePlayer :: FlashlightIsOn( void ) { return FALSE; } BOOL CBasePlayer :: FlashlightIsOn( void ) { return FALSE; }
void CBasePlayer :: FlashlightTurnOn( void ) { } void CBasePlayer :: FlashlightTurnOn( void ) { }
void CBasePlayer :: FlashlightTurnOff( void ) { } void CBasePlayer :: FlashlightTurnOff( void ) { }
void CBasePlayer :: ForceClientDllUpdate( void ) { } void CBasePlayer :: ForceClientDllUpdate( void ) { }
void CBasePlayer::ImpulseCommands( ) { } void CBasePlayer::ImpulseCommands( ) { }
void CBasePlayer::CheatImpulseCommands( int iImpulse ) { } void CBasePlayer::CheatImpulseCommands( int iImpulse ) { }
int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; } int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; } int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
void CBasePlayer::ItemPreFrame() { } void CBasePlayer::ItemPreFrame() { }
void CBasePlayer::ItemPostFrame() { } void CBasePlayer::ItemPostFrame() { }
int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; } int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; }
int CBasePlayer::GetAmmoIndex(const char *psz) { return -1; } int CBasePlayer::GetAmmoIndex(const char *psz) { return -1; }
void CBasePlayer::SendAmmoUpdate(void) { } void CBasePlayer::SendAmmoUpdate(void) { }
void CBasePlayer :: UpdateClientData( void ) { } void CBasePlayer :: UpdateClientData( void ) { }
BOOL CBasePlayer :: FBecomeProne ( void ) { return TRUE; } BOOL CBasePlayer :: FBecomeProne ( void ) { return TRUE; }
void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { } void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { }
void CBasePlayer :: BarnacleVictimReleased ( void ) { } void CBasePlayer :: BarnacleVictimReleased ( void ) { }
int CBasePlayer :: Illumination( void ) { return 0; } int CBasePlayer :: Illumination( void ) { return 0; }
void CBasePlayer :: EnableControl(BOOL fControl) { } void CBasePlayer :: EnableControl(BOOL fControl) { }
Vector CBasePlayer :: GetAutoaimVector( float flDelta ) { return g_vecZero; } Vector CBasePlayer :: GetAutoaimVector( float flDelta ) { return g_vecZero; }
Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; } Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; }
void CBasePlayer :: ResetAutoaim( ) { } void CBasePlayer :: ResetAutoaim( ) { }
void CBasePlayer :: SetCustomDecalFrames( int nFrames ) { } void CBasePlayer :: SetCustomDecalFrames( int nFrames ) { }
int CBasePlayer :: GetCustomDecalFrames( void ) { return -1; } int CBasePlayer :: GetCustomDecalFrames( void ) { return -1; }
void CBasePlayer::DropPlayerItem ( const char *pszItemName ) { } void CBasePlayer::DropPlayerItem ( const char *pszItemName ) { }
BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; } BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; }
BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; } BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; }
const char *CBasePlayer::TeamID( void ) { return ""; } const char *CBasePlayer::TeamID( void ) { return ""; }
int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) { return 0; } int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) { return 0; }
void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { }
void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { }
// CS16 START // CS16 START
void CBasePlayer::Restart( ) { } void CBasePlayer::Restart( ) { }
void CBasePlayer::ResetMaxSpeed() { } void CBasePlayer::ResetMaxSpeed() { }
void CBasePlayer::RoundRespawn() { } void CBasePlayer::RoundRespawn() { }
void CBasePlayer::Blind(float flUntilTime, float flHoldTime, float flFadeTime, int iAlpha) { } void CBasePlayer::Blind(float flUntilTime, float flHoldTime, float flFadeTime, int iAlpha) { }
void CBasePlayer::SetProgressBarTime( int iTime ) { } void CBasePlayer::SetProgressBarTime( int iTime ) { }
void CBasePlayer::SetBombIcon( int ) { } void CBasePlayer::SetBombIcon( int ) { }
void CBasePlayer::UpdateShieldCrosshair(bool bShieldDrawn) { } void CBasePlayer::UpdateShieldCrosshair(bool bShieldDrawn) { }
void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, int pitch, bool showIcon) { } 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 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) { } 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; } 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_ScreenShake(const Vector &center, float amplitude, float frequency, float duration, float radius) { }
void UTIL_Bubbles(Vector mins, Vector maxs, int count) { } void UTIL_Bubbles(Vector mins, Vector maxs, int count) { }
void RemoveEntityHashValue(entvars_s *pev, const char *value, hash_types_e fieldType) { } void RemoveEntityHashValue(entvars_s *pev, const char *value, hash_types_e fieldType) { }
void AddEntityHashValue(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; } 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) { } 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::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::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::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; } CGrenade *CGrenade::ShootSmokeGrenade(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time, unsigned short usEvent) { return 0; }
// CS16 END // CS16 END
void ClearMultiDamage(void) { } void ClearMultiDamage(void) { }
void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) { } void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) { }
void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { } void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { }
void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { } void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { }
int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; } int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; }
void DecalGunshot( TraceResult *pTrace, int iBulletType ) { } void DecalGunshot( TraceResult *pTrace, int iBulletType ) { }
void DecalGunshot( TraceResult *pTrace, int iBulletType, bool ClientOnly, entvars_t *pShooter, bool bHitMetal ) { } 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 EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { }
void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { } void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { }
int CBasePlayerItem::Restore( class CRestore & ) { return 1; } int CBasePlayerItem::Restore( class CRestore & ) { return 1; }
int CBasePlayerItem::Save( class CSave & ) { return 1; } int CBasePlayerItem::Save( class CSave & ) { return 1; }
int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; } int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; }
int CBasePlayerWeapon::Save( class CSave & ) { return 1; } int CBasePlayerWeapon::Save( class CSave & ) { return 1; }
void CBasePlayerItem :: SetObjectCollisionBox( void ) { } void CBasePlayerItem :: SetObjectCollisionBox( void ) { }
void CBasePlayerItem :: FallInit( void ) { } void CBasePlayerItem :: FallInit( void ) { }
void CBasePlayerItem::FallThink ( void ) { } void CBasePlayerItem::FallThink ( void ) { }
void CBasePlayerItem::Materialize( void ) { } void CBasePlayerItem::Materialize( void ) { }
void CBasePlayerItem::AttemptToMaterialize( void ) { } void CBasePlayerItem::AttemptToMaterialize( void ) { }
void CBasePlayerItem :: CheckRespawn ( void ) { } void CBasePlayerItem :: CheckRespawn ( void ) { }
CBaseEntity* CBasePlayerItem::Respawn( void ) { return NULL; } CBaseEntity* CBasePlayerItem::Respawn( void ) { return NULL; }
void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { } void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { }
void CBasePlayerItem::DestroyItem( void ) { } void CBasePlayerItem::DestroyItem( void ) { }
int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return TRUE; } int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return TRUE; }
void CBasePlayerItem::Drop( void ) { } void CBasePlayerItem::Drop( void ) { }
void CBasePlayerItem::Kill( void ) { } void CBasePlayerItem::Kill( void ) { }
void CBasePlayerItem::Holster( int skiplocal ) { } void CBasePlayerItem::Holster( int skiplocal ) { }
void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { } void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { }
int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; } int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; }
int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; } int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; }
int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; } int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; }
BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; } 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 :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; }
BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; } BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; }
int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; } int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; }
int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; } int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; }
void CBasePlayerAmmo::Spawn( void ) { } void CBasePlayerAmmo::Spawn( void ) { }
CBaseEntity* CBasePlayerAmmo::Respawn( void ) { return this; } CBaseEntity* CBasePlayerAmmo::Respawn( void ) { return this; }
void CBasePlayerAmmo::Materialize( void ) { } void CBasePlayerAmmo::Materialize( void ) { }
void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) { } void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) { }
int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return 0; } int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return 0; }
int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; } int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; }
void CBasePlayerWeapon::RetireWeapon( void ) { } void CBasePlayerWeapon::RetireWeapon( void ) { }
void CSoundEnt::InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {} void CSoundEnt::InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {}
void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){} void 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "demo.h" #include "demo.h"
#include "demo_api.h" #include "demo_api.h"
#include "const.h" #include "const.h"
#include "entity_state.h" #include "entity_state.h"
#include "cl_entity.h" #include "cl_entity.h"
#include "pm_defs.h" #include "pm_defs.h"
#include "event_api.h" #include "event_api.h"
#include "entity_types.h" #include "entity_types.h"
#include "r_efx.h" #include "r_efx.h"
/* /*
===================== =====================
Game_AddObjects Game_AddObjects
Add game specific, client-side objects here Add game specific, client-side objects here
===================== =====================
*/ */
void Game_AddObjects( void ) 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "demo.h" #include "demo.h"
#include "demo_api.h" #include "demo_api.h"
#include <memory.h> #include <memory.h>
#ifdef _WIN32 #ifdef _WIN32
#define DLLEXPORT __declspec( dllexport ) #define DLLEXPORT __declspec( dllexport )
#else #else
#define DLLEXPORT #define DLLEXPORT
#endif #endif
int g_demosniper = 0; int g_demosniper = 0;
int g_demosniperdamage = 0; int g_demosniperdamage = 0;
float g_demosniperorg[3]; float g_demosniperorg[3];
float g_demosniperangles[3]; float g_demosniperangles[3];
float g_demozoom; float g_demozoom;
// FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap. // FIXME: There should be buffer helper functions to avoid all of the *(int *)& crap.
extern "C" extern "C"
{ {
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer ); void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
} }
/* /*
===================== =====================
Demo_WriteBuffer Demo_WriteBuffer
Write some data to the demo stream Write some data to the demo stream
===================== =====================
*/ */
void Demo_WriteBuffer( int type, int size, unsigned char *buffer ) void Demo_WriteBuffer( int type, int size, unsigned char *buffer )
{ {
int pos = 0; int pos = 0;
unsigned char buf[ 32 * 1024 ]; unsigned char buf[ 32 * 1024 ];
*( int * )&buf[pos] = type; *( int * )&buf[pos] = type;
pos+=sizeof( int ); pos+=sizeof( int );
memcpy( &buf[pos], buffer, size ); memcpy( &buf[pos], buffer, size );
// Write full buffer out // Write full buffer out
gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf ); gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf );
} }
/* /*
===================== =====================
Demo_ReadBuffer Demo_ReadBuffer
Engine wants us to parse some data from the demo stream Engine wants us to parse some data from the demo stream
===================== =====================
*/ */
void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer ) void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
{ {
int type; int type;
int i = 0; int i = 0;
type = *( int * )buffer; type = *( int * )buffer;
i += sizeof( int ); i += sizeof( int );
switch ( type ) switch ( type )
{ {
case TYPE_SNIPERDOT: case TYPE_SNIPERDOT:
g_demosniper = *(int * )&buffer[ i ]; g_demosniper = *(int * )&buffer[ i ];
i += sizeof( int ); i += sizeof( int );
if ( g_demosniper ) if ( g_demosniper )
{ {
g_demosniperdamage = *( int * )&buffer[ i ]; g_demosniperdamage = *( int * )&buffer[ i ];
i += sizeof( int ); i += sizeof( int );
g_demosniperangles[ 0 ] = *(float *)&buffer[i]; g_demosniperangles[ 0 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperangles[ 1 ] = *(float *)&buffer[i]; g_demosniperangles[ 1 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperangles[ 2 ] = *(float *)&buffer[i]; g_demosniperangles[ 2 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperorg[ 0 ] = *(float *)&buffer[i]; g_demosniperorg[ 0 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperorg[ 1 ] = *(float *)&buffer[i]; g_demosniperorg[ 1 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
g_demosniperorg[ 2 ] = *(float *)&buffer[i]; g_demosniperorg[ 2 ] = *(float *)&buffer[i];
i += sizeof( float ); i += sizeof( float );
} }
break; break;
case TYPE_ZOOM: case TYPE_ZOOM:
g_demozoom = *(float * )&buffer[ i ]; g_demozoom = *(float * )&buffer[ i ];
i += sizeof( float ); i += sizeof( float );
break; break;
default: default:
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" ); gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
break; 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// shared event functions // shared event functions
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "entity_state.h" #include "entity_state.h"
#include "cl_entity.h" #include "cl_entity.h"
#include "r_efx.h" #include "r_efx.h"
#include "eventscripts.h" #include "eventscripts.h"
#include "event_api.h" #include "event_api.h"
#include "pm_shared.h" #include "pm_shared.h"
#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) ) #define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) )
/* /*
================= =================
GetEntity GetEntity
Return's the requested cl_entity_t Return's the requested cl_entity_t
================= =================
*/ */
struct cl_entity_s *GetEntity( int idx ) struct cl_entity_s *GetEntity( int idx )
{ {
return gEngfuncs.GetEntityByIndex( idx ); return gEngfuncs.GetEntityByIndex( idx );
} }
/* /*
================= =================
GetViewEntity GetViewEntity
Return's the current weapon/view model Return's the current weapon/view model
================= =================
*/ */
struct cl_entity_s *GetViewEntity( void ) struct cl_entity_s *GetViewEntity( void )
{ {
return gEngfuncs.GetViewModel(); return gEngfuncs.GetViewModel();
} }
/* /*
================= =================
EV_CreateTracer EV_CreateTracer
Creates a tracer effect Creates a tracer effect
================= =================
*/ */
void EV_CreateTracer( float *start, float *end ) void EV_CreateTracer( float *start, float *end )
{ {
gEngfuncs.pEfxAPI->R_TracerEffect( start, end ); gEngfuncs.pEfxAPI->R_TracerEffect( start, end );
} }
/* /*
================= =================
EV_IsPlayer EV_IsPlayer
Is the entity's index in the player range? Is the entity's index in the player range?
================= =================
*/ */
qboolean EV_IsPlayer( int idx ) qboolean EV_IsPlayer( int idx )
{ {
if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() ) if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() )
return true; return true;
return false; return false;
} }
/* /*
================= =================
EV_IsLocal EV_IsLocal
Is the entity == the local player Is the entity == the local player
================= =================
*/ */
qboolean EV_IsLocal( int idx ) qboolean EV_IsLocal( int idx )
{ {
// check if we are in some way in first person spec mode // check if we are in some way in first person spec mode
if ( IS_FIRSTPERSON_SPEC ) if ( IS_FIRSTPERSON_SPEC )
return (g_iUser2 == idx); return (g_iUser2 == idx);
else else
return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false; return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false;
} }
/* /*
================= =================
EV_GetGunPosition EV_GetGunPosition
Figure out the height of the gun Figure out the height of the gun
================= =================
*/ */
void EV_GetGunPosition( event_args_t *args, float *pos, float *origin ) void EV_GetGunPosition( event_args_t *args, float *pos, float *origin )
{ {
int idx; int idx;
Vector view_ofs(0, 0, 0); Vector view_ofs(0, 0, 0);
idx = args->entindex; idx = args->entindex;
view_ofs[2] = DEFAULT_VIEWHEIGHT; view_ofs[2] = DEFAULT_VIEWHEIGHT;
if ( EV_IsPlayer( idx ) ) if ( EV_IsPlayer( idx ) )
{ {
// in spec mode use entity viewheigh, not own // in spec mode use entity viewheigh, not own
if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC ) if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC )
{ {
// Grab predicted result for local player // Grab predicted result for local player
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
} }
else if ( args->ducking == 1 ) else if ( args->ducking == 1 )
{ {
view_ofs[2] = VEC_DUCK_VIEW; view_ofs[2] = VEC_DUCK_VIEW;
} }
} }
VectorAdd( origin, view_ofs, pos ); VectorAdd( origin, view_ofs, pos );
} }
/* /*
================= =================
EV_EjectBrass EV_EjectBrass
Bullet shell casings Bullet shell casings
================= =================
*/ */
void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype, int life ) void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype, int life )
{ {
vec3_t endpos; vec3_t endpos;
VectorClear( endpos ); VectorClear( endpos );
endpos[1] = rotation; endpos[1] = rotation;
gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, life, model, soundtype ); gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, endpos, life, model, soundtype );
} }
/* /*
================= =================
EV_GetDefaultShellInfo EV_GetDefaultShellInfo
Determine where to eject shells from Determine where to eject shells from
================= =================
*/ */
void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale ) void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, float *ShellVelocity, float *ShellOrigin, float *forward, float *right, float *up, float forwardScale, float upScale, float rightScale )
{ {
int i; int i;
vec3_t view_ofs; vec3_t view_ofs;
float fR, fU; float fR, fU;
int idx; int idx;
idx = args->entindex; idx = args->entindex;
VectorClear( view_ofs ); VectorClear( view_ofs );
view_ofs[2] = DEFAULT_VIEWHEIGHT; view_ofs[2] = DEFAULT_VIEWHEIGHT;
if ( EV_IsPlayer( idx ) ) if ( EV_IsPlayer( idx ) )
{ {
if ( EV_IsLocal( idx ) ) if ( EV_IsLocal( idx ) )
{ {
gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs );
} }
else if ( args->ducking == 1 ) else if ( args->ducking == 1 )
{ {
view_ofs[2] = VEC_DUCK_VIEW; view_ofs[2] = VEC_DUCK_VIEW;
} }
} }
fR = gEngfuncs.pfnRandomFloat( 50, 70 ); fR = gEngfuncs.pfnRandomFloat( 50, 70 );
fU = gEngfuncs.pfnRandomFloat( 100, 150 ); fU = gEngfuncs.pfnRandomFloat( 100, 150 );
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
{ {
ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25; ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25;
ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale; ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale;
} }
} }
/* /*
================= =================
EV_MuzzleFlash EV_MuzzleFlash
Flag weapon/view model for muzzle flash Flag weapon/view model for muzzle flash
================= =================
*/ */
void EV_MuzzleFlash( void ) void EV_MuzzleFlash( void )
{ {
// Add muzzle flash to current weapon model // Add muzzle flash to current weapon model
cl_entity_t *ent = GetViewEntity(); cl_entity_t *ent = GetViewEntity();
if ( !ent ) if ( !ent )
{ {
return; return;
} }
// Or in the muzzle flash // Or in the muzzle flash
ent->curstate.effects |= EF_MUZZLEFLASH; 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. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
void Game_HookEvents( void ); void Game_HookEvents( void );
/* /*
=================== ===================
EV_HookEvents EV_HookEvents
See if game specific code wants to hook any events. See if game specific code wants to hook any events.
=================== ===================
*/ */
void EV_HookEvents( void ) void EV_HookEvents( void )
{ {
Game_HookEvents(); 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#include "events.h" #include "events.h"
/* /*
====================== ======================
Game_HookEvents Game_HookEvents
Associate script file name with callback functions. Callback's must be extern "C" so 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 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 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 into the actual .sc files and create a .sc file parser and hook their functionality through
that.. i.e., a scripting system. that.. i.e., a scripting system.
That was what we were going to do, but we ran out of time...oh well. That was what we were going to do, but we ran out of time...oh well.
====================== ======================
*/ */
void Game_HookEvents( void ) void Game_HookEvents( void )
{ {
HOOK_EVENT( ak47, FireAK47 ); HOOK_EVENT( ak47, FireAK47 );
HOOK_EVENT( aug, FireAUG ); HOOK_EVENT( aug, FireAUG );
HOOK_EVENT( awp, FireAWP ); HOOK_EVENT( awp, FireAWP );
HOOK_EVENT( createexplo, CreateExplo ); HOOK_EVENT( createexplo, CreateExplo );
HOOK_EVENT( createsmoke, CreateSmoke ); HOOK_EVENT( createsmoke, CreateSmoke );
HOOK_EVENT( deagle, FireDEAGLE ); HOOK_EVENT( deagle, FireDEAGLE );
HOOK_EVENT( decal_reset, DecalReset ); HOOK_EVENT( decal_reset, DecalReset );
HOOK_EVENT( elite_left, FireEliteLeft ); HOOK_EVENT( elite_left, FireEliteLeft );
HOOK_EVENT( elite_right, FireEliteRight ); HOOK_EVENT( elite_right, FireEliteRight );
HOOK_EVENT( famas, FireFAMAS ); HOOK_EVENT( famas, FireFAMAS );
HOOK_EVENT( fiveseven, Fire57 ); HOOK_EVENT( fiveseven, Fire57 );
HOOK_EVENT( g3sg1, FireG3SG1 ); HOOK_EVENT( g3sg1, FireG3SG1 );
HOOK_EVENT( galil, FireGALIL ); HOOK_EVENT( galil, FireGALIL );
HOOK_EVENT( glock18, Fireglock18 ); HOOK_EVENT( glock18, Fireglock18 );
HOOK_EVENT( knife, Knife ); HOOK_EVENT( knife, Knife );
HOOK_EVENT( m249, FireM249 ); HOOK_EVENT( m249, FireM249 );
HOOK_EVENT( m3, FireM3 ); HOOK_EVENT( m3, FireM3 );
HOOK_EVENT( m4a1, FireM4A1 ); HOOK_EVENT( m4a1, FireM4A1 );
HOOK_EVENT( mac10, FireMAC10 ); HOOK_EVENT( mac10, FireMAC10 );
HOOK_EVENT( mp5n, FireMP5 ); HOOK_EVENT( mp5n, FireMP5 );
HOOK_EVENT( p228, FireP228 ); HOOK_EVENT( p228, FireP228 );
HOOK_EVENT( p90, FireP90 ); HOOK_EVENT( p90, FireP90 );
HOOK_EVENT( scout, FireScout ); HOOK_EVENT( scout, FireScout );
HOOK_EVENT( sg550, FireSG550 ); HOOK_EVENT( sg550, FireSG550 );
HOOK_EVENT( sg552, FireSG552 ); HOOK_EVENT( sg552, FireSG552 );
HOOK_EVENT( tmp, FireTMP ); HOOK_EVENT( tmp, FireTMP );
HOOK_EVENT( ump45, FireUMP45 ); HOOK_EVENT( ump45, FireUMP45 );
HOOK_EVENT( usp, FireUSP ); HOOK_EVENT( usp, FireUSP );
HOOK_EVENT( vehicle, Vehicle ); HOOK_EVENT( vehicle, Vehicle );
HOOK_EVENT( xm1014, FireXM1014 ); 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// ammo_secondary.cpp // ammo_secondary.cpp
// //
// implementation of CHudAmmoSecondary class // implementation of CHudAmmoSecondary class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal ); DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon ); DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
int CHudAmmoSecondary :: Init( void ) int CHudAmmoSecondary :: Init( void )
{ {
HOOK_MESSAGE( SecAmmoVal ); HOOK_MESSAGE( SecAmmoVal );
HOOK_MESSAGE( SecAmmoIcon ); HOOK_MESSAGE( SecAmmoIcon );
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
m_HUD_ammoicon = 0; m_HUD_ammoicon = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
m_iAmmoAmounts[i] = -1; // -1 means don't draw this value m_iAmmoAmounts[i] = -1; // -1 means don't draw this value
Reset(); Reset();
return 1; return 1;
} }
void CHudAmmoSecondary :: Reset( void ) void CHudAmmoSecondary :: Reset( void )
{ {
m_fFade = 0; m_fFade = 0;
} }
int CHudAmmoSecondary :: VidInit( void ) int CHudAmmoSecondary :: VidInit( void )
{ {
return 1; return 1;
} }
int CHudAmmoSecondary :: Draw(float flTime) int CHudAmmoSecondary :: Draw(float flTime)
{ {
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) ) if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
return 1; return 1;
// draw secondary ammo icons above normal ammo readout // draw secondary ammo icons above normal ammo readout
int a, x, y, r, g, b, AmmoWidth; int a, x, y, r, g, b, AmmoWidth;
DrawUtils::UnpackRGB( r, g, b, RGB_YELLOWISH ); DrawUtils::UnpackRGB( r, g, b, RGB_YELLOWISH );
a = (int) max( MIN_ALPHA, m_fFade ); a = (int) max( MIN_ALPHA, m_fFade );
if (m_fFade > 0) if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
DrawUtils::ScaleColors( r, g, b, a ); DrawUtils::ScaleColors( r, g, b, a );
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values
x = ScreenWidth - AmmoWidth; x = ScreenWidth - AmmoWidth;
if ( m_HUD_ammoicon ) if ( m_HUD_ammoicon )
{ {
// Draw the ammo icon // Draw the ammo icon
x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left); 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); y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom);
SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b ); SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
} }
else else
{ // move the cursor by the '0' char instead, since we don't have an icon to work with { // move the cursor by the '0' char instead, since we don't have an icon to work with
x -= AmmoWidth; x -= AmmoWidth;
y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom); 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 // draw the ammo counts, in reverse order, from right to left
for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- ) for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
{ {
if ( m_iAmmoAmounts[i] < 0 ) if ( m_iAmmoAmounts[i] < 0 )
continue; // negative ammo amounts imply that they shouldn't be drawn continue; // negative ammo amounts imply that they shouldn't be drawn
// half a char gap between the ammo number and the previous pic // half a char gap between the ammo number and the previous pic
x -= (AmmoWidth / 2); x -= (AmmoWidth / 2);
// draw the number, right-aligned // draw the number, right-aligned
x -= (DrawUtils::GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth); x -= (DrawUtils::GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
DrawUtils::DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b ); DrawUtils::DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
if ( i != 0 ) if ( i != 0 )
{ {
// draw the divider bar // draw the divider bar
x -= (AmmoWidth / 2); x -= (AmmoWidth / 2);
FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a); FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
} }
} }
return 1; return 1;
} }
// Message handler for Secondary Ammo Value // Message handler for Secondary Ammo Value
// accepts one value: // accepts one value:
// string: sprite name // string: sprite name
int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf ) int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() ); m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
return 1; return 1;
} }
// Message handler for Secondary Ammo Icon // Message handler for Secondary Ammo Icon
// Sets an ammo value // Sets an ammo value
// takes two values: // takes two values:
// byte: ammo index // byte: ammo index
// byte: ammo value // byte: ammo value
int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf ) int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int index = READ_BYTE(); int index = READ_BYTE();
if ( index < 0 || index >= MAX_SEC_AMMO_VALUES ) if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
return 1; return 1;
m_iAmmoAmounts[index] = READ_BYTE(); m_iAmmoAmounts[index] = READ_BYTE();
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
// check to see if there is anything left to draw // check to see if there is anything left to draw
int count = 0; int count = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
{ {
count += max( 0, m_iAmmoAmounts[i] ); count += max( 0, m_iAmmoAmounts[i] );
} }
if ( count == 0 ) if ( count == 0 )
{ // the ammo fields are all empty, so turn off this hud area { // the ammo fields are all empty, so turn off this hud area
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
return 1; return 1;
} }
// make the icons light up // make the icons light up
m_fFade = 200.0f; m_fFade = 200.0f;
return 1; return 1;
} }

View File

@ -1,191 +1,191 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// ammohistory.cpp // ammohistory.cpp
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "ammohistory.h" #include "ammohistory.h"
HistoryResource gHR; HistoryResource gHR;
#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5) #define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
#define AMMO_PICKUP_PICK_HEIGHT (gHUD.m_iFontHeight * 3 + (gHR.iHistoryGap * 2)) #define AMMO_PICKUP_PICK_HEIGHT (gHUD.m_iFontHeight * 3 + (gHR.iHistoryGap * 2))
#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100) #define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100)
#define MAX_ITEM_NAME 32 #define MAX_ITEM_NAME 32
int HISTORY_DRAW_TIME = 5; int HISTORY_DRAW_TIME = 5;
// keep a list of items // keep a list of items
struct ITEM_INFO struct ITEM_INFO
{ {
char szName[MAX_ITEM_NAME]; char szName[MAX_ITEM_NAME];
HSPRITE spr; HSPRITE spr;
wrect_t rect; wrect_t rect;
}; };
void HistoryResource :: AddToHistory( int iType, int iId, int iCount ) void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
{ {
if ( iType == HISTSLOT_AMMO && !iCount ) if ( iType == HISTSLOT_AMMO && !iCount )
return; // no amount, so don't add return; // no amount, so don't add
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) ) 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 { // the pic would have to be drawn too high
// so start from the bottom // so start from the bottom
iCurrentHistorySlot = 0; iCurrentHistorySlot = 0;
} }
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
HISTORY_DRAW_TIME = gHUD.m_Ammo.m_pHud_DrawHistory_Time->value; HISTORY_DRAW_TIME = gHUD.m_Ammo.m_pHud_DrawHistory_Time->value;
freeslot->type = iType; freeslot->type = iType;
freeslot->iId = iId; freeslot->iId = iId;
freeslot->iCount = iCount; freeslot->iCount = iCount;
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME; freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
} }
void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount ) void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
{ {
if ( iType != HISTSLOT_ITEM ) if ( iType != HISTSLOT_ITEM )
return; return;
if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) ) 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 { // the pic would have to be drawn too high
// so start from the bottom // so start from the bottom
iCurrentHistorySlot = 0; iCurrentHistorySlot = 0;
} }
HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot
// I am really unhappy with all the code in this file // I am really unhappy with all the code in this file
// I am too, -- a1batross // I am too, -- a1batross
int i = gHUD.GetSpriteIndex( szName ); int i = gHUD.GetSpriteIndex( szName );
if ( i == -1 ) if ( i == -1 )
return; // unknown sprite name, don't add it to history return; // unknown sprite name, don't add it to history
freeslot->iId = i; freeslot->iId = i;
freeslot->type = iType; freeslot->type = iType;
freeslot->iCount = iCount; freeslot->iCount = iCount;
HISTORY_DRAW_TIME = gHUD.m_Ammo.m_pHud_DrawHistory_Time->value; HISTORY_DRAW_TIME = gHUD.m_Ammo.m_pHud_DrawHistory_Time->value;
freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME; freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
} }
void HistoryResource :: CheckClearHistory( void ) void HistoryResource :: CheckClearHistory( void )
{ {
for ( int i = 0; i < MAX_HISTORY; i++ ) for ( int i = 0; i < MAX_HISTORY; i++ )
{ {
if ( rgAmmoHistory[i].type ) if ( rgAmmoHistory[i].type )
return; return;
} }
iCurrentHistorySlot = 0; iCurrentHistorySlot = 0;
} }
// //
// Draw Ammo pickup history // Draw Ammo pickup history
// //
int HistoryResource :: DrawAmmoHistory( float flTime ) int HistoryResource :: DrawAmmoHistory( float flTime )
{ {
for ( int i = 0; i < MAX_HISTORY; i++ ) for ( int i = 0; i < MAX_HISTORY; i++ )
{ {
if ( rgAmmoHistory[i].type ) if ( rgAmmoHistory[i].type )
{ {
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME ); rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
if ( rgAmmoHistory[i].DisplayTime <= flTime ) if ( rgAmmoHistory[i].DisplayTime <= flTime )
{ // pic drawing time has expired { // pic drawing time has expired
memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) ); memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
CheckClearHistory(); CheckClearHistory();
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO ) else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
{ {
wrect_t rcPic; wrect_t rcPic;
HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic ); HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
int r, g, b; int r, g, b;
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH); DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::ScaleColors(r, g, b, min(scale, 255) ); DrawUtils::ScaleColors(r, g, b, min(scale, 255) );
// Draw the pic // Draw the pic
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - 24; int xpos = ScreenWidth - 24;
if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic 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 { // the dll has to make sure it has sent info the weapons you need
SPR_Set( *spr, r, g, b ); SPR_Set( *spr, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rcPic ); SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
} }
// Draw the number // Draw the number
DrawUtils::DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b ); DrawUtils::DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP ) else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
{ {
WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId ); WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
if ( !weap ) if ( !weap )
return 1; // we don't know about the weapon yet, so don't draw anything return 1; // we don't know about the weapon yet, so don't draw anything
int r, g, b; int r, g, b;
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH); DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
if ( !gWR.HasAmmo( weap ) ) if ( !gWR.HasAmmo( weap ) )
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red 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; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::ScaleColors(r, g, b, min(scale, 255) ); DrawUtils::ScaleColors(r, g, b, min(scale, 255) );
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left); int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
SPR_Set( weap->hInactive, r, g, b ); SPR_Set( weap->hInactive, r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive ); SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
} }
else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM ) else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
{ {
int r, g, b; int r, g, b;
if ( !rgAmmoHistory[i].iId ) if ( !rgAmmoHistory[i].iId )
continue; // sprite not loaded continue; // sprite not loaded
wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId ); wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH); DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
DrawUtils::ScaleColors(r, g, b, min(scale, 255) ); DrawUtils::ScaleColors(r, g, b, min(scale, 255) );
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (rect.right - rect.left) - 10; int xpos = ScreenWidth - (rect.right - rect.left) - 10;
SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b ); SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
SPR_DrawAdditive( 0, xpos, ypos, &rect ); SPR_DrawAdditive( 0, xpos, ypos, &rect );
} }
} }
} }
return 1; return 1;
} }

View File

@ -1,298 +1,298 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// death notice // death notice
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
float color[3]; float color[3];
DECLARE_MESSAGE( m_DeathNotice, DeathMsg ); DECLARE_MESSAGE( m_DeathNotice, DeathMsg );
struct DeathNoticeItem { struct DeathNoticeItem {
char szKiller[MAX_PLAYER_NAME_LENGTH*2]; char szKiller[MAX_PLAYER_NAME_LENGTH*2];
char szVictim[MAX_PLAYER_NAME_LENGTH*2]; char szVictim[MAX_PLAYER_NAME_LENGTH*2];
int iId; // the index number of the associated sprite int iId; // the index number of the associated sprite
bool bSuicide; bool bSuicide;
bool bTeamKill; bool bTeamKill;
bool bNonPlayerKill; bool bNonPlayerKill;
float flDisplayTime; float flDisplayTime;
float *KillerColor; float *KillerColor;
float *VictimColor; float *VictimColor;
int iHeadShotId; int iHeadShotId;
}; };
#define MAX_DEATHNOTICES 4 #define MAX_DEATHNOTICES 4
static int DEATHNOTICE_DISPLAY_TIME = 6; static int DEATHNOTICE_DISPLAY_TIME = 6;
#define DEATHNOTICE_TOP 32 #define DEATHNOTICE_TOP 32
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ]; DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
int CHudDeathNotice :: Init( void ) int CHudDeathNotice :: Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
HOOK_MESSAGE( DeathMsg ); HOOK_MESSAGE( DeathMsg );
hud_deathnotice_time = CVAR_CREATE( "hud_deathnotice_time", "6", 0 ); hud_deathnotice_time = CVAR_CREATE( "hud_deathnotice_time", "6", 0 );
return 1; return 1;
} }
void CHudDeathNotice :: InitHUDData( void ) void CHudDeathNotice :: InitHUDData( void )
{ {
memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) ); memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) );
} }
int CHudDeathNotice :: VidInit( void ) int CHudDeathNotice :: VidInit( void )
{ {
m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" ); m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" );
m_HUD_d_headshot = gHUD.GetSpriteIndex("d_headshot"); m_HUD_d_headshot = gHUD.GetSpriteIndex("d_headshot");
return 1; return 1;
} }
int CHudDeathNotice :: Draw( float flTime ) int CHudDeathNotice :: Draw( float flTime )
{ {
int x, y, r, g, b; int x, y, r, g, b;
for ( int i = 0; i < MAX_DEATHNOTICES; i++ ) for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
{ {
if ( rgDeathNoticeList[i].iId == 0 ) if ( rgDeathNoticeList[i].iId == 0 )
break; // we've gone through them all break; // we've gone through them all
if ( rgDeathNoticeList[i].flDisplayTime < flTime ) if ( rgDeathNoticeList[i].flDisplayTime < flTime )
{ // display time has expired { // display time has expired
// remove the current item from the list // remove the current item from the list
memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) ); memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) );
i--; // continue on the next item; stop the counter getting incremented i--; // continue on the next item; stop the counter getting incremented
continue; continue;
} }
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME ); rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
// Hide when scoreboard drawing. It will break triapi // Hide when scoreboard drawing. It will break triapi
//if ( gViewPort && gViewPort->AllowedToPrintText() ) //if ( gViewPort && gViewPort->AllowedToPrintText() )
//if ( !gHUD.m_iNoConsolePrint ) //if ( !gHUD.m_iNoConsolePrint )
{ {
// Draw the death notice // Draw the death notice
y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!! y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!!
int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; 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); x = ScreenWidth - DrawUtils::ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
if( rgDeathNoticeList[i].iHeadShotId ) if( rgDeathNoticeList[i].iHeadShotId )
x -= gHUD.GetSpriteRect(m_HUD_d_headshot).right - gHUD.GetSpriteRect(m_HUD_d_headshot).left; x -= gHUD.GetSpriteRect(m_HUD_d_headshot).right - gHUD.GetSpriteRect(m_HUD_d_headshot).left;
if ( !rgDeathNoticeList[i].bSuicide ) if ( !rgDeathNoticeList[i].bSuicide )
{ {
x -= (5 + DrawUtils::ConsoleStringLen( rgDeathNoticeList[i].szKiller ) ); x -= (5 + DrawUtils::ConsoleStringLen( rgDeathNoticeList[i].szKiller ) );
// Draw killers name // Draw killers name
if ( rgDeathNoticeList[i].KillerColor ) if ( rgDeathNoticeList[i].KillerColor )
DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] ); DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
x = 5 + DrawUtils::DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller ); x = 5 + DrawUtils::DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
} }
r = 255; g = 80; b = 0; r = 255; g = 80; b = 0;
if ( rgDeathNoticeList[i].bTeamKill ) if ( rgDeathNoticeList[i].bTeamKill )
{ {
r = 10; g = 240; b = 10; // display it in sickly green r = 10; g = 240; b = 10; // display it in sickly green
} }
// Draw death weapon // Draw death weapon
SPR_Set( gHUD.GetSprite(id), r, g, b ); SPR_Set( gHUD.GetSprite(id), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) );
x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
if( rgDeathNoticeList[i].iHeadShotId) if( rgDeathNoticeList[i].iHeadShotId)
{ {
SPR_Set( gHUD.GetSprite(m_HUD_d_headshot), r, g, b ); SPR_Set( gHUD.GetSprite(m_HUD_d_headshot), r, g, b );
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_d_headshot)); 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); 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) // Draw victims name (if it was a player that was killed)
if (!rgDeathNoticeList[i].bNonPlayerKill) if (!rgDeathNoticeList[i].bNonPlayerKill)
{ {
if ( rgDeathNoticeList[i].VictimColor ) if ( rgDeathNoticeList[i].VictimColor )
DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] ); DrawUtils::SetConsoleTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
x = DrawUtils::DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim ); x = DrawUtils::DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
} }
} }
} }
return 1; return 1;
} }
// This message handler may be better off elsewhere // This message handler may be better off elsewhere
int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf ) int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf )
{ {
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int killer = READ_BYTE(); int killer = READ_BYTE();
int victim = READ_BYTE(); int victim = READ_BYTE();
int headshot = READ_BYTE(); int headshot = READ_BYTE();
char killedwith[32]; char killedwith[32];
strncpy( killedwith, "d_", sizeof(killedwith) ); strncpy( killedwith, "d_", sizeof(killedwith) );
strncat( killedwith, READ_STRING(), sizeof(killedwith) ); strncat( killedwith, READ_STRING(), sizeof(killedwith) );
//if (gViewPort) //if (gViewPort)
// gViewPort->DeathMsg( killer, victim ); // gViewPort->DeathMsg( killer, victim );
gHUD.m_Scoreboard.DeathMsg( killer, victim ); gHUD.m_Scoreboard.DeathMsg( killer, victim );
gHUD.m_Spectator.DeathMessage(victim); gHUD.m_Spectator.DeathMessage(victim);
int i; int i;
for ( i = 0; i < MAX_DEATHNOTICES; i++ ) for ( i = 0; i < MAX_DEATHNOTICES; i++ )
{ {
if ( rgDeathNoticeList[i].iId == 0 ) if ( rgDeathNoticeList[i].iId == 0 )
break; break;
} }
if ( i == MAX_DEATHNOTICES ) if ( i == MAX_DEATHNOTICES )
{ // move the rest of the list forward to make room for this item { // move the rest of the list forward to make room for this item
memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES ); memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES );
i = MAX_DEATHNOTICES - 1; i = MAX_DEATHNOTICES - 1;
} }
//if (gViewPort) //if (gViewPort)
//gViewPort->GetAllPlayersInfo(); //gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo(); gHUD.m_Scoreboard.GetAllPlayersInfo();
// Get the Killer's name // Get the Killer's name
char *killer_name = g_PlayerInfoList[ killer ].name; char *killer_name = g_PlayerInfoList[ killer ].name;
if ( !killer_name ) if ( !killer_name )
{ {
killer_name = ""; killer_name = "";
rgDeathNoticeList[i].szKiller[0] = 0; rgDeathNoticeList[i].szKiller[0] = 0;
} }
else else
{ {
rgDeathNoticeList[i].KillerColor = GetClientColor( killer ); rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH ); strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0; rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0;
} }
// Get the Victim's name // Get the Victim's name
char *victim_name = NULL; char *victim_name = NULL;
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun) // If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
if ( ((char)victim) != -1 ) if ( ((char)victim) != -1 )
victim_name = g_PlayerInfoList[ victim ].name; victim_name = g_PlayerInfoList[ victim ].name;
if ( !victim_name ) if ( !victim_name )
{ {
victim_name = ""; victim_name = "";
rgDeathNoticeList[i].szVictim[0] = 0; rgDeathNoticeList[i].szVictim[0] = 0;
} }
else else
{ {
rgDeathNoticeList[i].VictimColor = GetClientColor( victim ); rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH ); strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0; rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0;
} }
// Is it a non-player object kill? // Is it a non-player object kill?
if ( ((char)victim) == -1 ) if ( ((char)victim) == -1 )
{ {
rgDeathNoticeList[i].bNonPlayerKill = true; rgDeathNoticeList[i].bNonPlayerKill = true;
// Store the object's name in the Victim slot (skip the d_ bit) // Store the object's name in the Victim slot (skip the d_ bit)
strncpy( rgDeathNoticeList[i].szVictim, killedwith+2, sizeof(killedwith) ); strncpy( rgDeathNoticeList[i].szVictim, killedwith+2, sizeof(killedwith) );
} }
else else
{ {
if ( killer == victim || killer == 0 ) if ( killer == victim || killer == 0 )
rgDeathNoticeList[i].bSuicide = true; rgDeathNoticeList[i].bSuicide = true;
if ( !strncmp( killedwith, "d_teammate", sizeof(killedwith) ) ) if ( !strncmp( killedwith, "d_teammate", sizeof(killedwith) ) )
rgDeathNoticeList[i].bTeamKill = true; rgDeathNoticeList[i].bTeamKill = true;
} }
rgDeathNoticeList[i].iHeadShotId = headshot; rgDeathNoticeList[i].iHeadShotId = headshot;
// Find the sprite in the list // Find the sprite in the list
int spr = gHUD.GetSpriteIndex( killedwith ); int spr = gHUD.GetSpriteIndex( killedwith );
rgDeathNoticeList[i].iId = spr; rgDeathNoticeList[i].iId = spr;
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + hud_deathnotice_time->value; rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + hud_deathnotice_time->value;
if (rgDeathNoticeList[i].bNonPlayerKill) if (rgDeathNoticeList[i].bNonPlayerKill)
{ {
ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed a " ); ConsolePrint( " killed a " );
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
ConsolePrint( "\n" ); ConsolePrint( "\n" );
} }
else else
{ {
// record the death notice in the console // record the death notice in the console
if ( rgDeathNoticeList[i].bSuicide ) if ( rgDeathNoticeList[i].bSuicide )
{ {
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
if ( !strncmp( killedwith, "d_world", sizeof(killedwith) ) ) if ( !strncmp( killedwith, "d_world", sizeof(killedwith) ) )
{ {
ConsolePrint( " died" ); ConsolePrint( " died" );
} }
else else
{ {
ConsolePrint( " killed self" ); ConsolePrint( " killed self" );
} }
} }
else if ( rgDeathNoticeList[i].bTeamKill ) else if ( rgDeathNoticeList[i].bTeamKill )
{ {
ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed his teammate " ); ConsolePrint( " killed his teammate " );
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
} }
else else
{ {
if( headshot ) if( headshot )
ConsolePrint( "*** "); ConsolePrint( "*** ");
ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( rgDeathNoticeList[i].szKiller );
ConsolePrint( " killed " ); ConsolePrint( " killed " );
ConsolePrint( rgDeathNoticeList[i].szVictim ); ConsolePrint( rgDeathNoticeList[i].szVictim );
} }
if ( killedwith && *killedwith && (*killedwith > 13 ) && strncmp( killedwith, "d_world", sizeof(killedwith) ) && !rgDeathNoticeList[i].bTeamKill ) if ( killedwith && *killedwith && (*killedwith > 13 ) && strncmp( killedwith, "d_world", sizeof(killedwith) ) && !rgDeathNoticeList[i].bTeamKill )
{ {
if ( headshot ) if ( headshot )
ConsolePrint(" with a headshot from "); ConsolePrint(" with a headshot from ");
else else
ConsolePrint(" with "); ConsolePrint(" with ");
ConsolePrint( killedwith+2 ); // skip over the "d_" part ConsolePrint( killedwith+2 ); // skip over the "d_" part
} }
if( headshot ) ConsolePrint( " ***"); if( headshot ) ConsolePrint( " ***");
ConsolePrint( "\n" ); ConsolePrint( "\n" );
} }
return 1; return 1;
} }

View File

@ -1,139 +1,139 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// flashlight.cpp // flashlight.cpp
// //
// implementation of CHudFlashlight class // implementation of CHudFlashlight class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
DECLARE_MESSAGE(m_Flash, FlashBat) DECLARE_MESSAGE(m_Flash, FlashBat)
DECLARE_MESSAGE(m_Flash, Flashlight) DECLARE_MESSAGE(m_Flash, Flashlight)
#define BAT_NAME "sprites/%d_Flashlight.spr" #define BAT_NAME "sprites/%d_Flashlight.spr"
int CHudFlashlight::Init(void) int CHudFlashlight::Init(void)
{ {
m_fFade = 0; m_fFade = 0;
m_fOn = 0; m_fOn = 0;
HOOK_MESSAGE(Flashlight); HOOK_MESSAGE(Flashlight);
HOOK_MESSAGE(FlashBat); HOOK_MESSAGE(FlashBat);
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
return 1; return 1;
}; };
void CHudFlashlight::Reset(void) void CHudFlashlight::Reset(void)
{ {
m_fFade = 0; m_fFade = 0;
m_fOn = 0; m_fOn = 0;
} }
int CHudFlashlight::VidInit(void) int CHudFlashlight::VidInit(void)
{ {
m_hSprite1.SetSpriteByName("flash_empty"); m_hSprite1.SetSpriteByName("flash_empty");
m_hSprite2.SetSpriteByName("flash_full"); m_hSprite2.SetSpriteByName("flash_full");
m_hBeam.SetSpriteByName("flash_beam"); m_hBeam.SetSpriteByName("flash_beam");
m_iWidth = m_hSprite1.rect.right - m_hSprite1.rect.left; m_iWidth = m_hSprite1.rect.right - m_hSprite1.rect.left;
return 1; return 1;
}; };
int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf ) int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int x = READ_BYTE(); int x = READ_BYTE();
m_iBat = x; m_iBat = x;
m_flBat = ((float)x)/100.0; m_flBat = ((float)x)/100.0;
return 1; return 1;
} }
int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf ) int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_fOn = READ_BYTE(); m_fOn = READ_BYTE();
int x = READ_BYTE(); int x = READ_BYTE();
m_iBat = x; m_iBat = x;
m_flBat = ((float)x)/100.0; m_flBat = ((float)x)/100.0;
return 1; return 1;
} }
int CHudFlashlight::Draw(float flTime) int CHudFlashlight::Draw(float flTime)
{ {
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ) if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
return 1; return 1;
int r, g, b, x, y, a; int r, g, b, x, y, a;
wrect_t rc; wrect_t rc;
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
return 1; return 1;
if (m_fOn) if (m_fOn)
a = 225; a = 225;
else else
a = MIN_ALPHA; a = MIN_ALPHA;
if (m_flBat < 0.20) if (m_flBat < 0.20)
DrawUtils::UnpackRGB(r,g,b, RGB_REDISH); DrawUtils::UnpackRGB(r,g,b, RGB_REDISH);
else else
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH); DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
DrawUtils::ScaleColors(r, g, b, a); DrawUtils::ScaleColors(r, g, b, a);
y = (m_hSprite1.rect.bottom - m_hSprite1.rect.top)/2; y = (m_hSprite1.rect.bottom - m_hSprite1.rect.top)/2;
x = ScreenWidth - m_iWidth - m_iWidth/2 ; x = ScreenWidth - m_iWidth - m_iWidth/2 ;
// Draw the flashlight casing // Draw the flashlight casing
SPR_Set(m_hSprite1.spr, r, g, b ); SPR_Set(m_hSprite1.spr, r, g, b );
SPR_DrawAdditive( 0, x, y, &m_hSprite1.rect); SPR_DrawAdditive( 0, x, y, &m_hSprite1.rect);
if ( m_fOn ) if ( m_fOn )
{ // draw the flashlight beam { // draw the flashlight beam
x = ScreenWidth - m_iWidth/2; x = ScreenWidth - m_iWidth/2;
SPR_Set( m_hBeam.spr, r, g, b ); SPR_Set( m_hBeam.spr, r, g, b );
SPR_DrawAdditive( 0, x, y, &m_hBeam.rect ); SPR_DrawAdditive( 0, x, y, &m_hBeam.rect );
} }
// draw the flashlight energy level // draw the flashlight energy level
x = ScreenWidth - m_iWidth - m_iWidth/2 ; x = ScreenWidth - m_iWidth - m_iWidth/2 ;
int iOffset = m_iWidth * (1.0 - m_flBat); int iOffset = m_iWidth * (1.0 - m_flBat);
if (iOffset < m_iWidth) if (iOffset < m_iWidth)
{ {
rc = m_hSprite2.rect; rc = m_hSprite2.rect;
rc.left += iOffset; rc.left += iOffset;
SPR_Set(m_hSprite2.spr, r, g, b ); SPR_Set(m_hSprite2.spr, r, g, b );
SPR_DrawAdditive( 0, x + iOffset, y, &rc); SPR_DrawAdditive( 0, x + iOffset, y, &rc);
} }
return 1; return 1;
} }

View File

@ -1,184 +1,184 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// Geiger.cpp // Geiger.cpp
// //
// implementation of CHudAmmo class // implementation of CHudAmmo class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE(m_Geiger, Geiger ) DECLARE_MESSAGE(m_Geiger, Geiger )
int CHudGeiger::Init(void) int CHudGeiger::Init(void)
{ {
HOOK_MESSAGE( Geiger ); HOOK_MESSAGE( Geiger );
m_iGeigerRange = 0; m_iGeigerRange = 0;
m_iFlags = 0; m_iFlags = 0;
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
srand( (unsigned)time( NULL ) ); srand( (unsigned)time( NULL ) );
return 1; return 1;
}; };
int CHudGeiger::VidInit(void) int CHudGeiger::VidInit(void)
{ {
return 1; return 1;
}; };
int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf) int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
// update geiger data // update geiger data
m_iGeigerRange = READ_BYTE(); m_iGeigerRange = READ_BYTE();
m_iGeigerRange = m_iGeigerRange << 2; m_iGeigerRange = m_iGeigerRange << 2;
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
return 1; return 1;
} }
int CHudGeiger::Draw (float flTime) int CHudGeiger::Draw (float flTime)
{ {
int pct; int pct;
float flvol; float flvol;
int rg[3]; int rg[3];
int i; int i;
if (m_iGeigerRange < 1000 && m_iGeigerRange > 0) if (m_iGeigerRange < 1000 && m_iGeigerRange > 0)
{ {
// peicewise linear is better than continuous formula for this // peicewise linear is better than continuous formula for this
if (m_iGeigerRange > 800) if (m_iGeigerRange > 800)
{ {
pct = 0; //Con_Printf ( "range > 800\n"); pct = 0; //Con_Printf ( "range > 800\n");
} }
else if (m_iGeigerRange > 600) else if (m_iGeigerRange > 600)
{ {
pct = 2; pct = 2;
flvol = 0.4; //Con_Printf ( "range > 600\n"); flvol = 0.4; //Con_Printf ( "range > 600\n");
rg[0] = 1; rg[0] = 1;
rg[1] = 1; rg[1] = 1;
i = 2; i = 2;
} }
else if (m_iGeigerRange > 500) else if (m_iGeigerRange > 500)
{ {
pct = 4; pct = 4;
flvol = 0.5; //Con_Printf ( "range > 500\n"); flvol = 0.5; //Con_Printf ( "range > 500\n");
rg[0] = 1; rg[0] = 1;
rg[1] = 2; rg[1] = 2;
i = 2; i = 2;
} }
else if (m_iGeigerRange > 400) else if (m_iGeigerRange > 400)
{ {
pct = 8; pct = 8;
flvol = 0.6; //Con_Printf ( "range > 400\n"); flvol = 0.6; //Con_Printf ( "range > 400\n");
rg[0] = 1; rg[0] = 1;
rg[1] = 2; rg[1] = 2;
rg[2] = 3; rg[2] = 3;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 300) else if (m_iGeigerRange > 300)
{ {
pct = 8; pct = 8;
flvol = 0.7; //Con_Printf ( "range > 300\n"); flvol = 0.7; //Con_Printf ( "range > 300\n");
rg[0] = 2; rg[0] = 2;
rg[1] = 3; rg[1] = 3;
rg[2] = 4; rg[2] = 4;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 200) else if (m_iGeigerRange > 200)
{ {
pct = 28; pct = 28;
flvol = 0.78; //Con_Printf ( "range > 200\n"); flvol = 0.78; //Con_Printf ( "range > 200\n");
rg[0] = 2; rg[0] = 2;
rg[1] = 3; rg[1] = 3;
rg[2] = 4; rg[2] = 4;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 150) else if (m_iGeigerRange > 150)
{ {
pct = 40; pct = 40;
flvol = 0.80; //Con_Printf ( "range > 150\n"); flvol = 0.80; //Con_Printf ( "range > 150\n");
rg[0] = 3; rg[0] = 3;
rg[1] = 4; rg[1] = 4;
rg[2] = 5; rg[2] = 5;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 100) else if (m_iGeigerRange > 100)
{ {
pct = 60; pct = 60;
flvol = 0.85; //Con_Printf ( "range > 100\n"); flvol = 0.85; //Con_Printf ( "range > 100\n");
rg[0] = 3; rg[0] = 3;
rg[1] = 4; rg[1] = 4;
rg[2] = 5; rg[2] = 5;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 75) else if (m_iGeigerRange > 75)
{ {
pct = 80; pct = 80;
flvol = 0.9; //Con_Printf ( "range > 75\n"); flvol = 0.9; //Con_Printf ( "range > 75\n");
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75; //gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
rg[0] = 4; rg[0] = 4;
rg[1] = 5; rg[1] = 5;
rg[2] = 6; rg[2] = 6;
i = 3; i = 3;
} }
else if (m_iGeigerRange > 50) else if (m_iGeigerRange > 50)
{ {
pct = 90; pct = 90;
flvol = 0.95; //Con_Printf ( "range > 50\n"); flvol = 0.95; //Con_Printf ( "range > 50\n");
rg[0] = 5; rg[0] = 5;
rg[1] = 6; rg[1] = 6;
i = 2; i = 2;
} }
else else
{ {
pct = 95; pct = 95;
flvol = 1.0; //Con_Printf ( "range < 50\n"); flvol = 1.0; //Con_Printf ( "range < 50\n");
rg[0] = 5; rg[0] = 5;
rg[1] = 6; rg[1] = 6;
i = 2; i = 2;
} }
flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5); flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5);
if ((rand() & 127) < pct || (rand() & 127) < pct) if ((rand() & 127) < pct || (rand() & 127) < pct)
{ {
//S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100); //S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100);
char sz[256]; char sz[256];
int j = rand() & 1; int j = rand() & 1;
if (i > 2) if (i > 2)
j += rand() & 1; j += rand() & 1;
sprintf(sz, "player/geiger%d.wav", j + 1); sprintf(sz, "player/geiger%d.wav", j + 1);
PlaySound(sz, flvol); PlaySound(sz, flvol);
} }
} }
return 1; 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// hud_msg.cpp // hud_msg.cpp
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include "r_efx.h" #include "r_efx.h"
#include "rain.h" #include "rain.h"
#include "com_model.h" #include "com_model.h"
#include "studio.h" #include "studio.h"
#include "studio_util.h" #include "studio_util.h"
#include "StudioModelRenderer.h" #include "StudioModelRenderer.h"
#include "GameStudioModelRenderer.h" #include "GameStudioModelRenderer.h"
#include "com_weapons.h" #include "com_weapons.h"
#include <cstring> #include <cstring>
#define MAX_CLIENTS 32 #define MAX_CLIENTS 32
extern float g_flRoundTime; extern float g_flRoundTime;
/// USER-DEFINED SERVER MESSAGE HANDLERS /// USER-DEFINED SERVER MESSAGE HANDLERS
int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf ) int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
{ {
ASSERT( iSize == 0 ); ASSERT( iSize == 0 );
// clear all hud data // clear all hud data
HUDLIST *pList = m_pHudList; HUDLIST *pList = m_pHudList;
while ( pList ) while ( pList )
{ {
if ( pList->p ) if ( pList->p )
pList->p->Reset(); pList->p->Reset();
pList = pList->pNext; pList = pList->pNext;
} }
// reset sensitivity // reset sensitivity
m_flMouseSensitivity = 0; m_flMouseSensitivity = 0;
// reset concussion effect // reset concussion effect
m_iConcussionEffect = 0; m_iConcussionEffect = 0;
return 1; return 1;
} }
void CAM_ToFirstPerson(void); void CAM_ToFirstPerson(void);
int CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ) int CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{ {
CAM_ToFirstPerson(); CAM_ToFirstPerson();
return 1; return 1;
} }
int CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) int CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{ {
// prepare all hud data // prepare all hud data
HUDLIST *pList = m_pHudList; HUDLIST *pList = m_pHudList;
while (pList) while (pList)
{ {
if ( pList->p ) if ( pList->p )
pList->p->InitHUDData(); pList->p->InitHUDData();
pList = pList->pNext; pList = pList->pNext;
} }
g_iFreezeTimeOver = 0; g_iFreezeTimeOver = 0;
memset( g_PlayerExtraInfo, 0, sizeof(g_PlayerExtraInfo) ); memset( g_PlayerExtraInfo, 0, sizeof(g_PlayerExtraInfo) );
ResetRain(); ResetRain();
// reset round time // reset round time
g_flRoundTime = 0.0f; g_flRoundTime = 0.0f;
return 1; return 1;
} }
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf ) int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_Teamplay = READ_BYTE(); m_Teamplay = READ_BYTE();
return 1; return 1;
} }
int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ) int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_iConcussionEffect = READ_BYTE(); m_iConcussionEffect = READ_BYTE();
if (m_iConcussionEffect) if (m_iConcussionEffect)
this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0); this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0);
else else
this->m_StatusIcons.DisableIcon("dmg_concuss"); this->m_StatusIcons.DisableIcon("dmg_concuss");
return 1; return 1;
} }
int CHud::MsgFunc_ReceiveW(const char *pszName, int iSize, void *pbuf) int CHud::MsgFunc_ReceiveW(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ(pbuf, iSize); BEGIN_READ(pbuf, iSize);
int iWeatherType = READ_BYTE(); int iWeatherType = READ_BYTE();
if( iWeatherType == 0 ) if( iWeatherType == 0 )
{ {
ResetRain(); ResetRain();
return 1; return 1;
} }
Rain.distFromPlayer = 500; Rain.distFromPlayer = 500;
Rain.dripsPerSecond = 500; Rain.dripsPerSecond = 500;
Rain.windX = Rain.windY = 30; Rain.windX = Rain.windY = 30;
Rain.randX = Rain.randY = 0; Rain.randX = Rain.randY = 0;
Rain.weatherMode = iWeatherType - 1; Rain.weatherMode = iWeatherType - 1;
Rain.globalHeight = 100; Rain.globalHeight = 100;
return 1; return 1;
} }
int CHud::MsgFunc_BombDrop(const char *pszName, int iSize, void *pbuf) int CHud::MsgFunc_BombDrop(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ(pbuf, iSize); BEGIN_READ(pbuf, iSize);
g_PlayerExtraInfo[33].origin.x = READ_COORD(); g_PlayerExtraInfo[33].origin.x = READ_COORD();
g_PlayerExtraInfo[33].origin.y = READ_COORD(); g_PlayerExtraInfo[33].origin.y = READ_COORD();
g_PlayerExtraInfo[33].origin.z = READ_COORD(); g_PlayerExtraInfo[33].origin.z = READ_COORD();
g_PlayerExtraInfo[33].radarflashon = 1; g_PlayerExtraInfo[33].radarflashon = 1;
g_PlayerExtraInfo[33].radarflashes = 99999; g_PlayerExtraInfo[33].radarflashes = 99999;
g_PlayerExtraInfo[33].radarflash = gHUD.m_flTime; g_PlayerExtraInfo[33].radarflash = gHUD.m_flTime;
strncpy(g_PlayerExtraInfo[33].teamname, "TERRORIST", MAX_TEAM_NAME); strncpy(g_PlayerExtraInfo[33].teamname, "TERRORIST", MAX_TEAM_NAME);
g_PlayerExtraInfo[33].dead = 0; g_PlayerExtraInfo[33].dead = 0;
g_PlayerExtraInfo[33].nextflash = true; g_PlayerExtraInfo[33].nextflash = true;
int Flag = READ_BYTE(); int Flag = READ_BYTE();
g_PlayerExtraInfo[33].playerclass = Flag; g_PlayerExtraInfo[33].playerclass = Flag;
if( Flag ) // bomb planted if( Flag ) // bomb planted
m_Timer.m_iFlags = 0; m_Timer.m_iFlags = 0;
return 1; return 1;
} }
int CHud::MsgFunc_BombPickup(const char *pszName, int iSize, void *pbuf) int CHud::MsgFunc_BombPickup(const char *pszName, int iSize, void *pbuf)
{ {
g_PlayerExtraInfo[33].radarflashon = 0; g_PlayerExtraInfo[33].radarflashon = 0;
g_PlayerExtraInfo[33].radarflash = 0.0f; g_PlayerExtraInfo[33].radarflash = 0.0f;
g_PlayerExtraInfo[33].radarflashes = 0; g_PlayerExtraInfo[33].radarflashes = 0;
g_PlayerExtraInfo[33].dead = 1; g_PlayerExtraInfo[33].dead = 1;
return 1; return 1;
} }
int CHud::MsgFunc_HostagePos(const char *pszName, int iSize, void *pbuf) int CHud::MsgFunc_HostagePos(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ(pbuf, iSize); BEGIN_READ(pbuf, iSize);
int Flag = READ_BYTE(); int Flag = READ_BYTE();
int idx = READ_BYTE(); int idx = READ_BYTE();
if ( idx <= MAX_HOSTAGES ) if ( idx <= MAX_HOSTAGES )
{ {
g_HostageInfo[idx].origin.x = READ_COORD(); g_HostageInfo[idx].origin.x = READ_COORD();
g_HostageInfo[idx].origin.y = READ_COORD(); g_HostageInfo[idx].origin.y = READ_COORD();
g_HostageInfo[idx].origin.z = READ_COORD(); g_HostageInfo[idx].origin.z = READ_COORD();
if ( Flag == 1 ) if ( Flag == 1 )
{ {
g_HostageInfo[idx].radarflash = gHUD.m_flTime; g_HostageInfo[idx].radarflash = gHUD.m_flTime;
g_HostageInfo[idx].radarflashon = 1; g_HostageInfo[idx].radarflashon = 1;
g_HostageInfo[idx].radarflashes = 99999; g_HostageInfo[idx].radarflashes = 99999;
} }
strncpy(g_HostageInfo[idx].teamname, "CT", MAX_TEAM_NAME); strncpy(g_HostageInfo[idx].teamname, "CT", MAX_TEAM_NAME);
g_HostageInfo[idx].dead = 0; g_HostageInfo[idx].dead = 0;
} }
return 1; return 1;
} }
int CHud::MsgFunc_HostageK(const char *pszName, int iSize, void *pbuf) int CHud::MsgFunc_HostageK(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ(pbuf, iSize); BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE(); int idx = READ_BYTE();
if ( idx <= MAX_HOSTAGES ) if ( idx <= MAX_HOSTAGES )
{ {
g_HostageInfo[idx].dead = 1; g_HostageInfo[idx].dead = 1;
g_HostageInfo[idx].radarflash = gHUD.m_flTime; g_HostageInfo[idx].radarflash = gHUD.m_flTime;
g_HostageInfo[idx].radarflashes = 15; g_HostageInfo[idx].radarflashes = 15;
} }
return 1; return 1;
} }
int CHud::MsgFunc_ShadowIdx(const char *pszName, int iSize, void *pbuf) int CHud::MsgFunc_ShadowIdx(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ(pbuf, iSize); BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE(); int idx = READ_BYTE();
g_StudioRenderer.StudioSetShadowSprite(idx); g_StudioRenderer.StudioSetShadowSprite(idx);
return 1; return 1;
} }

View File

@ -1,175 +1,175 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// hud_redraw.cpp // hud_redraw.cpp
// //
#include <math.h> #include <math.h>
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "triangleapi.h" #include "triangleapi.h"
#include <string.h> #include <string.h>
#define MAX_LOGO_FRAMES 56 #define MAX_LOGO_FRAMES 56
int grgLogoFrame[MAX_LOGO_FRAMES] = 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, 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, 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 29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31
}; };
extern int g_iVisibleMouse; extern int g_iVisibleMouse;
float HUD_GetFOV( void ); float HUD_GetFOV( void );
extern cvar_t *sensitivity; extern cvar_t *sensitivity;
// Think // Think
void CHud::Think(void) void CHud::Think(void)
{ {
int newfov; int newfov;
HUDLIST *pList = m_pHudList; HUDLIST *pList = m_pHudList;
while (pList) while (pList)
{ {
if (pList->p->m_iFlags & HUD_ACTIVE) if (pList->p->m_iFlags & HUD_ACTIVE)
pList->p->Think(); pList->p->Think();
pList = pList->pNext; pList = pList->pNext;
} }
newfov = HUD_GetFOV(); newfov = HUD_GetFOV();
if ( newfov == 0 ) if ( newfov == 0 )
{ {
m_iFOV = default_fov->value; m_iFOV = default_fov->value;
} }
else else
{ {
m_iFOV = newfov; m_iFOV = newfov;
} }
// the clients fov is actually set in the client data update section of the hud // the clients fov is actually set in the client data update section of the hud
// Set a new sensitivity // Set a new sensitivity
if ( m_iFOV == default_fov->value ) if ( m_iFOV == default_fov->value )
{ {
// reset to saved sensitivity // reset to saved sensitivity
m_flMouseSensitivity = 0; m_flMouseSensitivity = 0;
} }
else else
{ {
// set a new sensitivity that is proportional to the change from the FOV default // 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"); m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)default_fov->value) * CVAR_GET_FLOAT("zoom_sensitivity_ratio");
} }
// think about default fov // think about default fov
if ( m_iFOV == 0 ) if ( m_iFOV == 0 )
{ // only let players adjust up in fov, and only if they are not overriden by something else { // only let players adjust up in fov, and only if they are not overriden by something else
m_iFOV = max( default_fov->value, 90 ); m_iFOV = max( default_fov->value, 90 );
} }
} }
// Redraw // Redraw
// step through the local data, placing the appropriate graphics & text as appropriate // step through the local data, placing the appropriate graphics & text as appropriate
// returns 1 if they've changed, 0 otherwise // returns 1 if they've changed, 0 otherwise
int CHud :: Redraw( float flTime, int intermission ) int CHud :: Redraw( float flTime, int intermission )
{ {
m_fOldTime = m_flTime; // save time of previous redraw m_fOldTime = m_flTime; // save time of previous redraw
m_flTime = flTime; m_flTime = flTime;
m_flTimeDelta = (double)m_flTime - m_fOldTime; m_flTimeDelta = (double)m_flTime - m_fOldTime;
static int m_flShotTime = 0; static int m_flShotTime = 0;
// Clock was reset, reset delta // Clock was reset, reset delta
if ( m_flTimeDelta < 0 ) if ( m_flTimeDelta < 0 )
m_flTimeDelta = 0; m_flTimeDelta = 0;
// Bring up the scoreboard during intermission // Bring up the scoreboard during intermission
/*if (gViewPort) /*if (gViewPort)
{ {
if ( m_iIntermission && !intermission ) if ( m_iIntermission && !intermission )
{ {
// Have to do this here so the scoreboard goes away // Have to do this here so the scoreboard goes away
m_iIntermission = intermission; m_iIntermission = intermission;
gViewPort->HideCommandMenu(); gViewPort->HideCommandMenu();
gViewPort->HideScoreBoard(); gViewPort->HideScoreBoard();
gViewPort->UpdateSpectatorPanel(); gViewPort->UpdateSpectatorPanel();
} }
else if ( !m_iIntermission && intermission ) else if ( !m_iIntermission && intermission )
{ {
m_iIntermission = intermission; m_iIntermission = intermission;
gViewPort->HideCommandMenu(); gViewPort->HideCommandMenu();
gViewPort->HideVGUIMenu(); gViewPort->HideVGUIMenu();
gViewPort->ShowScoreBoard(); gViewPort->ShowScoreBoard();
gViewPort->UpdateSpectatorPanel(); gViewPort->UpdateSpectatorPanel();
// Take a screenshot if the client's got the cvar set // Take a screenshot if the client's got the cvar set
if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 ) if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
m_flShotTime = flTime + 1.0; // Take a screenshot in a second m_flShotTime = flTime + 1.0; // Take a screenshot in a second
} }
}*/ }*/
if (m_flShotTime && m_flShotTime < flTime) if (m_flShotTime && m_flShotTime < flTime)
{ {
gEngfuncs.pfnClientCmd("snapshot\n"); gEngfuncs.pfnClientCmd("snapshot\n");
m_flShotTime = 0; m_flShotTime = 0;
} }
m_iIntermission = intermission; m_iIntermission = intermission;
if ( m_pCvarDraw->value ) if ( m_pCvarDraw->value )
{ {
HUDLIST *pList = m_pHudList; HUDLIST *pList = m_pHudList;
while (pList) while (pList)
{ {
if ( !intermission ) if ( !intermission )
{ {
if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) ) if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) )
pList->p->Draw(flTime); pList->p->Draw(flTime);
} }
else else
{ // it's an intermission, so only draw hud elements that are set to draw during intermissions { // it's an intermission, so only draw hud elements that are set to draw during intermissions
if ( pList->p->m_iFlags & HUD_INTERMISSION ) if ( pList->p->m_iFlags & HUD_INTERMISSION )
pList->p->Draw( flTime ); pList->p->Draw( flTime );
} }
pList = pList->pNext; pList = pList->pNext;
} }
} }
// are we in demo mode? do we need to draw the logo in the top corner? // are we in demo mode? do we need to draw the logo in the top corner?
if (m_iLogo) if (m_iLogo)
{ {
int x, y, i; int x, y, i;
if (m_hsprLogo == 0) if (m_hsprLogo == 0)
m_hsprLogo = LoadSprite("sprites/%d_logo.spr"); m_hsprLogo = LoadSprite("sprites/%d_logo.spr");
SPR_Set(m_hsprLogo, 250, 250, 250 ); SPR_Set(m_hsprLogo, 250, 250, 250 );
x = SPR_Width(m_hsprLogo, 0); x = SPR_Width(m_hsprLogo, 0);
x = ScreenWidth - x; x = ScreenWidth - x;
y = SPR_Height(m_hsprLogo, 0)/2; y = SPR_Height(m_hsprLogo, 0)/2;
// Draw the logo at 20 fps // Draw the logo at 20 fps
int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES; int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
i = grgLogoFrame[iFrame] - 1; i = grgLogoFrame[iFrame] - 1;
SPR_DrawAdditive(i, x, y, NULL); SPR_DrawAdditive(i, x, y, NULL);
} }
return 1; 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// hud_update.cpp // hud_update.cpp
// //
#include <math.h> #include <math.h>
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <stdlib.h> #include <stdlib.h>
#include <memory.h> #include <memory.h>
int CL_ButtonBits( int ); int CL_ButtonBits( int );
void CL_ResetButtonBits( int bits ); void CL_ResetButtonBits( int bits );
extern float v_idlescale; extern float v_idlescale;
float in_fov; float in_fov;
extern void HUD_SetCmdBits( int bits ); extern void HUD_SetCmdBits( int bits );
int CHud::UpdateClientData(client_data_t *cdata, float time) int CHud::UpdateClientData(client_data_t *cdata, float time)
{ {
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t)); memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t));
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t)); memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t));
m_iKeyBits = CL_ButtonBits( 0 ); m_iKeyBits = CL_ButtonBits( 0 );
m_iWeaponBits = cdata->iWeaponBits; m_iWeaponBits = cdata->iWeaponBits;
in_fov = cdata->fov; in_fov = cdata->fov;
Think(); Think();
cdata->fov = m_iFOV; cdata->fov = m_iFOV;
v_idlescale = m_iConcussionEffect; v_idlescale = m_iConcussionEffect;
CL_ResetButtonBits( m_iKeyBits ); CL_ResetButtonBits( m_iKeyBits );
// return 1 if in anything in the client_data struct has been changed, 0 otherwise // return 1 if in anything in the client_data struct has been changed, 0 otherwise
return 1; return 1;
} }

View File

@ -1,356 +1,356 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// menu.cpp // menu.cpp
// //
// generic menu handler // generic menu handler
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
//#include "vgui_TeamFortressViewport.h" //#include "vgui_TeamFortressViewport.h"
#define MAX_MENU_STRING 512 #define MAX_MENU_STRING 512
char g_szMenuString[MAX_MENU_STRING]; char g_szMenuString[MAX_MENU_STRING];
char g_szPrelocalisedMenuString[MAX_MENU_STRING]; char g_szPrelocalisedMenuString[MAX_MENU_STRING];
int KB_ConvertString( char *in, char **ppout ); int KB_ConvertString( char *in, char **ppout );
DECLARE_MESSAGE( m_Menu, ShowMenu ); DECLARE_MESSAGE( m_Menu, ShowMenu );
DECLARE_MESSAGE( m_Menu, VGUIMenu ); DECLARE_MESSAGE( m_Menu, VGUIMenu );
DECLARE_MESSAGE( m_Menu, BuyClose ); DECLARE_MESSAGE( m_Menu, BuyClose );
DECLARE_MESSAGE( m_Menu, AllowSpec ); DECLARE_MESSAGE( m_Menu, AllowSpec );
DECLARE_COMMAND( m_Menu, OldStyleMenuOpen ); DECLARE_COMMAND( m_Menu, OldStyleMenuOpen );
DECLARE_COMMAND( m_Menu, OldStyleMenuClose ); DECLARE_COMMAND( m_Menu, OldStyleMenuClose );
DECLARE_COMMAND( m_Menu, ShowVGUIMenu ); DECLARE_COMMAND( m_Menu, ShowVGUIMenu );
int CHudMenu :: Init( void ) int CHudMenu :: Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
HOOK_MESSAGE( ShowMenu ); HOOK_MESSAGE( ShowMenu );
HOOK_MESSAGE( VGUIMenu ); HOOK_MESSAGE( VGUIMenu );
HOOK_MESSAGE( BuyClose ); HOOK_MESSAGE( BuyClose );
HOOK_MESSAGE( AllowSpec ); HOOK_MESSAGE( AllowSpec );
HOOK_COMMAND( "client_buy_open", OldStyleMenuOpen ); HOOK_COMMAND( "client_buy_open", OldStyleMenuOpen );
HOOK_COMMAND( "client_buy_close", OldStyleMenuClose ); HOOK_COMMAND( "client_buy_close", OldStyleMenuClose );
HOOK_COMMAND( "showvguimenu", ShowVGUIMenu ); HOOK_COMMAND( "showvguimenu", ShowVGUIMenu );
_extended_menus = CVAR_CREATE("_extended_menus", "0", FCVAR_ARCHIVE); _extended_menus = CVAR_CREATE("_extended_menus", "0", FCVAR_ARCHIVE);
InitHUDData(); InitHUDData();
m_bAllowSpec = true; // by default, spectating is allowed m_bAllowSpec = true; // by default, spectating is allowed
return 1; return 1;
} }
void CHudMenu :: InitHUDData( void ) void CHudMenu :: InitHUDData( void )
{ {
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
m_bitsValidSlots = 0; m_bitsValidSlots = 0;
Reset(); Reset();
} }
void CHudMenu :: Reset( void ) void CHudMenu :: Reset( void )
{ {
g_szPrelocalisedMenuString[0] = 0; g_szPrelocalisedMenuString[0] = 0;
m_fWaitingForMore = FALSE; m_fWaitingForMore = FALSE;
} }
int CHudMenu :: VidInit( void ) int CHudMenu :: VidInit( void )
{ {
return 1; return 1;
} }
int CHudMenu :: Draw( float flTime ) int CHudMenu :: Draw( float flTime )
{ {
// check for if menu is set to disappear // check for if menu is set to disappear
if ( m_flShutoffTime > 0 ) if ( m_flShutoffTime > 0 )
{ {
if ( m_flShutoffTime <= gHUD.m_flTime ) if ( m_flShutoffTime <= gHUD.m_flTime )
{ // times up, shutoff { // times up, shutoff
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
return 1; return 1;
} }
} }
// don't draw the menu if the scoreboard is being shown // don't draw the menu if the scoreboard is being shown
//if ( gViewPort && gViewPort->IsScoreBoardVisible() ) //if ( gViewPort && gViewPort->IsScoreBoardVisible() )
//return 1; //return 1;
// draw the menu, along the left-hand side of the screen // draw the menu, along the left-hand side of the screen
// count the number of newlines // count the number of newlines
int nlc = 0; int nlc = 0;
int i; int i;
for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ ) for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ )
{ {
if ( g_szMenuString[i] == '\n' ) if ( g_szMenuString[i] == '\n' )
nlc++; nlc++;
} }
// center it // center it
int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text
int x = 20; int x = 20;
i = 0; i = 0;
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' ) while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' )
{ {
DrawUtils::DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 ); DrawUtils::DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 );
y += 24; y += 24;
while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' ) while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' )
i++; i++;
if ( g_szMenuString[i] == '\n' ) if ( g_szMenuString[i] == '\n' )
i++; i++;
} }
return 1; return 1;
} }
// selects an item from the menu // selects an item from the menu
void CHudMenu :: SelectMenuItem( int menu_item ) void CHudMenu :: SelectMenuItem( int menu_item )
{ {
// if menu_item is in a valid slot, send a menuselect command to the server // if menu_item is in a valid slot, send a menuselect command to the server
if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) ) if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) )
{ {
char szbuf[32]; char szbuf[32];
sprintf( szbuf, "menuselect %d\n", menu_item ); sprintf( szbuf, "menuselect %d\n", menu_item );
ClientCmd( szbuf ); ClientCmd( szbuf );
// remove the menu // remove the menu
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
} }
} }
// Message handler for ShowMenu message // Message handler for ShowMenu message
// takes four values: // takes four values:
// short: a bitfield of keys that are valid input // 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. // 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 // 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 // string: menu string to display
// if this message is never received, then scores will simply be the combined totals of the players. // 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 ) int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
{ {
char *temp = NULL, *menustring; char *temp = NULL, *menustring;
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_bitsValidSlots = READ_SHORT(); m_bitsValidSlots = READ_SHORT();
int DisplayTime = READ_CHAR(); int DisplayTime = READ_CHAR();
int NeedMore = READ_BYTE(); int NeedMore = READ_BYTE();
if ( DisplayTime > 0 ) if ( DisplayTime > 0 )
m_flShutoffTime = DisplayTime + gHUD.m_flTime; m_flShutoffTime = DisplayTime + gHUD.m_flTime;
else else
m_flShutoffTime = -1; m_flShutoffTime = -1;
if ( !m_bitsValidSlots ) if ( !m_bitsValidSlots )
{ {
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
ClientCmd("touch_removebutton _menu_*"); ClientCmd("touch_removebutton _menu_*");
return 1; return 1;
} }
menustring = READ_STRING(); menustring = READ_STRING();
// menu will be replaced by scripted touch config // menu will be replaced by scripted touch config
// so execute it and exit // so execute it and exit
if( _extended_menus->value != 0.0f ) if( _extended_menus->value != 0.0f )
{ {
if( !strcmp(menustring, "#RadioA") ) if( !strcmp(menustring, "#RadioA") )
{ {
ShowVGUIMenu(MENU_RADIOA); ShowVGUIMenu(MENU_RADIOA);
return 1; return 1;
} }
else if( !strcmp(menustring, "#RadioB")) else if( !strcmp(menustring, "#RadioB"))
{ {
ShowVGUIMenu(MENU_RADIOB); ShowVGUIMenu(MENU_RADIOB);
return 1; return 1;
} }
else if( !strcmp(menustring, "#RadioC")) else if( !strcmp(menustring, "#RadioC"))
{ {
ShowVGUIMenu(MENU_RADIOC); ShowVGUIMenu(MENU_RADIOC);
return 1; return 1;
} }
} }
if ( !m_fWaitingForMore ) // this is the start of a new menu if ( !m_fWaitingForMore ) // this is the start of a new menu
{ {
strncpy( g_szPrelocalisedMenuString, menustring, MAX_MENU_STRING ); strncpy( g_szPrelocalisedMenuString, menustring, MAX_MENU_STRING );
} }
else else
{ // append to the current menu string { // append to the current menu string
strncat( g_szPrelocalisedMenuString, menustring, MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) ); strncat( g_szPrelocalisedMenuString, menustring, MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) );
} }
g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not) g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not)
if ( !NeedMore ) if ( !NeedMore )
{ // we have the whole string, so we can localise it now { // we have the whole string, so we can localise it now
strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING ); strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING );
// Swap in characters // Swap in characters
if ( KB_ConvertString( g_szMenuString, &temp ) ) if ( KB_ConvertString( g_szMenuString, &temp ) )
{ {
strncpy( g_szMenuString, temp, MAX_MENU_STRING ); strncpy( g_szMenuString, temp, MAX_MENU_STRING );
free( temp ); free( temp );
} }
} }
m_fMenuDisplayed = 1; m_fMenuDisplayed = 1;
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
m_fWaitingForMore = NeedMore; m_fWaitingForMore = NeedMore;
return 1; return 1;
} }
int CHudMenu::MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf ) int CHudMenu::MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ(pbuf, iSize); BEGIN_READ(pbuf, iSize);
int menuType = READ_BYTE(); int menuType = READ_BYTE();
m_bitsValidSlots = READ_SHORT(); // is ignored m_bitsValidSlots = READ_SHORT(); // is ignored
ShowVGUIMenu(menuType); ShowVGUIMenu(menuType);
return 1; return 1;
} }
int CHudMenu::MsgFunc_BuyClose(const char *pszName, int iSize, void *pbuf) int CHudMenu::MsgFunc_BuyClose(const char *pszName, int iSize, void *pbuf)
{ {
UserCmd_OldStyleMenuClose(); UserCmd_OldStyleMenuClose();
ClientCmd("touch_removebutton _menu_*"); ClientCmd("touch_removebutton _menu_*");
return 1; return 1;
} }
int CHudMenu::MsgFunc_AllowSpec(const char *pszName, int iSize, void *pbuf) int CHudMenu::MsgFunc_AllowSpec(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
m_bAllowSpec = !!READ_BYTE(); m_bAllowSpec = !!READ_BYTE();
return 1; return 1;
} }
void CHudMenu::UserCmd_OldStyleMenuOpen() void CHudMenu::UserCmd_OldStyleMenuOpen()
{ {
m_flShutoffTime = -1; // stay open until user will not close it m_flShutoffTime = -1; // stay open until user will not close it
strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString("Buy"), MAX_MENU_STRING ); strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString("Buy"), MAX_MENU_STRING );
} }
void CHudMenu::UserCmd_OldStyleMenuClose() void CHudMenu::UserCmd_OldStyleMenuClose()
{ {
m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off m_fMenuDisplayed = 0; // no valid slots means that the menu should be turned off
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
ClientCmd("touch_removebutton _menu_*"); ClientCmd("touch_removebutton _menu_*");
} }
// lol, no real VGUI here // lol, no real VGUI here
// it's really good only for touchscreen // it's really good only for touchscreen
void CHudMenu::ShowVGUIMenu( int menuType ) void CHudMenu::ShowVGUIMenu( int menuType )
{ {
char *szCmd; char *szCmd;
switch(menuType) switch(menuType)
{ {
case MENU_TEAM: case MENU_TEAM:
szCmd = "exec touch/chooseteam.cfg"; szCmd = "exec touch/chooseteam.cfg";
break; break;
case MENU_CLASS_T: case MENU_CLASS_T:
szCmd = "exec touch/chooseteam_tr.cfg"; szCmd = "exec touch/chooseteam_tr.cfg";
break; break;
case MENU_CLASS_CT: case MENU_CLASS_CT:
szCmd = "exec touch/chooseteam_ct.cfg"; szCmd = "exec touch/chooseteam_ct.cfg";
break; break;
case MENU_BUY: case MENU_BUY:
szCmd = "exec touch/buy.cfg"; szCmd = "exec touch/buy.cfg";
break; break;
case MENU_BUY_PISTOL: case MENU_BUY_PISTOL:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST ) if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_pistol_t.cfg"; szCmd = "exec touch/buy_pistol_t.cfg";
else szCmd = "exec touch/buy_pistol_ct.cfg"; else szCmd = "exec touch/buy_pistol_ct.cfg";
break; break;
case MENU_BUY_SHOTGUN: case MENU_BUY_SHOTGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST ) if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_shotgun_t.cfg"; szCmd = "exec touch/buy_shotgun_t.cfg";
else szCmd = "exec touch/buy_shotgun_ct.cfg"; else szCmd = "exec touch/buy_shotgun_ct.cfg";
break; break;
case MENU_BUY_RIFLE: case MENU_BUY_RIFLE:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST ) if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_rifle_t.cfg"; szCmd = "exec touch/buy_rifle_t.cfg";
else szCmd ="exec touch/buy_rifle_ct.cfg"; else szCmd ="exec touch/buy_rifle_ct.cfg";
break; break;
case MENU_BUY_SUBMACHINEGUN: case MENU_BUY_SUBMACHINEGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST ) if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
szCmd = "exec touch/buy_submachinegun_t.cfg"; szCmd = "exec touch/buy_submachinegun_t.cfg";
else szCmd = "exec touch/buy_submachinegun_ct.cfg"; else szCmd = "exec touch/buy_submachinegun_ct.cfg";
break; break;
case MENU_BUY_MACHINEGUN: case MENU_BUY_MACHINEGUN:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == 1 ) if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == 1 )
szCmd = "exec touch/buy_machinegun_t.cfg"; szCmd = "exec touch/buy_machinegun_t.cfg";
else szCmd = "exec touch/buy_machinegun_ct.cfg"; else szCmd = "exec touch/buy_machinegun_ct.cfg";
break; break;
case MENU_BUY_ITEM: case MENU_BUY_ITEM:
if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == 1 ) if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == 1 )
szCmd = "exec touch/buy_item_t.cfg"; szCmd = "exec touch/buy_item_t.cfg";
else szCmd = "exec touch/buy_item_ct.cfg"; else szCmd = "exec touch/buy_item_ct.cfg";
break; break;
case MENU_RADIOA: case MENU_RADIOA:
szCmd = "exec touch/radioa.cfg"; szCmd = "exec touch/radioa.cfg";
break; break;
case MENU_RADIOB: case MENU_RADIOB:
szCmd = "exec touch/radiob.cfg"; szCmd = "exec touch/radiob.cfg";
break; break;
case MENU_RADIOC: case MENU_RADIOC:
szCmd = "exec touch/radioc.cfg"; szCmd = "exec touch/radioc.cfg";
break; break;
case MENU_RADIOSELECTOR: case MENU_RADIOSELECTOR:
szCmd = "exec touch/radioselector.cfg"; szCmd = "exec touch/radioselector.cfg";
break; break;
default: default:
szCmd = "touch_removebutton _menu_*"; // back to the default touch page szCmd = "touch_removebutton _menu_*"; // back to the default touch page
m_fMenuDisplayed = 0; m_fMenuDisplayed = 0;
break; break;
} }
m_fMenuDisplayed = 1; m_fMenuDisplayed = 1;
ClientCmd(szCmd); ClientCmd(szCmd);
} }
void CHudMenu::UserCmd_ShowVGUIMenu() void CHudMenu::UserCmd_ShowVGUIMenu()
{ {
if( gEngfuncs.Cmd_Argc() != 1 ) if( gEngfuncs.Cmd_Argc() != 1 )
{ {
ConsolePrint("usage: showvguimenu <menuType>\n"); ConsolePrint("usage: showvguimenu <menuType>\n");
} }
if( gEngfuncs.pfnGetCvarFloat("_vgui_menus") == 0.0f ) if( gEngfuncs.pfnGetCvarFloat("_vgui_menus") == 0.0f )
return; return;
int menuType = atoi(gEngfuncs.Cmd_Argv(1)); int menuType = atoi(gEngfuncs.Cmd_Argv(1));
ShowVGUIMenu(menuType); 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// saytext.cpp // saytext.cpp
// //
// implementation of CHudSayText class // implementation of CHudSayText class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include "vgui_parser.h" #include "vgui_parser.h"
//#include "vgui_TeamFortressViewport.h" //#include "vgui_TeamFortressViewport.h"
extern float *GetClientColor( int clientIndex ); extern float *GetClientColor( int clientIndex );
#define MAX_LINES 5 #define MAX_LINES 5
#define MAX_CHARS_PER_LINE 256 /* it can be less than this, depending on char size */ #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 // allow 20 pixels on either side of the text
#define MAX_LINE_WIDTH ( ScreenWidth - 40 ) #define MAX_LINE_WIDTH ( ScreenWidth - 40 )
#define LINE_START 10 #define LINE_START 10
static float SCROLL_SPEED = 5; static float SCROLL_SPEED = 5;
static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ]; static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ];
static float *g_pflNameColors[ MAX_LINES + 1 ]; static float *g_pflNameColors[ MAX_LINES + 1 ];
static int g_iNameLengths[ MAX_LINES + 1 ]; static int g_iNameLengths[ MAX_LINES + 1 ];
static float flScrollTime = 0; // the time at which the lines next scroll up static float flScrollTime = 0; // the time at which the lines next scroll up
static int Y_START = 0; static int Y_START = 0;
static int line_height = 0; static int line_height = 0;
DECLARE_MESSAGE( m_SayText, SayText ); DECLARE_MESSAGE( m_SayText, SayText );
int CHudSayText :: Init( void ) int CHudSayText :: Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
HOOK_MESSAGE( SayText ); HOOK_MESSAGE( SayText );
InitHUDData(); InitHUDData();
m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 ); m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 );
m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable( "hud_saytext_time", "5", 0 ); m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable( "hud_saytext_time", "5", 0 );
m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission
return 1; return 1;
} }
void CHudSayText :: InitHUDData( void ) void CHudSayText :: InitHUDData( void )
{ {
memset( g_szLineBuffer, 0, sizeof g_szLineBuffer ); memset( g_szLineBuffer, 0, sizeof g_szLineBuffer );
memset( g_pflNameColors, 0, sizeof g_pflNameColors ); memset( g_pflNameColors, 0, sizeof g_pflNameColors );
memset( g_iNameLengths, 0, sizeof g_iNameLengths ); memset( g_iNameLengths, 0, sizeof g_iNameLengths );
} }
int CHudSayText :: VidInit( void ) int CHudSayText :: VidInit( void )
{ {
return 1; return 1;
} }
int ScrollTextUp( void ) int ScrollTextUp( void )
{ {
ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer
g_szLineBuffer[MAX_LINES][0] = 0; 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_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_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]) ); memmove( &g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]) );
g_szLineBuffer[MAX_LINES-1][0] = 0; g_szLineBuffer[MAX_LINES-1][0] = 0;
if ( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines if ( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines
{ {
g_szLineBuffer[0][0] = 2; g_szLineBuffer[0][0] = 2;
return 1 + ScrollTextUp(); return 1 + ScrollTextUp();
} }
return 1; return 1;
} }
int CHudSayText :: Draw( float flTime ) int CHudSayText :: Draw( float flTime )
{ {
int y = Y_START; int y = Y_START;
//if ( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE) || !m_HUD_saytext->value ) //if ( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE) || !m_HUD_saytext->value )
//return 1; //return 1;
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value ); flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value );
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value ); flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value );
if ( flScrollTime <= flTime ) if ( flScrollTime <= flTime )
{ {
if ( *g_szLineBuffer[0] ) if ( *g_szLineBuffer[0] )
{ {
flScrollTime = flTime + m_HUD_saytext_time->value; flScrollTime = flTime + m_HUD_saytext_time->value;
// push the console up // push the console up
ScrollTextUp(); ScrollTextUp();
} }
else else
{ // buffer is empty, just disable drawing of this section { // buffer is empty, just disable drawing of this section
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
} }
} }
for ( int i = 0; i < MAX_LINES; i++ ) for ( int i = 0; i < MAX_LINES; i++ )
{ {
if ( *g_szLineBuffer[i] ) if ( *g_szLineBuffer[i] )
{ {
if ( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] ) if ( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] )
{ {
// it's a saytext string // it's a saytext string
static char buf[MAX_PLAYER_NAME_LENGTH+32]; static char buf[MAX_PLAYER_NAME_LENGTH+32];
// draw the first x characters in the player color // draw the first x characters in the player color
strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) ); 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; 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] ); DrawUtils::SetConsoleTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
int x = DrawUtils::DrawConsoleString( LINE_START, y, buf ); int x = DrawUtils::DrawConsoleString( LINE_START, y, buf );
// color is reset after each string draw // color is reset after each string draw
DrawUtils::DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] ); DrawUtils::DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] );
} }
else else
{ {
// normal draw // normal draw
DrawUtils::DrawConsoleString( LINE_START, y, g_szLineBuffer[i] ); DrawUtils::DrawConsoleString( LINE_START, y, g_szLineBuffer[i] );
} }
} }
y += line_height; y += line_height;
} }
return 1; return 1;
} }
struct CSimpleMap { struct CSimpleMap {
const char key[32]; const char key[32];
const char value[64]; const char value[64];
}; };
CSimpleMap sayTextFmt[] = CSimpleMap sayTextFmt[] =
{ {
{"#Cstrike_Chat_CT", "\x02(Counter-Terrorist) %s : %s"}, {"#Cstrike_Chat_CT", "\x02(Counter-Terrorist) %s : %s"},
{"#Cstrike_Chat_T", "\x02(Terrorist) %s : %s"}, {"#Cstrike_Chat_T", "\x02(Terrorist) %s : %s"},
{"#Cstrike_Chat_CT_Dead", "\x02*DEAD*(Counter-Terrorist) %s : %s"}, {"#Cstrike_Chat_CT_Dead", "\x02*DEAD*(Counter-Terrorist) %s : %s"},
{"#Cstrike_Chat_T_Dead", "\x02*DEAD*(Terrorist) %s : %s"}, {"#Cstrike_Chat_T_Dead", "\x02*DEAD*(Terrorist) %s : %s"},
{"#Cstrike_Chat_Spec", "\x02(Spectator) %s : %s"}, {"#Cstrike_Chat_Spec", "\x02(Spectator) %s : %s"},
{"#Cstrike_Chat_All", "\x02%s : %s"}, {"#Cstrike_Chat_All", "\x02%s : %s"},
{"#Cstrike_Chat_AllDead", "\x02*DEAD* %s: %s"}, {"#Cstrike_Chat_AllDead", "\x02*DEAD* %s: %s"},
{"#Cstrike_Chat_AllSpec", "\x02*SPEC* %s: %s"}, {"#Cstrike_Chat_AllSpec", "\x02*SPEC* %s: %s"},
{"#Cstrike_Name_Change", "\x02* %s changed name to %s"}, {"#Cstrike_Name_Change", "\x02* %s changed name to %s"},
}; };
int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ) int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int client_index = READ_BYTE(); // the client who spoke the message int client_index = READ_BYTE(); // the client who spoke the message
char szBuf[3][64]; char szBuf[3][64];
strncpy( szBuf[0], READ_STRING(), sizeof(szBuf[0])); strncpy( szBuf[0], READ_STRING(), sizeof(szBuf[0]));
strncpy( szBuf[1], READ_STRING(), sizeof(szBuf[1])); strncpy( szBuf[1], READ_STRING(), sizeof(szBuf[1]));
strncpy( szBuf[2], READ_STRING(), sizeof(szBuf[2])); strncpy( szBuf[2], READ_STRING(), sizeof(szBuf[2]));
const char *fmt = "\x02%s: %s"; const char *fmt = "\x02%s: %s";
int i = 0; int i = 0;
for( i; i < sizeof(sayTextFmt) / sizeof(CSimpleMap); i++ ) for( i; i < sizeof(sayTextFmt) / sizeof(CSimpleMap); i++ )
{ {
if( !strncmp( szBuf[0], sayTextFmt[i].key, sizeof( szBuf ) ) ) if( !strncmp( szBuf[0], sayTextFmt[i].key, sizeof( szBuf ) ) )
{ {
fmt = sayTextFmt[i].value; fmt = sayTextFmt[i].value;
break; break;
} }
} }
char dst[256]; char dst[256];
if( i == 8 ) if( i == 8 )
{ {
snprintf( dst, sizeof( dst ), fmt, szBuf[1], szBuf[2]); snprintf( dst, sizeof( dst ), fmt, szBuf[1], szBuf[2]);
} }
else else
{ {
GetPlayerInfo( client_index, &g_PlayerInfoList[client_index] ); GetPlayerInfo( client_index, &g_PlayerInfoList[client_index] );
const char *pName = g_PlayerInfoList[client_index].name; const char *pName = g_PlayerInfoList[client_index].name;
snprintf( dst, sizeof( dst ), fmt, pName, szBuf[2]); snprintf( dst, sizeof( dst ), fmt, pName, szBuf[2]);
} }
SayTextPrint( dst, strlen(dst), client_index ); SayTextPrint( dst, strlen(dst), client_index );
return 1; return 1;
} }
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex ) void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
{ {
/*if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE ) /*if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
{ {
// Print it straight to the console // Print it straight to the console
ConsolePrint( pszBuf ); ConsolePrint( pszBuf );
return; return;
}*/ }*/
// find an empty string slot // find an empty string slot
int i; int i;
for ( i = 0; i < MAX_LINES; i++ ) for ( i = 0; i < MAX_LINES; i++ )
{ {
if ( ! *g_szLineBuffer[i] ) if ( ! *g_szLineBuffer[i] )
break; break;
} }
if ( i == MAX_LINES ) if ( i == MAX_LINES )
{ {
// force scroll buffer up // force scroll buffer up
ScrollTextUp(); ScrollTextUp();
i = MAX_LINES - 1; i = MAX_LINES - 1;
} }
g_iNameLengths[i] = 0; g_iNameLengths[i] = 0;
g_pflNameColors[i] = NULL; g_pflNameColors[i] = NULL;
#if 1 #if 1
// if it's a say message, search for the players name in the string // if it's a say message, search for the players name in the string
if ( *pszBuf == 2 && clientIndex > 0 ) if ( *pszBuf == 2 && clientIndex > 0 )
{ {
GetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] ); GetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] );
const char *pName = g_PlayerInfoList[clientIndex].name; const char *pName = g_PlayerInfoList[clientIndex].name;
if ( pName ) if ( pName )
{ {
const char *nameInString = strstr( pszBuf, pName ); const char *nameInString = strstr( pszBuf, pName );
if ( nameInString ) if ( nameInString )
{ {
g_iNameLengths[i] = strlen( pName ) + (nameInString - pszBuf); g_iNameLengths[i] = strlen( pName ) + (nameInString - pszBuf);
g_pflNameColors[i] = GetClientColor( clientIndex ); g_pflNameColors[i] = GetClientColor( clientIndex );
} }
} }
} }
#endif #endif
strncpy( g_szLineBuffer[i], pszBuf, max(iBufSize -1, MAX_CHARS_PER_LINE-1) ); strncpy( g_szLineBuffer[i], pszBuf, max(iBufSize -1, MAX_CHARS_PER_LINE-1) );
// make sure the text fits in one line // make sure the text fits in one line
EnsureTextFitsInOneLineAndWrapIfHaveTo( i ); EnsureTextFitsInOneLineAndWrapIfHaveTo( i );
// Set scroll time // Set scroll time
if ( i == 0 ) if ( i == 0 )
{ {
flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value; flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value;
} }
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
PlaySound( "misc/talk.wav", 1 ); PlaySound( "misc/talk.wav", 1 );
if ( ScreenHeight >= 480 ) if ( ScreenHeight >= 480 )
Y_START = ScreenHeight - 60; Y_START = ScreenHeight - 60;
else else
Y_START = ScreenHeight - 45; Y_START = ScreenHeight - 45;
Y_START -= (line_height * (MAX_LINES+1)); Y_START -= (line_height * (MAX_LINES+1));
} }
void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ) void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
{ {
int line_width = 0; int line_width = 0;
DrawUtils::ConsoleStringSize(g_szLineBuffer[line], &line_width, &line_height ); DrawUtils::ConsoleStringSize(g_szLineBuffer[line], &line_width, &line_height );
if ( (line_width + LINE_START) > MAX_LINE_WIDTH ) if ( (line_width + LINE_START) > MAX_LINE_WIDTH )
{ // string is too long to fit on line { // 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 // 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 length = LINE_START;
int tmp_len = 0; int tmp_len = 0;
char *last_break = NULL; char *last_break = NULL;
for ( char *x = g_szLineBuffer[line]; *x != 0; x++ ) for ( char *x = g_szLineBuffer[line]; *x != 0; x++ )
{ {
// check for a color change, if so skip past it // check for a color change, if so skip past it
if ( x[0] == '/' && x[1] == '(' ) if ( x[0] == '/' && x[1] == '(' )
{ {
x += 2; x += 2;
// skip forward until past mode specifier // skip forward until past mode specifier
while ( *x != 0 && *x != ')' ) while ( *x != 0 && *x != ')' )
x++; x++;
if ( *x != 0 ) if ( *x != 0 )
x++; x++;
if ( *x == 0 ) if ( *x == 0 )
break; break;
} }
char buf[2]; char buf[2];
buf[1] = 0; buf[1] = 0;
if ( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character if ( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character
last_break = x; last_break = x;
buf[0] = *x; // get the length of the current character buf[0] = *x; // get the length of the current character
DrawUtils::ConsoleStringSize( buf, &tmp_len, &line_height ); DrawUtils::ConsoleStringSize( buf, &tmp_len, &line_height );
length += tmp_len; length += tmp_len;
if ( length > MAX_LINE_WIDTH ) if ( length > MAX_LINE_WIDTH )
{ // needs to be broken up { // needs to be broken up
if ( !last_break ) if ( !last_break )
last_break = x-1; last_break = x-1;
x = last_break; x = last_break;
// find an empty string slot // find an empty string slot
int j; int j;
do do
{ {
for ( j = 0; j < MAX_LINES; j++ ) for ( j = 0; j < MAX_LINES; j++ )
{ {
if ( ! *g_szLineBuffer[j] ) if ( ! *g_szLineBuffer[j] )
break; break;
} }
if ( j == MAX_LINES ) if ( j == MAX_LINES )
{ {
// need to make more room to display text, scroll stuff up then fix the pointers // need to make more room to display text, scroll stuff up then fix the pointers
int linesmoved = ScrollTextUp(); int linesmoved = ScrollTextUp();
line -= linesmoved; line -= linesmoved;
last_break = last_break - (sizeof(g_szLineBuffer[0]) * linesmoved); last_break = last_break - (sizeof(g_szLineBuffer[0]) * linesmoved);
} }
} }
while ( j == MAX_LINES ); while ( j == MAX_LINES );
// copy remaining string into next buffer, making sure it starts with a space character // copy remaining string into next buffer, making sure it starts with a space character
if ( (char)*last_break == (char)' ' ) if ( (char)*last_break == (char)' ' )
{ {
int linelen = strlen(g_szLineBuffer[j]); int linelen = strlen(g_szLineBuffer[j]);
int remaininglen = strlen(last_break); int remaininglen = strlen(last_break);
if ( (linelen - remaininglen) <= MAX_CHARS_PER_LINE ) if ( (linelen - remaininglen) <= MAX_CHARS_PER_LINE )
strcat( g_szLineBuffer[j], last_break ); strcat( g_szLineBuffer[j], last_break );
} }
else else
{ {
if ( (strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE ) if ( (strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE )
{ {
strcat( g_szLineBuffer[j], " " ); strcat( g_szLineBuffer[j], " " );
strcat( g_szLineBuffer[j], last_break ); strcat( g_szLineBuffer[j], last_break );
} }
} }
*last_break = 0; // cut off the last string *last_break = 0; // cut off the last string
EnsureTextFitsInOneLineAndWrapIfHaveTo( j ); EnsureTextFitsInOneLineAndWrapIfHaveTo( j );
break; break;
} }
} }
} }
} }

View File

@ -1,166 +1,166 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// status_icons.cpp // status_icons.cpp
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "entity_state.h" #include "entity_state.h"
#include "cl_entity.h" #include "cl_entity.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
#include "event_api.h" #include "event_api.h"
#include "com_weapons.h" #include "com_weapons.h"
DECLARE_MESSAGE( m_StatusIcons, StatusIcon ); DECLARE_MESSAGE( m_StatusIcons, StatusIcon );
int CHudStatusIcons::Init( void ) int CHudStatusIcons::Init( void )
{ {
HOOK_MESSAGE( StatusIcon ); HOOK_MESSAGE( StatusIcon );
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
Reset(); Reset();
return 1; return 1;
} }
int CHudStatusIcons::VidInit( void ) int CHudStatusIcons::VidInit( void )
{ {
return 1; return 1;
} }
void CHudStatusIcons::Reset( void ) void CHudStatusIcons::Reset( void )
{ {
memset( m_IconList, 0, sizeof m_IconList ); memset( m_IconList, 0, sizeof m_IconList );
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
} }
// Draw status icons along the left-hand side of the screen // Draw status icons along the left-hand side of the screen
int CHudStatusIcons::Draw( float flTime ) int CHudStatusIcons::Draw( float flTime )
{ {
if (gEngfuncs.IsSpectateOnly()) if (gEngfuncs.IsSpectateOnly())
return 1; return 1;
// find starting position to draw from, along right-hand side of screen // find starting position to draw from, along right-hand side of screen
int x = 5; int x = 5;
int y = ScreenHeight / 2; int y = ScreenHeight / 2;
// loop through icon list, and draw any valid icons drawing up from the middle of screen // loop through icon list, and draw any valid icons drawing up from the middle of screen
for ( int i = 0; i < MAX_ICONSPRITES; i++ ) for ( int i = 0; i < MAX_ICONSPRITES; i++ )
{ {
if ( m_IconList[i].spr ) if ( m_IconList[i].spr )
{ {
y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5; 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)) if( g_bInBombZone && !strcmp(m_IconList[i].szSpriteName, "c4") && ((int)(flTime * 10) % 2))
SPR_Set( m_IconList[i].spr, 255, 16, 16 ); 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 ); 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 ); SPR_DrawAdditive( 0, x, y, &m_IconList[i].rc );
} }
} }
return 1; return 1;
} }
// Message handler for StatusIcon message // Message handler for StatusIcon message
// accepts five values: // accepts five values:
// byte : TRUE = ENABLE icon, FALSE = DISABLE icon // byte : TRUE = ENABLE icon, FALSE = DISABLE icon
// string : the sprite name to display // string : the sprite name to display
// byte : red // byte : red
// byte : green // byte : green
// byte : blue // byte : blue
int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf ) int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int ShouldEnable = READ_BYTE(); int ShouldEnable = READ_BYTE();
char *pszIconName = READ_STRING(); char *pszIconName = READ_STRING();
if ( ShouldEnable ) if ( ShouldEnable )
{ {
int r = READ_BYTE(); int r = READ_BYTE();
int g = READ_BYTE(); int g = READ_BYTE();
int b = READ_BYTE(); int b = READ_BYTE();
EnableIcon( pszIconName, r, g, b ); EnableIcon( pszIconName, r, g, b );
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
} }
else else
{ {
DisableIcon( pszIconName ); DisableIcon( pszIconName );
} }
return 1; return 1;
} }
// add the icon to the icon list, and set it's drawing color // 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 ) 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 // check to see if the sprite is in the current list
int i; int i;
for ( i = 0; i < MAX_ICONSPRITES; i++ ) for ( i = 0; i < MAX_ICONSPRITES; i++ )
{ {
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) ) if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
break; break;
} }
if ( i == MAX_ICONSPRITES ) if ( i == MAX_ICONSPRITES )
{ {
// icon not in list, so find an empty slot to add to // icon not in list, so find an empty slot to add to
for ( i = 0; i < MAX_ICONSPRITES; i++ ) for ( i = 0; i < MAX_ICONSPRITES; i++ )
{ {
if ( !m_IconList[i].spr ) if ( !m_IconList[i].spr )
break; break;
} }
} }
// if we've run out of space in the list, overwrite the first icon // if we've run out of space in the list, overwrite the first icon
if ( i == MAX_ICONSPRITES ) if ( i == MAX_ICONSPRITES )
{ {
i = 0; i = 0;
} }
// Load the sprite and add it to the list // Load the sprite and add it to the list
// the sprite must be listed in hud.txt // the sprite must be listed in hud.txt
int spr_index = gHUD.GetSpriteIndex( pszIconName ); int spr_index = gHUD.GetSpriteIndex( pszIconName );
m_IconList[i].spr = gHUD.GetSprite( spr_index ); m_IconList[i].spr = gHUD.GetSprite( spr_index );
m_IconList[i].rc = gHUD.GetSpriteRect( spr_index ); m_IconList[i].rc = gHUD.GetSpriteRect( spr_index );
m_IconList[i].r = red; m_IconList[i].r = red;
m_IconList[i].g = green; m_IconList[i].g = green;
m_IconList[i].b = blue; m_IconList[i].b = blue;
strncpy( m_IconList[i].szSpriteName, pszIconName, MAX_ICONSPRITENAME_LENGTH ); strncpy( m_IconList[i].szSpriteName, pszIconName, MAX_ICONSPRITENAME_LENGTH );
// Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds) // Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds)
if ( strstr(m_IconList[i].szSpriteName, "grenade") ) if ( strstr(m_IconList[i].szSpriteName, "grenade") )
{ {
cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer(); 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 ); 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 ) void CHudStatusIcons::DisableIcon( char *pszIconName )
{ {
// find the sprite is in the current list // find the sprite is in the current list
for ( int i = 0; i < MAX_ICONSPRITES; i++ ) for ( int i = 0; i < MAX_ICONSPRITES; i++ )
{ {
if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) ) if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) )
{ {
// clear the item from the list // clear the item from the list
memset( &m_IconList[i], 0, sizeof( icon_sprite_t ) ); memset( &m_IconList[i], 0, sizeof( icon_sprite_t ) );
return; return;
} }
} }
} }

View File

@ -1,298 +1,298 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// statusbar.cpp // statusbar.cpp
// //
// generic text status bar, set by game dll // generic text status bar, set by game dll
// runs across bottom of screen // runs across bottom of screen
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "parsemsg.h" #include "parsemsg.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
DECLARE_MESSAGE( m_StatusBar, StatusText ); DECLARE_MESSAGE( m_StatusBar, StatusText );
DECLARE_MESSAGE( m_StatusBar, StatusValue ); DECLARE_MESSAGE( m_StatusBar, StatusValue );
extern float g_ColorYellow[3]; extern float g_ColorYellow[3];
#define STATUSBAR_ID_LINE 0 #define STATUSBAR_ID_LINE 0
inline void InsertTextMsg( char *szDst, size_t sLen, const char *szMsgName) inline void InsertTextMsg( char *szDst, size_t sLen, const char *szMsgName)
{ {
client_textmessage_t *msg = TextMessageGet(szMsgName); client_textmessage_t *msg = TextMessageGet(szMsgName);
if( msg ) if( msg )
{ {
strncpy( szDst, msg->pMessage, sLen ); strncpy( szDst, msg->pMessage, sLen );
} }
else strncpy( szDst, szMsgName, sLen ); else strncpy( szDst, szMsgName, sLen );
} }
int CHudStatusBar :: Init( void ) int CHudStatusBar :: Init( void )
{ {
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
HOOK_MESSAGE( StatusText ); HOOK_MESSAGE( StatusText );
HOOK_MESSAGE( StatusValue ); HOOK_MESSAGE( StatusValue );
Reset(); Reset();
hud_centerid = CVAR_CREATE( "hud_centerid", "0", FCVAR_ARCHIVE ); hud_centerid = CVAR_CREATE( "hud_centerid", "0", FCVAR_ARCHIVE );
return 1; return 1;
} }
int CHudStatusBar :: VidInit( void ) int CHudStatusBar :: VidInit( void )
{ {
// Load sprites here // Load sprites here
return 1; return 1;
} }
void CHudStatusBar :: Reset( void ) void CHudStatusBar :: Reset( void )
{ {
int i = 0; int i = 0;
m_iFlags &= ~HUD_ACTIVE; // start out inactive m_iFlags &= ~HUD_ACTIVE; // start out inactive
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ ) for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
m_szStatusText[i][0] = 0; m_szStatusText[i][0] = 0;
memset( m_iStatusValues, 0, sizeof m_iStatusValues ); memset( m_iStatusValues, 0, sizeof m_iStatusValues );
m_iStatusValues[0] = 1; // 0 is the special index, which always returns true m_iStatusValues[0] = 1; // 0 is the special index, which always returns true
// reset our colors for the status bar lines (yellow is default) // reset our colors for the status bar lines (yellow is default)
for ( i = 0; i < MAX_STATUSBAR_LINES; i++ ) for ( i = 0; i < MAX_STATUSBAR_LINES; i++ )
m_pflNameColors[i] = g_ColorYellow; m_pflNameColors[i] = g_ColorYellow;
} }
void CHudStatusBar :: ParseStatusString( int line_num ) void CHudStatusBar :: ParseStatusString( int line_num )
{ {
// localise string first // localise string first
char szBuffer[MAX_STATUSTEXT_LENGTH]; char szBuffer[MAX_STATUSTEXT_LENGTH];
memset( szBuffer, 0, sizeof szBuffer ); memset( szBuffer, 0, sizeof szBuffer );
gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH ); gHUD.m_TextMessage.LocaliseTextString( m_szStatusText[line_num], szBuffer, MAX_STATUSTEXT_LENGTH );
// parse m_szStatusText & m_iStatusValues into m_szStatusBar // parse m_szStatusText & m_iStatusValues into m_szStatusBar
memset( m_szStatusBar[line_num], 0, MAX_STATUSTEXT_LENGTH ); memset( m_szStatusBar[line_num], 0, MAX_STATUSTEXT_LENGTH );
char *src = szBuffer; char *src = szBuffer;
char *dst = m_szStatusBar[line_num]; char *dst = m_szStatusBar[line_num];
char *src_start = src, *dst_start = dst; char *src_start = src, *dst_start = dst;
while ( *src != 0 ) while ( *src != 0 )
{ {
while ( *src == '\n' ) while ( *src == '\n' )
src++; // skip over any newlines src++; // skip over any newlines
if ( ((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH) ) if ( ((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH) )
break; break;
int index = atoi( src ); int index = atoi( src );
// should we draw this line? // should we draw this line?
if ( (index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0) ) if ( (index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0) )
{ // parse this line and append result to the status bar { // parse this line and append result to the status bar
while ( *src >= '0' && *src <= '9' ) while ( *src >= '0' && *src <= '9' )
src++; src++;
if ( *src == '\n' || *src == 0 ) if ( *src == '\n' || *src == 0 )
continue; // no more left in this text line continue; // no more left in this text line
// copy the text, char by char, until we hit a % or a \n // copy the text, char by char, until we hit a % or a \n
while ( *src != '\n' && *src != 0 ) while ( *src != '\n' && *src != 0 )
{ {
if ( *src != '%' ) if ( *src != '%' )
{ // just copy the character { // just copy the character
*dst = *src; *dst = *src;
dst++, src++; dst++, src++;
} }
else else
{ {
// get the descriptor // get the descriptor
char valtype = *(++src); // move over % char valtype = *(++src); // move over %
// if it's a %, draw a % sign // if it's a %, draw a % sign
if ( valtype == '%' ) if ( valtype == '%' )
{ {
*dst = valtype; *dst = valtype;
dst++, src++; dst++, src++;
continue; continue;
} }
// move over descriptor, then get and move over the index // move over descriptor, then get and move over the index
index = atoi( ++src ); index = atoi( ++src );
while ( *src >= '0' && *src <= '9' ) while ( *src >= '0' && *src <= '9' )
src++; src++;
if ( index >= 0 && index < MAX_STATUSBAR_VALUES ) if ( index >= 0 && index < MAX_STATUSBAR_VALUES )
{ {
int indexval = m_iStatusValues[index]; int indexval = m_iStatusValues[index];
// get the string to substitute in place of the %XX // get the string to substitute in place of the %XX
char szRepString[MAX_PLAYER_NAME_LENGTH]; char szRepString[MAX_PLAYER_NAME_LENGTH];
switch ( valtype ) switch ( valtype )
{ {
case 'p': // player name case 'p': // player name
GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] ); GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] );
if ( g_PlayerInfoList[indexval].name != NULL ) if ( g_PlayerInfoList[indexval].name != NULL )
{ {
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH ); strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH );
m_pflNameColors[line_num] = GetClientColor( indexval ); m_pflNameColors[line_num] = GetClientColor( indexval );
} }
else else
{ {
strncpy( szRepString, "******", MAX_PLAYER_NAME_LENGTH ); strncpy( szRepString, "******", MAX_PLAYER_NAME_LENGTH );
} }
break; break;
case 'i': // number case 'i': // number
sprintf( szRepString, "%d", indexval ); sprintf( szRepString, "%d", indexval );
break; break;
case 'h': // health case 'h': // health
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Health"); InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Health");
break; break;
case 'c': case 'c':
if( indexval == 1 ) if( indexval == 1 )
{ {
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Friend"); InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Friend");
} }
else if( indexval == 2 ) else if( indexval == 2 )
{ {
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Enemy"); InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Enemy");
} }
else if( indexval == 3 ) else if( indexval == 3 )
{ {
InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Hostage"); InsertTextMsg(szRepString, MAX_PLAYER_NAME_LENGTH, "Hostage");
} }
else szRepString[0] = 0; else szRepString[0] = 0;
break; break;
default: default:
szRepString[0] = 0; szRepString[0] = 0;
} }
for ( char *cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++ ) for ( char *cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++ )
*dst = *cp; *dst = *cp;
} }
} }
} }
} }
else else
{ {
// skip to next line of text // skip to next line of text
while ( *src != 0 && *src != '\n' ) while ( *src != 0 && *src != '\n' )
src++; src++;
} }
} }
} }
int CHudStatusBar :: Draw( float fTime ) int CHudStatusBar :: Draw( float fTime )
{ {
if ( m_bReparseString ) if ( m_bReparseString )
{ {
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
{ {
m_pflNameColors[i] = g_ColorYellow; m_pflNameColors[i] = g_ColorYellow;
ParseStatusString( i ); ParseStatusString( i );
} }
m_bReparseString = FALSE; m_bReparseString = FALSE;
} }
if( g_iUser1 > 0 ) if( g_iUser1 > 0 )
{ {
// this is a spectator, so don't draw any statusbars // this is a spectator, so don't draw any statusbars
return 1; return 1;
} }
int Y_START = ScreenHeight - YRES(32 + 4); int Y_START = ScreenHeight - YRES(32 + 4);
// Draw the status bar lines // Draw the status bar lines
for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ )
{ {
int TextHeight, TextWidth; int TextHeight, TextWidth;
DrawUtils::ConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight ); DrawUtils::ConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight );
int x = 4; int x = 4;
int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen
// let user set status ID bar centering // let user set status ID bar centering
if ( i == STATUSBAR_ID_LINE && if ( i == STATUSBAR_ID_LINE &&
hud_centerid->value != 0.0f ) hud_centerid->value != 0.0f )
{ {
x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 ); x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 );
y = (ScreenHeight / 2) + (TextHeight * hud_centerid->value ); y = (ScreenHeight / 2) + (TextHeight * hud_centerid->value );
} }
if ( m_pflNameColors[i] ) if ( m_pflNameColors[i] )
DrawUtils::SetConsoleTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] ); DrawUtils::SetConsoleTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
DrawUtils::DrawConsoleString( x, y, m_szStatusBar[i] ); DrawUtils::DrawConsoleString( x, y, m_szStatusBar[i] );
} }
return 1; return 1;
} }
// Message handler for StatusText message // Message handler for StatusText message
// accepts two values: // accepts two values:
// byte: line number of status bar text // byte: line number of status bar text
// string: status bar text // string: status bar text
// this string describes how the status bar should be drawn // this string describes how the status bar should be drawn
// a semi-regular expression: // a semi-regular expression:
// ( slotnum ([a..z] [%pX] [%iX])*)* // ( slotnum ([a..z] [%pX] [%iX])*)*
// where slotnum is an index into the Value table (see below) // where slotnum is an index into the Value table (see below)
// if slotnum is 0, the string is always drawn // 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 // 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] // %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] // %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 ) int CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int line = READ_BYTE(); int line = READ_BYTE();
if ( line < 0 || line >= MAX_STATUSBAR_LINES ) if ( line < 0 || line >= MAX_STATUSBAR_LINES )
return 1; return 1;
strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH ); strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH );
m_szStatusText[line][MAX_STATUSTEXT_LENGTH-1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long) m_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 ) if ( m_szStatusText[0] == 0 )
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
else else
m_iFlags |= HUD_ACTIVE; // we have status text, so turn on the status bar m_iFlags |= HUD_ACTIVE; // we have status text, so turn on the status bar
m_bReparseString = TRUE; m_bReparseString = TRUE;
return 1; return 1;
} }
// Message handler for StatusText message // Message handler for StatusText message
// accepts two values: // accepts two values:
// byte: index into the status value array // byte: index into the status value array
// short: value to store // short: value to store
int CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf ) int CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int index = READ_BYTE(); int index = READ_BYTE();
if ( index < 1 || index >= MAX_STATUSBAR_VALUES ) if ( index < 1 || index >= MAX_STATUSBAR_VALUES )
return 1; // index out of range return 1; // index out of range
m_iStatusValues[index] = READ_SHORT(); m_iStatusValues[index] = READ_SHORT();
m_bReparseString = TRUE; m_bReparseString = TRUE;
return 1; return 1;
} }

View File

@ -1,249 +1,249 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// text_message.cpp // text_message.cpp
// //
// implementation of CHudTextMessage class // implementation of CHudTextMessage class
// //
// this class routes messages through titles.txt for localisation // this class routes messages through titles.txt for localisation
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
#include "vgui_parser.h" #include "vgui_parser.h"
#include "ctype.h" #include "ctype.h"
DECLARE_MESSAGE( m_TextMessage, TextMsg ); DECLARE_MESSAGE( m_TextMessage, TextMsg );
int CHudTextMessage::Init(void) int CHudTextMessage::Init(void)
{ {
HOOK_MESSAGE( TextMsg ); HOOK_MESSAGE( TextMsg );
gHUD.AddHudElem( this ); gHUD.AddHudElem( this );
Reset(); Reset();
return 1; return 1;
}; };
// Searches through the string for any msg names (indicated by a '#') // Searches through the string for any msg names (indicated by a '#')
// any found are looked up in titles.txt and the new message substituted // any found are looked up in titles.txt and the new message substituted
// the new value is pushed into dst_buffer // the new value is pushed into dst_buffer
char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size )
{ {
char *dst = dst_buffer; char *dst = dst_buffer;
for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- )
{ {
if ( *src == '#' ) if ( *src == '#' )
{ {
// cut msg name out of string // cut msg name out of string
static char word_buf[255]; static char word_buf[255];
char *wdst = word_buf, *word_start = src; char *wdst = word_buf, *word_start = src;
for ( ++src ; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++ ) for ( ++src ; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++ )
{ {
*wdst = *src; *wdst = *src;
} }
*wdst = 0; *wdst = 0;
// lookup msg name in titles.txt // lookup msg name in titles.txt
client_textmessage_t *clmsg = TextMessageGet( word_buf ); client_textmessage_t *clmsg = TextMessageGet( word_buf );
if ( !clmsg || !(clmsg->pMessage) ) if ( !clmsg || !(clmsg->pMessage) )
{ {
src = word_start; src = word_start;
*dst = *src; *dst = *src;
dst++, src++; dst++, src++;
continue; continue;
} }
if(clmsg->pMessage[0] == '#') strncpy(dst, Localize(clmsg->pMessage+1), sizeof( dst )); if(clmsg->pMessage[0] == '#') strncpy(dst, Localize(clmsg->pMessage+1), sizeof( dst ));
// copy string into message over the msg name // copy string into message over the msg name
for ( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ ) for ( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ )
{ {
*dst = *wsrc; *dst = *wsrc;
} }
*dst = 0; *dst = 0;
} }
else else
{ {
*dst = *src; *dst = *src;
dst++, src++; dst++, src++;
*dst = 0; *dst = 0;
} }
} }
dst_buffer[buffer_size-1] = 0; // ensure null termination dst_buffer[buffer_size-1] = 0; // ensure null termination
return dst_buffer; return dst_buffer;
} }
// As above, but with a local static buffer // As above, but with a local static buffer
char *CHudTextMessage::BufferedLocaliseTextString( const char *msg ) char *CHudTextMessage::BufferedLocaliseTextString( const char *msg )
{ {
static char dst_buffer[1024]; static char dst_buffer[1024];
LocaliseTextString( msg, dst_buffer, 1024 ); LocaliseTextString( msg, dst_buffer, 1024 );
return dst_buffer; return dst_buffer;
} }
// Simplified version of LocaliseTextString; assumes string is only one word // Simplified version of LocaliseTextString; assumes string is only one word
char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) char *CHudTextMessage::LookupString( const char *msg, int *msg_dest )
{ {
if ( !msg ) if ( !msg )
return ""; return "";
// '#' character indicates this is a reference to a string in titles.txt, and not the string itself // '#' character indicates this is a reference to a string in titles.txt, and not the string itself
if ( msg[0] == '#' ) if ( msg[0] == '#' )
{ {
// this is a message name, so look up the real message // this is a message name, so look up the real message
client_textmessage_t *clmsg = TextMessageGet( msg+1 ); client_textmessage_t *clmsg = TextMessageGet( msg+1 );
if ( !clmsg || !(clmsg->pMessage) ) if ( !clmsg || !(clmsg->pMessage) )
return (char*)msg; // lookup failed, so return the original string return (char*)msg; // lookup failed, so return the original string
if ( msg_dest ) if ( msg_dest )
{ {
// check to see if titles.txt info overrides msg destination // 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 is less than 0, then clmsg->effect holds -1 * message_destination
if ( clmsg->effect < 0 ) // if ( clmsg->effect < 0 ) //
*msg_dest = -clmsg->effect; *msg_dest = -clmsg->effect;
} }
if( clmsg->pMessage[0] == '#') if( clmsg->pMessage[0] == '#')
return (char *)Localize( clmsg->pMessage + 1); return (char *)Localize( clmsg->pMessage + 1);
return (char*)clmsg->pMessage; return (char*)clmsg->pMessage;
} }
else else
{ // nothing special about this message, so just return the same string { // nothing special about this message, so just return the same string
return (char*)msg; return (char*)msg;
} }
} }
void StripEndNewlineFromString( char *str ) void StripEndNewlineFromString( char *str )
{ {
int s = strlen( str ) - 1; int s = strlen( str ) - 1;
if ( str[s] == '\n' || str[s] == '\r' ) if ( str[s] == '\n' || str[s] == '\r' )
str[s] = 0; str[s] = 0;
} }
// converts all '\r' characters to '\n', so that the engine can deal with the properly // converts all '\r' characters to '\n', so that the engine can deal with the properly
// returns a pointer to str // returns a pointer to str
char* ConvertCRtoNL( char *str ) char* ConvertCRtoNL( char *str )
{ {
for ( char *ch = str; *ch != 0; ch++ ) for ( char *ch = str; *ch != 0; ch++ )
if ( *ch == '\r' ) if ( *ch == '\r' )
*ch = '\n'; *ch = '\n';
return str; return str;
} }
// Message handler for text messages // Message handler for text messages
// displays a string, looking them up from the titles.txt file, which can be localised // displays a string, looking them up from the titles.txt file, which can be localised
// parameters: // parameters:
// byte: message direction ( HUD_PRINTCONSOLE, HUD_PRINTNOTIFY, HUD_PRINTCENTER, HUD_PRINTTALK ) // byte: message direction ( HUD_PRINTCONSOLE, HUD_PRINTNOTIFY, HUD_PRINTCENTER, HUD_PRINTTALK )
// string: message // string: message
// optional parameters: // optional parameters:
// string: message parameter 1 // string: message parameter 1
// string: message parameter 2 // string: message parameter 2
// string: message parameter 3 // string: message parameter 3
// string: message parameter 4 // 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 // 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 '#') // 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 #define MAX_TEXTMSG_STRING 256
int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf ) int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
int msg_dest = READ_BYTE(); int msg_dest = READ_BYTE();
static char szBuf[6][MAX_TEXTMSG_STRING]; static char szBuf[6][MAX_TEXTMSG_STRING];
char *msg_text = LookupString( READ_STRING(), &msg_dest ); char *msg_text = LookupString( READ_STRING(), &msg_dest );
msg_text = strncpy( szBuf[0], msg_text, MAX_TEXTMSG_STRING ); 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 // keep reading strings and using C format strings for subsituting the strings into the localised text string
char *sstr1 = LookupString( READ_STRING() ); char *sstr1 = LookupString( READ_STRING() );
sstr1 = strncpy( szBuf[1], sstr1, MAX_TEXTMSG_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 StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
char *sstr2 = LookupString( READ_STRING() ); char *sstr2 = LookupString( READ_STRING() );
sstr2 = strncpy( szBuf[2], sstr2, MAX_TEXTMSG_STRING ); sstr2 = strncpy( szBuf[2], sstr2, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr2 ); StripEndNewlineFromString( sstr2 );
char *sstr3 = LookupString( READ_STRING() ); char *sstr3 = LookupString( READ_STRING() );
sstr3 = strncpy( szBuf[3], sstr3, MAX_TEXTMSG_STRING ); sstr3 = strncpy( szBuf[3], sstr3, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr3 ); StripEndNewlineFromString( sstr3 );
char *sstr4 = LookupString( READ_STRING() ); char *sstr4 = LookupString( READ_STRING() );
sstr4 = strncpy( szBuf[4], sstr4, MAX_TEXTMSG_STRING ); sstr4 = strncpy( szBuf[4], sstr4, MAX_TEXTMSG_STRING );
StripEndNewlineFromString( sstr4 ); StripEndNewlineFromString( sstr4 );
char *psz = szBuf[5]; char *psz = szBuf[5];
// Remove numbers after %s. // Remove numbers after %s.
// VALVEWHY? // VALVEWHY?
if( strlen(msg_text) >= 3 ) if( strlen(msg_text) >= 3 )
{ {
for( int i = 0; i < strlen(msg_text) - 2; i++) for( int i = 0; i < strlen(msg_text) - 2; i++)
{ {
if( msg_text[i] == '%' && msg_text[i + 1] == 's' && isdigit(msg_text[i + 2])) if( msg_text[i] == '%' && msg_text[i + 1] == 's' && isdigit(msg_text[i + 2]))
{ {
char *first = &msg_text[i + 2]; char *first = &msg_text[i + 2];
char *second = &msg_text[i + 3]; char *second = &msg_text[i + 3];
memmove( first, second, strlen( second )); memmove( first, second, strlen( second ));
first[strlen(first)] = '\0'; first[strlen(first)] = '\0';
} }
} }
} }
switch ( msg_dest ) switch ( msg_dest )
{ {
case HUD_PRINTCENTER: case HUD_PRINTCENTER:
snprintf( psz, MAX_TEXTMSG_STRING, msg_text, sstr1, sstr2, sstr3, sstr4 ); snprintf( psz, MAX_TEXTMSG_STRING, msg_text, sstr1, sstr2, sstr3, sstr4 );
CenterPrint( ConvertCRtoNL( psz ) ); CenterPrint( ConvertCRtoNL( psz ) );
break; break;
case HUD_PRINTNOTIFY: case HUD_PRINTNOTIFY:
psz[0] = 1; // mark this message to go into the notify buffer 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 ); snprintf( psz+1, MAX_TEXTMSG_STRING - 1, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) ); ConsolePrint( ConvertCRtoNL( psz ) );
break; break;
case HUD_PRINTTALK: case HUD_PRINTTALK:
psz[0] = 2; // mark, so SayTextPrint will color it psz[0] = 2; // mark, so SayTextPrint will color it
snprintf( psz+1, MAX_TEXTMSG_STRING-1, msg_text, sstr1, sstr2, sstr3, sstr4 ); snprintf( psz+1, MAX_TEXTMSG_STRING-1, msg_text, sstr1, sstr2, sstr3, sstr4 );
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 ); gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
break; break;
case HUD_PRINTCONSOLE: case HUD_PRINTCONSOLE:
snprintf( psz, MAX_TEXTMSG_STRING, msg_text, sstr1, sstr2, sstr3, sstr4 ); snprintf( psz, MAX_TEXTMSG_STRING, msg_text, sstr1, sstr2, sstr3, sstr4 );
ConsolePrint( ConvertCRtoNL( psz ) ); ConsolePrint( ConvertCRtoNL( psz ) );
break; break;
case HUD_PRINTRADIO: case HUD_PRINTRADIO:
// For some reason, HUD_PRINTRADIO always have "1" in msg_text // For some reason, HUD_PRINTRADIO always have "1" in msg_text
for( int i = 1; i < MAX_PLAYERS; i++ ) for( int i = 1; i < MAX_PLAYERS; i++ )
{ {
if( g_PlayerInfoList[i].name && !strcmp(g_PlayerInfoList[i].name, sstr2) ) if( g_PlayerInfoList[i].name && !strcmp(g_PlayerInfoList[i].name, sstr2) )
{ {
psz[0] = 2; psz[0] = 2;
snprintf( psz + 1, MAX_TEXTMSG_STRING-1, sstr1, sstr2, sstr3, sstr4 ); snprintf( psz + 1, MAX_TEXTMSG_STRING-1, sstr1, sstr2, sstr3, sstr4 );
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128, i ); gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128, i );
break; break;
} }
} }
break; break;
} }
return 1; return 1;
} }

View File

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

View File

@ -1,85 +1,85 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// Train.cpp // Train.cpp
// //
// implementation of CHudAmmo class // implementation of CHudAmmo class
// //
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "parsemsg.h" #include "parsemsg.h"
DECLARE_MESSAGE(m_Train, Train ) DECLARE_MESSAGE(m_Train, Train )
int CHudTrain::Init(void) int CHudTrain::Init(void)
{ {
HOOK_MESSAGE( Train ); HOOK_MESSAGE( Train );
m_iPos = 0; m_iPos = 0;
m_iFlags = 0; m_iFlags = 0;
gHUD.AddHudElem(this); gHUD.AddHudElem(this);
return 1; return 1;
}; };
int CHudTrain::VidInit(void) int CHudTrain::VidInit(void)
{ {
m_hSprite = 0; m_hSprite = 0;
return 1; return 1;
}; };
int CHudTrain::Draw(float fTime) int CHudTrain::Draw(float fTime)
{ {
if ( !m_hSprite ) if ( !m_hSprite )
m_hSprite = LoadSprite("sprites/%d_train.spr"); m_hSprite = LoadSprite("sprites/%d_train.spr");
if (m_iPos) if (m_iPos)
{ {
int r, g, b, x, y; int r, g, b, x, y;
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH); DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
SPR_Set(m_hSprite, r, g, b ); SPR_Set(m_hSprite, r, g, b );
// This should show up to the right and part way up the armor number // This should show up to the right and part way up the armor number
y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight; y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight;
x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4; x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4;
SPR_DrawAdditive( m_iPos - 1, x, y, NULL); SPR_DrawAdditive( m_iPos - 1, x, y, NULL);
} }
return 1; return 1;
} }
int CHudTrain::MsgFunc_Train(const char *pszName, int iSize, void *pbuf) int CHudTrain::MsgFunc_Train(const char *pszName, int iSize, void *pbuf)
{ {
BEGIN_READ( pbuf, iSize ); BEGIN_READ( pbuf, iSize );
// update Train data // update Train data
m_iPos = READ_BYTE(); m_iPos = READ_BYTE();
if (m_iPos) if (m_iPos)
m_iFlags |= HUD_ACTIVE; m_iFlags |= HUD_ACTIVE;
else else
m_iFlags &= ~HUD_ACTIVE; m_iFlags &= ~HUD_ACTIVE;
return 1; 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. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
// Camera.h -- defines and such for a 3rd person camera // Camera.h -- defines and such for a 3rd person camera
// NOTE: must include quakedef.h first // NOTE: must include quakedef.h first
#pragma once #pragma once
#ifndef _CAMERA_H_ #ifndef _CAMERA_H_
#define _CAMEA_H_ #define _CAMEA_H_
// pitch, yaw, dist // pitch, yaw, dist
extern vec3_t cam_ofs; extern vec3_t cam_ofs;
// Using third person camera // Using third person camera
extern int cam_thirdperson; extern int cam_thirdperson;
void CAM_Init( void ); void CAM_Init( void );
void CAM_ClearStates( void ); void CAM_ClearStates( void );
void CAM_StartMouseMove(void); void CAM_StartMouseMove(void);
void CAM_EndMouseMove(void); void CAM_EndMouseMove(void);
#endif // _CAMERA_H_ #endif // _CAMERA_H_

View File

@ -1,50 +1,50 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// cl_dll.h // cl_dll.h
// //
// 4-23-98 JOHN // 4-23-98 JOHN
#pragma once #pragma once
// //
// This DLL is linked by the client when they first initialize. // This DLL is linked by the client when they first initialize.
// This DLL is responsible for the following tasks: // This DLL is responsible for the following tasks:
// - Loading the HUD graphics upon initialization // - Loading the HUD graphics upon initialization
// - Drawing the HUD graphics every frame // - Drawing the HUD graphics every frame
// - Handling the custum HUD-update packets // - Handling the custum HUD-update packets
// //
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned short word; typedef unsigned short word;
typedef float vec_t; typedef float vec_t;
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
#define _cdecl #define _cdecl
#include "util_vector.h" #include "util_vector.h"
#ifdef _WIN32 #ifdef _WIN32
#define EXPORT _declspec( dllexport ) #define EXPORT _declspec( dllexport )
#else #else
#define EXPORT #define EXPORT
#define stricmp strcasecmp #define stricmp strcasecmp
#define strnicmp strncasecmp #define strnicmp strncasecmp
#define stristr strcasestr #define stristr strcasestr
#define strnistr strncasestr #define strnistr strncasestr
#endif #endif
#include "../engine/cdll_int.h" #include "../engine/cdll_int.h"
#include "../dlls/cdll_dll.h" #include "../dlls/cdll_dll.h"
#include "render_api.h" #include "render_api.h"
#include "mobility_int.h" #include "mobility_int.h"
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;
extern render_api_t gRenderAPI; extern render_api_t gRenderAPI;
extern mobile_engfuncs_t gMobileAPI; extern mobile_engfuncs_t gMobileAPI;
extern int g_iXash; extern int g_iXash;

View File

@ -1,141 +1,141 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// cl_util.h // cl_util.h
// //
#pragma once #pragma once
#include "cvardef.h" #include "cvardef.h"
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
#endif #endif
extern cvar_t *hud_textmode; extern cvar_t *hud_textmode;
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable : 4244) // 'argument': conversion from 'float' to 'int', possible loss of data #pragma warning(disable : 4244) // 'argument': conversion from 'float' to 'int', possible loss of data
#pragma warning(disable : 4101) // unreferenced local variable #pragma warning(disable : 4101) // unreferenced local variable
#endif #endif
// Macros to hook function calls into the HUD object // Macros to hook function calls into the HUD object
#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x ); #define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x );
#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \ #define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \
{ \ { \
return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \ return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \
} }
#define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y ); #define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y );
#define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \ #define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \
{ \ { \
gHUD.y.UserCmd_##x( ); \ gHUD.y.UserCmd_##x( ); \
} }
inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)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 char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); }
inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); } inline 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_Load (*gEngfuncs.pfnSPR_Load)
#define SPR_Set (*gEngfuncs.pfnSPR_Set) #define SPR_Set (*gEngfuncs.pfnSPR_Set)
#define SPR_Frames (*gEngfuncs.pfnSPR_Frames) #define SPR_Frames (*gEngfuncs.pfnSPR_Frames)
#define SPR_GetList (*gEngfuncs.pfnSPR_GetList) #define SPR_GetList (*gEngfuncs.pfnSPR_GetList)
// SPR_Draw draws a the current sprite as solid // SPR_Draw draws a the current sprite as solid
#define SPR_Draw (*gEngfuncs.pfnSPR_Draw) #define SPR_Draw (*gEngfuncs.pfnSPR_Draw)
// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent) // SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent)
#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles) #define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles)
// SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency) // SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency)
#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive) #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. // 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) #define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor)
// SPR_DisableScissor disables the clipping rect // SPR_DisableScissor disables the clipping rect
#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor) #define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor)
// //
#define FillRGBA (*gEngfuncs.pfnFillRGBA) #define FillRGBA (*gEngfuncs.pfnFillRGBA)
#define FillRGBABlend (*gEngfuncs.pfnFillRGBABlend) #define FillRGBABlend (*gEngfuncs.pfnFillRGBABlend)
// ScreenHeight returns the height of the screen, in pixels // ScreenHeight returns the height of the screen, in pixels
#define ScreenHeight (gHUD.m_scrinfo.iHeight) #define ScreenHeight (gHUD.m_scrinfo.iHeight)
// ScreenWidth returns the width of the screen, in pixels // ScreenWidth returns the width of the screen, in pixels
#define ScreenWidth (gHUD.m_scrinfo.iWidth) #define ScreenWidth (gHUD.m_scrinfo.iWidth)
#define TrueHeight (gHUD.m_truescrinfo.iHeight) #define TrueHeight (gHUD.m_truescrinfo.iHeight)
#define TrueWidth (gHUD.m_truescrinfo.iWidth) #define TrueWidth (gHUD.m_truescrinfo.iWidth)
// Use this to set any co-ords in 640x480 space // Use this to set any co-ords in 640x480 space
#define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f)) #define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f))
#define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f)) #define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f))
// use this to project world coordinates to screen coordinates // use this to project world coordinates to screen coordinates
#define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f ) #define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f )
#define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f ) #define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f )
#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo) #define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo)
#define ServerCmd (*gEngfuncs.pfnServerCmd) #define ServerCmd (*gEngfuncs.pfnServerCmd)
#define ClientCmd (*gEngfuncs.pfnClientCmd) #define ClientCmd (*gEngfuncs.pfnClientCmd)
#define SetCrosshair (*gEngfuncs.pfnSetCrosshair) #define SetCrosshair (*gEngfuncs.pfnSetCrosshair)
#define AngleVectors (*gEngfuncs.pfnAngleVectors) #define AngleVectors (*gEngfuncs.pfnAngleVectors)
extern float color[3]; // hud.cpp extern float color[3]; // hud.cpp
// Gets the height & width of a sprite, at the specified frame // 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_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); }
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); } inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }
inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); } inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); }
inline void ConsolePrint( const char *string ) inline void ConsolePrint( const char *string )
{ {
gEngfuncs.pfnConsolePrint( string ); gEngfuncs.pfnConsolePrint( string );
} }
inline void CenterPrint( const char *string ) inline void CenterPrint( const char *string )
{ {
gEngfuncs.pfnCenterPrint( string ); gEngfuncs.pfnCenterPrint( string );
} }
// returns the players name of entity no. // returns the players name of entity no.
#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo) #define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo)
// sound functions // sound functions
inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); } inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
#define max(a, b) (((a) > (b)) ? (a) : (b)) #define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b))
#define fabs(x) ((x) > 0 ? (x) : 0 - (x)) #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 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 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 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 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;} inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;}
float Length(const float *v); float Length(const float *v);
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc); void VectorMA (const float *veca, float scale, const float *vecb, float *vecc);
void VectorScale (const float *in, float scale, float *out); void VectorScale (const float *in, float scale, float *out);
float VectorNormalize (float *v); float VectorNormalize (float *v);
void VectorInverse ( float *v ); void VectorInverse ( float *v );
extern vec3_t vec3_origin; extern vec3_t vec3_origin;
// disable 'possible loss of data converting float to int' warning message // disable 'possible loss of data converting float to int' warning message
#pragma warning( disable: 4244 ) #pragma warning( disable: 4244 )
// disable 'truncation from 'const double' to 'float' warning message // disable 'truncation from 'const double' to 'float' warning message
#pragma warning( disable: 4305 ) #pragma warning( disable: 4305 )
HSPRITE LoadSprite(const char *pszName); HSPRITE LoadSprite(const char *pszName);
float *GetClientColor( int clientIndex ); float *GetClientColor( int clientIndex );
void GetTeamColor( int &r, int &g, int &b, int teamIndex ); void GetTeamColor( int &r, int &g, int &b, int teamIndex );
#define bound( min, num, max ) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min)) #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. ============ //========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#pragma once #pragma once
// com_weapons.h // com_weapons.h
// Shared weapons common function prototypes // Shared weapons common function prototypes
#if !defined( COM_WEAPONSH ) #if !defined( COM_WEAPONSH )
#define COM_WEAPONSH #define COM_WEAPONSH
#include "hud_iface.h" #include "hud_iface.h"
#define PLAYER_CAN_SHOOT (1 << 0) #define PLAYER_CAN_SHOOT (1 << 0)
#define PLAYER_FREEZE_TIME_OVER ( 1 << 1 ) #define PLAYER_FREEZE_TIME_OVER ( 1 << 1 )
#define PLAYER_IN_BOMB_ZONE (1 << 2) #define PLAYER_IN_BOMB_ZONE (1 << 2)
#define PLAYER_HOLDING_SHIELD (1 << 3) #define PLAYER_HOLDING_SHIELD (1 << 3)
#define CROSSHAIR_ #define CROSSHAIR_
#define ACCURACY_AIR (1 << 0) // accuracy depends on FL_ONGROUND #define ACCURACY_AIR (1 << 0) // accuracy depends on FL_ONGROUND
#define ACCURACY_SPEED (1 << 1) #define ACCURACY_SPEED (1 << 1)
#define ACCURACY_DUCK (1 << 2) // more accurate when ducking #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 (1 << 3) // accuracy multiply to 1.4
#define ACCURACY_MULTIPLY_BY_14_2 (1 << 4) // accuracy multiply to 1.4 #define ACCURACY_MULTIPLY_BY_14_2 (1 << 4) // accuracy multiply to 1.4
#ifndef WPNSTATE_USP_SILENCED #ifndef WPNSTATE_USP_SILENCED
#define WPNSTATE_USP_SILENCED (1<<0) #define WPNSTATE_USP_SILENCED (1<<0)
#define WPNSTATE_GLOCK18_BURST_MODE (1<<1) #define WPNSTATE_GLOCK18_BURST_MODE (1<<1)
#define WPNSTATE_M4A1_SILENCED (1<<2) #define WPNSTATE_M4A1_SILENCED (1<<2)
#define WPNSTATE_ELITE_LEFT (1<<3) #define WPNSTATE_ELITE_LEFT (1<<3)
#define WPNSTATE_FAMAS_BURST_MODE (1<<4) #define WPNSTATE_FAMAS_BURST_MODE (1<<4)
#define WPNSTATE_SHIELD_DRAWN (1<<5) #define WPNSTATE_SHIELD_DRAWN (1<<5)
#endif #endif
extern "C" 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 _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, ...); void COM_Log( char *pszFile, char *fmt, ...);
int CL_IsDead( void ); int CL_IsDead( void );
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
int HUD_GetWeaponAnim( void ); int HUD_GetWeaponAnim( void );
void HUD_SendWeaponAnim(int iAnim, int iWeaponId, int iBody, int iForce ); void HUD_SendWeaponAnim(int iAnim, int iWeaponId, int iBody, int iForce );
int HUD_GetWeapon( void ); int HUD_GetWeapon( void );
void HUD_PlaySound( char *sound, float volume ); 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_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 ); void HUD_SetMaxSpeed( const struct edict_s *ed, float speed );
int stub_PrecacheModel( char* s ); int stub_PrecacheModel( char* s );
int stub_PrecacheSound( char* s ); int stub_PrecacheSound( char* s );
unsigned short stub_PrecacheEvent( int type, const char *s ); unsigned short stub_PrecacheEvent( int type, const char *s );
const char *stub_NameForFunction ( unsigned int function ); const char *stub_NameForFunction ( unsigned int function );
void stub_SetModel ( struct edict_s *e, const char *m ); void stub_SetModel ( struct edict_s *e, const char *m );
int GetWeaponAccuracyFlags( int weaponid ); int GetWeaponAccuracyFlags( int weaponid );
extern cvar_t *cl_lw; extern cvar_t *cl_lw;
extern int g_runfuncs; extern int g_runfuncs;
extern vec3_t v_angles; extern vec3_t v_angles;
extern float g_lastFOV; extern float g_lastFOV;
extern int g_iWeaponFlags; extern int g_iWeaponFlags;
extern bool g_bInBombZone; extern bool g_bInBombZone;
extern int g_iFreezeTimeOver; extern int g_iFreezeTimeOver;
extern bool g_bHoldingShield; extern bool g_bHoldingShield;
extern bool g_bHoldingKnife; extern bool g_bHoldingKnife;
extern int g_iPlayerFlags; extern int g_iPlayerFlags;
extern vec3_t g_vPlayerVelocity; extern vec3_t g_vPlayerVelocity;
extern float g_flPlayerSpeed; extern float g_flPlayerSpeed;
extern struct local_state_s *g_curstate; extern struct local_state_s *g_curstate;
extern struct local_state_s *g_finalstate; extern struct local_state_s *g_finalstate;
extern int g_iShotsFired; extern int g_iShotsFired;
#endif #endif

View File

@ -1,26 +1,26 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#pragma once #pragma once
#if !defined( DEMOH ) #if !defined( DEMOH )
#define DEMOH #define DEMOH
// Types of demo messages we can write/parse // Types of demo messages we can write/parse
enum enum
{ {
TYPE_SNIPERDOT = 0, TYPE_SNIPERDOT = 0,
TYPE_ZOOM TYPE_ZOOM
}; };
void Demo_WriteBuffer( int type, int size, unsigned char *buffer ); void Demo_WriteBuffer( int type, int size, unsigned char *buffer );
extern int g_demosniper; extern int g_demosniper;
extern int g_demosniperdamage; extern int g_demosniperdamage;
extern float g_demosniperorg[3]; extern float g_demosniperorg[3];
extern float g_demosniperangles[3]; extern float g_demosniperangles[3];
extern float g_demozoom; extern float g_demozoom;
#endif #endif

View File

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

View File

@ -1,75 +1,75 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#pragma once #pragma once
// eventscripts.h // eventscripts.h
#if !defined ( EVENTSCRIPTSH ) #if !defined ( EVENTSCRIPTSH )
#define EVENTSCRIPTSH #define EVENTSCRIPTSH
// defaults for clientinfo messages // defaults for clientinfo messages
#define DEFAULT_VIEWHEIGHT 28 #define DEFAULT_VIEWHEIGHT 28
#define VEC_DUCK_VIEW 12 #define VEC_DUCK_VIEW 12
#define FTENT_FADEOUT 0x00000080 #define FTENT_FADEOUT 0x00000080
#define DMG_GENERIC 0 // generic damage was done #define DMG_GENERIC 0 // generic damage was done
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object #define DMG_CRUSH (1 << 0) // crushed by falling or moving object
#define DMG_BULLET (1 << 1) // shot #define DMG_BULLET (1 << 1) // shot
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed #define DMG_SLASH (1 << 2) // cut, clawed, stabbed
#define DMG_BURN (1 << 3) // heat burned #define DMG_BURN (1 << 3) // heat burned
#define DMG_FREEZE (1 << 4) // frozen #define DMG_FREEZE (1 << 4) // frozen
#define DMG_FALL (1 << 5) // fell too far #define DMG_FALL (1 << 5) // fell too far
#define DMG_BLAST (1 << 6) // explosive blast damage #define DMG_BLAST (1 << 6) // explosive blast damage
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt #define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
#define DMG_SHOCK (1 << 8) // electric shock #define DMG_SHOCK (1 << 8) // electric shock
#define DMG_SONIC (1 << 9) // sound pulse shockwave #define DMG_SONIC (1 << 9) // sound pulse shockwave
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam #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_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. #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 // time-based damage
//mask off TF-specific stuff too //mask off TF-specific stuff too
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage #define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
#define DMG_DROWN (1 << 14) // Drowning #define DMG_DROWN (1 << 14) // Drowning
#define DMG_FIRSTTIMEBASED DMG_DROWN #define DMG_FIRSTTIMEBASED DMG_DROWN
#define DMG_PARALYZE (1 << 15) // slows affected creature down #define DMG_PARALYZE (1 << 15) // slows affected creature down
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad #define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
#define DMG_POISON (1 << 17) // blood poisioning #define DMG_POISON (1 << 17) // blood poisioning
#define DMG_RADIATION (1 << 18) // radiation exposure #define DMG_RADIATION (1 << 18) // radiation exposure
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery #define DMG_DROWNRECOVER (1 << 19) // drowning recovery
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns #define DMG_ACID (1 << 20) // toxic chemicals or acid burns
#define DMG_SLOWBURN (1 << 21) // in an oven #define DMG_SLOWBURN (1 << 21) // in an oven
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer #define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar) #define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
//TF ADDITIONS //TF ADDITIONS
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn #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_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_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_IGNOREARMOR (1 << 27) // Damage ignores target's armor
#define DMG_AIMED (1 << 28) // Does Hit location damage #define DMG_AIMED (1 << 28) // Does Hit location damage
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls #define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
#define DMG_CALTROP (1<<30) #define DMG_CALTROP (1<<30)
#define DMG_HALLUC (1<<31) #define DMG_HALLUC (1<<31)
// Some of these are HL/TFC specific? // 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_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_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 ); 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_IsLocal( int idx );
qboolean EV_IsPlayer( int idx ); qboolean EV_IsPlayer( int idx );
void EV_CreateTracer( float *start, float *end ); void EV_CreateTracer( float *start, float *end );
void CreateCorpse(Vector *p_vOrigin, Vector *p_vAngles, const char *pModel, float flAnimTime, int iSequence, int iBody); 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 *GetEntity( int idx );
struct cl_entity_s *GetViewEntity( void ); struct cl_entity_s *GetViewEntity( void );
void EV_MuzzleFlash( void ); void EV_MuzzleFlash( void );
#endif // EVENTSCRIPTSH #endif // EVENTSCRIPTSH

View File

@ -1,62 +1,62 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#pragma once #pragma once
#ifndef __AMMO_H__ #ifndef __AMMO_H__
#define __AMMO_H__ #define __AMMO_H__
#define MAX_WEAPON_NAME 128 #define MAX_WEAPON_NAME 128
#define WEAPON_FLAGS_SELECTONEMPTY 1 #define WEAPON_FLAGS_SELECTONEMPTY 1
#define WEAPON_IS_ONTARGET 0x40 #define WEAPON_IS_ONTARGET 0x40
struct WEAPON struct WEAPON
{ {
char szName[MAX_WEAPON_NAME]; char szName[MAX_WEAPON_NAME];
int iAmmoType; int iAmmoType;
int iAmmo2Type; int iAmmo2Type;
int iMax1; int iMax1;
int iMax2; int iMax2;
int iSlot; int iSlot;
int iSlotPos; int iSlotPos;
int iFlags; int iFlags;
int iId; int iId;
int iClip; int iClip;
int iCount; // # of itesm in plist int iCount; // # of itesm in plist
HSPRITE hActive; HSPRITE hActive;
wrect_t rcActive; wrect_t rcActive;
HSPRITE hInactive; HSPRITE hInactive;
wrect_t rcInactive; wrect_t rcInactive;
HSPRITE hAmmo; HSPRITE hAmmo;
wrect_t rcAmmo; wrect_t rcAmmo;
HSPRITE hAmmo2; HSPRITE hAmmo2;
wrect_t rcAmmo2; wrect_t rcAmmo2;
HSPRITE hCrosshair; HSPRITE hCrosshair;
wrect_t rcCrosshair; wrect_t rcCrosshair;
HSPRITE hAutoaim; HSPRITE hAutoaim;
wrect_t rcAutoaim; wrect_t rcAutoaim;
HSPRITE hZoomedCrosshair; HSPRITE hZoomedCrosshair;
wrect_t rcZoomedCrosshair; wrect_t rcZoomedCrosshair;
HSPRITE hZoomedAutoaim; HSPRITE hZoomedAutoaim;
wrect_t rcZoomedAutoaim; wrect_t rcZoomedAutoaim;
}; };
typedef int AMMO; typedef int AMMO;
#endif #endif

View File

@ -1,143 +1,143 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// ammohistory.h // ammohistory.h
// //
#pragma once #pragma once
// this is the max number of items in each bucket // this is the max number of items in each bucket
#define MAX_WEAPON_POSITIONS 19 #define MAX_WEAPON_POSITIONS 19
class WeaponsResource class WeaponsResource
{ {
private: private:
// Information about weapons & ammo // Information about weapons & ammo
WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array
// counts of weapons * ammo // 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 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 int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type
public: public:
void Init( void ) void Init( void )
{ {
memset( rgWeapons, 0, sizeof rgWeapons ); memset( rgWeapons, 0, sizeof rgWeapons );
Reset(); Reset();
} }
void Reset( void ) void Reset( void )
{ {
iOldWeaponBits = 0; iOldWeaponBits = 0;
memset( rgSlots, 0, sizeof rgSlots ); memset( rgSlots, 0, sizeof rgSlots );
memset( riAmmo, 0, sizeof riAmmo ); memset( riAmmo, 0, sizeof riAmmo );
} }
///// WEAPON ///// ///// WEAPON /////
int iOldWeaponBits; int iOldWeaponBits;
WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; } WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
void AddWeapon( WEAPON *wp ) void AddWeapon( WEAPON *wp )
{ {
rgWeapons[ wp->iId ] = *wp; rgWeapons[ wp->iId ] = *wp;
LoadWeaponSprites( &rgWeapons[ wp->iId ] ); LoadWeaponSprites( &rgWeapons[ wp->iId ] );
} }
void PickupWeapon( WEAPON *wp ) void PickupWeapon( WEAPON *wp )
{ {
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp; rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
} }
void DropWeapon( WEAPON *wp ) void DropWeapon( WEAPON *wp )
{ {
rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL; rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
} }
void DropAllWeapons( void ) void DropAllWeapons( void )
{ {
for ( int i = 0; i < MAX_WEAPONS; i++ ) for ( int i = 0; i < MAX_WEAPONS; i++ )
{ {
if ( rgWeapons[i].iId ) if ( rgWeapons[i].iId )
DropWeapon( &rgWeapons[i] ); DropWeapon( &rgWeapons[i] );
} }
} }
WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; } WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
void LoadWeaponSprites( WEAPON* wp ); void LoadWeaponSprites( WEAPON* wp );
void LoadAllWeaponSprites( void ); void LoadAllWeaponSprites( void );
WEAPON* GetFirstPos( int iSlot ); WEAPON* GetFirstPos( int iSlot );
void SelectSlot( int iSlot, int fAdvance, int iDirection ); void SelectSlot( int iSlot, int fAdvance, int iDirection );
WEAPON* GetNextActivePos( int iSlot, int iSlotPos ); WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
int HasAmmo( WEAPON *p ); int HasAmmo( WEAPON *p );
///// AMMO ///// ///// AMMO /////
AMMO GetAmmo( int iId ) { return iId; } AMMO GetAmmo( int iId ) { return iId; }
void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; } void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount; }
int CountAmmo( int iId ); int CountAmmo( int iId );
HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect ); HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
}; };
extern WeaponsResource gWR; extern WeaponsResource gWR;
#define MAX_HISTORY 12 #define MAX_HISTORY 12
enum { enum {
HISTSLOT_EMPTY, HISTSLOT_EMPTY,
HISTSLOT_AMMO, HISTSLOT_AMMO,
HISTSLOT_WEAP, HISTSLOT_WEAP,
HISTSLOT_ITEM, HISTSLOT_ITEM,
}; };
class HistoryResource class HistoryResource
{ {
private: private:
struct HIST_ITEM { struct HIST_ITEM {
int type; int type;
float DisplayTime; // the time at which this item should be removed from the history float DisplayTime; // the time at which this item should be removed from the history
int iCount; int iCount;
int iId; int iId;
}; };
HIST_ITEM rgAmmoHistory[MAX_HISTORY]; HIST_ITEM rgAmmoHistory[MAX_HISTORY];
public: public:
void Init( void ) void Init( void )
{ {
Reset(); Reset();
} }
void Reset( void ) void Reset( void )
{ {
memset( rgAmmoHistory, 0, sizeof rgAmmoHistory ); memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
} }
int iHistoryGap; int iHistoryGap;
int iCurrentHistorySlot; int iCurrentHistorySlot;
void AddToHistory( int iType, int iId, int iCount = 0 ); void AddToHistory( int iType, int iId, int iCount = 0 );
void AddToHistory( int iType, const char *szName, int iCount = 0 ); void AddToHistory( int iType, const char *szName, int iCount = 0 );
void CheckClearHistory( void ); void CheckClearHistory( void );
int DrawAmmoHistory( float flTime ); int DrawAmmoHistory( float flTime );
}; };
extern HistoryResource gHR; extern HistoryResource gHR;

View File

@ -1,133 +1,133 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#pragma once #pragma once
#define DMG_IMAGE_LIFE 2 // seconds that image is up #define DMG_IMAGE_LIFE 2 // seconds that image is up
#define DMG_IMAGE_POISON 0 #define DMG_IMAGE_POISON 0
#define DMG_IMAGE_ACID 1 #define DMG_IMAGE_ACID 1
#define DMG_IMAGE_COLD 2 #define DMG_IMAGE_COLD 2
#define DMG_IMAGE_DROWN 3 #define DMG_IMAGE_DROWN 3
#define DMG_IMAGE_BURN 4 #define DMG_IMAGE_BURN 4
#define DMG_IMAGE_NERVE 5 #define DMG_IMAGE_NERVE 5
#define DMG_IMAGE_RAD 6 #define DMG_IMAGE_RAD 6
#define DMG_IMAGE_SHOCK 7 #define DMG_IMAGE_SHOCK 7
//tf defines //tf defines
#define DMG_IMAGE_CALTROP 8 #define DMG_IMAGE_CALTROP 8
#define DMG_IMAGE_TRANQ 9 #define DMG_IMAGE_TRANQ 9
#define DMG_IMAGE_CONCUSS 10 #define DMG_IMAGE_CONCUSS 10
#define DMG_IMAGE_HALLUC 11 #define DMG_IMAGE_HALLUC 11
#define NUM_DMG_TYPES 12 #define NUM_DMG_TYPES 12
// instant damage // instant damage
#define DMG_GENERIC 0 // generic damage was done #define DMG_GENERIC 0 // generic damage was done
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object #define DMG_CRUSH (1 << 0) // crushed by falling or moving object
#define DMG_BULLET (1 << 1) // shot #define DMG_BULLET (1 << 1) // shot
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed #define DMG_SLASH (1 << 2) // cut, clawed, stabbed
#define DMG_BURN (1 << 3) // heat burned #define DMG_BURN (1 << 3) // heat burned
#define DMG_FREEZE (1 << 4) // frozen #define DMG_FREEZE (1 << 4) // frozen
#define DMG_FALL (1 << 5) // fell too far #define DMG_FALL (1 << 5) // fell too far
#define DMG_BLAST (1 << 6) // explosive blast damage #define DMG_BLAST (1 << 6) // explosive blast damage
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt #define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
#define DMG_SHOCK (1 << 8) // electric shock #define DMG_SHOCK (1 << 8) // electric shock
#define DMG_SONIC (1 << 9) // sound pulse shockwave #define DMG_SONIC (1 << 9) // sound pulse shockwave
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam #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_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. #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 // time-based damage
//mask off TF-specific stuff too //mask off TF-specific stuff too
#define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage #define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage
#define DMG_DROWN (1 << 14) // Drowning #define DMG_DROWN (1 << 14) // Drowning
#define DMG_FIRSTTIMEBASED DMG_DROWN #define DMG_FIRSTTIMEBASED DMG_DROWN
#define DMG_PARALYZE (1 << 15) // slows affected creature down #define DMG_PARALYZE (1 << 15) // slows affected creature down
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad #define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
#define DMG_POISON (1 << 17) // blood poisioning #define DMG_POISON (1 << 17) // blood poisioning
#define DMG_RADIATION (1 << 18) // radiation exposure #define DMG_RADIATION (1 << 18) // radiation exposure
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery #define DMG_DROWNRECOVER (1 << 19) // drowning recovery
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns #define DMG_ACID (1 << 20) // toxic chemicals or acid burns
#define DMG_SLOWBURN (1 << 21) // in an oven #define DMG_SLOWBURN (1 << 21) // in an oven
#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer #define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer
#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar) #define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar)
//TF ADDITIONS //TF ADDITIONS
#define DMG_IGNITE (1 << 24) // Players hit by this begin to burn #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_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_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_IGNOREARMOR (1 << 27) // Damage ignores target's armor
#define DMG_AIMED (1 << 28) // Does Hit location damage #define DMG_AIMED (1 << 28) // Does Hit location damage
#define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls #define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls
#define DMG_CALTROP (1<<30) #define DMG_CALTROP (1<<30)
#define DMG_HALLUC (1<<31) #define DMG_HALLUC (1<<31)
// TF Healing Additions for TakeHealth // TF Healing Additions for TakeHealth
#define DMG_IGNORE_MAXHEALTH DMG_IGNITE #define DMG_IGNORE_MAXHEALTH DMG_IGNITE
// TF Redefines since we never use the originals // TF Redefines since we never use the originals
#define DMG_NAIL DMG_SLASH #define DMG_NAIL DMG_SLASH
#define DMG_NOT_SELF DMG_FREEZE #define DMG_NOT_SELF DMG_FREEZE
#define DMG_TRANQ DMG_MORTAR #define DMG_TRANQ DMG_MORTAR
#define DMG_CONCUSS DMG_SONIC #define DMG_CONCUSS DMG_SONIC
typedef struct typedef struct
{ {
float fExpire; float fExpire;
float fBaseline; float fBaseline;
int x, y; int x, y;
} DAMAGE_IMAGE; } DAMAGE_IMAGE;
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
class CHudHealth: public CHudBase class CHudHealth: public CHudBase
{ {
public: public:
virtual int Init( void ); virtual int Init( void );
virtual int VidInit( void ); virtual int VidInit( void );
virtual int Draw(float fTime); virtual int Draw(float fTime);
virtual void Reset( void ); virtual void Reset( void );
int MsgFunc_Health(const char *pszName, int iSize, void *pbuf); int MsgFunc_Health(const char *pszName, int iSize, void *pbuf);
int MsgFunc_Damage(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_ScoreAttrib(const char *pszName, int iSize, void *pbuf);
int MsgFunc_ClCorpse(const char *pszName, int iSize, void *pbuf); int MsgFunc_ClCorpse(const char *pszName, int iSize, void *pbuf);
int m_iHealth; int m_iHealth;
int m_HUD_dmg_bio; int m_HUD_dmg_bio;
int m_HUD_cross; int m_HUD_cross;
float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight; float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
void GetPainColor( int &r, int &g, int &b ); void GetPainColor( int &r, int &g, int &b );
float m_fFade; float m_fFade;
private: private:
HSPRITE m_hSprite; HSPRITE m_hSprite;
HSPRITE m_hDamage; HSPRITE m_hDamage;
DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES]; DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES];
float m_flTimeFlash; float m_flTimeFlash;
int m_bitsDamage; int m_bitsDamage;
int DrawPain(float fTime); int DrawPain(float fTime);
int DrawDamage(float fTime); int DrawDamage(float fTime);
void CalcDamageDirection(vec3_t vecFrom); void CalcDamageDirection(vec3_t vecFrom);
void UpdateTiles(float fTime, long bits); void UpdateTiles(float fTime, long bits);
void DrawPlayerLocation( void ); 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. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#pragma once #pragma once
#if !defined( HUD_IFACEH ) #if !defined( HUD_IFACEH )
#define HUD_IFACEH #define HUD_IFACEH
#ifdef _WIN32 #ifdef _WIN32
#define EXPORT _declspec( dllexport ) #define EXPORT _declspec( dllexport )
#define _DLLEXPORT __declspec( dllexport ) #define _DLLEXPORT __declspec( dllexport )
#else #else
#define EXPORT #define EXPORT
#define _DLLEXPORT #define _DLLEXPORT
#endif #endif
typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf);
#include "wrect.h" #include "wrect.h"
#include "../engine/cdll_int.h" #include "../engine/cdll_int.h"
extern cl_enginefunc_t gEngfuncs; extern cl_enginefunc_t gEngfuncs;
#endif #endif

View File

@ -1,139 +1,139 @@
//========= Copyright ? 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright ? 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#pragma once #pragma once
#ifndef SPECTATOR_H #ifndef SPECTATOR_H
#define SPECTATOR_H #define SPECTATOR_H
#include "cl_entity.h" #include "cl_entity.h"
#include "hud.h" #include "hud.h"
#define INSET_OFF 0 #define INSET_OFF 0
#define INSET_CHASE_FREE 1 #define INSET_CHASE_FREE 1
#define INSET_IN_EYE 2 #define INSET_IN_EYE 2
#define INSET_MAP_FREE 3 #define INSET_MAP_FREE 3
#define INSET_MAP_CHASE 4 #define INSET_MAP_CHASE 4
#define MAX_SPEC_HUD_MESSAGES 8 #define MAX_SPEC_HUD_MESSAGES 8
#define OVERVIEW_TILE_SIZE 256 // don't change this #define OVERVIEW_TILE_SIZE 256 // don't change this
#define OVERVIEW_MAX_LAYERS 1 #define OVERVIEW_MAX_LAYERS 1
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it ) // Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
typedef struct overviewInfo_s { typedef struct overviewInfo_s {
char map[64]; // cl.levelname or empty char map[64]; // cl.levelname or empty
vec3_t origin; // center of map vec3_t origin; // center of map
float zoom; // zoom of map images float zoom; // zoom of map images
int layers; // how may layers do we have int layers; // how may layers do we have
float layersHeights[OVERVIEW_MAX_LAYERS]; float layersHeights[OVERVIEW_MAX_LAYERS];
char layersImages[OVERVIEW_MAX_LAYERS][255]; char layersImages[OVERVIEW_MAX_LAYERS][255];
qboolean rotated; // are map images rotated (90 degrees) ? qboolean rotated; // are map images rotated (90 degrees) ?
int insetWindowX; int insetWindowX;
int insetWindowY; int insetWindowY;
int insetWindowHeight; int insetWindowHeight;
int insetWindowWidth; int insetWindowWidth;
} overviewInfo_t; } overviewInfo_t;
typedef struct overviewEntity_s { typedef struct overviewEntity_s {
HSPRITE hSprite; HSPRITE hSprite;
struct cl_entity_s * entity; struct cl_entity_s * entity;
double killTime; double killTime;
} overviewEntity_t; } overviewEntity_t;
#define MAX_OVERVIEW_ENTITIES 128 #define MAX_OVERVIEW_ENTITIES 128
class CHudSpectator : public CHudBase class CHudSpectator : public CHudBase
{ {
public: public:
void Reset(); void Reset();
int ToggleInset(bool allowOff); int ToggleInset(bool allowOff);
void CheckSettings(); void CheckSettings();
void InitHUDData( void ); void InitHUDData( void );
bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime); bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime);
void DeathMessage(int victim); void DeathMessage(int victim);
bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname ); bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname );
void CheckOverviewEntities(); void CheckOverviewEntities();
void DrawOverview(); void DrawOverview();
void DrawOverviewEntities(); void DrawOverviewEntities();
void GetMapPosition( float * returnvec ); void GetMapPosition( float * returnvec );
void DrawOverviewLayer(); void DrawOverviewLayer();
void LoadMapSprites(); void LoadMapSprites();
bool ParseOverviewFile(); bool ParseOverviewFile();
bool IsActivePlayer(cl_entity_t * ent); bool IsActivePlayer(cl_entity_t * ent);
void SetModes(int iMainMode, int iInsetMode); void SetModes(int iMainMode, int iInsetMode);
void HandleButtonsDown(int ButtonPressed); void HandleButtonsDown(int ButtonPressed);
void HandleButtonsUp(int ButtonPressed); void HandleButtonsUp(int ButtonPressed);
void FindNextPlayer( bool bReverse ); void FindNextPlayer( bool bReverse );
void DirectorMessage( int iSize, void *pbuf ); void DirectorMessage( int iSize, void *pbuf );
void SetSpectatorStartPosition(); void SetSpectatorStartPosition();
CHudMsgFunc(Spectator); CHudMsgFunc(Spectator);
int Init(); int Init();
int VidInit(); int VidInit();
int Draw(float flTime); int Draw(float flTime);
int m_iDrawCycle; int m_iDrawCycle;
client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES]; client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES];
char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128]; char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128];
int m_lastHudMessage; int m_lastHudMessage;
overviewInfo_t m_OverviewData; overviewInfo_t m_OverviewData;
overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES]; overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES];
int m_iObserverFlags; int m_iObserverFlags;
int m_iSpectatorNumber; int m_iSpectatorNumber;
float m_mapZoom; // zoom the user currently uses float m_mapZoom; // zoom the user currently uses
vec3_t m_mapOrigin; // origin where user rotates around vec3_t m_mapOrigin; // origin where user rotates around
cvar_t * m_drawnames; cvar_t * m_drawnames;
cvar_t * m_specmode; cvar_t * m_specmode;
cvar_t * m_drawcone; cvar_t * m_drawcone;
cvar_t * m_drawstatus; cvar_t * m_drawstatus;
cvar_t * m_autoDirector; cvar_t * m_autoDirector;
float m_lastAutoDirector; float m_lastAutoDirector;
cvar_t * m_pip; cvar_t * m_pip;
qboolean m_chatEnabled; qboolean m_chatEnabled;
vec3_t m_cameraOrigin; // a help camera vec3_t m_cameraOrigin; // a help camera
vec3_t m_cameraAngles; // and it's angles vec3_t m_cameraAngles; // and it's angles
private: private:
vec3_t m_vPlayerPos[MAX_PLAYERS]; vec3_t m_vPlayerPos[MAX_PLAYERS];
HSPRITE m_hsprPlayerC4; HSPRITE m_hsprPlayerC4;
HSPRITE m_hsprPlayerVIP; HSPRITE m_hsprPlayerVIP;
HSPRITE m_hsprHostage; HSPRITE m_hsprHostage;
HSPRITE m_hsprBackpack; HSPRITE m_hsprBackpack;
HSPRITE m_hsprBomb; HSPRITE m_hsprBomb;
HSPRITE m_hsprPlayerBlue; HSPRITE m_hsprPlayerBlue;
HSPRITE m_hsprPlayerRed; HSPRITE m_hsprPlayerRed;
HSPRITE m_hsprPlayer; HSPRITE m_hsprPlayer;
HSPRITE m_hsprCamera; HSPRITE m_hsprCamera;
HSPRITE m_hsprPlayerDead; HSPRITE m_hsprPlayerDead;
HSPRITE m_hsprViewcone; HSPRITE m_hsprViewcone;
HSPRITE m_hsprUnkownMap; HSPRITE m_hsprUnkownMap;
HSPRITE m_hsprBeam; HSPRITE m_hsprBeam;
HSPRITE m_hCrosshair; HSPRITE m_hCrosshair;
wrect_t m_crosshairRect; wrect_t m_crosshairRect;
struct model_s * m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame 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_flNextObserverInput;
float m_zoomDelta; float m_zoomDelta;
float m_moveDelta; float m_moveDelta;
int m_lastPrimaryObject; int m_lastPrimaryObject;
int m_lastSecondaryObject; int m_lastSecondaryObject;
}; };
#endif // SPECTATOR_H #endif // SPECTATOR_H

View File

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

View File

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

View File

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

View File

@ -1,40 +1,40 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// parsemsg.h // parsemsg.h
// //
#pragma once #pragma once
#define ASSERT( x ) #define ASSERT( x )
void BEGIN_READ( void *buf, int size ); void BEGIN_READ( void *buf, int size );
int READ_CHAR( void ); int READ_CHAR( void );
int READ_BYTE( void ); int READ_BYTE( void );
int READ_SHORT( void ); int READ_SHORT( void );
int READ_WORD( void ); int READ_WORD( void );
int READ_LONG( void ); int READ_LONG( void );
float READ_FLOAT( void ); float READ_FLOAT( void );
char* READ_STRING( void ); char* READ_STRING( void );
float READ_COORD( void ); float READ_COORD( void );
float READ_ANGLE( void ); float READ_ANGLE( void );
float READ_HIRESANGLE( void ); float READ_HIRESANGLE( void );

View File

@ -1,82 +1,82 @@
/*** /***
* *
* Copyright (c) 1996-2004, Shambler Team. All rights reserved. * Copyright (c) 1996-2004, Shambler Team. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Shambler Team. All other use, distribution, or modification is prohibited * Shambler Team. All other use, distribution, or modification is prohibited
* without written permission from Shambler Team. * without written permission from Shambler Team.
* *
****/ ****/
/* /*
====== rain.h ======================================================== ====== rain.h ========================================================
*/ */
#pragma once #pragma once
#ifndef __RAIN_H__ #ifndef __RAIN_H__
#define __RAIN_H__ #define __RAIN_H__
#define DRIPSPEED 900 // speed of raindrips (pixel per secs) #define DRIPSPEED 900 // speed of raindrips (pixel per secs)
#define SNOWSPEED 200 // speed of snowflakes #define SNOWSPEED 200 // speed of snowflakes
#define SNOWFADEDIST 80 #define SNOWFADEDIST 80
#define MAXDRIPS 2000 // max raindrops #define MAXDRIPS 2000 // max raindrops
#define MAXFX 3000 // max effects #define MAXFX 3000 // max effects
#define DRIP_SPRITE_HALFHEIGHT 64 #define DRIP_SPRITE_HALFHEIGHT 64
#define DRIP_SPRITE_HALFWIDTH 1 #define DRIP_SPRITE_HALFWIDTH 1
#define SNOW_SPRITE_HALFSIZE 3 #define SNOW_SPRITE_HALFSIZE 3
// radius water rings // radius water rings
#define MAXRINGHALFSIZE 25 #define MAXRINGHALFSIZE 25
typedef struct typedef struct
{ {
int dripsPerSecond; int dripsPerSecond;
float distFromPlayer; float distFromPlayer;
float windX, windY; float windX, windY;
float randX, randY; float randX, randY;
int weatherMode; // 0 - snow, 1 - rain int weatherMode; // 0 - snow, 1 - rain
float globalHeight; float globalHeight;
} rain_properties; } rain_properties;
typedef struct cl_drip typedef struct cl_drip
{ {
float birthTime; float birthTime;
float minHeight; // minimal height to kill raindrop float minHeight; // minimal height to kill raindrop
vec3_t origin; vec3_t origin;
float alpha; float alpha;
float xDelta; // side speed float xDelta; // side speed
float yDelta; float yDelta;
int landInWater; int landInWater;
cl_drip* p_Next; // next drip in chain cl_drip* p_Next; // next drip in chain
cl_drip* p_Prev; // previous drip in chain cl_drip* p_Prev; // previous drip in chain
} cl_drip_t; } cl_drip_t;
typedef struct cl_rainfx typedef struct cl_rainfx
{ {
float birthTime; float birthTime;
float life; float life;
vec3_t origin; vec3_t origin;
float alpha; float alpha;
cl_rainfx* p_Next; // next fx in chain cl_rainfx* p_Next; // next fx in chain
cl_rainfx* p_Prev; // previous fx in chain cl_rainfx* p_Prev; // previous fx in chain
} cl_rainfx_t; } cl_rainfx_t;
extern rain_properties Rain; extern rain_properties Rain;
extern cl_drip_t FirstChainDrip; extern cl_drip_t FirstChainDrip;
extern cl_rainfx_t FirstChainFX; extern cl_rainfx_t FirstChainFX;
void ProcessRain( void ); void ProcessRain( void );
void ProcessFXObjects( void ); void ProcessFXObjects( void );
void ResetRain( void ); void ResetRain( void );
void InitRain( void ); void InitRain( void );
#endif #endif

View File

@ -1,85 +1,85 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// Big thanks to Chicken Fortress developers // Big thanks to Chicken Fortress developers
// for this code. // for this code.
#pragma once #pragma once
#if !defined (GAMESTUDIOMODELRENDERER_H) #if !defined (GAMESTUDIOMODELRENDERER_H)
#define GAMESTUDIOMODELRENDERER_H #define GAMESTUDIOMODELRENDERER_H
enum BoneIndex enum BoneIndex
{ {
BONE_HEAD, BONE_HEAD,
BONE_PELVIS, BONE_PELVIS,
BONE_SPINE1, BONE_SPINE1,
BONE_SPINE2, BONE_SPINE2,
BONE_SPINE3, BONE_SPINE3,
BONE_MAX, BONE_MAX,
}; };
typedef struct typedef struct
{ {
vec3_t origin; vec3_t origin;
vec3_t angles; vec3_t angles;
vec3_t realangles; vec3_t realangles;
float animtime; float animtime;
float frame; float frame;
int sequence; int sequence;
int gaitsequence; int gaitsequence;
float framerate; float framerate;
int m_fSequenceLoops; int m_fSequenceLoops;
int m_fSequenceFinished; int m_fSequenceFinished;
byte controller[4]; byte controller[4];
byte blending[2]; byte blending[2];
latchedvars_t lv; latchedvars_t lv;
}client_anim_state_t; }client_anim_state_t;
class CGameStudioModelRenderer : public CStudioModelRenderer class CGameStudioModelRenderer : public CStudioModelRenderer
{ {
public: public:
CGameStudioModelRenderer(void); CGameStudioModelRenderer(void);
public: public:
virtual void StudioSetupBones(void); virtual void StudioSetupBones(void);
virtual void StudioEstimateGait(entity_state_t *pplayer); virtual void StudioEstimateGait(entity_state_t *pplayer);
virtual void StudioProcessGait(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 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 StudioFxTransform(cl_entity_t *ent, float transform[3][4]);
virtual void StudioPlayerBlend(mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch); virtual void StudioPlayerBlend(mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch);
virtual void CalculateYawBlend(entity_state_t *pplayer); virtual void CalculateYawBlend(entity_state_t *pplayer);
virtual void CalculatePitchBlend(entity_state_t *pplayer); virtual void CalculatePitchBlend(entity_state_t *pplayer);
private: private:
void SavePlayerState(entity_state_t *pplayer); void SavePlayerState(entity_state_t *pplayer);
void SetupClientAnimation(entity_state_t *pplayer); void SetupClientAnimation(entity_state_t *pplayer);
void RestorePlayerState(entity_state_t *pplayer); void RestorePlayerState(entity_state_t *pplayer);
mstudioanim_t* LookupAnimation(mstudioseqdesc_t *pseqdesc, int index); mstudioanim_t* LookupAnimation(mstudioseqdesc_t *pseqdesc, int index);
private: private:
int m_nPlayerGaitSequences[MAX_CLIENTS]; int m_nPlayerGaitSequences[MAX_CLIENTS];
bool m_bLocal; bool m_bLocal;
}; };
extern CGameStudioModelRenderer g_StudioRenderer; extern CGameStudioModelRenderer g_StudioRenderer;
#endif #endif

View File

@ -1,97 +1,97 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// Big thanks to Chicken Fortress developers // Big thanks to Chicken Fortress developers
// for this code. // for this code.
#pragma once #pragma once
#ifndef STUDIOMODELRENDERER_H #ifndef STUDIOMODELRENDERER_H
#define STUDIOMODELRENDERER_H #define STUDIOMODELRENDERER_H
class CStudioModelRenderer class CStudioModelRenderer
{ {
public: public:
CStudioModelRenderer(void); CStudioModelRenderer(void);
virtual ~CStudioModelRenderer(void); virtual ~CStudioModelRenderer(void);
public: public:
virtual void Init(void); virtual void Init(void);
virtual int StudioDrawModel(int flags); virtual int StudioDrawModel(int flags);
virtual int StudioDrawPlayer(int flags, struct entity_state_s *pplayer); virtual int StudioDrawPlayer(int flags, struct entity_state_s *pplayer);
public: public:
virtual mstudioanim_t *StudioGetAnim(model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc); virtual mstudioanim_t *StudioGetAnim(model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc);
virtual void StudioSetUpTransform(int trivial_accept); virtual void StudioSetUpTransform(int trivial_accept);
virtual void StudioSetupBones(void); virtual void StudioSetupBones(void);
virtual void StudioCalcAttachments(void); virtual void StudioCalcAttachments(void);
virtual void StudioSaveBones(void); virtual void StudioSaveBones(void);
virtual void StudioMergeBones(model_t *m_pSubModel); virtual void StudioMergeBones(model_t *m_pSubModel);
virtual float StudioEstimateInterpolant(void); virtual float StudioEstimateInterpolant(void);
virtual float StudioEstimateFrame(mstudioseqdesc_t *pseqdesc); virtual float StudioEstimateFrame(mstudioseqdesc_t *pseqdesc);
virtual void StudioFxTransform(cl_entity_t *ent, float transform[3][4]); 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 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 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 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 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 StudioCalcRotations(float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f);
virtual void StudioRenderModel(float *lightdir); virtual void StudioRenderModel(float *lightdir);
virtual void StudioRenderFinal(void); virtual void StudioRenderFinal(void);
virtual void StudioRenderFinal_Software(void); virtual void StudioRenderFinal_Software(void);
virtual void StudioRenderFinal_Hardware(void); virtual void StudioRenderFinal_Hardware(void);
virtual void StudioPlayerBlend(mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch); virtual void StudioPlayerBlend(mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch);
virtual void StudioEstimateGait(entity_state_t *pplayer); virtual void StudioEstimateGait(entity_state_t *pplayer);
virtual void StudioProcessGait(entity_state_t *pplayer); virtual void StudioProcessGait(entity_state_t *pplayer);
virtual void StudioSetShadowSprite(int idx); virtual void StudioSetShadowSprite(int idx);
virtual void StudioDrawShadow(Vector origin, float scale); virtual void StudioDrawShadow(Vector origin, float scale);
public: public:
double m_clTime; double m_clTime;
double m_clOldTime; double m_clOldTime;
int m_fDoInterp; int m_fDoInterp;
int m_iShadowSprite; int m_iShadowSprite;
int m_fGaitEstimation; int m_fGaitEstimation;
int m_nFrameCount; int m_nFrameCount;
cvar_t *m_pCvarHiModels; cvar_t *m_pCvarHiModels;
cvar_t *m_pCvarDeveloper; cvar_t *m_pCvarDeveloper;
cvar_t *m_pCvarDrawEntities; cvar_t *m_pCvarDrawEntities;
cl_entity_t *m_pCurrentEntity; cl_entity_t *m_pCurrentEntity;
model_t *m_pRenderModel; model_t *m_pRenderModel;
player_info_t *m_pPlayerInfo; player_info_t *m_pPlayerInfo;
int m_nPlayerIndex; int m_nPlayerIndex;
float m_flGaitMovement; float m_flGaitMovement;
studiohdr_t *m_pStudioHeader; studiohdr_t *m_pStudioHeader;
mstudiobodyparts_t *m_pBodyPart; mstudiobodyparts_t *m_pBodyPart;
mstudiomodel_t *m_pSubModel; mstudiomodel_t *m_pSubModel;
int m_nTopColor; int m_nTopColor;
int m_nBottomColor; int m_nBottomColor;
model_t *m_pChromeSprite; model_t *m_pChromeSprite;
int m_nCachedBones; int m_nCachedBones;
char m_nCachedBoneNames[MAXSTUDIOBONES][32]; char m_nCachedBoneNames[MAXSTUDIOBONES][32];
float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4]; float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4];
float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4]; float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4];
float m_fSoftwareXScale, m_fSoftwareYScale; float m_fSoftwareXScale, m_fSoftwareYScale;
float m_vUp[3]; float m_vUp[3];
float m_vRight[3]; float m_vRight[3];
float m_vNormal[3]; float m_vNormal[3];
float m_vRenderOrigin[3]; float m_vRenderOrigin[3];
int *m_pStudioModelCount; int *m_pStudioModelCount;
int *m_pModelsDrawn; int *m_pModelsDrawn;
float (*m_protationmatrix)[3][4]; float (*m_protationmatrix)[3][4];
float (*m_paliastransform)[3][4]; float (*m_paliastransform)[3][4];
float (*m_pbonetransform)[MAXSTUDIOBONES][3][4]; float (*m_pbonetransform)[MAXSTUDIOBONES][3][4];
float (*m_plighttransform)[MAXSTUDIOBONES][3][4]; float (*m_plighttransform)[MAXSTUDIOBONES][3][4];
}; };
#endif #endif

View File

@ -1,38 +1,38 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#pragma once #pragma once
#if !defined( STUDIO_UTIL_H ) #if !defined( STUDIO_UTIL_H )
#define STUDIO_UTIL_H #define STUDIO_UTIL_H
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif #endif
#ifndef PITCH #ifndef PITCH
// MOVEMENT INFO // MOVEMENT INFO
// up / down // up / down
#define PITCH 0 #define PITCH 0
// left / right // left / right
#define YAW 1 #define YAW 1
// fall over // fall over
#define ROLL 2 #define ROLL 2
#endif #endif
#define FDotProduct( a, b ) (fabs((a[0])*(b[0])) + fabs((a[1])*(b[1])) + fabs((a[2])*(b[2]))) #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] ); void AngleMatrix (const float *angles, float (*matrix)[4] );
int VectorCompare (const float *v1, const float *v2); int VectorCompare (const float *v1, const float *v2);
void CrossProduct (const float *v1, const float *v2, float *cross); void CrossProduct (const float *v1, const float *v2, float *cross);
void VectorTransform (const float *in1, float in2[3][4], float *out); 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 ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
void MatrixCopy( float in[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 QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] );
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ); void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt );
void AngleQuaternion( float *angles, vec4_t quaternion ); void AngleQuaternion( float *angles, vec4_t quaternion );
#endif // STUDIO_UTIL_H #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 * 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 * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, * along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL * link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * 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 * 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 * 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 * 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 * you do not wish to do so, delete this exception statement from your
* version. * version.
* *
*/ */
#pragma once #pragma once
#ifndef UNICODE_STR_TOOLS_H #ifndef UNICODE_STR_TOOLS_H
#define UNICODE_STR_TOOLS_H #define UNICODE_STR_TOOLS_H
#ifdef _WIN32 #ifdef _WIN32
typedef wchar_t uchar16; typedef wchar_t uchar16;
typedef unsigned int uchar32; typedef unsigned int uchar32;
#else #else
typedef unsigned short uchar16; typedef unsigned short uchar16;
typedef wchar_t uchar32; typedef wchar_t uchar32;
#endif // _WIN32 #endif // _WIN32
enum EStringConvertErrorPolicy enum EStringConvertErrorPolicy
{ {
_STRINGCONVERTFLAG_SKIP = 1, _STRINGCONVERTFLAG_SKIP = 1,
_STRINGCONVERTFLAG_FAIL = 2, _STRINGCONVERTFLAG_FAIL = 2,
_STRINGCONVERTFLAG_ASSERT = 4, _STRINGCONVERTFLAG_ASSERT = 4,
STRINGCONVERT_REPLACE = 0, STRINGCONVERT_REPLACE = 0,
STRINGCONVERT_SKIP = 1, STRINGCONVERT_SKIP = 1,
STRINGCONVERT_FAIL = 2, STRINGCONVERT_FAIL = 2,
STRINGCONVERT_ASSERT_REPLACE = 4, STRINGCONVERT_ASSERT_REPLACE = 4,
STRINGCONVERT_ASSERT_SKIP = 5, STRINGCONVERT_ASSERT_SKIP = 5,
STRINGCONVERT_ASSERT_FAIL = 6, STRINGCONVERT_ASSERT_FAIL = 6,
}; };
bool Q_IsValidUChar32(uchar32 uVal); bool Q_IsValidUChar32(uchar32 uVal);
int Q_UTF32ToUChar32(const uchar32 *pUTF32, uchar32 &uVal, bool &bErr); int Q_UTF32ToUChar32(const uchar32 *pUTF32, uchar32 &uVal, bool &bErr);
int Q_UChar32ToUTF32Len(uchar32 uVal); int Q_UChar32ToUTF32Len(uchar32 uVal);
int Q_UChar32ToUTF32(uchar32 uVal, uchar32 *pUTF32); int Q_UChar32ToUTF32(uchar32 uVal, uchar32 *pUTF32);
int Q_UChar32ToUTF8Len(uchar32 uVal); int Q_UChar32ToUTF8Len(uchar32 uVal);
int Q_UChar32ToUTF16Len(uchar32 uVal); int Q_UChar32ToUTF16Len(uchar32 uVal);
int Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out); int Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out);
int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out); int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out);
int Q_UTF16ToUChar32(const uchar16 *pUTF16, uchar32 &uValueOut, bool &bErrorOut); int Q_UTF16ToUChar32(const uchar16 *pUTF16, uchar32 &uValueOut, bool &bErrorOut);
int Q_UTF8ToUTF16(const char *pUTF8, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy); 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_UTF8ToUTF32(const char *pUTF8, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF16ToUTF8(const uchar16 *pUTF16, char *pUTF8, 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_UTF16ToUTF32(const uchar16 *pUTF16, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF32ToUTF8(const uchar32 *pUTF32, char *pUTF8, 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_UTF32ToUTF16(const uchar32 *pUTF32, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy);
int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut); int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut);
qboolean Q_UnicodeValidate(const char *pUTF8); qboolean Q_UnicodeValidate(const char *pUTF8);
int Q_UnicodeLength(const char *pUTF8); int Q_UnicodeLength(const char *pUTF8);
char *Q_UnicodeAdvance(char *pUTF8, int nChars); char *Q_UnicodeAdvance(char *pUTF8, int nChars);
//bool Q_IsMeanSpaceW(uchar16 wch); //bool Q_IsMeanSpaceW(uchar16 wch);
bool Q_IsDeprecatedW(uchar16 wch); bool Q_IsDeprecatedW(uchar16 wch);
uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pbStrippedAny); uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pbStrippedAny);
qboolean Q_StripUnprintableAndSpace(char *pch); qboolean Q_StripUnprintableAndSpace(char *pch);
qboolean V_UTF8ToUChar32(const char *pUTF8_, uchar32 *uValueOut); qboolean V_UTF8ToUChar32(const char *pUTF8_, uchar32 *uValueOut);
int Q_UnicodeRepair(char *pUTF8); int Q_UnicodeRepair(char *pUTF8);
wchar_t *Q_AdvanceSpace (wchar_t *start); wchar_t *Q_AdvanceSpace (wchar_t *start);
wchar_t *Q_ReadUToken (wchar_t *start, wchar_t *token, int tokenBufferSize, bool &quoted); wchar_t *Q_ReadUToken (wchar_t *start, wchar_t *token, int tokenBufferSize, bool &quoted);
#endif // UNICODE_STR_TOOLS_H #endif // UNICODE_STR_TOOLS_H

View File

@ -1,121 +1,121 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// Vector.h // Vector.h
// A subset of the extdll.h in the project HL Entity DLL // A subset of the extdll.h in the project HL Entity DLL
// //
#pragma once #pragma once
// Misc C-runtime library headers // Misc C-runtime library headers
#include "stdio.h" #include "stdio.h"
#include "stdlib.h" #include "stdlib.h"
#include "math.h" #include "math.h"
// Header file containing definition of globalvars_t and entvars_t // Header file containing definition of globalvars_t and entvars_t
typedef int func_t; // typedef int func_t; //
typedef int string_t; // from engine's pr_comp.h; typedef int string_t; // from engine's pr_comp.h;
typedef float vec_t; // needed before including progdefs.h typedef float vec_t; // needed before including progdefs.h
//========================================================= //=========================================================
// 2DVector - used for many pathfinding and many other // 2DVector - used for many pathfinding and many other
// operations that are treated as planar rather than 3d. // operations that are treated as planar rather than 3d.
//========================================================= //=========================================================
class Vector2D class Vector2D
{ {
public: public:
inline Vector2D(void) { } inline Vector2D(void) { }
inline Vector2D(float X, float Y) { x = X; y = Y; } 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-(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 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 float Length(void) const { return (float)sqrt(x*x + y*y ); }
inline Vector2D Normalize ( void ) const inline Vector2D Normalize ( void ) const
{ {
Vector2D vec2; Vector2D vec2;
float flLen = Length(); float flLen = Length();
if ( flLen == 0 ) if ( flLen == 0 )
{ {
return Vector2D( (float)0, (float)0 ); return Vector2D( (float)0, (float)0 );
} }
else else
{ {
flLen = 1 / flLen; flLen = 1 / flLen;
return Vector2D( x * flLen, y * flLen ); return Vector2D( x * flLen, y * flLen );
} }
} }
vec_t x, y; vec_t x, y;
}; };
inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.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; } inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; }
//========================================================= //=========================================================
// 3D Vector // 3D Vector
//========================================================= //=========================================================
class Vector // same data-layout as engine's vec3_t, class Vector // same data-layout as engine's vec3_t,
{ // which is a vec_t[3] { // which is a vec_t[3]
public: public:
// Construction/destruction // Construction/destruction
inline Vector(void) { } inline Vector(void) { }
inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; } 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(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(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(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]; } inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; }
// Operators // Operators
inline Vector operator-(void) const { return Vector(-x,-y,-z); } 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 x==v.x && y==v.y && z==v.z; }
inline int operator!=(const Vector& v) const { return !(*this==v); } 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-(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); }
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 // Methods
inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } 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); } 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 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 operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed
inline Vector Normalize(void) const inline Vector Normalize(void) const
{ {
float flLen = Length(); float flLen = Length();
if (flLen == 0) return Vector(0,0,1); // ???? if (flLen == 0) return Vector(0,0,1); // ????
flLen = 1 / flLen; flLen = 1 / flLen;
return Vector(x * flLen, y * flLen, z * flLen); return Vector(x * flLen, y * flLen, z * flLen);
} }
inline Vector2D Make2D ( void ) const inline Vector2D Make2D ( void ) const
{ {
Vector2D Vec2; Vector2D Vec2;
Vec2.x = x; Vec2.x = x;
Vec2.y = y; Vec2.y = y;
return Vec2; return Vec2;
} }
inline float Length2D(void) const { return (float)sqrt(x*x + y*y); } inline float Length2D(void) const { return (float)sqrt(x*x + y*y); }
// Members // Members
vec_t x, y, z; vec_t x, y, z;
}; };
inline Vector operator*(float fl, const Vector& v) { return v * fl; } 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 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 ); } 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 #define vec3_t Vector

View File

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

View File

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

View File

@ -1,166 +1,166 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// parsemsg.cpp // parsemsg.cpp
// //
typedef unsigned char byte; typedef unsigned char byte;
#define true 1 #define true 1
#include <stddef.h> #include <stddef.h>
static byte *gpBuf; static byte *gpBuf;
static size_t giSize; static size_t giSize;
static int giRead; static int giRead;
static bool giBadRead; static bool giBadRead;
void BEGIN_READ( void *buf, int size ) void BEGIN_READ( void *buf, int size )
{ {
giRead = 0; giRead = 0;
giBadRead = false; giBadRead = false;
giSize = size; giSize = size;
gpBuf = (byte*)buf; gpBuf = (byte*)buf;
} }
int READ_CHAR( void ) int READ_CHAR( void )
{ {
int c; int c;
if (giRead + 1 > giSize) if (giRead + 1 > giSize)
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = (signed char)gpBuf[giRead]; c = (signed char)gpBuf[giRead];
giRead++; giRead++;
return c; return c;
} }
int READ_BYTE( void ) int READ_BYTE( void )
{ {
int c; int c;
if (giRead+1 > giSize) if (giRead+1 > giSize)
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = (unsigned char)gpBuf[giRead]; c = (unsigned char)gpBuf[giRead];
giRead++; giRead++;
return c; return c;
} }
int READ_SHORT( void ) int READ_SHORT( void )
{ {
int c; int c;
if (giRead+2 > giSize) if (giRead+2 > giSize)
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) );
giRead += 2; giRead += 2;
return c; return c;
} }
int READ_WORD( void ) int READ_WORD( void )
{ {
return READ_SHORT(); return READ_SHORT();
} }
int READ_LONG( void ) int READ_LONG( void )
{ {
int c; int c;
if (giRead+4 > giSize) if (giRead+4 > giSize)
{ {
giBadRead = true; giBadRead = true;
return -1; return -1;
} }
c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24);
giRead += 4; giRead += 4;
return c; return c;
} }
float READ_FLOAT( void ) float READ_FLOAT( void )
{ {
union union
{ {
byte b[4]; byte b[4];
float f; float f;
int l; int l;
} dat; } dat;
dat.b[0] = gpBuf[giRead]; dat.b[0] = gpBuf[giRead];
dat.b[1] = gpBuf[giRead+1]; dat.b[1] = gpBuf[giRead+1];
dat.b[2] = gpBuf[giRead+2]; dat.b[2] = gpBuf[giRead+2];
dat.b[3] = gpBuf[giRead+3]; dat.b[3] = gpBuf[giRead+3];
giRead += 4; giRead += 4;
// dat.l = LittleLong (dat.l); // dat.l = LittleLong (dat.l);
return dat.f; return dat.f;
} }
char* READ_STRING( void ) char* READ_STRING( void )
{ {
static char string[2048]; static char string[2048];
int l,c; int l,c;
string[0] = 0; string[0] = 0;
l = 0; l = 0;
do do
{ {
if ( giRead+1 > giSize ) if ( giRead+1 > giSize )
break; // no more characters break; // no more characters
c = READ_CHAR(); c = READ_CHAR();
if (c == -1 || c == 0) if (c == -1 || c == 0)
break; break;
string[l] = c; string[l] = c;
l++; l++;
} while (l < sizeof(string)-1); } while (l < sizeof(string)-1);
string[l] = 0; string[l] = 0;
return string; return string;
} }
float READ_COORD( void ) float READ_COORD( void )
{ {
return (float)(READ_SHORT() * (1.0/8)); return (float)(READ_SHORT() * (1.0/8));
} }
float READ_ANGLE( void ) float READ_ANGLE( void )
{ {
return (float)(READ_CHAR() * (360.0/256)); return (float)(READ_CHAR() * (360.0/256));
} }
float READ_HIRESANGLE( void ) float READ_HIRESANGLE( void )
{ {
return (float)(READ_SHORT() * (360.0/65536)); return (float)(READ_SHORT() * (360.0/65536));
} }

View File

@ -1,405 +1,405 @@
/*** /***
* *
* Copyright (c) 2005, BUzer. * Copyright (c) 2005, BUzer.
* *
* Used with permission for Spirit of Half-Life 1.5 * Used with permission for Spirit of Half-Life 1.5
* *
****/ ****/
/* /*
====== rain.cpp ======================================================== ====== rain.cpp ========================================================
*/ */
#include <memory.h> #include <memory.h>
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "entity_types.h" #include "entity_types.h"
#include "cdll_int.h" #include "cdll_int.h"
#include "pm_defs.h" #include "pm_defs.h"
#include "event_api.h" #include "event_api.h"
#include "rain.h" #include "rain.h"
void WaterLandingEffect(cl_drip *drip); void WaterLandingEffect(cl_drip *drip);
rain_properties Rain; rain_properties Rain;
cl_drip FirstChainDrip; cl_drip FirstChainDrip;
cl_rainfx FirstChainFX; cl_rainfx FirstChainFX;
double rain_curtime; // current time double rain_curtime; // current time
double rain_oldtime; // last time we have updated drips double rain_oldtime; // last time we have updated drips
double rain_timedelta; // difference between old time and current time double rain_timedelta; // difference between old time and current time
double rain_nextspawntime; // when the next drip should be spawned double rain_nextspawntime; // when the next drip should be spawned
int dripcounter = 0; int dripcounter = 0;
int fxcounter = 0; int fxcounter = 0;
int RainInfo = 0; int RainInfo = 0;
/* /*
================================= =================================
ProcessRain ProcessRain
Must think every frame. Must think every frame.
================================= =================================
*/ */
void ProcessRain( void ) void ProcessRain( void )
{ {
rain_oldtime = rain_curtime; // save old time rain_oldtime = rain_curtime; // save old time
rain_curtime = gEngfuncs.GetClientTime(); rain_curtime = gEngfuncs.GetClientTime();
rain_timedelta = rain_curtime - rain_oldtime; rain_timedelta = rain_curtime - rain_oldtime;
// first frame // first frame
if (rain_oldtime == 0) if (rain_oldtime == 0)
{ {
// fix first frame bug with nextspawntime // fix first frame bug with nextspawntime
rain_nextspawntime = gEngfuncs.GetClientTime(); rain_nextspawntime = gEngfuncs.GetClientTime();
return; return;
} }
if (Rain.dripsPerSecond == 0 && FirstChainDrip.p_Next == NULL) if (Rain.dripsPerSecond == 0 && FirstChainDrip.p_Next == NULL)
{ {
// keep nextspawntime correct // keep nextspawntime correct
rain_nextspawntime = rain_curtime; rain_nextspawntime = rain_curtime;
return; return;
} }
if (rain_timedelta == 0) if (rain_timedelta == 0)
return; // not in pause return; // not in pause
double timeBetweenDrips = 1 / (double)Rain.dripsPerSecond; double timeBetweenDrips = 1 / (double)Rain.dripsPerSecond;
cl_drip* curDrip = FirstChainDrip.p_Next; cl_drip* curDrip = FirstChainDrip.p_Next;
cl_drip* nextDrip = NULL; cl_drip* nextDrip = NULL;
// save debug info // save debug info
float debug_lifetime = 0; float debug_lifetime = 0;
int debug_howmany = 0; int debug_howmany = 0;
int debug_attempted = 0; int debug_attempted = 0;
int debug_dropped = 0; int debug_dropped = 0;
while (curDrip != NULL) // go through list while (curDrip != NULL) // go through list
{ {
nextDrip = curDrip->p_Next; // save pointer to next drip nextDrip = curDrip->p_Next; // save pointer to next drip
if (Rain.weatherMode == 0) if (Rain.weatherMode == 0)
curDrip->origin.z -= rain_timedelta * DRIPSPEED; // rain curDrip->origin.z -= rain_timedelta * DRIPSPEED; // rain
else else
curDrip->origin.z -= rain_timedelta * SNOWSPEED; // snow curDrip->origin.z -= rain_timedelta * SNOWSPEED; // snow
curDrip->origin.x += rain_timedelta * curDrip->xDelta; curDrip->origin.x += rain_timedelta * curDrip->xDelta;
curDrip->origin.y += rain_timedelta * curDrip->yDelta; curDrip->origin.y += rain_timedelta * curDrip->yDelta;
// remove drip if its origin lower than minHeight // remove drip if its origin lower than minHeight
if (curDrip->origin.z < curDrip->minHeight) if (curDrip->origin.z < curDrip->minHeight)
{ {
if (curDrip->landInWater/* && Rain.weatherMode == 0*/) if (curDrip->landInWater/* && Rain.weatherMode == 0*/)
WaterLandingEffect(curDrip); // create water rings WaterLandingEffect(curDrip); // create water rings
if (RainInfo) if (RainInfo)
{ {
debug_lifetime += (rain_curtime - curDrip->birthTime); debug_lifetime += (rain_curtime - curDrip->birthTime);
debug_howmany++; debug_howmany++;
} }
curDrip->p_Prev->p_Next = curDrip->p_Next; // link chain curDrip->p_Prev->p_Next = curDrip->p_Next; // link chain
if (nextDrip != NULL) if (nextDrip != NULL)
nextDrip->p_Prev = curDrip->p_Prev; nextDrip->p_Prev = curDrip->p_Prev;
delete curDrip; delete curDrip;
dripcounter--; dripcounter--;
} }
curDrip = nextDrip; // restore pointer, so we can continue moving through chain curDrip = nextDrip; // restore pointer, so we can continue moving through chain
} }
int maxDelta; // maximum height randomize distance int maxDelta; // maximum height randomize distance
float falltime; float falltime;
if (Rain.weatherMode == 0) if (Rain.weatherMode == 0)
{ {
maxDelta = DRIPSPEED * rain_timedelta; // for rain maxDelta = DRIPSPEED * rain_timedelta; // for rain
falltime = (Rain.globalHeight + 4096) / DRIPSPEED; falltime = (Rain.globalHeight + 4096) / DRIPSPEED;
} }
else else
{ {
maxDelta = SNOWSPEED * rain_timedelta; // for snow maxDelta = SNOWSPEED * rain_timedelta; // for snow
falltime = (Rain.globalHeight + 4096) / SNOWSPEED; falltime = (Rain.globalHeight + 4096) / SNOWSPEED;
} }
while (rain_nextspawntime < rain_curtime) while (rain_nextspawntime < rain_curtime)
{ {
rain_nextspawntime += timeBetweenDrips; rain_nextspawntime += timeBetweenDrips;
if (RainInfo) if (RainInfo)
debug_attempted++; debug_attempted++;
if (dripcounter < MAXDRIPS) // check for overflow if (dripcounter < MAXDRIPS) // check for overflow
{ {
float deathHeight; float deathHeight;
vec3_t vecStart, vecEnd; vec3_t vecStart, vecEnd;
vecStart[0] = gEngfuncs.pfnRandomFloat(gHUD.m_vecOrigin.x - Rain.distFromPlayer, gHUD.m_vecOrigin.x + Rain.distFromPlayer); 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[1] = gEngfuncs.pfnRandomFloat(gHUD.m_vecOrigin.y - Rain.distFromPlayer, gHUD.m_vecOrigin.y + Rain.distFromPlayer);
vecStart[2] = Rain.globalHeight; vecStart[2] = Rain.globalHeight;
float xDelta = Rain.windX + gEngfuncs.pfnRandomFloat(Rain.randX * -1, Rain.randX); float xDelta = Rain.windX + gEngfuncs.pfnRandomFloat(Rain.randX * -1, Rain.randX);
float yDelta = Rain.windY + gEngfuncs.pfnRandomFloat(Rain.randY * -1, Rain.randY); float yDelta = Rain.windY + gEngfuncs.pfnRandomFloat(Rain.randY * -1, Rain.randY);
// find a point at bottom of map // find a point at bottom of map
vecEnd[0] = falltime * xDelta; vecEnd[0] = falltime * xDelta;
vecEnd[1] = falltime * yDelta; vecEnd[1] = falltime * yDelta;
vecEnd[2] = -4096; vecEnd[2] = -4096;
pmtrace_t pmtrace; pmtrace_t pmtrace;
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecStart, vecEnd, PM_STUDIO_IGNORE, -1, &pmtrace ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecStart, vecEnd, PM_STUDIO_IGNORE, -1, &pmtrace );
if (pmtrace.startsolid) if (pmtrace.startsolid)
{ {
if (RainInfo) if (RainInfo)
debug_dropped++; debug_dropped++;
continue; // drip cannot be placed continue; // drip cannot be placed
} }
// falling to water? // falling to water?
int contents = gEngfuncs.PM_PointContents( pmtrace.endpos, NULL ); int contents = gEngfuncs.PM_PointContents( pmtrace.endpos, NULL );
if (contents == CONTENTS_WATER) if (contents == CONTENTS_WATER)
{ {
int waterEntity = gEngfuncs.PM_WaterEntity( pmtrace.endpos ); int waterEntity = gEngfuncs.PM_WaterEntity( pmtrace.endpos );
if ( waterEntity > 0 ) if ( waterEntity > 0 )
{ {
cl_entity_t *pwater = gEngfuncs.GetEntityByIndex( waterEntity ); cl_entity_t *pwater = gEngfuncs.GetEntityByIndex( waterEntity );
if ( pwater && ( pwater->model != NULL ) ) if ( pwater && ( pwater->model != NULL ) )
{ {
deathHeight = pwater->curstate.maxs[2]; deathHeight = pwater->curstate.maxs[2];
} }
else else
{ {
gEngfuncs.Con_Printf("Rain error: can't get water entity\n"); gEngfuncs.Con_Printf("Rain error: can't get water entity\n");
continue; continue;
} }
} }
else else
{ {
gEngfuncs.Con_Printf("Rain error: water is not func_water entity\n"); gEngfuncs.Con_Printf("Rain error: water is not func_water entity\n");
continue; continue;
} }
} }
else else
{ {
deathHeight = pmtrace.endpos[2]; deathHeight = pmtrace.endpos[2];
} }
// just in case.. // just in case..
if (deathHeight > vecStart[2]) if (deathHeight > vecStart[2])
{ {
gEngfuncs.Con_Printf("Rain error: can't create drip in water\n"); gEngfuncs.Con_Printf("Rain error: can't create drip in water\n");
continue; continue;
} }
cl_drip *newClDrip = new cl_drip; cl_drip *newClDrip = new cl_drip;
if (!newClDrip) if (!newClDrip)
{ {
Rain.dripsPerSecond = 0; // disable rain Rain.dripsPerSecond = 0; // disable rain
gEngfuncs.Con_Printf( "Rain error: failed to allocate object!\n"); gEngfuncs.Con_Printf( "Rain error: failed to allocate object!\n");
return; return;
} }
vecStart[2] -= gEngfuncs.pfnRandomFloat(0, maxDelta); // randomize a bit vecStart[2] -= gEngfuncs.pfnRandomFloat(0, maxDelta); // randomize a bit
newClDrip->alpha = gEngfuncs.pfnRandomFloat(0.12, 0.2); newClDrip->alpha = gEngfuncs.pfnRandomFloat(0.12, 0.2);
VectorCopy(vecStart, newClDrip->origin); VectorCopy(vecStart, newClDrip->origin);
newClDrip->xDelta = xDelta; newClDrip->xDelta = xDelta;
newClDrip->yDelta = yDelta; newClDrip->yDelta = yDelta;
newClDrip->birthTime = rain_curtime; // store time when it was spawned newClDrip->birthTime = rain_curtime; // store time when it was spawned
newClDrip->minHeight = deathHeight; newClDrip->minHeight = deathHeight;
if (contents == CONTENTS_WATER) if (contents == CONTENTS_WATER)
newClDrip->landInWater = 1; newClDrip->landInWater = 1;
else else
newClDrip->landInWater = 0; newClDrip->landInWater = 0;
// add to first place in chain // add to first place in chain
newClDrip->p_Next = FirstChainDrip.p_Next; newClDrip->p_Next = FirstChainDrip.p_Next;
newClDrip->p_Prev = &FirstChainDrip; newClDrip->p_Prev = &FirstChainDrip;
if (newClDrip->p_Next != NULL) if (newClDrip->p_Next != NULL)
newClDrip->p_Next->p_Prev = newClDrip; newClDrip->p_Next->p_Prev = newClDrip;
FirstChainDrip.p_Next = newClDrip; FirstChainDrip.p_Next = newClDrip;
dripcounter++; dripcounter++;
} }
else else
{ {
gEngfuncs.Con_Printf( "Rain error: Drip limit overflow!\n" ); gEngfuncs.Con_Printf( "Rain error: Drip limit overflow!\n" );
return; return;
} }
} }
if (RainInfo) // print debug info if (RainInfo) // print debug info
{ {
gEngfuncs.Con_Printf( "Rain info: Drips exist: %i\n", dripcounter ); 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: FX's exist: %i\n", fxcounter );
gEngfuncs.Con_Printf( "Rain info: Attempted/Dropped: %i, %i\n", debug_attempted, debug_dropped); gEngfuncs.Con_Printf( "Rain info: Attempted/Dropped: %i, %i\n", debug_attempted, debug_dropped);
if (debug_howmany) if (debug_howmany)
{ {
float ave = debug_lifetime / (float)debug_howmany; float ave = debug_lifetime / (float)debug_howmany;
gEngfuncs.Con_Printf( "Rain info: Average drip life time: %f\n", ave); gEngfuncs.Con_Printf( "Rain info: Average drip life time: %f\n", ave);
} }
else else
gEngfuncs.Con_Printf( "Rain info: Average drip life time: --\n"); gEngfuncs.Con_Printf( "Rain info: Average drip life time: --\n");
} }
return; return;
} }
/* /*
================================= =================================
WaterLandingEffect WaterLandingEffect
================================= =================================
*/ */
void WaterLandingEffect(cl_drip *drip) void WaterLandingEffect(cl_drip *drip)
{ {
if (fxcounter >= MAXFX) if (fxcounter >= MAXFX)
{ {
gEngfuncs.Con_Printf( "Rain error: FX limit overflow!\n" ); gEngfuncs.Con_Printf( "Rain error: FX limit overflow!\n" );
return; return;
} }
cl_rainfx *newFX = new cl_rainfx; cl_rainfx *newFX = new cl_rainfx;
if (!newFX) if (!newFX)
{ {
gEngfuncs.Con_Printf( "Rain error: failed to allocate FX object!\n"); gEngfuncs.Con_Printf( "Rain error: failed to allocate FX object!\n");
return; return;
} }
newFX->alpha = gEngfuncs.pfnRandomFloat(0.6, 0.9); newFX->alpha = gEngfuncs.pfnRandomFloat(0.6, 0.9);
VectorCopy(drip->origin, newFX->origin); VectorCopy(drip->origin, newFX->origin);
newFX->origin[2] = drip->minHeight; // correct position newFX->origin[2] = drip->minHeight; // correct position
newFX->birthTime = gEngfuncs.GetClientTime(); newFX->birthTime = gEngfuncs.GetClientTime();
newFX->life = gEngfuncs.pfnRandomFloat(0.7, 1); newFX->life = gEngfuncs.pfnRandomFloat(0.7, 1);
// add to first place in chain // add to first place in chain
newFX->p_Next = FirstChainFX.p_Next; newFX->p_Next = FirstChainFX.p_Next;
newFX->p_Prev = &FirstChainFX; newFX->p_Prev = &FirstChainFX;
if (newFX->p_Next != NULL) if (newFX->p_Next != NULL)
newFX->p_Next->p_Prev = newFX; newFX->p_Next->p_Prev = newFX;
FirstChainFX.p_Next = newFX; FirstChainFX.p_Next = newFX;
fxcounter++; fxcounter++;
} }
/* /*
================================= =================================
ProcessFXObjects ProcessFXObjects
Remove all fx objects with out time to live Remove all fx objects with out time to live
Call every frame before ProcessRain Call every frame before ProcessRain
================================= =================================
*/ */
void ProcessFXObjects( void ) void ProcessFXObjects( void )
{ {
float curtime = gEngfuncs.GetClientTime(); float curtime = gEngfuncs.GetClientTime();
cl_rainfx* curFX = FirstChainFX.p_Next; cl_rainfx* curFX = FirstChainFX.p_Next;
cl_rainfx* nextFX = NULL; cl_rainfx* nextFX = NULL;
while (curFX != NULL) // go through FX objects list while (curFX != NULL) // go through FX objects list
{ {
nextFX = curFX->p_Next; // save pointer to next nextFX = curFX->p_Next; // save pointer to next
// delete current? // delete current?
if ((curFX->birthTime + curFX->life) < curtime) if ((curFX->birthTime + curFX->life) < curtime)
{ {
curFX->p_Prev->p_Next = curFX->p_Next; // link chain curFX->p_Prev->p_Next = curFX->p_Next; // link chain
if (nextFX != NULL) if (nextFX != NULL)
nextFX->p_Prev = curFX->p_Prev; nextFX->p_Prev = curFX->p_Prev;
delete curFX; delete curFX;
fxcounter--; fxcounter--;
} }
curFX = nextFX; // restore pointer curFX = nextFX; // restore pointer
} }
} }
/* /*
================================= =================================
ResetRain ResetRain
clear memory, delete all objects clear memory, delete all objects
================================= =================================
*/ */
void ResetRain( void ) void ResetRain( void )
{ {
// delete all drips // delete all drips
cl_drip* delDrip = FirstChainDrip.p_Next; cl_drip* delDrip = FirstChainDrip.p_Next;
FirstChainDrip.p_Next = NULL; FirstChainDrip.p_Next = NULL;
while (delDrip != NULL) while (delDrip != NULL)
{ {
cl_drip* nextDrip = delDrip->p_Next; // save pointer to next drip in chain cl_drip* nextDrip = delDrip->p_Next; // save pointer to next drip in chain
delete delDrip; delete delDrip;
delDrip = nextDrip; // restore pointer delDrip = nextDrip; // restore pointer
dripcounter--; dripcounter--;
} }
// delete all FX objects // delete all FX objects
cl_rainfx* delFX = FirstChainFX.p_Next; cl_rainfx* delFX = FirstChainFX.p_Next;
FirstChainFX.p_Next = NULL; FirstChainFX.p_Next = NULL;
while (delFX != NULL) while (delFX != NULL)
{ {
cl_rainfx* nextFX = delFX->p_Next; cl_rainfx* nextFX = delFX->p_Next;
delete delFX; delete delFX;
delFX = nextFX; delFX = nextFX;
fxcounter--; fxcounter--;
} }
InitRain(); InitRain();
return; return;
} }
/* /*
================================= =================================
InitRain InitRain
initialze system initialze system
================================= =================================
*/ */
void InitRain( void ) void InitRain( void )
{ {
Rain.dripsPerSecond = 0; Rain.dripsPerSecond = 0;
Rain.distFromPlayer = 0; Rain.distFromPlayer = 0;
Rain.windX = 0; Rain.windX = 0;
Rain.windY = 0; Rain.windY = 0;
Rain.randX = 0; Rain.randX = 0;
Rain.randY = 0; Rain.randY = 0;
Rain.weatherMode = 0; Rain.weatherMode = 0;
Rain.globalHeight = 0; Rain.globalHeight = 0;
FirstChainDrip.birthTime = 0; FirstChainDrip.birthTime = 0;
FirstChainDrip.minHeight = 0; FirstChainDrip.minHeight = 0;
FirstChainDrip.origin[0]=0; FirstChainDrip.origin[0]=0;
FirstChainDrip.origin[1]=0; FirstChainDrip.origin[1]=0;
FirstChainDrip.origin[2]=0; FirstChainDrip.origin[2]=0;
FirstChainDrip.alpha = 0; FirstChainDrip.alpha = 0;
FirstChainDrip.xDelta = 0; FirstChainDrip.xDelta = 0;
FirstChainDrip.yDelta = 0; FirstChainDrip.yDelta = 0;
FirstChainDrip.landInWater = 0; FirstChainDrip.landInWater = 0;
FirstChainDrip.p_Next = NULL; FirstChainDrip.p_Next = NULL;
FirstChainDrip.p_Prev = NULL; FirstChainDrip.p_Prev = NULL;
FirstChainFX.alpha = 0; FirstChainFX.alpha = 0;
FirstChainFX.birthTime = 0; FirstChainFX.birthTime = 0;
FirstChainFX.life = 0; FirstChainFX.life = 0;
FirstChainFX.origin[0] = 0; FirstChainFX.origin[0] = 0;
FirstChainFX.origin[1] = 0; FirstChainFX.origin[1] = 0;
FirstChainFX.origin[2] = 0; FirstChainFX.origin[2] = 0;
FirstChainFX.p_Next = NULL; FirstChainFX.p_Next = NULL;
FirstChainFX.p_Prev = NULL; FirstChainFX.p_Prev = NULL;
rain_oldtime = 0; rain_oldtime = 0;
rain_curtime = 0; rain_curtime = 0;
rain_nextspawntime = 0; rain_nextspawntime = 0;
return; 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. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#include <memory.h> #include <memory.h>
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include "const.h" #include "const.h"
#include "com_model.h" #include "com_model.h"
#include "studio_util.h" #include "studio_util.h"
/* /*
==================== ====================
AngleMatrix AngleMatrix
==================== ====================
*/ */
void AngleMatrix (const float *angles, float (*matrix)[4] ) void AngleMatrix (const float *angles, float (*matrix)[4] )
{ {
float angle; float angle;
float sr, sp, sy, cr, cp, cy; float sr, sp, sy, cr, cp, cy;
angle = angles[YAW] * (M_PI*2 / 360); angle = angles[YAW] * (M_PI*2 / 360);
sy = sin(angle); sy = sin(angle);
cy = cos(angle); cy = cos(angle);
angle = angles[PITCH] * (M_PI*2 / 360); angle = angles[PITCH] * (M_PI*2 / 360);
sp = sin(angle); sp = sin(angle);
cp = cos(angle); cp = cos(angle);
angle = angles[ROLL] * (M_PI*2 / 360); angle = angles[ROLL] * (M_PI*2 / 360);
sr = sin(angle); sr = sin(angle);
cr = cos(angle); cr = cos(angle);
// matrix = (YAW * PITCH) * ROLL // matrix = (YAW * PITCH) * ROLL
matrix[0][0] = cp*cy; matrix[0][0] = cp*cy;
matrix[1][0] = cp*sy; matrix[1][0] = cp*sy;
matrix[2][0] = -sp; matrix[2][0] = -sp;
matrix[0][1] = sr*sp*cy+cr*-sy; matrix[0][1] = sr*sp*cy+cr*-sy;
matrix[1][1] = sr*sp*sy+cr*cy; matrix[1][1] = sr*sp*sy+cr*cy;
matrix[2][1] = sr*cp; matrix[2][1] = sr*cp;
matrix[0][2] = (cr*sp*cy+-sr*-sy); matrix[0][2] = (cr*sp*cy+-sr*-sy);
matrix[1][2] = (cr*sp*sy+-sr*cy); matrix[1][2] = (cr*sp*sy+-sr*cy);
matrix[2][2] = cr*cp; matrix[2][2] = cr*cp;
matrix[0][3] = 0.0; matrix[0][3] = 0.0;
matrix[1][3] = 0.0; matrix[1][3] = 0.0;
matrix[2][3] = 0.0; matrix[2][3] = 0.0;
} }
/* /*
==================== ====================
VectorCompare VectorCompare
==================== ====================
*/ */
int VectorCompare (const float *v1, const float *v2) int VectorCompare (const float *v1, const float *v2)
{ {
int i; int i;
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
if (v1[i] != v2[i]) if (v1[i] != v2[i])
return 0; return 0;
return 1; return 1;
} }
/* /*
==================== ====================
CrossProduct CrossProduct
==================== ====================
*/ */
void CrossProduct (const float *v1, const float *v2, float *cross) void CrossProduct (const float *v1, const float *v2, float *cross)
{ {
cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
} }
/* /*
==================== ====================
VectorTransform VectorTransform
==================== ====================
*/ */
void VectorTransform (const float *in1, float in2[3][4], float *out) void VectorTransform (const float *in1, float in2[3][4], float *out)
{ {
out[0] = DotProduct(in1, in2[0]) + in2[0][3]; out[0] = DotProduct(in1, in2[0]) + in2[0][3];
out[1] = DotProduct(in1, in2[1]) + in2[1][3]; out[1] = DotProduct(in1, in2[1]) + in2[1][3];
out[2] = DotProduct(in1, in2[2]) + in2[2][3]; out[2] = DotProduct(in1, in2[2]) + in2[2][3];
} }
/* /*
================ ================
ConcatTransforms ConcatTransforms
================ ================
*/ */
void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]) 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] + out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
in1[0][2] * in2[2][0]; in1[0][2] * in2[2][0];
out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] + out[0][1] = in1[0][0] * in2[0][1] + in1[0][1] * in2[1][1] +
in1[0][2] * in2[2][1]; in1[0][2] * in2[2][1];
out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] + out[0][2] = in1[0][0] * in2[0][2] + in1[0][1] * in2[1][2] +
in1[0][2] * in2[2][2]; in1[0][2] * in2[2][2];
out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] + out[0][3] = in1[0][0] * in2[0][3] + in1[0][1] * in2[1][3] +
in1[0][2] * in2[2][3] + in1[0][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] + out[1][0] = in1[1][0] * in2[0][0] + in1[1][1] * in2[1][0] +
in1[1][2] * in2[2][0]; in1[1][2] * in2[2][0];
out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] + out[1][1] = in1[1][0] * in2[0][1] + in1[1][1] * in2[1][1] +
in1[1][2] * in2[2][1]; in1[1][2] * in2[2][1];
out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] + out[1][2] = in1[1][0] * in2[0][2] + in1[1][1] * in2[1][2] +
in1[1][2] * in2[2][2]; in1[1][2] * in2[2][2];
out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] + out[1][3] = in1[1][0] * in2[0][3] + in1[1][1] * in2[1][3] +
in1[1][2] * in2[2][3] + in1[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] + out[2][0] = in1[2][0] * in2[0][0] + in1[2][1] * in2[1][0] +
in1[2][2] * in2[2][0]; in1[2][2] * in2[2][0];
out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] + out[2][1] = in1[2][0] * in2[0][1] + in1[2][1] * in2[1][1] +
in1[2][2] * in2[2][1]; in1[2][2] * in2[2][1];
out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] + out[2][2] = in1[2][0] * in2[0][2] + in1[2][1] * in2[1][2] +
in1[2][2] * in2[2][2]; in1[2][2] * in2[2][2];
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] + out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
in1[2][2] * in2[2][3] + in1[2][3]; in1[2][2] * in2[2][3] + in1[2][3];
} }
// angles index are not the same as ROLL, PITCH, YAW // angles index are not the same as ROLL, PITCH, YAW
/* /*
==================== ====================
AngleQuaternion AngleQuaternion
==================== ====================
*/ */
void AngleQuaternion( float *angles, vec4_t quaternion ) void AngleQuaternion( float *angles, vec4_t quaternion )
{ {
float angle; float angle;
float sr, sp, sy, cr, cp, cy; float sr, sp, sy, cr, cp, cy;
// FIXME: rescale the inputs to 1/2 angle // FIXME: rescale the inputs to 1/2 angle
angle = angles[2] * 0.5; angle = angles[2] * 0.5;
sy = sin(angle); sy = sin(angle);
cy = cos(angle); cy = cos(angle);
angle = angles[1] * 0.5; angle = angles[1] * 0.5;
sp = sin(angle); sp = sin(angle);
cp = cos(angle); cp = cos(angle);
angle = angles[0] * 0.5; angle = angles[0] * 0.5;
sr = sin(angle); sr = sin(angle);
cr = cos(angle); cr = cos(angle);
quaternion[0] = sr*cp*cy-cr*sp*sy; // X quaternion[0] = sr*cp*cy-cr*sp*sy; // X
quaternion[1] = cr*sp*cy+sr*cp*sy; // Y quaternion[1] = cr*sp*cy+sr*cp*sy; // Y
quaternion[2] = cr*cp*sy-sr*sp*cy; // Z quaternion[2] = cr*cp*sy-sr*sp*cy; // Z
quaternion[3] = cr*cp*cy+sr*sp*sy; // W quaternion[3] = cr*cp*cy+sr*sp*sy; // W
} }
/* /*
==================== ====================
QuaternionSlerp QuaternionSlerp
==================== ====================
*/ */
void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ) void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
{ {
int i; int i;
float omega, cosom, sinom, sclp, sclq; float omega, cosom, sinom, sclp, sclq;
// decide if one of the quaternions is backwards // decide if one of the quaternions is backwards
float a = 0; float a = 0;
float b = 0; float b = 0;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
a += (p[i]-q[i])*(p[i]-q[i]); a += (p[i]-q[i])*(p[i]-q[i]);
b += (p[i]+q[i])*(p[i]+q[i]); b += (p[i]+q[i])*(p[i]+q[i]);
} }
if (a > b) if (a > b)
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
q[i] = -q[i]; q[i] = -q[i];
} }
} }
cosom = p[0]*q[0] + p[1]*q[1] + p[2]*q[2] + p[3]*q[3]; cosom = p[0]*q[0] + p[1]*q[1] + p[2]*q[2] + p[3]*q[3];
if ((1.0 + cosom) > 0.000001) if ((1.0 + cosom) > 0.000001)
{ {
if ((1.0 - cosom) > 0.000001) if ((1.0 - cosom) > 0.000001)
{ {
omega = acos( cosom ); omega = acos( cosom );
sinom = sin( omega ); sinom = sin( omega );
sclp = sin( (1.0 - t)*omega) / sinom; sclp = sin( (1.0 - t)*omega) / sinom;
sclq = sin( t*omega ) / sinom; sclq = sin( t*omega ) / sinom;
} }
else else
{ {
sclp = 1.0 - t; sclp = 1.0 - t;
sclq = t; sclq = t;
} }
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
qt[i] = sclp * p[i] + sclq * q[i]; qt[i] = sclp * p[i] + sclq * q[i];
} }
} }
else else
{ {
qt[0] = -q[1]; qt[0] = -q[1];
qt[1] = q[0]; qt[1] = q[0];
qt[2] = -q[3]; qt[2] = -q[3];
qt[3] = q[2]; qt[3] = q[2];
sclp = sin( (1.0 - t) * (0.5 * M_PI)); sclp = sin( (1.0 - t) * (0.5 * M_PI));
sclq = sin( t * (0.5 * M_PI)); sclq = sin( t * (0.5 * M_PI));
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
qt[i] = sclp * p[i] + sclq * qt[i]; qt[i] = sclp * p[i] + sclq * qt[i];
} }
} }
} }
/* /*
==================== ====================
QuaternionMatrix QuaternionMatrix
==================== ====================
*/ */
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] ) void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] )
{ {
matrix[0][0] = 1.0 - 2.0 * quaternion[1] * quaternion[1] - 2.0 * quaternion[2] * quaternion[2]; matrix[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[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[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[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[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[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[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[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]; matrix[2][2] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[1] * quaternion[1];
} }
/* /*
==================== ====================
MatrixCopy MatrixCopy
==================== ====================
*/ */
void MatrixCopy( float in[3][4], float out[3][4] ) void MatrixCopy( float in[3][4], float out[3][4] )
{ {
memcpy( out, in, sizeof( float ) * 3 * 4 ); memcpy( out, in, sizeof( float ) * 3 * 4 );
} }

View File

@ -1,312 +1,312 @@
//========= Copyright ? 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright ? 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
// Triangle rendering, if any // Triangle rendering, if any
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
// Triangle rendering apis are in gEngfuncs.pTriAPI // Triangle rendering apis are in gEngfuncs.pTriAPI
#include "const.h" #include "const.h"
#include "entity_state.h" #include "entity_state.h"
#include "cl_entity.h" #include "cl_entity.h"
#include "triangleapi.h" #include "triangleapi.h"
#include "rain.h" #include "rain.h"
#ifdef _WIN32 #ifdef _WIN32
#define DLLEXPORT __declspec( dllexport ) #define DLLEXPORT __declspec( dllexport )
#else #else
#define DLLEXPORT #define DLLEXPORT
#endif #endif
extern "C" extern "C"
{ {
void DLLEXPORT HUD_DrawNormalTriangles( void ); void DLLEXPORT HUD_DrawNormalTriangles( void );
void DLLEXPORT HUD_DrawTransparentTriangles( void ); void DLLEXPORT HUD_DrawTransparentTriangles( void );
}; };
//#define TEST_IT //#define TEST_IT
#if defined( TEST_IT ) #if defined( TEST_IT )
/* /*
================= =================
Draw_Triangles Draw_Triangles
Example routine. Draws a sprite offset from the player origin. Example routine. Draws a sprite offset from the player origin.
================= =================
*/ */
void Draw_Triangles( void ) void Draw_Triangles( void )
{ {
cl_entity_t *player; cl_entity_t *player;
vec3_t org; vec3_t org;
// Load it up with some bogus data // Load it up with some bogus data
player = gEngfuncs.GetLocalPlayer(); player = gEngfuncs.GetLocalPlayer();
if ( !player ) if ( !player )
return; return;
org = player->origin; org = player->origin;
org.x += 50; org.x += 50;
org.y += 50; org.y += 50;
if (gHUD.m_hsprCursor == 0) if (gHUD.m_hsprCursor == 0)
{ {
char sz[256]; char sz[256];
sprintf( sz, "sprites/cursor.spr" ); sprintf( sz, "sprites/cursor.spr" );
gHUD.m_hsprCursor = SPR_Load( sz ); gHUD.m_hsprCursor = SPR_Load( sz );
} }
if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 )) if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ))
{ {
return; return;
} }
// Create a triangle, sigh // Create a triangle, sigh
gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); gEngfuncs.pTriAPI->CullFace( TRI_NONE );
gEngfuncs.pTriAPI->Begin( TRI_QUADS ); gEngfuncs.pTriAPI->Begin( TRI_QUADS );
// Overload p->color with index into tracer palette, p->packedColor with brightness // Overload p->color with index into tracer palette, p->packedColor with brightness
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 );
// UNDONE: This gouraud shading causes tracers to disappear on some cards (permedia2) // UNDONE: This gouraud shading causes tracers to disappear on some cards (permedia2)
gEngfuncs.pTriAPI->Brightness( 1 ); gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f( org.x, org.y, org.z ); gEngfuncs.pTriAPI->Vertex3f( org.x, org.y, org.z );
gEngfuncs.pTriAPI->Brightness( 1 ); gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
gEngfuncs.pTriAPI->Vertex3f( org.x, org.y + 50, org.z ); gEngfuncs.pTriAPI->Vertex3f( org.x, org.y + 50, org.z );
gEngfuncs.pTriAPI->Brightness( 1 ); gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y + 50, org.z ); gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y + 50, org.z );
gEngfuncs.pTriAPI->Brightness( 1 ); gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y, org.z ); gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y, org.z );
gEngfuncs.pTriAPI->End(); gEngfuncs.pTriAPI->End();
gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
} }
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
extern "C" { extern "C" {
#endif #endif
void AngleMatrix (const float angles[3], float (*matrix)[4]); void AngleMatrix (const float angles[3], float (*matrix)[4]);
void VectorTransform (const float in1[3], float in2[3][4], float out[3]); void VectorTransform (const float in1[3], float in2[3][4], float out[3]);
#ifdef _MSC_VER #ifdef _MSC_VER
} }
#endif #endif
void SetPoint( float x, float y, float z, float (*matrix)[4]) void SetPoint( float x, float y, float z, float (*matrix)[4])
{ {
vec3_t point, result; vec3_t point, result;
point[0] = x; point[0] = x;
point[1] = y; point[1] = y;
point[2] = z; point[2] = z;
VectorTransform(point, matrix, result); VectorTransform(point, matrix, result);
gEngfuncs.pTriAPI->Vertex3f(result[0], result[1], result[2]); gEngfuncs.pTriAPI->Vertex3f(result[0], result[1], result[2]);
} }
/* /*
================================= =================================
DrawRain DrawRain
draw raindrips and snowflakes draw raindrips and snowflakes
================================= =================================
*/ */
void DrawRain( void ) void DrawRain( void )
{ {
if (FirstChainDrip.p_Next == NULL) if (FirstChainDrip.p_Next == NULL)
return; // no drips to draw return; // no drips to draw
float visibleHeight = Rain.globalHeight - SNOWFADEDIST; float visibleHeight = Rain.globalHeight - SNOWFADEDIST;
// usual triapi stuff // usual triapi stuff
HSPRITE hsprTexture; HSPRITE hsprTexture;
if( Rain.weatherMode == 0 ) if( Rain.weatherMode == 0 )
hsprTexture = LoadSprite("sprites/effects/rain.spr"); hsprTexture = LoadSprite("sprites/effects/rain.spr");
else else
hsprTexture = LoadSprite("sprites/effects/snowflake.spr"); hsprTexture = LoadSprite("sprites/effects/snowflake.spr");
const model_s *pTexture = gEngfuncs.GetSpritePointer(hsprTexture); const model_s *pTexture = gEngfuncs.GetSpritePointer(hsprTexture);
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)pTexture, 0 ); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)pTexture, 0 );
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); gEngfuncs.pTriAPI->CullFace( TRI_NONE );
// go through drips list // go through drips list
cl_drip* Drip = FirstChainDrip.p_Next; cl_drip* Drip = FirstChainDrip.p_Next;
cl_entity_t *player = gEngfuncs.GetLocalPlayer(); cl_entity_t *player = gEngfuncs.GetLocalPlayer();
if ( Rain.weatherMode == 0 ) // draw rain if ( Rain.weatherMode == 0 ) // draw rain
{ {
while (Drip != NULL) while (Drip != NULL)
{ {
cl_drip* nextdDrip = Drip->p_Next; cl_drip* nextdDrip = Drip->p_Next;
Vector2D toPlayer; Vector2D toPlayer;
toPlayer.x = player->origin[0] - Drip->origin[0]; toPlayer.x = player->origin[0] - Drip->origin[0];
toPlayer.y = player->origin[1] - Drip->origin[1]; toPlayer.y = player->origin[1] - Drip->origin[1];
toPlayer = toPlayer.Normalize(); toPlayer = toPlayer.Normalize();
toPlayer.x *= DRIP_SPRITE_HALFWIDTH; toPlayer.x *= DRIP_SPRITE_HALFWIDTH;
toPlayer.y *= DRIP_SPRITE_HALFWIDTH; toPlayer.y *= DRIP_SPRITE_HALFWIDTH;
float shiftX = (Drip->xDelta / DRIPSPEED) * DRIP_SPRITE_HALFHEIGHT; float shiftX = (Drip->xDelta / DRIPSPEED) * DRIP_SPRITE_HALFHEIGHT;
float shiftY = (Drip->yDelta / DRIPSPEED) * DRIP_SPRITE_HALFHEIGHT; float shiftY = (Drip->yDelta / DRIPSPEED) * DRIP_SPRITE_HALFHEIGHT;
// --- draw triangle -------------------------- // --- draw triangle --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, Drip->alpha ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, Drip->alpha );
gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES ); gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); 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->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->TexCoord2f( 0.5, 1 );
gEngfuncs.pTriAPI->Vertex3f( Drip->origin[0] + shiftX, Drip->origin[1] + shiftY, Drip->origin[2]-DRIP_SPRITE_HALFHEIGHT ); gEngfuncs.pTriAPI->Vertex3f( Drip->origin[0] + shiftX, Drip->origin[1] + shiftY, Drip->origin[2]-DRIP_SPRITE_HALFHEIGHT );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); 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->Vertex3f( Drip->origin[0]+toPlayer.y - shiftX, Drip->origin[1]-toPlayer.x - shiftY, Drip->origin[2]+DRIP_SPRITE_HALFHEIGHT);
gEngfuncs.pTriAPI->End(); gEngfuncs.pTriAPI->End();
// --- draw triangle end ---------------------- // --- draw triangle end ----------------------
Drip = nextdDrip; Drip = nextdDrip;
} }
} }
else // draw snow else // draw snow
{ {
vec3_t normal; vec3_t normal;
gEngfuncs.GetViewAngles((float*)normal); gEngfuncs.GetViewAngles((float*)normal);
float matrix[3][4]; float matrix[3][4];
AngleMatrix (normal, matrix); // calc view matrix AngleMatrix (normal, matrix); // calc view matrix
while (Drip != NULL) while (Drip != NULL)
{ {
cl_drip* nextdDrip = Drip->p_Next; cl_drip* nextdDrip = Drip->p_Next;
matrix[0][3] = Drip->origin[0]; // write origin to matrix matrix[0][3] = Drip->origin[0]; // write origin to matrix
matrix[1][3] = Drip->origin[1]; matrix[1][3] = Drip->origin[1];
matrix[2][3] = Drip->origin[2]; matrix[2][3] = Drip->origin[2];
// apply start fading effect // apply start fading effect
float alpha = (Drip->origin[2] <= visibleHeight) ? Drip->alpha : ((Rain.globalHeight - Drip->origin[2]) / (float)SNOWFADEDIST) * Drip->alpha; float alpha = (Drip->origin[2] <= visibleHeight) ? Drip->alpha : ((Rain.globalHeight - Drip->origin[2]) / (float)SNOWFADEDIST) * Drip->alpha;
// --- draw quad -------------------------- // --- draw quad --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, alpha ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, alpha );
gEngfuncs.pTriAPI->Begin( TRI_QUADS ); gEngfuncs.pTriAPI->Begin( TRI_QUADS );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
SetPoint(0, SNOW_SPRITE_HALFSIZE ,SNOW_SPRITE_HALFSIZE, matrix); SetPoint(0, SNOW_SPRITE_HALFSIZE ,SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
SetPoint(0, SNOW_SPRITE_HALFSIZE ,-SNOW_SPRITE_HALFSIZE, matrix); SetPoint(0, SNOW_SPRITE_HALFSIZE ,-SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
SetPoint(0, -SNOW_SPRITE_HALFSIZE ,-SNOW_SPRITE_HALFSIZE, matrix); SetPoint(0, -SNOW_SPRITE_HALFSIZE ,-SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
SetPoint(0, -SNOW_SPRITE_HALFSIZE ,SNOW_SPRITE_HALFSIZE, matrix); SetPoint(0, -SNOW_SPRITE_HALFSIZE ,SNOW_SPRITE_HALFSIZE, matrix);
gEngfuncs.pTriAPI->End(); gEngfuncs.pTriAPI->End();
// --- draw quad end ---------------------- // --- draw quad end ----------------------
Drip = nextdDrip; Drip = nextdDrip;
} }
} }
} }
/* /*
================================= =================================
DrawFXObjects DrawFXObjects
================================= =================================
*/ */
void DrawFXObjects( void ) void DrawFXObjects( void )
{ {
if (FirstChainFX.p_Next == NULL) if (FirstChainFX.p_Next == NULL)
return; // no objects to draw return; // no objects to draw
float curtime = gEngfuncs.GetClientTime(); float curtime = gEngfuncs.GetClientTime();
// usual triapi stuff // usual triapi stuff
HSPRITE hsprTexture = LoadSprite("sprites/effects/ripple.spr"); HSPRITE hsprTexture = LoadSprite("sprites/effects/ripple.spr");
const model_s *pTexture = gEngfuncs.GetSpritePointer( hsprTexture ); const model_s *pTexture = gEngfuncs.GetSpritePointer( hsprTexture );
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)pTexture, 0 ); gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)pTexture, 0 );
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
gEngfuncs.pTriAPI->CullFace( TRI_NONE ); gEngfuncs.pTriAPI->CullFace( TRI_NONE );
// go through objects list // go through objects list
cl_rainfx* curFX = FirstChainFX.p_Next; cl_rainfx* curFX = FirstChainFX.p_Next;
while (curFX != NULL) while (curFX != NULL)
{ {
cl_rainfx* nextFX = curFX->p_Next; cl_rainfx* nextFX = curFX->p_Next;
// fadeout // fadeout
float alpha = ((curFX->birthTime + curFX->life - curtime) / curFX->life) * curFX->alpha; float alpha = ((curFX->birthTime + curFX->life - curtime) / curFX->life) * curFX->alpha;
float size = (curtime - curFX->birthTime) * MAXRINGHALFSIZE; float size = (curtime - curFX->birthTime) * MAXRINGHALFSIZE;
// --- draw quad -------------------------- // --- draw quad --------------------------
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, alpha ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, alpha );
gEngfuncs.pTriAPI->Begin( TRI_QUADS ); gEngfuncs.pTriAPI->Begin( TRI_QUADS );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] - size, curFX->origin[1] - size, curFX->origin[2]); gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] - size, curFX->origin[1] - size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] - size, curFX->origin[1] + size, curFX->origin[2]); gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] - size, curFX->origin[1] + size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] + size, curFX->origin[1] + size, curFX->origin[2]); gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] + size, curFX->origin[1] + size, curFX->origin[2]);
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] + size, curFX->origin[1] - size, curFX->origin[2]); gEngfuncs.pTriAPI->Vertex3f(curFX->origin[0] + size, curFX->origin[1] - size, curFX->origin[2]);
gEngfuncs.pTriAPI->End(); gEngfuncs.pTriAPI->End();
// --- draw quad end ---------------------- // --- draw quad end ----------------------
curFX = nextFX; curFX = nextFX;
} }
} }
/* /*
================= =================
HUD_DrawNormalTriangles HUD_DrawNormalTriangles
Non-transparent triangles-- add them here Non-transparent triangles-- add them here
================= =================
*/ */
void DLLEXPORT HUD_DrawNormalTriangles( void ) void DLLEXPORT HUD_DrawNormalTriangles( void )
{ {
gHUD.m_Spectator.DrawOverview(); gHUD.m_Spectator.DrawOverview();
#if defined( TEST_IT ) #if defined( TEST_IT )
// Draw_Triangles(); // Draw_Triangles();
#endif #endif
} }
/* /*
================= =================
HUD_DrawTransparentTriangles HUD_DrawTransparentTriangles
Render any triangles with transparent rendermode needs here Render any triangles with transparent rendermode needs here
================= =================
*/ */
void DLLEXPORT HUD_DrawTransparentTriangles( void ) void DLLEXPORT HUD_DrawTransparentTriangles( void )
{ {
ProcessFXObjects(); ProcessFXObjects();
ProcessRain(); ProcessRain();
DrawRain(); DrawRain();
DrawFXObjects(); DrawFXObjects();
#if defined( TEST_IT ) #if defined( TEST_IT )
// Draw_Triangles(); // Draw_Triangles();
#endif #endif
} }

View File

@ -1,198 +1,198 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// //
// util.cpp // util.cpp
// //
// implementation of class-less helper functions // implementation of class-less helper functions
// //
#include "stdio.h" #include "stdio.h"
#include "stdlib.h" #include "stdlib.h"
#include "math.h" #include "math.h"
#include "hud.h" #include "hud.h"
#include "cl_util.h" #include "cl_util.h"
#include <string.h> #include <string.h>
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif #endif
//vec3_t vec3_origin( 0, 0, 0 ); //vec3_t vec3_origin( 0, 0, 0 );
double sqrt(double x); double sqrt(double x);
float Length(const float *v) float Length(const float *v)
{ {
int i; int i;
float length; float length;
length = 0; length = 0;
for (i=0 ; i< 3 ; i++) for (i=0 ; i< 3 ; i++)
length += v[i]*v[i]; length += v[i]*v[i];
length = sqrt (length); // FIXME length = sqrt (length); // FIXME
return length; return length;
} }
void VectorAngles( const float *forward, float *angles ) void VectorAngles( const float *forward, float *angles )
{ {
float tmp, yaw, pitch; float tmp, yaw, pitch;
if (forward[1] == 0 && forward[0] == 0) if (forward[1] == 0 && forward[0] == 0)
{ {
yaw = 0; yaw = 0;
if (forward[2] > 0) if (forward[2] > 0)
pitch = 90; pitch = 90;
else else
pitch = 270; pitch = 270;
} }
else else
{ {
yaw = (atan2(forward[1], forward[0]) * 180 / M_PI); yaw = (atan2(forward[1], forward[0]) * 180 / M_PI);
if (yaw < 0) if (yaw < 0)
yaw += 360; yaw += 360;
tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]); tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]);
pitch = (atan2(forward[2], tmp) * 180 / M_PI); pitch = (atan2(forward[2], tmp) * 180 / M_PI);
if (pitch < 0) if (pitch < 0)
pitch += 360; pitch += 360;
} }
angles[0] = pitch; angles[0] = pitch;
angles[1] = yaw; angles[1] = yaw;
angles[2] = 0; angles[2] = 0;
} }
float VectorNormalize (float *v) float VectorNormalize (float *v)
{ {
float length, ilength; float length, ilength;
length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
length = sqrt (length); // FIXME length = sqrt (length); // FIXME
if (length) if (length)
{ {
ilength = 1/length; ilength = 1/length;
v[0] *= ilength; v[0] *= ilength;
v[1] *= ilength; v[1] *= ilength;
v[2] *= ilength; v[2] *= ilength;
} }
return length; return length;
} }
void VectorInverse ( float *v ) void VectorInverse ( float *v )
{ {
v[0] = -v[0]; v[0] = -v[0];
v[1] = -v[1]; v[1] = -v[1];
v[2] = -v[2]; v[2] = -v[2];
} }
void VectorScale (const float *in, float scale, float *out) void VectorScale (const float *in, float scale, float *out)
{ {
out[0] = in[0]*scale; out[0] = in[0]*scale;
out[1] = in[1]*scale; out[1] = in[1]*scale;
out[2] = in[2]*scale; out[2] = in[2]*scale;
} }
void VectorMA (const float *veca, float scale, const float *vecb, float *vecc) void VectorMA (const float *veca, float scale, const float *vecb, float *vecc)
{ {
vecc[0] = veca[0] + scale*vecb[0]; vecc[0] = veca[0] + scale*vecb[0];
vecc[1] = veca[1] + scale*vecb[1]; vecc[1] = veca[1] + scale*vecb[1];
vecc[2] = veca[2] + scale*vecb[2]; vecc[2] = veca[2] + scale*vecb[2];
} }
HSPRITE LoadSprite(const char *pszName) HSPRITE LoadSprite(const char *pszName)
{ {
int i; int i;
char sz[256]; char sz[256];
if (ScreenWidth < 640) if (ScreenWidth < 640)
i = 320; i = 320;
else else
i = 640; i = 640;
sprintf(sz, pszName, i); sprintf(sz, pszName, i);
return SPR_Load(sz); return SPR_Load(sz);
} }
int HUD_GetSpriteIndexByName( const char *sz ) int HUD_GetSpriteIndexByName( const char *sz )
{ {
return gHUD.GetSpriteIndex(sz); return gHUD.GetSpriteIndex(sz);
} }
HSPRITE HUD_GetSprite( int index ) HSPRITE HUD_GetSprite( int index )
{ {
return gHUD.GetSprite(index); return gHUD.GetSprite(index);
} }
wrect_t HUD_GetSpriteRect( int index ) wrect_t HUD_GetSpriteRect( int index )
{ {
return gHUD.GetSpriteRect( index ); return gHUD.GetSpriteRect( index );
} }
float g_ColorBlue[3] = { 0.6, 0.8, 1.0 }; float g_ColorBlue[3] = { 0.6, 0.8, 1.0 };
float g_ColorRed[3] = { 1.0, 0.25, 0.25 }; float g_ColorRed[3] = { 1.0, 0.25, 0.25 };
float g_ColorGreen[3] = { 0.6, 1.0, 0.6 }; float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 }; float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 }; float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
float *GetClientColor( int clientIndex ) float *GetClientColor( int clientIndex )
{ {
switch ( g_PlayerExtraInfo[clientIndex].teamnumber ) switch ( g_PlayerExtraInfo[clientIndex].teamnumber )
{ {
case TEAM_TERRORIST: return g_ColorRed; case TEAM_TERRORIST: return g_ColorRed;
case TEAM_CT: return g_ColorBlue; case TEAM_CT: return g_ColorBlue;
case TEAM_SPECTATOR: case TEAM_SPECTATOR:
case TEAM_UNASSIGNED: return g_ColorYellow; case TEAM_UNASSIGNED: return g_ColorYellow;
case 4: return g_ColorGreen; case 4: return g_ColorGreen;
default: return g_ColorGrey; default: return g_ColorGrey;
} }
} }
void GetTeamColor(int &r, int &g, int &b, int teamIndex) void GetTeamColor(int &r, int &g, int &b, int teamIndex)
{ {
r = 255; r = 255;
g = 255; g = 255;
b = 255; b = 255;
switch( teamIndex ) switch( teamIndex )
{ {
case TEAM_TERRORIST: case TEAM_TERRORIST:
r *= g_ColorRed[0]; r *= g_ColorRed[0];
g *= g_ColorRed[1]; g *= g_ColorRed[1];
b *= g_ColorRed[2]; b *= g_ColorRed[2];
break; break;
case TEAM_CT: case TEAM_CT:
r *= g_ColorBlue[0]; r *= g_ColorBlue[0];
g *= g_ColorBlue[1]; g *= g_ColorBlue[1];
b *= g_ColorBlue[2]; b *= g_ColorBlue[2];
break; break;
case TEAM_SPECTATOR: case TEAM_SPECTATOR:
case TEAM_UNASSIGNED: case TEAM_UNASSIGNED:
r *= g_ColorYellow[0]; r *= g_ColorYellow[0];
g *= g_ColorYellow[1]; g *= g_ColorYellow[1];
b *= g_ColorYellow[2]; b *= g_ColorYellow[2];
break; break;
default: default:
r *= g_ColorGrey[0]; r *= g_ColorGrey[0];
g *= g_ColorGrey[1]; g *= g_ColorGrey[1];
b *= g_ColorGrey[2]; b *= g_ColorGrey[2];
break; 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. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined ( BEAMDEFH ) #if !defined ( BEAMDEFH )
#define BEAMDEFH #define BEAMDEFH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
#define FBEAM_STARTENTITY 0x00000001 #define FBEAM_STARTENTITY 0x00000001
#define FBEAM_ENDENTITY 0x00000002 #define FBEAM_ENDENTITY 0x00000002
#define FBEAM_FADEIN 0x00000004 #define FBEAM_FADEIN 0x00000004
#define FBEAM_FADEOUT 0x00000008 #define FBEAM_FADEOUT 0x00000008
#define FBEAM_SINENOISE 0x00000010 #define FBEAM_SINENOISE 0x00000010
#define FBEAM_SOLID 0x00000020 #define FBEAM_SOLID 0x00000020
#define FBEAM_SHADEIN 0x00000040 #define FBEAM_SHADEIN 0x00000040
#define FBEAM_SHADEOUT 0x00000080 #define FBEAM_SHADEOUT 0x00000080
#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet? #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_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet?
#define FBEAM_ISACTIVE 0x40000000 #define FBEAM_ISACTIVE 0x40000000
#define FBEAM_FOREVER 0x80000000 #define FBEAM_FOREVER 0x80000000
typedef struct beam_s BEAM; typedef struct beam_s BEAM;
struct beam_s struct beam_s
{ {
BEAM *next; BEAM *next;
int type; int type;
int flags; int flags;
vec3_t source; vec3_t source;
vec3_t target; vec3_t target;
vec3_t delta; vec3_t delta;
float t; // 0 .. 1 over lifetime of beam float t; // 0 .. 1 over lifetime of beam
float freq; float freq;
float die; float die;
float width; float width;
float amplitude; float amplitude;
float r, g, b; float r, g, b;
float brightness; float brightness;
float speed; float speed;
float frameRate; float frameRate;
float frame; float frame;
int segments; int segments;
int startEntity; int startEntity;
int endEntity; int endEntity;
int modelIndex; int modelIndex;
int frameCount; int frameCount;
struct model_s *pFollowModel; struct model_s *pFollowModel;
struct particle_s *particles; struct particle_s *particles;
}; };
#endif #endif

View File

@ -1,117 +1,117 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// cl_entity.h // cl_entity.h
#if !defined( CL_ENTITYH ) #if !defined( CL_ENTITYH )
#define CL_ENTITYH #define CL_ENTITYH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
typedef struct efrag_s typedef struct efrag_s
{ {
struct mleaf_s *leaf; struct mleaf_s *leaf;
struct efrag_s *leafnext; struct efrag_s *leafnext;
struct cl_entity_s *entity; struct cl_entity_s *entity;
struct efrag_s *entnext; struct efrag_s *entnext;
} efrag_t; } efrag_t;
typedef struct typedef struct
{ {
byte mouthopen; // 0 = mouth closed, 255 = mouth agape byte mouthopen; // 0 = mouth closed, 255 = mouth agape
byte sndcount; // counter for running average byte sndcount; // counter for running average
int sndavg; // running average int sndavg; // running average
} mouth_t; } mouth_t;
typedef struct typedef struct
{ {
float prevanimtime; float prevanimtime;
float sequencetime; float sequencetime;
byte prevseqblending[2]; byte prevseqblending[2];
vec3_t prevorigin; vec3_t prevorigin;
vec3_t prevangles; vec3_t prevangles;
int prevsequence; int prevsequence;
float prevframe; float prevframe;
byte prevcontroller[4]; byte prevcontroller[4];
byte prevblending[2]; byte prevblending[2];
} latchedvars_t; } latchedvars_t;
typedef struct typedef struct
{ {
// Time stamp for this movement // Time stamp for this movement
float animtime; float animtime;
vec3_t origin; vec3_t origin;
vec3_t angles; vec3_t angles;
} position_history_t; } position_history_t;
typedef struct cl_entity_s cl_entity_t; typedef struct cl_entity_s cl_entity_t;
#define HISTORY_MAX 64 // Must be power of 2 #define HISTORY_MAX 64 // Must be power of 2
#define HISTORY_MASK ( HISTORY_MAX - 1 ) #define HISTORY_MASK ( HISTORY_MAX - 1 )
#if !defined( ENTITY_STATEH ) #if !defined( ENTITY_STATEH )
#include "entity_state.h" #include "entity_state.h"
#endif #endif
#if !defined( PROGS_H ) #if !defined( PROGS_H )
#include "progs.h" #include "progs.h"
#endif #endif
struct cl_entity_s struct cl_entity_s
{ {
int index; // Index into cl_entities ( should match actual slot, but not necessarily ) int index; // Index into cl_entities ( should match actual slot, but not necessarily )
qboolean player; // True if this entity is a "player" 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 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 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 entity_state_t curstate; // The state information from the last message received from server
int current_position; // Last received history update index int current_position; // Last received history update index
position_history_t ph[ HISTORY_MAX ]; // History of position and angle updates for this player position_history_t ph[ HISTORY_MAX ]; // History of position and angle updates for this player
mouth_t mouth; // For synchronizing mouth movements. mouth_t mouth; // For synchronizing mouth movements.
latchedvars_t latched; // Variables used by studio model rendering routines latchedvars_t latched; // Variables used by studio model rendering routines
// Information based on interplocation, extrapolation, prediction, or just copied from last msg received. // Information based on interplocation, extrapolation, prediction, or just copied from last msg received.
// //
float lastmove; float lastmove;
// Actual render position and angles // Actual render position and angles
vec3_t origin; vec3_t origin;
vec3_t angles; vec3_t angles;
// Attachment points // Attachment points
vec3_t attachment[4]; vec3_t attachment[4];
// Other entity local information // Other entity local information
int trivial_accept; int trivial_accept;
struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model
struct efrag_s *efrag; // linked list of efrags struct efrag_s *efrag; // linked list of efrags
struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split struct 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? 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 int visframe; // last frame this entity was found in an active leaf
colorVec cvFloorColor; colorVec cvFloorColor;
}; };
#endif // !CL_ENTITYH #endif // !CL_ENTITYH

View File

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

View File

@ -1,33 +1,33 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( CON_NPRINTH ) #if !defined( CON_NPRINTH )
#define CON_NPRINTH #define CON_NPRINTH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
typedef struct con_nprint_s typedef struct con_nprint_s
{ {
int index; // Row # int index; // Row #
float time_to_live; // # of seconds before it dissappears float time_to_live; // # of seconds before it dissappears
float color[ 3 ]; // RGB colors ( 0.0 -> 1.0 scale ) float color[ 3 ]; // RGB colors ( 0.0 -> 1.0 scale )
} con_nprint_t; } con_nprint_t;
void Con_NPrintf( int idx, char *fmt, ... ); void Con_NPrintf( int idx, char *fmt, ... );
void Con_NXPrintf( struct con_nprint_s *info, char *fmt, ... ); void Con_NXPrintf( struct con_nprint_s *info, char *fmt, ... );
#endif #endif

View File

@ -1,54 +1,54 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
/* crc.h */ /* crc.h */
#ifndef CRC_H #ifndef CRC_H
#define CRC_H #define CRC_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
// MD5 Hash // MD5 Hash
typedef struct typedef struct
{ {
unsigned int buf[4]; unsigned int buf[4];
unsigned int bits[2]; unsigned int bits[2];
unsigned char in[64]; unsigned char in[64];
} MD5Context_t; } MD5Context_t;
typedef unsigned long CRC32_t; typedef unsigned long CRC32_t;
void CRC32_Init(CRC32_t *pulCRC); void CRC32_Init(CRC32_t *pulCRC);
CRC32_t CRC32_Final(CRC32_t pulCRC); CRC32_t CRC32_Final(CRC32_t pulCRC);
void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len); void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len);
void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch);
int CRC_File(CRC32_t *crcvalue, char *pszFileName); int CRC_File(CRC32_t *crcvalue, char *pszFileName);
unsigned char COM_BlockSequenceCRCByte (unsigned char *base, int length, int sequence); unsigned char COM_BlockSequenceCRCByte (unsigned char *base, int length, int sequence);
void MD5Init(MD5Context_t *context); void MD5Init(MD5Context_t *context);
void MD5Update(MD5Context_t *context, unsigned char const *buf, void MD5Update(MD5Context_t *context, unsigned char const *buf,
unsigned int len); unsigned int len);
void MD5Final(unsigned char digest[16], MD5Context_t *context); void MD5Final(unsigned char digest[16], MD5Context_t *context);
void Transform(unsigned int buf[4], unsigned int const in[16]); 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]); 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]); char *MD5_Print(unsigned char hash[16]);
int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char *pCache, int nFileSize, int bSeed, unsigned int seed[4]); int MD5_Hash_CachedFile(unsigned char digest[16], unsigned char *pCache, int nFileSize, int bSeed, unsigned int seed[4]);
int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName); int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName);
#endif #endif

View File

@ -1,36 +1,36 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef CVARDEF_H #ifndef CVARDEF_H
#define CVARDEF_H #define CVARDEF_H
#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc #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_USERINFO (1<<1) // changes the client's info string
#define FCVAR_SERVER (1<<2) // notifies players when changed #define FCVAR_SERVER (1<<2) // notifies players when changed
#define FCVAR_EXTDLL (1<<3) // defined by external DLL #define FCVAR_EXTDLL (1<<3) // defined by external DLL
#define FCVAR_CLIENTDLL (1<<4) // defined by the client 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_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_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_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log #define FCVAR_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 typedef struct cvar_s
{ {
char *name; char *name;
char *string; char *string;
int flags; int flags;
float value; float value;
struct cvar_s *next; struct cvar_s *next;
} cvar_t; } cvar_t;
#endif #endif

View File

@ -1,33 +1,33 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined ( DEMO_APIH ) #if !defined ( DEMO_APIH )
#define DEMO_APIH #define DEMO_APIH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
typedef struct demo_api_s typedef struct demo_api_s
{ {
int ( *IsRecording ) ( void ); int ( *IsRecording ) ( void );
int ( *IsPlayingback ) ( void ); int ( *IsPlayingback ) ( void );
int ( *IsTimeDemo ) ( void ); int ( *IsTimeDemo ) ( void );
void ( *WriteBuffer ) ( int size, unsigned char *buffer ); void ( *WriteBuffer ) ( int size, unsigned char *buffer );
} demo_api_t; } demo_api_t;
extern demo_api_t demoapi; extern demo_api_t demoapi;
#endif #endif

View File

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

View File

@ -1,35 +1,35 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined ( DLIGHTH ) #if !defined ( DLIGHTH )
#define DLIGHTH #define DLIGHTH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
typedef struct dlight_s typedef struct dlight_s
{ {
vec3_t origin; vec3_t origin;
float radius; float radius;
color24 color; color24 color;
float die; // stop lighting after this time float die; // stop lighting after this time
float decay; // drop this each second float decay; // drop this each second
float minlight; // don't add when contributing less float minlight; // don't add when contributing less
int key; int key;
qboolean dark; // subtracts light instead of adding qboolean dark; // subtracts light instead of adding
} dlight_t; } dlight_t;
#endif #endif

View File

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

View File

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

View File

@ -1,195 +1,195 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( ENTITY_STATEH ) #if !defined( ENTITY_STATEH )
#define ENTITY_STATEH #define ENTITY_STATEH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
// For entityType below // For entityType below
#define ENTITY_NORMAL (1<<0) #define ENTITY_NORMAL (1<<0)
#define ENTITY_BEAM (1<<1) #define ENTITY_BEAM (1<<1)
// Entity state is used for the baseline and for delta compression of a packet of // Entity state is used for the baseline and for delta compression of a packet of
// entities that is sent to a client. // entities that is sent to a client.
typedef struct entity_state_s entity_state_t; typedef struct entity_state_s entity_state_t;
struct entity_state_s struct entity_state_s
{ {
// Fields which are filled in by routines outside of delta compression // Fields which are filled in by routines outside of delta compression
int entityType; int entityType;
// Index into cl_entities array for this entity. // Index into cl_entities array for this entity.
int number; int number;
float msg_time; float msg_time;
// Message number last time the player/entity state was updated. // Message number last time the player/entity state was updated.
int messagenum; int messagenum;
// Fields which can be transitted and reconstructed over the network stream // Fields which can be transitted and reconstructed over the network stream
vec3_t origin; vec3_t origin;
vec3_t angles; vec3_t angles;
int modelindex; int modelindex;
int sequence; int sequence;
float frame; float frame;
int colormap; int colormap;
short skin; short skin;
short solid; short solid;
int effects; int effects;
float scale; float scale;
byte eflags; byte eflags;
// Render information // Render information
int rendermode; int rendermode;
int renderamt; int renderamt;
color24 rendercolor; color24 rendercolor;
int renderfx; int renderfx;
int movetype; int movetype;
float animtime; float animtime;
float framerate; float framerate;
int body; int body;
byte controller[4]; byte controller[4];
byte blending[4]; byte blending[4];
vec3_t velocity; vec3_t velocity;
// Send bbox down to client for use during prediction. // Send bbox down to client for use during prediction.
vec3_t mins; vec3_t mins;
vec3_t maxs; vec3_t maxs;
int aiment; int aiment;
// If owned by a player, the index of that player ( for projectiles ). // If owned by a player, the index of that player ( for projectiles ).
int owner; int owner;
// Friction, for prediction. // Friction, for prediction.
float friction; float friction;
// Gravity multiplier // Gravity multiplier
float gravity; float gravity;
// PLAYER SPECIFIC // PLAYER SPECIFIC
int team; int team;
int playerclass; int playerclass;
int health; int health;
qboolean spectator; qboolean spectator;
int weaponmodel; int weaponmodel;
int gaitsequence; int gaitsequence;
// If standing on conveyor, e.g. // If standing on conveyor, e.g.
vec3_t basevelocity; vec3_t basevelocity;
// Use the crouched hull, or the regular player hull. // Use the crouched hull, or the regular player hull.
int usehull; int usehull;
// Latched buttons last time state updated. // Latched buttons last time state updated.
int oldbuttons; int oldbuttons;
// -1 = in air, else pmove entity number // -1 = in air, else pmove entity number
int onground; int onground;
int iStepLeft; int iStepLeft;
// How fast we are falling // How fast we are falling
float flFallVelocity; float flFallVelocity;
float fov; float fov;
int weaponanim; int weaponanim;
// Parametric movement overrides // Parametric movement overrides
vec3_t startpos; vec3_t startpos;
vec3_t endpos; vec3_t endpos;
float impacttime; float impacttime;
float starttime; float starttime;
// For mods // For mods
int iuser1; int iuser1;
int iuser2; int iuser2;
int iuser3; int iuser3;
int iuser4; int iuser4;
float fuser1; float fuser1;
float fuser2; float fuser2;
float fuser3; float fuser3;
float fuser4; float fuser4;
vec3_t vuser1; vec3_t vuser1;
vec3_t vuser2; vec3_t vuser2;
vec3_t vuser3; vec3_t vuser3;
vec3_t vuser4; vec3_t vuser4;
}; };
#include "pm_info.h" #include "pm_info.h"
typedef struct clientdata_s typedef struct clientdata_s
{ {
vec3_t origin; vec3_t origin;
vec3_t velocity; vec3_t velocity;
int viewmodel; int viewmodel;
vec3_t punchangle; vec3_t punchangle;
int flags; int flags;
int waterlevel; int waterlevel;
int watertype; int watertype;
vec3_t view_ofs; vec3_t view_ofs;
float health; float health;
int bInDuck; int bInDuck;
int weapons; // remove? int weapons; // remove?
int flTimeStepSound; int flTimeStepSound;
int flDuckTime; int flDuckTime;
int flSwimTime; int flSwimTime;
int waterjumptime; int waterjumptime;
float maxspeed; float maxspeed;
float fov; float fov;
int weaponanim; int weaponanim;
int m_iId; int m_iId;
int ammo_shells; int ammo_shells;
int ammo_nails; int ammo_nails;
int ammo_cells; int ammo_cells;
int ammo_rockets; int ammo_rockets;
float m_flNextAttack; float m_flNextAttack;
int tfstate; int tfstate;
int pushmsec; int pushmsec;
int deadflag; int deadflag;
char physinfo[ MAX_PHYSINFO_STRING ]; char physinfo[ MAX_PHYSINFO_STRING ];
// For mods // For mods
int iuser1; int iuser1;
int iuser2; int iuser2;
int iuser3; int iuser3;
int iuser4; int iuser4;
float fuser1; float fuser1;
float fuser2; float fuser2;
float fuser3; float fuser3;
float fuser4; float fuser4;
vec3_t vuser1; vec3_t vuser1;
vec3_t vuser2; vec3_t vuser2;
vec3_t vuser3; vec3_t vuser3;
vec3_t vuser4; vec3_t vuser4;
} clientdata_t; } clientdata_t;
#include "weaponinfo.h" #include "weaponinfo.h"
typedef struct local_state_s typedef struct local_state_s
{ {
entity_state_t playerstate; entity_state_t playerstate;
clientdata_t client; clientdata_t client;
weapon_data_t weapondata[ 32 ]; weapon_data_t weapondata[ 32 ];
} local_state_t; } local_state_t;
#endif // !ENTITY_STATEH #endif // !ENTITY_STATEH

View File

@ -1,26 +1,26 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// entity_types.h // entity_types.h
#if !defined( ENTITY_TYPESH ) #if !defined( ENTITY_TYPESH )
#define ENTITY_TYPESH #define ENTITY_TYPESH
#define ET_NORMAL 0 #define ET_NORMAL 0
#define ET_PLAYER 1 #define ET_PLAYER 1
#define ET_TEMPENTITY 2 #define ET_TEMPENTITY 2
#define ET_BEAM 3 #define ET_BEAM 3
// BMODEL or SPRITE that was split across BSP nodes // BMODEL or SPRITE that was split across BSP nodes
#define ET_FRAGMENTED 4 #define ET_FRAGMENTED 4
#endif // !ENTITY_TYPESH #endif // !ENTITY_TYPESH

View File

@ -1,53 +1,53 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined ( EVENT_APIH ) #if !defined ( EVENT_APIH )
#define EVENT_APIH #define EVENT_APIH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
#define EVENT_API_VERSION 1 #define EVENT_API_VERSION 1
typedef struct event_api_s typedef struct event_api_s
{ {
int version; int version;
void ( *EV_PlaySound ) ( int ent, float *origin, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); 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 ); void ( *EV_StopSound ) ( int ent, int channel, const char *sample );
int ( *EV_FindModelIndex )( const char *pmodel ); int ( *EV_FindModelIndex )( const char *pmodel );
int ( *EV_IsLocal ) ( int playernum ); int ( *EV_IsLocal ) ( int playernum );
int ( *EV_LocalPlayerDucking ) ( void ); int ( *EV_LocalPlayerDucking ) ( void );
void ( *EV_LocalPlayerViewheight ) ( float * ); void ( *EV_LocalPlayerViewheight ) ( float * );
void ( *EV_LocalPlayerBounds ) ( int hull, float *mins, float *maxs ); void ( *EV_LocalPlayerBounds ) ( int hull, float *mins, float *maxs );
int ( *EV_IndexFromTrace) ( struct pmtrace_s *pTrace ); int ( *EV_IndexFromTrace) ( struct pmtrace_s *pTrace );
struct physent_s *( *EV_GetPhysent ) ( int idx ); struct physent_s *( *EV_GetPhysent ) ( int idx );
void ( *EV_SetUpPlayerPrediction ) ( int dopred, int bIncludeLocalClient ); void ( *EV_SetUpPlayerPrediction ) ( int dopred, int bIncludeLocalClient );
void ( *EV_PushPMStates ) ( void ); void ( *EV_PushPMStates ) ( void );
void ( *EV_PopPMStates ) ( void ); void ( *EV_PopPMStates ) ( void );
void ( *EV_SetSolidPlayers ) (int playernum); void ( *EV_SetSolidPlayers ) (int playernum);
void ( *EV_SetTraceHull ) ( int hull ); void ( *EV_SetTraceHull ) ( int hull );
void ( *EV_PlayerTrace ) ( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr ); void ( *EV_PlayerTrace ) ( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr );
void ( *EV_WeaponAnimation ) ( int sequence, int body ); void ( *EV_WeaponAnimation ) ( int sequence, int body );
unsigned short ( *EV_PrecacheEvent ) ( int type, const char* psz ); 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 ); 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 ); const char *( *EV_TraceTexture ) ( int ground, float *vstart, float *vend );
void ( *EV_StopAllSounds ) ( int entnum, int entchannel ); void ( *EV_StopAllSounds ) ( int entnum, int entchannel );
void ( *EV_KillEvents ) ( int entnum, const char *eventname ); void ( *EV_KillEvents ) ( int entnum, const char *eventname );
} event_api_t; } event_api_t;
extern event_api_t eventapi; extern event_api_t eventapi;
#endif #endif

View File

@ -1,52 +1,52 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( EVENT_ARGSH ) #if !defined( EVENT_ARGSH )
#define EVENT_ARGSH #define EVENT_ARGSH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
// Event was invoked with stated origin // Event was invoked with stated origin
#define FEVENT_ORIGIN ( 1<<0 ) #define FEVENT_ORIGIN ( 1<<0 )
// Event was invoked with stated angles // Event was invoked with stated angles
#define FEVENT_ANGLES ( 1<<1 ) #define FEVENT_ANGLES ( 1<<1 )
typedef struct event_args_s typedef struct event_args_s
{ {
int flags; int flags;
// Transmitted // Transmitted
int entindex; int entindex;
float origin[3]; float origin[3];
float angles[3]; float angles[3];
float velocity[3]; float velocity[3];
int ducking; int ducking;
float fparam1; float fparam1;
float fparam2; float fparam2;
int iparam1; int iparam1;
int iparam2; int iparam2;
int bparam1; int bparam1;
int bparam2; int bparam2;
} event_args_t; } event_args_t;
#endif #endif

View File

@ -1,49 +1,49 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( EVENT_FLAGSH ) #if !defined( EVENT_FLAGSH )
#define EVENT_FLAGSH #define EVENT_FLAGSH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
// Skip local host for event send. // Skip local host for event send.
#define FEV_NOTHOST (1<<0) #define FEV_NOTHOST (1<<0)
// Send the event reliably. You must specify the origin and angles and use // 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 // 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 // that depends on the event origin/angles. I.e., the origin/angles are not
// taken from the invoking edict for reliable events. // taken from the invoking edict for reliable events.
#define FEV_RELIABLE (1<<1) #define FEV_RELIABLE (1<<1)
// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC // 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. ). // sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ).
#define FEV_GLOBAL (1<<2) #define FEV_GLOBAL (1<<2)
// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate // If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate
// //
#define FEV_UPDATE (1<<3) #define FEV_UPDATE (1<<3)
// Only send to entity specified as the invoker // Only send to entity specified as the invoker
#define FEV_HOSTONLY (1<<4) #define FEV_HOSTONLY (1<<4)
// Only send if the event was created on the server. // Only send if the event was created on the server.
#define FEV_SERVER (1<<5) #define FEV_SERVER (1<<5)
// Only issue event client side ( from shared code ) // Only issue event client side ( from shared code )
#define FEV_CLIENT (1<<6) #define FEV_CLIENT (1<<6)
#endif #endif

View File

@ -1,50 +1,50 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
// exefuncs.h // exefuncs.h
#ifndef EXEFUNCS_H #ifndef EXEFUNCS_H
#define EXEFUNCS_H #define EXEFUNCS_H
// Engine hands this to DLLs for functionality callbacks // Engine hands this to DLLs for functionality callbacks
typedef struct exefuncs_s typedef struct exefuncs_s
{ {
int fMMX; int fMMX;
int iCPUMhz; int iCPUMhz;
void (*unused1)(void); void (*unused1)(void);
void (*unused2)(void); void (*unused2)(void);
void (*unused3)(void); void (*unused3)(void);
void (*unused4)(void); void (*unused4)(void);
void (*VID_ForceLockState)(int lk); void (*VID_ForceLockState)(int lk);
int (*VID_ForceUnlockedAndReturnState)(void); int (*VID_ForceUnlockedAndReturnState)(void);
void (*unused5)(void); void (*unused5)(void);
void (*unused6)(void); void (*unused6)(void);
void (*unused7)(void); void (*unused7)(void);
void (*unused8)(void); void (*unused8)(void);
void (*unused9)(void); void (*unused9)(void);
void (*unused10)(void); void (*unused10)(void);
void (*unused11)(void); void (*unused11)(void);
void (*unused12)(void); void (*unused12)(void);
void (*unused13)(void); void (*unused13)(void);
void (*unused14)(void); void (*unused14)(void);
void (*unused15)(void); void (*unused15)(void);
void (*ErrorMessage)(int nLevel, const char *pszErrorMessage); void (*ErrorMessage)(int nLevel, const char *pszErrorMessage);
void (*unused16)(void); void (*unused16)(void);
void (*Sys_Printf)(char *fmt, ...); void (*Sys_Printf)(char *fmt, ...);
void (*unused17)(void); void (*unused17)(void);
void (*unused18)(void); void (*unused18)(void);
void (*unused19)(void); void (*unused19)(void);
void (*unused20)(void); void (*unused20)(void);
void (*unused21)(void); void (*unused21)(void);
void (*unused22)(void); void (*unused22)(void);
void (*unused23)(void); void (*unused23)(void);
void (*unused24)(void); void (*unused24)(void);
void (*unused25)(void); void (*unused25)(void);
void (*unused26)(void); void (*unused26)(void);
void (*unused27)(void); void (*unused27)(void);
} exefuncs_t; } exefuncs_t;
#endif #endif

View File

@ -1,57 +1,57 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
// hltv.h // hltv.h
// all shared consts between server, clients and proxy // all shared consts between server, clients and proxy
#ifndef HLTV_H #ifndef HLTV_H
#define HLTV_H #define HLTV_H
#define TYPE_CLIENT 0 // client is a normal HL client (default) #define TYPE_CLIENT 0 // client is a normal HL client (default)
#define TYPE_PROXY 1 // client is another proxy #define TYPE_PROXY 1 // client is another proxy
#define TYPE_COMMENTATOR 3 // client is a commentator #define TYPE_COMMENTATOR 3 // client is a commentator
#define TYPE_DEMO 4 // client is a demo file #define TYPE_DEMO 4 // client is a demo file
// sub commands of svc_hltv: // sub commands of svc_hltv:
#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands #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_STATUS 1 // send status infos about proxy
#define HLTV_LISTEN 2 // tell client to listen to a multicast stream #define HLTV_LISTEN 2 // tell client to listen to a multicast stream
// sub commands of svc_director: // sub commands of svc_director:
#define DRC_CMD_NONE 0 // NULL director command #define DRC_CMD_NONE 0 // NULL director command
#define DRC_CMD_START 1 // start director mode #define DRC_CMD_START 1 // start director mode
#define DRC_CMD_EVENT 2 // informs about director command #define DRC_CMD_EVENT 2 // informs about director command
#define DRC_CMD_MODE 3 // switches camera modes #define DRC_CMD_MODE 3 // switches camera modes
#define DRC_CMD_CAMERA 4 // sets camera registers #define DRC_CMD_CAMERA 4 // sets camera registers
#define DRC_CMD_TIMESCALE 5 // sets time scale #define DRC_CMD_TIMESCALE 5 // sets time scale
#define DRC_CMD_MESSAGE 6 // send HUD centerprint #define DRC_CMD_MESSAGE 6 // send HUD centerprint
#define DRC_CMD_SOUND 7 // plays a particular sound #define DRC_CMD_SOUND 7 // plays a particular sound
#define DRC_CMD_STATUS 8 // status info about broadcast #define DRC_CMD_STATUS 8 // status info about broadcast
#define DRC_CMD_BANNER 9 // banner file name for HLTV gui #define DRC_CMD_BANNER 9 // banner file name for HLTV gui
#define DRC_CMD_FADE 10 // send screen fade command #define DRC_CMD_FADE 10 // send screen fade command
#define DRC_CMD_SHAKE 11 // send screen shake 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_STUFFTEXT 12 // like the normal svc_stufftext but as director command
#define DRC_CMD_LAST 12 #define DRC_CMD_LAST 12
// HLTV_EVENT event flags // HLTV_EVENT event flags
#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) #define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important)
#define DRC_FLAG_SIDE (1<<4) // #define DRC_FLAG_SIDE (1<<4) //
#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene #define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene
#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo #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_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc)
#define DRC_FLAG_INTRO (1<<8) // is a introduction scene #define DRC_FLAG_INTRO (1<<8) // is a introduction scene
#define DRC_FLAG_FINAL (1<<9) // is a final scene #define DRC_FLAG_FINAL (1<<9) // is a final scene
#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data #define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data
#define MAX_DIRECTOR_CMD_PARAMETERS 4 #define MAX_DIRECTOR_CMD_PARAMETERS 4
#define MAX_DIRECTOR_CMD_STRING 128 #define MAX_DIRECTOR_CMD_STRING 128
#endif // HLTV_H #endif // HLTV_H

View File

@ -1,43 +1,43 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#ifndef IN_BUTTONS_H #ifndef IN_BUTTONS_H
#define IN_BUTTONS_H #define IN_BUTTONS_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
#ifndef CONST_H #ifndef CONST_H
#define IN_ATTACK (1 << 0) #define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1) #define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2) #define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3) #define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4) #define IN_BACK (1 << 4)
#define IN_USE (1 << 5) #define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6) #define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7) #define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8) #define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9) #define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10) #define IN_MOVERIGHT (1 << 10)
#define IN_ATTACK2 (1 << 11) #define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12) #define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13) #define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14) #define IN_ALT1 (1 << 14)
#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down #define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down
#endif #endif
#endif // IN_BUTTONS_H #endif // IN_BUTTONS_H

View File

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

View File

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

View File

@ -1,37 +1,37 @@
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ //========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
// //
// Purpose: // Purpose:
// //
// $NoKeywords: $ // $NoKeywords: $
//============================================================================= //=============================================================================
#ifndef IVOICETWEAK_H #ifndef IVOICETWEAK_H
#define IVOICETWEAK_H #define IVOICETWEAK_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
// These provide access to the voice controls. // These provide access to the voice controls.
typedef enum typedef enum
{ {
MicrophoneVolume=0, // values 0-1. MicrophoneVolume=0, // values 0-1.
OtherSpeakerScale // values 0-1. Scales how loud other players are. OtherSpeakerScale // values 0-1. Scales how loud other players are.
} VoiceTweakControl; } VoiceTweakControl;
typedef struct IVoiceTweak_s typedef struct IVoiceTweak_s
{ {
// These turn voice tweak mode on and off. While in voice tweak mode, the user's voice is echoed back // 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. // without sending to the server.
int (*StartVoiceTweakMode)(); // Returns 0 on error. int (*StartVoiceTweakMode)(); // Returns 0 on error.
void (*EndVoiceTweakMode)(); void (*EndVoiceTweakMode)();
// Get/set control values. // Get/set control values.
void (*SetControlFloat)(VoiceTweakControl iControl, float value); void (*SetControlFloat)(VoiceTweakControl iControl, float value);
float (*GetControlFloat)(VoiceTweakControl iControl); float (*GetControlFloat)(VoiceTweakControl iControl);
} IVoiceTweak; } IVoiceTweak;
#endif // IVOICETWEAK_H #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: // Purpose:
// //

View File

@ -1,156 +1,156 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// mathlib.h // mathlib.h
typedef float vec_t; typedef float vec_t;
typedef vec_t vec3_t[3]; typedef vec_t vec3_t[3];
typedef vec_t vec4_t[4]; // x,y,z,w typedef vec_t vec4_t[4]; // x,y,z,w
typedef vec_t vec5_t[5]; typedef vec_t vec5_t[5];
typedef short vec_s_t; typedef short vec_s_t;
typedef vec_s_t vec3s_t[3]; typedef vec_s_t vec3s_t[3];
typedef vec_s_t vec4s_t[4]; // x,y,z,w typedef vec_s_t vec4s_t[4]; // x,y,z,w
typedef vec_s_t vec5s_t[5]; typedef vec_s_t vec5s_t[5];
typedef int fixed4_t; typedef int fixed4_t;
typedef int fixed8_t; typedef int fixed8_t;
typedef int fixed16_t; typedef int fixed16_t;
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
#endif #endif
struct mplane_s; struct mplane_s;
extern vec3_t vec3_origin; extern vec3_t vec3_origin;
extern int nanmask; extern int nanmask;
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
#ifndef VECTOR_H #ifndef VECTOR_H
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
#endif #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 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 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 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;} #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); void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc);
vec_t _DotProduct (vec3_t v1, vec3_t v2); vec_t _DotProduct (vec3_t v1, vec3_t v2);
void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out); void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
void _VectorAdd (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); void _VectorCopy (vec3_t in, vec3_t out);
int VectorCompare (const vec3_t v1, const vec3_t v2); int VectorCompare (const vec3_t v1, const vec3_t v2);
float Length (const vec3_t v); float Length (const vec3_t v);
void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross); void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross);
float VectorNormalize (vec3_t v); // returns vector length float VectorNormalize (vec3_t v); // returns vector length
void VectorInverse (vec3_t v); void VectorInverse (vec3_t v);
void VectorScale (const vec3_t in, vec_t scale, vec3_t out); void VectorScale (const vec3_t in, vec_t scale, vec3_t out);
int Q_log2(int val); int Q_log2(int val);
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); void R_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 // Here are some "manual" INLINE routines for doing floating point to integer conversions
extern short new_cw, old_cw; extern short new_cw, old_cw;
typedef union DLONG { typedef union DLONG {
int i[2]; int i[2];
double d; double d;
float f; float f;
} DLONG; } DLONG;
extern DLONG dlong; extern DLONG dlong;
#ifdef _WIN32 #ifdef _WIN32
void __inline set_fpu_cw(void) void __inline set_fpu_cw(void)
{ {
_asm _asm
{ wait { wait
fnstcw old_cw fnstcw old_cw
wait wait
mov ax, word ptr old_cw mov ax, word ptr old_cw
or ah, 0xc or ah, 0xc
mov word ptr new_cw,ax mov word ptr new_cw,ax
fldcw new_cw fldcw new_cw
} }
} }
int __inline quick_ftol(float f) int __inline quick_ftol(float f)
{ {
_asm { _asm {
// Assumes that we are already in chop mode, and only need a 32-bit int // Assumes that we are already in chop mode, and only need a 32-bit int
fld DWORD PTR f fld DWORD PTR f
fistp DWORD PTR dlong fistp DWORD PTR dlong
} }
return dlong.i[0]; return dlong.i[0];
} }
void __inline restore_fpu_cw(void) void __inline restore_fpu_cw(void)
{ {
_asm fldcw old_cw _asm fldcw old_cw
} }
#else #else
#define set_fpu_cw() /* */ #define set_fpu_cw() /* */
#define quick_ftol(f) ftol(f) #define quick_ftol(f) ftol(f)
#define restore_fpu_cw() /* */ #define restore_fpu_cw() /* */
#endif #endif
void FloorDivMod (double numer, double denom, int *quotient, void FloorDivMod (double numer, double denom, int *quotient,
int *rem); int *rem);
fixed16_t Invert24To16(fixed16_t val); fixed16_t Invert24To16(fixed16_t val);
int GreatestCommonDivisor (int i1, int i2); int GreatestCommonDivisor (int i1, int i2);
void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); 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); void AngleVectorsTranspose (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
#define AngleIVectors AngleVectorsTranspose #define AngleIVectors AngleVectorsTranspose
void AngleMatrix (const vec3_t angles, float (*matrix)[4] ); void AngleMatrix (const vec3_t angles, float (*matrix)[4] );
void AngleIMatrix (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 VectorTransform (const vec3_t in1, float in2[3][4], vec3_t out);
void NormalizeAngles( vec3_t angles ); void NormalizeAngles( vec3_t angles );
void InterpolateAngles( vec3_t start, vec3_t end, vec3_t output, float frac ); void InterpolateAngles( vec3_t start, vec3_t end, vec3_t output, float frac );
float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 ); float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 );
void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up); void VectorMatrix( vec3_t forward, vec3_t right, vec3_t up);
void VectorAngles( const vec3_t forward, vec3_t angles ); void VectorAngles( const vec3_t forward, vec3_t angles );
int InvertMatrix( const float * m, float *out ); int InvertMatrix( const float * m, float *out );
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane); int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
float anglemod(float a); float anglemod(float a);
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ #define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
(((p)->type < 3)? \ (((p)->type < 3)? \
( \ ( \
((p)->dist <= (emins)[(p)->type])? \ ((p)->dist <= (emins)[(p)->type])? \
1 \ 1 \
: \ : \
( \ ( \
((p)->dist >= (emaxs)[(p)->type])?\ ((p)->dist >= (emaxs)[(p)->type])?\
2 \ 2 \
: \ : \
3 \ 3 \
) \ ) \
) \ ) \
: \ : \
BoxOnPlaneSide( (emins), (emaxs), (p))) BoxOnPlaneSide( (emins), (emaxs), (p)))

View File

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

View File

@ -1,42 +1,42 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
// netadr.h // netadr.h
#ifndef NETADR_H #ifndef NETADR_H
#define NETADR_H #define NETADR_H
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
typedef enum typedef enum
{ {
NA_UNUSED, NA_UNUSED,
NA_LOOPBACK, NA_LOOPBACK,
NA_BROADCAST, NA_BROADCAST,
NA_IP, NA_IP,
NA_IPX, NA_IPX,
NA_BROADCAST_IPX, NA_BROADCAST_IPX,
} netadrtype_t; } netadrtype_t;
typedef struct netadr_s typedef struct netadr_s
{ {
netadrtype_t type; netadrtype_t type;
unsigned char ip[4]; unsigned char ip[4];
unsigned char ipx[10]; unsigned char ipx[10];
unsigned short port; unsigned short port;
} netadr_t; } netadr_t;
#endif // NETADR_H #endif // NETADR_H

View File

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

View File

@ -1,59 +1,59 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( PARTICLEDEFH ) #if !defined( PARTICLEDEFH )
#define PARTICLEDEFH #define PARTICLEDEFH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
typedef enum { typedef enum {
pt_static, pt_static,
pt_grav, pt_grav,
pt_slowgrav, pt_slowgrav,
pt_fire, pt_fire,
pt_explode, pt_explode,
pt_explode2, pt_explode2,
pt_blob, pt_blob,
pt_blob2, pt_blob2,
pt_vox_slowgrav, pt_vox_slowgrav,
pt_vox_grav, pt_vox_grav,
pt_clientcustom // Must have callback function specified pt_clientcustom // Must have callback function specified
} ptype_t; } ptype_t;
// !!! if this is changed, it must be changed in d_ifacea.h too !!! // !!! if this is changed, it must be changed in d_ifacea.h too !!!
typedef struct particle_s typedef struct particle_s
{ {
// driver-usable fields // driver-usable fields
vec3_t org; vec3_t org;
short color; short color;
short packedColor; short packedColor;
// drivers never touch the following fields // drivers never touch the following fields
struct particle_s *next; struct particle_s *next;
vec3_t vel; vec3_t vel;
float ramp; float ramp;
float die; float die;
ptype_t type; ptype_t type;
void (*deathfunc)( struct particle_s *particle ); void (*deathfunc)( struct particle_s *particle );
// for pt_clientcusttom, we'll call this function each frame // for pt_clientcusttom, we'll call this function each frame
void (*callback)( struct particle_s *particle, float frametime ); void (*callback)( struct particle_s *particle, float frametime );
// For deathfunc, etc. // For deathfunc, etc.
unsigned char context; unsigned char context;
} particle_t; } particle_t;
#endif #endif

View File

@ -1,45 +1,45 @@
/*** /***
* *
* Copyright (c) 1996-2002, Valve LLC. All rights reserved. * Copyright (c) 1996-2002, Valve LLC. All rights reserved.
* *
* This product contains software technology licensed from Id * This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved. * All Rights Reserved.
* *
* Use, distribution, and modification of this source code and/or resulting * Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from * object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited * Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC. * without written permission from Valve LLC.
* *
****/ ****/
#if !defined( PMTRACEH ) #if !defined( PMTRACEH )
#define PMTRACEH #define PMTRACEH
#ifdef _WIN32 #ifdef _WIN32
#ifndef __MINGW32__ #ifndef __MINGW32__
#pragma once #pragma once
#endif /* not __MINGW32__ */ #endif /* not __MINGW32__ */
#endif #endif
typedef struct typedef struct
{ {
vec3_t normal; vec3_t normal;
float dist; float dist;
} pmplane_t; } pmplane_t;
typedef struct pmtrace_s pmtrace_t; typedef struct pmtrace_s pmtrace_t;
struct pmtrace_s struct pmtrace_s
{ {
qboolean allsolid; // if true, plane is not valid qboolean allsolid; // if true, plane is not valid
qboolean startsolid; // if true, the initial point was in a solid area qboolean startsolid; // if true, the initial point was in a solid area
qboolean inopen, inwater; // End point is in empty space or in water qboolean inopen, inwater; // End point is in empty space or in water
float fraction; // time completed, 1.0 = didn't hit anything float fraction; // time completed, 1.0 = didn't hit anything
vec3_t endpos; // final position vec3_t endpos; // final position
pmplane_t plane; // surface normal at impact pmplane_t plane; // surface normal at impact
int ent; // entity at impact int ent; // entity at impact
vec3_t deltavelocity; // Change in player's velocity caused by impact. vec3_t deltavelocity; // Change in player's velocity caused by impact.
// Only run on server. // Only run on server.
int hitgroup; int hitgroup;
}; };
#endif #endif

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