From ade1de41a96c956e76004f15fa5287e2e35d06fe Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 9 Aug 2022 11:53:33 +0200 Subject: [PATCH] Implement abstract class 'IEngine' Also reversed one new method: IEngine::GetPlaylistCount (gets the number of playlists read from the playlists file, the other 2 unknown methods after this one also do stuff with the playlists, but rather on KeyValues level, one checks if something exists i think, the other returns a const char. Haven't ran these yet). --- r5dev/engine/host_state.cpp | 4 +- r5dev/engine/sys_engine.cpp | 2 + r5dev/engine/sys_engine.h | 41 +++--------------- r5dev/launcher/IApplication.cpp | 2 +- r5dev/public/iengine.h | 61 +++++++++++++++++++++++++++ r5dev/vproj/clientsdk.vcxproj | 1 + r5dev/vproj/clientsdk.vcxproj.filters | 3 ++ r5dev/vproj/dedicated.vcxproj | 1 + r5dev/vproj/dedicated.vcxproj.filters | 3 ++ r5dev/vproj/gamesdk.vcxproj | 1 + r5dev/vproj/gamesdk.vcxproj.filters | 3 ++ 11 files changed, 85 insertions(+), 37 deletions(-) create mode 100644 r5dev/public/iengine.h diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp index 84338cb8..c215055d 100644 --- a/r5dev/engine/host_state.cpp +++ b/r5dev/engine/host_state.cpp @@ -119,7 +119,7 @@ FORCEINLINE void CHostState::FrameUpdate(CHostState* pHostState, double flCurren CL_EndMovie(); #endif // !DEDICATED Stryder_SendOfflineRequest(); // We have hostnames nulled anyway. - g_pEngine->SetNextState(EngineState_t::DLL_RESTART); + g_pEngine->SetNextState(IEngine::DLL_RESTART); break; } case HostStates_t::HS_SHUTDOWN: @@ -129,7 +129,7 @@ FORCEINLINE void CHostState::FrameUpdate(CHostState* pHostState, double flCurren CL_EndMovie(); #endif // !DEDICATED Stryder_SendOfflineRequest(); // We have hostnames nulled anyway. - g_pEngine->SetNextState(EngineState_t::DLL_CLOSE); + g_pEngine->SetNextState(IEngine::DLL_CLOSE); break; } default: diff --git a/r5dev/engine/sys_engine.cpp b/r5dev/engine/sys_engine.cpp index 2a714b92..6038c141 100644 --- a/r5dev/engine/sys_engine.cpp +++ b/r5dev/engine/sys_engine.cpp @@ -4,6 +4,7 @@ /////////////////////////////////////////////////////////////////////////////// CEngine* g_pEngine = nullptr; +/* //----------------------------------------------------------------------------- // Purpose: Start initializing the engine. // Output : Returns true on success, false on failure. @@ -81,3 +82,4 @@ void CEngine::SetQuitting(EngineDllQuitting_t quitDllState) const int index = 9; CallVFunc(index, this, quitDllState); } +*/ \ No newline at end of file diff --git a/r5dev/engine/sys_engine.h b/r5dev/engine/sys_engine.h index d81062b7..b96bb1a3 100644 --- a/r5dev/engine/sys_engine.h +++ b/r5dev/engine/sys_engine.h @@ -1,44 +1,17 @@ #pragma once #include +#include -enum class EngineState_t : int +class CEngine : public IEngine { - DLL_INACTIVE = 0x0, - DLL_ACTIVE = 0x1, - DLL_CLOSE = 0x2, - DLL_RESTART = 0x3, - DLL_PAUSED = 0x4, -}; - -enum class EngineDllQuitting_t : int -{ - QUIT_NOTQUITTING = 0x0, - QUIT_TODESKTOP = 0x1, - QUIT_RESTART = 0x2, -}; - -class CEngine -{ -public: - bool Load(bool dedicated, const char* rootDir); - void Unload(void); - void SetNextState(EngineState_t iNextState); - EngineState_t GetState(void) const; - void Frame(void); - float GetFrameTime(void) const; - float GetPreviousTime(void); - __m128 GetCurTime(CEngine* thisPtr) const; - void SetQuitting(EngineDllQuitting_t quitDllState); - private: - void* vtable; EngineState_t m_nDLLState; EngineState_t m_nNextDLLState; - int64_t m_flCurrentTime; - int64_t m_flPreviousTime; - int m_flFrameTime; - int field_24; - int m_flFilteredTime; + double m_flCurrentTime; + double m_flPreviousTime; + float m_flFrameTime; + float m_flPreviousFrameTime; + float m_flFilteredTime; uint8_t gap2C[4]; int64_t field_30; char field_38; diff --git a/r5dev/launcher/IApplication.cpp b/r5dev/launcher/IApplication.cpp index 0868b9eb..79c7c7a9 100644 --- a/r5dev/launcher/IApplication.cpp +++ b/r5dev/launcher/IApplication.cpp @@ -33,7 +33,7 @@ int CModAppSystemGroup::Main(CModAppSystemGroup* pModAppSystemGroup) return CModAppSystemGroup_Main(pModAppSystemGroup); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - g_pEngine->SetQuitting(EngineDllQuitting_t::QUIT_NOTQUITTING); + g_pEngine->SetQuitting(IEngine::QUIT_NOTQUITTING); if (g_pEngine->Load(pModAppSystemGroup->IsServerOnly(), g_pEngineParms->baseDirectory)) { if (CEngineAPI_MainLoop()) diff --git a/r5dev/public/iengine.h b/r5dev/public/iengine.h new file mode 100644 index 00000000..f9fe9c8e --- /dev/null +++ b/r5dev/public/iengine.h @@ -0,0 +1,61 @@ +//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// $NoKeywords: $ +//===========================================================================// +#if !defined( IENGINE_H ) +#define IENGINE_H +#ifdef _WIN32 +#pragma once +#endif + +//#include "tier1/interface.h" + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +abstract_class IEngine +{ +public: + enum + { + QUIT_NOTQUITTING = 0, + QUIT_TODESKTOP, + QUIT_RESTART + }; + + // Engine State Flags + enum EngineState_t + { + DLL_INACTIVE = 0, // no dll + DLL_ACTIVE, // engine is focused + DLL_CLOSE, // closing down dll + DLL_RESTART, // engine is shutting down but will restart right away + DLL_PAUSED, // engine is paused, can become active from this state + }; + + + virtual ~IEngine(void) { } + + virtual bool Load(bool dedicated, const char* rootdir) = 0; + virtual void Unload(void) = 0; + virtual void SetNextState(EngineState_t iNextState) = 0; + virtual EngineState_t GetState(void) = 0; + + virtual void Frame(void) = 0; + virtual float GetFrameTime(void) = 0; + virtual float GetPreviousTime(void) = 0; + + virtual __m128 GetCurTime(void) = 0; + virtual void SetQuitting(int quittype) = 0; + + virtual int GetPlaylistCount(void) = 0; + + virtual const char* sub_1401FE2B0(int a2) = 0; // Playlists KeyValues stuff. + virtual bool sub_1401FE3B0(__int64 a2) = 0; // Playlists KeyValues stuff. +}; + +#endif // IENGINE_H diff --git a/r5dev/vproj/clientsdk.vcxproj b/r5dev/vproj/clientsdk.vcxproj index 7c0ab45b..73dc220c 100644 --- a/r5dev/vproj/clientsdk.vcxproj +++ b/r5dev/vproj/clientsdk.vcxproj @@ -235,6 +235,7 @@ + diff --git a/r5dev/vproj/clientsdk.vcxproj.filters b/r5dev/vproj/clientsdk.vcxproj.filters index df701101..1f929199 100644 --- a/r5dev/vproj/clientsdk.vcxproj.filters +++ b/r5dev/vproj/clientsdk.vcxproj.filters @@ -1673,6 +1673,9 @@ sdk\tier0 + + sdk\public + diff --git a/r5dev/vproj/dedicated.vcxproj b/r5dev/vproj/dedicated.vcxproj index 36bc0a45..66915901 100644 --- a/r5dev/vproj/dedicated.vcxproj +++ b/r5dev/vproj/dedicated.vcxproj @@ -211,6 +211,7 @@ + diff --git a/r5dev/vproj/dedicated.vcxproj.filters b/r5dev/vproj/dedicated.vcxproj.filters index 6067a329..f1ef6111 100644 --- a/r5dev/vproj/dedicated.vcxproj.filters +++ b/r5dev/vproj/dedicated.vcxproj.filters @@ -1197,6 +1197,9 @@ sdk\tier0 + + sdk\public + diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index 71df00b1..9629f399 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -258,6 +258,7 @@ + diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index 1d422b74..8c21e6e3 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -1763,6 +1763,9 @@ sdk\tier0 + + sdk\public +