#include "tier2/ifilesystem.h" #include "materialsystem/igamewindow.h" #include "materialsystem/imaterialsystem.h" #include "tier1/interface.h" #include "tier0/commandline.h" #include "tier0/mem.h" #include "sv_dll.h" #include "cl_dll.h" #include "inetworkserver.h" #include "inetworkclient.h" #ifdef STEAM #include "steam/steam_api.h" #endif IRenderContext *g_pRenderContext; IFileSystem *filesystem; IGameWindowManager *g_pWindowManager; CServerGameDLL *g_pServerGame; CClientGameDLL *g_pClientGame; extern "C" void FunnyMain( int argc, char **argv ) { CommandLine()->CreateCommandLine(argc, argv); EngineConsts_t stConstants = {}; #ifdef STEAM stConstants.m_bIsSteam = true; if (!SteamAPI_Init()) Plat_FatalErrorFunc("SteamAPI_Init failed lol\n"); stConstants.LaunchServer = LaunchLocalBridge; stConstants.ConnectSteamServer = ConnectBySteamID; #endif stConstants.m_bIsDedicated = CommandLine()->CheckParam("-dedicated"); stConstants.LaunchLocalBridge = LaunchLocalBridge; stConstants.ConnectLocalBridge = ConnectByLocalBridge; CreateInterfaceFn pFilesystemFactory = Sys_GetFactory("filesystem_std"); CreateInterfaceFn pMaterialSystemFactory = Sys_GetFactory("MaterialSystem"); CreateInterfaceFn pRenderSystemFactory = Sys_GetFactory("RenderSystemVulkan"); IGameWindow *pWindow; filesystem = (IFileSystem*)pFilesystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL); filesystem->Init(); if (!stConstants.m_bIsDedicated) { g_pWindowManager = (IGameWindowManager*)pRenderSystemFactory(GAME_WINDOW_MANAGER_INTERFACE_VERSION, NULL); g_pWindowManager->Init(); pWindow = g_pWindowManager->CreateWindow(); pWindow->Init(); g_pRenderContext = (IRenderContext*)pRenderSystemFactory(RENDER_CONTEXT_INTERFACE_VERSION, NULL); g_pRenderContext->SetMainWindowManager(g_pWindowManager); g_pRenderContext->Init(); g_pRenderContext->RegisterGameWindow(pWindow); } g_pServerGame = new CServerGameDLL; g_pServerGame->m_pEngineConsts = &stConstants; g_pServerGame->Init(); if (!stConstants.m_bIsDedicated) { g_pClientGame = new CClientGameDLL; g_pClientGame->m_pGameWindow = pWindow; g_pClientGame->m_pRenderContext = g_pRenderContext; g_pClientGame->m_pEngineConsts = &stConstants; g_pClientGame->Init(); } double fPrevious = Plat_GetTime(); for (;;) { double fCurrent = Plat_GetTime(); double fDelta = fCurrent-fPrevious; fPrevious = fCurrent; g_pServerGame->m_pBridge->Frame(fDelta); if (!stConstants.m_bIsDedicated) { g_pWindowManager->Frame(fDelta); g_pClientGame->m_pBridge->Frame(fDelta); g_pRenderContext->Frame(fDelta); } }; };