diff options
-rw-r--r-- | NorthstarDedicatedTest/concommand.cpp | 8 | ||||
-rw-r--r-- | NorthstarDedicatedTest/concommand.h | 1 | ||||
-rw-r--r-- | NorthstarDedicatedTest/convar.cpp | 10 | ||||
-rw-r--r-- | NorthstarDedicatedTest/convar.h | 3 | ||||
-rw-r--r-- | NorthstarDedicatedTest/serverauthentication.cpp | 5 | ||||
-rw-r--r-- | NorthstarDedicatedTest/sourceconsole.cpp | 8 |
6 files changed, 21 insertions, 14 deletions
diff --git a/NorthstarDedicatedTest/concommand.cpp b/NorthstarDedicatedTest/concommand.cpp index d81796d8..2952e7e7 100644 --- a/NorthstarDedicatedTest/concommand.cpp +++ b/NorthstarDedicatedTest/concommand.cpp @@ -16,6 +16,14 @@ void RegisterConCommand(const char* name, void(*callback)(const CCommand&), cons conCommandConstructor(newCommand, name, callback, helpString, flags, nullptr); } +ConCommand* FindConCommand(const char* name) +{ + ICvar* icvar = *g_pCvar; // hellish call because i couldn't get icvar vtable stuff in convar.h to get the right offset for whatever reason + typedef ConCommand* (*FindCommandBaseType)(ICvar* self, const char* varName); + FindCommandBaseType FindCommandBase = *(FindCommandBaseType*)((*(char**)icvar) + 112); + return FindCommandBase(icvar, name); +} + void InitialiseConCommands(HMODULE baseAddress) { conCommandConstructor = (ConCommandConstructorType)((char*)baseAddress + 0x415F60); diff --git a/NorthstarDedicatedTest/concommand.h b/NorthstarDedicatedTest/concommand.h index 5b7fedae..7e610f91 100644 --- a/NorthstarDedicatedTest/concommand.h +++ b/NorthstarDedicatedTest/concommand.h @@ -89,4 +89,5 @@ inline const char* CCommand::operator[](int nIndex) const } void RegisterConCommand(const char* name, void(*callback)(const CCommand&), const char* helpString, int flags); +ConCommand* FindConCommand(const char* name); void InitialiseConCommands(HMODULE baseAddress);
\ No newline at end of file diff --git a/NorthstarDedicatedTest/convar.cpp b/NorthstarDedicatedTest/convar.cpp index 344f16c6..324779b4 100644 --- a/NorthstarDedicatedTest/convar.cpp +++ b/NorthstarDedicatedTest/convar.cpp @@ -27,10 +27,18 @@ ConVar* RegisterConVar(const char* name, const char* defaultValue, int flags, co return newVar; } +ConVar* FindConVar(const char* name) +{ + ICvar* icvar = *g_pCvar; // hellish call because i couldn't get icvar vtable stuff in convar.h to get the right offset for whatever reason + typedef ConVar* (*FindConVarType)(ICvar* self, const char* varName); + FindConVarType FindConVarInternal = *(FindConVarType*)((*(char**)icvar) + 128); + return FindConVarInternal(icvar, name); +} + bool CvarIsFlagSetHook(ConVar* self, int flags) { // unrestrict FCVAR_DEVELOPMENTONLY and FCVAR_HIDDEN - if (self && flags == FCVAR_DEVELOPMENTONLY || flags == FCVAR_HIDDEN) + if (self && (flags == FCVAR_DEVELOPMENTONLY || flags == FCVAR_HIDDEN)) return false; return CvarIsFlagSet(self, flags); diff --git a/NorthstarDedicatedTest/convar.h b/NorthstarDedicatedTest/convar.h index 3de8139b..df51edb7 100644 --- a/NorthstarDedicatedTest/convar.h +++ b/NorthstarDedicatedTest/convar.h @@ -96,7 +96,7 @@ public: //void* unknown2[28]; //ConVar*(*FindVar)(const char* var_name); // offset for this is currently very wrong char* unknown[112]; - ConCommand*(*FindCommandBase)(ICvar* self, const char* varName); + ConCommand*(*FindCommandBase)(ICvar* self, const char* varName); // this offset is also wrong for some reason }; VTable* m_vtable; @@ -104,6 +104,7 @@ public: ConVar* RegisterConVar(const char* name, const char* defaultValue, int flags, const char* helpString); +ConVar* FindConVar(const char* name); void InitialiseConVars(HMODULE baseAddress); extern std::unordered_map<std::string, ConVar*> g_CustomConvars; diff --git a/NorthstarDedicatedTest/serverauthentication.cpp b/NorthstarDedicatedTest/serverauthentication.cpp index f4fe25ea..d6a74008 100644 --- a/NorthstarDedicatedTest/serverauthentication.cpp +++ b/NorthstarDedicatedTest/serverauthentication.cpp @@ -372,10 +372,7 @@ char CGameClient__ExecuteStringCommandHook(void* self, uint32_t unknown, const c if (!CCommand__Tokenize(tempCommand, pCommandString, cmd_source_t::kCommandSrcCode) || !tempCommand.ArgC()) return false; - ICvar* icvar = *g_pCvar; // hellish call because i couldn't get icvar vtable stuff in convar.h to get the right offset for whatever reason - typedef ConCommand*(*FindCommandBaseType)(ICvar* self, const char* varName); - FindCommandBaseType FindCommandBase = *(FindCommandBaseType*)((*(char**)icvar) + 112); - ConCommand* command = FindCommandBase(icvar, tempCommand.Arg(0)); + ConCommand* command = FindConCommand(tempCommand.Arg(0)); // if the command doesn't exist pass it on to ExecuteStringCommand for script clientcommands and stuff if (command && !command->IsFlagSet(FCVAR_CLIENTCMD_CAN_EXECUTE)) diff --git a/NorthstarDedicatedTest/sourceconsole.cpp b/NorthstarDedicatedTest/sourceconsole.cpp index 64c6565c..98901737 100644 --- a/NorthstarDedicatedTest/sourceconsole.cpp +++ b/NorthstarDedicatedTest/sourceconsole.cpp @@ -15,14 +15,6 @@ void ConCommand_toggleconsole(const CCommand& arg) (*g_SourceGameConsole)->Activate(); } -void ConCommand_help(const CCommand& arg) -{ - if (arg.ArgC() < 2) - return; - - // todo: this should basically just call FindConVar once we have that working, then just print convar.GetHelpString -} - typedef void(*OnCommandSubmittedType)(CConsoleDialog* consoleDialog, const char* pCommand); OnCommandSubmittedType onCommandSubmittedOriginal; void OnCommandSubmittedHook(CConsoleDialog* consoleDialog, const char* pCommand) |