Browse Source

initial seed of Half-Life 1 SDK

Alfred Reynolds 5 years ago
parent
commit
de70fada50
100 changed files with 37515 additions and 0 deletions
  1. 117
    0
      cl_dll/Exports.h
  2. 121
    0
      cl_dll/GameStudioModelRenderer.cpp
  3. 26
    0
      cl_dll/GameStudioModelRenderer.h
  4. 992
    0
      cl_dll/GameStudioModelRenderer_Sample.cpp
  5. 55
    0
      cl_dll/GameStudioModelRenderer_Sample.h
  6. 155
    0
      cl_dll/MOTD.cpp
  7. 2114
    0
      cl_dll/StudioModelRenderer.cpp
  8. 189
    0
      cl_dll/StudioModelRenderer.h
  9. 1200
    0
      cl_dll/ammo.cpp
  10. 62
    0
      cl_dll/ammo.h
  11. 159
    0
      cl_dll/ammo_secondary.cpp
  12. 190
    0
      cl_dll/ammohistory.cpp
  13. 143
    0
      cl_dll/ammohistory.h
  14. 158
    0
      cl_dll/battery.cpp
  15. 26
    0
      cl_dll/bench.h
  16. 24
    0
      cl_dll/camera.h
  17. 445
    0
      cl_dll/cdll_int.cpp
  18. 648
    0
      cl_dll/cl_dll.dsp
  19. 43
    0
      cl_dll/cl_dll.h
  20. 196
    0
      cl_dll/cl_util.h
  21. 277
    0
      cl_dll/com_weapons.cpp
  22. 44
    0
      cl_dll/com_weapons.h
  23. 304
    0
      cl_dll/death.cpp
  24. 99
    0
      cl_dll/demo.cpp
  25. 27
    0
      cl_dll/demo.h
  26. 785
    0
      cl_dll/entity.cpp
  27. 205
    0
      cl_dll/ev_common.cpp
  28. 1704
    0
      cl_dll/ev_hldm.cpp
  29. 95
    0
      cl_dll/ev_hldm.h
  30. 23
    0
      cl_dll/events.cpp
  31. 73
    0
      cl_dll/eventscripts.h
  32. 149
    0
      cl_dll/flashlight.cpp
  33. 184
    0
      cl_dll/geiger.cpp
  34. 30
    0
      cl_dll/global_consts.h
  35. 473
    0
      cl_dll/health.cpp
  36. 127
    0
      cl_dll/health.h
  37. 348
    0
      cl_dll/hl/hl_baseentity.cpp
  38. 80
    0
      cl_dll/hl/hl_events.cpp
  39. 90
    0
      cl_dll/hl/hl_objects.cpp
  40. 1081
    0
      cl_dll/hl/hl_weapons.cpp
  41. 698
    0
      cl_dll/hud.cpp
  42. 658
    0
      cl_dll/hud.h
  43. 1129
    0
      cl_dll/hud_bench.cpp
  44. 234
    0
      cl_dll/hud_benchtrace.cpp
  45. 8
    0
      cl_dll/hud_benchtrace.h
  46. 17
    0
      cl_dll/hud_iface.h
  47. 141
    0
      cl_dll/hud_msg.cpp
  48. 346
    0
      cl_dll/hud_redraw.cpp
  49. 1234
    0
      cl_dll/hud_servers.cpp
  50. 41
    0
      cl_dll/hud_servers.h
  51. 98
    0
      cl_dll/hud_servers_priv.h
  52. 1981
    0
      cl_dll/hud_spectator.cpp
  53. 156
    0
      cl_dll/hud_spectator.h
  54. 54
    0
      cl_dll/hud_update.cpp
  55. 631
    0
      cl_dll/in_camera.cpp
  56. 20
    0
      cl_dll/in_defs.h
  57. 1041
    0
      cl_dll/input.cpp
  58. 1114
    0
      cl_dll/inputw32.cpp
  59. 222
    0
      cl_dll/interpolation.cpp
  60. 56
    0
      cl_dll/interpolation.h
  61. 18
    0
      cl_dll/kbutton.h
  62. 283
    0
      cl_dll/menu.cpp
  63. 536
    0
      cl_dll/message.cpp
  64. 160
    0
      cl_dll/overview.cpp
  65. 31
    0
      cl_dll/overview.h
  66. 20
    0
      cl_dll/player_info.h
  67. 107
    0
      cl_dll/readme.txt
  68. 326
    0
      cl_dll/saytext.cpp
  69. 586
    0
      cl_dll/scoreboard.cpp
  70. 162
    0
      cl_dll/soundsystem.cpp
  71. 163
    0
      cl_dll/status_icons.cpp
  72. 265
    0
      cl_dll/statusbar.cpp
  73. 251
    0
      cl_dll/studio_util.cpp
  74. 40
    0
      cl_dll/studio_util.h
  75. 214
    0
      cl_dll/text_message.cpp
  76. 1389
    0
      cl_dll/tf_defs.h
  77. 85
    0
      cl_dll/train.cpp
  78. 60
    0
      cl_dll/tri.cpp
  79. 13
    0
      cl_dll/tri.h
  80. 133
    0
      cl_dll/util.cpp
  81. 125
    0
      cl_dll/util_vector.h
  82. 437
    0
      cl_dll/vgui_ClassMenu.cpp
  83. 101
    0
      cl_dll/vgui_ConsolePanel.cpp
  84. 38
    0
      cl_dll/vgui_ConsolePanel.h
  85. 212
    0
      cl_dll/vgui_ControlConfigPanel.cpp
  86. 47
    0
      cl_dll/vgui_ControlConfigPanel.h
  87. 547
    0
      cl_dll/vgui_CustomObjects.cpp
  88. 154
    0
      cl_dll/vgui_MOTDWindow.cpp
  89. 556
    0
      cl_dll/vgui_SchemeManager.cpp
  90. 54
    0
      cl_dll/vgui_SchemeManager.h
  91. 1151
    0
      cl_dll/vgui_ScorePanel.cpp
  92. 310
    0
      cl_dll/vgui_ScorePanel.h
  93. 623
    0
      cl_dll/vgui_ServerBrowser.cpp
  94. 50
    0
      cl_dll/vgui_ServerBrowser.h
  95. 426
    0
      cl_dll/vgui_SpectatorPanel.cpp
  96. 112
    0
      cl_dll/vgui_SpectatorPanel.h
  97. 2644
    0
      cl_dll/vgui_TeamFortressViewport.cpp
  98. 1818
    0
      cl_dll/vgui_TeamFortressViewport.h
  99. 128
    0
      cl_dll/vgui_int.cpp
  100. 0
    0
      cl_dll/vgui_int.h

+ 117
- 0
cl_dll/Exports.h View File

@@ -0,0 +1,117 @@
1
+// CL_DLLEXPORT is the client version of dllexport.  It's turned off for secure clients.
2
+#ifdef _WIN32
3
+#define CL_DLLEXPORT __declspec(dllexport)
4
+#else
5
+#define CL_DLLEXPORT __attribute__ ((visibility("default")))
6
+#endif
7
+
8
+extern "C" 
9
+{
10
+	// From hl_weapons
11
+	void CL_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 );
12
+
13
+	// From cdll_int
14
+	int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
15
+	int CL_DLLEXPORT HUD_VidInit( void );
16
+	void CL_DLLEXPORT HUD_Init( void );
17
+	int CL_DLLEXPORT HUD_Redraw( float flTime, int intermission );
18
+	int CL_DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
19
+	void CL_DLLEXPORT HUD_Reset ( void );
20
+	void CL_DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
21
+	void CL_DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
22
+	char CL_DLLEXPORT HUD_PlayerMoveTexture( char *name );
23
+	int CL_DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
24
+	int CL_DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
25
+	void CL_DLLEXPORT HUD_Frame( double time );
26
+	void CL_DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
27
+	void CL_DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf );
28
+	void CL_DLLEXPORT HUD_ChatInputPosition( int *x, int *y );
29
+
30
+	// From demo
31
+	void CL_DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );
32
+
33
+	// From entity
34
+	int CL_DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname );
35
+	void CL_DLLEXPORT HUD_CreateEntities( void );
36
+	void CL_DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity );
37
+	void CL_DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client );
38
+	void CL_DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src );
39
+	void CL_DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd );
40
+	void CL_DLLEXPORT HUD_TempEntUpdate( double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int ( *Callback_AddVisibleEntity )( struct cl_entity_s *pEntity ), void ( *Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ) );
41
+	struct cl_entity_s CL_DLLEXPORT *HUD_GetUserEntity( int index );
42
+
43
+	// From in_camera
44
+	void CL_DLLEXPORT CAM_Think( void );
45
+	int CL_DLLEXPORT CL_IsThirdPerson( void );
46
+	void CL_DLLEXPORT CL_CameraOffset( float *ofs );
47
+
48
+	// From input
49
+	struct kbutton_s CL_DLLEXPORT *KB_Find( const char *name );
50
+	void CL_DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active );
51
+	void CL_DLLEXPORT HUD_Shutdown( void );
52
+	int CL_DLLEXPORT HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding );
53
+
54
+	// From inputw32
55
+	void CL_DLLEXPORT IN_ActivateMouse( void );
56
+	void CL_DLLEXPORT IN_DeactivateMouse( void );
57
+	void CL_DLLEXPORT IN_MouseEvent (int mstate);
58
+	void CL_DLLEXPORT IN_Accumulate (void);
59
+	void CL_DLLEXPORT IN_ClearStates (void);
60
+
61
+	// From tri
62
+	void CL_DLLEXPORT HUD_DrawNormalTriangles( void );
63
+	void CL_DLLEXPORT HUD_DrawTransparentTriangles( void );
64
+
65
+	// From view
66
+	void	CL_DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams );
67
+
68
+	// From GameStudioModelRenderer
69
+	int CL_DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
70
+}
71
+
72
+/*
73
+extern cldll_func_dst_t *g_pcldstAddrs;
74
+
75
+// Macros for the client receiving calls from the engine
76
+#define RecClInitialize(a, b)			(g_pcldstAddrs->pInitFunc(&a, &b))
77
+#define RecClHudInit()					(g_pcldstAddrs->pHudInitFunc())
78
+#define RecClHudVidInit()				(g_pcldstAddrs->pHudVidInitFunc())
79
+#define RecClHudRedraw(a, b)			(g_pcldstAddrs->pHudRedrawFunc(&a, &b))
80
+#define RecClHudUpdateClientData(a, b)	(g_pcldstAddrs->pHudUpdateClientDataFunc(&a, &b))
81
+#define RecClHudReset()					(g_pcldstAddrs->pHudResetFunc())
82
+#define RecClClientMove(a, b)			(g_pcldstAddrs->pClientMove(&a, &b))
83
+#define RecClClientMoveInit(a)			(g_pcldstAddrs->pClientMoveInit(&a))
84
+#define RecClClientTextureType(a)		(g_pcldstAddrs->pClientTextureType(&a))
85
+#define RecClIN_ActivateMouse()			(g_pcldstAddrs->pIN_ActivateMouse())
86
+#define RecClIN_DeactivateMouse()		(g_pcldstAddrs->pIN_DeactivateMouse())
87
+#define RecClIN_MouseEvent(a)			(g_pcldstAddrs->pIN_MouseEvent(&a))
88
+#define RecClIN_ClearStates()			(g_pcldstAddrs->pIN_ClearStates())
89
+#define RecClIN_Accumulate()			(g_pcldstAddrs->pIN_Accumulate())
90
+#define RecClCL_CreateMove(a, b, c)		(g_pcldstAddrs->pCL_CreateMove(&a, &b, &c))
91
+#define RecClCL_IsThirdPerson()			(g_pcldstAddrs->pCL_IsThirdPerson())
92
+#define RecClCL_GetCameraOffsets(a)		(g_pcldstAddrs->pCL_GetCameraOffsets(&a))
93
+#define RecClFindKey(a)					(g_pcldstAddrs->pFindKey(&a))
94
+#define RecClCamThink()					(g_pcldstAddrs->pCamThink())
95
+#define RecClCalcRefdef(a)				(g_pcldstAddrs->pCalcRefdef(&a))
96
+#define RecClAddEntity(a, b, c)			(g_pcldstAddrs->pAddEntity(&a, &b, &c))
97
+#define RecClCreateEntities()			(g_pcldstAddrs->pCreateEntities())
98
+#define RecClDrawNormalTriangles()		(g_pcldstAddrs->pDrawNormalTriangles())
99
+#define RecClDrawTransparentTriangles()	(g_pcldstAddrs->pDrawTransparentTriangles())
100
+#define RecClStudioEvent(a, b)			(g_pcldstAddrs->pStudioEvent(&a, &b))
101
+#define RecClPostRunCmd(a, b, c, d, e, f)		(g_pcldstAddrs->pPostRunCmd(&a, &b, &c, &d, &e, &f))
102
+#define RecClShutdown()					(g_pcldstAddrs->pShutdown())
103
+#define RecClTxferLocalOverrides(a, b)	(g_pcldstAddrs->pTxferLocalOverrides(&a, &b))
104
+#define RecClProcessPlayerState(a, b)	(g_pcldstAddrs->pProcessPlayerState(&a, &b))
105
+#define RecClTxferPredictionData(a, b, c, d, e, f)		(g_pcldstAddrs->pTxferPredictionData(&a, &b, &c, &d, &e, &f))
106
+#define RecClReadDemoBuffer(a, b)		(g_pcldstAddrs->pReadDemoBuffer(&a, &b))
107
+#define RecClConnectionlessPacket(a, b, c, d)		(g_pcldstAddrs->pConnectionlessPacket(&a, &b, &c, &d))
108
+#define RecClGetHullBounds(a, b, c)		(g_pcldstAddrs->pGetHullBounds(&a, &b, &c))
109
+#define RecClHudFrame(a)				(g_pcldstAddrs->pHudFrame(&a))
110
+#define RecClKeyEvent(a, b, c)			(g_pcldstAddrs->pKeyEvent(&a, &b, &c))
111
+#define RecClTempEntUpdate(a, b, c, d, e, f, g)	(g_pcldstAddrs->pTempEntUpdate(&a, &b, &c, &d, &e, &f, &g))
112
+#define RecClGetUserEntity(a)			(g_pcldstAddrs->pGetUserEntity(&a))
113
+#define RecClVoiceStatus(a, b)			(g_pcldstAddrs->pVoiceStatus(&a, &b))
114
+#define RecClDirectorMessage(a, b)		(g_pcldstAddrs->pDirectorMessage(&a, &b))
115
+#define RecClStudioInterface(a, b, c)	(g_pcldstAddrs->pStudioInterface(&a, &b, &c))
116
+#define RecClChatInputPosition(a, b)	(g_pcldstAddrs->pChatInputPosition(&a, &b))
117
+*/

