aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/plugins.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/plugins.cpp')
-rw-r--r--NorthstarDLL/plugins.cpp96
1 files changed, 49 insertions, 47 deletions
diff --git a/NorthstarDLL/plugins.cpp b/NorthstarDLL/plugins.cpp
index 57701fcd..790439d1 100644
--- a/NorthstarDLL/plugins.cpp
+++ b/NorthstarDLL/plugins.cpp
@@ -1,9 +1,11 @@
#include "pch.h"
#include "squirrel.h"
#include "plugins.h"
-#include <chrono>
#include "masterserver.h"
#include "convar.h"
+#include "serverpresence.h"
+
+#include <chrono>
#include <windows.h>
/// <summary>
@@ -109,31 +111,31 @@ void initGameState()
}
// string gamemode, string gamemodeName, string map, string mapName, bool connected, bool loading
-SQRESULT SQ_UpdateGameStateUI(void* sqvm)
+SQRESULT SQ_UpdateGameStateUI(HSquirrelVM* sqvm)
{
AcquireSRWLockExclusive(&gameStateLock);
- gameState.map = ClientSq_getstring(sqvm, 1);
- gameState.mapDisplayName = ClientSq_getstring(sqvm, 2);
- gameState.playlist = ClientSq_getstring(sqvm, 3);
- gameState.playlistDisplayName = ClientSq_getstring(sqvm, 4);
- gameState.connected = ClientSq_getbool(sqvm, 5);
- gameState.loading = ClientSq_getbool(sqvm, 6);
+ gameState.map = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1);
+ gameState.mapDisplayName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 2);
+ gameState.playlist = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 3);
+ gameState.playlistDisplayName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 4);
+ gameState.connected = g_pSquirrel<ScriptContext::UI>->getbool(sqvm, 5);
+ gameState.loading = g_pSquirrel<ScriptContext::UI>->getbool(sqvm, 6);
ReleaseSRWLockExclusive(&gameStateLock);
return SQRESULT_NOTNULL;
}
// int playerCount, int outScore, int secondHighestScore, int highestScore, bool roundBased, int scoreLimit
-SQRESULT SQ_UpdateGameStateClient(void* sqvm)
+SQRESULT SQ_UpdateGameStateClient(HSquirrelVM* sqvm)
{
AcquireSRWLockExclusive(&gameStateLock);
AcquireSRWLockExclusive(&serverInfoLock);
- gameState.players = ClientSq_getinteger(sqvm, 1);
- serverInfo.maxPlayers = ClientSq_getinteger(sqvm, 2);
- gameState.ourScore = ClientSq_getinteger(sqvm, 3);
- gameState.secondHighestScore = ClientSq_getinteger(sqvm, 4);
- gameState.highestScore = ClientSq_getinteger(sqvm, 5);
- serverInfo.roundBased = ClientSq_getbool(sqvm, 6);
- serverInfo.scoreLimit = ClientSq_getbool(sqvm, 7);
+ gameState.players = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 1);
+ serverInfo.maxPlayers = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 2);
+ gameState.ourScore = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 3);
+ gameState.secondHighestScore = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 4);
+ gameState.highestScore = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 5);
+ serverInfo.roundBased = g_pSquirrel<ScriptContext::CLIENT>->getbool(sqvm, 6);
+ serverInfo.scoreLimit = g_pSquirrel<ScriptContext::CLIENT>->getbool(sqvm, 7);
ReleaseSRWLockExclusive(&gameStateLock);
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
@@ -141,59 +143,59 @@ SQRESULT SQ_UpdateGameStateClient(void* sqvm)
// string id, string name, string password, int players, int maxPlayers, string map, string mapDisplayName, string playlist, string
// playlistDisplayName
-SQRESULT SQ_UpdateServerInfo(void* sqvm)
+SQRESULT SQ_UpdateServerInfo(HSquirrelVM* sqvm)
{
AcquireSRWLockExclusive(&gameStateLock);
AcquireSRWLockExclusive(&serverInfoLock);
- serverInfo.id = ClientSq_getstring(sqvm, 1);
- serverInfo.name = ClientSq_getstring(sqvm, 2);
- serverInfo.password = ClientSq_getstring(sqvm, 3);
- gameState.players = ClientSq_getinteger(sqvm, 4);
- serverInfo.maxPlayers = ClientSq_getinteger(sqvm, 5);
- gameState.map = ClientSq_getstring(sqvm, 6);
- gameState.mapDisplayName = ClientSq_getstring(sqvm, 7);
- gameState.playlist = ClientSq_getstring(sqvm, 8);
- gameState.playlistDisplayName = ClientSq_getstring(sqvm, 9);
+ serverInfo.id = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 1);
+ serverInfo.name = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 2);
+ serverInfo.password = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 3);
+ gameState.players = g_pSquirrel<ScriptContext::UI>->getinteger(sqvm, 4);
+ serverInfo.maxPlayers = g_pSquirrel<ScriptContext::UI>->getinteger(sqvm, 5);
+ gameState.map = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 6);
+ gameState.mapDisplayName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 7);
+ gameState.playlist = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 8);
+ gameState.playlistDisplayName = g_pSquirrel<ScriptContext::UI>->getstring(sqvm, 9);
ReleaseSRWLockExclusive(&gameStateLock);
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
}
// int maxPlayers
-SQRESULT SQ_UpdateServerInfoBetweenRounds(void* sqvm)
+SQRESULT SQ_UpdateServerInfoBetweenRounds(HSquirrelVM* sqvm)
{
AcquireSRWLockExclusive(&serverInfoLock);
- serverInfo.id = ClientSq_getstring(sqvm, 1);
- serverInfo.name = ClientSq_getstring(sqvm, 2);
- serverInfo.password = ClientSq_getstring(sqvm, 3);
- serverInfo.maxPlayers = ClientSq_getinteger(sqvm, 4);
+ serverInfo.id = g_pSquirrel<ScriptContext::CLIENT>->getstring(sqvm, 1);
+ serverInfo.name = g_pSquirrel<ScriptContext::CLIENT>->getstring(sqvm, 2);
+ serverInfo.password = g_pSquirrel<ScriptContext::CLIENT>->getstring(sqvm, 3);
+ serverInfo.maxPlayers = g_pSquirrel<ScriptContext::CLIENT>->getinteger(sqvm, 4);
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
}
// float timeInFuture
-SQRESULT SQ_UpdateTimeInfo(void* sqvm)
+SQRESULT SQ_UpdateTimeInfo(HSquirrelVM* sqvm)
{
AcquireSRWLockExclusive(&serverInfoLock);
- serverInfo.endTime = ceil(ClientSq_getfloat(sqvm, 1));
+ serverInfo.endTime = ceil(g_pSquirrel<ScriptContext::CLIENT>->getfloat(sqvm, 1));
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
}
// bool loading
-SQRESULT SQ_SetConnected(void* sqvm)
+SQRESULT SQ_SetConnected(HSquirrelVM* sqvm)
{
AcquireSRWLockExclusive(&gameStateLock);
- gameState.loading = ClientSq_getbool(sqvm, 1);
+ gameState.loading = g_pSquirrel<ScriptContext::UI>->getbool(sqvm, 1);
ReleaseSRWLockExclusive(&gameStateLock);
return SQRESULT_NOTNULL;
}
-SQRESULT SQ_UpdateListenServer(void* sqvm)
+SQRESULT SQ_UpdateListenServer(HSquirrelVM* sqvm)
{
AcquireSRWLockExclusive(&serverInfoLock);
- serverInfo.id = g_MasterServerManager->m_sOwnServerId;
- serverInfo.password = Cvar_ns_server_password->GetString();
+ serverInfo.id = g_pMasterServerManager->m_sOwnServerId;
+ serverInfo.password = ""; // g_pServerPresence->Cvar_ns_server_password->GetString(); todo this fr
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
}
@@ -384,26 +386,26 @@ int getPlayerInfoBool(bool* out_ptr, PlayerInfoType var)
return n;
}
-void InitialisePluginCommands(HMODULE baseAddress)
+ON_DLL_LOAD_CLIENT_RELIESON("client.dll", PluginCommands, ClientSquirrel, (CModule module))
{
// i swear there's a way to make this not have be run in 2 contexts but i can't figure it out
// some funcs i need are just not available in UI or CLIENT
- if (g_UISquirrelManager && g_ClientSquirrelManager)
+ if (g_pSquirrel<ScriptContext::UI> && g_pSquirrel<ScriptContext::CLIENT>)
{
- g_UISquirrelManager->AddFuncRegistration(
+ g_pSquirrel<ScriptContext::UI>->AddFuncRegistration(
"void",
"NSUpdateGameStateUI",
"string gamemode, string gamemodeName, string map, string mapName, bool connected, bool loading",
"",
SQ_UpdateGameStateUI);
- g_ClientSquirrelManager->AddFuncRegistration(
+ g_pSquirrel<ScriptContext::CLIENT>->AddFuncRegistration(
"void",
"NSUpdateGameStateClient",
"int playerCount, int maxPlayers, int outScore, int secondHighestScore, int highestScore, bool roundBased, int scoreLimit",
"",
SQ_UpdateGameStateClient);
- g_UISquirrelManager->AddFuncRegistration(
+ g_pSquirrel<ScriptContext::UI>->AddFuncRegistration(
"void",
"NSUpdateServerInfo",
"string id, string name, string password, int players, int maxPlayers, string map, string mapDisplayName, string playlist, "
@@ -411,10 +413,10 @@ void InitialisePluginCommands(HMODULE baseAddress)
"playlistDisplayName",
"",
SQ_UpdateServerInfo);
- g_ClientSquirrelManager->AddFuncRegistration(
+ g_pSquirrel<ScriptContext::CLIENT>->AddFuncRegistration(
"void", "NSUpdateServerInfoReload", "int maxPlayers", "", SQ_UpdateServerInfoBetweenRounds);
- g_ClientSquirrelManager->AddFuncRegistration("void", "NSUpdateTimeInfo", "float timeInFuture", "", SQ_UpdateTimeInfo);
- g_UISquirrelManager->AddFuncRegistration("void", "NSSetLoading", "bool loading", "", SQ_SetConnected);
- g_UISquirrelManager->AddFuncRegistration("void", "NSUpdateListenServer", "", "", SQ_UpdateListenServer);
+ g_pSquirrel<ScriptContext::CLIENT>->AddFuncRegistration("void", "NSUpdateTimeInfo", "float timeInFuture", "", SQ_UpdateTimeInfo);
+ g_pSquirrel<ScriptContext::UI>->AddFuncRegistration("void", "NSSetLoading", "bool loading", "", SQ_SetConnected);
+ g_pSquirrel<ScriptContext::UI>->AddFuncRegistration("void", "NSUpdateListenServer", "", "", SQ_UpdateListenServer);
}
}