Skip to content

Commit 8b7db69

Browse files
hasandramalia1batross
authored andcommitted
client: implement particleman effects and cleanup old rain code
The particleman code was taken from the halflife-featureful repository.
1 parent 0879a46 commit 8b7db69

29 files changed

Lines changed: 3596 additions & 733 deletions

cl_dll/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ file(GLOB CS_INPUT_SRC "input/*.cpp")
1313
file(GLOB CS_PM_SRC "../pm_shared/*.cpp")
1414
file(GLOB CS_GAMSH_SRC "../game_shared/*.cpp")
1515
file(GLOB MINIUTL_SRC "../3rdparty/mainui_cpp/miniutl/*.cpp")
16+
file(GLOB CS_PARTICLEMAN_SRC "particleman/*.cpp")
1617

1718
list(REMOVE_ITEM CS_CLIENT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/ev_hldm.cpp")
1819
list(REMOVE_ITEM CS_INPUT_SRC "${CMAKE_CURRENT_SOURCE_DIR}/input/input_sdl.cpp")
@@ -30,6 +31,7 @@ list(APPEND CS_CLIENT_SRC ${CS_PM_SRC})
3031
list(APPEND CS_CLIENT_SRC ${CS_INPUT_SRC})
3132
list(APPEND CS_CLIENT_SRC ${CS_GAMSH_SRC})
3233
list(APPEND CS_CLIENT_SRC ${MINIUTL_SRC})
34+
list(APPEND CS_CLIENT_SRC ${CS_PARTICLEMAN_SRC})
3335

3436
include_directories(
3537
include
@@ -47,7 +49,8 @@ include_directories(
4749
../3rdparty/mainui_cpp
4850
../3rdparty/mainui_cpp/controls
4951
../3rdparty/mainui_cpp/menus
50-
../3rdparty/mainui_cpp/miniutl)
52+
../3rdparty/mainui_cpp/miniutl
53+
particleman)
5154

5255
add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL -DSTDINT_H=<cstdint>)
5356

cl_dll/cdll_int.cpp

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
//
2020

2121
#include "hud.h"
22-
#include "cl_util.h"
2322
#include "netadr.h"
2423
#include "pmtrace.h"
2524

@@ -31,6 +30,12 @@
3130
#include "mobility_int.h"
3231
#include "vgui_parser.h"
3332
#include "cl_dll/IGameMenuExports.h"
33+
#include "particleman.h"
34+
#include "IParticleMan_Active.h"
35+
#include "CMiniMem.h"
36+
#include "environment.h"
37+
38+
#include "cl_util.h"
3439

3540
cl_enginefunc_t gEngfuncs = { };
3641
render_api_t gRenderAPI = { };
@@ -40,6 +45,7 @@ int g_iXash = 0; // indicates a buildnum
4045
int g_iMobileAPIVersion = 0;
4146

4247
IGameMenuExports *g_pMenu = nullptr;
48+
IParticleMan *g_pParticleMan = NULL;
4349