+ 121
- 0
cl_dll/GameStudioModelRenderer.cpp View File

@@ -0,0 +1,121 @@
1
+//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
2
+//
3
+// Purpose: 
4
+//
5
+// $NoKeywords: $
6
+//=============================================================================
7
+
8
+#include <assert.h>
9
+#include "hud.h"
10
+#include "cl_util.h"
11
+#include "const.h"
12
+#include "com_model.h"
13
+#include "studio.h"
14
+#include "entity_state.h"
15
+#include "cl_entity.h"
16
+#include "dlight.h"
17
+#include "triangleapi.h"
18
+
19
+#include <stdio.h>
20
+#include <string.h>
21
+#include <memory.h>
22
+#include <math.h>
23
+
24
+#include "studio_util.h"
25
+#include "r_studioint.h"
26
+
27
+#include "StudioModelRenderer.h"
28
+#include "GameStudioModelRenderer.h"
29
+#include "Exports.h"
30
+
31
+//
32
+// Override the StudioModelRender virtual member functions here to implement custom bone
33
+// setup, blending, etc.
34
+//
35
+
36
+// Global engine <-> studio model rendering code interface
37
+extern engine_studio_api_t IEngineStudio;
38
+
39
+// The renderer object, created on the stack.
40
+CGameStudioModelRenderer g_StudioRenderer;
41
+/*
42
+====================
43
+CGameStudioModelRenderer
44
+
45
+====================
46
+*/
47
+CGameStudioModelRenderer::CGameStudioModelRenderer( void )
48
+{
49
+}
50
+
51
+////////////////////////////////////
52
+// Hooks to class implementation
53
+////////////////////////////////////
54
+
55
+/*
56
+====================
57
+R_StudioDrawPlayer
58
+
59
+====================
60
+*/
61
+int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
62
+{
63
+	return g_StudioRenderer.StudioDrawPlayer( flags, pplayer );
64
+}
65
+
66
+/*
67
+====================
68
+R_StudioDrawModel
69
+
70
+====================
71
+*/
72
+int R_StudioDrawModel( int flags )
73
+{
74
+	return g_StudioRenderer.StudioDrawModel( flags );
75
+}
76
+
77
+/*
78
+====================
79
+R_StudioInit
80
+
81
+====================
82
+*/
83
+void R_StudioInit( void )
84
+{
85
+	g_StudioRenderer.Init();
86
+}
87
+
88
+// The simple drawing interface we'll pass back to the engine
89
+r_studio_interface_t studio =
90
+{
91
+	STUDIO_INTERFACE_VERSION,
92
+	R_StudioDrawModel,
93
+	R_StudioDrawPlayer,
94
+};
95
+
96
+/*
97
+====================
98
+HUD_GetStudioModelInterface
99
+
100
+Export this function for the engine to use the studio renderer class to render objects.
101
+====================
102
+*/
103
+int CL_DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
104
+{
105
+//	RecClStudioInterface(version, ppinterface, pstudio);
106
+
107
+	if ( version != STUDIO_INTERFACE_VERSION )
108
+		return 0;
109
+
110
+	// Point the engine to our callbacks
111
+	*ppinterface = &studio;
112
+
113
+	// Copy in engine helper functions
114
+	memcpy( &IEngineStudio, pstudio, sizeof( IEngineStudio ) );
115
+
116
+	// Initialize local variables, etc.
117
+	R_StudioInit();
118
+
119
+	// Success
120
+	return 1;
121
+}

+ 26
- 0
cl_dll/GameStudioModelRenderer.h View File

@@ -0,0 +1,26 @@
1
+//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
2
+//
3
+// Purpose: 
4
+//
5
+// $NoKeywords: $
6
+//=============================================================================
7
+
8
+#if !defined( GAMESTUDIOMODELRENDERER_H )
9
+#define GAMESTUDIOMODELRENDERER_H
10
+#if defined( _WIN32 )
11
+#pragma once
12
+#endif
13
+
14
+/*
15
+====================
16
+CGameStudioModelRenderer
17
+
18
+====================
19
+*/
20
+class CGameStudioModelRenderer : public CStudioModelRenderer
21
+{
22
+public:
23
+	CGameStudioModelRenderer( void );
24
+};
25
+
26
+#endif // GAMESTUDIOMODELRENDERER_H

+ 992
- 0
cl_dll/GameStudioModelRenderer_Sample.cpp View File

