Skip to content

Commit 87cd9b2

Browse files
committed
Mapbase v6.1
- Added postprocess_controller entity from later versions of Source - Added env_dof_controller entity from later versions of Source - Added SDK_Engine_Post and DepthOfField shaders from the Momentum repo/Alien Swarm SDK - Fixed auto-breaking game_text/choreo text not null terminating - Fixed console groups showing up at the wrong developer levels - Added more mesages to console groups, including a new "NPC AI" console group - Fixed typos and added elaboration in various cvars, console messages, etc. - Fixed npc_metropolice not using frag grenades correctly when allowed to use them - Fixed npc_metropolice not registering stitching squad slots in AI - Fixed SetModel input late precache warning - Fixed env_global_light angles resetting upon loading a save - Fixed an issue with ScriptKeyValuesRead using the wrong name and having a memory leak - Allowed VScript functions which return null strings to actually return null instead of empty strings - Added VScript member variable documentation - Fixed VScript documentation lines sometimes mixing together - Fixed VScript singletons having a ! at the beginning of descriptions - Added Color struct to VScript and allowed color-related inputs to use it - Added more VScript functions for weapons, ammo, ragdolling, and response contexts - Added GameRules singleton for VScript - Exposed AI interaction system to VScript - Recovered some lost documentation from older revisions of the Mapbase wiki - Added a way to get the current game's load type in VScript - Fixed Precache/SpawnEntityFromTable not accounting for a few important field types - Added VScript functions for getting a player's eye vectors - Fixed a crash caused by removing the active weapon of a Combine soldier while it's firing - Changed the way metrocops deploy their manhacks so they could use their manhack death response properly - Fixed "Use Server" keyvalue on game_convar_mod not working - Adjusted CAI_Expresser in VScript
1 parent 6d45d95 commit 87cd9b2

File tree

82 files changed

+4589
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4589
-330
lines changed

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Here's a list of Mapbase's other known external code sources:
5353
- https://github.com/KyleGospo/City-17-Episode-One-Source (Brush phong and projected texture changes, included indirectly via Insolence repo)
5454
- https://github.com/DownFall-Team/DownFall (Multiple skybox code and fix for ent_fire delay not using floats; Also used as a guide to port certain Alien Swarm SDK changes to Source 2013,
5555
including radial fog, rope code, and treesway)
56+
- https://github.com/momentum-mod/game (Used as a guide to port postprocess_controller and env_dof_controller to Source 2013)
5657
- https://github.com/DeathByNukes/source-sdk-2013 (VBSP manifest fixes)
5758
- https://github.com/entropy-zero/source-sdk-2013 (skill_changed game event)
5859

sp/src/game/client/c_baseplayer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ END_RECV_TABLE()
331331

332332
RecvPropString( RECVINFO(m_szLastPlaceName) ),
333333

334+
RecvPropEHandle(RECVINFO(m_hPostProcessCtrl)), // Send to everybody - for spectating
335+
334336
#if defined USES_ECON_ITEMS
335337
RecvPropUtlVector( RECVINFO_UTLVECTOR( m_hMyWearables ), MAX_WEARABLES_SENT_FROM_SERVER, RecvPropEHandle(NULL, 0, 0) ),
336338
#endif
@@ -2907,6 +2909,14 @@ void C_BasePlayer::UpdateFogBlend( void )
29072909
}
29082910
}
29092911

2912+
//-----------------------------------------------------------------------------
2913+
//
2914+
//-----------------------------------------------------------------------------
2915+
C_PostProcessController* C_BasePlayer::GetActivePostProcessController() const
2916+
{
2917+
return m_hPostProcessCtrl.Get();
2918+
}
2919+
29102920
//-----------------------------------------------------------------------------
29112921
// Purpose:
29122922
//-----------------------------------------------------------------------------

sp/src/game/client/c_baseplayer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "hintsystem.h"
2424
#include "SoundEmitterSystem/isoundemittersystembase.h"
2525
#include "c_env_fog_controller.h"
26+
#include "c_postprocesscontroller.h"
2627
#include "igameevents.h"
2728
#include "GameEventListener.h"
2829

@@ -37,6 +38,7 @@ class C_BaseViewModel;
3738
class C_FuncLadder;
3839
class CFlashlightEffect;
3940
class C_EconWearable;
41+
class C_PostProcessController;
4042

4143
extern int g_nKillCamMode;
4244
extern int g_nKillCamTarget1;
@@ -379,6 +381,8 @@ class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener
379381
void UpdateFogController( void );
380382
void UpdateFogBlend( void );
381383

384+
C_PostProcessController* GetActivePostProcessController() const;
385+
382386
float GetFOVTime( void ){ return m_flFOVTime; }
383387

