r5sdk/r5dev/ebisusdk/EbisuSDK.cpp
Kawe Mazidjatari 0c25246f91 Check if dedicated using global
Global instead of directive as the ebisusdk lib is used for both the server and client. Removed useless directives.
2023-05-13 19:41:57 +02:00

66 lines
1.8 KiB
C++

#include "core/stdafx.h"
#include "tier1/cvar.h"
#include "ebisusdk/EbisuSDK.h"
#include "engine/server/sv_main.h"
//-----------------------------------------------------------------------------
// Purpose: sets the EbisuSDK globals for dedicated to satisfy command callbacks
//-----------------------------------------------------------------------------
void HEbisuSDK_Init()
{
if (*s_bIsDedicated)
{
*g_EbisuSDKInit = true; // <- 1st EbisuSDK
*g_EbisuProfileInit = true; // <- 2nd EbisuSDK
*g_NucleusID = 9990000; // <- 3rd EbisuSDK
}
}
//-----------------------------------------------------------------------------
// Purpose: checks if the EbisuSDK is initialized
// Output : true on success, false on failure
//-----------------------------------------------------------------------------
bool IsOriginInitialized()
{
if (*s_bIsDedicated)
{
return true;
}
else if ((!(*g_OriginErrorLevel)
&& (*g_EbisuSDKInit)
&& (*g_NucleusID)
&& (*g_EbisuProfileInit)))
// && (*g_OriginAuthCode)
// && (g_NucleusToken[0])))
{
return true;
}
return false;
}
//-----------------------------------------------------------------------------
// Purpose: validates if client's persona name meets EA's criteria
// Input : *pszName -
// Output : true on success, false on failure
//-----------------------------------------------------------------------------
bool IsValidPersonaName(const char* pszName)
{
if (!sv_validatePersonaName->GetBool())
{
return true;
}
size_t len = strlen(pszName);
if (len < sv_minPersonaNameLength->GetInt() ||
len > sv_maxPersonaNameLength->GetInt())
{
return false;
}
// Check if the name contains any special characters.
size_t pos = strspn(pszName, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
return pszName[pos] == '\0';
}