aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/miscserverscript.cpp
diff options
context:
space:
mode:
authorBobTheBob9 <for.oliver.kirkham@gmail.com>2022-07-07 21:31:41 +0100
committerBobTheBob9 <for.oliver.kirkham@gmail.com>2022-07-07 21:31:41 +0100
commit2ae34b67e36b8ba05132d481876eb4ed7a826283 (patch)
tree63f44c8e2dcdc959d7a5317a3a7b36efedbd7d38 /NorthstarDLL/miscserverscript.cpp
parent3406de7aaaf52cbef20b1549f2d7da0255d30f51 (diff)
downloadNorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.tar.gz
NorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.zip
almost fully replaced hooking lib
Diffstat (limited to 'NorthstarDLL/miscserverscript.cpp')
-rw-r--r--NorthstarDLL/miscserverscript.cpp130
1 files changed, 65 insertions, 65 deletions
diff --git a/NorthstarDLL/miscserverscript.cpp b/NorthstarDLL/miscserverscript.cpp
index 488e071a..32fd8a84 100644
--- a/NorthstarDLL/miscserverscript.cpp
+++ b/NorthstarDLL/miscserverscript.cpp
@@ -1,66 +1,66 @@
-#include "pch.h"
-#include "miscserverscript.h"
-#include "squirrel.h"
-#include "masterserver.h"
-#include "serverauthentication.h"
-#include "r2client.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;
-}
-
-// void function NSEarlyWritePlayerIndexPersistenceForLeave( int playerIndex )
-SQRESULT SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm)
-{
- int playerIndex = g_pServerSquirrel->getinteger(sqvm, 1);
- void* player = GetPlayerByIndex(playerIndex);
-
- if (!g_ServerAuthenticationManager->m_additionalPlayerData.count(player))
- {
- g_pServerSquirrel->raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
- return SQRESULT_ERROR;
- }
-
- g_ServerAuthenticationManager->m_additionalPlayerData[player].needPersistenceWriteOnLeave = false;
- g_ServerAuthenticationManager->WritePersistentData(player);
- return SQRESULT_NULL;
-}
-
-// bool function NSIsWritingPlayerPersistence()
-SQRESULT SQ_IsWritingPlayerPersistence(void* sqvm)
-{
- g_pServerSquirrel->pushbool(sqvm, g_MasterServerManager->m_bSavingPersistentData);
- return SQRESULT_NOTNULL;
-}
-
-// bool function NSIsPlayerIndexLocalPlayer( int playerIndex )
-SQRESULT SQ_IsPlayerIndexLocalPlayer(void* sqvm)
-{
- int playerIndex = g_pServerSquirrel->getinteger(sqvm, 1);
- void* player = GetPlayerByIndex(playerIndex);
- if (!g_ServerAuthenticationManager->m_additionalPlayerData.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));
- return SQRESULT_NOTNULL;
-}
-
-ON_DLL_LOAD_RELIESON("server.dll", MiscServerScriptCommands, ServerSquirrel, [](HMODULE baseAddress)
-{
- g_pServerSquirrel->AddFuncRegistration(
- "void", "NSEarlyWritePlayerIndexPersistenceForLeave", "int playerIndex", "", SQ_EarlyWritePlayerIndexPersistenceForLeave);
- g_pServerSquirrel->AddFuncRegistration("bool", "NSIsWritingPlayerPersistence", "", "", SQ_IsWritingPlayerPersistence);
- g_pServerSquirrel->AddFuncRegistration("bool", "NSIsPlayerIndexLocalPlayer", "int playerIndex", "", SQ_IsPlayerIndexLocalPlayer);
+#include "pch.h"
+#include "miscserverscript.h"
+#include "squirrel.h"
+#include "masterserver.h"
+#include "serverauthentication.h"
+#include "r2client.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;
+}
+
+// void function NSEarlyWritePlayerIndexPersistenceForLeave( int playerIndex )
+SQRESULT SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm)
+{
+ int playerIndex = g_pServerSquirrel->getinteger(sqvm, 1);
+ void* player = GetPlayerByIndex(playerIndex);
+
+ if (!g_ServerAuthenticationManager->m_additionalPlayerData.count(player))
+ {
+ g_pServerSquirrel->raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
+ return SQRESULT_ERROR;
+ }
+
+ g_ServerAuthenticationManager->m_additionalPlayerData[player].needPersistenceWriteOnLeave = false;
+ g_ServerAuthenticationManager->WritePersistentData(player);
+ return SQRESULT_NULL;
+}
+
+// bool function NSIsWritingPlayerPersistence()
+SQRESULT SQ_IsWritingPlayerPersistence(void* sqvm)
+{
+ g_pServerSquirrel->pushbool(sqvm, g_MasterServerManager->m_bSavingPersistentData);
+ return SQRESULT_NOTNULL;
+}
+
+// bool function NSIsPlayerIndexLocalPlayer( int playerIndex )
+SQRESULT SQ_IsPlayerIndexLocalPlayer(void* sqvm)
+{
+ int playerIndex = g_pServerSquirrel->getinteger(sqvm, 1);
+ void* player = GetPlayerByIndex(playerIndex);
+ if (!g_ServerAuthenticationManager->m_additionalPlayerData.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));
+ return SQRESULT_NOTNULL;
+}
+
+ON_DLL_LOAD_RELIESON("server.dll", MiscServerScriptCommands, ServerSquirrel, [](HMODULE baseAddress)
+{
+ g_pServerSquirrel->AddFuncRegistration(
+ "void", "NSEarlyWritePlayerIndexPersistenceForLeave", "int playerIndex", "", SQ_EarlyWritePlayerIndexPersistenceForLeave);
+ g_pServerSquirrel->AddFuncRegistration("bool", "NSIsWritingPlayerPersistence", "", "", SQ_IsWritingPlayerPersistence);
+ g_pServerSquirrel->AddFuncRegistration("bool", "NSIsPlayerIndexLocalPlayer", "int playerIndex", "", SQ_IsPlayerIndexLocalPlayer);
}) \ No newline at end of file