2022-01-16 01:18:36 +01:00
|
|
|
|
#include "core/stdafx.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
#include "core/r5dev.h"
|
|
|
|
|
#include "core/init.h"
|
2022-01-14 20:45:36 +01:00
|
|
|
|
#include "core/logdef.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
#include "windows/id3dx.h"
|
|
|
|
|
#include "windows/input.h"
|
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
#include "windows/console.h"
|
2021-12-30 17:20:41 +01:00
|
|
|
|
#include "windows/system.h"
|
2022-04-16 00:30:46 +02:00
|
|
|
|
#include "launcher/launcher.h"
|
2021-04-13 04:45:22 -07:00
|
|
|
|
|
2021-06-28 15:51:32 -07:00
|
|
|
|
//#############################################################################
|
|
|
|
|
// INITIALIZATION
|
|
|
|
|
//#############################################################################
|
2021-04-13 04:45:22 -07:00
|
|
|
|
|
2022-08-29 14:31:05 +02:00
|
|
|
|
void SDK_Init()
|
2021-04-13 04:45:22 -07:00
|
|
|
|
{
|
2022-04-16 00:30:46 +02:00
|
|
|
|
if (strstr(GetCommandLineA(), "-launcher"))
|
|
|
|
|
{
|
|
|
|
|
g_svCmdLine = GetCommandLineA();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_svCmdLine = LoadConfigFile(SDK_DEFAULT_CFG);
|
|
|
|
|
}
|
2022-01-14 20:45:36 +01:00
|
|
|
|
#ifndef DEDICATED
|
2022-08-11 11:07:45 +02:00
|
|
|
|
if (g_svCmdLine.find("-wconsole") != std::string::npos)
|
2022-04-16 00:30:46 +02:00
|
|
|
|
{
|
|
|
|
|
Console_Init();
|
|
|
|
|
}
|
2022-01-14 20:45:36 +01:00
|
|
|
|
#else
|
2021-12-25 22:36:38 +01:00
|
|
|
|
Console_Init();
|
2022-01-14 20:45:36 +01:00
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
SpdLog_Init();
|
2022-04-14 19:18:59 +02:00
|
|
|
|
spdlog::info("\n");
|
2022-07-03 19:18:23 +02:00
|
|
|
|
for (size_t i = 0; i < SDK_ARRAYSIZE(R5R_EMBLEM); i++)
|
2022-04-14 19:18:59 +02:00
|
|
|
|
{
|
|
|
|
|
std::string svEscaped = StringEscape(R5R_EMBLEM[i]);
|
2022-08-11 11:07:45 +02:00
|
|
|
|
spdlog::info("{:s}{:s}{:s}\n", g_svRedF, svEscaped, g_svReset);
|
2022-04-14 19:18:59 +02:00
|
|
|
|
}
|
|
|
|
|
spdlog::info("\n");
|
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
Systems_Init();
|
2021-12-30 17:20:41 +01:00
|
|
|
|
WinSys_Attach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
Input_Init();
|
|
|
|
|
DirectX_Init();
|
|
|
|
|
#endif // !DEDICATED
|
2021-04-13 04:45:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 20:45:36 +01:00
|
|
|
|
//#############################################################################
|
|
|
|
|
// SHUTDOWN
|
|
|
|
|
//#############################################################################
|
|
|
|
|
|
2022-08-29 14:31:05 +02:00
|
|
|
|
void SDK_Shutdown()
|
2021-04-13 04:45:22 -07:00
|
|
|
|
{
|
2022-02-18 14:00:58 +01:00
|
|
|
|
static bool bShutDown = false;
|
|
|
|
|
if (bShutDown)
|
|
|
|
|
{
|
|
|
|
|
spdlog::error("Recursive shutdown!\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
bShutDown = true;
|
2022-02-19 14:02:46 +01:00
|
|
|
|
spdlog::info("Shutdown GameSDK\n");
|
2022-02-18 14:00:58 +01:00
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
Systems_Shutdown();
|
2021-12-30 17:20:41 +01:00
|
|
|
|
WinSys_Detach();
|
2021-12-25 22:36:38 +01:00
|
|
|
|
|
|
|
|
|
#ifndef DEDICATED
|
|
|
|
|
Input_Shutdown();
|
|
|
|
|
DirectX_Shutdown();
|
|
|
|
|
#endif // !DEDICATED
|
|
|
|
|
|
2021-06-19 11:21:31 -07:00
|
|
|
|
FreeConsole();
|
2021-04-13 04:45:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-28 15:51:32 -07:00
|
|
|
|
//#############################################################################
|
|
|
|
|
// ENTRYPOINT
|
|
|
|
|
//#############################################################################
|
2021-06-08 10:54:49 -07:00
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
|
2021-04-13 04:45:22 -07:00
|
|
|
|
{
|
|
|
|
|
switch (dwReason)
|
|
|
|
|
{
|
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2021-04-17 04:51:04 -07:00
|
|
|
|
{
|
2022-08-29 14:31:05 +02:00
|
|
|
|
SDK_Init();
|
2021-04-13 04:45:22 -07:00
|
|
|
|
break;
|
2021-04-17 04:51:04 -07:00
|
|
|
|
}
|
2021-04-13 04:45:22 -07:00
|
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
2021-04-17 04:51:04 -07:00
|
|
|
|
{
|
2022-08-29 14:31:05 +02:00
|
|
|
|
SDK_Shutdown();
|
2021-04-13 04:45:22 -07:00
|
|
|
|
break;
|
2021-04-17 04:51:04 -07:00
|
|
|
|
}
|
2021-04-13 04:45:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2021-06-08 10:54:49 -07:00
|
|
|
|
}
|