@@ -0,0 +1,992 @@
1
+//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
2
+//
3
+// Purpose: 
4
+//
5
+// $NoKeywords: $
6
+//=============================================================================
7
+
8
+#include <assert.h>
9
+#include "hud.h"
10
+#include "cl_util.h"
11
+#include "const.h"
12
+#include "com_model.h"
13
+#include "studio.h"
14
+#include "entity_state.h"
15
+#include "cl_entity.h"
16
+#include "dlight.h"
17
+#include "triangleapi.h"
18
+
19
+#include <stdio.h>
20
+#include <string.h>
21
+#include <memory.h>
22
+#include <math.h>
23
+
24
+#include "studio_util.h"
25
+#include "r_studioint.h"
26
+
27
+#include "StudioModelRenderer.h"
28
+#include "GameStudioModelRenderer.h"
29
+
30
+// Predicted values saved off in hl_weapons.cpp
31
+void Game_GetSequence( int *seq, int *gaitseq );
32
+void Game_GetOrientation( float *o, float *a );
33
+
34
+float g_flStartScaleTime;
35
+int iPrevRenderState;
36
+int iRenderStateChanged;
37
+
38
+// Global engine <-> studio model rendering code interface
39
+extern engine_studio_api_t IEngineStudio;
40
+
41
+typedef struct
42
+{
43
+	vec3_t		origin;
44
+	vec3_t		angles;
45
+
46
+	vec3_t		realangles;
47
+
48
+	float		animtime;
49
+	float		frame;
50
+	int			sequence;
51
+	int			gaitsequence;
52
+	float		framerate;
53
+
54
+	int			m_fSequenceLoops;
55
+	int			m_fSequenceFinished;
56
+
57
+	byte		controller[ 4 ];
58
+	byte		blending[ 2 ];
59
+
60
+	latchedvars_t	lv;
61
+} client_anim_state_t;
62
+
63
+static client_anim_state_t g_state;
64
+static client_anim_state_t g_clientstate;
65
+
66
+// The renderer object, created on the stack.
67
+CGameStudioModelRenderer g_StudioRenderer;
68
+/*
69
+====================
70
+CGameStudioModelRenderer
71
+
72
+====================
73
+*/
74
+CGameStudioModelRenderer::CGameStudioModelRenderer( void )
75
+{
76
+	// If you want to predict animations locally, set this to TRUE
77
+	// NOTE:  The animation code is somewhat broken, but gives you a sense for how
78
+	//  to do client side animation of the predicted player in a third person game.
79
+	m_bLocal = false;
80
+}
81
+
82
+/*
83
+====================
84
+StudioSetupBones
85
+
86
+====================
87
+*/
88
+void CGameStudioModelRenderer::StudioSetupBones ( void )
89
+{
90
+	int					i;
91
+	double				f;
92
+
93
+	mstudiobone_t		*pbones;
94
+	mstudioseqdesc_t	*pseqdesc;
95
+	mstudioanim_t		*panim;
96
+
97
+	static float		pos[MAXSTUDIOBONES][3];
98
+	static vec4_t		q[MAXSTUDIOBONES];
99
+	float				bonematrix[3][4];
100
+
101
+	static float		pos2[MAXSTUDIOBONES][3];
102
+	static vec4_t		q2[MAXSTUDIOBONES];
103
+	static float		pos3[MAXSTUDIOBONES][3];
104
+	static vec4_t		q3[MAXSTUDIOBONES];
105
+	static float		pos4[MAXSTUDIOBONES][3];
106
+	static vec4_t		q4[MAXSTUDIOBONES];
107
+
108
+	// Use default bone setup for nonplayers
109
+	if ( !m_pCurrentEntity->player )
110
+	{
111
+		CStudioModelRenderer::StudioSetupBones();
112
+		return;
113
+	}
114
+
115
+	// Bound sequence number.
116
+	if ( m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq ) 
117
+	{
118
+		m_pCurrentEntity->curstate.sequence = 0;
119
+	}
120
+
121
+	pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence;
122
+
123
+	if ( m_pPlayerInfo && m_pPlayerInfo->gaitsequence != 0 )
124
+	{
125
+		f = m_pPlayerInfo->gaitframe;
126
+	}
127
+	else 
128
+	{
129
+		f = StudioEstimateFrame( pseqdesc );
130
+	}
131
+
132
+	// This game knows how to do three way blending
133
+	if ( pseqdesc->numblends == 3 )
134
+	{
135
+		float				s;
136
+
137
+		// Get left anim
138
+		panim = StudioGetAnim( m_pRenderModel, pseqdesc );
139
+
140
+		// Blending is 0-127 == Left to Middle, 128 to 255 == Middle to right
141
+		if ( m_pCurrentEntity->curstate.blending[0] <= 127 )
142
+		{
143
+			StudioCalcRotations( pos, q, pseqdesc, panim, f );
144
+			
145
+			// Scale 0-127 blending up to 0-255
146
+			s = m_pCurrentEntity->curstate.blending[0];
147
+			s = ( s * 2.0 );
148
+		}
149
+		else
150
+		{
151
+			
152
+			// Skip ahead to middle
153
+			panim += m_pStudioHeader->numbones;
154
+
155
+			StudioCalcRotations( pos, q, pseqdesc, panim, f );
156
+
157
+			// Scale 127-255 blending up to 0-255
158
+			s = m_pCurrentEntity->curstate.blending[0];
159
+			s = 2.0 * ( s - 127.0 );
160
+		}
161
+
162
+		// Normalize interpolant
163
+		s /= 255.0;
164
+
165
+		// Go to middle or right
166
+		panim += m_pStudioHeader->numbones;
167
+
168
+		StudioCalcRotations( pos2, q2, pseqdesc, panim, f );
169
+
170
+		// Spherically interpolate the bones
171
+		StudioSlerpBones( q, pos, q2, pos2, s );
172
+	}
173
+	else
174
+	{
175
+		panim = StudioGetAnim( m_pRenderModel, pseqdesc );
176
+		StudioCalcRotations( pos, q, pseqdesc, panim, f );
177
+	}
178
+
179
+	// Are we in the process of transitioning from one sequence to another.
180
+	if ( m_fDoInterp &&
181
+		m_pCurrentEntity->latched.sequencetime &&
182
+		( m_pCurrentEntity->latched.sequencetime + 0.2 > m_clTime ) && 
183
+		( m_pCurrentEntity->latched.prevsequence < m_pStudioHeader->numseq ))
184
+	{
185
+		// blend from last sequence
186
+		static float		pos1b[MAXSTUDIOBONES][3];
187
+		static vec4_t		q1b[MAXSTUDIOBONES];
188
+		float				s;
189
+
190
+		// Blending value into last sequence
191
+		unsigned char prevseqblending = m_pCurrentEntity->latched.prevseqblending[ 0 ];
192
+
193
+		// Point at previous sequenece
194
+		pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->latched.prevsequence;
195
+		
196
+		// Know how to do three way blends
197
+		if ( pseqdesc->numblends == 3 )
198
+		{
199
+			float				s;
200
+
201
+			// Get left animation
202
+			panim = StudioGetAnim( m_pRenderModel, pseqdesc );
203
+
204
+			if ( prevseqblending <= 127 )
205
+			{
206
+				// Set up bones based on final frame of previous sequence
207
+				StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
208
+				
209
+				s = prevseqblending;
210
+				s = ( s * 2.0 );
211
+			}
212
+			else
213
+			{
214
+				// Skip to middle blend
215
+				panim += m_pStudioHeader->numbones;
216
+
217
+				StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
218
+
219
+				s = prevseqblending;
220
+				s = 2.0 * ( s - 127.0 );
221
+			}
222
+
223
+			// Normalize
224
+			s /= 255.0;
225
+
226
+			panim += m_pStudioHeader->numbones;
227
+			StudioCalcRotations( pos2, q2, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
228
+
229
+			// Interpolate bones
230
+			StudioSlerpBones( q1b, pos1b, q2, pos2, s );
231
+		}
232
+		else
233
+		{
234
+			panim = StudioGetAnim( m_pRenderModel, pseqdesc );
235
+			// clip prevframe
236
+			StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe );
237
+		}
238
+
239
+		// Now blend last frame of previous sequence with current sequence.
240
+		s = 1.0 - (m_clTime - m_pCurrentEntity->latched.sequencetime) / 0.2;
241
+		StudioSlerpBones( q, pos, q1b, pos1b, s );
242
+	}
243
+	else
244
+	{
245
+		m_pCurrentEntity->latched.prevframe = f;
246
+	}
247
+
248
+	// Now convert quaternions and bone positions into matrices
249
+	pbones = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex);
250
+
251
+	for (i = 0; i < m_pStudioHeader->numbones; i++) 
252
+	{
253
+		QuaternionMatrix( q[i], bonematrix );
254
+
255
+		bonematrix[0][3] = pos[i][0];
256
+		bonematrix[1][3] = pos[i][1];
257
+		bonematrix[2][3] = pos[i][2];
258
+
259
+		if (pbones[i].parent == -1) 
260
+		{
261
+			if ( IEngineStudio.IsHardware() )
262
+			{
263
+				ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_pbonetransform)[i]);
264
+				ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]);
265
+			}
266
+			else
267
+			{
268
+				ConcatTransforms ((*m_paliastransform), bonematrix, (*m_pbonetransform)[i]);
269
+				ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]);
270
+			}
271
+
272
+			// Apply client-side effects to the transformation matrix
273
+			StudioFxTransform( m_pCurrentEntity, (*m_pbonetransform)[i] );
274
+		} 
275
+		else 
276
+		{
277
+			ConcatTransforms ((*m_pbonetransform)[pbones[i].parent], bonematrix, (*m_pbonetransform)[i]);
278
+			ConcatTransforms ((*m_plighttransform)[pbones[i].parent], bonematrix, (*m_plighttransform)[i]);
279
+		}
280
+	}
281
+}
282
+
283
+/*
284
+====================
285
+StudioEstimateGait
286
+
287
+====================
288
+*/
289
+void CGameStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer )
290
+{
291
+	float dt;
292
+	vec3_t est_velocity;
293
+
294
+	dt = (m_clTime - m_clOldTime);
295
+	dt = max( 0.0, dt );
296
+	dt = min( 1.0, dt );
297
+
298
+	if (dt == 0 || m_pPlayerInfo->renderframe == m_nFrameCount)
299
+	{
300
+		m_flGaitMovement = 0;
301
+		return;
302
+	}
303
+
304
+	// VectorAdd( pplayer->velocity, pplayer->prediction_error, est_velocity );
305
+	if ( m_fGaitEstimation )
306
+	{
307
+		VectorSubtract( m_pCurrentEntity->origin, m_pPlayerInfo->prevgaitorigin, est_velocity );
308
+		VectorCopy( m_pCurrentEntity->origin, m_pPlayerInfo->prevgaitorigin );
309
+		m_flGaitMovement = Length( est_velocity );
310
+		if (dt <= 0 || m_flGaitMovement / dt < 5)
311
+		{
312
+			m_flGaitMovement = 0;
313
+			est_velocity[0] = 0;
314
+			est_velocity[1] = 0;
315
+		}
316
+	}
317
+	else
318
+	{
319
+		VectorCopy( pplayer->velocity, est_velocity );
320
+		m_flGaitMovement = Length( est_velocity ) * dt;
321
+	}
322
+
323
+	if (est_velocity[1] == 0 && est_velocity[0] == 0)
324
+	{
325
+		float flYawDiff = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
326
+		flYawDiff = flYawDiff - (int)(flYawDiff / 360) * 360;
327
+		if (flYawDiff > 180)
328
+			flYawDiff -= 360;
329
+		if (flYawDiff < -180)
330
+			flYawDiff += 360;
331
+
332
+		if (dt < 0.25)
333
+			flYawDiff *= dt * 4;
334
+		else
335
+			flYawDiff *= dt;
336
+
337
+		m_pPlayerInfo->gaityaw += flYawDiff;
338
+		m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)(m_pPlayerInfo->gaityaw / 360) * 360;
339
+
340
+		m_flGaitMovement = 0;
341
+	}
342
+	else
343
+	{
344
+		m_pPlayerInfo->gaityaw = (atan2(est_velocity[1], est_velocity[0]) * 180 / M_PI);
345
+		if (m_pPlayerInfo->gaityaw > 180)
346
+			m_pPlayerInfo->gaityaw = 180;
347
+		if (m_pPlayerInfo->gaityaw < -180)
348
+			m_pPlayerInfo->gaityaw = -180;
349
+	}
350
+
351
+}
352
+
353
+/*
354
+====================
355
+StudioProcessGait
356
+
357
+====================
358
+*/
359
+void CGameStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer )
360
+{
361
+	mstudioseqdesc_t	*pseqdesc;
362
+	float dt;
363
+	float flYaw;	 // view direction relative to movement
364
+
365
+	pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence;
366
+
367
+	m_pCurrentEntity->angles[PITCH] = 0;
368
+	m_pCurrentEntity->latched.prevangles[PITCH] = m_pCurrentEntity->angles[PITCH];
369
+
370
+	dt = (m_clTime - m_clOldTime);
371
+	dt = max( 0.0, dt );
372
+	dt = min( 1.0, dt );
373
+
374
+	StudioEstimateGait( pplayer );
375
+
376
+	// calc side to side turning
377
+	flYaw = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
378
+
379
+	flYaw = fmod( flYaw, 360.0 );
380
+
381
+	if (flYaw < -180)
382
+	{
383
+		flYaw = flYaw + 360;
384
+	}
385
+	else if (flYaw > 180)
386
+	{
387
+		flYaw = flYaw - 360;
388
+	}
389
+
390
+	float maxyaw = 120.0;
391
+
392
+	if (flYaw > maxyaw)
393
+	{
394
+		m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - 180;
395
+		m_flGaitMovement = -m_flGaitMovement;
396
+		flYaw = flYaw - 180;
397
+	}
398
+	else if (flYaw < -maxyaw)
399
+	{
400
+		m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw + 180;
401
+		m_flGaitMovement = -m_flGaitMovement;
402
+		flYaw = flYaw + 180;
403
+	}
404
+
405
+	float blend_yaw = ( flYaw / 90.0 ) * 128.0 + 127.0;
406
+	blend_yaw = min( 255.0, blend_yaw );
407
+	blend_yaw = max( 0.0, blend_yaw );
408
+	
409
+	blend_yaw = 255.0 - blend_yaw;
410
+
411
+	m_pCurrentEntity->curstate.blending[0] = (int)(blend_yaw);
412
+	m_pCurrentEntity->latched.prevblending[0] = m_pCurrentEntity->curstate.blending[0];
413
+	m_pCurrentEntity->latched.prevseqblending[0] = m_pCurrentEntity->curstate.blending[0];
414
+
415
+	m_pCurrentEntity->angles[YAW] = m_pPlayerInfo->gaityaw;
416
+	if (m_pCurrentEntity->angles[YAW] < -0)
417
+	{
418
+		m_pCurrentEntity->angles[YAW] += 360;
419
+	}
420
+	m_pCurrentEntity->latched.prevangles[YAW] = m_pCurrentEntity->angles[YAW];
421
+
422
+	pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + pplayer->gaitsequence;
423
+	
424
+	// Calc gait frame
425
+	if (pseqdesc->linearmovement[0] > 0)
426
+	{
427
+		m_pPlayerInfo->gaitframe += (m_flGaitMovement / pseqdesc->linearmovement[0]) * pseqdesc->numframes;
428
+	}
429
+	else
430
+	{
431
+		m_pPlayerInfo->gaitframe += pseqdesc->fps * dt * m_pCurrentEntity->curstate.framerate;
432
+	}
433
+
434
+	// Do modulo
435
+	m_pPlayerInfo->gaitframe = m_pPlayerInfo->gaitframe - (int)(m_pPlayerInfo->gaitframe / pseqdesc->numframes) * pseqdesc->numframes;
436
+	if (m_pPlayerInfo->gaitframe < 0)
437
+	{
438
+		m_pPlayerInfo->gaitframe += pseqdesc->numframes;
439
+	}
440
+}
441
+
442
+/*
443
+==============================
444
+SavePlayerState
445
+
446
+For local player, in third person, we need to store real render data and then
447
+  setup for with fake/client side animation data
448
+==============================
449
+*/
450
+void CGameStudioModelRenderer::SavePlayerState( entity_state_t *pplayer )
451
+{
452
+	client_anim_state_t *st;
453
+	cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
454
+	assert( ent );
455
+	if ( !ent )
456
+		return;
457
+
458
+	st = &g_state;
459
+
460
+	st->angles		= ent->curstate.angles;
461
+	st->origin		= ent->curstate.origin;
462
+
463
+	st->realangles	= ent->angles;
464
+
465
+	st->sequence	= ent->curstate.sequence;
466
+	st->gaitsequence = pplayer->gaitsequence;
467
+	st->animtime	= ent->curstate.animtime;
468
+	st->frame		= ent->curstate.frame;
469
+	st->framerate	= ent->curstate.framerate;
470
+	memcpy( st->blending, ent->curstate.blending, 2 );
471
+	memcpy( st->controller, ent->curstate.controller, 4 );
472
+
473
+	st->lv = ent->latched;
474
+}
475
+
476
+void GetSequenceInfo( void *pmodel, client_anim_state_t *pev, float *pflFrameRate, float *pflGroundSpeed )
477
+{
478
+	studiohdr_t *pstudiohdr;
479
+	
480
+	pstudiohdr = (studiohdr_t *)pmodel;
481
+	if (! pstudiohdr)
482
+		return;
483
+
484
+	mstudioseqdesc_t	*pseqdesc;
485
+
486
+	if (pev->sequence >= pstudiohdr->numseq)
487
+	{
488
+		*pflFrameRate = 0.0;
489
+		*pflGroundSpeed = 0.0;
490
+		return;
491
+	}
492
+
493
+	pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence;
494
+
495
+	if (pseqdesc->numframes > 1)
496
+	{
497
+		*pflFrameRate = 256 * pseqdesc->fps / (pseqdesc->numframes - 1);
498
+		*pflGroundSpeed = sqrt( pseqdesc->linearmovement[0]*pseqdesc->linearmovement[0]+ pseqdesc->linearmovement[1]*pseqdesc->linearmovement[1]+ pseqdesc->linearmovement[2]*pseqdesc->linearmovement[2] );
499
+		*pflGroundSpeed = *pflGroundSpeed * pseqdesc->fps / (pseqdesc->numframes - 1);
500
+	}
501
+	else
502
+	{
503
+		*pflFrameRate = 256.0;
504
+		*pflGroundSpeed = 0.0;
505
+	}
506
+}
507
+
508
+int GetSequenceFlags( void *pmodel, client_anim_state_t *pev )
509
+{
510
+	studiohdr_t *pstudiohdr;
511
+	
512
+	pstudiohdr = (studiohdr_t *)pmodel;
513
+	if ( !pstudiohdr || pev->sequence >= pstudiohdr->numseq )
514
+		return 0;
515
+
516
+	mstudioseqdesc_t	*pseqdesc;
517
+	pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + (int)pev->sequence;
518
+
519
+	return pseqdesc->flags;
520
+}
521
+
522
+float StudioFrameAdvance ( client_anim_state_t *st, float framerate, float flInterval )
523
+{
524
+	if (flInterval == 0.0)
525
+	{
526
+		flInterval = (gEngfuncs.GetClientTime() - st->animtime);
527
+		if (flInterval <= 0.001)
528
+		{
529
+			st->animtime = gEngfuncs.GetClientTime();
530
+			return 0.0;
531
+		}
532
+	}
533
+	if (!st->animtime)
534
+		flInterval = 0.0;
535
+	
536
+	st->frame += flInterval * framerate * st->framerate;
537
+	st->animtime = gEngfuncs.GetClientTime();
538
+
539
+	if (st->frame < 0.0 || st->frame >= 256.0) 
540
+	{
541
+		if ( st->m_fSequenceLoops )
542
+			st->frame -= (int)(st->frame / 256.0) * 256.0;
543
+		else
544
+			st->frame = (st->frame < 0.0) ? 0 : 255;
545
+		st->m_fSequenceFinished = TRUE;	// just in case it wasn't caught in GetEvents
546
+	}
547
+
548
+	return flInterval;
549
+}
550
+
551
+/*
552
+==============================
553
+SetupClientAnimation
554
+
555
+Called to set up local player's animation values
556
+==============================
557
+*/
558
+void CGameStudioModelRenderer::SetupClientAnimation( entity_state_t *pplayer )
559
+{
560
+	static double oldtime;
561
+	double curtime, dt;
562
+
563
+	client_anim_state_t *st;
564
+	float fr, gs;
565
+
566
+	cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
567
+	assert( ent );
568
+	if ( !ent )
569
+		return;
570
+
571
+	curtime = gEngfuncs.GetClientTime();
572
+	dt = curtime - oldtime;
573
+	dt = min( 1.0, max( 0.0, dt ) );
574
+
575
+	oldtime = curtime;
576
+	st = &g_clientstate;
577
+	
578
+	st->framerate = 1.0;
579
+
580
+	int oldseq = st->sequence;
581
+	Game_GetSequence( &st->sequence, &st->gaitsequence ); //CVAR_GET_FLOAT( "sequence" );
582
+	Game_GetOrientation( (float *)&st->origin, (float *)&st->angles );
583
+	st->realangles = st->angles;
584
+
585
+	if ( st->sequence != oldseq )
586
+	{
587
+		st->frame = 0.0;
588
+		st->lv.prevsequence = oldseq;
589
+		st->lv.sequencetime = st->animtime;
590
+
591
+		memcpy( st->lv.prevseqblending, st->blending, 2 );
592
+		memcpy( st->lv.prevcontroller, st->controller, 4 );
593
+	}
594
+
595
+	void *pmodel = (studiohdr_t *)IEngineStudio.Mod_Extradata( ent->model );
596
+
597
+	GetSequenceInfo( pmodel, st, &fr, &gs );
598
+	st->m_fSequenceLoops = ((GetSequenceFlags( pmodel, st ) & STUDIO_LOOPING) != 0);
599
+	StudioFrameAdvance( st, fr, dt );
600
+	
601
+//	gEngfuncs.Con_Printf( "gs %i frame %f\n", st->gaitsequence, st->frame );
602
+
603
+	ent->angles				= st->realangles;
604
+	ent->curstate.angles	= st->angles;
605
+	ent->curstate.origin	= st->origin;
606
+
607
+	ent->curstate.sequence	= st->sequence;
608
+	pplayer->gaitsequence = st->gaitsequence;
609
+	ent->curstate.animtime	= st->animtime;
610
+	ent->curstate.frame		= st->frame;
611
+	ent->curstate.framerate	= st->framerate;
612
+	memcpy( ent->curstate.blending, st->blending, 2 );
613
+	memcpy( ent->curstate.controller, st->controller, 4 );
614
+
615
+	ent->latched = st->lv;
616
+}
617
+
618
+/*
619
+==============================
620
+RestorePlayerState
621
+
622
+Called to restore original player state information
623
+==============================
624
+*/
625
+void CGameStudioModelRenderer::RestorePlayerState( entity_state_t *pplayer )
626
+{
627
+	client_anim_state_t *st;
628
+	cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
629
+	assert( ent );
630
+	if ( !ent )
631
+		return;
632
+
633
+	st = &g_clientstate;
634
+
635
+	st->angles		= ent->curstate.angles;
636
+	st->origin		= ent->curstate.origin;
637
+	st->realangles  = ent->angles;
638
+
639
+	st->sequence	= ent->curstate.sequence;
640
+	st->gaitsequence = pplayer->gaitsequence;
641
+	st->animtime	= ent->curstate.animtime;
642
+	st->frame		= ent->curstate.frame;
643
+	st->framerate	= ent->curstate.framerate;
644
+	memcpy( st->blending, ent->curstate.blending, 2 );
645
+	memcpy( st->controller, ent->curstate.controller, 4 );
646
+
647
+	st->lv = ent->latched;
648
+
649
+	st = &g_state;
650
+
651
+	ent->curstate.angles	= st->angles;
652
+	ent->curstate.origin	= st->origin;
653
+	ent->angles				= st->realangles;
654
+
655
+	ent->curstate.sequence	= st->sequence;
656
+	pplayer->gaitsequence = st->gaitsequence;
657
+	ent->curstate.animtime	= st->animtime;
658
+	ent->curstate.frame		= st->frame;
659
+	ent->curstate.framerate	= st->framerate;
660
+	memcpy( ent->curstate.blending, st->blending, 2 );
661
+	memcpy( ent->curstate.controller, st->controller, 4 );
662
+
663
+	ent->latched = st->lv;
664
+}
665
+
666
+/*
667
+==============================
668
+StudioDrawPlayer
669
+
670
+==============================
671
+*/
672
+int CGameStudioModelRenderer::StudioDrawPlayer( int flags, entity_state_t *pplayer )
673
+{
674
+	int iret = 0;
675
+
676
+	bool isLocalPlayer = false;
677
+		
678
+	// Set up for client?
679
+	if ( m_bLocal && IEngineStudio.GetCurrentEntity() == gEngfuncs.GetLocalPlayer() )
680
+	{
681
+		isLocalPlayer = true;
682
+	}
683
+
684
+	if ( isLocalPlayer )
685
+	{
686
+		// Store original data
687
+		SavePlayerState( pplayer );
688
+
689
+		// Copy in client side animation data
690
+		SetupClientAnimation( pplayer );
691
+	}
692
+
693
+	// Call real draw function
694
+	iret = _StudioDrawPlayer( flags, pplayer );
695
+
696
+	// Restore for client?
697
+	if ( isLocalPlayer )
698
+	{
699
+		// Restore the original data for the player
700
+		RestorePlayerState( pplayer );
701
+	}
702
+
703
+	return iret;
704
+}
705
+
706
+/*
707
+====================
708
+_StudioDrawPlayer
709
+
710
+====================
711
+*/
712
+int CGameStudioModelRenderer::_StudioDrawPlayer( int flags, entity_state_t *pplayer )
713
+{
714
+	alight_t lighting;
715
+	vec3_t dir;
716
+
717
+	m_pCurrentEntity = IEngineStudio.GetCurrentEntity();
718
+	IEngineStudio.GetTimes( &m_nFrameCount, &m_clTime, &m_clOldTime );
719
+	IEngineStudio.GetViewInfo( m_vRenderOrigin, m_vUp, m_vRight, m_vNormal );
720
+	IEngineStudio.GetAliasScale( &m_fSoftwareXScale, &m_fSoftwareYScale );
721
+
722
+	m_nPlayerIndex = pplayer->number - 1;
723
+
724
+	if (m_nPlayerIndex < 0 || m_nPlayerIndex >= gEngfuncs.GetMaxClients())
725
+		return 0;
726
+
727
+	m_pRenderModel = IEngineStudio.SetupPlayerModel( m_nPlayerIndex );
728
+	if (m_pRenderModel == NULL)
729
+		return 0;
730
+
731
+	m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (m_pRenderModel);
732
+	IEngineStudio.StudioSetHeader( m_pStudioHeader );
733
+	IEngineStudio.SetRenderModel( m_pRenderModel );
734
+
735
+	if (pplayer->gaitsequence)
736
+	{
737
+		vec3_t orig_angles;
738
+		m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
739
+
740
+		VectorCopy( m_pCurrentEntity->angles, orig_angles );
741
+	
742
+		StudioProcessGait( pplayer );
743
+
744
+		m_pPlayerInfo->gaitsequence = pplayer->gaitsequence;
745
+		m_pPlayerInfo = NULL;
746
+
747
+		StudioSetUpTransform( 0 );
748
+		VectorCopy( orig_angles, m_pCurrentEntity->angles );
749
+	}
750
+	else
751
+	{
752
+		m_pCurrentEntity->curstate.controller[0] = 127;
753
+		m_pCurrentEntity->curstate.controller[1] = 127;
754
+		m_pCurrentEntity->curstate.controller[2] = 127;
755
+		m_pCurrentEntity->curstate.controller[3] = 127;
756
+		m_pCurrentEntity->latched.prevcontroller[0] = m_pCurrentEntity->curstate.controller[0];
757
+		m_pCurrentEntity->latched.prevcontroller[1] = m_pCurrentEntity->curstate.controller[1];
758
+		m_pCurrentEntity->latched.prevcontroller[2] = m_pCurrentEntity->curstate.controller[2];
759
+		m_pCurrentEntity->latched.prevcontroller[3] = m_pCurrentEntity->curstate.controller[3];
760
+		
761
+		m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
762
+		m_pPlayerInfo->gaitsequence = 0;
763
+
764
+		StudioSetUpTransform( 0 );
765
+	}
766
+
767
+	if (flags & STUDIO_RENDER)
768
+	{
769
+		// see if the bounding box lets us trivially reject, also sets
770
+		if (!IEngineStudio.StudioCheckBBox ())
771
+			return 0;
772
+
773
+		(*m_pModelsDrawn)++;
774
+		(*m_pStudioModelCount)++; // render data cache cookie
775
+
776
+		if (m_pStudioHeader->numbodyparts == 0)
777
+			return 1;
778
+	}
779
+
780
+	m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
781
+	StudioSetupBones( );
782
+	StudioSaveBones( );
783
+	m_pPlayerInfo->renderframe = m_nFrameCount;
784
+
785
+	m_pPlayerInfo = NULL;
786
+
787
+	if (flags & STUDIO_EVENTS)
788
+	{
789
+		StudioCalcAttachments( );
790
+		IEngineStudio.StudioClientEvents( );
791
+		// copy attachments into global entity array
792
+		if ( m_pCurrentEntity->index > 0 )
793
+		{
794
+			cl_entity_t *ent = gEngfuncs.GetEntityByIndex( m_pCurrentEntity->index );
795
+
796
+			memcpy( ent->attachment, m_pCurrentEntity->attachment, sizeof( vec3_t ) * 4 );
797
+		}
798
+	}
799
+
800
+	if (flags & STUDIO_RENDER)
801
+	{
802
+		/*
803
+		if (m_pCvarHiModels->value && m_pRenderModel != m_pCurrentEntity->model  )
804
+		{
805
+			// show highest resolution multiplayer model
806
+			m_pCurrentEntity->curstate.body = 255;
807
+		}
808
+
809
+		if (!(m_pCvarDeveloper->value == 0 && gEngfuncs.GetMaxClients() == 1 ) && ( m_pRenderModel == m_pCurrentEntity->model ) )
810
+		{
811
+			m_pCurrentEntity->curstate.body = 1; // force helmet
812
+		}
813
+		*/
814
+
815
+		lighting.plightvec = dir;
816
+		IEngineStudio.StudioDynamicLight(m_pCurrentEntity, &lighting );
817
+
818
+		IEngineStudio.StudioEntityLight( &lighting );
819
+
820
+		// model and frame independant
821
+		IEngineStudio.StudioSetupLighting (&lighting);
822
+
823
+		m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex );
824
+
825
+		// get remap colors
826
+		m_nTopColor = m_pPlayerInfo->topcolor;
827
+		if (m_nTopColor < 0)
828
+			m_nTopColor = 0;
829
+		if (m_nTopColor > 360)
830
+			m_nTopColor = 360;
831
+		m_nBottomColor = m_pPlayerInfo->bottomcolor;
832
+		if (m_nBottomColor < 0)
833
+			m_nBottomColor = 0;
834
+		if (m_nBottomColor > 360)
835
+			m_nBottomColor = 360;
836
+
837
+		IEngineStudio.StudioSetRemapColors( m_nTopColor, m_nBottomColor );
838
+
839
+		StudioRenderModel( );
840
+		m_pPlayerInfo = NULL;
841
+
842
+		if (pplayer->weaponmodel)
843
+		{
844
+			cl_entity_t saveent = *m_pCurrentEntity;
845
+
846
+			model_t *pweaponmodel = IEngineStudio.GetModelByIndex( pplayer->weaponmodel );
847
+
848
+			m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (pweaponmodel);
849
+			IEngineStudio.StudioSetHeader( m_pStudioHeader );
850
+
851
+			StudioMergeBones( pweaponmodel);
852
+
853
+			IEngineStudio.StudioSetupLighting (&lighting);
854
+
855
+			StudioRenderModel( );
856
+
857
+			StudioCalcAttachments( );
858
+
859
+			*m_pCurrentEntity = saveent;
860
+		}
861
+	}
862
+
863
+	return 1;
864
+}
865
+
866
+/*
867
+====================
868
+Studio_FxTransform
869
+
870
+====================
871
+*/
872
+void CGameStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[3][4] )
873
+{
874
+	switch( ent->curstate.renderfx )
875
+	{
876
+	case kRenderFxDistort:
877
+	case kRenderFxHologram:
878
+		if ( gEngfuncs.pfnRandomLong(0,49) == 0 )
879
+		{
880
+			int axis = gEngfuncs.pfnRandomLong(0,1);
881
+			if ( axis == 1 ) // Choose between x & z
882
+				axis = 2;
883
+			VectorScale( transform[axis], gEngfuncs.pfnRandomFloat(1,1.484), transform[axis] );
884
+		}
885
+		else if ( gEngfuncs.pfnRandomLong(0,49) == 0 )
886
+		{
887
+			float offset;
888
+			int axis = gEngfuncs.pfnRandomLong(0,1);
889
+			if ( axis == 1 ) // Choose between x & z
890
+				axis = 2;
891
+			offset = gEngfuncs.pfnRandomFloat(-10,10);
892
+			transform[gEngfuncs.pfnRandomLong(0,2)][3] += offset;
893
+		}
894
+		break;
895
+	case kRenderFxExplode:
896
+		{
897
+			if ( iRenderStateChanged )
898
+			{
899
+				g_flStartScaleTime = m_clTime;
900
+				iRenderStateChanged = FALSE;
901
+			}
902
+
903
+			// Make the Model continue to shrink
904
+			float flTimeDelta = m_clTime - g_flStartScaleTime;
905
+			if ( flTimeDelta > 0 )
906
+			{
907
+				float flScale = 0.001;
908
+				// Goes almost all away
909
+				if ( flTimeDelta <= 2.0 )
910
+					flScale = 1.0 - (flTimeDelta / 2.0);
911
+
912
+				for (int i = 0; i < 3; i++)
913
+				{
914
+					for (int j = 0; j < 3; j++)
915
+						transform[i][j] *= flScale;
916
+				}
917
+			}
918
+		}
919
+		break;
920
+	}
921
+}
922
+
923
+////////////////////////////////////
924
+// Hooks to class implementation
925
+////////////////////////////////////
926
+
927
+/*
928
+====================
929
+R_StudioDrawPlayer
930
+
931
+====================
932
+*/
933
+int R_StudioDrawPlayer( int flags, entity_state_t *pplayer )
934
+{
935
+	return g_StudioRenderer.StudioDrawPlayer( flags, pplayer );
936
+}
937
+
938
+/*
939
+====================
940
+R_StudioDrawModel
941
+
942
+====================
943
+*/
944
+int R_StudioDrawModel( int flags )
945
+{
946
+	return g_StudioRenderer.StudioDrawModel( flags );
947
+}
948
+
949
+/*
950
+====================
951
+R_StudioInit
952
+
953
+====================
954
+*/
955
+void R_StudioInit( void )
956
+{
957
+	g_StudioRenderer.Init();
958
+}
959
+
960
+// The simple drawing interface we'll pass back to the engine
961
+r_studio_interface_t studio =
962
+{
963
+	STUDIO_INTERFACE_VERSION,
964
+	R_StudioDrawModel,
965
+	R_StudioDrawPlayer,
966
+};
967
+
968
+/*
969
+====================
970
+HUD_GetStudioModelInterface
971
+
972
+Export this function for the engine to use the studio renderer class to render objects.
973
+====================
974
+*/
975
+#define DLLEXPORT __declspec( dllexport )
976
+extern "C" int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
977
+{
978
+	if ( version != STUDIO_INTERFACE_VERSION )
979
+		return 0;
980
+
981
+	// Point the engine to our callbacks
982
+	*ppinterface = &studio;
983
+
984
+	// Copy in engine helper functions
985
+	memcpy( &IEngineStudio, pstudio, sizeof( IEngineStudio ) );
986
+
987
+	// Initialize local variables, etc.
988
+	R_StudioInit();
989
+
990
+	// Success
991
+	return 1;
992
+}

