From 1c29d5aed5f2fc912bd9fe594b4a84c5a717d785 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 29 Aug 2022 01:14:53 +0200 Subject: [PATCH] CEngineAPI vftable implementation --- r5dev/appframework/engine_launcher_api.h | 37 +++++++++++++++++++++++- r5dev/engine/sdk_dll.cpp | 8 +++++ r5dev/engine/sdk_dll.h | 5 ++++ r5dev/engine/sys_dll2.h | 34 ++++++++++++++++++++-- r5dev/launcher/IApplication.cpp | 1 + r5dev/launcher/IApplication.h | 21 ++------------ r5dev/vproj/clientsdk.vcxproj | 2 ++ r5dev/vproj/clientsdk.vcxproj.filters | 6 ++++ r5dev/vproj/dedicated.vcxproj | 2 ++ r5dev/vproj/dedicated.vcxproj.filters | 6 ++++ r5dev/vproj/gamesdk.vcxproj | 2 ++ r5dev/vproj/gamesdk.vcxproj.filters | 6 ++++ 12 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 r5dev/engine/sdk_dll.cpp create mode 100644 r5dev/engine/sdk_dll.h diff --git a/r5dev/appframework/engine_launcher_api.h b/r5dev/appframework/engine_launcher_api.h index 4ff3c4c9..c25ed097 100644 --- a/r5dev/appframework/engine_launcher_api.h +++ b/r5dev/appframework/engine_launcher_api.h @@ -4,9 +4,21 @@ // // $NoKeywords: $ //=============================================================================// +#ifndef ENGINE_LAUNCHER_APIH +#define ENGINE_LAUNCHER_APIH #include "appframework/iappsystem.h" +struct StartupInfo_t +{ + void* m_pInstance; + const char m_pBaseDirectory[260]; + const char m_pInitialMod[260]; + const char m_pInitialGame[260]; + uint8_t m_pParentAppSystemGroup[236]; + bool m_bTextMode; +}; + //----------------------------------------------------------------------------- // Return values from the initialization stage of the application framework //----------------------------------------------------------------------------- @@ -32,4 +44,27 @@ enum //----------------------------------------------------------------------------- #define VENGINE_LAUNCHER_API_VERSION "VENGINE_LAUNCHER_API_VERSION004" -// NOTE: _purecall IEngineAPI vtable +abstract_class IEngineAPI : public IAppSystem +{ + // Functions + public: + // This function must be called before init + virtual bool SetStartupInfo(StartupInfo_t & info) = 0; + + // Run the engine + virtual int Run() = 0; + + // Sets the engine to run in a particular editor window + virtual void PostConsoleCommand(const char* pConsoleCommand) = 0; + + // Are we running the simulation? + virtual bool IsRunningSimulation() const = 0; + + // Start/stop running the simulation + virtual void ActivateSimulation(bool bActive) = 0; + + // Reset the map we're on + virtual void SetMap(const char* pMapName) = 0; +}; + +#endif // ENGINE_LAUNCHER_APIH \ No newline at end of file diff --git a/r5dev/engine/sdk_dll.cpp b/r5dev/engine/sdk_dll.cpp new file mode 100644 index 00000000..64300761 --- /dev/null +++ b/r5dev/engine/sdk_dll.cpp @@ -0,0 +1,8 @@ +//=============================================================================// +// +// Purpose: +// +//=============================================================================// + +#include "core/stdafx.h" +#include "engine/sdk_dll.h" diff --git a/r5dev/engine/sdk_dll.h b/r5dev/engine/sdk_dll.h new file mode 100644 index 00000000..8bbd20ad --- /dev/null +++ b/r5dev/engine/sdk_dll.h @@ -0,0 +1,5 @@ +#ifndef SDK_DLL_H +#define SDK_DLL_H + + +#endif // SDK_DLL_H diff --git a/r5dev/engine/sys_dll2.h b/r5dev/engine/sys_dll2.h index 24ec1f9b..6d48782d 100644 --- a/r5dev/engine/sys_dll2.h +++ b/r5dev/engine/sys_dll2.h @@ -1,11 +1,41 @@ #pragma once #include "vpc/interfaces.h" +#include "appframework/engine_launcher_api.h" -class CEngineAPI +class CEngineAPI : public IEngineAPI { public: + virtual bool Connect(CreateInterfaceFn factory) = 0; + virtual void Disconnect() = 0; + virtual void* QueryInterface(const char* pInterfaceName) = 0; + virtual InitReturnVal_t Init() = 0; + virtual void Shutdown() = 0; + virtual AppSystemTier_t GetTier() = 0; + virtual void Reconnect(CreateInterfaceFn factory, const char* pInterfaceName) = 0; + + // This function must be called before init + virtual bool SetStartupInfo(StartupInfo_t& info) = 0; + + virtual int Run() = 0; + + // Posts a console command + virtual void PostConsoleCommand(const char* pConsoleCommand) = 0; + + // Are we running the simulation? + virtual bool IsRunningSimulation() const = 0; + + // Start/stop running the simulation + virtual void ActivateSimulation(bool bActive) = 0; + + // Reset the map we're on + virtual void SetMap(const char* pMapName) = 0; + + static bool ModInit(CEngineAPI* pEngineAPI, const char* pModName, const char* pGameDir); - // TODO [ AMOS ]: +private: + void* m_hEditorHWnd; + bool m_bRunningSimulation; + StartupInfo_t m_StartupInfo; }; inline CMemory p_CEngineAPI_Connect; diff --git a/r5dev/launcher/IApplication.cpp b/r5dev/launcher/IApplication.cpp index 0b0e395d..e0b13070 100644 --- a/r5dev/launcher/IApplication.cpp +++ b/r5dev/launcher/IApplication.cpp @@ -9,6 +9,7 @@ #include "tier0/commandline.h" #include "tier1/cvar.h" #include "vpc/interfaces.h" +#include "appframework/engine_launcher_api.h" #include "launcher/IApplication.h" #include "pluginsystem/pluginsystem.h" #include "ebisusdk/EbisuSDK.h" diff --git a/r5dev/launcher/IApplication.h b/r5dev/launcher/IApplication.h index b33782cb..ca26813f 100644 --- a/r5dev/launcher/IApplication.h +++ b/r5dev/launcher/IApplication.h @@ -1,24 +1,9 @@ #pragma once #include "appframework/iappsystem.h" -//----------------------------------------------------------------------------- -// Return values from the initialization stage of the application framework -//----------------------------------------------------------------------------- -enum -{ - INIT_RESTART = INIT_LAST_VAL, - RUN_FIRST_VAL, -}; - - -//----------------------------------------------------------------------------- -// Return values from IEngineAPI::Run. -//----------------------------------------------------------------------------- -enum -{ - RUN_OK = RUN_FIRST_VAL, - RUN_RESTART, -}; +//------------------------------------------------------------------------- +// +//------------------------------------------------------------------------- class CModAppSystemGroup { public: diff --git a/r5dev/vproj/clientsdk.vcxproj b/r5dev/vproj/clientsdk.vcxproj index 0a072fb1..3591b906 100644 --- a/r5dev/vproj/clientsdk.vcxproj +++ b/r5dev/vproj/clientsdk.vcxproj @@ -43,6 +43,7 @@ + @@ -189,6 +190,7 @@ + diff --git a/r5dev/vproj/clientsdk.vcxproj.filters b/r5dev/vproj/clientsdk.vcxproj.filters index 18c57184..77a060f1 100644 --- a/r5dev/vproj/clientsdk.vcxproj.filters +++ b/r5dev/vproj/clientsdk.vcxproj.filters @@ -591,6 +591,9 @@ sdk\pluginsystem + + sdk\engine + @@ -1748,6 +1751,9 @@ sdk\pluginsystem + + sdk\engine + diff --git a/r5dev/vproj/dedicated.vcxproj b/r5dev/vproj/dedicated.vcxproj index 15a5b672..4ae78aad 100644 --- a/r5dev/vproj/dedicated.vcxproj +++ b/r5dev/vproj/dedicated.vcxproj @@ -161,6 +161,7 @@ + @@ -497,6 +498,7 @@ + diff --git a/r5dev/vproj/dedicated.vcxproj.filters b/r5dev/vproj/dedicated.vcxproj.filters index 223b3c1c..f6649404 100644 --- a/r5dev/vproj/dedicated.vcxproj.filters +++ b/r5dev/vproj/dedicated.vcxproj.filters @@ -1245,6 +1245,9 @@ sdk\pluginsystem + + sdk\engine + @@ -1559,6 +1562,9 @@ sdk\pluginsystem + + sdk\engine + diff --git a/r5dev/vproj/gamesdk.vcxproj b/r5dev/vproj/gamesdk.vcxproj index 222a2123..0a8ef765 100644 --- a/r5dev/vproj/gamesdk.vcxproj +++ b/r5dev/vproj/gamesdk.vcxproj @@ -43,6 +43,7 @@ + @@ -199,6 +200,7 @@ + diff --git a/r5dev/vproj/gamesdk.vcxproj.filters b/r5dev/vproj/gamesdk.vcxproj.filters index db74e322..4cbf2909 100644 --- a/r5dev/vproj/gamesdk.vcxproj.filters +++ b/r5dev/vproj/gamesdk.vcxproj.filters @@ -630,6 +630,9 @@ sdk\pluginsystem + + sdk\engine + @@ -1838,6 +1841,9 @@ sdk\pluginsystem + + sdk\engine +