2016-06-04 15:24:23 +02:00
|
|
|
/***
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
// Robin, 4-22-98: Moved set_suicide_frame() here from player.cpp to allow us to
|
|
|
|
// have one without a hardcoded player.mdl in tf_client.cpp
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
===== client.cpp ========================================================
|
|
|
|
|
|
|
|
client/server game specific stuff
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "extdll.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "saverestore.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "spectator.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "soundent.h"
|
|
|
|
#include "gamerules.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "customentity.h"
|
|
|
|
#include "weapons.h"
|
|
|
|
#include "weaponinfo.h"
|
|
|
|
#include "usercmd.h"
|
|
|
|
#include "netadr.h"
|
2017-06-26 04:41:01 +02:00
|
|
|
#include "pm_shared.h"
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
extern DLL_GLOBAL ULONG g_ulModelIndexPlayer;
|
|
|
|
extern DLL_GLOBAL BOOL g_fGameOver;
|
|
|
|
extern DLL_GLOBAL int g_iSkillLevel;
|
|
|
|
extern DLL_GLOBAL ULONG g_ulFrameCount;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
extern void CopyToBodyQue( entvars_t* pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
extern int giPrecacheGrunt;
|
|
|
|
extern int gmsgSayText;
|
2017-07-05 20:50:55 +02:00
|
|
|
extern int gmsgBhopcap;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
extern cvar_t allow_spectators;
|
2019-01-18 13:41:41 +01:00
|
|
|
extern cvar_t multibyte_only;
|
2017-06-26 02:47:19 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
extern int g_teamplay;
|
|
|
|
|
2017-07-05 20:50:55 +02:00
|
|
|
extern cvar_t bhopcap;
|
|
|
|
extern "C" int g_bhopcap;
|
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
void LinkUserMessages( void );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* used by kill command and disconnect command
|
|
|
|
* ROBIN: Moved here from player.cpp, to allow multiple player models
|
|
|
|
*/
|
2016-07-31 15:48:50 +02:00
|
|
|
void set_suicide_frame( entvars_t *pev )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !FStrEq( STRING( pev->model ), "models/player.mdl" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return; // allready gibbed
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
//pev->frame = $deatha11;
|
|
|
|
pev->solid = SOLID_NOT;
|
|
|
|
pev->movetype = MOVETYPE_TOSS;
|
|
|
|
pev->deadflag = DEAD_DEAD;
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = -1.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
ClientConnect
|
|
|
|
|
|
|
|
called when a player connects to a server
|
|
|
|
============
|
|
|
|
*/
|
2016-07-31 15:48:50 +02:00
|
|
|
BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] )
|
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
return g_pGameRules->ClientConnected( pEntity, pszName, pszAddress, szRejectReason );
|
|
|
|
|
|
|
|
// a client connecting during an intermission can cause problems
|
2016-07-31 15:48:50 +02:00
|
|
|
// if( intermission_running )
|
|
|
|
// ExitIntermission();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
ClientDisconnect
|
|
|
|
|
|
|
|
called when a player disconnects from a server
|
|
|
|
|
|
|
|
GLOBALS ASSUMED SET: g_fGameOver
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void ClientDisconnect( edict_t *pEntity )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_fGameOver )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
char text[256] = "";
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pEntity->v.netname )
|
2018-03-03 22:24:54 +01:00
|
|
|
_snprintf( text, sizeof(text), "- %s has left the game\n", STRING( pEntity->v.netname ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
|
2016-07-31 15:48:50 +02:00
|
|
|
WRITE_BYTE( ENTINDEX( pEntity ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
WRITE_STRING( text );
|
|
|
|
MESSAGE_END();
|
|
|
|
|
2017-07-03 00:24:14 +02:00
|
|
|
CSound *pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) );
|
|
|
|
|
|
|
|
// since this client isn't around to think anymore, reset their sound.
|
|
|
|
if( pSound )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-03 00:24:14 +02:00
|
|
|
pSound->Reset();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
// since the edict doesn't get deleted, fix it so it doesn't interfere.
|
2016-06-04 15:24:23 +02:00
|
|
|
pEntity->v.takedamage = DAMAGE_NO;// don't attract autoaim
|
|
|
|
pEntity->v.solid = SOLID_NOT;// nonsolid
|
2017-07-20 07:51:34 +02:00
|
|
|
pEntity->v.effects = 0;// clear any effects
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_SetOrigin( &pEntity->v, pEntity->v.origin );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
g_pGameRules->ClientDisconnected( pEntity );
|
|
|
|
}
|
|
|
|
|
|
|
|
// called by ClientKill and DeadThink
|
2016-07-31 15:48:50 +02:00
|
|
|
void respawn( entvars_t *pev, BOOL fCopyCorpse )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( gpGlobals->coop || gpGlobals->deathmatch )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( fCopyCorpse )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// make a copy of the dead body for appearances sake
|
2016-07-31 15:48:50 +02:00
|
|
|
CopyToBodyQue( pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// respawn player
|
2016-07-31 15:48:50 +02:00
|
|
|
GetClassPtr( (CBasePlayer *)pev )->Spawn();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // restart the entire server
|
2016-07-31 15:48:50 +02:00
|
|
|
SERVER_COMMAND( "reload\n" );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
ClientKill
|
|
|
|
|
|
|
|
Player entered the suicide command
|
|
|
|
|
|
|
|
GLOBALS ASSUMED SET: g_ulModelIndexPlayer
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void ClientKill( edict_t *pEntity )
|
|
|
|
{
|
|
|
|
entvars_t *pev = &pEntity->v;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayer *pl = (CBasePlayer*)CBasePlayer::Instance( pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pl->m_fNextSuicideTime > gpGlobals->time )
|
2016-06-04 15:24:23 +02:00
|
|
|
return; // prevent suiciding too ofter
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
pl->m_fNextSuicideTime = gpGlobals->time + 1.0f; // don't let them suicide for 5 seconds after suiciding
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// have the player kill themself
|
|
|
|
pev->health = 0;
|
|
|
|
pl->Killed( pev, GIB_NEVER );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
//pev->modelindex = g_ulModelIndexPlayer;
|
|
|
|
//pev->frags -= 2; // extra penalty
|
|
|
|
//respawn( pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
ClientPutInServer
|
|
|
|
|
|
|
|
called each time a player is spawned
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void ClientPutInServer( edict_t *pEntity )
|
|
|
|
{
|
|
|
|
CBasePlayer *pPlayer;
|
|
|
|
|
|
|
|
entvars_t *pev = &pEntity->v;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pPlayer = GetClassPtr( (CBasePlayer *)pev );
|
|
|
|
pPlayer->SetCustomDecalFrames( -1 ); // Assume none;
|
2019-11-03 18:59:33 +01:00
|
|
|
pPlayer->SetPrefsFromUserinfo( g_engfuncs.pfnGetInfoKeyBuffer( pEntity ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Allocate a CBasePlayer for pev, and call spawn
|
2016-07-31 15:48:50 +02:00
|
|
|
pPlayer->Spawn();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Reset interpolation during first frame
|
|
|
|
pPlayer->pev->effects |= EF_NOINTERP;
|
2016-02-29 21:04:01 +01:00
|
|
|
|
|
|
|
pPlayer->pev->iuser1 = 0;
|
|
|
|
pPlayer->pev->iuser2 = 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2021-06-07 02:05:58 +02:00
|
|
|
#if !NO_VOICEGAMEMGR
|
2016-06-04 15:24:23 +02:00
|
|
|
#include "voice_gamemgr.h"
|
|
|
|
extern CVoiceGameMgr g_VoiceGameMgr;
|
2016-06-12 22:43:32 +02:00
|
|
|
#endif
|
2017-06-26 02:47:19 +02:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: determine if a uchar32 represents a valid Unicode code point
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool Q_IsValidUChar32( unsigned int uVal )
|
|
|
|
{
|
|
|
|
// Values > 0x10FFFF are explicitly invalid; ditto for UTF-16 surrogate halves,
|
|
|
|
// values ending in FFFE or FFFF, or values in the 0x00FDD0-0x00FDEF reserved range
|
2017-06-29 15:56:03 +02:00
|
|
|
return ( ( uVal - 0x0u ) < 0x110000u ) && ( (uVal - 0x00D800u) > 0x7FFu ) && ( (uVal & 0xFFFFu) < 0xFFFEu ) && ( ( uVal - 0x00FDD0u ) > 0x1Fu );
|
2017-06-26 02:47:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Decode one character from a UTF-8 encoded string. Treats 6-byte CESU-8 sequences
|
|
|
|
// as a single character, as if they were a correctly-encoded 4-byte UTF-8 sequence.
|
|
|
|
int Q_UTF8ToUChar32( const char *pUTF8_, unsigned int &uValueOut, bool &bErrorOut )
|
|
|
|
{
|
|
|
|
const unsigned char *pUTF8 = (const unsigned char*)pUTF8_;
|
|
|
|
|
|
|
|
int nBytes = 1;
|
|
|
|
unsigned int uValue = pUTF8[0];
|
|
|
|
unsigned int uMinValue = 0;
|
|
|
|
|
|
|
|
// 0....... single byte
|
|
|
|
if( uValue < 0x80 )
|
|
|
|
goto decodeFinishedNoCheck;
|
|
|
|
|
|
|
|
// Expecting at least a two-byte sequence with 0xC0 <= first <= 0xF7 (110...... and 11110...)
|
|
|
|
if( ( uValue - 0xC0u ) > 0x37u || ( pUTF8[1] & 0xC0 ) != 0x80 )
|
|
|
|
goto decodeError;
|
|
|
|
|
|
|
|
uValue = ( uValue << 6 ) - ( 0xC0 << 6 ) + pUTF8[1] - 0x80;
|
|
|
|
nBytes = 2;
|
|
|
|
uMinValue = 0x80;
|
|
|
|
|
|
|
|
// 110..... two-byte lead byte
|
|
|
|
if( !( uValue & ( 0x20 << 6 ) ) )
|
|
|
|
goto decodeFinished;
|
|
|
|
|
|
|
|
// Expecting at least a three-byte sequence
|
|
|
|
if( ( pUTF8[2] & 0xC0 ) != 0x80 )
|
|
|
|
goto decodeError;
|
|
|
|
|
|
|
|
uValue = ( uValue << 6 ) - ( 0x20 << 12 ) + pUTF8[2] - 0x80;
|
|
|
|
nBytes = 3;
|
|
|
|
uMinValue = 0x800;
|
|
|
|
|
|
|
|
// 1110.... three-byte lead byte
|
|
|
|
decodeFinished:
|
|
|
|
if( uValue >= uMinValue && Q_IsValidUChar32( uValue ) )
|
|
|
|
{
|
|
|
|
decodeFinishedNoCheck:
|
|
|
|
uValueOut = uValue;
|
|
|
|
bErrorOut = false;
|
|
|
|
return nBytes;
|
|
|
|
}
|
|
|
|
decodeError:
|
|
|
|
uValueOut = '?';
|
|
|
|
bErrorOut = true;
|
|
|
|
return nBytes;
|
2021-06-18 10:00:09 +02:00
|
|
|
#if 0
|
2017-06-26 02:47:19 +02:00
|
|
|
decodeFinishedMaybeCESU8:
|
|
|
|
// Do we have a full UTF-16 surrogate pair that's been UTF-8 encoded afterwards?
|
|
|
|
// That is, do we have 0xD800-0xDBFF followed by 0xDC00-0xDFFF? If so, decode it all.
|
|
|
|
if( ( uValue - 0xD800u ) < 0x400u && pUTF8[3] == 0xED && (unsigned char)( pUTF8[4] - 0xB0 ) < 0x10 && ( pUTF8[5] & 0xC0 ) == 0x80 )
|
|
|
|
{
|
|
|
|
uValue = 0x10000 + ( ( uValue - 0xD800u ) << 10 ) + ( (unsigned char)( pUTF8[4] - 0xB0 ) << 6 ) + pUTF8[5] - 0x80;
|
|
|
|
nBytes = 6;
|
|
|
|
uMinValue = 0x10000;
|
|
|
|
}
|
|
|
|
goto decodeFinished;
|
2021-06-18 10:00:09 +02:00
|
|
|
#endif
|
2017-06-26 02:47:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: Returns true if UTF-8 string contains invalid sequences.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool Q_UnicodeValidate( const char *pUTF8 )
|
|
|
|
{
|
|
|
|
bool bError = false;
|
2019-01-18 13:41:41 +01:00
|
|
|
|
|
|
|
if( !multibyte_only.value )
|
|
|
|
return true;
|
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
while( *pUTF8 )
|
|
|
|
{
|
|
|
|
unsigned int uVal;
|
|
|
|
// Our UTF-8 decoder silently fixes up 6-byte CESU-8 (improperly re-encoded UTF-16) sequences.
|
|
|
|
// However, these are technically not valid UTF-8. So if we eat 6 bytes at once, it's an error.
|
|
|
|
int nCharSize = Q_UTF8ToUChar32( pUTF8, uVal, bError );
|
|
|
|
if( bError || nCharSize == 6 )
|
|
|
|
return false;
|
|
|
|
pUTF8 += nCharSize;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
//// HOST_SAY
|
|
|
|
// String comes in as
|
|
|
|
// say blah blah blah
|
|
|
|
// or as
|
|
|
|
// blah blah blah
|
|
|
|
//
|
|
|
|
void Host_Say( edict_t *pEntity, int teamonly )
|
|
|
|
{
|
|
|
|
CBasePlayer *client;
|
|
|
|
int j;
|
2021-06-18 10:00:09 +02:00
|
|
|
char *p; //, *pc;
|
2016-06-04 15:24:23 +02:00
|
|
|
char text[128];
|
|
|
|
char szTemp[256];
|
|
|
|
const char *cpSay = "say";
|
|
|
|
const char *cpSayTeam = "say_team";
|
2016-07-31 15:48:50 +02:00
|
|
|
const char *pcmd = CMD_ARGV( 0 );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// We can get a raw string now, without the "say " prepended
|
2016-07-31 15:48:50 +02:00
|
|
|
if( CMD_ARGC() == 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
entvars_t *pev = &pEntity->v;
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayer* player = GetClassPtr( (CBasePlayer *)pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//Not yet.
|
2016-07-31 15:48:50 +02:00
|
|
|
if( player->m_flNextChatTime > gpGlobals->time )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !stricmp( pcmd, cpSay ) || !stricmp( pcmd, cpSayTeam ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( CMD_ARGC() >= 2 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
p = (char *)CMD_ARGS();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// say with a blank message, nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // Raw text, need to prepend argv[0]
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( CMD_ARGC() >= 2 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
sprintf( szTemp, "%s %s", (char *)pcmd, (char *)CMD_ARGS() );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Just a one word command, use the first word...sigh
|
2016-07-31 15:48:50 +02:00
|
|
|
sprintf( szTemp, "%s", (char *)pcmd );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
p = szTemp;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
// remove quotes if present
|
2017-07-02 17:09:34 +02:00
|
|
|
if( p && *p == '"' )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
p++;
|
2016-07-31 15:48:50 +02:00
|
|
|
p[strlen( p ) - 1] = 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
if( !p || !p[0] || !Q_UnicodeValidate ( p ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return; // no character found, so say nothing
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
// turn on color set 2 (color on, no sound)
|
2017-06-26 02:47:19 +02:00
|
|
|
if( player->IsObserver() && ( teamonly ) )
|
|
|
|
sprintf( text, "%c(SPEC) %s: ", 2, STRING( pEntity->v.netname ) );
|
|
|
|
else if( teamonly )
|
2016-06-04 15:24:23 +02:00
|
|
|
sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) );
|
|
|
|
else
|
|
|
|
sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
j = sizeof( text ) - 2 - strlen( text ); // -2 for /n and null terminator
|
|
|
|
if( (int)strlen( p ) > j )
|
2016-06-04 15:24:23 +02:00
|
|
|
p[j] = 0;
|
|
|
|
|
|
|
|
strcat( text, p );
|
|
|
|
strcat( text, "\n" );
|
|
|
|
|
|
|
|
player->m_flNextChatTime = gpGlobals->time + CHAT_INTERVAL;
|
|
|
|
|
|
|
|
// loop through all players
|
|
|
|
// Start with the first player.
|
|
|
|
// This may return the world in single player if the client types something between levels or during spawn
|
|
|
|
// so check it, or it will infinite loop
|
|
|
|
|
|
|
|
client = NULL;
|
2016-07-31 15:48:50 +02:00
|
|
|
while( ( ( client = (CBasePlayer*)UTIL_FindEntityByClassname( client, "player" ) ) != NULL ) && ( !FNullEnt( client->edict() ) ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !client->pev )
|
2016-06-04 15:24:23 +02:00
|
|
|
continue;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( client->edict() == pEntity )
|
2016-06-04 15:24:23 +02:00
|
|
|
continue;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !( client->IsNetClient() ) ) // Not a client ? (should never be true)
|
|
|
|
continue;
|
2021-06-07 02:05:58 +02:00
|
|
|
#if !NO_VOICEGAMEMGR
|
2016-06-04 15:24:23 +02:00
|
|
|
// can the receiver hear the sender? or has he muted him?
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
continue;
|
2016-06-12 22:43:32 +02:00
|
|
|
#endif
|
2017-06-26 02:47:19 +02:00
|
|
|
if( !player->IsObserver() && teamonly && g_pGameRules->PlayerRelationship( client, CBaseEntity::Instance( pEntity ) ) != GR_TEAMMATE )
|
2016-06-04 15:24:23 +02:00
|
|
|
continue;
|
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
// Spectators can only talk to other specs
|
|
|
|
if( player->IsObserver() && teamonly )
|
|
|
|
if ( !client->IsObserver() )
|
|
|
|
continue;
|
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev );
|
2016-07-31 15:48:50 +02:00
|
|
|
WRITE_BYTE( ENTINDEX( pEntity ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
WRITE_STRING( text );
|
|
|
|
MESSAGE_END();
|
|
|
|
}
|
|
|
|
|
|
|
|
// print to the sending client
|
|
|
|
MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, &pEntity->v );
|
2016-07-31 15:48:50 +02:00
|
|
|
WRITE_BYTE( ENTINDEX( pEntity ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
WRITE_STRING( text );
|
|
|
|
MESSAGE_END();
|
|
|
|
|
|
|
|
// echo to server console
|
|
|
|
g_engfuncs.pfnServerPrint( text );
|
|
|
|
|
2017-06-29 15:56:03 +02:00
|
|
|
const char *temp;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( teamonly )
|
2016-06-04 15:24:23 +02:00
|
|
|
temp = "say_team";
|
|
|
|
else
|
|
|
|
temp = "say";
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// team match?
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_teamplay )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" %s \"%s\"\n",
|
|
|
|
STRING( pEntity->v.netname ),
|
|
|
|
GETPLAYERUSERID( pEntity ),
|
|
|
|
GETPLAYERAUTHID( pEntity ),
|
|
|
|
g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pEntity ), "model" ),
|
|
|
|
temp,
|
|
|
|
p );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UTIL_LogPrintf( "\"%s<%i><%s><%i>\" %s \"%s\"\n",
|
|
|
|
STRING( pEntity->v.netname ),
|
|
|
|
GETPLAYERUSERID( pEntity ),
|
|
|
|
GETPLAYERAUTHID( pEntity ),
|
|
|
|
GETPLAYERUSERID( pEntity ),
|
|
|
|
temp,
|
|
|
|
p );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
ClientCommand
|
|
|
|
called each time a player uses a "cmd" command
|
|
|
|
============
|
|
|
|
*/
|
2021-10-26 23:52:17 +02:00
|
|
|
extern cvar_t *g_enable_cheats;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command.
|
|
|
|
void ClientCommand( edict_t *pEntity )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
const char *pcmd = CMD_ARGV( 0 );
|
2016-06-04 15:24:23 +02:00
|
|
|
const char *pstr;
|
|
|
|
|
|
|
|
// Is the client spawned yet?
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !pEntity->pvPrivateData )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
entvars_t *pev = &pEntity->v;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( FStrEq( pcmd, "say" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Host_Say( pEntity, 0 );
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq( pcmd, "say_team" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Host_Say( pEntity, 1 );
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq( pcmd, "fullupdate" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
GetClassPtr( (CBasePlayer *)pev )->ForceClientDllUpdate();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq(pcmd, "give" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2021-10-26 23:52:17 +02:00
|
|
|
if( g_enable_cheats->value != 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
int iszItem = ALLOC_STRING( CMD_ARGV( 1 ) ); // Make a copy of the classname
|
|
|
|
GetClassPtr( (CBasePlayer *)pev )->GiveNamedItem( STRING( iszItem ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq( pcmd, "fire" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2021-10-26 23:52:17 +02:00
|
|
|
if( g_enable_cheats->value != 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CBaseEntity *pPlayer = CBaseEntity::Instance( pEntity );
|
|
|
|
if( CMD_ARGC() > 1 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
FireTargets( CMD_ARGV( 1 ), pPlayer, pPlayer, USE_TOGGLE, 0 );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TraceResult tr;
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_MakeVectors( pev->v_angle );
|
2016-06-04 15:24:23 +02:00
|
|
|
UTIL_TraceLine(
|
|
|
|
pev->origin + pev->view_ofs,
|
|
|
|
pev->origin + pev->view_ofs + gpGlobals->v_forward * 1000,
|
|
|
|
dont_ignore_monsters, pEntity, &tr
|
|
|
|
);
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( tr.pHit )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CBaseEntity *pHitEnt = CBaseEntity::Instance( tr.pHit );
|
|
|
|
if( pHitEnt )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
pHitEnt->Use( pPlayer, pPlayer, USE_TOGGLE, 0 );
|
|
|
|
ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Fired %s \"%s\"\n", STRING( pHitEnt->pev->classname ), STRING( pHitEnt->pev->targetname ) ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq( pcmd, "drop" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// player is dropping an item.
|
2016-07-31 15:48:50 +02:00
|
|
|
GetClassPtr( (CBasePlayer *)pev )->DropPlayerItem( (char *)CMD_ARGV( 1 ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq( pcmd, "fov" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2021-10-26 23:52:17 +02:00
|
|
|
if( g_enable_cheats->value != 0 && CMD_ARGC() > 1 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
GetClassPtr( (CBasePlayer *)pev )->m_iFOV = atoi( CMD_ARGV( 1 ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CLIENT_PRINTF( pEntity, print_console, UTIL_VarArgs( "\"fov\" is \"%d\"\n", (int)GetClassPtr( (CBasePlayer *)pev )->m_iFOV ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq( pcmd, "use" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
GetClassPtr( (CBasePlayer *)pev )->SelectItem( (char *)CMD_ARGV( 1 ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( ( ( pstr = strstr( pcmd, "weapon_" ) ) != NULL ) && ( pstr == pcmd ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
GetClassPtr( (CBasePlayer *)pev )->SelectItem( pcmd );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq( pcmd, "lastinv" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
GetClassPtr( (CBasePlayer *)pev )->SelectLastItem();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2017-06-26 04:41:01 +02:00
|
|
|
else if( FStrEq( pcmd, "spectate" ) ) // clients wants to become a spectator
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-24 13:38:38 +02:00
|
|
|
CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev );
|
|
|
|
if( !pPlayer->IsObserver() )
|
2017-06-26 02:47:19 +02:00
|
|
|
{
|
2017-07-24 13:38:38 +02:00
|
|
|
// always allow proxies to become a spectator
|
|
|
|
if( ( pev->flags & FL_PROXY ) || allow_spectators.value )
|
|
|
|
{
|
|
|
|
edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer );
|
|
|
|
pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles );
|
2017-06-26 02:47:19 +02:00
|
|
|
|
2017-07-24 13:38:38 +02:00
|
|
|
// notify other clients of player switching to spectator mode
|
|
|
|
UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n",
|
2017-07-20 20:32:06 +02:00
|
|
|
( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) );
|
2017-07-24 13:38:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" );
|
2017-06-26 02:47:19 +02:00
|
|
|
}
|
|
|
|
else
|
2017-07-24 13:38:38 +02:00
|
|
|
{
|
|
|
|
pPlayer->StopObserver();
|
|
|
|
|
|
|
|
// notify other clients of player left spectators
|
|
|
|
UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has left spectator mode\n",
|
|
|
|
( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) );
|
|
|
|
}
|
2017-06-26 02:47:19 +02:00
|
|
|
}
|
|
|
|
else if( FStrEq( pcmd, "specmode" ) ) // new spectator mode
|
|
|
|
{
|
|
|
|
CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
if( pPlayer->IsObserver() )
|
|
|
|
pPlayer->Observer_SetMode( atoi( CMD_ARGV( 1 ) ) );
|
|
|
|
}
|
|
|
|
else if( FStrEq( pcmd, "closemenus" ) )
|
|
|
|
{
|
|
|
|
// just ignore it
|
|
|
|
}
|
|
|
|
else if( FStrEq( pcmd, "follownext" ) ) // follow next player
|
|
|
|
{
|
|
|
|
CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev );
|
|
|
|
|
|
|
|
if( pPlayer->IsObserver() )
|
|
|
|
pPlayer->Observer_FindNextPlayer( atoi( CMD_ARGV( 1 ) ) ? true : false );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2017-04-03 18:16:25 +02:00
|
|
|
else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// MenuSelect returns true only if the command is properly handled, so don't print a warning
|
2017-04-03 18:16:25 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( FStrEq( pcmd, "VModEnable" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// clear 'Unknown command: VModEnable' in singleplayer
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// tell the user they entered an unknown command
|
|
|
|
char command[128];
|
|
|
|
|
|
|
|
// check the length of the command (prevents crash)
|
|
|
|
// max total length is 192 ...and we're adding a string below ("Unknown command: %s\n")
|
|
|
|
strncpy( command, pcmd, 127 );
|
|
|
|
command[127] = '\0';
|
|
|
|
|
|
|
|
// tell the user they entered an unknown command
|
|
|
|
ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", command ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
ClientUserInfoChanged
|
|
|
|
|
|
|
|
called after the player changes
|
|
|
|
userinfo - gives dll a chance to modify it before
|
|
|
|
it gets sent into the rest of the engine.
|
|
|
|
========================
|
|
|
|
*/
|
|
|
|
void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer )
|
|
|
|
{
|
|
|
|
// Is the client spawned yet?
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !pEntity->pvPrivateData )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
// msg everyone if someone changes their name, and it isn't the first time (changing no name to current name)
|
2017-07-20 20:32:06 +02:00
|
|
|
if( pEntity->v.netname && ( STRING( pEntity->v.netname ) )[0] != 0 && !FStrEq( STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
char sName[256];
|
|
|
|
char *pName = g_engfuncs.pfnInfoKeyValue( infobuffer, "name" );
|
|
|
|
strncpy( sName, pName, sizeof(sName) - 1 );
|
2016-07-31 15:48:50 +02:00
|
|
|
sName[sizeof(sName) - 1] = '\0';
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// First parse the name and remove any %'s
|
2016-07-31 15:48:50 +02:00
|
|
|
for( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// Replace it with a space
|
2016-07-31 15:48:50 +02:00
|
|
|
if( *pApersand == '%' )
|
2016-06-04 15:24:23 +02:00
|
|
|
*pApersand = ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the name
|
2016-07-31 15:48:50 +02:00
|
|
|
g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "name", sName );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
if( gpGlobals->maxClients > 1 )
|
|
|
|
{
|
|
|
|
char text[256];
|
2018-03-03 22:24:54 +01:00
|
|
|
_snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
|
2017-06-26 02:47:19 +02:00
|
|
|
MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL );
|
|
|
|
WRITE_BYTE( ENTINDEX( pEntity ) );
|
|
|
|
WRITE_STRING( text );
|
|
|
|
MESSAGE_END();
|
|
|
|
}
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// team match?
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_teamplay )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
UTIL_LogPrintf( "\"%s<%i><%s><%s>\" changed name to \"%s\"\n",
|
|
|
|
STRING( pEntity->v.netname ),
|
|
|
|
GETPLAYERUSERID( pEntity ),
|
|
|
|
GETPLAYERAUTHID( pEntity ),
|
|
|
|
g_engfuncs.pfnInfoKeyValue( infobuffer, "model" ),
|
|
|
|
g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UTIL_LogPrintf( "\"%s<%i><%s><%i>\" changed name to \"%s\"\n",
|
|
|
|
STRING( pEntity->v.netname ),
|
|
|
|
GETPLAYERUSERID( pEntity ),
|
|
|
|
GETPLAYERAUTHID( pEntity ),
|
|
|
|
GETPLAYERUSERID( pEntity ),
|
|
|
|
g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
g_pGameRules->ClientUserInfoChanged( GetClassPtr( (CBasePlayer *)&pEntity->v ), infobuffer );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int g_serveractive = 0;
|
|
|
|
|
|
|
|
void ServerDeactivate( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
//ALERT( at_console, "ServerDeactivate()\n" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// It's possible that the engine will call this function more times than is necessary
|
|
|
|
// Therefore, only run it one time for each call to ServerActivate
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_serveractive != 1 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_serveractive = 0;
|
|
|
|
|
|
|
|
// Peform any shutdown operations here...
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
int i;
|
|
|
|
CBaseEntity *pClass;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
//ALERT( at_console, "ServerActivate()\n" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Every call to ServerActivate should be matched by a call to ServerDeactivate
|
|
|
|
g_serveractive = 1;
|
|
|
|
|
|
|
|
// Clients have not been initialized yet
|
2016-07-31 15:48:50 +02:00
|
|
|
for( i = 0; i < edictCount; i++ )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pEdictList[i].free )
|
2016-06-04 15:24:23 +02:00
|
|
|
continue;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// Clients aren't necessarily initialized until ClientPutInServer()
|
2022-07-21 16:23:22 +02:00
|
|
|
if( (i > 0 && i <= clientMax) || !pEdictList[i].pvPrivateData )
|
2016-06-04 15:24:23 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
pClass = CBaseEntity::Instance( &pEdictList[i] );
|
|
|
|
// Activate this entity if it's got a class & isn't dormant
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pClass && !( pClass->pev->flags & FL_DORMANT ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pClass->Activate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
ALERT( at_console, "Can't instance %s\n", STRING( pEdictList[i].v.classname ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Link user messages here to make sure first client can get them...
|
|
|
|
LinkUserMessages();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
PlayerPreThink
|
|
|
|
|
|
|
|
Called every frame before physics are run
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void PlayerPreThink( edict_t *pEntity )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
//ALERT( at_console, "PreThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pPlayer )
|
|
|
|
pPlayer->PreThink();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
PlayerPostThink
|
|
|
|
|
|
|
|
Called every frame after physics are run
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void PlayerPostThink( edict_t *pEntity )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
//ALERT( at_console, "PostThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pPlayer )
|
|
|
|
pPlayer->PostThink();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ParmsNewLevel( void )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ParmsChangeLevel( void )
|
|
|
|
{
|
|
|
|
// retrieve the pointer to the save data
|
|
|
|
SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pSaveData )
|
2016-06-04 15:24:23 +02:00
|
|
|
pSaveData->connectionCount = BuildChangeList( pSaveData->levelList, MAX_LEVEL_CONNECTIONS );
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// GLOBALS ASSUMED SET: g_ulFrameCount
|
|
|
|
//
|
|
|
|
void StartFrame( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
//ALERT( at_console, "SV_Physics( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_pGameRules )
|
2016-06-04 15:24:23 +02:00
|
|
|
g_pGameRules->Think();
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_fGameOver )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
gpGlobals->teamplay = teamplay.value;
|
|
|
|
g_ulFrameCount++;
|
|
|
|
|
2017-07-05 20:50:55 +02:00
|
|
|
int oldBhopcap = g_bhopcap;
|
|
|
|
g_bhopcap = ( g_pGameRules->IsMultiplayer() && bhopcap.value != 0.0f ) ? 1 : 0;
|
|
|
|
if( g_bhopcap != oldBhopcap )
|
|
|
|
{
|
|
|
|
MESSAGE_BEGIN( MSG_ALL, gmsgBhopcap, NULL );
|
|
|
|
WRITE_BYTE( g_bhopcap );
|
|
|
|
MESSAGE_END();
|
|
|
|
}
|
|
|
|
}
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
void ClientPrecache( void )
|
|
|
|
{
|
|
|
|
// setup precaches always needed
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_SOUND( "player/sprayer.wav" ); // spray paint sound for PreAlpha
|
|
|
|
|
|
|
|
// PRECACHE_SOUND( "player/pl_jumpland2.wav" ); // UNDONE: play 2x step sound
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_fallpain2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_fallpain3.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_step1.wav" ); // walk on concrete
|
|
|
|
PRECACHE_SOUND( "player/pl_step2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_step3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_step4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "common/npc_step1.wav" ); // NPC walk on concrete
|
|
|
|
PRECACHE_SOUND( "common/npc_step2.wav" );
|
|
|
|
PRECACHE_SOUND( "common/npc_step3.wav" );
|
|
|
|
PRECACHE_SOUND( "common/npc_step4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_metal1.wav" ); // walk on metal
|
|
|
|
PRECACHE_SOUND( "player/pl_metal2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_metal3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_metal4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_dirt1.wav" ); // walk on dirt
|
|
|
|
PRECACHE_SOUND( "player/pl_dirt2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_dirt3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_dirt4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_duct1.wav" ); // walk in duct
|
|
|
|
PRECACHE_SOUND( "player/pl_duct2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_duct3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_duct4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_grate1.wav" ); // walk on grate
|
|
|
|
PRECACHE_SOUND( "player/pl_grate2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_grate3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_grate4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_slosh1.wav" ); // walk in shallow water
|
|
|
|
PRECACHE_SOUND( "player/pl_slosh2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_slosh3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_slosh4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_tile1.wav" ); // walk on tile
|
|
|
|
PRECACHE_SOUND( "player/pl_tile2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_tile3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_tile4.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_tile5.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_swim1.wav" ); // breathe bubbles
|
|
|
|
PRECACHE_SOUND( "player/pl_swim2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_swim3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_swim4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_ladder1.wav" ); // climb ladder rung
|
|
|
|
PRECACHE_SOUND( "player/pl_ladder2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_ladder3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_ladder4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "player/pl_wade1.wav" ); // wade in water
|
|
|
|
PRECACHE_SOUND( "player/pl_wade2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_wade3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_wade4.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "debris/wood1.wav" ); // hit wood texture
|
|
|
|
PRECACHE_SOUND( "debris/wood2.wav" );
|
|
|
|
PRECACHE_SOUND( "debris/wood3.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "plats/train_use1.wav" ); // use a train
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "buttons/spark5.wav" ); // hit computer texture
|
|
|
|
PRECACHE_SOUND( "buttons/spark6.wav" );
|
|
|
|
PRECACHE_SOUND( "debris/glass1.wav" );
|
|
|
|
PRECACHE_SOUND( "debris/glass2.wav" );
|
|
|
|
PRECACHE_SOUND( "debris/glass3.wav" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
PRECACHE_SOUND( SOUND_FLASHLIGHT_ON );
|
|
|
|
PRECACHE_SOUND( SOUND_FLASHLIGHT_OFF );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
// player gib sounds
|
|
|
|
PRECACHE_SOUND( "common/bodysplat.wav" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
// player pain sounds
|
|
|
|
PRECACHE_SOUND( "player/pl_pain2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_pain4.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_pain5.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_pain6.wav" );
|
|
|
|
PRECACHE_SOUND( "player/pl_pain7.wav" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_MODEL( "models/player.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// hud sounds
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_SOUND( "common/wpn_hudoff.wav" );
|
|
|
|
PRECACHE_SOUND( "common/wpn_hudon.wav" );
|
|
|
|
PRECACHE_SOUND( "common/wpn_moveselect.wav" );
|
|
|
|
PRECACHE_SOUND( "common/wpn_select.wav" );
|
|
|
|
PRECACHE_SOUND( "common/wpn_denyselect.wav" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// geiger sounds
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_SOUND( "player/geiger6.wav" );
|
|
|
|
PRECACHE_SOUND( "player/geiger5.wav" );
|
|
|
|
PRECACHE_SOUND( "player/geiger4.wav" );
|
|
|
|
PRECACHE_SOUND( "player/geiger3.wav" );
|
|
|
|
PRECACHE_SOUND( "player/geiger2.wav" );
|
|
|
|
PRECACHE_SOUND( "player/geiger1.wav" );
|
|
|
|
|
|
|
|
if( giPrecacheGrunt )
|
|
|
|
UTIL_PrecacheOther( "monster_human_grunt" );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
GetGameDescription
|
|
|
|
|
|
|
|
Returns the descriptive name of this .dll. E.g., Half-Life, or Team Fortress 2
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
const char *GetGameDescription()
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_pGameRules ) // this function may be called before the world has spawned, and the game rules initialized
|
2016-06-04 15:24:23 +02:00
|
|
|
return g_pGameRules->GetGameDescription();
|
|
|
|
else
|
|
|
|
return "Half-Life";
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Sys_Error
|
|
|
|
|
|
|
|
Engine is going to shut down, allows setting a breakpoint in game .dll to catch that occasion
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void Sys_Error( const char *error_string )
|
|
|
|
{
|
|
|
|
// Default case, do nothing. MOD AUTHORS: Add code ( e.g., _asm { int 3 }; here to cause a breakpoint for debugging your game .dlls
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
PlayerCustomization
|
|
|
|
|
|
|
|
A new player customization has been registered on the server
|
|
|
|
UNDONE: This only sets the # of frames of the spray can logo
|
|
|
|
animation right now.
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void PlayerCustomization( edict_t *pEntity, customization_t *pCust )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !pPlayer )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
ALERT( at_console, "PlayerCustomization: Couldn't get player!\n" );
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !pCust )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
ALERT( at_console, "PlayerCustomization: NULL customization!\n" );
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( pCust->resource.type )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case t_decal:
|
2016-07-31 15:48:50 +02:00
|
|
|
pPlayer->SetCustomDecalFrames( pCust->nUserData2 ); // Second int is max # of frames.
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
case t_sound:
|
|
|
|
case t_skin:
|
|
|
|
case t_model:
|
|
|
|
// Ignore for now.
|
|
|
|
break;
|
|
|
|
default:
|
2016-07-31 15:48:50 +02:00
|
|
|
ALERT( at_console, "PlayerCustomization: Unknown customization type!\n" );
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SpectatorConnect
|
|
|
|
|
|
|
|
A spectator has joined the game
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SpectatorConnect( edict_t *pEntity )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pPlayer )
|
|
|
|
pPlayer->SpectatorConnect();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SpectatorConnect
|
|
|
|
|
|
|
|
A spectator has left the game
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SpectatorDisconnect( edict_t *pEntity )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pPlayer )
|
|
|
|
pPlayer->SpectatorDisconnect();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SpectatorConnect
|
|
|
|
|
|
|
|
A spectator has sent a usercmd
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SpectatorThink( edict_t *pEntity )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pPlayer )
|
|
|
|
pPlayer->SpectatorThink();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
// PAS and PVS routines for client messaging
|
|
|
|
//
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
SetupVisibility
|
|
|
|
|
|
|
|
A client can have a separate "view entity" indicating that his/her view should depend on the origin of that
|
|
|
|
view entity. If that's the case, then pViewEntity will be non-NULL and will be used. Otherwise, the current
|
|
|
|
entity's origin is used. Either is offset by the view_ofs to get the eye position.
|
|
|
|
|
|
|
|
From the eye position, we set up the PAS and PVS to use for filtering network messages to the client. At this point, we could
|
|
|
|
override the actual PAS or PVS values, or use a different origin.
|
|
|
|
|
|
|
|
NOTE: Do not cache the values of pas and pvs, as they depend on reusable memory in the engine, they are only good for this one frame
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas )
|
|
|
|
{
|
|
|
|
Vector org;
|
|
|
|
edict_t *pView = pClient;
|
|
|
|
|
|
|
|
// Find the client's PVS
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pViewEntity )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pView = pViewEntity;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pClient->v.flags & FL_PROXY )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
*pvs = NULL; // the spectator proxy sees
|
|
|
|
*pas = NULL; // and hears everything
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pView->v.effects & EF_MERGE_VISIBILITY )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( FClassnameIs( pView, "env_sky" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
org = pView->v.origin;
|
|
|
|
}
|
|
|
|
else return; // don't merge pvs
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
org = pView->v.origin + pView->v.view_ofs;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pView->v.flags & FL_DUCKING )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
org = org + ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-07 16:37:24 +02:00
|
|
|
*pvs = ENGINE_SET_PVS( org );
|
|
|
|
*pas = ENGINE_SET_PAS( org );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "entity_state.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
AddToFullPack
|
|
|
|
|
|
|
|
Return 1 if the entity state has been filled in for the ent and the entity will be propagated to the client, 0 otherwise
|
|
|
|
|
|
|
|
state is the server maintained copy of the state info that is transmitted to the client
|
|
|
|
a MOD could alter values copied into state to send the "host" a different look for a particular entity update, etc.
|
|
|
|
e and ent are the entity that is being added to the update, if 1 is returned
|
|
|
|
host is the player's edict of the player whom we are sending the update to
|
|
|
|
player is 1 if the ent/e is a player and 0 otherwise
|
|
|
|
pSet is either the PAS or PVS that we previous set up. We can use it to ask the engine to filter the entity against the PAS or PVS.
|
|
|
|
we could also use the pas/ pvs that we set in SetupVisibility, if we wanted to. Caching the value is valid in that case, but still only for the current frame
|
|
|
|
*/
|
|
|
|
int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
int i;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// don't send if flagged for NODRAW and it's not the host getting the message
|
2017-06-26 02:47:19 +02:00
|
|
|
if( ( ent->v.effects & EF_NODRAW ) && ( ent != host ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Ignore ents without valid / visible models
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !ent->v.modelindex || !STRING( ent->v.model ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Don't send spectators to other players
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ( ent->v.flags & FL_SPECTATOR ) && ( ent != host ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ignore if not the host and not touching a PVS/PAS leaf
|
|
|
|
// If pSet is NULL, then the test will always succeed and the entity will be added to the update
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ent != host )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !ENGINE_CHECK_VISIBILITY( (const struct edict_s *)ent, pSet ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// env_sky is visible always
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !FClassnameIs( ent, "env_sky" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't send entity to local client if the client says it's predicting the entity itself.
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ent->v.flags & FL_SKIPLOCALHOST )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( hostflags & 4 )
|
|
|
|
return 0; // it's a portal pass
|
|
|
|
|
|
|
|
if( ( hostflags & 1 ) && ( ent->v.owner == host ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( host->v.groupinfo )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
UTIL_SetGroupTrace( host->v.groupinfo, GROUP_OP_AND );
|
|
|
|
|
|
|
|
// Should always be set, of course
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ent->v.groupinfo )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_groupop == GROUP_OP_AND )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !( ent->v.groupinfo & host->v.groupinfo ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( g_groupop == GROUP_OP_NAND )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ent->v.groupinfo & host->v.groupinfo )
|
2016-06-04 15:24:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UTIL_UnsetGroupTrace();
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
memset( state, 0, sizeof(*state) );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Assign index so we can track this entity from frame to frame and
|
|
|
|
// delta from it.
|
2016-07-31 15:48:50 +02:00
|
|
|
state->number = e;
|
2016-06-04 15:24:23 +02:00
|
|
|
state->entityType = ENTITY_NORMAL;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// Flag custom entities.
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ent->v.flags & FL_CUSTOMENTITY )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
state->entityType = ENTITY_BEAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Copy state data
|
|
|
|
//
|
|
|
|
|
|
|
|
// Round animtime to nearest millisecond
|
2019-10-13 13:49:25 +02:00
|
|
|
state->animtime = (int)( 1000.0f * ent->v.animtime ) / 1000.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
memcpy( state->origin, ent->v.origin, 3 * sizeof(float) );
|
|
|
|
memcpy( state->angles, ent->v.angles, 3 * sizeof(float) );
|
|
|
|
memcpy( state->mins, ent->v.mins, 3 * sizeof(float) );
|
|
|
|
memcpy( state->maxs, ent->v.maxs, 3 * sizeof(float) );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
memcpy( state->startpos, ent->v.startpos, 3 * sizeof(float) );
|
|
|
|
memcpy( state->endpos, ent->v.endpos, 3 * sizeof(float) );
|
|
|
|
memcpy( state->velocity, ent->v.velocity, 3 * sizeof(float) );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
state->impacttime = ent->v.impacttime;
|
|
|
|
state->starttime = ent->v.starttime;
|
|
|
|
|
|
|
|
state->modelindex = ent->v.modelindex;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
state->frame = ent->v.frame;
|
|
|
|
|
|
|
|
state->skin = ent->v.skin;
|
|
|
|
state->effects = ent->v.effects;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// This non-player entity is being moved by the game .dll and not the physics simulation system
|
|
|
|
// make sure that we interpolate it's position on the client if it moves
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !player &&
|
2016-06-04 15:24:23 +02:00
|
|
|
ent->v.animtime &&
|
2016-07-31 15:48:50 +02:00
|
|
|
ent->v.velocity[0] == 0 &&
|
|
|
|
ent->v.velocity[1] == 0 &&
|
|
|
|
ent->v.velocity[2] == 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
state->eflags |= EFLAG_SLERP;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
state->scale = ent->v.scale;
|
|
|
|
state->solid = ent->v.solid;
|
|
|
|
state->colormap = ent->v.colormap;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
state->movetype = ent->v.movetype;
|
|
|
|
state->sequence = ent->v.sequence;
|
|
|
|
state->framerate = ent->v.framerate;
|
|
|
|
state->body = ent->v.body;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
for( i = 0; i < 4; i++ )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
state->controller[i] = ent->v.controller[i];
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
for( i = 0; i < 2; i++ )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
state->blending[i] = ent->v.blending[i];
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
state->rendermode = ent->v.rendermode;
|
2017-06-29 15:56:03 +02:00
|
|
|
state->renderamt = (int)ent->v.renderamt;
|
2016-07-31 15:48:50 +02:00
|
|
|
state->renderfx = ent->v.renderfx;
|
2017-06-29 15:56:03 +02:00
|
|
|
state->rendercolor.r = (byte)ent->v.rendercolor.x;
|
|
|
|
state->rendercolor.g = (byte)ent->v.rendercolor.y;
|
|
|
|
state->rendercolor.b = (byte)ent->v.rendercolor.z;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
state->aiment = 0;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ent->v.aiment )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
state->aiment = ENTINDEX( ent->v.aiment );
|
|
|
|
}
|
|
|
|
|
|
|
|
state->owner = 0;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ent->v.owner )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
int owner = ENTINDEX( ent->v.owner );
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
// Only care if owned by a player
|
2016-07-31 15:48:50 +02:00
|
|
|
if( owner >= 1 && owner <= gpGlobals->maxClients )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
state->owner = owner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
state->onground = 0;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ent->v.groundentity )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
state->onground = ENTINDEX( ent->v.groundentity );
|
|
|
|
}
|
|
|
|
|
|
|
|
// HACK: Somewhat...
|
|
|
|
// Class is overridden for non-players to signify a breakable glass object ( sort of a class? )
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !player )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
state->playerclass = ent->v.playerclass;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special stuff for players only
|
2016-07-31 15:48:50 +02:00
|
|
|
if( player )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
memcpy( state->basevelocity, ent->v.basevelocity, 3 * sizeof(float) );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
state->weaponmodel = MODEL_INDEX( STRING( ent->v.weaponmodel ) );
|
|
|
|
state->gaitsequence = ent->v.gaitsequence;
|
|
|
|
state->spectator = ent->v.flags & FL_SPECTATOR;
|
|
|
|
state->friction = ent->v.friction;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
state->gravity = ent->v.gravity;
|
|
|
|
//state->team = ent->v.team;
|
|
|
|
|
|
|
|
state->usehull = ( ent->v.flags & FL_DUCKING ) ? 1 : 0;
|
2017-06-29 15:56:03 +02:00
|
|
|
state->health = (int)ent->v.health;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// defaults for clientinfo messages
|
|
|
|
#define DEFAULT_VIEWHEIGHT 28
|
|
|
|
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
CreateBaseline
|
|
|
|
|
|
|
|
Creates baselines used for network encoding, especially for player data since players are not spawned until connect time.
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs )
|
|
|
|
{
|
|
|
|
baseline->origin = entity->v.origin;
|
|
|
|
baseline->angles = entity->v.angles;
|
|
|
|
baseline->frame = entity->v.frame;
|
|
|
|
baseline->skin = (short)entity->v.skin;
|
|
|
|
|
|
|
|
// render information
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->rendermode = (byte)entity->v.rendermode;
|
2016-06-04 15:24:23 +02:00
|
|
|
baseline->renderamt = (byte)entity->v.renderamt;
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->rendercolor.r = (byte)entity->v.rendercolor.x;
|
|
|
|
baseline->rendercolor.g = (byte)entity->v.rendercolor.y;
|
|
|
|
baseline->rendercolor.b = (byte)entity->v.rendercolor.z;
|
2016-06-04 15:24:23 +02:00
|
|
|
baseline->renderfx = (byte)entity->v.renderfx;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( player )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->mins = player_mins;
|
|
|
|
baseline->maxs = player_maxs;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->colormap = eindex;
|
2016-06-04 15:24:23 +02:00
|
|
|
baseline->modelindex = playermodelindex;
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->friction = 1.0;
|
|
|
|
baseline->movetype = MOVETYPE_WALK;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->scale = entity->v.scale;
|
|
|
|
baseline->solid = SOLID_SLIDEBOX;
|
|
|
|
baseline->framerate = 1.0;
|
|
|
|
baseline->gravity = 1.0;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->mins = entity->v.mins;
|
|
|
|
baseline->maxs = entity->v.maxs;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->colormap = 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
baseline->modelindex = entity->v.modelindex;//SV_ModelIndex(pr_strings + entity->v.model);
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->movetype = entity->v.movetype;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
baseline->scale = entity->v.scale;
|
|
|
|
baseline->solid = entity->v.solid;
|
|
|
|
baseline->framerate = entity->v.framerate;
|
|
|
|
baseline->gravity = entity->v.gravity;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char name[32];
|
2016-07-31 15:48:50 +02:00
|
|
|
int field;
|
2016-06-04 15:24:23 +02:00
|
|
|
} entity_field_alias_t;
|
|
|
|
|
|
|
|
#define FIELD_ORIGIN0 0
|
|
|
|
#define FIELD_ORIGIN1 1
|
|
|
|
#define FIELD_ORIGIN2 2
|
|
|
|
#define FIELD_ANGLES0 3
|
|
|
|
#define FIELD_ANGLES1 4
|
|
|
|
#define FIELD_ANGLES2 5
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
static entity_field_alias_t entity_field_alias[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{ "origin[0]", 0 },
|
|
|
|
{ "origin[1]", 0 },
|
|
|
|
{ "origin[2]", 0 },
|
|
|
|
{ "angles[0]", 0 },
|
|
|
|
{ "angles[1]", 0 },
|
|
|
|
{ "angles[2]", 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
void Entity_FieldInit( struct delta_s *pFields )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
entity_field_alias[FIELD_ORIGIN0].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ORIGIN0].name );
|
|
|
|
entity_field_alias[FIELD_ORIGIN1].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ORIGIN1].name );
|
|
|
|
entity_field_alias[FIELD_ORIGIN2].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ORIGIN2].name );
|
|
|
|
entity_field_alias[FIELD_ANGLES0].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ANGLES0].name );
|
|
|
|
entity_field_alias[FIELD_ANGLES1].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ANGLES1].name );
|
|
|
|
entity_field_alias[FIELD_ANGLES2].field = DELTA_FINDFIELD( pFields, entity_field_alias[FIELD_ANGLES2].name );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Entity_Encode
|
|
|
|
|
|
|
|
Callback for sending entity_state_t info over network.
|
|
|
|
FIXME: Move to script
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Entity_Encode( struct delta_s *pFields, const unsigned char *from, const unsigned char *to )
|
|
|
|
{
|
|
|
|
entity_state_t *f, *t;
|
|
|
|
int localplayer = 0;
|
|
|
|
static int initialized = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !initialized )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Entity_FieldInit( pFields );
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
f = (entity_state_t *)from;
|
|
|
|
t = (entity_state_t *)to;
|
|
|
|
|
|
|
|
// Never send origin to local player, it's sent with more resolution in clientdata_t structure
|
2016-07-31 15:48:50 +02:00
|
|
|
localplayer = ( t->number - 1 ) == ENGINE_CURRENT_PLAYER();
|
|
|
|
if( localplayer )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN0].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN1].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ( t->impacttime != 0 ) && ( t->starttime != 0 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN0].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN1].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ANGLES0].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ANGLES1].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ANGLES2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ( t->movetype == MOVETYPE_FOLLOW ) &&
|
|
|
|
( t->aiment != 0 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN0].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN1].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( t->aiment != f->aiment )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_SETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN0].field );
|
|
|
|
DELTA_SETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN1].field );
|
|
|
|
DELTA_SETBYINDEX( pFields, entity_field_alias[FIELD_ORIGIN2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
static entity_field_alias_t player_field_alias[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{ "origin[0]", 0 },
|
|
|
|
{ "origin[1]", 0 },
|
|
|
|
{ "origin[2]", 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
void Player_FieldInit( struct delta_s *pFields )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
player_field_alias[FIELD_ORIGIN0].field = DELTA_FINDFIELD( pFields, player_field_alias[FIELD_ORIGIN0].name );
|
|
|
|
player_field_alias[FIELD_ORIGIN1].field = DELTA_FINDFIELD( pFields, player_field_alias[FIELD_ORIGIN1].name );
|
|
|
|
player_field_alias[FIELD_ORIGIN2].field = DELTA_FINDFIELD( pFields, player_field_alias[FIELD_ORIGIN2].name );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Player_Encode
|
|
|
|
|
|
|
|
Callback for sending entity_state_t for players info over network.
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Player_Encode( struct delta_s *pFields, const unsigned char *from, const unsigned char *to )
|
|
|
|
{
|
|
|
|
entity_state_t *f, *t;
|
|
|
|
int localplayer = 0;
|
|
|
|
static int initialized = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !initialized )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Player_FieldInit( pFields );
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
f = (entity_state_t *)from;
|
|
|
|
t = (entity_state_t *)to;
|
|
|
|
|
|
|
|
// Never send origin to local player, it's sent with more resolution in clientdata_t structure
|
2016-07-31 15:48:50 +02:00
|
|
|
localplayer = ( t->number - 1 ) == ENGINE_CURRENT_PLAYER();
|
|
|
|
if( localplayer )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN0].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN1].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ( t->movetype == MOVETYPE_FOLLOW ) &&
|
2016-06-04 15:24:23 +02:00
|
|
|
( t->aiment != 0 ) )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN0].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN1].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( t->aiment != f->aiment )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_SETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN0].field );
|
|
|
|
DELTA_SETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN1].field );
|
|
|
|
DELTA_SETBYINDEX( pFields, player_field_alias[FIELD_ORIGIN2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CUSTOMFIELD_ORIGIN0 0
|
|
|
|
#define CUSTOMFIELD_ORIGIN1 1
|
|
|
|
#define CUSTOMFIELD_ORIGIN2 2
|
|
|
|
#define CUSTOMFIELD_ANGLES0 3
|
|
|
|
#define CUSTOMFIELD_ANGLES1 4
|
|
|
|
#define CUSTOMFIELD_ANGLES2 5
|
|
|
|
#define CUSTOMFIELD_SKIN 6
|
2016-07-31 15:48:50 +02:00
|
|
|
#define CUSTOMFIELD_SEQUENCE 7
|
|
|
|
#define CUSTOMFIELD_ANIMTIME 8
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
entity_field_alias_t custom_entity_field_alias[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
{ "origin[0]", 0 },
|
|
|
|
{ "origin[1]", 0 },
|
|
|
|
{ "origin[2]", 0 },
|
|
|
|
{ "angles[0]", 0 },
|
|
|
|
{ "angles[1]", 0 },
|
|
|
|
{ "angles[2]", 0 },
|
2016-07-31 15:48:50 +02:00
|
|
|
{ "skin", 0 },
|
2016-06-04 15:24:23 +02:00
|
|
|
{ "sequence", 0 },
|
|
|
|
{ "animtime", 0 },
|
|
|
|
};
|
|
|
|
|
|
|
|
void Custom_Entity_FieldInit( struct delta_s *pFields )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].name );
|
|
|
|
custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].name );
|
|
|
|
custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].name );
|
|
|
|
custom_entity_field_alias[CUSTOMFIELD_ANGLES0].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES0].name );
|
|
|
|
custom_entity_field_alias[CUSTOMFIELD_ANGLES1].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES1].name );
|
|
|
|
custom_entity_field_alias[CUSTOMFIELD_ANGLES2].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES2].name );
|
|
|
|
custom_entity_field_alias[CUSTOMFIELD_SKIN].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_SKIN].name );
|
|
|
|
custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].name );
|
|
|
|
custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].field = DELTA_FINDFIELD( pFields, custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].name );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Custom_Encode
|
|
|
|
|
|
|
|
Callback for sending entity_state_t info ( for custom entities ) over network.
|
|
|
|
FIXME: Move to script
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Custom_Encode( struct delta_s *pFields, const unsigned char *from, const unsigned char *to )
|
|
|
|
{
|
|
|
|
entity_state_t *f, *t;
|
|
|
|
int beamType;
|
|
|
|
static int initialized = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !initialized )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Custom_Entity_FieldInit( pFields );
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
f = (entity_state_t *)from;
|
|
|
|
t = (entity_state_t *)to;
|
|
|
|
|
|
|
|
beamType = t->rendermode & 0x0f;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
if( beamType != BEAM_POINTS && beamType != BEAM_ENTPOINT )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( beamType != BEAM_POINTS )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES0].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES1].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES2].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_SKIN].field );
|
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// animtime is compared by rounding first
|
|
|
|
// see if we really shouldn't actually send it
|
2016-07-31 15:48:50 +02:00
|
|
|
if( (int)f->animtime == (int)t->animtime )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
DELTA_UNSETBYINDEX( pFields, custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].field );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
RegisterEncoders
|
|
|
|
|
|
|
|
Allows game .dll to override network encoding of certain types of entities and tweak values, etc.
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void RegisterEncoders( void )
|
|
|
|
{
|
|
|
|
DELTA_ADDENCODER( "Entity_Encode", Entity_Encode );
|
|
|
|
DELTA_ADDENCODER( "Custom_Encode", Custom_Encode );
|
|
|
|
DELTA_ADDENCODER( "Player_Encode", Player_Encode );
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
|
|
|
|
{
|
2022-07-27 07:24:22 +02:00
|
|
|
memset( info, 0, MAX_WEAPONS * sizeof(weapon_data_t) );
|
2021-06-07 16:17:22 +02:00
|
|
|
#if CLIENT_WEAPONS
|
2016-06-04 15:24:23 +02:00
|
|
|
int i;
|
|
|
|
weapon_data_t *item;
|
|
|
|
entvars_t *pev = &player->v;
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
CBasePlayerWeapon *gun;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
if( !pl )
|
2016-06-04 15:24:23 +02:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
// go through all of the weapons and make a list of the ones to pack
|
2016-07-31 15:48:50 +02:00
|
|
|
for( i = 0; i < MAX_ITEM_TYPES; i++ )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pl->m_rgpPlayerItems[i] )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// there's a weapon here. Should I pack it?
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayerItem *pPlayerItem = pl->m_rgpPlayerItems[i];
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
while( pPlayerItem )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr();
|
2016-07-31 15:48:50 +02:00
|
|
|
if( gun && gun->UseDecrement() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-08-02 13:59:22 +02:00
|
|
|
ItemInfo II = {0};
|
2016-06-04 15:24:23 +02:00
|
|
|
// Get The ID.
|
|
|
|
gun->GetItemInfo( &II );
|
|
|
|
|
2022-07-27 07:24:22 +02:00
|
|
|
if( II.iId >= 0 && II.iId < MAX_WEAPONS )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
item = &info[II.iId];
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
item->m_iId = II.iId;
|
|
|
|
item->m_iClip = gun->m_iClip;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
item->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle, -0.001f );
|
|
|
|
item->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack, -0.001f );
|
|
|
|
item->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack, -0.001f );
|
2016-07-31 15:48:50 +02:00
|
|
|
item->m_fInReload = gun->m_fInReload;
|
|
|
|
item->m_fInSpecialReload = gun->m_fInSpecialReload;
|
2019-10-13 13:49:25 +02:00
|
|
|
item->fuser1 = Q_max( gun->pev->fuser1, -0.001f );
|
2016-07-31 15:48:50 +02:00
|
|
|
item->fuser2 = gun->m_flStartThrow;
|
|
|
|
item->fuser3 = gun->m_flReleaseThrow;
|
|
|
|
item->iuser1 = gun->m_chargeReady;
|
|
|
|
item->iuser2 = gun->m_fInAttack;
|
|
|
|
item->iuser3 = gun->m_fireState;
|
|
|
|
|
|
|
|
//item->m_flPumpTime = max( gun->m_flPumpTime, -0.001 );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pPlayerItem = pPlayerItem->m_pNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
UpdateClientData
|
|
|
|
|
|
|
|
Data sent to current client only
|
|
|
|
engine sets cd to 0 before calling.
|
|
|
|
=================
|
|
|
|
*/
|
2016-07-31 15:48:50 +02:00
|
|
|
void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-06-26 02:47:19 +02:00
|
|
|
if( !ent || !ent->pvPrivateData )
|
|
|
|
return;
|
|
|
|
entvars_t *pev = (entvars_t *)&ent->v;
|
|
|
|
CBasePlayer *pl = (CBasePlayer *)( CBasePlayer::Instance( pev ) );
|
|
|
|
entvars_t *pevOrg = NULL;
|
|
|
|
|
|
|
|
// if user is spectating different player in First person, override some vars
|
|
|
|
if( pl && pl->pev->iuser1 == OBS_IN_EYE )
|
|
|
|
{
|
|
|
|
if( pl->m_hObserverTarget )
|
|
|
|
{
|
|
|
|
pevOrg = pev;
|
|
|
|
pev = pl->m_hObserverTarget->pev;
|
|
|
|
pl = (CBasePlayer *)(CBasePlayer::Instance( pev ) );
|
|
|
|
}
|
|
|
|
}
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
cd->flags = pev->flags;
|
|
|
|
cd->health = pev->health;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
cd->viewmodel = MODEL_INDEX( STRING( pev->viewmodel ) );
|
|
|
|
|
|
|
|
cd->waterlevel = pev->waterlevel;
|
|
|
|
cd->watertype = pev->watertype;
|
|
|
|
cd->weapons = pev->weapons;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Vectors
|
2017-06-26 02:47:19 +02:00
|
|
|
cd->origin = pev->origin;
|
|
|
|
cd->velocity = pev->velocity;
|
|
|
|
cd->view_ofs = pev->view_ofs;
|
|
|
|
cd->punchangle = pev->punchangle;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
cd->bInDuck = pev->bInDuck;
|
|
|
|
cd->flTimeStepSound = pev->flTimeStepSound;
|
|
|
|
cd->flDuckTime = pev->flDuckTime;
|
|
|
|
cd->flSwimTime = pev->flSwimTime;
|
|
|
|
cd->waterjumptime = pev->teleport_time;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) );
|
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
cd->maxspeed = pev->maxspeed;
|
|
|
|
cd->fov = pev->fov;
|
|
|
|
cd->weaponanim = pev->weaponanim;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
cd->pushmsec = pev->pushmsec;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-06-26 02:47:19 +02:00
|
|
|
// Spectator mode
|
|
|
|
if( pevOrg != NULL )
|
|
|
|
{
|
|
|
|
// don't use spec vars from chased player
|
|
|
|
cd->iuser1 = pevOrg->iuser1;
|
|
|
|
cd->iuser2 = pevOrg->iuser2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cd->iuser1 = pev->iuser1;
|
|
|
|
cd->iuser2 = pev->iuser2;
|
|
|
|
}
|
2021-06-07 16:17:22 +02:00
|
|
|
#if CLIENT_WEAPONS
|
2016-07-31 15:48:50 +02:00
|
|
|
if( sendweapons )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pl )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
cd->m_flNextAttack = pl->m_flNextAttack;
|
|
|
|
cd->fuser2 = pl->m_flNextAmmoBurn;
|
|
|
|
cd->fuser3 = pl->m_flAmmoStartCharge;
|
|
|
|
cd->vuser1.x = pl->ammo_9mm;
|
|
|
|
cd->vuser1.y = pl->ammo_357;
|
|
|
|
cd->vuser1.z = pl->ammo_argrens;
|
|
|
|
cd->ammo_nails = pl->ammo_bolts;
|
|
|
|
cd->ammo_shells = pl->ammo_buckshot;
|
|
|
|
cd->ammo_rockets = pl->ammo_rockets;
|
|
|
|
cd->ammo_cells = pl->ammo_uranium;
|
|
|
|
cd->vuser2.x = pl->ammo_hornets;
|
|
|
|
|
|
|
|
if( pl->m_pActiveItem )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
CBasePlayerWeapon *gun;
|
|
|
|
gun = (CBasePlayerWeapon *)pl->m_pActiveItem->GetWeaponPtr();
|
2016-07-31 15:48:50 +02:00
|
|
|
if( gun && gun->UseDecrement() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-08-02 13:59:22 +02:00
|
|
|
ItemInfo II = {0};
|
2016-06-04 15:24:23 +02:00
|
|
|
gun->GetItemInfo( &II );
|
|
|
|
|
|
|
|
cd->m_iId = II.iId;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
cd->vuser3.z = gun->m_iSecondaryAmmoType;
|
|
|
|
cd->vuser4.x = gun->m_iPrimaryAmmoType;
|
|
|
|
cd->vuser4.y = pl->m_rgAmmo[gun->m_iPrimaryAmmoType];
|
|
|
|
cd->vuser4.z = pl->m_rgAmmo[gun->m_iSecondaryAmmoType];
|
|
|
|
|
|
|
|
if( pl->m_pActiveItem->m_iId == WEAPON_RPG )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
cd->vuser2.y = ( (CRpg *)pl->m_pActiveItem )->m_fSpotActive;
|
|
|
|
cd->vuser2.z = ( (CRpg *)pl->m_pActiveItem )->m_cActiveRockets;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CmdStart
|
|
|
|
|
|
|
|
We're about to run this usercmd for the specified player. We can set up groupinfo and masking here, etc.
|
|
|
|
This is the time to examine the usercmd for anything extra. This call happens even if think does not.
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed )
|
|
|
|
{
|
|
|
|
entvars_t *pev = (entvars_t *)&player->v;
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
if( !pl )
|
|
|
|
return;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pl->pev->groupinfo != 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
UTIL_SetGroupTrace( pl->pev->groupinfo, GROUP_OP_AND );
|
|
|
|
}
|
|
|
|
|
|
|
|
pl->random_seed = random_seed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CmdEnd
|
|
|
|
|
|
|
|
Each cmdstart is exactly matched with a cmd end, clean up any group trace flags, etc. here
|
|
|
|
=================
|
|
|
|
*/
|
2016-07-31 15:48:50 +02:00
|
|
|
void CmdEnd( const edict_t *player )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
entvars_t *pev = (entvars_t *)&player->v;
|
2016-07-31 15:48:50 +02:00
|
|
|
CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
if( !pl )
|
|
|
|
return;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pl->pev->groupinfo != 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
UTIL_UnsetGroupTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================
|
|
|
|
ConnectionlessPacket
|
|
|
|
|
|
|
|
Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max
|
|
|
|
size of the response_buffer, so you must zero it out if you choose not to respond.
|
|
|
|
================================
|
|
|
|
*/
|
2016-07-31 15:48:50 +02:00
|
|
|
int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// Parse stuff from args
|
2017-06-29 15:56:03 +02:00
|
|
|
//int max_buffer_size = *response_buffer_size;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Zero it out since we aren't going to respond.
|
|
|
|
// If we wanted to response, we'd write data into response_buffer
|
|
|
|
*response_buffer_size = 0;
|
|
|
|
|
|
|
|
// Since we don't listen for anything here, just respond that it's a bogus message
|
|
|
|
// If we didn't reject the message, we'd return 1 for success instead.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================
|
|
|
|
GetHullBounds
|
|
|
|
|
|
|
|
Engine calls this to enumerate player collision hulls, for prediction. Return 0 if the hullnumber doesn't exist.
|
|
|
|
================================
|
|
|
|
*/
|
|
|
|
int GetHullBounds( int hullnumber, float *mins, float *maxs )
|
|
|
|
{
|
|
|
|
int iret = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( hullnumber )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case 0: // Normal player
|
2017-07-02 16:02:52 +02:00
|
|
|
VEC_HULL_MIN.CopyToArray(mins);
|
|
|
|
VEC_HULL_MAX.CopyToArray(maxs);
|
2016-06-04 15:24:23 +02:00
|
|
|
iret = 1;
|
|
|
|
break;
|
|
|
|
case 1: // Crouched player
|
2017-07-02 16:02:52 +02:00
|
|
|
VEC_DUCK_HULL_MIN.CopyToArray(mins);
|
|
|
|
VEC_DUCK_HULL_MAX.CopyToArray(maxs);
|
2016-06-04 15:24:23 +02:00
|
|
|
iret = 1;
|
|
|
|
break;
|
|
|
|
case 2: // Point based hull
|
2017-07-02 16:02:52 +02:00
|
|
|
Vector( 0, 0, 0 ).CopyToArray(mins);
|
|
|
|
Vector( 0, 0, 0 ).CopyToArray(maxs);
|
2016-06-04 15:24:23 +02:00
|
|
|
iret = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================
|
|
|
|
CreateInstancedBaselines
|
|
|
|
|
|
|
|
Create pseudo-baselines for items that aren't placed in the map at spawn time, but which are likely
|
|
|
|
to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, etc. )
|
|
|
|
================================
|
|
|
|
*/
|
2016-07-31 15:48:50 +02:00
|
|
|
void CreateInstancedBaselines( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-06-29 15:56:03 +02:00
|
|
|
/*int iret = 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
entity_state_t state;
|
|
|
|
|
2017-06-29 15:56:03 +02:00
|
|
|
memset( &state, 0, sizeof(state) );*/
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// Create any additional baselines here for things like grendates, etc.
|
|
|
|
// iret = ENGINE_INSTANCE_BASELINE( pc->pev->classname, &state );
|
|
|
|
|
|
|
|
// Destroy objects.
|
|
|
|
//UTIL_Remove( pc );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================
|
|
|
|
InconsistentFile
|
|
|
|
|
|
|
|
One of the ENGINE_FORCE_UNMODIFIED files failed the consistency check for the specified player
|
|
|
|
Return 0 to allow the client to continue, 1 to force immediate disconnection ( with an optional disconnect message of up to 256 characters )
|
|
|
|
================================
|
|
|
|
*/
|
2016-07-31 15:48:50 +02:00
|
|
|
int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// Server doesn't care?
|
2019-10-13 13:49:25 +02:00
|
|
|
if( CVAR_GET_FLOAT( "mp_consistency" ) != 1.0f )
|
2016-06-04 15:24:23 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Default behavior is to kick the player
|
|
|
|
sprintf( disconnect_message, "Server is enforcing file consistency for %s\n", filename );
|
|
|
|
|
|
|
|
// Kick now with specified disconnect message.
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================
|
|
|
|
AllowLagCompensation
|
|
|
|
|
|
|
|
The game .dll should return 1 if lag compensation should be allowed ( could also just set
|
|
|
|
the sv_unlag cvar.
|
|
|
|
Most games right now should return 0, until client-side weapon prediction code is written
|
|
|
|
and tested for them ( note you can predict weapons, but not do lag compensation, too,
|
|
|
|
if you want.
|
|
|
|
================================
|
|
|
|
*/
|
|
|
|
int AllowLagCompensation( void )
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|