+ 55
- 0
cl_dll/GameStudioModelRenderer_Sample.h View File

@@ -0,0 +1,55 @@
1
+//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
2
+//
3
+// Purpose: 
4
+//
5
+// $NoKeywords: $
6
+//=============================================================================
7
+
8
+#if !defined( GAMESTUDIOMODELRENDERER_H )
9
+#define GAMESTUDIOMODELRENDERER_H
10
+#if defined( _WIN32 )
11
+#pragma once
12
+#endif
13
+
14
+/*
15
+====================
16
+CGameStudioModelRenderer
17
+
18
+====================
19
+*/
20
+class CGameStudioModelRenderer : public CStudioModelRenderer
21
+{
22
+public:
23
+	CGameStudioModelRenderer( void );
24
+
25
+	// Set up model bone positions
26
+	virtual void StudioSetupBones ( void );	
27
+
28
+	// Estimate gait frame for player
29
+	virtual void StudioEstimateGait ( entity_state_t *pplayer );
30
+
31
+	// Process movement of player
32
+	virtual void StudioProcessGait ( entity_state_t *pplayer );
33
+
34
+	// Player drawing code
35
+	virtual int StudioDrawPlayer( int flags, entity_state_t *pplayer );
36
+	virtual int _StudioDrawPlayer( int flags, entity_state_t *pplayer );
37
+
38
+	// Apply special effects to transform matrix
39
+	virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] );
40
+
41
+private:
42
+	// For local player, in third person, we need to store real render data and then
43
+	//  setup for with fake/client side animation data
44
+	void SavePlayerState( entity_state_t *pplayer );
45
+	// Called to set up local player's animation values
46
+	void SetupClientAnimation( entity_state_t *pplayer );
47
+	// Called to restore original player state information
48
+	void RestorePlayerState( entity_state_t *pplayer );
49
+
50
+private: 
51
+	// Private data
52
+	bool m_bLocal;
53
+};
54
+
55
+#endif // GAMESTUDIOMODELRENDERER_H

