move to using g_pCVar more

This commit is contained in:
BobTheBob 2022-03-15 00:04:33 +00:00
parent 5df2346ba1
commit 96aa95aede
9 changed files with 38 additions and 42 deletions

View File

@ -2,6 +2,7 @@
#include "clientchathooks.h"
#include <rapidjson/document.h>
#include "squirrel.h"
#include "dedicated.h"
#include "serverchathooks.h"
#include "localchatwriter.h"
@ -86,6 +87,9 @@ static SQRESULT SQ_ChatWriteLine(void* sqvm)
void InitialiseClientChatHooks(HMODULE baseAddress)
{
if (IsDedicated())
return;
HookEnabler hook;
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x22E580, &CHudChat__AddGameLineHook, reinterpret_cast<LPVOID*>(&CHudChat__AddGameLine));

View File

@ -42,7 +42,7 @@ void RunServer(CDedicatedExports* dedicated)
// add +map if not present
// don't manually execute this from cbuf as users may have it in their startup args anyway, easier just to run from stuffcmds if present
if (!CommandLine()->CheckParm("+map"))
CommandLine()->AppendParm("+map", Cvar_match_defaultMap->GetString());
CommandLine()->AppendParm("+map", g_pCVar->FindVar("match_defaultMap")->GetString());
// run server autoexec and re-run commandline
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec autoexec_ns_server", cmd_source_t::kCommandSrcCode);
@ -55,6 +55,9 @@ void RunServer(CDedicatedExports* dedicated)
// note: we no longer manually set map and hoststate to start server in g_pHostState, we just use +map which seems to initialise stuff
// better
// get tickinterval
ConVar* Cvar_base_tickinterval_mp = g_pCVar->FindVar("base_tickinterval_mp");
// main loop
double frameTitle = 0;
while (g_pEngine->m_nQuitting == EngineQuitState::QUIT_NOTQUITTING)

View File

@ -33,7 +33,6 @@ VPKData* MountVPKHook(IFileSystem* fileSystem, const char* vpkPath);
bool readingOriginalFile;
std::string currentModPath;
SourceInterface<IFileSystem>* g_Filesystem;
void* g_pVGuiLocalize;
void InitialiseFilesystem(HMODULE baseAddress)
{

View File

@ -1,7 +1,6 @@
#include "pch.h"
#include "gameutils.h"
#include "convar.h"
#include "concommand.h"
#include "gameutils.h"
// memory
IMemAlloc* g_pMemAllocSingleton;
@ -22,7 +21,6 @@ server_state_t* sv_m_State;
// network stuff
ConVar* Cvar_hostport;
ConVar* Cvar_net_datablock_enabled;
// playlist stuff
GetCurrentPlaylistType GetCurrentPlaylistName;
@ -33,17 +31,11 @@ GetCurrentPlaylistVarType GetCurrentPlaylistVar;
// server entity stuff
Server_GetEntityByIndexType Server_GetEntityByIndex;
// server tickrate stuff
ConVar* Cvar_base_tickinterval_mp;
ConVar* Cvar_base_tickinterval_sp;
// auth
char* g_LocalPlayerUserID;
char* g_LocalPlayerOriginToken;
// misc stuff
ConVar* Cvar_match_defaultMap;
ConVar* Cvar_communities_hostname;
ErrorType Error;
CommandLineType CommandLine;
Plat_FloatTimeType Plat_FloatTime;
@ -84,17 +76,13 @@ void InitialiseEngineGameUtilFunctions(HMODULE baseAddress)
g_pAllConVars.push_back(pConVar);
}
}*/
Cvar_hostport = (ConVar*)((char*)baseAddress + 0x13FA6070);
Cvar_net_datablock_enabled = (ConVar*)((char*)baseAddress + 0x12A4F6D0);
Cvar_match_defaultMap = (ConVar*)((char*)baseAddress + 0x8AB530);
Cvar_communities_hostname = (ConVar*)((char*)baseAddress + 0x13157E50);
}
void InitialiseServerGameUtilFunctions(HMODULE baseAddress)
{
Server_GetEntityByIndex = (Server_GetEntityByIndexType)((char*)baseAddress + 0xFB820);
Cvar_base_tickinterval_mp = (ConVar*)((char*)baseAddress + 0xBFC360);
Cvar_base_tickinterval_sp = (ConVar*)((char*)baseAddress + 0xBFBEA0);
}
void InitialiseTier0GameUtilFunctions(HMODULE baseAddress)

View File

