aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/server/auth
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/server/auth')
-rw-r--r--NorthstarDLL/server/auth/bansystem.cpp8
-rw-r--r--NorthstarDLL/server/auth/serverauthentication.cpp46
-rw-r--r--NorthstarDLL/server/auth/serverauthentication.h16
3 files changed, 35 insertions, 35 deletions
diff --git a/NorthstarDLL/server/auth/bansystem.cpp b/NorthstarDLL/server/auth/bansystem.cpp
index 9b9d24c4..a45cde93 100644
--- a/NorthstarDLL/server/auth/bansystem.cpp
+++ b/NorthstarDLL/server/auth/bansystem.cpp
@@ -173,7 +173,7 @@ void ServerBanSystem::UnbanUID(uint64_t uid)
bool ServerBanSystem::IsUIDAllowed(uint64_t uid)
{
- uint64_t localPlayerUserID = strtoull(R2::g_pLocalPlayerUserID, nullptr, 10);
+ uint64_t localPlayerUserID = strtoull(g_pLocalPlayerUserID, nullptr, 10);
if (localPlayerUserID == uid)
return true;
@@ -186,14 +186,14 @@ void ConCommand_ban(const CCommand& args)
if (args.ArgC() < 2)
return;
- for (int i = 0; i < R2::g_pGlobals->m_nMaxClients; i++)
+ for (int i = 0; i < g_pGlobals->m_nMaxClients; i++)
{
- R2::CBaseClient* player = &R2::g_pClientArray[i];
+ CBaseClient* player = &g_pClientArray[i];
if (!strcmp(player->m_Name, args.Arg(1)) || !strcmp(player->m_UID, args.Arg(1)))
{
g_pBanSystem->BanUID(strtoull(player->m_UID, nullptr, 10));
- R2::CBaseClient__Disconnect(player, 1, "Banned from server");
+ CBaseClient__Disconnect(player, 1, "Banned from server");
break;
}
}
diff --git a/NorthstarDLL/server/auth/serverauthentication.cpp b/NorthstarDLL/server/auth/serverauthentication.cpp
index d5653dcc..0d46426f 100644
--- a/NorthstarDLL/server/auth/serverauthentication.cpp
+++ b/NorthstarDLL/server/auth/serverauthentication.cpp
@@ -40,7 +40,7 @@ void ServerAuthenticationManager::AddRemotePlayer(std::string token, uint64_t ui
m_RemoteAuthenticationData[token] = newAuthData;
}
-void ServerAuthenticationManager::AddPlayer(R2::CBaseClient* pPlayer, const char* pToken)
+void ServerAuthenticationManager::AddPlayer(CBaseClient* pPlayer, const char* pToken)
{
PlayerAuthenticationData additionalData;
@@ -48,14 +48,14 @@ void ServerAuthenticationManager::AddPlayer(R2::CBaseClient* pPlayer, const char
if (remoteAuthData != m_RemoteAuthenticationData.end())
additionalData.pdataSize = remoteAuthData->second.pdataSize;
else
- additionalData.pdataSize = R2::PERSISTENCE_MAX_SIZE;
+ additionalData.pdataSize = PERSISTENCE_MAX_SIZE;
- additionalData.usingLocalPdata = pPlayer->m_iPersistenceReady == R2::ePersistenceReady::READY_INSECURE;
+ additionalData.usingLocalPdata = pPlayer->m_iPersistenceReady == ePersistenceReady::READY_INSECURE;
m_PlayerAuthenticationData.insert(std::make_pair(pPlayer, additionalData));
}
-void ServerAuthenticationManager::RemovePlayer(R2::CBaseClient* pPlayer)
+void ServerAuthenticationManager::RemovePlayer(CBaseClient* pPlayer)
{
if (m_PlayerAuthenticationData.count(pPlayer))
m_PlayerAuthenticationData.erase(pPlayer);
@@ -88,20 +88,20 @@ bool ServerAuthenticationManager::VerifyPlayerName(const char* pAuthToken, const
return true;
}
-bool ServerAuthenticationManager::IsDuplicateAccount(R2::CBaseClient* pPlayer, const char* pPlayerUid)
+bool ServerAuthenticationManager::IsDuplicateAccount(CBaseClient* pPlayer, const char* pPlayerUid)
{
if (m_bAllowDuplicateAccounts)
return false;
bool bHasUidPlayer = false;
- for (int i = 0; i < R2::g_pGlobals->m_nMaxClients; i++)
- if (&R2::g_pClientArray[i] != pPlayer && !strcmp(pPlayerUid, R2::g_pClientArray[i].m_UID))
+ for (int i = 0; i < g_pGlobals->m_nMaxClients; i++)
+ if (&g_pClientArray[i] != pPlayer && !strcmp(pPlayerUid, g_pClientArray[i].m_UID))
return true;
return false;
}
-bool ServerAuthenticationManager::CheckAuthentication(R2::CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken)
+bool ServerAuthenticationManager::CheckAuthentication(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken)
{
std::string sUid = std::to_string(iUid);
@@ -111,7 +111,7 @@ bool ServerAuthenticationManager::CheckAuthentication(R2::CBaseClient* pPlayer,
return true;
// local server that doesn't need auth (probably sp) and local player
- if (m_bStartingLocalSPGame && !strcmp(sUid.c_str(), R2::g_pLocalPlayerUserID))
+ if (m_bStartingLocalSPGame && !strcmp(sUid.c_str(), g_pLocalPlayerUserID))
return true;
// don't allow duplicate accounts
@@ -126,7 +126,7 @@ bool ServerAuthenticationManager::CheckAuthentication(R2::CBaseClient* pPlayer,
return false;
}
-void ServerAuthenticationManager::AuthenticatePlayer(R2::CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken)
+void ServerAuthenticationManager::AuthenticatePlayer(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken)
{
// for bot players, generate a new uid
if (pPlayer->m_bFakePlayer)
@@ -142,31 +142,31 @@ void ServerAuthenticationManager::AuthenticatePlayer(R2::CBaseClient* pPlayer, u
if (authData != m_RemoteAuthenticationData.end())
{
// if we're resetting let script handle the reset with InitPersistentData() on connect
- if (!m_bForceResetLocalPlayerPersistence || strcmp(sUid.c_str(), R2::g_pLocalPlayerUserID))
+ if (!m_bForceResetLocalPlayerPersistence || strcmp(sUid.c_str(), g_pLocalPlayerUserID))
{
// copy pdata into buffer
memcpy(pPlayer->m_PersistenceBuffer, authData->second.pdata, authData->second.pdataSize);
}
// set persistent data as ready
- pPlayer->m_iPersistenceReady = R2::ePersistenceReady::READY_REMOTE;
+ pPlayer->m_iPersistenceReady = ePersistenceReady::READY_REMOTE;
}
// we probably allow insecure at this point, but make sure not to write anyway if not insecure
else if (Cvar_ns_auth_allow_insecure->GetBool() || pPlayer->m_bFakePlayer)
{
// set persistent data as ready
// note: actual placeholder persistent data is populated in script with InitPersistentData()
- pPlayer->m_iPersistenceReady = R2::ePersistenceReady::READY_INSECURE;
+ pPlayer->m_iPersistenceReady = ePersistenceReady::READY_INSECURE;
}
}
-bool ServerAuthenticationManager::RemovePlayerAuthData(R2::CBaseClient* pPlayer)
+bool ServerAuthenticationManager::RemovePlayerAuthData(CBaseClient* pPlayer)
{
if (!Cvar_ns_erase_auth_info->GetBool()) // keep auth data forever
return false;
// hack for special case where we're on a local server, so we erase our own newly created auth data on disconnect
- if (m_bNeedLocalAuthForNewgame && !strcmp(pPlayer->m_UID, R2::g_pLocalPlayerUserID))
+ if (m_bNeedLocalAuthForNewgame && !strcmp(pPlayer->m_UID, g_pLocalPlayerUserID))
return false;
// we don't have our auth token at this point, so lookup authdata by uid
@@ -187,9 +187,9 @@ bool ServerAuthenticationManager::RemovePlayerAuthData(R2::CBaseClient* pPlayer)
return false;
}
-void ServerAuthenticationManager::WritePersistentData(R2::CBaseClient* pPlayer)
+void ServerAuthenticationManager::WritePersistentData(CBaseClient* pPlayer)
{
- if (pPlayer->m_iPersistenceReady == R2::ePersistenceReady::READY_REMOTE)
+ if (pPlayer->m_iPersistenceReady == ePersistenceReady::READY_REMOTE)
{
g_pMasterServerManager->WritePlayerPersistentData(
pPlayer->m_UID, (const char*)pPlayer->m_PersistenceBuffer, m_PlayerAuthenticationData[pPlayer].pdataSize);
@@ -240,7 +240,7 @@ ConVar* Cvar_ns_allowuserclantags;
// clang-format off
AUTOHOOK(CBaseClient__Connect, engine.dll + 0x101740,
-bool,, (R2::CBaseClient* self, char* pName, void* pNetChannel, char bFakePlayer, void* a5, char pDisconnectReason[256], void* a7))
+bool,, (CBaseClient* self, char* pName, void* pNetChannel, char bFakePlayer, void* a5, char pDisconnectReason[256], void* a7))
// clang-format on
{
const char* pAuthenticationFailure = nullptr;
@@ -281,13 +281,13 @@ bool,, (R2::CBaseClient* self, char* pName, void* pNetChannel, char bFakePlayer,
// clang-format off
AUTOHOOK(CBaseClient__ActivatePlayer, engine.dll + 0x100F80,
-void,, (R2::CBaseClient* self))
+void,, (CBaseClient* self))
// clang-format on
{
// if we're authed, write our persistent data
// RemovePlayerAuthData returns true if it removed successfully, i.e. on first call only, and we only want to write on >= second call
// (since this func is called on map loads)
- if (self->m_iPersistenceReady >= R2::ePersistenceReady::READY && !g_pServerAuthentication->RemovePlayerAuthData(self))
+ if (self->m_iPersistenceReady >= ePersistenceReady::READY && !g_pServerAuthentication->RemovePlayerAuthData(self))
{
g_pServerAuthentication->m_bForceResetLocalPlayerPersistence = false;
g_pServerAuthentication->WritePersistentData(self);
@@ -299,7 +299,7 @@ void,, (R2::CBaseClient* self))
// clang-format off
AUTOHOOK(_CBaseClient__Disconnect, engine.dll + 0x1012C0,
-void,, (R2::CBaseClient* self, uint32_t unknownButAlways1, const char* pReason, ...))
+void,, (CBaseClient* self, uint32_t unknownButAlways1, const char* pReason, ...))
// clang-format on
{
// have to manually format message because can't pass varargs to original func
@@ -333,7 +333,7 @@ void,, (R2::CBaseClient* self, uint32_t unknownButAlways1, const char* pReason,
void ConCommand_ns_resetpersistence(const CCommand& args)
{
- if (*R2::g_pServerState == R2::server_state_t::ss_active)
+ if (*g_pServerState == server_state_t::ss_active)
{
spdlog::error("ns_resetpersistence must be entered from the main menu");
return;
@@ -370,7 +370,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", ServerAuthentication, (ConCommand, ConVar), (
CBaseServer__RejectConnection = module.Offset(0x1182E0).RCast<CBaseServer__RejectConnectionType>();
- if (Tier0::CommandLine()->CheckParm("-allowdupeaccounts"))
+ if (CommandLine()->CheckParm("-allowdupeaccounts"))
{
// patch to allow same of multiple account
module.Offset(0x114510).Patch("EB");
diff --git a/NorthstarDLL/server/auth/serverauthentication.h b/NorthstarDLL/server/auth/serverauthentication.h
index dd0e13af..32e1d0a8 100644
--- a/NorthstarDLL/server/auth/serverauthentication.h
+++ b/NorthstarDLL/server/auth/serverauthentication.h
@@ -33,7 +33,7 @@ class ServerAuthenticationManager
std::mutex m_AuthDataMutex;
std::unordered_map<std::string, RemoteAuthData> m_RemoteAuthenticationData;
- std::unordered_map<R2::CBaseClient*, PlayerAuthenticationData> m_PlayerAuthenticationData;
+ std::unordered_map<CBaseClient*, PlayerAuthenticationData> m_PlayerAuthenticationData;
bool m_bAllowDuplicateAccounts = false;
bool m_bNeedLocalAuthForNewgame = false;
@@ -43,16 +43,16 @@ class ServerAuthenticationManager
public:
void AddRemotePlayer(std::string token, uint64_t uid, std::string username, std::string pdata);
- void AddPlayer(R2::CBaseClient* pPlayer, const char* pAuthToken);
- void RemovePlayer(R2::CBaseClient* pPlayer);
+ void AddPlayer(CBaseClient* pPlayer, const char* pAuthToken);
+ void RemovePlayer(CBaseClient* pPlayer);
bool VerifyPlayerName(const char* pAuthToken, const char* pName, char pOutVerifiedName[64]);
- bool IsDuplicateAccount(R2::CBaseClient* pPlayer, const char* pUid);
- bool CheckAuthentication(R2::CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken);
+ bool IsDuplicateAccount(CBaseClient* pPlayer, const char* pUid);
+ bool CheckAuthentication(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken);
- void AuthenticatePlayer(R2::CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken);
- bool RemovePlayerAuthData(R2::CBaseClient* pPlayer);
- void WritePersistentData(R2::CBaseClient* pPlayer);
+ void AuthenticatePlayer(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken);
+ bool RemovePlayerAuthData(CBaseClient* pPlayer);
+ void WritePersistentData(CBaseClient* pPlayer);
};
extern ServerAuthenticationManager* g_pServerAuthentication;