+ 155
- 0
cl_dll/MOTD.cpp View File

@@ -0,0 +1,155 @@
1
+/***
2
+*
3
+*	Copyright (c) 1999, Valve LLC. All rights reserved.
4
+*	
5
+*	This product contains software technology licensed from Id 
6
+*	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
7
+*	All Rights Reserved.
8
+*
9
+*   Use, distribution, and modification of this source code and/or resulting
10
+*   object code is restricted to non-commercial enhancements to products from
11
+*   Valve LLC.  All other use, distribution, or modification is prohibited
12
+*   without written permission from Valve LLC.
13
+*
14
+****/
15
+//
16
+// MOTD.cpp
17
+//
18
+// for displaying a server-sent message of the day
19
+//
20
+
21
+#include "hud.h"
22
+#include "cl_util.h"
23
+#include "parsemsg.h"
24
+
25
+#include <string.h>
26
+#include <stdio.h>
27
+
28
+//DECLARE_MESSAGE( m_MOTD, MOTD );
29
+
30
+int CHudMOTD::MOTD_DISPLAY_TIME;
31
+
32
+int CHudMOTD :: Init( void )
33
+{
34
+	gHUD.AddHudElem( this );
35
+
36
+	// HOOK_MESSAGE( MOTD );
37
+
38
+	CVAR_CREATE( "motd_display_time", "15", 0 );
39
+
40
+	m_iFlags &= ~HUD_ACTIVE;  // start out inactive
41
+	m_szMOTD[0] = 0;
42
+
43
+	return 1;
44
+}
45
+
46
+int CHudMOTD :: VidInit( void )
47
+{
48
+	// Load sprites here
49
+
50
+	return 1;
51
+}
52
+
53
+void CHudMOTD :: Reset( void )
54
+{
55
+	m_iFlags &= ~HUD_ACTIVE;  // start out inactive
56
+	m_szMOTD[0] = 0;
57
+	m_iLines = 0;
58
+	m_flActiveRemaining = 0;
59
+}
60
+
61
+#define LINE_HEIGHT  13
62
+
63
+int CHudMOTD :: Draw( float fTime )
64
+{
65
+	static float sfLastTime;
66
+	float fElapsed;
67
+
68
+	// Draw MOTD line-by-line
69
+	if ( m_flActiveRemaining <= 0.0 )
70
+	{ 
71
+		// finished with MOTD, disable it
72
+		m_szMOTD[0] = 0;
73
+		m_iLines = 0;
74
+		m_iFlags &= ~HUD_ACTIVE;
75
+		m_flActiveRemaining = 0.0;
76
+		return 1;
77
+	}
78
+
79
+	fElapsed = gHUD.m_flTime - sfLastTime;
80
+
81
+	// Don't let time go negative ( level transition? )
82
+	fElapsed = max( 0.0, fElapsed );
83
+	// Don't let time go hugely positive ( first connection to active server ? )
84
+	fElapsed = min( 1.0, fElapsed );
85
+
86
+	// Remember last timestamp
87
+	sfLastTime = gHUD.m_flTime;
88
+
89
+	// Remove a bit of time
90
+	m_flActiveRemaining -= fElapsed;
91
+
92
+	// find the top of where the MOTD should be drawn,  so the whole thing is centered in the screen
93
+	int ypos = max(((ScreenHeight - (m_iLines * LINE_HEIGHT)) / 2) - 40, 30 ); // shift it up slightly
94
+	char *ch = m_szMOTD;
95
+	while ( *ch )
96
+	{
97
+		int line_length = 0;  // count the length of the current line
98
+		for ( char *next_line = ch; *next_line != '\n' && *next_line != 0; next_line++ )
99
+			line_length += gHUD.m_scrinfo.charWidths[ *next_line ];
100
+		char *top = next_line;
101
+		if ( *top == '\n' )
102
+			*top = 0;
103
+		else
104
+			top = NULL;
105
+
106
+		// find where to start drawing the line
107
+		int xpos = (ScreenWidth - line_length) / 2;
108
+
109
+		gHUD.DrawHudString( xpos, ypos, ScreenWidth, ch, 255, 180, 0 );
110
+
111
+		ypos += LINE_HEIGHT;
112
+
113
+		if ( top )  // restore 
114
+			*top = '\n';
115
+		ch = next_line;
116
+		if ( *ch == '\n' )
117
+			ch++;
118
+
119
+		if ( ypos > (ScreenHeight - 20) )
120
+			break;  // don't let it draw too low
121
+	}
122
+	
123
+	return 1;
124
+}
125
+
126
+int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
127
+{
128
+	if ( m_iFlags & HUD_ACTIVE )
129
+	{
130
+		Reset(); // clear the current MOTD in prep for this one
131
+	}
132
+
133
+	BEGIN_READ( pbuf, iSize );
134
+
135
+	int is_finished = READ_BYTE();
136
+	strcat( m_szMOTD, READ_STRING() );
137
+
138
+	if ( is_finished )
139
+	{
140
+		m_iFlags |= HUD_ACTIVE;
141
+
142
+		MOTD_DISPLAY_TIME = max( 10, CVAR_GET_FLOAT( "motd_display_time" ) );
143
+
144
+		m_flActiveRemaining = MOTD_DISPLAY_TIME;
145
+
146
+		for ( char *sz = m_szMOTD; *sz != 0; sz++ )  // count the number of lines in the MOTD
147
+		{
148
+			if ( *sz == '\n' )
149
+				m_iLines++;
150
+		}
151
+	}
152
+
153
+	return 1;
154
+}
155
+