384388
virtual void OnAchievementAchieved( int iAchievement ) {}
@@ -641,6 +645,8 @@ class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener
641645
// One for left and one for right side of step
642646
StepSoundCache_t m_StepSoundCache[ 2 ];
643647

648+
CNetworkHandle(C_PostProcessController, m_hPostProcessCtrl); // active postprocessing controller
649+
644650
public:
645651

646652
const char *GetLastKnownPlaceName( void ) const { return m_szLastPlaceName; } // return the last nav place name the player occupied

sp/src/game/client/c_effects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ConVar r_RainSplashPercentage( "r_RainSplashPercentage", "20", FCVAR_CHEAT ); //
4040
ConVar r_RainParticleDensity( "r_RainParticleDensity", "1", FCVAR_NONE, "Density of Particle Rain 0-1" );
4141

4242
#ifdef MAPBASE
43-
ConVar r_RainParticleClampOffset( "r_RainParticleClampOffset", "112", FCVAR_NONE, "How far inward or outward to extrude clamped precipitation particle systemss" );
43+
ConVar r_RainParticleClampOffset( "r_RainParticleClampOffset", "112", FCVAR_NONE, "How far inward or outward to extrude clamped precipitation particle systems" );
4444
ConVar r_RainParticleClampDebug( "r_RainParticleClampDebug", "0", FCVAR_NONE, "Enables debug code for precipitation particle system clamping" );
4545
#endif
4646

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
2+
//
3+
// Purpose: Depth of field controller entity
4+
//
5+
//=============================================================================
6+
7+
#include "cbase.h"
8+
9+
// NOTE: This has to be the last file included!
10+
#include "tier0/memdbgon.h"
11+
12+
13+
extern bool g_bDOFEnabled;
14+
extern float g_flDOFNearBlurDepth;
15+
extern float g_flDOFNearFocusDepth;
16+
extern float g_flDOFFarFocusDepth;
17+
extern float g_flDOFFarBlurDepth;
18+
extern float g_flDOFNearBlurRadius;
19+
extern float g_flDOFFarBlurRadius;
20+
21+
EHANDLE g_hDOFControllerInUse = NULL;
22+
23+
class C_EnvDOFController : public C_BaseEntity
24+
{
25+
DECLARE_CLASS( C_EnvDOFController, C_BaseEntity );
26+
public:
27+
DECLARE_CLIENTCLASS();
28+
29+
C_EnvDOFController();
30+
~C_EnvDOFController();
31+
virtual void OnDataChanged( DataUpdateType_t updateType );
32+
33+
private:
34+
bool m_bDOFEnabled;
35+
float m_flNearBlurDepth;
36+
float m_flNearFocusDepth;
37+
float m_flFarFocusDepth;
38+
float m_flFarBlurDepth;
39+
float m_flNearBlurRadius;
40+
float m_flFarBlurRadius;
41+
42+
private:
43+
C_EnvDOFController( const C_EnvDOFController & );
44+
};
45+
46+
IMPLEMENT_CLIENTCLASS_DT( C_EnvDOFController, DT_EnvDOFController, CEnvDOFController )
47+
RecvPropInt( RECVINFO(m_bDOFEnabled) ),
48+
RecvPropFloat( RECVINFO(m_flNearBlurDepth) ),
49+
RecvPropFloat( RECVINFO(m_flNearFocusDepth) ),
50+
RecvPropFloat( RECVINFO(m_flFarFocusDepth) ),
51+
RecvPropFloat( RECVINFO(m_flFarBlurDepth) ),
52+
RecvPropFloat( RECVINFO(m_flNearBlurRadius) ),
53+
RecvPropFloat( RECVINFO(m_flFarBlurRadius) )
54+
END_RECV_TABLE()
55+
56+
C_EnvDOFController::C_EnvDOFController()
57+
: m_bDOFEnabled( true ),
58+
m_flNearBlurDepth( 20.0f ),
59+
m_flNearFocusDepth( 100.0f ),
60+
m_flFarFocusDepth( 250.0f ),
61+
m_flFarBlurDepth( 1000.0f ),
62+
m_flNearBlurRadius( 0.0f ), // no near blur by default
63+
m_flFarBlurRadius( 5.0f )
64+
{
65+
}
66+
67+
C_EnvDOFController::~C_EnvDOFController()
68+
{
69+
if ( g_hDOFControllerInUse == this )
70+
{
71+
g_bDOFEnabled = false;
72+
}
73+
}
74+
75+
void C_EnvDOFController::OnDataChanged( DataUpdateType_t updateType )
76+
{
77+
BaseClass::OnDataChanged( updateType );
78+
79+
g_bDOFEnabled = m_bDOFEnabled && ( ( m_flNearBlurRadius > 0.0f ) || ( m_flFarBlurRadius > 0.0f ) );
80+
g_flDOFNearBlurDepth = m_flNearBlurDepth;
81+
g_flDOFNearFocusDepth = m_flNearFocusDepth;
82+
g_flDOFFarFocusDepth = m_flFarFocusDepth;
83+
g_flDOFFarBlurDepth = m_flFarBlurDepth;
84+
g_flDOFNearBlurRadius = m_flNearBlurRadius;
85+
g_flDOFFarBlurRadius = m_flFarBlurRadius;
86+
87+
g_hDOFControllerInUse = this;
88+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
2+
//
3+
// Purpose: stores map postprocess params
4+
//
5+
//=============================================================================
6+
#include "cbase.h"
7+
#include "c_postprocesscontroller.h"
8+
9+
// memdbgon must be the last include file in a .cpp file!!!
10+
#include "tier0/memdbgon.h"
11+
12+
IMPLEMENT_CLIENTCLASS_DT( C_PostProcessController, DT_PostProcessController, CPostProcessController )
13+
RecvPropArray3( RECVINFO_NAME( m_PostProcessParameters.m_flParameters[0], m_flPostProcessParameters ), POST_PROCESS_PARAMETER_COUNT, RecvPropFloat( RECVINFO_NAME( m_PostProcessParameters.m_flParameters[0], m_flPostProcessParameters[0] ) ) ),
14+
RecvPropBool( RECVINFO(m_bMaster) )
15+
END_RECV_TABLE()
16+
17+
C_PostProcessController* C_PostProcessController::ms_pMasterController = nullptr;
18+
19+
//-----------------------------------------------------------------------------
20+
C_PostProcessController::C_PostProcessController()
21+
: m_bMaster( false )
22+
{
23+
if ( ms_pMasterController == nullptr)
24+
{
25+
ms_pMasterController = this;
26+
}
27+
}
28+
29+
//-----------------------------------------------------------------------------
30+
C_PostProcessController::~C_PostProcessController()
31+
{
32+
if ( ms_pMasterController == this )
33+
{
34+
ms_pMasterController = nullptr;
35+
}
36+
}
37+
38+
void C_PostProcessController::PostDataUpdate( DataUpdateType_t updateType )
39+
{
40+
BaseClass::PostDataUpdate( updateType );
41+
42+
if ( m_bMaster )
43+
{
44+
ms_pMasterController = this;
45+
}
46+
}
47+
48+
#ifdef MAPBASE
49+
// Prevents parameters from fading after a save/restore
50+
bool g_bPostProcessNeedsRestore = false;
51+
52+
void C_PostProcessController::OnRestore()
53+
{
54+
BaseClass::OnRestore();
55+
56+
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
57+
if ( pPlayer && pPlayer->GetActivePostProcessController() == this )
58+
{
59+
// Tell clientmode this is part of a save/restore
60+
g_bPostProcessNeedsRestore = true;
61+
}
62+
}
63+
#endif
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
#include "postprocess_shared.h"
4+
5+
//=============================================================================
6+
//
7+
// Class Postprocess Controller:
8+
//
9+
class C_PostProcessController : public C_BaseEntity
10+
{
11+
DECLARE_CLASS( C_PostProcessController, C_BaseEntity );
12+
public:
13+
DECLARE_CLIENTCLASS();
14+
15+
C_PostProcessController();
16+
virtual ~C_PostProcessController();
17+
18+
virtual void PostDataUpdate( DataUpdateType_t updateType );
19+
20+
static C_PostProcessController* GetMasterController() { return ms_pMasterController; }
21+
22+
PostProcessParameters_t m_PostProcessParameters;
23+
24+
#ifdef MAPBASE
25+
// Prevents fade time from being used in save/restore
26+
virtual void OnRestore();
27+
#endif
28+
29+
private:
30+
bool m_bMaster;
31+
32+
static C_PostProcessController* ms_pMasterController;
33+
};

sp/src/game/client/client_mapbase.vpc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ $Project
2828
$File "c_gameinstructor.h"
2929
$File "hud_locator_target.cpp"
3030
$File "hud_locator_target.h"
31+
$File "c_postprocesscontroller.cpp"
32+
$File "c_postprocesscontroller.h"
33+
$File "c_env_dof_controller.cpp"
3134

3235
$Folder "Mapbase"
3336
{

sp/src/game/client/clientmode_shared.cpp

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <vgui/ILocalize.h>
3737
#include "hud_vote.h"
3838
#include "ienginevgui.h"
39+
#include "viewpostprocess.h"
3940
#include "sourcevr/isourcevirtualreality.h"
4041
#if defined( _X360 )
4142
#include "xbox/xbox_console.h"
@@ -291,6 +292,9 @@ ClientModeShared::ClientModeShared()
291292
m_pWeaponSelection = NULL;
292293
m_nRootSize[ 0 ] = m_nRootSize[ 1 ] = -1;
293294

295+
m_pCurrentPostProcessController = NULL;
296+
m_PostProcessLerpTimer.Invalidate();
297+
294298
#if defined( REPLAY_ENABLED )
295299
m_pReplayReminderPanel = NULL;
296300
m_flReplayStartRecordTime = 0.0f;
@@ -604,6 +608,8 @@ void ClientModeShared::Update()
604608
m_pViewport->SetVisible( cl_drawhud.GetBool() );
605609
}
606610

611+
UpdatePostProcessingEffects();
612+
607613
UpdateRumbleEffects();
608614

609615
if ( cl_show_num_particle_systems.GetBool() )
@@ -914,6 +920,17 @@ void ClientModeShared::LevelShutdown( void )
914920
s_hVGuiContext = DEFAULT_VGUI_CONTEXT;
915921
}
916922