@ -206,7 +206,6 @@ extern server_state_t* sv_m_State;
// network stuff
extern ConVar* Cvar_hostport;
extern ConVar* Cvar_net_datablock_enabled;
// playlist stuff
typedef const char* (*GetCurrentPlaylistType)();
@ -225,18 +224,11 @@ extern GetCurrentPlaylistVarType GetCurrentPlaylistVar;
typedef void* (*Server_GetEntityByIndexType)(int index);
extern Server_GetEntityByIndexType Server_GetEntityByIndex;
// server tickrate stuff
extern ConVar* Cvar_base_tickinterval_mp;
extern ConVar* Cvar_base_tickinterval_sp;
// auth
extern char* g_LocalPlayerUserID;
extern char* g_LocalPlayerOriginToken;
// misc stuff
extern ConVar* Cvar_match_defaultMap;
extern ConVar* Cvar_communities_hostname;
typedef void (*ErrorType)(const char* fmt, ...);
extern ErrorType Error;

View File

@ -3,7 +3,7 @@
#include "sourceconsole.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "hookutils.h"
#include "gameutils.h"
#include "convar.h"
#include "dedicated.h"
#include <iomanip>
#include <sstream>

View File

@ -390,21 +390,25 @@ void InitialisePluginCommands(HMODULE baseAddress)
// 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
g_UISquirrelManager->AddFuncRegistration(
"void", "NSUpdateGameStateUI", "string gamemode, string gamemodeName, string map, string mapName, bool connected, bool loading", "",
SQ_UpdateGameStateUI);
g_ClientSquirrelManager->AddFuncRegistration(
"void", "NSUpdateGameStateClient",
"int playerCount, int outScore, int secondHighestScore, int highestScore, bool roundBased, int scoreLimit", "",
SQ_UpdateGameStateClient);
g_UISquirrelManager->AddFuncRegistration(
"void", "NSUpdateServerInfo",
"string id, string name, string password, int players, int maxPlayers, string map, string mapDisplayName, string playlist, string "
"playlistDisplayName",
"", SQ_UpdateServerInfo);
g_ClientSquirrelManager->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);
if (g_UISquirrelManager && g_ClientSquirrelManager)
{
g_UISquirrelManager->AddFuncRegistration(
"void", "NSUpdateGameStateUI", "string gamemode, string gamemodeName, string map, string mapName, bool connected, bool loading",
"", SQ_UpdateGameStateUI);
g_ClientSquirrelManager->AddFuncRegistration(
"void", "NSUpdateGameStateClient",
"int playerCount, int outScore, int secondHighestScore, int highestScore, bool roundBased, int scoreLimit", "",
SQ_UpdateGameStateClient);
g_UISquirrelManager->AddFuncRegistration(
"void", "NSUpdateServerInfo",
"string id, string name, string password, int players, int maxPlayers, string map, string mapDisplayName, string playlist, "
"string "
"playlistDisplayName",
"", SQ_UpdateServerInfo);
g_ClientSquirrelManager->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);
}
}

View File

@ -4,6 +4,7 @@
#include "concommand.h"
#include "dedicated.h"
#include "gameutils.h"
#include "convar.h"
typedef bool (*IsValveModType)();
IsValveModType IsValveMod;

View File

@ -1,5 +1,6 @@
#include "pch.h"
#include "serverauthentication.h"
#include "cvar.h"
#include "convar.h"
#include "hookutils.h"
#include "masterserver.h"
@ -63,6 +64,8 @@ ConVar* Cvar_net_chan_limit_msec_per_sec;
ConVar* Cvar_sv_querylimit_per_sec;
ConVar* Cvar_sv_max_chat_messages_per_sec;
ConVar* Cvar_net_datablock_enabled;
void ServerAuthenticationManager::StartPlayerAuthServer()
{
if (m_runningPlayerAuthThread)
@ -596,6 +599,8 @@ void InitialiseServerAuthentication(HMODULE baseAddress)
Cvar_sv_querylimit_per_sec = new ConVar("sv_querylimit_per_sec", "15", FCVAR_GAMEDLL, "");
Cvar_sv_max_chat_messages_per_sec = new ConVar("sv_max_chat_messages_per_sec", "5", FCVAR_GAMEDLL, "");
Cvar_net_datablock_enabled = g_pCVar->FindVar("net_datablock_enabled");
RegisterConCommand("ns_resetpersistence", ResetPdataCommand, "resets your pdata when you next enter the lobby", FCVAR_NONE);
HookEnabler hook;