+ 2114
- 0
cl_dll/StudioModelRenderer.cpp
File diff suppressed because it is too large
View File


+ 189
- 0
cl_dll/StudioModelRenderer.h View File

@@ -0,0 +1,189 @@
1
+//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
2
+//
3
+// Purpose: 
4
+//
5
+// $NoKeywords: $
6
+//=============================================================================
7
+
8
+#if !defined ( STUDIOMODELRENDERER_H )
9
+#define STUDIOMODELRENDERER_H
10
+#if defined( _WIN32 )
11
+#pragma once
12
+#endif
13
+
14
+/*
15
+====================
16
+CStudioModelRenderer
17
+
18
+====================
19
+*/
20
+class CStudioModelRenderer
21
+{
22
+public:
23
+	// Construction/Destruction
24
+	CStudioModelRenderer( void );
25
+	virtual ~CStudioModelRenderer( void );
26
+
27
+	// Initialization
28
+	virtual void Init( void );
29
+
30
+public:  
31
+	// Public Interfaces
32
+	virtual int StudioDrawModel ( int flags );
33
+	virtual int StudioDrawPlayer ( int flags, struct entity_state_s *pplayer );
34
+
35
+public:
36
+	// Local interfaces
37
+	//
38
+
39
+	// Look up animation data for sequence
40
+	virtual mstudioanim_t *StudioGetAnim ( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
41
+
42
+	// Interpolate model position and angles and set up matrices
43
+	virtual void StudioSetUpTransform (int trivial_accept);
44
+
45
+	// Set up model bone positions
46
+	virtual void StudioSetupBones ( void );	
47
+
48
+	// Find final attachment points
49
+	virtual void StudioCalcAttachments ( void );
50
+	
51
+	// Save bone matrices and names
52
+	virtual void StudioSaveBones( void );
53
+
54
+	// Merge cached bones with current bones for model
55
+	virtual void StudioMergeBones ( model_t *m_pSubModel );
56
+
57
+	// Determine interpolation fraction
58
+	virtual float StudioEstimateInterpolant( void );
59
+
60
+	// Determine current frame for rendering
61
+	virtual float StudioEstimateFrame ( mstudioseqdesc_t *pseqdesc );
62
+
63
+	// Apply special effects to transform matrix
64
+	virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] );
65
+
66
+	// Spherical interpolation of bones
67
+	virtual void StudioSlerpBones ( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s );
68
+
69
+	// Compute bone adjustments ( bone controllers )
70
+	virtual void StudioCalcBoneAdj ( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen );
71
+
72
+	// Get bone quaternions
73
+	virtual void StudioCalcBoneQuaterion ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q );
74
+
75
+	// Get bone positions
76
+	virtual void StudioCalcBonePosition ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos );
77
+
78
+	// Compute rotations
79
+	virtual void StudioCalcRotations ( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f );
80
+
81
+	// Send bones and verts to renderer
82
+	virtual void StudioRenderModel ( void );
83
+
84
+	// Finalize rendering
85
+	virtual void StudioRenderFinal (void);
86
+	
87
+	// GL&D3D vs. Software renderer finishing functions
88
+	virtual void StudioRenderFinal_Software ( void );
89
+	virtual void StudioRenderFinal_Hardware ( void );
90
+
91
+	// Player specific data
92
+	// Determine pitch and blending amounts for players
93
+	virtual void StudioPlayerBlend ( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch );
94
+
95
+	// Estimate gait frame for player
96
+	virtual void StudioEstimateGait ( entity_state_t *pplayer );
97
+
98
+	// Process movement of player
99
+	virtual void StudioProcessGait ( entity_state_t *pplayer );
100
+
101
+public:
102
+
103
+	// Client clock
104
+	double			m_clTime;				
105
+	// Old Client clock
106
+	double			m_clOldTime;			
107
+
108
+	// Do interpolation?
109
+	int				m_fDoInterp;			
110
+	// Do gait estimation?
111
+	int				m_fGaitEstimation;		
112
+
113
+	// Current render frame #
114
+	int				m_nFrameCount;
115
+
116
+	// Cvars that studio model code needs to reference
117
+	//
118
+	// Use high quality models?
119
+	cvar_t			*m_pCvarHiModels;	
120
+	// Developer debug output desired?
121
+	cvar_t			*m_pCvarDeveloper;
122
+	// Draw entities bone hit boxes, etc?
123
+	cvar_t			*m_pCvarDrawEntities;
124
+
125
+	// The entity which we are currently rendering.
126
+	cl_entity_t		*m_pCurrentEntity;		
127
+
128
+	// The model for the entity being rendered
129
+	model_t			*m_pRenderModel;
130
+
131
+	// Player info for current player, if drawing a player
132
+	player_info_t	*m_pPlayerInfo;
133
+
134
+	// The index of the player being drawn
135
+	int				m_nPlayerIndex;
136
+
137
+	// The player's gait movement
138
+	float			m_flGaitMovement;
139
+
140
+	// Pointer to header block for studio model data
141
+	studiohdr_t		*m_pStudioHeader;
142
+	
143
+	// Pointers to current body part and submodel
144
+	mstudiobodyparts_t *m_pBodyPart;
145
+	mstudiomodel_t	*m_pSubModel;
146
+
147
+	// Palette substition for top and bottom of model
148
+	int				m_nTopColor;			
149
+	int				m_nBottomColor;
150
+
151
+	//
152
+	// Sprite model used for drawing studio model chrome
153
+	model_t			*m_pChromeSprite;
154
+
155
+	// Caching
156
+	// Number of bones in bone cache
157
+	int				m_nCachedBones; 
158
+	// Names of cached bones
159
+	char			m_nCachedBoneNames[ MAXSTUDIOBONES ][ 32 ];
160
+	// Cached bone & light transformation matrices
161
+	float			m_rgCachedBoneTransform [ MAXSTUDIOBONES ][ 3 ][ 4 ];
162
+	float			m_rgCachedLightTransform[ MAXSTUDIOBONES ][ 3 ][ 4 ];
163
+
164
+	// Software renderer scale factors
165
+	float			m_fSoftwareXScale, m_fSoftwareYScale;
166
+
167
+	// Current view vectors and render origin
168
+	float			m_vUp[ 3 ];
169
+	float			m_vRight[ 3 ];
170
+	float			m_vNormal[ 3 ];
171
+
172
+	float			m_vRenderOrigin[ 3 ];
173
+	
174
+	// Model render counters ( from engine )
175
+	int				*m_pStudioModelCount;
176
+	int				*m_pModelsDrawn;
177
+
178
+	// Matrices
179
+	// Model to world transformation
180
+	float			(*m_protationmatrix)[ 3 ][ 4 ];	
181
+	// Model to view transformation
182
+	float			(*m_paliastransform)[ 3 ][ 4 ];	
183
+
184
+	// Concatenated bone and light transforms
185
+	float			(*m_pbonetransform) [ MAXSTUDIOBONES ][ 3 ][ 4 ];
186
+	float			(*m_plighttransform)[ MAXSTUDIOBONES ][ 3 ][ 4 ];
187
+};
188
+
189
+#endif // STUDIOMODELRENDERER_H

+ 1200
- 0
cl_dll/ammo.cpp
File diff suppressed because it is too large
View File


+ 62
- 0
cl_dll/ammo.h View File

@@ -0,0 +1,62 @@
1
+/***
2
+*
3
+*	Copyright (c) 1996-2002, Valve LLC. All rights reserved.
4
+*	
5
+*	This product contains software technology licensed from Id 
6
+*	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
7
+*	All Rights Reserved.
8
+*
9
+*   Use, distribution, and modification of this source code and/or resulting
10
+*   object code is restricted to non-commercial enhancements to products from
11
+*   Valve LLC.  All other use, distribution, or modification is prohibited
12
+*   without written permission from Valve LLC.
13
+*
14
+****/
15
+
16
+#ifndef __AMMO_H__
17
+#define __AMMO_H__
18
+
19
+#define MAX_WEAPON_NAME 128
20
+
21
+
22
+#define WEAPON_FLAGS_SELECTONEMPTY	1
23
+
24
+#define WEAPON_IS_ONTARGET 0x40
25
+
26
+struct WEAPON
27
+{
28
+	char	szName[MAX_WEAPON_NAME];
29
+	int		iAmmoType;
30
+	int		iAmmo2Type;
31
+	int		iMax1;
32
+	int		iMax2;
33
+	int		iSlot;
34
+	int		iSlotPos;
35
+	int		iFlags;
36
+	int		iId;
37
+	int		iClip;
38
+
39
+	int		iCount;		// # of itesm in plist
40
+
41
+	HSPRITE hActive;
42
+	wrect_t rcActive;
43
+	HSPRITE hInactive;
44
+	wrect_t rcInactive;
45
+	HSPRITE	hAmmo;
46
+	wrect_t rcAmmo;
47
+	HSPRITE hAmmo2;
48
+	wrect_t rcAmmo2;
49
+	HSPRITE hCrosshair;
50
+	wrect_t rcCrosshair;
51
+	HSPRITE hAutoaim;
52
+	wrect_t rcAutoaim;
53
+	HSPRITE hZoomedCrosshair;
54
+	wrect_t rcZoomedCrosshair;
55
+	HSPRITE hZoomedAutoaim;
56
+	wrect_t rcZoomedAutoaim;
57
+};
58
+
59
+typedef int AMMO;
60
+
61
+
62
+#endif

+ 159
- 0
cl_dll/ammo_secondary.cpp View File

