1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-20 04:26:03 +08:00

Update IGameSystem message structs & add more comments

This commit is contained in:
GAMMACASE
2023-12-24 00:17:31 +03:00
parent fe3adce23a
commit 31c4dfa372
2 changed files with 283 additions and 110 deletions

View File

@ -11,36 +11,202 @@
#pragma once #pragma once
#endif #endif
struct EventGameInit_t; #include "iloopmode.h"
struct EventGameShutdown_t;
struct EventGamePostInit_t; /*
struct EventGamePreShutdown_t; * AMNOTE: To create your own gamesystem, you need to inherit from CBaseGameSystem or CAutoGameSystem,
struct EventBuildGameSessionManifest_t; * and define the events that you are interested in receiving via the GS_EVENT macro, example:
struct EventGameActivate_t; *
struct EventClientFullySignedOn_t; * class TestGameSystem : CBaseGameSystem
struct EventDisconnect_t; * {
struct EventGameDeactivate_t; * GS_EVENT( GameInit )
struct EventSpawnGroupPrecache_t; * {
struct EventSpawnGroupUncache_t; * // In every event there's a ``msg`` argument provided which is a struct for this particular event
struct EventPreSpawnGroupLoad_t; * // refer to struct implementation to see what members are available in it, example usage:
struct EventPostSpawnGroupLoad_t; * msg->m_pConfig;
struct EventPreSpawnGroupUnload_t; * msg->m_pRegistry;
struct EventPostSpawnGroupUnload_t; * }
struct EventActiveSpawnGroupChanged_t; *
struct EventClientPostDataUpdate_t; * // Or you can declare the needed events in your gamesystem, and define their body somewhere else
struct EventClientPreRender_t; * GS_EVENT( GameShutdown );
struct EventClientPreEntityThink_t; * };
struct EventClientUpdate_t; *
struct EventClientPostRender_t; * GS_EVENT_MEMBER( TestGameSystem, GameShutdown )
struct EventServerPreEntityThink_t; * {
struct EventServerPostEntityThink_t; * // The same ``msg`` argument would be available in here as well.
struct EventServerPreClientUpdate_t; * }
struct EventServerGamePostSimulate_t; */
struct EventClientGamePostSimulate_t;
struct EventGameFrameBoundary_t; // Forward declaration
struct EventOutOfGameFrameBoundary_t; class GameSessionConfiguration_t;
struct EventSaveGame_t; class ILoopModePrerequisiteRegistry;
struct EventRestoreGame_t; class IEntityResourceManifest;
class EngineLoopState_t;
class ISpawnGroupPrerequisiteRegistry;
class IEntityPrecacheConfiguration;
class EntitySpawnInfo_t;
#define GS_EVENT_MSG( name ) struct Event##name##_t
#define GS_EVENT_MSG_CHILD( name, parent ) struct Event##name##_t : Event##parent##_t
GS_EVENT_MSG( GameInit )
{
const GameSessionConfiguration_t *m_pConfig;
ILoopModePrerequisiteRegistry *m_pRegistry;
};
GS_EVENT_MSG( GamePostInit )
{
const GameSessionConfiguration_t *m_pConfig;
ILoopModePrerequisiteRegistry *m_pRegistry;
};
GS_EVENT_MSG( GameShutdown );
GS_EVENT_MSG( GamePreShutdown );
GS_EVENT_MSG( GameActivate )
{
const EngineLoopState_t *m_pState;
bool m_bBackgroundMap;
};
GS_EVENT_MSG( GameDeactivate )
{
const EngineLoopState_t *m_pState;
bool m_bBackgroundMap;
};
GS_EVENT_MSG( ClientFullySignedOn );
GS_EVENT_MSG( Disconnect );
GS_EVENT_MSG( BuildGameSessionManifest )
{
IEntityResourceManifest *m_pResourceManifest;
};
GS_EVENT_MSG( SpawnGroupPrecache )
{
CUtlString m_SpawnGroupName;
CUtlString m_EntityLumpName;
SpawnGroupHandle_t m_SpawnGroupHandle;
int m_nEntityCount;
const EntitySpawnInfo_t *m_pEntitiesToSpawn;
ISpawnGroupPrerequisiteRegistry *m_pRegistry;
IEntityResourceManifest *m_pManifest;
IEntityPrecacheConfiguration *m_pConfig;
};
GS_EVENT_MSG( SpawnGroupUncache )
{
CUtlString m_SpawnGroupName;
CUtlString m_EntityLumpName;
SpawnGroupHandle_t m_SpawnGroupHandle;
};
GS_EVENT_MSG( PreSpawnGroupLoad )
{
CUtlString m_SpawnGroupName;
CUtlString m_EntityLumpName;
SpawnGroupHandle_t m_SpawnGroupHandle;
};
GS_EVENT_MSG( PostSpawnGroupLoad )
{
CUtlString m_SpawnGroupName;
CUtlString m_EntityLumpName;
SpawnGroupHandle_t m_SpawnGroupHandle;
CUtlVector<CEntityHandle> m_EntityList;
};
GS_EVENT_MSG( PreSpawnGroupUnload )
{
CUtlString m_SpawnGroupName;
CUtlString m_EntityLumpName;
SpawnGroupHandle_t m_SpawnGroupHandle;
CUtlVector<CEntityHandle> m_EntityList;
};
GS_EVENT_MSG( PostSpawnGroupUnload )
{
CUtlString m_SpawnGroupName;
CUtlString m_EntityLumpName;
SpawnGroupHandle_t m_SpawnGroupHandle;
};
GS_EVENT_MSG( ActiveSpawnGroupChanged )
{
SpawnGroupHandle_t m_SpawnGroupHandle;
CUtlString m_SpawnGroupName;
SpawnGroupHandle_t m_PreviousHandle;
};
GS_EVENT_MSG( ClientPostDataUpdate );
GS_EVENT_MSG( ClientPreRender )
{
float m_flFrameTime;
};
GS_EVENT_MSG( ClientPostRender );
GS_EVENT_MSG( ClientPreEntityThink )
{
bool m_bFirstTick;
bool m_bLastTick;
};
GS_EVENT_MSG( ClientUpdate )
{
float m_flFrameTime;
bool m_bFirstTick;
bool m_bLastTick;
};
GS_EVENT_MSG( ServerPreEntityThink )
{
bool m_bFirstTick;
bool m_bLastTick;
};
GS_EVENT_MSG( ServerPostEntityThink )
{
bool m_bFirstTick;
bool m_bLastTick;
};
GS_EVENT_MSG( ServerPreClientUpdate );
GS_EVENT_MSG( Simulate )
{
EngineLoopState_t m_LoopState;
bool m_bFirstTick;
bool m_bLastTick;
};
GS_EVENT_MSG_CHILD( ServerGamePostSimulate, Simulate ) { };
GS_EVENT_MSG_CHILD( ClientGamePostSimulate, Simulate ) { };
GS_EVENT_MSG( FrameBoundary )
{
float m_flFrameTime;
};
GS_EVENT_MSG_CHILD( GameFrameBoundary, FrameBoundary ) { };
GS_EVENT_MSG_CHILD( OutOfGameFrameBoundary, FrameBoundary ) { };
GS_EVENT_MSG( SaveGame )
{
const CUtlVector<CEntityHandle> *m_pEntityList;
};
GS_EVENT_MSG( RestoreGame )
{
const CUtlVector<CEntityHandle> *m_pEntityList;
};
#define GS_EVENT_IMPL( name ) virtual void name(const Event##name##_t* const msg) = 0;
#define GS_EVENT( name ) virtual void name(const Event##name##_t* const msg) override
#define GS_EVENT_MEMBER( gamesystem, name ) void gamesystem::name(const Event##name##_t* const msg)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Game systems are singleton objects in the client + server codebase responsible for // Game systems are singleton objects in the client + server codebase responsible for
@ -59,68 +225,68 @@ public:
virtual void Shutdown() = 0; virtual void Shutdown() = 0;
// Game init, shutdown // Game init, shutdown
virtual void GameInit(const EventGameInit_t* const msg) = 0; GS_EVENT_IMPL( GameInit );
virtual void GameShutdown(const EventGameShutdown_t* const msg) = 0; GS_EVENT_IMPL( GameShutdown );
virtual void GamePostInit(const EventGamePostInit_t* const msg) = 0; GS_EVENT_IMPL( GamePostInit );
virtual void GamePreShutdown(const EventGamePreShutdown_t* const msg) = 0; GS_EVENT_IMPL( GamePreShutdown );
virtual void BuildGameSessionManifest(const EventBuildGameSessionManifest_t* const msg) = 0; GS_EVENT_IMPL( BuildGameSessionManifest );
virtual void GameActivate(const EventGameActivate_t* const msg) = 0; GS_EVENT_IMPL( GameActivate );
virtual void ClientFullySignedOn(const EventClientFullySignedOn_t* const msg) = 0; GS_EVENT_IMPL( ClientFullySignedOn );
virtual void ClientDisconnect(const EventDisconnect_t* const msg) = 0; GS_EVENT_IMPL( Disconnect );
virtual void GameDeactivate(const EventGameDeactivate_t* const msg) = 0; GS_EVENT_IMPL( GameDeactivate );
virtual void SpawnGroupPrecache(const EventSpawnGroupPrecache_t* const msg) = 0; GS_EVENT_IMPL( SpawnGroupPrecache );
virtual void SpawnGroupUncache(const EventSpawnGroupUncache_t* const msg) = 0; GS_EVENT_IMPL( SpawnGroupUncache );
virtual void PreSpawnGroupLoad(const EventPreSpawnGroupLoad_t* const msg) = 0; GS_EVENT_IMPL( PreSpawnGroupLoad );
virtual void PostSpawnGroupLoad(const EventPostSpawnGroupLoad_t* const msg) = 0; GS_EVENT_IMPL( PostSpawnGroupLoad );
virtual void PreSpawnGroupUnload(const EventPreSpawnGroupUnload_t* const msg) = 0; GS_EVENT_IMPL( PreSpawnGroupUnload );
virtual void PostSpawnGroupUnload(const EventPostSpawnGroupUnload_t* const msg) = 0; GS_EVENT_IMPL( PostSpawnGroupUnload );
virtual void ActiveSpawnGroupChanged(const EventActiveSpawnGroupChanged_t* const msg) = 0; GS_EVENT_IMPL( ActiveSpawnGroupChanged );
virtual void PostDataUpdate(EventClientPostDataUpdate_t* const msg) = 0; GS_EVENT_IMPL( ClientPostDataUpdate );
// Called before rendering // Called before rendering
virtual void PreRender(const EventClientPreRender_t* const msg) = 0; GS_EVENT_IMPL( ClientPreRender );
virtual void ClientPreEntityThink(const EventClientPreEntityThink_t* const msg) = 0; GS_EVENT_IMPL( ClientPreEntityThink );
virtual void unk_1271(const void* const msg) = 0; virtual void unk_1271( const void *const msg ) = 0;
// Gets called each frame // Gets called each frame
virtual void Update(const EventClientUpdate_t* const msg) = 0; GS_EVENT_IMPL( ClientUpdate );
// Called after rendering // Called after rendering
virtual void PostRender(const EventClientPostRender_t* const msg) = 0; GS_EVENT_IMPL( ClientPostRender );
// Called each frame before entities think // Called each frame before entities think
virtual void FrameUpdatePreEntityThink(const EventServerPreEntityThink_t* const msg) = 0; GS_EVENT_IMPL( ServerPreEntityThink );
// called after entities think // called after entities think
virtual void FrameUpdatePostEntityThink(const EventServerPostEntityThink_t* const msg) = 0; GS_EVENT_IMPL( ServerPostEntityThink );
virtual void PreClientUpdate(const EventServerPreClientUpdate_t* const msg) = 0; GS_EVENT_IMPL( ServerPreClientUpdate );
virtual void unk_1277(const void* const msg) = 0; virtual void unk_1277( const void *const msg ) = 0;
virtual void unk_1278(const void* const msg) = 0; virtual void unk_1278( const void *const msg ) = 0;
virtual void OnServerGamePostSimulate(const EventServerGamePostSimulate_t* const msg) = 0; GS_EVENT_IMPL( ServerGamePostSimulate );
virtual void OnClientGamePostSimulate(const EventClientGamePostSimulate_t* const msg) = 0; GS_EVENT_IMPL( ClientGamePostSimulate );
virtual void unk_1281(const void* const msg) = 0; virtual void unk_1281( const void *const msg ) = 0;
virtual void FrameBoundary(const EventGameFrameBoundary_t* const msg) = 0; GS_EVENT_IMPL( GameFrameBoundary );
virtual void OutOfGameFrameBoundary(const EventOutOfGameFrameBoundary_t* const msg) = 0; GS_EVENT_IMPL( OutOfGameFrameBoundary );
virtual void SaveGame(const EventSaveGame_t* const msg) = 0; GS_EVENT_IMPL( SaveGame );
virtual void RestoreGame(const EventRestoreGame_t* const msg) = 0; GS_EVENT_IMPL( RestoreGame );
virtual void unk_1285(const void* const msg) = 0; virtual void unk_1285( const void *const msg ) = 0;
virtual void unk_1286(const void* const msg) = 0; virtual void unk_1286( const void *const msg ) = 0;
virtual void unk_1287(const void* const msg) = 0; virtual void unk_1287( const void *const msg ) = 0;
virtual void unk_1288(const void* const msg) = 0; virtual void unk_1288( const void *const msg ) = 0;
virtual void unk_1289(const void* const msg) = 0; virtual void unk_1289( const void *const msg ) = 0;
virtual const char* GetName() = 0; virtual const char* GetName() = 0;
virtual void SetGameSystemGlobalPtrs(void* pValue) = 0; virtual void SetGameSystemGlobalPtrs(void* pValue) = 0;
@ -146,68 +312,68 @@ public:
virtual void Shutdown() {} virtual void Shutdown() {}
// Game init, shutdown // Game init, shutdown
virtual void GameInit(const EventGameInit_t* const msg) {} GS_EVENT( GameInit ) {}
virtual void GameShutdown(const EventGameShutdown_t* const msg) {} GS_EVENT( GameShutdown ) {}
virtual void GamePostInit(const EventGamePostInit_t* const msg) {} GS_EVENT( GamePostInit ) {}
virtual void GamePreShutdown(const EventGamePreShutdown_t* const msg) {} GS_EVENT( GamePreShutdown ) {}
virtual void BuildGameSessionManifest(const EventBuildGameSessionManifest_t* const msg) {} GS_EVENT( BuildGameSessionManifest ) {}
virtual void GameActivate(const EventGameActivate_t* const msg) {} GS_EVENT( GameActivate ) {}
virtual void ClientFullySignedOn(const EventClientFullySignedOn_t* const msg) {} GS_EVENT( ClientFullySignedOn ) {}
virtual void ClientDisconnect(const EventDisconnect_t* const msg) {} GS_EVENT( Disconnect ) {}
virtual void GameDeactivate(const EventGameDeactivate_t* const msg) {} GS_EVENT( GameDeactivate ) {}
virtual void SpawnGroupPrecache(const EventSpawnGroupPrecache_t* const msg) {} GS_EVENT( SpawnGroupPrecache ) {}
virtual void SpawnGroupUncache(const EventSpawnGroupUncache_t* const msg) {} GS_EVENT( SpawnGroupUncache ) {}
virtual void PreSpawnGroupLoad(const EventPreSpawnGroupLoad_t* const msg) {} GS_EVENT( PreSpawnGroupLoad ) {}
virtual void PostSpawnGroupLoad(const EventPostSpawnGroupLoad_t* const msg) {} GS_EVENT( PostSpawnGroupLoad ) {}
virtual void PreSpawnGroupUnload(const EventPreSpawnGroupUnload_t* const msg) {} GS_EVENT( PreSpawnGroupUnload ) {}
virtual void PostSpawnGroupUnload(const EventPostSpawnGroupUnload_t* const msg) {} GS_EVENT( PostSpawnGroupUnload ) {}
virtual void ActiveSpawnGroupChanged(const EventActiveSpawnGroupChanged_t* const msg) {} GS_EVENT( ActiveSpawnGroupChanged ) {}
virtual void PostDataUpdate(EventClientPostDataUpdate_t* const msg) {} GS_EVENT( ClientPostDataUpdate ) {}
// Called before rendering // Called before rendering
virtual void PreRender(const EventClientPreRender_t* const msg) {} GS_EVENT( ClientPreRender ) {}
virtual void ClientPreEntityThink(const EventClientPreEntityThink_t* const msg) {} GS_EVENT( ClientPreEntityThink ) {}
virtual void unk_1271(const void* const msg) {} virtual void unk_1271( const void *const msg ) {}
// Gets called each frame // Gets called each frame
virtual void Update(const EventClientUpdate_t* const msg) {} GS_EVENT( ClientUpdate ) {}
// Called after rendering // Called after rendering
virtual void PostRender(const EventClientPostRender_t* const msg) {} GS_EVENT( ClientPostRender ) {}
// Called each frame before entities think // Called each frame before entities think
virtual void FrameUpdatePreEntityThink(const EventServerPreEntityThink_t* const msg) {} GS_EVENT( ServerPreEntityThink ) {}
// called after entities think // called after entities think
virtual void FrameUpdatePostEntityThink(const EventServerPostEntityThink_t* const msg) {} GS_EVENT( ServerPostEntityThink ) {}
virtual void PreClientUpdate(const EventServerPreClientUpdate_t* const msg) {} GS_EVENT( ServerPreClientUpdate ) {}
virtual void unk_1277(const void* const msg) {} virtual void unk_1277( const void *const msg ) {}
virtual void unk_1278(const void* const msg) {} virtual void unk_1278( const void *const msg ) {}
virtual void OnServerGamePostSimulate(const EventServerGamePostSimulate_t* const msg) {} GS_EVENT( ServerGamePostSimulate ) {}
virtual void OnClientGamePostSimulate(const EventClientGamePostSimulate_t* const msg) {} GS_EVENT( ClientGamePostSimulate ) {}
virtual void unk_1281(const void* const msg) {} virtual void unk_1281( const void *const msg ) {}
virtual void FrameBoundary(const EventGameFrameBoundary_t* const msg) {} GS_EVENT( GameFrameBoundary ) {}
virtual void OutOfGameFrameBoundary(const EventOutOfGameFrameBoundary_t* const msg) {} GS_EVENT( OutOfGameFrameBoundary ) {}
virtual void SaveGame(const EventSaveGame_t* const msg) {} GS_EVENT( SaveGame ) {}
virtual void RestoreGame(const EventRestoreGame_t* const msg) {} GS_EVENT( RestoreGame ) {}
virtual void unk_1285(const void* const msg) {} virtual void unk_1285( const void *const msg ) {}
virtual void unk_1286(const void* const msg) {} virtual void unk_1286( const void *const msg ) {}
virtual void unk_1287(const void* const msg) {} virtual void unk_1287( const void *const msg ) {}
virtual void unk_1288(const void* const msg) {} virtual void unk_1288( const void *const msg ) {}
virtual void unk_1289(const void* const msg) {} virtual void unk_1289( const void *const msg ) {}
virtual const char* GetName() { return m_pName; } virtual const char* GetName() { return m_pName; }
virtual void SetGameSystemGlobalPtrs(void* pValue) {} virtual void SetGameSystemGlobalPtrs(void* pValue) {}

