-
Notifications
You must be signed in to change notification settings - Fork 0
/
hud_msg.cpp
156 lines (121 loc) · 3.05 KB
/
hud_msg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/***
*
* Copyright (c) 1999, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
//
// hud_msg.cpp
//
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include "r_efx.h"
#include "particleman.h"
extern IParticleMan *g_pParticleMan;
#define MAX_CLIENTS 32
#if !defined( _TFC )
extern BEAM *pBeam;
extern BEAM *pBeam2;
extern TEMPENTITY *pFlare; // Vit_amiN
#endif
extern float g_lastFOV; // Vit_amiN
extern bool g_hasPredictedFOV; // Vit_amiN
#if defined( _TFC )
void ClearEventList( void );
#endif
extern int CL_ButtonBits(int); // Vit_amiN
/// USER-DEFINED SERVER MESSAGE HANDLERS
int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
{
ASSERT( iSize == 0 );
// clear all hud data
HUDLIST *pList = m_pHudList;
while ( pList )
{
if ( pList->p )
pList->p->Reset();
pList = pList->pNext;
}
// reset sensitivity
m_flMouseSensitivity = 0;
// reset concussion effect
m_iConcussionEffect = 0;
// Vit_amiN: reset the FOV
m_iFOV = 0; // default_fov
g_lastFOV = 0.0f;
g_hasPredictedFOV = false;
return 1;
}
void CAM_ToFirstPerson(void);
void CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{
CAM_ToFirstPerson();
}
void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{
// prepare all hud data
HUDLIST *pList = m_pHudList;
while (pList)
{
if ( pList->p )
pList->p->InitHUDData();
pList = pList->pNext;
}
#if defined( _TFC )
ClearEventList();
// catch up on any building events that are going on
gEngfuncs.pfnServerCmd("sendevents");
#endif
if ( g_pParticleMan )
g_pParticleMan->ResetParticles();
#if !defined( _TFC )
//Probably not a good place to put this.
pBeam = pBeam2 = NULL;
pFlare = NULL; // Vit_amiN: clear egon's beam flare
#endif
}
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
m_Teamplay = READ_BYTE();
return 1;
}
int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf )
{
int armor, blood;
Vector from;
int i;
float count;
BEGIN_READ( pbuf, iSize );
armor = READ_BYTE();
blood = READ_BYTE();
for (i=0 ; i<3 ; i++)
from[i] = READ_COORD();
count = (blood * 0.5) + (armor * 0.5);
if (count < 10)
count = 10;
// TODO: kick viewangles, show damage visually
return 1;
}
int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
{
int r, g, b;
BEGIN_READ( pbuf, iSize );
m_iConcussionEffect = READ_BYTE();
if (m_iConcussionEffect)
{
UnpackRGB(r, g, b, RGB_YELLOWISH); // Vit_amiN: fixed
this->m_StatusIcons.EnableIcon("dmg_concuss", r, g, b);
} else
this->m_StatusIcons.DisableIcon("dmg_concuss");
return 1;
}