diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-11-27 01:35:22 +0000 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2021-11-27 01:35:22 +0000 |
commit | f66ea9ce2af44a00e49e6defaa7ec6ef4f100bb4 (patch) | |
tree | fce15e55515c16ba5f1884545643ae45e52c6e7f /NorthstarDedicatedTest | |
parent | 3d3d2c2a13a292a9093ad3029563a1c543a07ab7 (diff) | |
download | NorthstarLauncher-f66ea9ce2af44a00e49e6defaa7ec6ef4f100bb4.tar.gz NorthstarLauncher-f66ea9ce2af44a00e49e6defaa7ec6ef4f100bb4.zip |
more masterserver stuff and support for devonly/hidden cvars
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj | 8 | ||||
-rw-r--r-- | NorthstarDedicatedTest/concommand.cpp | 1 | ||||
-rw-r--r-- | NorthstarDedicatedTest/convar.cpp | 16 | ||||
-rw-r--r-- | NorthstarDedicatedTest/masterserver.cpp | 6 | ||||
-rw-r--r-- | NorthstarDedicatedTest/misccommands.cpp | 17 | ||||
-rw-r--r-- | NorthstarDedicatedTest/serverauthentication.cpp | 2 |
6 files changed, 37 insertions, 13 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj index fa617e4d..9c48644d 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj @@ -30,26 +30,26 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> <WholeProgramOptimization>true</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> </PropertyGroup> diff --git a/NorthstarDedicatedTest/concommand.cpp b/NorthstarDedicatedTest/concommand.cpp index dff0f964..d81796d8 100644 --- a/NorthstarDedicatedTest/concommand.cpp +++ b/NorthstarDedicatedTest/concommand.cpp @@ -19,6 +19,5 @@ void RegisterConCommand(const char* name, void(*callback)(const CCommand&), cons void InitialiseConCommands(HMODULE baseAddress) { conCommandConstructor = (ConCommandConstructorType)((char*)baseAddress + 0x415F60); - AddMiscConCommands(); }
\ No newline at end of file diff --git a/NorthstarDedicatedTest/convar.cpp b/NorthstarDedicatedTest/convar.cpp index 156301b6..ed7e8dac 100644 --- a/NorthstarDedicatedTest/convar.cpp +++ b/NorthstarDedicatedTest/convar.cpp @@ -1,5 +1,7 @@ #include "pch.h" #include "convar.h" +#include "hookutils.h" +#include "gameutils.h" #include <set> // should this be in modmanager? @@ -7,6 +9,8 @@ std::unordered_map<std::string, ConVar*> g_CustomConvars; // this is used in mod typedef void(*ConVarConstructorType)(ConVar* newVar, const char* name, const char* defaultValue, int flags, const char* helpString); ConVarConstructorType conVarConstructor; +typedef bool(*CvarIsFlagSetType)(ConVar* self, int flags); +CvarIsFlagSetType CvarIsFlagSet; ConVar* RegisterConVar(const char* name, const char* defaultValue, int flags, const char* helpString) { @@ -21,7 +25,19 @@ ConVar* RegisterConVar(const char* name, const char* defaultValue, int flags, co return newVar; } +bool CvarIsFlagSetHook(ConVar* self, int flags) +{ + // unrestrict FCVAR_DEVELOPMENTONLY and FCVAR_HIDDEN + if (self && flags == FCVAR_DEVELOPMENTONLY || flags == FCVAR_HIDDEN) + return false; + + return CvarIsFlagSet(self, flags); +} + void InitialiseConVars(HMODULE baseAddress) { conVarConstructor = (ConVarConstructorType)((char*)baseAddress + 0x416200); + + HookEnabler hook; + ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x417FA0, &CvarIsFlagSetHook, reinterpret_cast<LPVOID*>(&CvarIsFlagSet)); }
\ No newline at end of file diff --git a/NorthstarDedicatedTest/masterserver.cpp b/NorthstarDedicatedTest/masterserver.cpp index 1d639f28..43db66e7 100644 --- a/NorthstarDedicatedTest/masterserver.cpp +++ b/NorthstarDedicatedTest/masterserver.cpp @@ -227,6 +227,9 @@ void MasterServerManager::RequestServerList() { RemoteModInfo modInfo; + if (!requiredMod.HasMember("RequiredOnClient") || !requiredMod["RequiredOnClient"].IsTrue()) + continue; + if (!requiredMod.HasMember("Name") || !requiredMod["Name"].IsString()) continue; modInfo.Name = requiredMod["Name"].GetString(); @@ -477,12 +480,13 @@ void MasterServerManager::AddSelfToServerList(int port, int authPort, char* name int currentModIndex = 0; for (Mod& mod : g_ModManager->m_loadedMods) { - if (!mod.RequiredOnClient) + if (!mod.RequiredOnClient && !mod.Pdiff.size()) continue; modinfoDoc["Mods"].PushBack(rapidjson::Value(rapidjson::kObjectType), modinfoDoc.GetAllocator()); modinfoDoc["Mods"][currentModIndex].AddMember("Name", rapidjson::StringRef(&mod.Name[0]), modinfoDoc.GetAllocator()); modinfoDoc["Mods"][currentModIndex].AddMember("Version", rapidjson::StringRef(&mod.Version[0]), modinfoDoc.GetAllocator()); + modinfoDoc["Mods"][currentModIndex].AddMember("RequiredOnClient", mod.RequiredOnClient, modinfoDoc.GetAllocator()); modinfoDoc["Mods"][currentModIndex].AddMember("Pdiff", rapidjson::StringRef(&mod.Pdiff[0]), modinfoDoc.GetAllocator()); currentModIndex++; diff --git a/NorthstarDedicatedTest/misccommands.cpp b/NorthstarDedicatedTest/misccommands.cpp index f7ccbe2c..a01948af 100644 --- a/NorthstarDedicatedTest/misccommands.cpp +++ b/NorthstarDedicatedTest/misccommands.cpp @@ -4,6 +4,7 @@ #include "gameutils.h" #include "masterserver.h" #include "serverauthentication.h" +#include "squirrel.h" void ForceLoadMapCommand(const CCommand& arg) { @@ -27,12 +28,16 @@ void EndSelfAuthAndLeaveToLobbyCommand(const CCommand& arg) Cbuf_AddText(Cbuf_GetCurrentPlayer(), fmt::format("serverfilter {}", g_ServerAuthenticationManager->m_authData.begin()->first).c_str(), cmd_source_t::kCommandSrcCode); Cbuf_Execute(); - g_ServerAuthenticationManager->m_bNeedLocalAuthForNewgame = true; - // this won't set playlist correctly on remote clients, don't think they can set playlist until they've left which sorta fucks things - // should maybe set this in HostState_NewGame? - SetCurrentPlaylist("tdm"); - strcpy(g_pHostState->m_levelName, "mp_lobby"); - g_pHostState->m_iNextState = HS_NEW_GAME; + // weird way of checking, but check if client script vm is initialised, mainly just to allow players to cancel this + if (g_ClientSquirrelManager->sqvm) + { + g_ServerAuthenticationManager->m_bNeedLocalAuthForNewgame = true; + // this won't set playlist correctly on remote clients, don't think they can set playlist until they've left which sorta fucks things + // should maybe set this in HostState_NewGame? + SetCurrentPlaylist("tdm"); + strcpy(g_pHostState->m_levelName, "mp_lobby"); + g_pHostState->m_iNextState = HS_NEW_GAME; + } } void AddMiscConCommands() diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp index 52e376f6..ba2e8b07 100644 --- a/NorthstarDedicatedTest/serverauthentication.cpp +++ b/NorthstarDedicatedTest/serverauthentication.cpp @@ -310,7 +310,7 @@ void InitialiseServerAuthentication(HMODULE baseAddress) CVar_ns_auth_allow_insecure = RegisterConVar("ns_auth_allow_insecure", "0", FCVAR_GAMEDLL, "Whether this server will allow unauthenicated players to connect"); CVar_ns_auth_allow_insecure_write = RegisterConVar("ns_auth_allow_insecure_write", "0", FCVAR_GAMEDLL, "Whether the pdata of unauthenticated clients will be written to disk when changed"); // literally just stolen from a fix valve used in csgo - CVar_sv_quota_stringcmdspersecond = RegisterConVar("sv_quota_stringcmdspersecond", "60", FCVAR_NONE, "How many string commands per second clients are allowed to submit, 0 to disallow all string commands"); + CVar_sv_quota_stringcmdspersecond = RegisterConVar("sv_quota_stringcmdspersecond", "60", FCVAR_GAMEDLL, "How many string commands per second clients are allowed to submit, 0 to disallow all string commands"); Cvar_ns_player_auth_port = RegisterConVar("ns_player_auth_port", "8081", FCVAR_GAMEDLL, ""); HookEnabler hook; |