@@ -0,0 +1,159 @@
1
+/***
2
+*
3
+*	Copyright (c) 1996-2002, Valve LLC. All rights reserved.
4
+*	
5
+*	This product contains software technology licensed from Id 
6
+*	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
7
+*	All Rights Reserved.
8
+*
9
+*   Use, distribution, and modification of this source code and/or resulting
10
+*   object code is restricted to non-commercial enhancements to products from
11
+*   Valve LLC.  All other use, distribution, or modification is prohibited
12
+*   without written permission from Valve LLC.
13
+*
14
+****/
15
+//
16
+// ammo_secondary.cpp
17
+//
18
+// implementation of CHudAmmoSecondary class
19
+//
20
+
21
+#include "hud.h"
22
+#include "cl_util.h"
23
+#include <string.h>
24
+#include <stdio.h>
25
+#include "parsemsg.h"
26
+
27
+DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal );
28
+DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon );
29
+
30
+int CHudAmmoSecondary :: Init( void )
31
+{
32
+	HOOK_MESSAGE( SecAmmoVal );
33
+	HOOK_MESSAGE( SecAmmoIcon );
34
+
35
+	gHUD.AddHudElem(this);
36
+	m_HUD_ammoicon = 0;
37
+
38
+	for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
39
+		m_iAmmoAmounts[i] = -1;  // -1 means don't draw this value
40
+
41
+	Reset();
42
+
43
+	return 1;
44
+}
45
+
46
+void CHudAmmoSecondary :: Reset( void )
47
+{
48
+	m_fFade = 0;
49
+}
50
+
51
+int CHudAmmoSecondary :: VidInit( void )
52
+{
53
+	return 1;
54
+}
55
+
56
+int CHudAmmoSecondary :: Draw(float flTime)
57
+{
58
+	if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
59
+		return 1;
60
+
61
+	// draw secondary ammo icons above normal ammo readout
62
+	int a, x, y, r, g, b, AmmoWidth;
63
+	UnpackRGB( r, g, b, RGB_YELLOWISH );
64
+	a = (int) max( MIN_ALPHA, m_fFade );
65
+	if (m_fFade > 0)
66
+		m_fFade -= (gHUD.m_flTimeDelta * 20);  // slowly lower alpha to fade out icons
67
+	ScaleColors( r, g, b, a );
68
+
69
+	AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
70
+
71
+	y = ScreenHeight - (gHUD.m_iFontHeight*4);  // this is one font height higher than the weapon ammo values
72
+	x = ScreenWidth - AmmoWidth;
73
+
74
+	if ( m_HUD_ammoicon )
75
+	{
76
+		// Draw the ammo icon
77
+		x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left);
78
+		y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom);
79
+
80
+		SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b );
81
+		SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) );
82
+	}
83
+	else
84
+	{  // move the cursor by the '0' char instead, since we don't have an icon to work with
85
+		x -= AmmoWidth;
86
+		y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom);
87
+	}
88
+
89
+	// draw the ammo counts, in reverse order, from right to left
90
+	for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
91
+	{
92
+		if ( m_iAmmoAmounts[i] < 0 )
93
+			continue; // negative ammo amounts imply that they shouldn't be drawn
94
+
95
+		// half a char gap between the ammo number and the previous pic
96
+		x -= (AmmoWidth / 2);
97
+
98
+		// draw the number, right-aligned
99
+		x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth);
100
+		gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );
101
+
102
+		if ( i != 0 )
103
+		{
104
+			// draw the divider bar
105
+			x -= (AmmoWidth / 2);
106
+			FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a);
107
+		}
108
+	}
109
+
110
+	return 1;
111
+}
112
+
113
+// Message handler for Secondary Ammo Value
114
+// accepts one value:
115
+//		string:  sprite name
116
+int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf )
117
+{
118
+	BEGIN_READ( pbuf, iSize );
119
+	m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() );
120
+
121
+	return 1;
122
+}
123
+
124
+// Message handler for Secondary Ammo Icon
125
+// Sets an ammo value
126
+// takes two values:
127
+//		byte:  ammo index
128
+//		byte:  ammo value
129
+int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf )
130
+{
131
+	BEGIN_READ( pbuf, iSize );
132
+
133
+	int index = READ_BYTE();
134
+	if ( index < 0 || index >= MAX_SEC_AMMO_VALUES )
135
+		return 1;
136
+
137
+	m_iAmmoAmounts[index] = READ_BYTE();
138
+	m_iFlags |= HUD_ACTIVE;
139
+
140
+	// check to see if there is anything left to draw
141
+	int count = 0;
142
+	for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
143
+	{
144
+		count += max( 0, m_iAmmoAmounts[i] );
145
+	}
146
+
147
+	if ( count == 0 ) 
148
+	{	// the ammo fields are all empty, so turn off this hud area
149
+		m_iFlags &= ~HUD_ACTIVE;
150
+		return 1;
151
+	}
152
+
153
+	// make the icons light up
154
+	m_fFade = 200.0f;
155
+
156
+	return 1;
157
+}
158
+
159
+

+ 190
- 0
cl_dll/ammohistory.cpp View File

@@ -0,0 +1,190 @@
1
+/***
2
+*
3
+*	Copyright (c) 1996-2002, Valve LLC. All rights reserved.
4
+*	
5
+*	This product contains software technology licensed from Id 
6
+*	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
7
+*	All Rights Reserved.
8
+*
9
+*   Use, distribution, and modification of this source code and/or resulting
10
+*   object code is restricted to non-commercial enhancements to products from
11
+*   Valve LLC.  All other use, distribution, or modification is prohibited
12
+*   without written permission from Valve LLC.
13
+*
14
+****/
15
+//
16
+//  ammohistory.cpp
17
+//
18
+
19
+
20
+#include "hud.h"
21
+#include "cl_util.h"
22
+#include "parsemsg.h"
23
+
24
+#include <string.h>
25
+#include <stdio.h>
26
+
27
+#include "ammohistory.h"
28
+
29
+HistoryResource gHR;
30
+
31
+#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5)
32
+#define AMMO_PICKUP_PICK_HEIGHT		(32 + (gHR.iHistoryGap * 2))
33
+#define AMMO_PICKUP_HEIGHT_MAX		(ScreenHeight - 100)
34
+
35
+#define MAX_ITEM_NAME	32
36
+int HISTORY_DRAW_TIME = 5;
37
+
38
+// keep a list of items
39
+struct ITEM_INFO
40
+{
41
+	char szName[MAX_ITEM_NAME];
42
+	HSPRITE spr;
43
+	wrect_t rect;
44
+};
45
+
46
+void HistoryResource :: AddToHistory( int iType, int iId, int iCount )
47
+{
48
+	if ( iType == HISTSLOT_AMMO && !iCount )
49
+		return;  // no amount, so don't add
50
+
51
+	if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
52
+	{	// the pic would have to be drawn too high
53
+		// so start from the bottom
54
+		iCurrentHistorySlot = 0;
55
+	}
56
+	
57
+	HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++];  // default to just writing to the first slot
58
+	HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
59
+
60
+	freeslot->type = iType;
61
+	freeslot->iId = iId;
62
+	freeslot->iCount = iCount;
63
+	freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
64
+}
65
+
66
+void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount )
67
+{
68
+	if ( iType != HISTSLOT_ITEM )
69
+		return;
70
+
71
+	if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) )
72
+	{	// the pic would have to be drawn too high
73
+		// so start from the bottom
74
+		iCurrentHistorySlot = 0;
75
+	}
76
+
77
+	HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++];  // default to just writing to the first slot
78
+
79
+	// I am really unhappy with all the code in this file
80
+
81
+	int i = gHUD.GetSpriteIndex( szName );
82
+	if ( i == -1 )
83
+		return;  // unknown sprite name, don't add it to history
84
+
85
+	freeslot->iId = i;
86
+	freeslot->type = iType;
87
+	freeslot->iCount = iCount;
88
+
89
+	HISTORY_DRAW_TIME = CVAR_GET_FLOAT( "hud_drawhistory_time" );
90
+	freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME;
91
+}
92
+
93
+
94
+void HistoryResource :: CheckClearHistory( void )
95
+{
96
+	for ( int i = 0; i < MAX_HISTORY; i++ )
97
+	{
98
+		if ( rgAmmoHistory[i].type )
99
+			return;
100
+	}
101
+
102
+	iCurrentHistorySlot = 0;
103
+}
104
+
105
+//
106
+// Draw Ammo pickup history
107
+//
108
+int HistoryResource :: DrawAmmoHistory( float flTime )
109
+{
110
+	for ( int i = 0; i < MAX_HISTORY; i++ )
111
+	{
112
+		if ( rgAmmoHistory[i].type )
113
+		{
114
+			rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
115
+
116
+			if ( rgAmmoHistory[i].DisplayTime <= flTime )
117
+			{  // pic drawing time has expired
118
+				memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) );
119
+				CheckClearHistory();
120
+			}
121
+			else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO )
122
+			{
123
+				wrect_t rcPic;
124
+				HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic );
125
+
126
+				int r, g, b;
127
+				UnpackRGB(r,g,b, RGB_YELLOWISH);
128
+				float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
129
+				ScaleColors(r, g, b, min(scale, 255) );
130
+
131
+				// Draw the pic
132
+				int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
133
+				int xpos = ScreenWidth - 24;
134
+				if ( spr && *spr )    // weapon isn't loaded yet so just don't draw the pic
135
+				{ // the dll has to make sure it has sent info the weapons you need
136
+					SPR_Set( *spr, r, g, b );
137
+					SPR_DrawAdditive( 0, xpos, ypos, &rcPic );
138
+				}
139
+
140
+				// Draw the number
141
+				gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
142
+			}
143
+			else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP )
144
+			{
145
+				WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId );
146
+
147
+				if ( !weap )
148
+					return 1;  // we don't know about the weapon yet, so don't draw anything
149
+
150
+				int r, g, b;
151
+				UnpackRGB(r,g,b, RGB_YELLOWISH);
152
+
153
+				if ( !gWR.HasAmmo( weap ) )
154
+					UnpackRGB(r,g,b, RGB_REDISH);	// if the weapon doesn't have ammo, display it as red
155
+
156
+				float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
157
+				ScaleColors(r, g, b, min(scale, 255) );
158
+
159
+				int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
160
+				int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
161
+				SPR_Set( weap->hInactive, r, g, b );
162
+				SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive );
163
+			}
164
+			else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM )
165
+			{
166
+				int r, g, b;
167
+
168
+				if ( !rgAmmoHistory[i].iId )
169
+					continue;  // sprite not loaded
170
+
171
+				wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId );
172
+
173
+				UnpackRGB(r,g,b, RGB_YELLOWISH);
174
+				float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
175
+				ScaleColors(r, g, b, min(scale, 255) );
176
+
177
+				int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
178
+				int xpos = ScreenWidth - (rect.right - rect.left) - 10;
179
+
180
+				SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b );
181
+				SPR_DrawAdditive( 0, xpos, ypos, &rect );
182
+			}
183
+		}
184
+	}
185
+
186
+
187
+	return 1;
188
+}
189
+
190
+

+ 143
- 0
cl_dll/ammohistory.h View File

@@ -0,0 +1,143 @@
1
+/***
2
+*
3
+*	Copyright (c) 1996-2002, Valve LLC. All rights reserved.
4
+*	
5
+*	This product contains software technology licensed from Id 
6
+*	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
7
+*	All Rights Reserved.
8
+*
9
+*   Use, distribution, and modification of this source code and/or resulting
10
+*   object code is restricted to non-commercial enhancements to products from
11
+*   Valve LLC.  All other use, distribution, or modification is prohibited
12
+*   without written permission from Valve LLC.
13
+*
14
+****/
15
+//
16
+// ammohistory.h
17
+//
18
+
19
+// this is the max number of items in each bucket
20
+#define MAX_WEAPON_POSITIONS		MAX_WEAPON_SLOTS
21
+
22
+class WeaponsResource
23
+{
24
+private:
25
+	// Information about weapons & ammo
26
+	WEAPON		rgWeapons[MAX_WEAPONS];	// Weapons Array
27
+
28
+	// counts of weapons * ammo
29
+	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
30
+	int			riAmmo[MAX_AMMO_TYPES];							// count of each ammo type
31
+
32
+public:
33
+	void Init( void )
34
+	{
35
+		memset( rgWeapons, 0, sizeof rgWeapons );
36
+		Reset();
37
+	}
38
+
39
+	void Reset( void )
40
+	{
41
+		iOldWeaponBits = 0;
42
+		memset( rgSlots, 0, sizeof rgSlots );
43
+		memset( riAmmo, 0, sizeof riAmmo );
44
+	}
45
+
46
+///// WEAPON /////
47
+	int			iOldWeaponBits;
48
+
49
+	WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; }
50
+	void AddWeapon( WEAPON *wp ) 
51
+	{ 
52
+		rgWeapons[ wp->iId ] = *wp;	
53
+		LoadWeaponSprites( &rgWeapons[ wp->iId ] );
54
+	}
55
+
56
+	void PickupWeapon( WEAPON *wp )
57
+	{
58
+		rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp;
59
+	}
60
+
61
+	void DropWeapon( WEAPON *wp )
62
+	{
63
+		rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL;
64
+	}
65
+
66
+	void DropAllWeapons( void )
67
+	{
68
+		for ( int i = 0; i < MAX_WEAPONS; i++ )
69
+		{
70
+			if ( rgWeapons[i].iId )
71
+				DropWeapon( &rgWeapons[i] );
72
+		}
73
+	}
74
+
75
+	WEAPON* GetWeaponSlot( int slot, int pos ) { return rgSlots[slot][pos]; }
76
+
77
+	void LoadWeaponSprites( WEAPON* wp );
78
+	void LoadAllWeaponSprites( void );
79
+	WEAPON* GetFirstPos( int iSlot );
80
+	void SelectSlot( int iSlot, int fAdvance, int iDirection );
81
+	WEAPON* GetNextActivePos( int iSlot, int iSlotPos );
82
+
83
+	int HasAmmo( WEAPON *p );
84
+
85
+///// AMMO /////
86
+	AMMO GetAmmo( int iId ) { return iId; }
87
+
88
+	void SetAmmo( int iId, int iCount ) { riAmmo[ iId ] = iCount;	}
89
+
90
+	int CountAmmo( int iId );
91
+
92
+	HSPRITE* GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect );
93
+};
94
+
95
+extern WeaponsResource gWR;
96
+
97
+
98
+#define MAX_HISTORY 12
99
+enum {
100
+	HISTSLOT_EMPTY,
101
+	HISTSLOT_AMMO,
102
+	HISTSLOT_WEAP,
103
+	HISTSLOT_ITEM,
104
+};
105
+
106
+class HistoryResource
107
+{
108
+private:
109
+	struct HIST_ITEM {
110
+		int type;
111
+		float DisplayTime;  // the time at which this item should be removed from the history
112
+		int iCount;
113
+		int iId;
114
+	};
115
+
116
+	HIST_ITEM rgAmmoHistory[MAX_HISTORY];
117
+
118
+public:
119
+
120
+	void Init( void )
121
+	{
122
+		Reset();
123
+	}
124
+
125
+	void Reset( void )
126
+	{
127
+		memset( rgAmmoHistory, 0, sizeof rgAmmoHistory );
128
+	}
129
+
130
+	int iHistoryGap;
131
+	int iCurrentHistorySlot;
132
+
133
+	void AddToHistory( int iType, int iId, int iCount = 0 );
134
+	void AddToHistory( int iType, const char *szName, int iCount = 0 );
135
+
136
+	void CheckClearHistory( void );
137
+	int DrawAmmoHistory( float flTime );
138
+};
139
+
140
+extern HistoryResource gHR;
141
+
142
+
143
+

