Browse Source

Shutdown code de-duplication

Adam Johnson 11 years ago
parent
commit
dc9497cf90
  1. 70
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 2
      Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp
  3. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

70
Sources/Plasma/Apps/plClient/plClient.cpp

@ -251,6 +251,15 @@ plClient::~plClient()
#include "plGImage/plAVIWriter.h" #include "plGImage/plAVIWriter.h"
#include "pfCharacter/pfMarkerMgr.h" #include "pfCharacter/pfMarkerMgr.h"
template<typename T>
static void IUnRegisterAs(T*& ko, plFixedKeyId id)
{
if (ko) {
ko->UnRegisterAs(id);
ko = nullptr;
}
}
bool plClient::Shutdown() bool plClient::Shutdown()
{ {
plSynchEnabler ps(false); // disable dirty state tracking during shutdown plSynchEnabler ps(false); // disable dirty state tracking during shutdown
@ -296,31 +305,13 @@ bool plClient::Shutdown()
// Take down our GUI control generator // Take down our GUI control generator
pfGUICtrlGenerator::Instance().Shutdown(); pfGUICtrlGenerator::Instance().Shutdown();
if (plNetClientMgr::GetInstance()) if (plNetClientMgr* nc = plNetClientMgr::GetInstance())
{ nc->Shutdown();
plNetClientMgr::GetInstance()->Shutdown(); if (plAgeLoader* al = plAgeLoader::GetInstance())
plNetClientMgr::GetInstance()->UnRegisterAs(kNetClientMgr_KEY); // deletes NetClientMgr instance al->Shutdown();
plNetClientMgr::SetInstance(nil);
}
if (plAgeLoader::GetInstance())
{
plAgeLoader::GetInstance()->Shutdown();
plAgeLoader::GetInstance()->UnRegisterAs(kAgeLoader_KEY); // deletes instance
plAgeLoader::SetInstance(nil);
}
if (fInputManager)
{
fInputManager->UnRegisterAs(kInput_KEY);
fInputManager = nil;
}
if( fGameGUIMgr != nil ) IUnRegisterAs(fInputManager, kInput_KEY);
{ IUnRegisterAs(fGameGUIMgr, kGameGUIMgr_KEY);
fGameGUIMgr->UnRegisterAs( kGameGUIMgr_KEY );
fGameGUIMgr = nil;
}
for (int i = 0; i < fRooms.Count(); i++) for (int i = 0; i < fRooms.Count(); i++)
{ {
@ -345,46 +336,26 @@ bool plClient::Shutdown()
if (fPageMgr) if (fPageMgr)
fPageMgr->Reset(); fPageMgr->Reset();
if( fTransitionMgr != nil ) IUnRegisterAs(fTransitionMgr, kTransitionMgr_KEY);
{
fTransitionMgr->UnRegisterAs( kTransitionMgr_KEY );
fTransitionMgr = nil;
}
delete fConsoleEngine; delete fConsoleEngine;
fConsoleEngine = nil; fConsoleEngine = nil;
if (fLinkEffectsMgr) IUnRegisterAs(fLinkEffectsMgr, kLinkEffectsMgr_KEY);
{
fLinkEffectsMgr->UnRegisterAs( kLinkEffectsMgr_KEY);
fLinkEffectsMgr=nil;
}
plClothingMgr::DeInit(); plClothingMgr::DeInit();
if( fFontCache != nil ) IUnRegisterAs(fFontCache, kFontCache_KEY);
{
fFontCache->UnRegisterAs( kFontCache_KEY );
fFontCache = nil;
}
pfMarkerMgr::Shutdown(); pfMarkerMgr::Shutdown();
delete fAnimDebugList; delete fAnimDebugList;
//#ifndef PLASMA_EXTERNAL_RELEASE IUnRegisterAs(fConsole, kConsoleObject_KEY);
if( fConsole != nil )
{
// UnRegisterAs destroys the object for us
fConsole->UnRegisterAs( kConsoleObject_KEY );
fConsole = nil;
}
//#endif
PythonInterface::finiPython(); PythonInterface::finiPython();
if (fNewCamera) IUnRegisterAs(fNewCamera, kVirtualCamera1_KEY);
fNewCamera->UnRegisterAs( kVirtualCamera1_KEY );
// mark the listener for death. // mark the listener for death.
// there's no need to keep this around... // there's no need to keep this around...
@ -417,7 +388,6 @@ bool plClient::Shutdown()
// This will destruct the client. Do it last. // This will destruct the client. Do it last.
UnRegisterAs(kClient_KEY); UnRegisterAs(kClient_KEY);
return false; return false;
} }

2
Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp

@ -110,6 +110,8 @@ plAgeLoader::~plAgeLoader()
void plAgeLoader::Shutdown() void plAgeLoader::Shutdown()
{ {
plResPatcher::GetInstance()->Shutdown(); plResPatcher::GetInstance()->Shutdown();
UnRegisterAs(kAgeLoader_KEY);
SetInstance(nullptr);
} }
void plAgeLoader::Init() void plAgeLoader::Init()

4
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

@ -199,6 +199,10 @@ void plNetClientMgr::Shutdown()
IRemoveCloneRoom(); IRemoveCloneRoom();
VaultDestroy(); VaultDestroy();
// commit hara-kiri
UnRegisterAs(kNetClientMgr_KEY);
SetInstance(nullptr);
} }
// //

Loading…
Cancel
Save