4450
static IGameMenuExports *GetNativeMenuExports( void )
4551
{
@@ -68,6 +74,8 @@ void InitInput (void);
6874
void Game_HookEvents( void );
6975
void IN_Commands( void );
7076
void Input_Shutdown (void);
77+
void CL_LoadParticleMan();
78+
void CL_UnloadParticleMan();
7179

7280
/*
7381
==========================
@@ -84,11 +92,13 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
8492
gEngfuncs = *pEnginefuncs;
8593

8694
// Register cvar to allow using old touch menus (1 = use old cfg-based menus)
95+
8796
CVAR_CREATE("cl_oldtouchmenus", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE);
8897

8998
sscanf( CVAR_GET_STRING( "host_ver" ), "%d", &g_iXash );
9099

91100
Game_HookEvents();
101+
CL_LoadParticleMan();
92102

93103
return 1;
94104
}
@@ -105,6 +115,17 @@ void DLLEXPORT HUD_Shutdown( void )
105115
gHUD.Shutdown();
106116
Input_Shutdown();
107117
Localize_Free();
118+
g_Environment.Clear();
119+
if (g_pParticleMan)
120+
{
121+
CL_UnloadParticleMan();
122+
}
123+
auto miniMem = CMiniMem::Instance();
124+
if (miniMem)
125+
{
126+
miniMem->Reset();
127+
miniMem->Shutdown();
128+
}
108129
}
109130

110131

@@ -217,7 +238,12 @@ int DLLEXPORT HUD_VidInit( void )
217238

218239
isLoaded = true;
219240

220-
//VGui_Startup();
241+
if (g_pParticleMan)
242+
{
243+
g_pParticleMan->ResetParticles();
244+
g_Environment.Reset();
245+
g_Environment.RestoreWeather();
246+
}
221247

222248
return 1;
223249
}
@@ -468,6 +494,24 @@ extern "C" int DLLEXPORT HUD_GetPlayerTeam(int iplayer)
468494
return 0;
469495
}
470496

497+
void CL_UnloadParticleMan()
498+
{
499+
if (g_pParticleMan)
500+
{
501+
delete g_pParticleMan;
502+
g_pParticleMan = NULL;
503+
}
504+
}
505+
506+
void CL_LoadParticleMan()
507+
{
508+
g_pParticleMan = new IParticleMan_Active();
509+
if (g_pParticleMan)
510+
{
511+
g_pParticleMan->SetUp(&gEngfuncs);
512+
}
513+
}
514+
471515
#include "APIProxy.h"
472516

473517
cldll_func_dst_t *g_pcldstAddrs;

cl_dll/cl_util.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,31 @@ inline bool UseOldTouchMenusEnabled()
129129
inline void PlaySound( const char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
130130
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
131131

132+
#ifdef __cplusplus
133+
#include <type_traits>
134+
#ifndef CL_UTIL_MAX_MIN_DEFINED
135+
#define CL_UTIL_MAX_MIN_DEFINED
136+
#ifdef max
137+
#undef max
138+
#endif
139+
#ifdef min
140+
#undef min
141+
#endif
142+
template<typename T, typename U>
143+
inline auto max(T a, U b) -> typename std::decay<decltype((a > b) ? a : b)>::type { return (a > b) ? a : b; }
144+
template<typename T, typename U>
145+
inline auto min(T a, U b) -> typename std::decay<decltype((a < b) ? a : b)>::type { return (a < b) ? a : b; }
146+
#endif
147+
#else
148+
#ifdef max
149+
#undef max
150+
#endif
132151
#define max(a, b) (((a) > (b)) ? (a) : (b))
152+
#ifdef min
153+
#undef min
154+
#endif
133155
#define min(a, b) (((a) < (b)) ? (a) : (b))
156+
#endif
134157
#if !defined(__APPLE__) && !defined(_WIN32)
135158
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))
136159
#endif

cl_dll/entity.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "eventscripts.h"
2525
#include "com_weapons.h"
2626
#include "ev_hldm.h"
27+
#include "particleman.h"
28+
#include "particleman_internal.h"
2729

2830
extern vec3_t v_origin;
2931

@@ -397,12 +399,13 @@ void DLLEXPORT HUD_TempEntUpdate (
397399
TEMPENTITY *pTemp, *pnext, *pprev;
398400
float gravity, gravitySlow, life, fastFreq;
399401

400-
// g_flGravity = cl_gravity;
402+
g_flGravity = cl_gravity;
403+
404+
Vector vAngles;
405+
gEngfuncs.GetViewAngles( (float*)vAngles );
401406

402-
/*
403407
if ( g_pParticleMan )
404408
g_pParticleMan->SetVariables( cl_gravity, vAngles );
405-
*/
406409

407410
// Nothing to simulate
408411
if ( !*ppTempEntActive )

0 commit comments

Comments
 (0)