#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" #include "steam/steam_gameserver.h" #endif IRenderContext *g_pRenderContext; IFileSystem *filesystem; IGameWindowManager *g_pWindowManager; CServerGameDLL *g_pServerGame; CClientGameDLL *g_pClientGame; extern "C" void __cdecl SteamAPIDebug( ESteamNetworkingSocketsDebugOutputType nType, const char *pszMsg ) { V_printf("STEAM: %s\n", pszMsg); } extern "C" void FunnyMain( int argc, char **argv ) { CommandLine()->CreateCommandLine(argc, argv); EngineConsts_t stConstants = {}; #ifdef STEAM if(SteamAPI_RestartAppIfNecessary(480)) { V_printf("Mshallah we are doing reboot\n"); Plat_Exit(0); } stConstants.m_bIsSteam = true; if (!SteamAPI_Init()) { stConstants.m_bIsSteam = false; } stConstants.LaunchServer = LaunchServerAtSteamRelay; stConstants.ConnectSteamServer = ConnectBySteamID; //SteamNetworkingUtils()->SetDebugOutputFunction(k_ESteamNetworkingSocketsDebugOutputType_Debug, SteamAPIDebug); #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 (;;) { #ifdef STEAM SteamAPI_RunCallbacks(); #endif 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); } }; };