summaryrefslogtreecommitdiff
path: root/game/server/hl2mp/hl2mp_client.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/hl2mp/hl2mp_client.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/server/hl2mp/hl2mp_client.cpp')
-rw-r--r--game/server/hl2mp/hl2mp_client.cpp201
1 files changed, 201 insertions, 0 deletions
diff --git a/game/server/hl2mp/hl2mp_client.cpp b/game/server/hl2mp/hl2mp_client.cpp
new file mode 100644
index 0000000..571fbb8
--- /dev/null
+++ b/game/server/hl2mp/hl2mp_client.cpp
@@ -0,0 +1,201 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+/*
+
+===== tf_client.cpp ========================================================
+
+ HL2 client/server game specific stuff
+
+*/
+
+#include "cbase.h"
+#include "hl2mp_player.h"
+#include "hl2mp_gamerules.h"
+#include "gamerules.h"
+#include "teamplay_gamerules.h"
+#include "entitylist.h"
+#include "physics.h"
+#include "game.h"
+#include "player_resource.h"
+#include "engine/IEngineSound.h"
+#include "team.h"
+#include "viewport_panel_names.h"
+
+#include "tier0/vprof.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+void Host_Say( edict_t *pEdict, bool teamonly );
+
+ConVar sv_motd_unload_on_dismissal( "sv_motd_unload_on_dismissal", "0", 0, "If enabled, the MOTD contents will be unloaded when the player closes the MOTD." );
+
+extern CBaseEntity* FindPickerEntityClass( CBasePlayer *pPlayer, char *classname );
+extern bool g_fGameOver;
+
+void FinishClientPutInServer( CHL2MP_Player *pPlayer )
+{
+ pPlayer->InitialSpawn();
+ pPlayer->Spawn();
+
+
+ char sName[128];
+ Q_strncpy( sName, pPlayer->GetPlayerName(), sizeof( sName ) );
+
+ // First parse the name and remove any %'s
+ for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ )
+ {
+ // Replace it with a space
+ if ( *pApersand == '%' )
+ *pApersand = ' ';
+ }
+
+ // notify other clients of player joining the game
+ UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Game_connected", sName[0] != 0 ? sName : "<unconnected>" );
+
+ if ( HL2MPRules()->IsTeamplay() == true )
+ {
+ ClientPrint( pPlayer, HUD_PRINTTALK, "You are on team %s1\n", pPlayer->GetTeam()->GetName() );
+ }
+
+ const ConVar *hostname = cvar->FindVar( "hostname" );
+ const char *title = (hostname) ? hostname->GetString() : "MESSAGE OF THE DAY";
+
+ KeyValues *data = new KeyValues("data");
+ data->SetString( "title", title ); // info panel title
+ data->SetString( "type", "1" ); // show userdata from stringtable entry
+ data->SetString( "msg", "motd" ); // use this stringtable entry
+ data->SetBool( "unload", sv_motd_unload_on_dismissal.GetBool() );
+
+ pPlayer->ShowViewPortPanel( PANEL_INFO, true, data );
+
+ data->deleteThis();
+}
+
+/*
+===========
+ClientPutInServer
+
+called each time a player is spawned into the game
+============
+*/
+void ClientPutInServer( edict_t *pEdict, const char *playername )
+{
+ // Allocate a CBaseTFPlayer for pev, and call spawn
+ CHL2MP_Player *pPlayer = CHL2MP_Player::CreatePlayer( "player", pEdict );
+ pPlayer->SetPlayerName( playername );
+}
+
+
+void ClientActive( edict_t *pEdict, bool bLoadGame )
+{
+ // Can't load games in CS!
+ Assert( !bLoadGame );
+
+ CHL2MP_Player *pPlayer = ToHL2MPPlayer( CBaseEntity::Instance( pEdict ) );
+ FinishClientPutInServer( pPlayer );
+}
+
+
+/*
+===============
+const char *GetGameDescription()
+
+Returns the descriptive name of this .dll. E.g., Half-Life, or Team Fortress 2
+===============
+*/
+const char *GetGameDescription()
+{
+ if ( g_pGameRules ) // this function may be called before the world has spawned, and the game rules initialized
+ return g_pGameRules->GetGameDescription();
+ else
+ return "Half-Life 2 Deathmatch";
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Given a player and optional name returns the entity of that
+// classname that the player is nearest facing
+//
+// Input :
+// Output :
+//-----------------------------------------------------------------------------
+CBaseEntity* FindEntity( edict_t *pEdict, char *classname)
+{
+ // If no name was given set bits based on the picked
+ if (FStrEq(classname,""))
+ {
+ return (FindPickerEntityClass( static_cast<CBasePlayer*>(GetContainingEntity(pEdict)), classname ));
+ }
+ return NULL;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Precache game-specific models & sounds
+//-----------------------------------------------------------------------------
+void ClientGamePrecache( void )
+{
+ CBaseEntity::PrecacheModel("models/player.mdl");
+ CBaseEntity::PrecacheModel( "models/gibs/agibs.mdl" );
+ CBaseEntity::PrecacheModel ("models/weapons/v_hands.mdl");
+
+ CBaseEntity::PrecacheScriptSound( "HUDQuickInfo.LowAmmo" );
+ CBaseEntity::PrecacheScriptSound( "HUDQuickInfo.LowHealth" );
+
+ CBaseEntity::PrecacheScriptSound( "FX_AntlionImpact.ShellImpact" );
+ CBaseEntity::PrecacheScriptSound( "Missile.ShotDown" );
+ CBaseEntity::PrecacheScriptSound( "Bullets.DefaultNearmiss" );
+ CBaseEntity::PrecacheScriptSound( "Bullets.GunshipNearmiss" );
+ CBaseEntity::PrecacheScriptSound( "Bullets.StriderNearmiss" );
+
+ CBaseEntity::PrecacheScriptSound( "Geiger.BeepHigh" );
+ CBaseEntity::PrecacheScriptSound( "Geiger.BeepLow" );
+}
+
+
+// called by ClientKill and DeadThink
+void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
+{
+ CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );
+
+ if ( pPlayer )
+ {
+ if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
+ {
+ // respawn player
+ pPlayer->Spawn();
+ }
+ else
+ {
+ pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
+ }
+ }
+}
+
+void GameStartFrame( void )
+{
+ VPROF("GameStartFrame()");
+ if ( g_fGameOver )
+ return;
+
+ gpGlobals->teamplay = (teamplay.GetInt() != 0);
+
+#ifdef DEBUG
+ extern void Bot_RunAll();
+ Bot_RunAll();
+#endif
+}
+
+//=========================================================
+// instantiate the proper game rules object
+//=========================================================
+void InstallGameRules()
+{
+ // vanilla deathmatch
+ CreateGameRulesObject( "CHL2MPRules" );
+}
+