aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/miscserverscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/miscserverscript.cpp')
-rw-r--r--NorthstarDLL/miscserverscript.cpp31
1 files changed, 10 insertions, 21 deletions
diff --git a/NorthstarDLL/miscserverscript.cpp b/NorthstarDLL/miscserverscript.cpp
index 25a0cd1a..12ab5708 100644
--- a/NorthstarDLL/miscserverscript.cpp
+++ b/NorthstarDLL/miscserverscript.cpp
@@ -1,44 +1,33 @@
#include "pch.h"
-#include "miscserverscript.h"
#include "squirrel.h"
#include "masterserver.h"
#include "serverauthentication.h"
#include "r2client.h"
+#include "r2server.h"
-// annoying helper function because i can't figure out getting players or entities from sqvm rn
-// wish i didn't have to do it like this, but here we are
-void* GetPlayerByIndex(int playerIndex)
-{
- const int PLAYER_ARRAY_OFFSET = 0x12A53F90;
- const int PLAYER_SIZE = 0x2D728;
-
- void* playerArrayBase = (char*)GetModuleHandleA("engine.dll") + PLAYER_ARRAY_OFFSET;
- void* player = (char*)playerArrayBase + (playerIndex * PLAYER_SIZE);
-
- return player;
-}
+#include <filesystem>
// void function NSEarlyWritePlayerIndexPersistenceForLeave( int playerIndex )
SQRESULT SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm)
{
int playerIndex = g_pServerSquirrel->getinteger(sqvm, 1);
- void* player = GetPlayerByIndex(playerIndex);
+ R2::CBasePlayer* player = R2::UTIL_PlayerByIndex(playerIndex);
- if (!g_pServerAuthenticationManager->m_additionalPlayerData.count(player))
+ if (!g_pServerAuthentication->m_PlayerAuthenticationData.count(player))
{
g_pServerSquirrel->raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
return SQRESULT_ERROR;
}
- g_pServerAuthenticationManager->m_additionalPlayerData[player].needPersistenceWriteOnLeave = false;
- g_pServerAuthenticationManager->WritePersistentData(player);
+ g_pServerAuthentication->m_PlayerAuthenticationData[player].needPersistenceWriteOnLeave = false;
+ g_pServerAuthentication->WritePersistentData(player);
return SQRESULT_NULL;
}
// bool function NSIsWritingPlayerPersistence()
SQRESULT SQ_IsWritingPlayerPersistence(void* sqvm)
{
- g_pServerSquirrel->pushbool(sqvm, g_MasterServerManager->m_bSavingPersistentData);
+ g_pServerSquirrel->pushbool(sqvm, g_pMasterServerManager->m_bSavingPersistentData);
return SQRESULT_NOTNULL;
}
@@ -46,14 +35,14 @@ SQRESULT SQ_IsWritingPlayerPersistence(void* sqvm)
SQRESULT SQ_IsPlayerIndexLocalPlayer(void* sqvm)
{
int playerIndex = g_pServerSquirrel->getinteger(sqvm, 1);
- void* player = GetPlayerByIndex(playerIndex);
- if (!g_pServerAuthenticationManager->m_additionalPlayerData.count(player))
+ R2::CBasePlayer* player = R2::UTIL_PlayerByIndex(playerIndex);
+ if (!g_pServerAuthentication->m_PlayerAuthenticationData.count(player))
{
g_pServerSquirrel->raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
return SQRESULT_ERROR;
}
- g_pServerSquirrel->pushbool(sqvm, !strcmp(R2::g_pLocalPlayerUserID, (char*)player + 0xF500));
+ g_pServerSquirrel->pushbool(sqvm, !strcmp(R2::g_pLocalPlayerUserID, player->m_UID));
return SQRESULT_NOTNULL;
}