From d9ce7203871cea0046144bce175df5bf1d7fcc19 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 27 Feb 2011 15:03:57 +0100 Subject: made engine an interface --- src/engine/client/client.cpp | 56 +++++++++++++++++++++++------------------ src/engine/client/client.h | 47 +++++++++------------------------- src/engine/client/graphics.cpp | 3 +-- src/engine/client/sound.cpp | 2 ++ src/engine/client/sound.h | 3 --- src/engine/client/srvbrowse.cpp | 1 - 6 files changed, 47 insertions(+), 65 deletions(-) (limited to 'src/engine/client') diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 67f954dd..ccc21da7 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -6,29 +6,42 @@ #include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include +#include +#include +#include #include -#include #include -#include -#include -#include #include - -#include +#include +#include #include #include +#include "srvbrowse.h" #include "client.h" #if defined(CONF_FAMILY_WINDOWS) - #define _WIN32_WINNT 0x0500 - #define NOGDI + #define _WIN32_WINNT 0x0501 + #define WIN32_LEAN_AND_MEAN #include #endif @@ -1748,7 +1761,7 @@ void CClient::VersionUpdate() { if(m_VersionInfo.m_State == 0) { - m_Engine.HostLookup(&m_VersionInfo.m_VersionServeraddr, g_Config.m_ClVersionServer); + Engine()->HostLookup(&m_VersionInfo.m_VersionServeraddr, g_Config.m_ClVersionServer); m_VersionInfo.m_State++; } else if(m_VersionInfo.m_State == 1) @@ -1773,11 +1786,6 @@ void CClient::VersionUpdate() } } -void CClient::InitEngine(const char *pAppname) -{ - m_Engine.Init(pAppname); -} - void CClient::RegisterInterfaces() { Kernel()->RegisterInterface(static_cast(&m_DemoRecorder)); @@ -1788,6 +1796,7 @@ void CClient::RegisterInterfaces() void CClient::InitInterfaces() { // fetch interfaces + m_pEngine = Kernel()->RequestInterface(); m_pEditor = Kernel()->RequestInterface(); m_pGraphics = Kernel()->RequestInterface(); m_pSound = Kernel()->RequestInterface(); @@ -2280,15 +2289,12 @@ int main(int argc, const char **argv) // ignore_convention } #endif - // init the engine - dbg_msg("client", "starting..."); - m_Client.InitEngine("Teeworlds"); - IKernel *pKernel = IKernel::Create(); pKernel->RegisterInterface(&m_Client); m_Client.RegisterInterfaces(); // create the components + IEngine *pEngine = CreateEngine("Teeworlds"); IConsole *pConsole = CreateConsole(CFGFLAG_CLIENT); IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention IConfig *pConfig = CreateConfig(); @@ -2302,8 +2308,9 @@ int main(int argc, const char **argv) // ignore_convention { bool RegisterFail = false; - RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast(pConsole)); - RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast(pConfig)); + RegisterFail = RegisterFail || !pKernel->RegisterInterface(pEngine); + RegisterFail = RegisterFail || !pKernel->RegisterInterface(pConsole); + RegisterFail = RegisterFail || !pKernel->RegisterInterface(pConfig); RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast(pEngineGraphics)); // register graphics as both RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast(pEngineGraphics)); @@ -2332,7 +2339,7 @@ int main(int argc, const char **argv) // ignore_convention } pConfig->Init(); - pEngineMasterServer->Init(m_Client.Engine()); + pEngineMasterServer->Init(); pEngineMasterServer->Load(); // register all console commands @@ -2359,6 +2366,7 @@ int main(int argc, const char **argv) // ignore_convention m_Client.Engine()->InitLogfile(); // run the client + dbg_msg("client", "starting..."); m_Client.Run(); // write down the config and quit diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 8768f23a..2c0f5f86 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -3,28 +3,6 @@ #ifndef ENGINE_CLIENT_CLIENT_H #define ENGINE_CLIENT_CLIENT_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "srvbrowse.h" - class CGraph { public: @@ -106,6 +84,7 @@ public: class CClient : public IClient, public CDemoPlayer::IListner { // needed interfaces + IEngine *m_pEngine; IEditor *m_pEditor; IEngineInput *m_pInput; IEngineGraphics *m_pGraphics; @@ -122,11 +101,10 @@ class CClient : public IClient, public CDemoPlayer::IListner PREDICTION_MARGIN=1000/50/2, // magic network prediction value }; - CNetClient m_NetClient; - CDemoPlayer m_DemoPlayer; - CDemoRecorder m_DemoRecorder; - CEngine m_Engine; - CServerBrowser m_ServerBrowser; + class CNetClient m_NetClient; + class CDemoPlayer m_DemoPlayer; + class CDemoRecorder m_DemoRecorder; + class CServerBrowser m_ServerBrowser; char m_aServerAddressStr[256]; @@ -191,28 +169,30 @@ class CClient : public IClient, public CDemoPlayer::IListner CGraph m_FpsGraph; // the game snapshots are modifiable by the game - CSnapshotStorage m_SnapshotStorage; + class CSnapshotStorage m_SnapshotStorage; CSnapshotStorage::CHolder *m_aSnapshots[NUM_SNAPSHOT_TYPES]; int m_RecivedSnapshots; char m_aSnapshotIncommingData[CSnapshot::MAX_SIZE]; - CSnapshotStorage::CHolder m_aDemorecSnapshotHolders[NUM_SNAPSHOT_TYPES]; + class CSnapshotStorage::CHolder m_aDemorecSnapshotHolders[NUM_SNAPSHOT_TYPES]; char *m_aDemorecSnapshotData[NUM_SNAPSHOT_TYPES][2][CSnapshot::MAX_SIZE]; - CSnapshotDelta m_SnapshotDelta; + class CSnapshotDelta m_SnapshotDelta; // - CServerInfo m_CurrentServerInfo; + class CServerInfo m_CurrentServerInfo; int64 m_CurrentServerInfoRequestTime; // >= 0 should request, == -1 got info // version info struct { int m_State; - CHostLookup m_VersionServeraddr; + class CHostLookup m_VersionServeraddr; } m_VersionInfo; + public: + IEngine *Engine() { return m_pEngine; } IEngineGraphics *Graphics() { return m_pGraphics; } IEngineInput *Input() { return m_pInput; } IEngineSound *Sound() { return m_pSound; } @@ -298,7 +278,6 @@ public: void Update(); - void InitEngine(const char *pAppname); void RegisterInterfaces(); void InitInterfaces(); @@ -327,7 +306,5 @@ public: void AutoScreenshot_Start(); void AutoScreenshot_Cleanup(); - - virtual class CEngine *Engine() { return &m_Engine; } }; #endif diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index f313e6e3..99f5e095 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -21,14 +21,13 @@ #include #include -#include #include #include #include #include #include -#include +#include // cosf, sinf #include "graphics.h" diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp index fea79285..55ca2939 100644 --- a/src/engine/client/sound.cpp +++ b/src/engine/client/sound.cpp @@ -1,6 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include +#include +#include #include #include "SDL.h" diff --git a/src/engine/client/sound.h b/src/engine/client/sound.h index 1372b9c4..0c45f1ab 100644 --- a/src/engine/client/sound.h +++ b/src/engine/client/sound.h @@ -4,9 +4,6 @@ #define ENGINE_CLIENT_SOUND_H #include -#include -#include -#include class CSound : public IEngineSound { diff --git a/src/engine/client/srvbrowse.cpp b/src/engine/client/srvbrowse.cpp index b9eeac11..540cadf3 100644 --- a/src/engine/client/srvbrowse.cpp +++ b/src/engine/client/srvbrowse.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include -- cgit 1.4.1