View File

@ -18,11 +18,18 @@
* AMNOTE: To register your own game system, CGameSystemStaticFactory could be used to register it, * AMNOTE: To register your own game system, CGameSystemStaticFactory could be used to register it,
* but since the actual factory lives inside the game originally and we don't have direct access to it * but since the actual factory lives inside the game originally and we don't have direct access to it
* you need provide the CBaseGameSystemFactory::sm_pFirst by whatever means are possible to you. * you need provide the CBaseGameSystemFactory::sm_pFirst by whatever means are possible to you.
* As a starting point you can look for "Game System %s is defined twice" string in the server binary
* to find it, if that string is missing then this comment is out of date, please, report or update it!
* *
* Once CBaseGameSystemFactory::sm_pFirst is initialized and correct address provided, * Once CBaseGameSystemFactory::sm_pFirst is initialized and correct address provided,
* you can create your own gamesystem (refer to igamesystem.h on what it should be like) and register it * you can create your own gamesystem (refer to igamesystem.h on what it should be like) and register it
* via ``new CGameSystemStaticFactory<YourGameSystemClass>( "YourGameSystemName", &PointerToYourGameSystemInstance )`` * via:
* the new factory object would be created and if all is done correctly your game system should be viewable to the game *
* // Factory object would be returned, and you are responsible for freeing it inside the ``Shutdown`` method of ``YourGameSystemClass``
* // common way to do that would be to store the factory as a static member in ``YourGameSystemClass`` and free it when ``Shutdown`` is called.
* IGameSystemFactory factory = new CGameSystemStaticFactory<YourGameSystemClass>( "YourGameSystemName", &PointerToYourGameSystemInstance );
*
* after the new factory object has been created and if all is done correctly your game system should be viewable to the game
* and its callbacks should trigger. * and its callbacks should trigger.
*/ */