2023-05-10 00:05:38 +02:00
|
|
|
|
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
2023-01-30 21:22:17 +01:00
|
|
|
|
//
|
|
|
|
|
// Purpose: Defines a group of app systems that all have the same lifetime
|
|
|
|
|
// that need to be connected/initialized, etc. in a well-defined order
|
|
|
|
|
//
|
|
|
|
|
// $Revision: $
|
|
|
|
|
// $NoKeywords: $
|
|
|
|
|
//===========================================================================//
|
|
|
|
|
#include "core/stdafx.h"
|
2023-05-10 00:05:38 +02:00
|
|
|
|
#include "appframework/IAppSystemGroup.h"
|
2023-01-30 21:22:17 +01:00
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Purpose: Initialize plugin system
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2023-04-01 01:27:04 +02:00
|
|
|
|
void CAppSystemGroup::StaticDestroy(CAppSystemGroup* pModAppSystemGroup)
|
2023-01-30 21:22:17 +01:00
|
|
|
|
{
|
|
|
|
|
CAppSystemGroup_Destroy(pModAppSystemGroup);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 01:07:20 +02:00
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Returns the stage at which the app system group ran into an error
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
CAppSystemGroup::AppSystemGroupStage_t CAppSystemGroup::GetCurrentStage() const
|
|
|
|
|
{
|
|
|
|
|
return m_nCurrentStage;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 01:07:01 +02:00
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Methods to find various global singleton systems
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
void* CAppSystemGroup::FindSystem(const char* pSystemName)
|
|
|
|
|
{
|
|
|
|
|
unsigned short i = m_SystemDict.Find(pSystemName);
|
|
|
|
|
if (i != m_SystemDict.InvalidIndex())
|
|
|
|
|
return m_Systems[m_SystemDict[i]];
|
|
|
|
|
|
|
|
|
|
// If it's not an interface we know about, it could be an older
|
|
|
|
|
// version of an interface, or maybe something implemented by
|
|
|
|
|
// one of the instantiated interfaces...
|
|
|
|
|
|
|
|
|
|
// QUESTION: What order should we iterate this in?
|
|
|
|
|
// It controls who wins if multiple ones implement the same interface
|
|
|
|
|
for (i = 0; i < m_Systems.Count(); ++i)
|
|
|
|
|
{
|
|
|
|
|
void* pInterface = m_Systems[i]->QueryInterface(pSystemName);
|
|
|
|
|
if (pInterface)
|
|
|
|
|
return pInterface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int nExternalCount = m_NonAppSystemFactories.Count();
|
|
|
|
|
for (i = 0; i < nExternalCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
void* pInterface = m_NonAppSystemFactories[i](pSystemName, NULL);
|
|
|
|
|
if (pInterface)
|
|
|
|
|
return pInterface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_pParentAppSystem)
|
|
|
|
|
{
|
|
|
|
|
void* pInterface = m_pParentAppSystem->FindSystem(pSystemName);
|
|
|
|
|
if (pInterface)
|
|
|
|
|
return pInterface;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No dice..
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-26 13:21:20 +01:00
|
|
|
|
void VAppSystemGroup::Detour(const bool bAttach) const
|
2023-01-30 21:22:17 +01:00
|
|
|
|
{
|
2023-11-26 13:21:20 +01:00
|
|
|
|
DetourSetup(&CAppSystemGroup_Destroy, &CAppSystemGroup::StaticDestroy, bAttach);
|
2023-01-30 21:22:17 +01:00
|
|
|
|
}
|