mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Let CKernel clean-up. Use unused CSound::Shutdown
This commit is contained in:
parent
fece84c892
commit
f91a3069c3
|
@ -3049,19 +3049,6 @@ void CClient::Run()
|
|||
g_UuidManager.DebugDump();
|
||||
}
|
||||
|
||||
// init SDL
|
||||
{
|
||||
if(SDL_Init(0) < 0)
|
||||
{
|
||||
dbg_msg("client", "unable to init SDL base: %s", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef CONF_PLATFORM_ANDROID
|
||||
atexit(SDL_Quit);
|
||||
#endif
|
||||
}
|
||||
|
||||
// init graphics
|
||||
{
|
||||
m_pGraphics = CreateEngineGraphicsThreaded();
|
||||
|
@ -3492,11 +3479,6 @@ void CClient::Run()
|
|||
m_aNetClient[i].Close();
|
||||
|
||||
delete m_pEditor;
|
||||
m_pInput->Shutdown();
|
||||
m_pGraphics->Shutdown();
|
||||
|
||||
// shutdown SDL
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
bool CClient::CtrlShiftKey(int Key, bool &Last)
|
||||
|
@ -4788,6 +4770,17 @@ int main(int argc, const char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
// init SDL
|
||||
if(SDL_Init(0) < 0)
|
||||
{
|
||||
dbg_msg("client", "unable to init SDL base: %s", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef CONF_PLATFORM_ANDROID
|
||||
atexit(SDL_Quit);
|
||||
#endif
|
||||
|
||||
// run the client
|
||||
dbg_msg("client", "starting...");
|
||||
pClient->Run();
|
||||
|
@ -4806,8 +4799,12 @@ int main(int argc, const char **argv)
|
|||
shell_execute(pStorage->GetBinaryPath(PLAT_CLIENT_EXEC, aBuf, sizeof aBuf));
|
||||
}
|
||||
|
||||
pKernel->Shutdown();
|
||||
delete pKernel;
|
||||
|
||||
// shutdown SDL
|
||||
SDL_Quit();
|
||||
|
||||
#ifdef CONF_PLATFORM_ANDROID
|
||||
// properly close this native thread, so globals are destructed
|
||||
std::exit(0);
|
||||
|
|
|
@ -342,7 +342,7 @@ int CSound::Update()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CSound::Shutdown()
|
||||
void CSound::Shutdown()
|
||||
{
|
||||
for(unsigned SampleID = 0; SampleID < NUM_SAMPLES; SampleID++)
|
||||
{
|
||||
|
@ -353,7 +353,6 @@ int CSound::Shutdown()
|
|||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
free(m_pMixBuffer);
|
||||
m_pMixBuffer = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CSound::AllocID()
|
||||
|
|
|
@ -30,7 +30,7 @@ class CSound : public IEngineSound
|
|||
public:
|
||||
int Init() override;
|
||||
int Update() override;
|
||||
int Shutdown() override;
|
||||
void Shutdown() override;
|
||||
|
||||
bool IsSoundEnabled() override { return m_SoundEnabled; }
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ class IEngineGraphics : public IGraphics
|
|||
MACRO_INTERFACE("enginegraphics", 0)
|
||||
public:
|
||||
virtual int Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual void Shutdown() override = 0;
|
||||
|
||||
virtual void Minimize() = 0;
|
||||
virtual void Maximize() = 0;
|
||||
|
|
|
@ -128,7 +128,7 @@ class IEngineInput : public IInput
|
|||
MACRO_INTERFACE("engineinput", 0)
|
||||
public:
|
||||
virtual void Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual void Shutdown() override = 0;
|
||||
virtual int Update() = 0;
|
||||
virtual int VideoRestartNeeded() = 0;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@ protected:
|
|||
public:
|
||||
IInterface() :
|
||||
m_pKernel(nullptr) {}
|
||||
virtual void Shutdown() {}
|
||||
virtual ~IInterface() {}
|
||||
};
|
||||
|
||||
|
@ -40,6 +41,7 @@ class IKernel
|
|||
|
||||
public:
|
||||
static IKernel *Create();
|
||||
virtual void Shutdown() = 0;
|
||||
virtual ~IKernel() {}
|
||||
|
||||
// templated access to handle pointer conversions and interface names
|
||||
|
|
|
@ -44,6 +44,15 @@ public:
|
|||
m_NumInterfaces = 0;
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
{
|
||||
for(int i = m_NumInterfaces - 1; i >= 0; i--)
|
||||
{
|
||||
if(m_aInterfaces[i].m_AutoDestroy)
|
||||
m_aInterfaces[i].m_pInterface->Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~CKernel()
|
||||
{
|
||||
// delete interfaces in reverse order just the way it would happen to objects on the stack
|
||||
|
|
|
@ -110,7 +110,7 @@ class IEngineSound : public ISound
|
|||
public:
|
||||
virtual int Init() = 0;
|
||||
virtual int Update() = 0;
|
||||
virtual int Shutdown() = 0;
|
||||
virtual void Shutdown() override = 0;
|
||||
};
|
||||
|
||||
extern IEngineSound *CreateEngineSound();
|
||||
|
|
Loading…
Reference in a new issue