Skip to content

Commit fa1565f

Browse files
committed
Add AllowDefaultSuit and AllowDefaultItems for HL2MP gamerules
1 parent d7eef2a commit fa1565f

5 files changed

Lines changed: 56 additions & 0 deletions

File tree

src/game/server/hl2mp/hl2mp_player.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,16 @@ void CHL2MP_Player::GiveAllItems( void )
244244

245245
void CHL2MP_Player::GiveDefaultItems( void )
246246
{
247+
#ifdef MAPBASE
248+
if (HL2MPRules()->AllowDefaultSuit())
249+
#endif
247250
EquipSuit();
248251

252+
#ifdef MAPBASE
253+
if (!HL2MPRules()->AllowDefaultItems())
254+
return;
255+
#endif
256+
249257
CBasePlayer::GiveAmmo( 255, "Pistol");
250258
CBasePlayer::GiveAmmo( 45, "SMG1");
251259
CBasePlayer::GiveAmmo( 1, "grenade" );

src/game/shared/hl2mp/hl2mp_gamerules.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,38 @@ void CHL2MPRules::PlayerIdle( CBasePlayer *pPlayer )
308308

309309
//BaseClass::PlayerIdle( pPlayer );
310310
}
311+
312+
//-----------------------------------------------------------------------------
313+
// Gets our default items setting.
314+
//-----------------------------------------------------------------------------
315+
bool CHL2MPRules::AllowDefaultItems()
316+
{
317+
return m_bAllowDefaultItems;
318+
}
319+
320+
//-----------------------------------------------------------------------------
321+
// Sets our default items setting.
322+
//-----------------------------------------------------------------------------
323+
void CHL2MPRules::SetAllowDefaultItems( bool toggle )
324+
{
325+
m_bAllowDefaultItems = toggle;
326+
}
327+
328+
//-----------------------------------------------------------------------------
329+
// Gets our default suit setting.
330+
//-----------------------------------------------------------------------------
331+
bool CHL2MPRules::AllowDefaultSuit()
332+
{
333+
return m_bAllowDefaultSuit;
334+
}
335+
336+
//-----------------------------------------------------------------------------
337+
// Sets our default suit setting.
338+
//-----------------------------------------------------------------------------
339+
void CHL2MPRules::SetAllowDefaultSuit( bool toggle )
340+
{
341+
m_bAllowDefaultSuit = toggle;
342+
}
311343
#endif
312344

313345

src/game/shared/hl2mp/hl2mp_gamerules.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ class CHL2MPRules : public CTeamplayRules
139139
#ifdef MAPBASE
140140
void PlayerSpawn( CBasePlayer *pPlayer );
141141
void PlayerIdle( CBasePlayer *pPlayer );
142+
143+
bool AllowDefaultItems();
144+
void SetAllowDefaultItems( bool toggle );
145+
146+
bool AllowDefaultSuit();
147+
void SetAllowDefaultSuit( bool toggle );
142148
#endif
143149

144150
#endif
@@ -173,6 +179,9 @@ class CHL2MPRules : public CTeamplayRules
173179
bool m_bChangelevelDone;
174180

175181
#ifdef MAPBASE
182+
bool m_bAllowDefaultItems = true;
183+
bool m_bAllowDefaultSuit = true;
184+
176185
CNetworkVar( bool, m_bHideBotJoinGame ); // Hides when bots connect and disconnect from the game
177186
#endif
178187
#endif

src/game/shared/multiplay_gamerules.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ ConVarRef suitcharger( "sk_suitcharger" );
680680
bool addDefault;
681681
CBaseEntity *pWeaponEntity = NULL;
682682

683+
#ifdef MAPBASE
684+
if (AllowDefaultSuit())
685+
#endif
683686
pPlayer->EquipSuit();
684687

685688
addDefault = true;

src/game/shared/multiplay_gamerules.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ class CMultiplayRules : public CGameRules
168168
virtual bool CanHaveItem( CBasePlayer *pPlayer, CItem *pItem );
169169
virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem );
170170

171+
#ifdef MAPBASE
172+
virtual bool AllowDefaultSuit() { return true; }
173+
#endif
174+
171175
// Item spawn/respawn control
172176
virtual int ItemShouldRespawn( CItem *pItem );
173177
virtual float FlItemRespawnTime( CItem *pItem );

0 commit comments

Comments
 (0)