+ 158
- 0
cl_dll/battery.cpp View File

@@ -0,0 +1,158 @@
1
+/***
2
+*
3
+*	Copyright (c) 1996-2002, Valve LLC. All rights reserved.
4
+*	
5
+*	This product contains software technology licensed from Id 
6
+*	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
7
+*	All Rights Reserved.
8
+*
9
+*   Use, distribution, and modification of this source code and/or resulting
10
+*   object code is restricted to non-commercial enhancements to products from
11
+*   Valve LLC.  All other use, distribution, or modification is prohibited
12
+*   without written permission from Valve LLC.
13
+*
14
+****/
15
+//
16
+// battery.cpp
17
+//
18
+// implementation of CHudBattery class
19
+//
20
+
21
+#include "hud.h"
22
+#include "cl_util.h"
23
+#include "parsemsg.h"
24
+
25
+#include <string.h>
26
+#include <stdio.h>
27
+
28
+DECLARE_MESSAGE(m_Battery, Battery)
29
+
30
+int CHudBattery::Init(void)
31
+{
32
+	m_iBat = 0;
33
+	m_fFade = 0;
34
+	m_iFlags = 0;
35
+
36
+	HOOK_MESSAGE(Battery);
37
+
38
+	gHUD.AddHudElem(this);
39
+
40
+	return 1;
41
+};
42
+
43
+
44
+int CHudBattery::VidInit(void)
45
+{
46
+	int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" );
47
+	int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" );
48
+
49
+	m_hSprite1 = m_hSprite2 = 0;  // delaying get sprite handles until we know the sprites are loaded
50
+	m_prc1 = &gHUD.GetSpriteRect( HUD_suit_empty );
51
+	m_prc2 = &gHUD.GetSpriteRect( HUD_suit_full );
52
+	m_iHeight = m_prc2->bottom - m_prc1->top;
53
+	m_fFade = 0;
54
+	return 1;
55
+};
56
+
57
+int CHudBattery:: MsgFunc_Battery(const char *pszName,  int iSize, void *pbuf )
58
+{
59
+	m_iFlags |= HUD_ACTIVE;
60
+	
61
+	BEGIN_READ( pbuf, iSize );
62
+	int x = READ_SHORT();
63
+
64
+#if defined( _TFC )
65
+	int y = READ_SHORT();
66
+
67
+	if ( x != m_iBat || y != m_iBatMax )
68
+	{
69
+		m_fFade = FADE_TIME;
70
+		m_iBat = x;
71
+		m_iBatMax = y;
72
+	}
73
+#else
74
+	if ( x != m_iBat )
75
+	{
76
+		m_fFade = FADE_TIME;
77
+		m_iBat = x;
78
+	}
79
+#endif
80
+
81
+	return 1;
82
+}
83
+
84
+
85
+int CHudBattery::Draw(float flTime)
86
+{
87
+	if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
88
+		return 1;
89
+
90
+	int r, g, b, x, y, a;
91
+	wrect_t rc;
92
+
93
+	rc = *m_prc2;
94
+
95
+#if defined( _TFC )
96
+	float fScale = 0.0;
97
+	
98
+	if ( m_iBatMax > 0 )
99
+		fScale = 1.0 / (float)m_iBatMax;
100
+
101
+	rc.top  += m_iHeight * ((float)(m_iBatMax-(min(m_iBatMax,m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
102
+#else
103
+	rc.top  += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01);	// battery can go from 0 to 100 so * 0.01 goes from 0 to 1
104
+#endif
105
+
106
+	UnpackRGB(r,g,b, RGB_YELLOWISH);
107
+
108
+	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
109
+		return 1;
110
+
111
+	// Has health changed? Flash the health #
112
+	if (m_fFade)
113
+	{
114
+		if (m_fFade > FADE_TIME)
115
+			m_fFade = FADE_TIME;
116
+
117
+		m_fFade -= (gHUD.m_flTimeDelta * 20);
118
+		if (m_fFade <= 0)
119
+		{
120
+			a = 128;
121
+			m_fFade = 0;
122
+		}
123
+
124
+		// Fade the health number back to dim
125
+
126
+		a = MIN_ALPHA +  (m_fFade/FADE_TIME) * 128;
127
+
128
+	}
129
+	else
130
+		a = MIN_ALPHA;
131
+
132
+	ScaleColors(r, g, b, a );
133
+	
134
+	int iOffset = (m_prc1->bottom - m_prc1->top)/6;
135
+
136
+	y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
137
+	x = ScreenWidth/5;
138
+
139
+	// make sure we have the right sprite handles
140
+	if ( !m_hSprite1 )
141
+		m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
142
+	if ( !m_hSprite2 )
143
+		m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );
144
+
145
+	SPR_Set(m_hSprite1, r, g, b );
146
+	SPR_DrawAdditive( 0,  x, y - iOffset, m_prc1);
147
+
148
+	if (rc.bottom > rc.top)
149
+	{
150
+		SPR_Set(m_hSprite2, r, g, b );
151
+		SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
152
+	}
153
+
154
+	x += (m_prc1->right - m_prc1->left);
155
+	x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
156
+
157
+	return 1;
158
+}

+ 26
- 0
cl_dll/bench.h View File

@@ -0,0 +1,26 @@
1
+#if !defined ( BENCHH )
2
+#define BENCHH
3
+#pragma once
4
+
5
+#define FIRST_STAGE		1
6
+#define SECOND_STAGE	2
7
+#define THIRD_STAGE		3
8
+#define FOURTH_STAGE	4
9
+#define LAST_STAGE		( FOURTH_STAGE )
10
+
11
+void Bench_CheckStart( void );
12
+
13
+int Bench_InStage( int stage );
14
+int Bench_GetPowerPlay( void );
15
+int Bench_GetStage( void );
16
+void Bench_SetPowerPlay( int set );
17
+int Bench_Active( void );
18
+
19
+void Bench_SetDotAdded( int dot );
20
+void Bench_SpotPosition( vec3_t dot, vec3_t target );
21
+void Bench_CheckEntity( int type, struct cl_entity_s *ent, const char *modelname );
22
+void Bench_AddObjects( void );
23
+void Bench_SetViewAngles( int recalc_wander, float *viewangles, float frametime, struct usercmd_s *cmd );
24
+void Bench_SetViewOrigin( float *vieworigin, float frametime );
25
+
26
+#endif

+ 24
- 0
cl_dll/camera.h View File

@@ -0,0 +1,24 @@
1
+//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
2
+//
3
+// Purpose: 
4
+//
5
+// $NoKeywords: $
6
+//=============================================================================
7
+
8
+// Camera.h  --  defines and such for a 3rd person camera
9
+// NOTE: must include quakedef.h first
10
+
11
+#ifndef _CAMERA_H_
12
+#define _CAMEA_H_
13
+
14
+// pitch, yaw, dist
15
+extern vec3_t cam_ofs;
16
+// Using third person camera
17
+extern int cam_thirdperson;
18
+
19
+void CAM_Init( void );
20
+void CAM_ClearStates( void );
21
+void CAM_StartMouseMove(void);
22
+void CAM_EndMouseMove(void);
23
+
24
+#endif		// _CAMERA_H_

+ 445
- 0
cl_dll/cdll_int.cpp View File

@@ -0,0 +1,445 @@
1
+/***
2
+*
3
+*	Copyright (c) 1999, Valve LLC. All rights reserved.
4
+*	
5
+*	This product contains software technology licensed from Id 
6
+*	Software, Inc. ("Id Technology").  Id Technology (c) 1996 Id Software, Inc. 
7
+*	All Rights Reserved.
8
+*
9
+*   Use, distribution, and modification of this source code and/or resulting
10
+*   object code is restricted to non-commercial enhancements to products from
11
+*   Valve LLC.  All other use, distribution, or modification is prohibited
12
+*   without written permission from Valve LLC.
13
+*
14
+****/
15
+//
16
+//  cdll_int.c
17
+//
18
+// this implementation handles the linking of the engine to the DLL
19
+//
20
+
21
+#include "hud.h"
22
+#include "cl_util.h"
23
+#include "netadr.h"
24
+#undef INTERFACE_H
25
+#include "../public/interface.h"
26
+//#include "vgui_schememanager.h"
27
+
28
+extern "C"
29
+{
30
+#include "pm_shared.h"
31
+}
32
+
33
+#include <string.h>
34
+#include "hud_servers.h"
35
+#include "vgui_int.h"
36
+#include "interface.h"
37
+
38
+#ifdef _WIN32
39
+#include <windows.h>
40
+#endif
41
+#include "Exports.h"
42
+#
43
+#include "tri.h"
44
+#include "vgui_TeamFortressViewport.h"
45
+#include "../public/interface.h"
46
+
47
+cl_enginefunc_t gEngfuncs;
48
+CHud gHUD;
49
+TeamFortressViewport *gViewPort = NULL;
50
+
51
+
52
+#include "particleman.h"
53
+CSysModule *g_hParticleManModule = NULL;
54
+IParticleMan *g_pParticleMan = NULL;
55
+
56
+void CL_LoadParticleMan( void );
57
+void CL_UnloadParticleMan( void );
58
+
59
+void InitInput (void);
60
+void EV_HookEvents( void );
61
+void IN_Commands( void );
62
+
63
+/*
64
+================================
65
+HUD_GetHullBounds
66
+
67
+  Engine calls this to enumerate player collision hulls, for prediction.  Return 0 if the hullnumber doesn't exist.
68
+================================
69
+*/
70
+int CL_DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs )
71
+{
72
+//	RecClGetHullBounds(hullnumber, mins, maxs);
73
+
74
+	int iret = 0;
75
+
76
+	switch ( hullnumber )
77
+	{
78
+	case 0:				// Normal player
79
+		mins = Vector(-16, -16, -36);
80
+		maxs = Vector(16, 16, 36);
81
+		iret = 1;
82
+		break;
83
+	case 1:				// Crouched player
84
+		mins = Vector(-16, -16, -18 );
85
+		maxs = Vector(16, 16, 18 );
86
+		iret = 1;
87
+		break;
88
+	case 2:				// Point based hull
89
+		mins = Vector( 0, 0, 0 );
90
+		maxs = Vector( 0, 0, 0 );
91
+		iret = 1;
92
+		break;
93
+	}
94
+
95
+	return iret;
96
+}
97
+
98
+/*
99
+================================
100
+HUD_ConnectionlessPacket
101
+
102
+ Return 1 if the packet is valid.  Set response_buffer_size if you want to send a response packet.  Incoming, it holds the max
103
+  size of the response_buffer, so you must zero it out if you choose not to respond.
104
+================================
105
+*/
106
+int	CL_DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
107
+{
108
+//	RecClConnectionlessPacket(net_from, args, response_buffer, response_buffer_size);
109
+
110
+	// Parse stuff from args
111
+	int max_buffer_size = *response_buffer_size;
112
+
113
+	// Zero it out since we aren't going to respond.
114
+	// If we wanted to response, we'd write data into response_buffer
115
+	*response_buffer_size = 0;
116
+
117
+	// Since we don't listen for anything here, just respond that it's a bogus message
118
+	// If we didn't reject the message, we'd return 1 for success instead.
119
+	return 0;
120
+}
121
<