2023-01-30 21:22:17 +01:00
|
|
|
#ifndef APPSYSTEMGROUP_H
|
|
|
|
#define APPSYSTEMGROUP_H
|
|
|
|
|
2023-05-15 14:47:03 +02:00
|
|
|
#include "tier1/interface.h"
|
2023-04-01 01:07:20 +02:00
|
|
|
#include "tier1/utlvector.h"
|
2023-08-22 01:07:01 +02:00
|
|
|
#include "tier1/utldict.h"
|
2023-04-01 01:07:20 +02:00
|
|
|
#include "filesystem/filesystem.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// NOTE: The following methods must be implemented in your application
|
|
|
|
// although they can be empty implementations if you like...
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
abstract_class IAppSystemGroup
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IAppSystemGroup() {}
|
|
|
|
|
|
|
|
// An installed application creation function, you should tell the group
|
|
|
|
// the DLLs and the singleton interfaces you want to instantiate.
|
|
|
|
// Return false if there's any problems and the app will abort
|
|
|
|
virtual bool Create() = 0;
|
|
|
|
|
|
|
|
// Allow the application to do some work after AppSystems are connected but
|
|
|
|
// they are all Initialized.
|
|
|
|
// Return false if there's any problems and the app will abort
|
|
|
|
virtual bool PreInit() = 0;
|
|
|
|
|
|
|
|
// Allow the application to do some work after AppSystems are initialized but
|
|
|
|
// before main is run
|
|
|
|
// Return false if there's any problems and the app will abort
|
|
|
|
virtual bool PostInit() = 0;
|
|
|
|
|
|
|
|
// Main loop implemented by the application
|
|
|
|
virtual int Main() = 0;
|
|
|
|
|
|
|
|
// Allow the application to do some work after all AppSystems are shut down
|
|
|
|
virtual void PreShutdown() = 0;
|
|
|
|
|
|
|
|
// Allow the application to do some work after all AppSystems are shut down
|
|
|
|
virtual void PostShutdown() = 0;
|
|
|
|
|
|
|
|
// Call an installed application destroy function, occurring after all modules
|
|
|
|
// are unloaded
|
|
|
|
virtual void Destroy() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// This class represents a group of app systems that all have the same lifetime
|
|
|
|
// that need to be connected/initialized, etc. in a well-defined order
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class CAppSystemGroup : public IAppSystemGroup
|
2023-01-30 21:22:17 +01:00
|
|
|
{
|
|
|
|
public:
|
2023-04-01 01:07:20 +02:00
|
|
|
// Used to determine where we exited out from the system
|
|
|
|
enum AppSystemGroupStage_t
|
|
|
|
{
|
|
|
|
CREATION = 0,
|
|
|
|
DEPENDENCIES,
|
|
|
|
CONNECTION,
|
|
|
|
PREINITIALIZATION,
|
|
|
|
INITIALIZATION,
|
|
|
|
POSTINITIALIZATION,
|
|
|
|
RUNNING,
|
|
|
|
PRESHUTDOWN,
|
|
|
|
SHUTDOWN,
|
|
|
|
POSTSHUTDOWN,
|
|
|
|
DISCONNECTION,
|
|
|
|
DESTRUCTION,
|
|
|
|
|
|
|
|
APPSYSTEM_GROUP_STAGE_COUNT,
|
|
|
|
NONE, // This means no error
|
|
|
|
};
|
|
|
|
|
|
|
|
// Detour statics.
|
2023-04-01 01:27:04 +02:00
|
|
|
static void StaticDestroy(CAppSystemGroup* pAppSystemGroup);
|
2023-04-01 01:07:20 +02:00
|
|
|
|
|
|
|
// Returns the stage at which the app system group ran into an error
|
|
|
|
AppSystemGroupStage_t GetCurrentStage() const;
|
|
|
|
|
2023-08-22 01:07:01 +02:00
|
|
|
// Method to look up a particular named system...
|
|
|
|
void* FindSystem(const char* pInterfaceName);
|
|
|
|
|
2023-04-01 01:07:20 +02:00
|
|
|
private:
|
|
|
|
struct Module_t
|
|
|
|
{
|
2023-08-22 01:07:01 +02:00
|
|
|
CSysModule* m_pModule;
|
2023-04-01 01:07:20 +02:00
|
|
|
CreateInterfaceFn m_Factory;
|
|
|
|
char* m_pModuleName;
|
|
|
|
};
|
2023-01-30 21:22:17 +01:00
|
|
|
|
|
|
|
protected:
|
2023-04-01 01:07:20 +02:00
|
|
|
CUtlVector<Module_t> m_Modules;
|
|
|
|
CUtlVector<IAppSystem*> m_Systems;
|
|
|
|
CUtlVector<CreateInterfaceFn> m_NonAppSystemFactories;
|
2023-08-22 01:07:01 +02:00
|
|
|
CUtlDict<int, unsigned short> m_SystemDict;
|
|
|
|
CAppSystemGroup* m_pParentAppSystem;
|
2023-04-01 01:07:20 +02:00
|
|
|
AppSystemGroupStage_t m_nCurrentStage;
|
2023-01-30 21:22:17 +01:00
|
|
|
};
|
2023-04-01 01:27:04 +02:00
|
|
|
static_assert(sizeof(CAppSystemGroup) == 0xA8);
|
2023-01-30 21:22:17 +01:00
|
|
|
|
2024-01-02 15:21:36 +01:00
|
|
|
inline void(*CAppSystemGroup__Destroy)(CAppSystemGroup* pAppSystemGroup);
|
2023-01-30 21:22:17 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
class VAppSystemGroup : public IDetour
|
|
|
|
{
|
|
|
|
virtual void GetAdr(void) const
|
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
LogFunAdr("CAppSystemGroup::Destroy", CAppSystemGroup__Destroy);
|
2023-01-30 21:22:17 +01:00
|
|
|
}
|
|
|
|
virtual void GetFun(void) const
|
|
|
|
{
|
2024-01-02 15:21:36 +01:00
|
|
|
g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 8B 81 ?? ?? ?? ?? 48 8B F9").GetPtr(CAppSystemGroup__Destroy);
|
2023-01-30 21:22:17 +01:00
|
|
|
}
|
|
|
|
virtual void GetVar(void) const { }
|
|
|
|
virtual void GetCon(void) const { }
|
2023-11-26 13:21:20 +01:00
|
|
|
virtual void Detour(const bool bAttach) const;
|
2023-01-30 21:22:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // APPSYSTEMGROUP_H
|