diff options
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/client.cpp | 56 | ||||
| -rw-r--r-- | src/engine/client/client.h | 47 | ||||
| -rw-r--r-- | src/engine/client/graphics.cpp | 3 | ||||
| -rw-r--r-- | src/engine/client/sound.cpp | 2 | ||||
| -rw-r--r-- | src/engine/client/sound.h | 3 | ||||
| -rw-r--r-- | src/engine/client/srvbrowse.cpp | 1 |
6 files changed, 47 insertions, 65 deletions
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 <base/math.h> #include <base/system.h> -#include <engine/shared/engine.h> -#include <engine/shared/protocol.h> -#include <engine/shared/snapshot.h> +#include <engine/client.h> +#include <engine/config.h> +#include <engine/console.h> +#include <engine/editor.h> +#include <engine/engine.h> +#include <engine/graphics.h> +#include <engine/input.h> +#include <engine/keys.h> +#include <engine/map.h> +#include <engine/masterserver.h> +#include <engine/serverbrowser.h> +#include <engine/sound.h> +#include <engine/storage.h> +#include <engine/textrender.h> + +#include <engine/shared/config.h> #include <engine/shared/compression.h> +#include <engine/shared/datafile.h> +#include <engine/shared/demo.h> +#include <engine/shared/memheap.h> #include <engine/shared/network.h> -#include <engine/shared/config.h> #include <engine/shared/packer.h> -#include <engine/shared/memheap.h> -#include <engine/shared/datafile.h> -#include <engine/shared/ringbuffer.h> #include <engine/shared/protocol.h> - -#include <engine/shared/demo.h> +#include <engine/shared/ringbuffer.h> +#include <engine/shared/snapshot.h> #include <mastersrv/mastersrv.h> #include <versionsrv/versionsrv.h> +#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 <windows.h> #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<IDemoRecorder*>(&m_DemoRecorder)); @@ -1788,6 +1796,7 @@ void CClient::RegisterInterfaces() void CClient::InitInterfaces() { // fetch interfaces + m_pEngine = Kernel()->RequestInterface<IEngine>(); m_pEditor = Kernel()->RequestInterface<IEditor>(); m_pGraphics = Kernel()->RequestInterface<IEngineGraphics>(); m_pSound = Kernel()->RequestInterface<IEngineSound>(); @@ -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<IConsole*>(pConsole)); - RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast<IConfig*>(pConfig)); + RegisterFail = RegisterFail || !pKernel->RegisterInterface(pEngine); + RegisterFail = RegisterFail || !pKernel->RegisterInterface(pConsole); + RegisterFail = RegisterFail || !pKernel->RegisterInterface(pConfig); RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast<IEngineGraphics*>(pEngineGraphics)); // register graphics as both RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast<IGraphics*>(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 <engine/console.h> -#include <engine/editor.h> -#include <engine/graphics.h> -#include <engine/textrender.h> -#include <engine/client.h> -#include <engine/config.h> -#include <engine/serverbrowser.h> -#include <engine/sound.h> -#include <engine/input.h> -#include <engine/keys.h> -#include <engine/map.h> -#include <engine/masterserver.h> -#include <engine/storage.h> - -#include <engine/shared/engine.h> -#include <engine/shared/protocol.h> -#include <engine/shared/demo.h> -#include <engine/shared/network.h> - -#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 <base/system.h> #include <engine/external/pnglite/pnglite.h> -#include <engine/shared/engine.h> #include <engine/shared/config.h> #include <engine/graphics.h> #include <engine/storage.h> #include <engine/keys.h> #include <engine/console.h> -#include <math.h> +#include <math.h> // 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 <base/system.h> +#include <engine/graphics.h> +#include <engine/storage.h> #include <engine/shared/config.h> #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 <engine/sound.h> -#include <engine/storage.h> -#include <engine/graphics.h> -#include <engine/shared/engine.h> 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 <engine/shared/protocol.h> #include <engine/shared/config.h> #include <engine/shared/memheap.h> -#include <engine/shared/engine.h> #include <engine/masterserver.h> #include <engine/console.h> |