Skip to content

Commit 020946a

Browse files
committed
Add SP changes to HL2MP gravity gun + clientside +USE prediction
1 parent 303e632 commit 020946a

File tree

6 files changed

+1441
-133
lines changed

6 files changed

+1441
-133
lines changed

src/game/client/c_baseentity.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,11 @@ class C_BaseEntity : public IClientEntity
10471047
// are relative to the attachment on this entity.
10481048
void SetParent( C_BaseEntity *pParentEntity, int iParentAttachment=0 );
10491049

1050+
#ifdef MAPBASE_MP
1051+
// Some entities should predict +USE interaction
1052+
virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) {}
1053+
#endif
1054+
10501055
bool PhysicsRunThink( thinkmethods_t thinkMethod = THINK_FIRE_ALL_FUNCTIONS );
10511056
bool PhysicsRunSpecificThink( int nContextIndex, BASEPTR thinkFunc );
10521057

src/game/client/c_baseplayer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,13 @@ void C_BasePlayer::PostThink( void )
24482448
{
24492449
SetCollisionBounds( VEC_HULL_MIN, VEC_HULL_MAX );
24502450
}
2451+
2452+
#ifdef MAPBASE_MP
2453+
if ( m_hUseEntity != NULL )
2454+
{
2455+
m_hUseEntity->Use( this, this, USE_SET, 2 );
2456+
}
2457+
#endif
24512458

24522459
if ( !CommentaryModeShouldSwallowInput( this ) )
24532460
{

src/game/server/hl2/func_tank.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,23 @@ void CFuncTank::UpdateOnRemove( void )
11111111
BaseClass::UpdateOnRemove();
11121112
}
11131113

1114+
#ifdef MAPBASE_MP
1115+
void CFuncTank::AddEffects( int nEffects )
1116+
{
1117+
if ( nEffects & EF_NODRAW && gpGlobals->maxClients > 1 )
1118+
{
1119+
// The client needs to know that we are the +USE entity for prediction, but EF_NODRAW prevents that.
1120+
// Swallow nodraw and turn invisible in a way that transmits to the client.
1121+
nEffects &= ~(EF_NODRAW);
1122+
1123+
nEffects |= EF_NOSHADOW;
1124+
SetRenderMode( kRenderNone );
1125+
}
1126+
1127+
BaseClass::AddEffects( nEffects );
1128+
}
1129+
#endif
1130+
11141131

11151132
//-----------------------------------------------------------------------------
11161133
// Barrel position

src/game/server/hl2/func_tank.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ class CFuncTank : public CBaseEntity
9191
bool KeyValue( const char *szKeyName, const char *szValue );
9292
void UpdateOnRemove();
9393

94+
#ifdef MAPBASE_MP
95+
void AddEffects( int nEffects );
96+
#endif
97+
9498
void SetYawRate( float flYawRate ) { m_yawRate = flYawRate; }
9599
void SetPitchRate( float flPitchRate ) { m_pitchRate = flPitchRate; }
96100

0 commit comments

Comments
 (0)