Shutdown components

This commit is contained in:
ChillerDragon 2022-01-20 12:19:06 +01:00
parent aaea2636c0
commit e4be3f5241
8 changed files with 25 additions and 3 deletions

View file

@ -158,6 +158,11 @@ public:
* Called to let the components run initialization code.
*/
virtual void OnInit(){};
/**
* Called to cleanup the component.
* This method is called when the client is closed.
*/
virtual void OnShutdown(){};
/**
* Called to reset the component.
* This method is usually called on your component constructor to avoid code duplication.

View file

@ -618,6 +618,11 @@ void CGhost::OnReset()
m_LastRaceTick = -1;
}
void CGhost::OnShutdown()
{
OnReset();
}
void CGhost::OnMapLoad()
{
OnReset();

View file

@ -155,6 +155,7 @@ public:
virtual void OnReset();
virtual void OnMessage(int MsgType, void *pRawMsg);
virtual void OnMapLoad();
virtual void OnShutdown();
void OnNewSnapshot();
void OnNewPredictedSnapshot();

View file

@ -2375,6 +2375,11 @@ void CMenus::OnReset()
{
}
void CMenus::OnShutdown()
{
KillServer();
}
bool CMenus::OnMouseMove(float x, float y)
{
if(!m_MenuActive)

View file

@ -528,6 +528,7 @@ public:
virtual void OnRender();
virtual bool OnInput(IInput::CEvent Event);
virtual bool OnMouseMove(float x, float y);
virtual void OnShutdown();
enum
{

View file

@ -117,6 +117,11 @@ void CRaceDemo::OnReset()
StopRecord();
}
void CRaceDemo::OnShutdown()
{
StopRecord();
}
void CRaceDemo::OnMessage(int MsgType, void *pRawMsg)
{
// check for messages from server

View file

@ -41,6 +41,7 @@ public:
virtual void OnStateChange(int NewState, int OldState);
virtual void OnMessage(int MsgType, void *pRawMsg);
virtual void OnMapLoad();
virtual void OnShutdown();
void OnNewSnapshot();
};

View file

@ -806,9 +806,8 @@ void CGameClient::OnStateChange(int NewState, int OldState)
void CGameClient::OnShutdown()
{
m_Menus.KillServer();
m_RaceDemo.OnReset();
m_Ghost.OnReset();
for(int i = 0; i < m_All.m_Num; i++)
m_All.m_paComponents[i]->OnShutdown();
}
void CGameClient::OnEnterGame()