923+
#ifdef MAPBASE
924+
// Always reset post-processing on level unload
925+
//if (m_pCurrentPostProcessController)
926+
{
927+
m_CurrentPostProcessParameters = PostProcessParameters_t();
928+
m_LerpEndPostProcessParameters = PostProcessParameters_t();
929+
m_pCurrentPostProcessController = NULL;
930+
SetPostProcessParams( &m_CurrentPostProcessParameters );
931+
}
932+
#endif
933+
917934
// Reset any player explosion/shock effects
918935
CLocalPlayerFilter filter;
919936
enginesound->SetPlayerDSP( filter, 0, true );
@@ -988,6 +1005,69 @@ float ClientModeShared::GetViewModelFOV( void )
9881005
return v_viewmodel_fov.GetFloat();
9891006
}
9901007

1008+
#ifdef MAPBASE
1009+
extern bool g_bPostProcessNeedsRestore;
1010+
#endif
1011+
1012+
void ClientModeShared::UpdatePostProcessingEffects()
1013+
{
1014+
C_PostProcessController* pNewPostProcessController = NULL;
1015+
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
1016+
1017+
if (pPlayer)
1018+
pNewPostProcessController = pPlayer->GetActivePostProcessController();
1019+
1020+
if (!pNewPostProcessController)
1021+
{
1022+
m_CurrentPostProcessParameters = PostProcessParameters_t();
1023+
m_pCurrentPostProcessController = NULL;
1024+
SetPostProcessParams( &m_CurrentPostProcessParameters );
1025+
return;
1026+
}
1027+
1028+
if (pNewPostProcessController != m_pCurrentPostProcessController)
1029+
m_pCurrentPostProcessController = pNewPostProcessController;
1030+
1031+
// Start a lerp timer if the parameters changed, regardless of whether the controller changed
1032+
if (m_LerpEndPostProcessParameters != pNewPostProcessController->m_PostProcessParameters)
1033+
{
1034+
m_LerpStartPostProcessParameters = m_CurrentPostProcessParameters;
1035+
m_LerpEndPostProcessParameters = pNewPostProcessController ? pNewPostProcessController->m_PostProcessParameters : m_CurrentPostProcessParameters;
1036+
1037+
float flFadeTime = pNewPostProcessController ? pNewPostProcessController->m_PostProcessParameters.m_flParameters[PPPN_FADE_TIME] : 0.0f;
1038+
if (flFadeTime <= 0.0f)
1039+
{
1040+
flFadeTime = 0.001f;
1041+
}
1042+
1043+
m_PostProcessLerpTimer.Start( flFadeTime );
1044+
}
1045+
#ifdef MAPBASE
1046+
// HACKHACK: Needs to be checked here because OnRestore() doesn't seem to run before a lerp begins
1047+
else if (g_bPostProcessNeedsRestore)
1048+
{
1049+
// The player just loaded a saved game.
1050+
// Don't fade parameters from 0; instead, take what's already there and assume they were already active.
1051+
// (we have no way of knowing if they were in the middle of a lerp)
1052+
m_PostProcessLerpTimer.Invalidate();
1053+
g_bPostProcessNeedsRestore = false;
1054+
}
1055+
#endif
1056+
1057+
// Lerp between old and new parameters
1058+
float flLerpFactor = 1.0f - m_PostProcessLerpTimer.GetRemainingRatio();
1059+
for (int nParameter = 0; nParameter < POST_PROCESS_PARAMETER_COUNT; ++nParameter)
1060+
{
1061+
m_CurrentPostProcessParameters.m_flParameters[nParameter] =
1062+
Lerp(
1063+
flLerpFactor,
1064+
m_LerpStartPostProcessParameters.m_flParameters[nParameter],
1065+
m_LerpEndPostProcessParameters.m_flParameters[nParameter] );
1066+
}
1067+
1068+
SetPostProcessParams( &m_CurrentPostProcessParameters );
1069+
}
1070+
9911071
class CHudChat;
9921072

9931073
bool PlayerNameNotSetYet( const char *pszName )

0 commit comments

Comments
 (0)