From 037113d4b8032cd3715d879c2f4b08f66fa2be43 Mon Sep 17 00:00:00 2001
From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
Date: Mon, 9 May 2022 03:48:14 +0100
Subject: move sqvm funcs to sq managers
---
.../NorthstarDedicatedTest.vcxproj.filters | 12 +-
NorthstarDedicatedTest/clientchathooks.cpp | 12 +-
NorthstarDedicatedTest/miscserverscript.cpp | 12 +-
NorthstarDedicatedTest/plugins.cpp | 56 +++----
NorthstarDedicatedTest/scriptmainmenupromos.cpp | 30 ++--
NorthstarDedicatedTest/scriptmodmenu.cpp | 42 ++---
NorthstarDedicatedTest/scriptserverbrowser.cpp | 96 ++++++------
NorthstarDedicatedTest/serverchathooks.cpp | 20 +--
NorthstarDedicatedTest/squirrel.cpp | 135 ++++++----------
NorthstarDedicatedTest/squirrel.h | 169 +++++++--------------
10 files changed, 241 insertions(+), 343 deletions(-)
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index 686493f8..23e406a3 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -82,9 +82,6 @@
{d1f93d1e-0ecb-44fe-a277-d3e75aec2570}
-
- {14fc0931-acad-46ec-a55e-94f4469d4235}
-
{3d41d3fc-8a3b-4358-b3e8-4f06dc96abfe}
@@ -133,6 +130,9 @@
{947835db-67d6-42c0-870d-62743f85231f}
+
+ {14fc0931-acad-46ec-a55e-94f4469d4235}
+
@@ -1560,7 +1560,7 @@
Source Files\Shared
- Source Files\Shared\Mods\Compiled
+ Source Files\Shared\Mods\Compiled Assets
Source Files\Server\Authentication
@@ -1572,7 +1572,7 @@
Source Files\Client
- Source Files\Shared\Mods\Compiled
+ Source Files\Shared\Mods\Compiled Assets
Source Files\Shared
@@ -1599,7 +1599,7 @@
Source Files\Server
- Source Files\Shared\Mods\Compiled
+ Source Files\Shared\Mods\Compiled Assets
Source Files\Client
diff --git a/NorthstarDedicatedTest/clientchathooks.cpp b/NorthstarDedicatedTest/clientchathooks.cpp
index ef40c634..b6cf56ac 100644
--- a/NorthstarDedicatedTest/clientchathooks.cpp
+++ b/NorthstarDedicatedTest/clientchathooks.cpp
@@ -58,8 +58,8 @@ static void CHudChat__AddGameLineHook(void* self, const char* message, int inbox
// void NSChatWrite( int context, string str )
static SQRESULT SQ_ChatWrite(void* sqvm)
{
- int context = ClientSq_getinteger(sqvm, 1);
- const char* str = ClientSq_getstring(sqvm, 2);
+ int context = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
+ const char* str = g_ClientSquirrelManager->sq_getstring(sqvm, 2);
LocalChatWriter((LocalChatWriter::Context)context).Write(str);
return SQRESULT_NOTNULL;
@@ -68,8 +68,8 @@ static SQRESULT SQ_ChatWrite(void* sqvm)
// void NSChatWriteRaw( int context, string str )
static SQRESULT SQ_ChatWriteRaw(void* sqvm)
{
- int context = ClientSq_getinteger(sqvm, 1);
- const char* str = ClientSq_getstring(sqvm, 2);
+ int context = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
+ const char* str = g_ClientSquirrelManager->sq_getstring(sqvm, 2);
LocalChatWriter((LocalChatWriter::Context)context).InsertText(str);
return SQRESULT_NOTNULL;
@@ -78,8 +78,8 @@ static SQRESULT SQ_ChatWriteRaw(void* sqvm)
// void NSChatWriteLine( int context, string str )
static SQRESULT SQ_ChatWriteLine(void* sqvm)
{
- int context = ClientSq_getinteger(sqvm, 1);
- const char* str = ClientSq_getstring(sqvm, 2);
+ int context = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
+ const char* str = g_ClientSquirrelManager->sq_getstring(sqvm, 2);
LocalChatWriter((LocalChatWriter::Context)context).WriteLine(str);
return SQRESULT_NOTNULL;
diff --git a/NorthstarDedicatedTest/miscserverscript.cpp b/NorthstarDedicatedTest/miscserverscript.cpp
index 0f66d386..3c32ad1c 100644
--- a/NorthstarDedicatedTest/miscserverscript.cpp
+++ b/NorthstarDedicatedTest/miscserverscript.cpp
@@ -22,12 +22,12 @@ void* GetPlayerByIndex(int playerIndex)
// void function NSEarlyWritePlayerIndexPersistenceForLeave( int playerIndex )
SQRESULT SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm)
{
- int playerIndex = ServerSq_getinteger(sqvm, 1);
+ int playerIndex = g_ServerSquirrelManager->sq_getinteger(sqvm, 1);
void* player = GetPlayerByIndex(playerIndex);
if (!g_ServerAuthenticationManager->m_additionalPlayerData.count(player))
{
- ServerSq_pusherror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
+ g_ServerSquirrelManager->sq_raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
return SQRESULT_ERROR;
}
@@ -39,22 +39,22 @@ SQRESULT SQ_EarlyWritePlayerIndexPersistenceForLeave(void* sqvm)
// bool function NSIsWritingPlayerPersistence()
SQRESULT SQ_IsWritingPlayerPersistence(void* sqvm)
{
- ServerSq_pushbool(sqvm, g_MasterServerManager->m_bSavingPersistentData);
+ g_ServerSquirrelManager->sq_pushbool(sqvm, g_MasterServerManager->m_bSavingPersistentData);
return SQRESULT_NOTNULL;
}
// bool function NSIsPlayerIndexLocalPlayer( int playerIndex )
SQRESULT SQ_IsPlayerIndexLocalPlayer(void* sqvm)
{
- int playerIndex = ServerSq_getinteger(sqvm, 1);
+ int playerIndex = g_ServerSquirrelManager->sq_getinteger(sqvm, 1);
void* player = GetPlayerByIndex(playerIndex);
if (!g_ServerAuthenticationManager->m_additionalPlayerData.count(player))
{
- ServerSq_pusherror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
+ g_ServerSquirrelManager->sq_raiseerror(sqvm, fmt::format("Invalid playerindex {}", playerIndex).c_str());
return SQRESULT_ERROR;
}
- ServerSq_pushbool(sqvm, !strcmp(g_LocalPlayerUserID, (char*)player + 0xF500));
+ g_ServerSquirrelManager->sq_pushbool(sqvm, !strcmp(g_LocalPlayerUserID, (char*)player + 0xF500));
return SQRESULT_NOTNULL;
}
diff --git a/NorthstarDedicatedTest/plugins.cpp b/NorthstarDedicatedTest/plugins.cpp
index 7424d954..b77b4ef4 100644
--- a/NorthstarDedicatedTest/plugins.cpp
+++ b/NorthstarDedicatedTest/plugins.cpp
@@ -113,12 +113,12 @@ void initGameState()
SQRESULT SQ_UpdateGameStateUI(void* 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_ClientSquirrelManager->sq_getstring(sqvm, 1);
+ gameState.mapDisplayName = g_ClientSquirrelManager->sq_getstring(sqvm, 2);
+ gameState.playlist = g_ClientSquirrelManager->sq_getstring(sqvm, 3);
+ gameState.playlistDisplayName = g_ClientSquirrelManager->sq_getstring(sqvm, 4);
+ gameState.connected = g_ClientSquirrelManager->sq_getbool(sqvm, 5);
+ gameState.loading = g_ClientSquirrelManager->sq_getbool(sqvm, 6);
ReleaseSRWLockExclusive(&gameStateLock);
return SQRESULT_NOTNULL;
}
@@ -128,13 +128,13 @@ SQRESULT SQ_UpdateGameStateClient(void* 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_ClientSquirrelManager->sq_getinteger(sqvm, 1);
+ serverInfo.maxPlayers = g_ClientSquirrelManager->sq_getinteger(sqvm, 2);
+ gameState.ourScore = g_ClientSquirrelManager->sq_getinteger(sqvm, 3);
+ gameState.secondHighestScore = g_ClientSquirrelManager->sq_getinteger(sqvm, 4);
+ gameState.highestScore = g_ClientSquirrelManager->sq_getinteger(sqvm, 5);
+ serverInfo.roundBased = g_ClientSquirrelManager->sq_getbool(sqvm, 6);
+ serverInfo.scoreLimit = g_ClientSquirrelManager->sq_getbool(sqvm, 7);
ReleaseSRWLockExclusive(&gameStateLock);
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
@@ -146,15 +146,15 @@ SQRESULT SQ_UpdateServerInfo(void* 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_ClientSquirrelManager->sq_getstring(sqvm, 1);
+ serverInfo.name = g_ClientSquirrelManager->sq_getstring(sqvm, 2);
+ serverInfo.password = g_ClientSquirrelManager->sq_getstring(sqvm, 3);
+ gameState.players = g_ClientSquirrelManager->sq_getinteger(sqvm, 4);
+ serverInfo.maxPlayers = g_ClientSquirrelManager->sq_getinteger(sqvm, 5);
+ gameState.map = g_ClientSquirrelManager->sq_getstring(sqvm, 6);
+ gameState.mapDisplayName = g_ClientSquirrelManager->sq_getstring(sqvm, 7);
+ gameState.playlist = g_ClientSquirrelManager->sq_getstring(sqvm, 8);
+ gameState.playlistDisplayName = g_ClientSquirrelManager->sq_getstring(sqvm, 9);
ReleaseSRWLockExclusive(&gameStateLock);
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
@@ -164,10 +164,10 @@ SQRESULT SQ_UpdateServerInfo(void* sqvm)
SQRESULT SQ_UpdateServerInfoBetweenRounds(void* 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_ClientSquirrelManager->sq_getstring(sqvm, 1);
+ serverInfo.name = g_ClientSquirrelManager->sq_getstring(sqvm, 2);
+ serverInfo.password = g_ClientSquirrelManager->sq_getstring(sqvm, 3);
+ serverInfo.maxPlayers = g_ClientSquirrelManager->sq_getinteger(sqvm, 4);
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
}
@@ -176,7 +176,7 @@ SQRESULT SQ_UpdateServerInfoBetweenRounds(void* sqvm)
SQRESULT SQ_UpdateTimeInfo(void* sqvm)
{
AcquireSRWLockExclusive(&serverInfoLock);
- serverInfo.endTime = ceil(ClientSq_getfloat(sqvm, 1));
+ serverInfo.endTime = ceil(g_ClientSquirrelManager->sq_getfloat(sqvm, 1));
ReleaseSRWLockExclusive(&serverInfoLock);
return SQRESULT_NOTNULL;
}
@@ -185,7 +185,7 @@ SQRESULT SQ_UpdateTimeInfo(void* sqvm)
SQRESULT SQ_SetConnected(void* sqvm)
{
AcquireSRWLockExclusive(&gameStateLock);
- gameState.loading = ClientSq_getbool(sqvm, 1);
+ gameState.loading = g_ClientSquirrelManager->sq_getbool(sqvm, 1);
ReleaseSRWLockExclusive(&gameStateLock);
return SQRESULT_NOTNULL;
}
diff --git a/NorthstarDedicatedTest/scriptmainmenupromos.cpp b/NorthstarDedicatedTest/scriptmainmenupromos.cpp
index e03b6142..745fe01b 100644
--- a/NorthstarDedicatedTest/scriptmainmenupromos.cpp
+++ b/NorthstarDedicatedTest/scriptmainmenupromos.cpp
@@ -35,7 +35,7 @@ SQRESULT SQ_RequestCustomMainMenuPromos(void* sqvm)
// bool function NSHasCustomMainMenuPromoData()
SQRESULT SQ_HasCustomMainMenuPromoData(void* sqvm)
{
- ClientSq_pushbool(sqvm, g_MasterServerManager->m_bHasMainMenuPromoData);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, g_MasterServerManager->m_bHasMainMenuPromoData);
return SQRESULT_NOTNULL;
}
@@ -45,83 +45,83 @@ SQRESULT SQ_GetCustomMainMenuPromoData(void* sqvm)
if (!g_MasterServerManager->m_bHasMainMenuPromoData)
return SQRESULT_NULL;
- switch (ClientSq_getinteger(sqvm, 1))
+ switch (g_ClientSquirrelManager->sq_getinteger(sqvm, 1))
{
case eMainMenuPromoDataProperty::newInfoTitle1:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle1.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle1.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::newInfoTitle2:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle2.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle2.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::newInfoTitle3:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle3.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.newInfoTitle3.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::largeButtonTitle:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonTitle.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonTitle.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::largeButtonText:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonText.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonText.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::largeButtonUrl:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonUrl.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonUrl.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::largeButtonImageIndex:
{
- ClientSq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonImageIndex);
+ g_ClientSquirrelManager->sq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.largeButtonImageIndex);
break;
}
case eMainMenuPromoDataProperty::smallButton1Title:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1Title.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1Title.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::smallButton1Url:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1Url.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1Url.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::smallButton1ImageIndex:
{
- ClientSq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1ImageIndex);
+ g_ClientSquirrelManager->sq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton1ImageIndex);
break;
}
case eMainMenuPromoDataProperty::smallButton2Title:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2Title.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2Title.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::smallButton2Url:
{
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2Url.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2Url.c_str(), -1);
break;
}
case eMainMenuPromoDataProperty::smallButton2ImageIndex:
{
- ClientSq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2ImageIndex);
+ g_ClientSquirrelManager->sq_pushinteger(sqvm, g_MasterServerManager->m_sMainMenuPromoData.smallButton2ImageIndex);
break;
}
}
diff --git a/NorthstarDedicatedTest/scriptmodmenu.cpp b/NorthstarDedicatedTest/scriptmodmenu.cpp
index 5332449e..c31f24cf 100644
--- a/NorthstarDedicatedTest/scriptmodmenu.cpp
+++ b/NorthstarDedicatedTest/scriptmodmenu.cpp
@@ -7,12 +7,12 @@
// array function NSGetModNames()
SQRESULT SQ_GetModNames(void* sqvm)
{
- ClientSq_newarray(sqvm, 0);
+ g_ClientSquirrelManager->sq_newarray(sqvm, 0);
for (Mod& mod : g_ModManager->m_loadedMods)
{
- ClientSq_pushstring(sqvm, mod.Name.c_str(), -1);
- ClientSq_arrayappend(sqvm, -2);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, mod.Name.c_str(), -1);
+ g_ClientSquirrelManager->sq_arrayappend(sqvm, -2);
}
return SQRESULT_NOTNULL;
@@ -21,14 +21,14 @@ SQRESULT SQ_GetModNames(void* sqvm)
// bool function NSIsModEnabled(string modName)
SQRESULT SQ_IsModEnabled(void* sqvm)
{
- const SQChar* modName = ClientSq_getstring(sqvm, 1);
+ const SQChar* modName = g_ClientSquirrelManager->sq_getstring(sqvm, 1);
// manual lookup, not super performant but eh not a big deal
for (Mod& mod : g_ModManager->m_loadedMods)
{
if (!mod.Name.compare(modName))
{
- ClientSq_pushbool(sqvm, mod.Enabled);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, mod.Enabled);
return SQRESULT_NOTNULL;
}
}
@@ -39,8 +39,8 @@ SQRESULT SQ_IsModEnabled(void* sqvm)
// void function NSSetModEnabled(string modName, bool enabled)
SQRESULT SQ_SetModEnabled(void* sqvm)
{
- const SQChar* modName = ClientSq_getstring(sqvm, 1);
- const SQBool enabled = ClientSq_getbool(sqvm, 2);
+ const SQChar* modName = g_ClientSquirrelManager->sq_getstring(sqvm, 1);
+ const SQBool enabled = g_ClientSquirrelManager->sq_getbool(sqvm, 2);
// manual lookup, not super performant but eh not a big deal
for (Mod& mod : g_ModManager->m_loadedMods)
@@ -58,14 +58,14 @@ SQRESULT SQ_SetModEnabled(void* sqvm)
// string function NSGetModDescriptionByModName(string modName)
SQRESULT SQ_GetModDescription(void* sqvm)
{
- const SQChar* modName = ClientSq_getstring(sqvm, 1);
+ const SQChar* modName = g_ClientSquirrelManager->sq_getstring(sqvm, 1);
// manual lookup, not super performant but eh not a big deal
for (Mod& mod : g_ModManager->m_loadedMods)
{
if (!mod.Name.compare(modName))
{
- ClientSq_pushstring(sqvm, mod.Description.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, mod.Description.c_str(), -1);
return SQRESULT_NOTNULL;
}
}
@@ -76,14 +76,14 @@ SQRESULT SQ_GetModDescription(void* sqvm)
// string function NSGetModVersionByModName(string modName)
SQRESULT SQ_GetModVersion(void* sqvm)
{
- const SQChar* modName = ClientSq_getstring(sqvm, 1);
+ const SQChar* modName = g_ClientSquirrelManager->sq_getstring(sqvm, 1);
// manual lookup, not super performant but eh not a big deal
for (Mod& mod : g_ModManager->m_loadedMods)
{
if (!mod.Name.compare(modName))
{
- ClientSq_pushstring(sqvm, mod.Version.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, mod.Version.c_str(), -1);
return SQRESULT_NOTNULL;
}
}
@@ -94,14 +94,14 @@ SQRESULT SQ_GetModVersion(void* sqvm)
// string function NSGetModDownloadLinkByModName(string modName)
SQRESULT SQ_GetModDownloadLink(void* sqvm)
{
- const SQChar* modName = ClientSq_getstring(sqvm, 1);
+ const SQChar* modName = g_ClientSquirrelManager->sq_getstring(sqvm, 1);
// manual lookup, not super performant but eh not a big deal
for (Mod& mod : g_ModManager->m_loadedMods)
{
if (!mod.Name.compare(modName))
{
- ClientSq_pushstring(sqvm, mod.DownloadLink.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, mod.DownloadLink.c_str(), -1);
return SQRESULT_NOTNULL;
}
}
@@ -112,14 +112,14 @@ SQRESULT SQ_GetModDownloadLink(void* sqvm)
// int function NSGetModLoadPriority(string modName)
SQRESULT SQ_GetModLoadPriority(void* sqvm)
{
- const SQChar* modName = ClientSq_getstring(sqvm, 1);
+ const SQChar* modName = g_ClientSquirrelManager->sq_getstring(sqvm, 1);
// manual lookup, not super performant but eh not a big deal
for (Mod& mod : g_ModManager->m_loadedMods)
{
if (!mod.Name.compare(modName))
{
- ClientSq_pushinteger(sqvm, mod.LoadPriority);
+ g_ClientSquirrelManager->sq_pushinteger(sqvm, mod.LoadPriority);
return SQRESULT_NOTNULL;
}
}
@@ -130,14 +130,14 @@ SQRESULT SQ_GetModLoadPriority(void* sqvm)
// bool function NSIsModRequiredOnClient(string modName)
SQRESULT SQ_IsModRequiredOnClient(void* sqvm)
{
- const SQChar* modName = ClientSq_getstring(sqvm, 1);
+ const SQChar* modName = g_ClientSquirrelManager->sq_getstring(sqvm, 1);
// manual lookup, not super performant but eh not a big deal
for (Mod& mod : g_ModManager->m_loadedMods)
{
if (!mod.Name.compare(modName))
{
- ClientSq_pushbool(sqvm, mod.RequiredOnClient);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, mod.RequiredOnClient);
return SQRESULT_NOTNULL;
}
}
@@ -148,8 +148,8 @@ SQRESULT SQ_IsModRequiredOnClient(void* sqvm)
// array function NSGetModConvarsByModName(string modName)
SQRESULT SQ_GetModConvars(void* sqvm)
{
- const SQChar* modName = ClientSq_getstring(sqvm, 1);
- ClientSq_newarray(sqvm, 0);
+ const SQChar* modName = g_ClientSquirrelManager->sq_getstring(sqvm, 1);
+ g_ClientSquirrelManager->sq_newarray(sqvm, 0);
// manual lookup, not super performant but eh not a big deal
for (Mod& mod : g_ModManager->m_loadedMods)
@@ -158,8 +158,8 @@ SQRESULT SQ_GetModConvars(void* sqvm)
{
for (ModConVar* cvar : mod.ConVars)
{
- ClientSq_pushstring(sqvm, cvar->Name.c_str(), -1);
- ClientSq_arrayappend(sqvm, -2);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, cvar->Name.c_str(), -1);
+ g_ClientSquirrelManager->sq_arrayappend(sqvm, -2);
}
return SQRESULT_NOTNULL;
diff --git a/NorthstarDedicatedTest/scriptserverbrowser.cpp b/NorthstarDedicatedTest/scriptserverbrowser.cpp
index 41506230..f2d53347 100644
--- a/NorthstarDedicatedTest/scriptserverbrowser.cpp
+++ b/NorthstarDedicatedTest/scriptserverbrowser.cpp
@@ -11,7 +11,7 @@
// bool function NSIsMasterServerAuthenticated()
SQRESULT SQ_IsMasterServerAuthenticated(void* sqvm)
{
- ClientSq_pushbool(sqvm, g_MasterServerManager->m_bOriginAuthWithMasterServerDone);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, g_MasterServerManager->m_bOriginAuthWithMasterServerDone);
return SQRESULT_NOTNULL;
}
@@ -25,32 +25,32 @@ SQRESULT SQ_RequestServerList(void* sqvm)
// bool function NSIsRequestingServerList()
SQRESULT SQ_IsRequestingServerList(void* sqvm)
{
- ClientSq_pushbool(sqvm, g_MasterServerManager->m_bScriptRequestingServerList);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, g_MasterServerManager->m_bScriptRequestingServerList);
return SQRESULT_NOTNULL;
}
// bool function NSMasterServerConnectionSuccessful()
SQRESULT SQ_MasterServerConnectionSuccessful(void* sqvm)
{
- ClientSq_pushbool(sqvm, g_MasterServerManager->m_bSuccessfullyConnected);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, g_MasterServerManager->m_bSuccessfullyConnected);
return SQRESULT_NOTNULL;
}
// int function NSGetServerCount()
SQRESULT SQ_GetServerCount(void* sqvm)
{
- ClientSq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers.size());
+ g_ClientSquirrelManager->sq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers.size());
return SQRESULT_NOTNULL;
}
// string function NSGetServerName( int serverIndex )
SQRESULT SQ_GetServerName(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get name of server index {} when only {} servers are available",
@@ -60,18 +60,18 @@ SQRESULT SQ_GetServerName(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].name, -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].name, -1);
return SQRESULT_NOTNULL;
}
// string function NSGetServerDescription( int serverIndex )
SQRESULT SQ_GetServerDescription(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get description of server index {} when only {} servers are available",
@@ -81,18 +81,18 @@ SQRESULT SQ_GetServerDescription(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].description.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].description.c_str(), -1);
return SQRESULT_NOTNULL;
}
// string function NSGetServerMap( int serverIndex )
-SQInteger SQ_GetServerMap(void* sqvm)
+SQRESULT SQ_GetServerMap(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get map of server index {} when only {} servers are available",
@@ -102,18 +102,18 @@ SQInteger SQ_GetServerMap(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].map, -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].map, -1);
return SQRESULT_NOTNULL;
}
// string function NSGetServerPlaylist( int serverIndex )
SQRESULT SQ_GetServerPlaylist(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get playlist of server index {} when only {} servers are available",
@@ -123,18 +123,18 @@ SQRESULT SQ_GetServerPlaylist(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].playlist, -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].playlist, -1);
return SQRESULT_NOTNULL;
}
// int function NSGetServerPlayerCount( int serverIndex )
SQRESULT SQ_GetServerPlayerCount(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get playercount of server index {} when only {} servers are available",
@@ -144,18 +144,18 @@ SQRESULT SQ_GetServerPlayerCount(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].playerCount);
+ g_ClientSquirrelManager->sq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].playerCount);
return SQRESULT_NOTNULL;
}
// int function NSGetServerMaxPlayerCount( int serverIndex )
SQRESULT SQ_GetServerMaxPlayerCount(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get max playercount of server index {} when only {} servers are available",
@@ -165,18 +165,18 @@ SQRESULT SQ_GetServerMaxPlayerCount(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].maxPlayers);
+ g_ClientSquirrelManager->sq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].maxPlayers);
return SQRESULT_NOTNULL;
}
// string function NSGetServerID( int serverIndex )
SQRESULT SQ_GetServerID(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get id of server index {} when only {} servers are available",
@@ -186,18 +186,18 @@ SQRESULT SQ_GetServerID(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].id, -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].id, -1);
return SQRESULT_NOTNULL;
}
// bool function NSServerRequiresPassword( int serverIndex )
SQRESULT SQ_ServerRequiresPassword(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get hasPassword of server index {} when only {} servers are available",
@@ -207,18 +207,18 @@ SQRESULT SQ_ServerRequiresPassword(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushbool(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiresPassword);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiresPassword);
return SQRESULT_NOTNULL;
}
// int function NSGetServerRequiredModsCount( int serverIndex )
SQRESULT SQ_GetServerRequiredModsCount(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get required mods count of server index {} when only {} servers are available",
@@ -228,19 +228,19 @@ SQRESULT SQ_GetServerRequiredModsCount(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size());
+ g_ClientSquirrelManager->sq_pushinteger(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size());
return SQRESULT_NOTNULL;
}
// string function NSGetServerRequiredModName( int serverIndex, int modIndex )
SQRESULT SQ_GetServerRequiredModName(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
- SQInteger modIndex = ClientSq_getinteger(sqvm, 2);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
+ SQInteger modIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 2);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get hasPassword of server index {} when only {} servers are available",
@@ -252,7 +252,7 @@ SQRESULT SQ_GetServerRequiredModName(void* sqvm)
if (modIndex >= g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get required mod name of mod index {} when only {} mod are available",
@@ -262,19 +262,19 @@ SQRESULT SQ_GetServerRequiredModName(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods[modIndex].Name.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods[modIndex].Name.c_str(), -1);
return SQRESULT_NOTNULL;
}
// string function NSGetServerRequiredModVersion( int serverIndex, int modIndex )
SQRESULT SQ_GetServerRequiredModVersion(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
- SQInteger modIndex = ClientSq_getinteger(sqvm, 2);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
+ SQInteger modIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 2);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get required mod version of server index {} when only {} servers are available",
@@ -286,7 +286,7 @@ SQRESULT SQ_GetServerRequiredModVersion(void* sqvm)
if (modIndex >= g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to get required mod version of mod index {} when only {} mod are available",
@@ -296,7 +296,7 @@ SQRESULT SQ_GetServerRequiredModVersion(void* sqvm)
return SQRESULT_ERROR;
}
- ClientSq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods[modIndex].Version.c_str(), -1);
+ g_ClientSquirrelManager->sq_pushstring(sqvm, g_MasterServerManager->m_vRemoteServers[serverIndex].requiredMods[modIndex].Version.c_str(), -1);
return SQRESULT_NOTNULL;
}
@@ -312,12 +312,12 @@ SQRESULT SQ_ClearRecievedServerList(void* sqvm)
// void function NSTryAuthWithServer( int serverIndex, string password = "" )
SQRESULT SQ_TryAuthWithServer(void* sqvm)
{
- SQInteger serverIndex = ClientSq_getinteger(sqvm, 1);
- const SQChar* password = ClientSq_getstring(sqvm, 2);
+ SQInteger serverIndex = g_ClientSquirrelManager->sq_getinteger(sqvm, 1);
+ const SQChar* password = g_ClientSquirrelManager->sq_getstring(sqvm, 2);
if (serverIndex >= g_MasterServerManager->m_vRemoteServers.size())
{
- ClientSq_pusherror(
+ g_ClientSquirrelManager->sq_raiseerror(
sqvm,
fmt::format(
"Tried to auth with server index {} when only {} servers are available",
@@ -345,14 +345,14 @@ SQRESULT SQ_TryAuthWithServer(void* sqvm)
// bool function NSIsAuthenticatingWithServer()
SQRESULT SQ_IsAuthComplete(void* sqvm)
{
- ClientSq_pushbool(sqvm, g_MasterServerManager->m_bScriptAuthenticatingWithGameServer);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, g_MasterServerManager->m_bScriptAuthenticatingWithGameServer);
return SQRESULT_NOTNULL;
}
// bool function NSWasAuthSuccessful()
SQRESULT SQ_WasAuthSuccessful(void* sqvm)
{
- ClientSq_pushbool(sqvm, g_MasterServerManager->m_bSuccessfullyAuthenticatedWithGameServer);
+ g_ClientSquirrelManager->sq_pushbool(sqvm, g_MasterServerManager->m_bSuccessfullyAuthenticatedWithGameServer);
return SQRESULT_NOTNULL;
}
@@ -361,7 +361,7 @@ SQRESULT SQ_ConnectToAuthedServer(void* sqvm)
{
if (!g_MasterServerManager->m_bHasPendingConnectionInfo)
{
- ClientSq_pusherror(sqvm, fmt::format("Tried to connect to authed server before any pending connection info was available").c_str());
+ g_ClientSquirrelManager->sq_raiseerror(sqvm, fmt::format("Tried to connect to authed server before any pending connection info was available").c_str());
return SQRESULT_ERROR;
}
diff --git a/NorthstarDedicatedTest/serverchathooks.cpp b/NorthstarDedicatedTest/serverchathooks.cpp
index ad037a5f..98f1bdc1 100644
--- a/NorthstarDedicatedTest/serverchathooks.cpp
+++ b/NorthstarDedicatedTest/serverchathooks.cpp
@@ -142,9 +142,9 @@ void ChatBroadcastMessage(int fromPlayerIndex, int toPlayerIndex, const char* te
SQRESULT SQ_SendMessage(void* sqvm)
{
- int playerIndex = ServerSq_getinteger(sqvm, 1);
- const char* text = ServerSq_getstring(sqvm, 2);
- bool isTeam = ServerSq_getbool(sqvm, 3);
+ int playerIndex = g_ServerSquirrelManager->sq_getinteger(sqvm, 1);
+ const char* text = g_ServerSquirrelManager->sq_getstring(sqvm, 2);
+ bool isTeam = g_ServerSquirrelManager->sq_getbool(sqvm, 3);
ChatSendMessage(playerIndex, text, isTeam);
@@ -153,16 +153,16 @@ SQRESULT SQ_SendMessage(void* sqvm)
SQRESULT SQ_BroadcastMessage(void* sqvm)
{
- int fromPlayerIndex = ServerSq_getinteger(sqvm, 1);
- int toPlayerIndex = ServerSq_getinteger(sqvm, 2);
- const char* text = ServerSq_getstring(sqvm, 3);
- bool isTeam = ServerSq_getbool(sqvm, 4);
- bool isDead = ServerSq_getbool(sqvm, 5);
- int messageType = ServerSq_getinteger(sqvm, 6);
+ int fromPlayerIndex = g_ServerSquirrelManager->sq_getinteger(sqvm, 1);
+ int toPlayerIndex = g_ServerSquirrelManager->sq_getinteger(sqvm, 2);
+ const char* text = g_ServerSquirrelManager->sq_getstring(sqvm, 3);
+ bool isTeam = g_ServerSquirrelManager->sq_getbool(sqvm, 4);
+ bool isDead = g_ServerSquirrelManager->sq_getbool(sqvm, 5);
+ int messageType = g_ServerSquirrelManager->sq_getinteger(sqvm, 6);
if (messageType < 1)
{
- ServerSq_pusherror(sqvm, fmt::format("Invalid message type {}", messageType).c_str());
+ g_ServerSquirrelManager->sq_raiseerror(sqvm, fmt::format("Invalid message type {}", messageType).c_str());
return SQRESULT_ERROR;
}
diff --git a/NorthstarDedicatedTest/squirrel.cpp b/NorthstarDedicatedTest/squirrel.cpp
index 835e4bd9..1e405e29 100644
--- a/NorthstarDedicatedTest/squirrel.cpp
+++ b/NorthstarDedicatedTest/squirrel.cpp
@@ -34,58 +34,9 @@ CallScriptInitCallbackType ClientCallScriptInitCallback;
CallScriptInitCallbackType ServerCallScriptInitCallback;
template char CallScriptInitCallbackHook(void* sqvm, const char* callback);
-// core sqvm funcs
-sq_compilebufferType ClientSq_compilebuffer;
-sq_compilebufferType ServerSq_compilebuffer;
-
-sq_pushroottableType ClientSq_pushroottable;
-sq_pushroottableType ServerSq_pushroottable;
-
-sq_callType ClientSq_call;
-sq_callType ServerSq_call;
-
RegisterSquirrelFuncType ClientRegisterSquirrelFunc;
RegisterSquirrelFuncType ServerRegisterSquirrelFunc;
-// sq stack array funcs
-sq_newarrayType ClientSq_newarray;
-sq_newarrayType ServerSq_newarray;
-
-sq_arrayappendType ClientSq_arrayappend;
-sq_arrayappendType ServerSq_arrayappend;
-
-// sq stack push funcs
-sq_pushstringType ClientSq_pushstring;
-sq_pushstringType ServerSq_pushstring;
-
-sq_pushintegerType ClientSq_pushinteger;
-sq_pushintegerType ServerSq_pushinteger;
-
-sq_pushfloatType ClientSq_pushfloat;
-sq_pushfloatType ServerSq_pushfloat;
-
-sq_pushboolType ClientSq_pushbool;
-sq_pushboolType ServerSq_pushbool;
-
-sq_pusherrorType ClientSq_pusherror;
-sq_pusherrorType ServerSq_pusherror;
-
-// sq stack get funcs
-sq_getstringType ClientSq_getstring;
-sq_getstringType ServerSq_getstring;
-
-sq_getintegerType ClientSq_getinteger;
-sq_getintegerType ServerSq_getinteger;
-
-sq_getfloatType ClientSq_getfloat;
-sq_getfloatType ServerSq_getfloat;
-
-sq_getboolType ClientSq_getbool;
-sq_getboolType ServerSq_getbool;
-
-sq_getType ClientSq_sq_get;
-sq_getType ServerSq_sq_get;
-
template void ExecuteCodeCommand(const CCommand& args);
// inits
@@ -115,27 +66,42 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (HMODULE baseAddr
hook, (char*)baseAddress + 0x12BA0, &SQPrintHook, reinterpret_cast(&UISQPrint)); // ui print function
RegisterConCommand("script_ui", ExecuteCodeCommand, "Executes script code on the ui vm", FCVAR_CLIENTDLL);
- // inits for both client and ui, since they share some functions
- ClientSq_compilebuffer = (sq_compilebufferType)((char*)baseAddress + 0x3110);
- ClientSq_pushroottable = (sq_pushroottableType)((char*)baseAddress + 0x5860);
- ClientSq_call = (sq_callType)((char*)baseAddress + 0x8650);
ClientRegisterSquirrelFunc = (RegisterSquirrelFuncType)((char*)baseAddress + 0x108E0);
- ClientSq_newarray = (sq_newarrayType)((char*)baseAddress + 0x39F0);
- ClientSq_arrayappend = (sq_arrayappendType)((char*)baseAddress + 0x3C70);
-
- ClientSq_pushstring = (sq_pushstringType)((char*)baseAddress + 0x3440);
- ClientSq_pushinteger = (sq_pushintegerType)((char*)baseAddress + 0x36A0);
- ClientSq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
- ClientSq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
- ClientSq_pusherror = (sq_pusherrorType)((char*)baseAddress + 0x8470);
-
- ClientSq_getstring = (sq_getstringType)((char*)baseAddress + 0x60C0);
- ClientSq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60E0);
- ClientSq_getfloat = (sq_getfloatType)((char*)baseAddress + 0x6100);
- ClientSq_getbool = (sq_getboolType)((char*)baseAddress + 0x6130);
-
- ClientSq_sq_get = (sq_getType)((char*)baseAddress + 0x7C30);
+ g_ClientSquirrelManager->sq_compilebuffer = (sq_compilebufferType)((char*)baseAddress + 0x3110);
+ g_UISquirrelManager->sq_compilebuffer = (sq_compilebufferType)((char*)baseAddress + 0x3110);
+ g_ClientSquirrelManager->sq_pushroottable = (sq_pushroottableType)((char*)baseAddress + 0x5860);
+ g_UISquirrelManager->sq_pushroottable = (sq_pushroottableType)((char*)baseAddress + 0x5860);
+
+ g_ClientSquirrelManager->sq_call = (sq_callType)((char*)baseAddress + 0x8650);
+ g_UISquirrelManager->sq_call = (sq_callType)((char*)baseAddress + 0x8650);
+
+ g_ClientSquirrelManager->sq_newarray = (sq_newarrayType)((char*)baseAddress + 0x39F0);
+ g_UISquirrelManager->sq_newarray = (sq_newarrayType)((char*)baseAddress + 0x39F0);
+ g_ClientSquirrelManager->sq_arrayappend = (sq_arrayappendType)((char*)baseAddress + 0x3C70);
+ g_UISquirrelManager->sq_arrayappend = (sq_arrayappendType)((char*)baseAddress + 0x3C70);
+
+ g_ClientSquirrelManager->sq_pushstring = (sq_pushstringType)((char*)baseAddress + 0x3440);
+ g_UISquirrelManager->sq_pushstring = (sq_pushstringType)((char*)baseAddress + 0x3440);
+ g_ClientSquirrelManager->sq_pushinteger = (sq_pushintegerType)((char*)baseAddress + 0x36A0);
+ g_UISquirrelManager->sq_pushinteger = (sq_pushintegerType)((char*)baseAddress + 0x36A0);
+ g_ClientSquirrelManager->sq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
+ g_UISquirrelManager->sq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
+ g_ClientSquirrelManager->sq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
+ g_UISquirrelManager->sq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
+ g_ClientSquirrelManager->sq_raiseerror = (sq_raiseerrorType)((char*)baseAddress + 0x8470);
+ g_UISquirrelManager->sq_raiseerror = (sq_raiseerrorType)((char*)baseAddress + 0x8470);
+
+ g_ClientSquirrelManager->sq_getstring = (sq_getstringType)((char*)baseAddress + 0x60C0);
+ g_UISquirrelManager->sq_getstring = (sq_getstringType)((char*)baseAddress + 0x60C0);
+ g_ClientSquirrelManager->sq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60E0);
+ g_UISquirrelManager->sq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60E0);
+ g_ClientSquirrelManager->sq_getfloat = (sq_getfloatType)((char*)baseAddress + 0x6100);
+ g_UISquirrelManager->sq_getfloat = (sq_getfloatType)((char*)baseAddress + 0x6100);
+ g_ClientSquirrelManager->sq_getbool = (sq_getboolType)((char*)baseAddress + 0x6130);
+ g_UISquirrelManager->sq_getbool = (sq_getboolType)((char*)baseAddress + 0x6130);
+ g_ClientSquirrelManager->sq_get = (sq_getType)((char*)baseAddress + 0x7C30);
+ g_UISquirrelManager->sq_get = (sq_getType)((char*)baseAddress + 0x7C30);
ENABLER_CREATEHOOK(
hook,
@@ -163,29 +129,28 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (HMODULE baseAddr
{
g_ServerSquirrelManager = new SquirrelManager();
- HookEnabler hook;
-
- ServerSq_compilebuffer = (sq_compilebufferType)((char*)baseAddress + 0x3110);
- ServerSq_pushroottable = (sq_pushroottableType)((char*)baseAddress + 0x5840);
- ServerSq_call = (sq_callType)((char*)baseAddress + 0x8620);
ServerRegisterSquirrelFunc = (RegisterSquirrelFuncType)((char*)baseAddress + 0x1DD10);
- ServerSq_newarray = (sq_newarrayType)((char*)baseAddress + 0x39F0);
- ServerSq_arrayappend = (sq_arrayappendType)((char*)baseAddress + 0x3C70);
+ g_ServerSquirrelManager->sq_compilebuffer = (sq_compilebufferType)((char*)baseAddress + 0x3110);
+ g_ServerSquirrelManager->sq_pushroottable = (sq_pushroottableType)((char*)baseAddress + 0x5840);
+ g_ServerSquirrelManager->sq_call = (sq_callType)((char*)baseAddress + 0x8620);
- ServerSq_pushstring = (sq_pushstringType)((char*)baseAddress + 0x3440);
- ServerSq_pushinteger = (sq_pushintegerType)((char*)baseAddress + 0x36A0);
- ServerSq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
- ServerSq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
- ServerSq_pusherror = (sq_pusherrorType)((char*)baseAddress + 0x8440);
+ g_ServerSquirrelManager->sq_newarray = (sq_newarrayType)((char*)baseAddress + 0x39F0);
+ g_ServerSquirrelManager->sq_arrayappend = (sq_arrayappendType)((char*)baseAddress + 0x3C70);
- ServerSq_getstring = (sq_getstringType)((char*)baseAddress + 0x60A0);
- ServerSq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60C0);
- ServerSq_getfloat = (sq_getfloatType)((char*)baseAddress + 0x60E0);
- ServerSq_getbool = (sq_getboolType)((char*)baseAddress + 0x6110);
+ g_ServerSquirrelManager->sq_pushstring = (sq_pushstringType)((char*)baseAddress + 0x3440);
+ g_ServerSquirrelManager->sq_pushinteger = (sq_pushintegerType)((char*)baseAddress + 0x36A0);
+ g_ServerSquirrelManager->sq_pushfloat = (sq_pushfloatType)((char*)baseAddress + 0x3800);
+ g_ServerSquirrelManager->sq_pushbool = (sq_pushboolType)((char*)baseAddress + 0x3710);
+ g_ServerSquirrelManager->sq_raiseerror = (sq_raiseerrorType)((char*)baseAddress + 0x8440);
- ServerSq_sq_get = (sq_getType)((char*)baseAddress + 0x7C00);
+ g_ServerSquirrelManager->sq_getstring = (sq_getstringType)((char*)baseAddress + 0x60A0);
+ g_ServerSquirrelManager->sq_getinteger = (sq_getintegerType)((char*)baseAddress + 0x60C0);
+ g_ServerSquirrelManager->sq_getfloat = (sq_getfloatType)((char*)baseAddress + 0x60E0);
+ g_ServerSquirrelManager->sq_getbool = (sq_getboolType)((char*)baseAddress + 0x6110);
+ g_ServerSquirrelManager->sq_get = (sq_getType)((char*)baseAddress + 0x7C00);
+ HookEnabler hook;
ENABLER_CREATEHOOK(
hook,
(char*)baseAddress + 0x1FE90,
diff --git a/NorthstarDedicatedTest/squirrel.h b/NorthstarDedicatedTest/squirrel.h
index dc99ac04..453db83b 100644
--- a/NorthstarDedicatedTest/squirrel.h
+++ b/NorthstarDedicatedTest/squirrel.h
@@ -7,13 +7,15 @@ typedef unsigned long SQUnsignedInteger;
typedef char SQChar;
typedef SQUnsignedInteger SQBool;
-typedef SQInteger SQRESULT;
-const SQRESULT SQRESULT_ERROR = -1;
-const SQRESULT SQRESULT_NULL = 0;
-const SQRESULT SQRESULT_NOTNULL = 1;
+enum SQRESULT : SQInteger
+{
+ SQRESULT_ERROR = -1,
+ SQRESULT_NULL = 0,
+ SQRESULT_NOTNULL = 1,
+};
-typedef SQInteger (*SQFunction)(void* sqvm);
+typedef SQRESULT (*SQFunction)(void* sqvm);
struct CompileBufferState
{
@@ -57,73 +59,31 @@ struct SQFuncRegistration
};
// core sqvm funcs
-typedef SQRESULT (*sq_compilebufferType)(void* sqvm, CompileBufferState* compileBuffer, const char* file, int a1, ScriptContext a2);
-extern sq_compilebufferType ClientSq_compilebuffer;
-extern sq_compilebufferType ServerSq_compilebuffer;
-
-typedef void (*sq_pushroottableType)(void* sqvm);
-extern sq_pushroottableType ClientSq_pushroottable;
-extern sq_pushroottableType ServerSq_pushroottable;
-
-typedef SQRESULT (*sq_callType)(void* sqvm, SQInteger s1, SQBool a2, SQBool a3);
-extern sq_callType ClientSq_call;
-extern sq_callType ServerSq_call;
-
typedef int64_t (*RegisterSquirrelFuncType)(void* sqvm, SQFuncRegistration* funcReg, char unknown);
extern RegisterSquirrelFuncType ClientRegisterSquirrelFunc;
extern RegisterSquirrelFuncType ServerRegisterSquirrelFunc;
+typedef SQRESULT (*sq_compilebufferType)(void* sqvm, CompileBufferState* compileBuffer, const char* file, int a1, ScriptContext a2);
+typedef SQRESULT (*sq_callType)(void* sqvm, SQInteger s1, SQBool a2, SQBool a3);
+
// sq stack array funcs
typedef void (*sq_newarrayType)(void* sqvm, SQInteger stackpos);
-extern sq_newarrayType ClientSq_newarray;
-extern sq_newarrayType ServerSq_newarray;
-
typedef SQRESULT (*sq_arrayappendType)(void* sqvm, SQInteger stackpos);
-extern sq_arrayappendType ClientSq_arrayappend;
-extern sq_arrayappendType ServerSq_arrayappend;
// sq stack push funcs
-typedef void (*sq_pushstringType)(void* sqvm, const SQChar* str, SQInteger stackpos);
-extern sq_pushstringType ClientSq_pushstring;
-extern sq_pushstringType ServerSq_pushstring;
-
-// weird how these don't take a stackpos arg?
+typedef void (*sq_pushroottableType)(void* sqvm);
+typedef void (*sq_pushstringType)(void* sqvm, const SQChar* str, SQInteger length);
typedef void (*sq_pushintegerType)(void* sqvm, SQInteger i);
-extern sq_pushintegerType ClientSq_pushinteger;
-extern sq_pushintegerType ServerSq_pushinteger;
-
typedef void (*sq_pushfloatType)(void* sqvm, SQFloat f);
-extern sq_pushfloatType ClientSq_pushfloat;
-extern sq_pushfloatType ServerSq_pushfloat;
-
typedef void (*sq_pushboolType)(void* sqvm, SQBool b);
-extern sq_pushboolType ClientSq_pushbool;
-extern sq_pushboolType ServerSq_pushbool;
-
-typedef SQInteger (*sq_pusherrorType)(void* sqvm, const SQChar* error);
-extern sq_pusherrorType ClientSq_pusherror;
-extern sq_pusherrorType ServerSq_pusherror;
+typedef SQInteger (*sq_raiseerrorType)(void* sqvm, const SQChar* error);
// sq stack get funcs
typedef const SQChar* (*sq_getstringType)(void* sqvm, SQInteger stackpos);
-extern sq_getstringType ClientSq_getstring;
-extern sq_getstringType ServerSq_getstring;
-
typedef SQInteger (*sq_getintegerType)(void* sqvm, SQInteger stackpos);
-extern sq_getintegerType ClientSq_getinteger;
-extern sq_getintegerType ServerSq_getinteger;
-
typedef SQFloat (*sq_getfloatType)(void*, SQInteger stackpos);
-extern sq_getfloatType ClientSq_getfloat;
-extern sq_getfloatType ServerSq_getfloat;
-
typedef SQBool (*sq_getboolType)(void*, SQInteger stackpos);
-extern sq_getboolType ClientSq_getbool;
-extern sq_getboolType ServerSq_getbool;
-
-typedef SQRESULT (*sq_getType)(void* sqvm, SQInteger idx);
-extern sq_getType ServerSq_sq_get;
-extern sq_getType ClientSq_sq_get;
+typedef SQRESULT (*sq_getType)(void* sqvm, SQInteger stackpos);
template class SquirrelManager
{
@@ -133,6 +93,24 @@ template class SquirrelManager
public:
void* sqvm;
void* sqvm2;
+ #pragma region SQVM funcs
+ sq_compilebufferType sq_compilebuffer;
+ sq_callType sq_call;
+ sq_newarrayType sq_newarray;
+ sq_arrayappendType sq_arrayappend;
+ sq_pushroottableType sq_pushroottable;
+ sq_pushstringType sq_pushstring;
+ sq_pushintegerType sq_pushinteger;
+ sq_pushfloatType sq_pushfloat;
+ sq_pushboolType sq_pushbool;
+ sq_raiseerrorType sq_raiseerror;
+
+ sq_getstringType sq_getstring;
+ sq_getintegerType sq_getinteger;
+ sq_getfloatType sq_getfloat;
+ sq_getboolType sq_getbool;
+ sq_getType sq_get;
+ #pragma endregion
public:
SquirrelManager() : sqvm(nullptr) {}
@@ -160,8 +138,6 @@ template class SquirrelManager
void ExecuteCode(const char* code)
{
- // ttf2sdk checks ThreadIsInMainThread here, might be good to do that? doesn't seem like an issue rn tho
-
if (!sqvm)
{
spdlog::error("Cannot execute code, {} squirrel vm is not initialised", GetContextName(context));
@@ -173,94 +149,51 @@ template class SquirrelManager
std::string strCode(code);
CompileBufferState bufferState = CompileBufferState(strCode);
- SQRESULT compileResult;
- if (context == ScriptContext::CLIENT || context == ScriptContext::UI)
- compileResult = ClientSq_compilebuffer(sqvm2, &bufferState, "console", -1, context);
- else if (context == ScriptContext::SERVER)
- compileResult = ServerSq_compilebuffer(sqvm2, &bufferState, "console", -1, context);
-
+ SQRESULT compileResult = sq_compilebuffer(sqvm2, &bufferState, "console", -1, context);
spdlog::info("sq_compilebuffer returned {}", compileResult);
if (compileResult >= 0)
{
- if (context == ScriptContext::CLIENT || context == ScriptContext::UI)
- {
- ClientSq_pushroottable(sqvm2);
- SQRESULT callResult = ClientSq_call(sqvm2, 1, false, false);
- spdlog::info("sq_call returned {}", callResult);
- }
- else if (context == ScriptContext::SERVER)
- {
- ServerSq_pushroottable(sqvm2);
- SQRESULT callResult = ServerSq_call(sqvm2, 1, false, false);
- spdlog::info("sq_call returned {}", callResult);
- }
+ sq_pushroottable(sqvm2);
+ SQRESULT callResult = sq_call(sqvm2, 1, false, false);
+ spdlog::info("sq_call returned {}", callResult);
}
}
int setupfunc(const char* funcname)
{
- int result = -2;
- if (context == ScriptContext::CLIENT || context == ScriptContext::UI)
- {
- ClientSq_pushroottable(sqvm2);
- ClientSq_pushstring(sqvm2, funcname, -1);
- result = ClientSq_sq_get(sqvm2, -2);
- if (result != SQRESULT_ERROR)
- {
- ClientSq_pushroottable(sqvm2);
- }
- }
- else if (context == ScriptContext::SERVER)
- {
- ServerSq_pushroottable(sqvm2);
- ServerSq_pushstring(sqvm2, funcname, -1);
- result = ServerSq_sq_get(sqvm2, -2);
- if (result != SQRESULT_ERROR)
- {
- ServerSq_pushroottable(sqvm2);
- }
- }
+ sq_pushroottable(sqvm2);
+ sq_pushstring(sqvm2, funcname, -1);
+
+ int result = sq_get(sqvm2, -2);
+ if (result != SQRESULT_ERROR)
+ sq_pushroottable(sqvm2);
+
return result;
}
void pusharg(int arg)
{
- if (context == ScriptContext::CLIENT || context == ScriptContext::UI)
- ClientSq_pushinteger(sqvm2, arg);
- else if (context == ScriptContext::SERVER)
- ServerSq_pushinteger(sqvm2, arg);
+ sq_pushinteger(sqvm2, arg);
}
+
void pusharg(const char* arg)
{
- if (context == ScriptContext::CLIENT || context == ScriptContext::UI)
- ClientSq_pushstring(sqvm2, arg, -1);
- else if (context == ScriptContext::SERVER)
- ServerSq_pushstring(sqvm2, arg, -1);
+ sq_pushstring(sqvm2, arg, -1);
}
+
void pusharg(float arg)
{
- if (context == ScriptContext::CLIENT || context == ScriptContext::UI)
- ClientSq_pushfloat(sqvm2, arg);
- else if (context == ScriptContext::SERVER)
- ServerSq_pushfloat(sqvm2, arg);
+ sq_pushfloat(sqvm2, arg);
}
+
void pusharg(bool arg)
{
- if (context == ScriptContext::CLIENT || context == ScriptContext::UI)
- ClientSq_pushbool(sqvm2, arg);
- else if (context == ScriptContext::SERVER)
- ServerSq_pushbool(sqvm2, arg);
+ sq_pushbool(sqvm2, arg);
}
int call(int args)
{
- int result = -2;
- if (context == ScriptContext::CLIENT || context == ScriptContext::UI)
- result = ClientSq_call(sqvm2, args + 1, false, false);
- else if (context == ScriptContext::SERVER)
- result = ServerSq_call(sqvm2, args + 1, false, false);
-
- return result;
+ return sq_call(sqvm2, args + 1, false, false);
}
void AddFuncRegistration(std::string returnType, std::string name, std::string argTypes, std::string helpText, SQFunction func)
--
cgit v1.2.3