2021-12-25 22:36:38 +01:00
|
|
|
#include "core/stdafx.h"
|
2024-05-07 16:05:57 +02:00
|
|
|
#include "tier0/commandline.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
#include "ebisusdk/EbisuSDK.h"
|
2023-05-13 19:41:57 +02:00
|
|
|
#include "engine/server/sv_main.h"
|
2021-12-25 22:36:38 +01:00
|
|
|
|
2022-08-22 03:53:38 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
2024-05-17 11:12:57 +02:00
|
|
|
// Purpose: initialize the EbisuSDK
|
2023-03-31 22:37:53 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void HEbisuSDK_Init()
|
|
|
|
{
|
2024-05-17 11:12:57 +02:00
|
|
|
const bool isDedicated = IsDedicated();
|
|
|
|
const bool noOrigin = IsOriginDisabled();
|
|
|
|
|
|
|
|
// Fill with default data if this is a dedicated server, or if the game was
|
|
|
|
// launched with the platform system disabled. Engine code requires these
|
|
|
|
// to be set for the game to function, else stuff like the "map" command
|
|
|
|
// won't run as 'IsOriginInitialized()' returns false (which got inlined in
|
|
|
|
// every place this was called in the game's executable).
|
|
|
|
if (isDedicated || noOrigin)
|
|
|
|
{
|
|
|
|
*g_EbisuSDKInit = true;
|
|
|
|
*g_EbisuProfileInit = true;
|
|
|
|
*g_NucleusID = FAKE_BASE_NUCLEUD_ID;
|
|
|
|
|
|
|
|
Q_snprintf(g_OriginAuthCode, 256, "%s", "INVALID_OAUTH_CODE");
|
|
|
|
Q_snprintf(g_NucleusToken, 1024, "%s", "INVALID_NUCLEUS_TOKEN");
|
|
|
|
|
|
|
|
if (!isDedicated)
|
|
|
|
{
|
|
|
|
platform_user_id->SetValue(FAKE_BASE_NUCLEUD_ID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: runs the EbisuSDK state machine
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void HEbisuSDK_RunFrame()
|
|
|
|
{
|
|
|
|
if (IsOriginDisabled())
|
2023-05-13 19:41:57 +02:00
|
|
|
{
|
2024-05-17 11:12:57 +02:00
|
|
|
return;
|
2023-05-13 19:41:57 +02:00
|
|
|
}
|
2024-05-17 11:12:57 +02:00
|
|
|
|
|
|
|
EbisuSDK_RunFrame();
|
2023-03-31 22:37:53 +02:00
|
|
|
}
|
|
|
|
|
2024-05-07 16:05:57 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: returns the currently set language
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
const char* HEbisuSDK_GetLanguage()
|
|
|
|
{
|
|
|
|
static bool initialized = false;
|
|
|
|
static char languageName[32];
|
|
|
|
|
|
|
|
if (initialized)
|
|
|
|
{
|
|
|
|
return languageName;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* value = nullptr;
|
|
|
|
bool useDefault = true;
|
|
|
|
|
|
|
|
if (CommandLine()->CheckParm("-language", &value))
|
|
|
|
{
|
|
|
|
if (V_LocaleNameExists(value))
|
|
|
|
{
|
|
|
|
strncpy(languageName, value, sizeof(languageName));
|
|
|
|
useDefault = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (useDefault)
|
|
|
|
{
|
|
|
|
strncpy(languageName, g_LanguageNames[0], sizeof(languageName));
|
|
|
|
}
|
|
|
|
|
|
|
|
languageName[sizeof(languageName) - 1] = '\0';
|
|
|
|
initialized = true;
|
|
|
|
|
|
|
|
return languageName;
|
|
|
|
}
|
|
|
|
|
2024-05-17 11:12:57 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: checks if the EbisuSDK is disabled
|
|
|
|
// Output : true on success, false on failure
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool IsOriginDisabled()
|
|
|
|
{
|
|
|
|
const static bool isDisabled = CommandLine()->CheckParm("-noorigin");
|
|
|
|
return isDisabled;
|
|
|
|
}
|
|
|
|
|
2023-03-31 22:37:53 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: checks if the EbisuSDK is initialized
|
|
|
|
// Output : true on success, false on failure
|
2022-08-22 03:53:38 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool IsOriginInitialized()
|
|
|
|
{
|
2023-06-01 22:55:36 +02:00
|
|
|
if (IsDedicated())
|
2023-05-13 19:41:57 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if ((!(*g_OriginErrorLevel)
|
2023-02-04 00:39:34 +01:00
|
|
|
&& (*g_EbisuSDKInit)
|
2022-08-22 12:42:41 +02:00
|
|
|
&& (*g_NucleusID)
|
2023-02-04 00:39:34 +01:00
|
|
|
&& (*g_EbisuProfileInit)))
|
2022-08-22 03:53:38 +02:00
|
|
|
// && (*g_OriginAuthCode)
|
2023-01-25 02:30:54 +01:00
|
|
|
// && (g_NucleusToken[0])))
|
2022-08-22 03:53:38 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2023-05-13 19:41:57 +02:00
|
|
|
|
2022-08-22 03:53:38 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-25 22:36:38 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
2023-03-31 22:37:53 +02:00
|
|
|
// Purpose: validates if client's persona name meets EA's criteria
|
|
|
|
// Input : *pszName -
|
|
|
|
// Output : true on success, false on failure
|
2021-12-25 22:36:38 +01:00
|
|
|
//-----------------------------------------------------------------------------
|
2023-07-19 02:16:06 +02:00
|
|
|
bool IsValidPersonaName(const char* pszName, int nMinLen, int nMaxLen)
|
2021-12-25 22:36:38 +01:00
|
|
|
{
|
2023-03-31 22:37:53 +02:00
|
|
|
size_t len = strlen(pszName);
|
|
|
|
|
2023-07-19 02:16:06 +02:00
|
|
|
if (len < nMinLen ||
|
|
|
|
len > nMaxLen)
|
2023-03-31 22:37:53 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the name contains any special characters.
|
2023-04-05 15:32:00 +02:00
|
|
|
size_t pos = strspn(pszName, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
|
2023-03-31 22:37:53 +02:00
|
|
|
return pszName[pos] == '\0';
|
2021-12-25 22:36:38 +01:00
|
|
|
}
|
2024-05-07 16:05:57 +02:00
|
|
|
|
|
|
|
void VEbisuSDK::Detour(const bool bAttach) const
|
|
|
|
{
|
2024-05-17 11:12:57 +02:00
|
|
|
DetourSetup(&EbisuSDK_RunFrame, &HEbisuSDK_RunFrame, bAttach);
|
2024-05-07 16:05:57 +02:00
|
|
|
DetourSetup(&EbisuSDK_GetLanguage, &HEbisuSDK_GetLanguage, bAttach);
|
|
|
|
}
|