cs16-client-legacy/cl_dll/hud/hud_msg.cpp

216 lines
4.5 KiB
C++

/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
//
// hud_msg.cpp
//
#include "hud.h"
#include "cl_util.h"
#include "parsemsg.h"
#include "r_efx.h"
#include "rain.h"
#include "com_model.h"
#include "studio.h"
#include "studio_util.h"
#include "StudioModelRenderer.h"
#include "GameStudioModelRenderer.h"
#include "com_weapons.h"
#include <cstring>
#define MAX_CLIENTS 32
extern float g_flRoundTime;
/// USER-DEFINED SERVER MESSAGE HANDLERS
int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf )
{
ASSERT( iSize == 0 );
// clear all hud data
HUDLIST *pList = m_pHudList;
while ( pList )
{
if ( pList->p )
pList->p->Reset();
pList = pList->pNext;
}
// reset sensitivity
m_flMouseSensitivity = 0;
// reset concussion effect
m_iConcussionEffect = 0;
return 1;
}
void CAM_ToFirstPerson(void);
int CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf )
{
CAM_ToFirstPerson();
return 1;
}
int CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )
{
// prepare all hud data
HUDLIST *pList = m_pHudList;
while (pList)
{
if ( pList->p )
pList->p->InitHUDData();
pList = pList->pNext;
}
g_iFreezeTimeOver = 0;
memset( g_PlayerExtraInfo, 0, sizeof(g_PlayerExtraInfo) );
ResetRain();
// reset round time
g_flRoundTime = 0.0f;
return 1;
}
int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
m_Teamplay = READ_BYTE();
return 1;
}
int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
{
BEGIN_READ( pbuf, iSize );
m_iConcussionEffect = READ_BYTE();
if (m_iConcussionEffect)
this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0);
else
this->m_StatusIcons.DisableIcon("dmg_concuss");
return 1;
}
int CHud::MsgFunc_ReceiveW(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int iWeatherType = READ_BYTE();
if( iWeatherType == 0 )
{
ResetRain();
return 1;
}
Rain.distFromPlayer = 500;
Rain.dripsPerSecond = 500;
Rain.windX = Rain.windY = 30;
Rain.randX = Rain.randY = 0;
Rain.weatherMode = iWeatherType - 1;
Rain.globalHeight = 100;
return 1;
}
int CHud::MsgFunc_BombDrop(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
g_PlayerExtraInfo[33].origin.x = READ_COORD();
g_PlayerExtraInfo[33].origin.y = READ_COORD();
g_PlayerExtraInfo[33].origin.z = READ_COORD();
g_PlayerExtraInfo[33].radarflashon = 1;
g_PlayerExtraInfo[33].radarflashes = 99999;
g_PlayerExtraInfo[33].radarflash = gHUD.m_flTime;
strncpy(g_PlayerExtraInfo[33].teamname, "TERRORIST", MAX_TEAM_NAME);
g_PlayerExtraInfo[33].dead = 0;
g_PlayerExtraInfo[33].nextflash = true;
int Flag = READ_BYTE();
g_PlayerExtraInfo[33].playerclass = Flag;
if( Flag ) // bomb planted
m_Timer.m_iFlags = 0;
return 1;
}
int CHud::MsgFunc_BombPickup(const char *pszName, int iSize, void *pbuf)
{
g_PlayerExtraInfo[33].radarflashon = 0;
g_PlayerExtraInfo[33].radarflash = 0.0f;
g_PlayerExtraInfo[33].radarflashes = 0;
g_PlayerExtraInfo[33].dead = 1;
return 1;
}
int CHud::MsgFunc_HostagePos(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int Flag = READ_BYTE();
int idx = READ_BYTE();
if ( idx <= MAX_HOSTAGES )
{
g_HostageInfo[idx].origin.x = READ_COORD();
g_HostageInfo[idx].origin.y = READ_COORD();
g_HostageInfo[idx].origin.z = READ_COORD();
if ( Flag == 1 )
{
g_HostageInfo[idx].radarflash = gHUD.m_flTime;
g_HostageInfo[idx].radarflashon = 1;
g_HostageInfo[idx].radarflashes = 99999;
}
strncpy(g_HostageInfo[idx].teamname, "CT", MAX_TEAM_NAME);
g_HostageInfo[idx].dead = 0;
}
return 1;
}
int CHud::MsgFunc_HostageK(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE();
if ( idx <= MAX_HOSTAGES )
{
g_HostageInfo[idx].dead = 1;
g_HostageInfo[idx].radarflash = gHUD.m_flTime;
g_HostageInfo[idx].radarflashes = 15;
}
return 1;
}
int CHud::MsgFunc_ShadowIdx(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ(pbuf, iSize);
int idx = READ_BYTE();
g_StudioRenderer.StudioSetShadowSprite(idx);
return 1;
}