aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/miscserverscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/miscserverscript.cpp')
-rw-r--r--NorthstarDLL/miscserverscript.cpp119
1 files changed, 64 insertions, 55 deletions
diff --git a/NorthstarDLL/miscserverscript.cpp b/NorthstarDLL/miscserverscript.cpp
index d41c4afe..83d68ea1 100644
--- a/NorthstarDLL/miscserverscript.cpp
+++ b/NorthstarDLL/miscserverscript.cpp
@@ -1,55 +1,64 @@
-#include "pch.h"
-#include "squirrel.h"
-#include "masterserver.h"
-#include "serverauthentication.h"
-#include "r2client.h"
-#include "r2server.h"
-
-#include <filesystem>
-
-// void function NSEarlyWritePlayerIndexPersistenceForLeave( int playerIndex )
-SQRESULT SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm)
-{
- int playerIndex = g_pServerSquirrel->getinteger(sqvm, 1);
- R2::CBaseClient* player = &R2::g_pClientArray[playerIndex];
-
- if (!g_pServerAuthentication->m_PlayerAuthenticationData.count(player))
- {
- g_pServerSquirrel->raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
- return SQRESULT_ERROR;
- }
-
- 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_pMasterServerManager->m_bSavingPersistentData);
- return SQRESULT_NOTNULL;
-}
-
-// bool function NSIsPlayerIndexLocalPlayer( int playerIndex )
-SQRESULT SQ_IsPlayerIndexLocalPlayer(void* sqvm)
-{
- int playerIndex = g_pServerSquirrel->getinteger(sqvm, 1);
- R2::CBaseClient* player = &R2::g_pClientArray[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, player->m_UID));
- return SQRESULT_NOTNULL;
-}
-
-ON_DLL_LOAD_RELIESON("server.dll", MiscServerScriptCommands, ServerSquirrel, (CModule module))
-{
- 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
+#include "pch.h"
+#include "squirrel.h"
+#include "masterserver.h"
+#include "serverauthentication.h"
+#include "dedicated.h"
+#include "r2client.h"
+#include "r2server.h"
+
+#include <filesystem>
+
+// void function NSEarlyWritePlayerIndexPersistenceForLeave( int playerIndex )
+SQRESULT SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm)
+{
+ int playerIndex = g_pSquirrel<ScriptContext::SERVER>->getinteger(sqvm, 1);
+ R2::CBaseClient* player = &R2::g_pClientArray[playerIndex];
+
+ if (!g_pServerAuthentication->m_PlayerAuthenticationData.count(player))
+ {
+ g_pSquirrel<ScriptContext::SERVER>->raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
+ return SQRESULT_ERROR;
+ }
+
+ g_pServerAuthentication->m_PlayerAuthenticationData[player].needPersistenceWriteOnLeave = false;
+ g_pServerAuthentication->WritePersistentData(player);
+ return SQRESULT_NULL;
+}
+
+// bool function NSIsWritingPlayerPersistence()
+SQRESULT SQ_IsWritingPlayerPersistence(void* sqvm)
+{
+ g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, g_pMasterServerManager->m_bSavingPersistentData);
+ return SQRESULT_NOTNULL;
+}
+
+// bool function NSIsPlayerIndexLocalPlayer( int playerIndex )
+SQRESULT SQ_IsPlayerIndexLocalPlayer(void* sqvm)
+{
+ int playerIndex = g_pSquirrel<ScriptContext::SERVER>->getinteger(sqvm, 1);
+ R2::CBaseClient* player = &R2::g_pClientArray[playerIndex];
+ if (!g_pServerAuthentication->m_PlayerAuthenticationData.count(player))
+ {
+ g_pSquirrel<ScriptContext::SERVER>->raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
+ return SQRESULT_ERROR;
+ }
+
+ g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, !strcmp(R2::g_pLocalPlayerUserID, player->m_UID));
+ return SQRESULT_NOTNULL;
+}
+
+// bool function NSIsDedicated()
+SQRESULT SQ_IsDedicated(void* sqvm)
+{
+ g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, IsDedicatedServer());
+ return SQRESULT_NOTNULL;
+}
+
+ON_DLL_LOAD_RELIESON("server.dll", MiscServerScriptCommands, ServerSquirrel, (CModule module))
+{
+ g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration(
+ "void", "NSEarlyWritePlayerIndexPersistenceForLeave", "int playerIndex", "", SQ_EarlyWritePlayerIndexPersistenceForLeave);
+ g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration("bool", "NSIsWritingPlayerPersistence", "", "", SQ_IsWritingPlayerPersistence);
+ g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration("bool", "NSIsPlayerIndexLocalPlayer", "int playerIndex", "", SQ_IsPlayerIndexLocalPlayer);
+ g_pSquirrel<ScriptContext::SERVER>->AddFuncRegistration("bool", "NSIsDedicated", "", "", SQ_IsDedicated);
+}