source-engine/game/server/stargate/dhd_console.cpp
Deploy Bot 44cb9a4837 StargateTC port — initial integration into nillerusr/source-engine
P1: Source files
- Copy 9 server stargate files + sg_constants.h + sg_weapons.cpp from
  StargateTCSource/sourcecode/ into game/server/stargate/ and
  game/shared/stargate/.
- Add $Folder "Stargate" block to server_hl2mp.vpc and client_hl2mp.vpc.
- Extend $AdditionalIncludeDirectories with stargate paths.

P2/P3: Gamerules + player patches
- hl2mp_gamerules.h: add TEAM_JAFFA=4, TEAM_UNAS=5 to team enum.
- hl2mp_gamerules.cpp: preserve 5 Stargate spawn classnames in
  s_PreserveEnts[]; rename teams to Tau'ri/Goa'uld/Jaffa/Unas;
  rename game description to "StargateTC"/"StargateTC Teamplay".
- hl2mp_player.cpp: EntSelectSpawnPoint now searches Stargate spawn
  classnames first (torri/goauld/marine/unas) with per-team fallback
  chain to combine/rebel/deathmatch.

Build: 0 errors. Server.dll 13.19MB, client.dll 9.85MB.
Runtime test: window title "StargateTC", live game launches,
HEALTH 100 HUD renders, HL2MP MOTD shown, sky/world geometry renders.
Response system loads 217 rules without crashing (was the original
Mapbase+VS2022 heap-corruption point).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 14:08:44 +01:00

73 lines
2.0 KiB
C++

//============= Copyright © StargateTC Source Team =============================
//
// dhd_console — the Dial-Home-Device. A player +USEs it to fire the matching
// stargate_event's Dial input. Includes a per-DHD lockout while the gate is
// active to prevent re-dial.
//
// Keyvalues:
// target — name of the stargate_event to dial
//
//==============================================================================
#include "cbase.h"
#include "stargate/sg_constants.h"
class CDHDConsole : public CBaseAnimating
{
public:
DECLARE_CLASS( CDHDConsole, CBaseAnimating );
DECLARE_DATADESC();
void Spawn() override;
void Precache() override;
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller,
USE_TYPE useType, float value ) override;
int ObjectCaps() override { return BaseClass::ObjectCaps() | FCAP_IMPULSE_USE; }
private:
bool m_bBusy { false };
void Unbusy() { m_bBusy = false; SetNextThink( TICK_NEVER_THINK ); }
};
LINK_ENTITY_TO_CLASS( dhd_console, CDHDConsole );
BEGIN_DATADESC( CDHDConsole )
DEFINE_THINKFUNC( Unbusy ),
END_DATADESC()
void CDHDConsole::Spawn()
{
BaseClass::Spawn();
Precache();
SetModel( "models/stargate/dhd_console.mdl" );
SetSolid( SOLID_VPHYSICS );
SetMoveType( MOVETYPE_NONE );
}
void CDHDConsole::Precache()
{
PrecacheModel( "models/stargate/dhd_console.mdl" );
PrecacheScriptSound( "Stargate.DHDPress" );
}
void CDHDConsole::Use( CBaseEntity *pActivator, CBaseEntity *,
USE_TYPE, float )
{
if ( m_bBusy || !pActivator || !pActivator->IsPlayer() )
return;
EmitSound( "Stargate.DHDPress" );
CBaseEntity *pGate = gEntList.FindEntityByName( NULL, m_target );
if ( pGate )
{
variant_t empty;
pGate->AcceptInput( "Dial", pActivator, this, empty, 0 );
}
m_bBusy = true;
SetThink( &CDHDConsole::Unbusy );
SetNextThink( gpGlobals->curtime +
StargateTC::DIAL_SYMBOL_COUNT * StargateTC::DIAL_SYMBOL_TIME +
StargateTC::KAWOOSH_DURATION );
}