diff options
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj | 6 | ||||
-rw-r--r-- | NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters | 69 | ||||
-rw-r--r-- | NorthstarDedicatedTest/commandprint.cpp | 161 | ||||
-rw-r--r-- | NorthstarDedicatedTest/commandprint.h | 6 | ||||
-rw-r--r-- | NorthstarDedicatedTest/dedicated.cpp | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/demofixes.cpp | 25 | ||||
-rw-r--r-- | NorthstarDedicatedTest/demofixes.h | 1 | ||||
-rw-r--r-- | NorthstarDedicatedTest/host.cpp | 6 | ||||
-rw-r--r-- | NorthstarDedicatedTest/mapsprint.cpp | 7 | ||||
-rw-r--r-- | NorthstarDedicatedTest/mapsprint.h | 2 | ||||
-rw-r--r-- | NorthstarDedicatedTest/miscclientfixes.cpp | 15 | ||||
-rw-r--r-- | NorthstarDedicatedTest/sourceconsole.cpp | 117 |
12 files changed, 266 insertions, 151 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj index a12a10f5..172ad4ca 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj @@ -120,12 +120,15 @@ <ClInclude Include="buildainfile.h" /> <ClInclude Include="chatcommand.h" /> <ClInclude Include="clientchathooks.h" /> + <ClInclude Include="commandprint.h" /> <ClInclude Include="debugoverlay.h" /> <ClInclude Include="clientruihooks.h" /> <ClInclude Include="clientvideooverrides.h" /> + <ClInclude Include="demofixes.h" /> <ClInclude Include="host.h" /> <ClInclude Include="hoststate.h" /> <ClInclude Include="localchatwriter.h" /> + <ClInclude Include="mapsprint.h" /> <ClInclude Include="ns_version.h" /> <ClInclude Include="plugins.h" /> <ClInclude Include="plugin_abi.h" /> @@ -592,6 +595,7 @@ <ClCompile Include="debugoverlay.cpp" /> <ClCompile Include="dedicated.cpp" /> <ClCompile Include="dedicatedmaterialsystem.cpp" /> + <ClCompile Include="demofixes.cpp" /> <ClCompile Include="dllmain.cpp" /> <ClCompile Include="filesystem.cpp" /> <ClCompile Include="gameutils.cpp" /> @@ -602,6 +606,7 @@ <ClCompile Include="keyvalues.cpp" /> <ClCompile Include="latencyflex.cpp" /> <ClCompile Include="localchatwriter.cpp" /> + <ClCompile Include="mapsprint.cpp" /> <ClCompile Include="maxplayers.cpp" /> <ClCompile Include="languagehooks.cpp" /> <ClCompile Include="memalloc.cpp" /> @@ -619,6 +624,7 @@ <ClCompile Include="pdef.cpp" /> <ClCompile Include="playlist.cpp" /> <ClCompile Include="plugins.cpp" /> + <ClCompile Include="commandprint.cpp" /> <ClCompile Include="rpakfilesystem.cpp" /> <ClCompile Include="scriptbrowserhooks.cpp" /> <ClCompile Include="scriptmainmenupromos.cpp" /> diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters index 0dc606d2..8f63935b 100644 --- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters +++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters @@ -25,9 +25,6 @@ <Filter Include="Source Files\Shared"> <UniqueIdentifier>{4f525372-34a8-40b3-8a95-81d77cdfcf7f}</UniqueIdentifier> </Filter> - <Filter Include="Header Files\Dedicated"> - <UniqueIdentifier>{8b8ed12a-9269-4dc3-b932-0daefdf6a388}</UniqueIdentifier> - </Filter> <Filter Include="Source Files\Client"> <UniqueIdentifier>{b6f79919-9735-476d-8798-067a75cbeca0}</UniqueIdentifier> </Filter> @@ -142,6 +139,18 @@ <Filter Include="Source Files\Shared\Console"> <UniqueIdentifier>{04fd662a-6e70-494c-b720-c694a5cc2fb1}</UniqueIdentifier> </Filter> + <Filter Include="Source Files\Server\Scripted"> + <UniqueIdentifier>{325e0d7d-6832-496d-8d8e-968fdfa5dd40}</UniqueIdentifier> + </Filter> + <Filter Include="Header Files\Server\Scripted"> + <UniqueIdentifier>{802d0771-62f1-4733-89f9-57a4d8864b8d}</UniqueIdentifier> + </Filter> + <Filter Include="Header Files\Server\Dedicated"> + <UniqueIdentifier>{0f1ba4c4-78ee-4b05-afa5-6f598063f5c1}</UniqueIdentifier> + </Filter> + <Filter Include="Header Files\Shared\Console"> + <UniqueIdentifier>{bf0769d8-40fd-4701-85e9-7ed94aab2283}</UniqueIdentifier> + </Filter> </ItemGroup> <ItemGroup> <ClInclude Include="pch.h"> @@ -159,9 +168,6 @@ <ClInclude Include="main.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="dedicated.h"> - <Filter>Header Files\Dedicated</Filter> - </ClInclude> <ClInclude Include="sourceconsole.h"> <Filter>Header Files\Client</Filter> </ClInclude> @@ -585,15 +591,9 @@ <ClInclude Include="modlocalisation.h"> <Filter>Header Files\Client</Filter> </ClInclude> - <ClInclude Include="dedicatedmaterialsystem.h"> - <Filter>Header Files\Dedicated</Filter> - </ClInclude> <ClInclude Include="misccommands.h"> <Filter>Header Files\Shared\Convar</Filter> </ClInclude> - <ClInclude Include="miscserverscript.h"> - <Filter>Header Files\Server</Filter> - </ClInclude> <ClInclude Include="pdef.h"> <Filter>Header Files\Shared\Mods\Compiled</Filter> </ClInclude> @@ -1458,9 +1458,6 @@ <ClInclude Include="bits.h"> <Filter>Header Files\Shared\Math</Filter> </ClInclude> - <ClInclude Include="serverchathooks.h"> - <Filter>Header Files\Server</Filter> - </ClInclude> <ClInclude Include="localchatwriter.h"> <Filter>Header Files\Client</Filter> </ClInclude> @@ -1527,6 +1524,27 @@ <ClInclude Include="hoststate.h"> <Filter>Header Files\Shared</Filter> </ClInclude> + <ClInclude Include="miscserverscript.h"> + <Filter>Header Files\Server\Scripted</Filter> + </ClInclude> + <ClInclude Include="serverchathooks.h"> + <Filter>Header Files\Server\Scripted</Filter> + </ClInclude> + <ClInclude Include="dedicated.h"> + <Filter>Header Files\Server\Dedicated</Filter> + </ClInclude> + <ClInclude Include="dedicatedmaterialsystem.h"> + <Filter>Header Files\Server\Dedicated</Filter> + </ClInclude> + <ClInclude Include="commandprint.h"> + <Filter>Header Files\Shared\Console</Filter> + </ClInclude> + <ClInclude Include="mapsprint.h"> + <Filter>Header Files\Shared\Console</Filter> + </ClInclude> + <ClInclude Include="demofixes.h"> + <Filter>Header Files\Client</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="dllmain.cpp"> @@ -1598,9 +1616,6 @@ <ClCompile Include="misccommands.cpp"> <Filter>Source Files\Shared\Convar</Filter> </ClCompile> - <ClCompile Include="miscserverscript.cpp"> - <Filter>Source Files\Server</Filter> - </ClCompile> <ClCompile Include="pdef.cpp"> <Filter>Source Files\Shared\Mods\Compiled Assets</Filter> </ClCompile> @@ -1646,9 +1661,6 @@ <ClCompile Include="bits.cpp"> <Filter>Source Files\Shared\Math</Filter> </ClCompile> - <ClCompile Include="serverchathooks.cpp"> - <Filter>Source Files\Server</Filter> - </ClCompile> <ClCompile Include="localchatwriter.cpp"> <Filter>Source Files\Client</Filter> </ClCompile> @@ -1700,6 +1712,21 @@ <ClCompile Include="scriptbrowserhooks.cpp"> <Filter>Source Files\Client\Scripted</Filter> </ClCompile> + <ClCompile Include="serverchathooks.cpp"> + <Filter>Source Files\Server\Scripted</Filter> + </ClCompile> + <ClCompile Include="miscserverscript.cpp"> + <Filter>Source Files\Server\Scripted</Filter> + </ClCompile> + <ClCompile Include="commandprint.cpp"> + <Filter>Source Files\Shared\Console</Filter> + </ClCompile> + <ClCompile Include="demofixes.cpp"> + <Filter>Source Files\Client</Filter> + </ClCompile> + <ClCompile Include="mapsprint.cpp"> + <Filter>Source Files\Shared\Console</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <MASM Include="audio_asm.asm"> diff --git a/NorthstarDedicatedTest/commandprint.cpp b/NorthstarDedicatedTest/commandprint.cpp new file mode 100644 index 00000000..5d78a1b4 --- /dev/null +++ b/NorthstarDedicatedTest/commandprint.cpp @@ -0,0 +1,161 @@ +#include "pch.h" +#include "commandprint.h" +#include "convar.h" +#include "concommand.h" + +void PrintCommandHelpDialogue(const ConCommandBase* command, const char* name) +{ + if (!command) + { + spdlog::info("unknown command {}", name); + return; + } + + // build string for flags if not FCVAR_NONE + std::string flagString; + if (command->GetFlags() != FCVAR_NONE) + { + flagString = "( "; + + for (auto& flagPair : g_PrintCommandFlags) + { + if (command->GetFlags() & flagPair.first) + { + flagString += flagPair.second; + flagString += " "; + } + } + + flagString += ") "; + } + + // temp because command->IsCommand does not currently work + ConVar* cvar = g_pCVar->FindVar(command->m_pszName); + if (cvar) + spdlog::info("\"{}\" = \"{}\" {}- {}", cvar->GetBaseName(), cvar->GetString(), flagString, cvar->GetHelpText()); + else + spdlog::info("\"{}\" {} - {}", command->m_pszName, flagString, command->GetHelpText()); +} + +void TryPrintCvarHelpForCommand(const char* pCommand) +{ + // try to display help text for an inputted command string from the console + int pCommandLen = strlen(pCommand); + char* pCvarStr = new char[pCommandLen]; + strcpy(pCvarStr, pCommand); + + // trim whitespace from right + for (int i = pCommandLen - 1; i; i--) + { + if (isspace(pCvarStr[i])) + pCvarStr[i] = '\0'; + else + break; + } + + // check if we're inputting a cvar, but not setting it at all + ConVar* cvar = g_pCVar->FindVar(pCvarStr); + if (cvar) + PrintCommandHelpDialogue(&cvar->m_ConCommandBase, pCvarStr); + + delete[] pCvarStr; +} + +void ConCommand_help(const CCommand& arg) +{ + if (arg.ArgC() < 2) + { + spdlog::info("Usage: help <cvarname>"); + return; + } + + PrintCommandHelpDialogue(g_pCVar->FindCommandBase(arg.Arg(1)), arg.Arg(1)); +} + +void ConCommand_find(const CCommand& arg) +{ + if (arg.ArgC() < 2) + { + spdlog::info("Usage: find <string> [<string>...]"); + return; + } + + char pTempName[256]; + char pTempSearchTerm[256]; + + for (auto& map : g_pCVar->DumpToMap()) + { + bool bPrintCommand = true; + for (int i = 0; i < arg.ArgC() - 1; i++) + { + // make lowercase to avoid case sensitivity + strncpy(pTempName, map.second->m_pszName, sizeof(pTempName)); + strncpy(pTempSearchTerm, arg.Arg(i + 1), sizeof(pTempSearchTerm)); + + for (int i = 0; pTempName[i]; i++) + pTempName[i] = tolower(pTempName[i]); + + for (int i = 0; pTempSearchTerm[i]; i++) + pTempSearchTerm[i] = tolower(pTempSearchTerm[i]); + + if (!strstr(pTempName, pTempSearchTerm)) + { + bPrintCommand = false; + break; + } + } + + if (bPrintCommand) + PrintCommandHelpDialogue(map.second, map.second->m_pszName); + } +} + +void ConCommand_findflags(const CCommand& arg) +{ + if (arg.ArgC() < 2) + { + spdlog::info("Usage: findflags <string>"); + for (auto& flagPair : g_PrintCommandFlags) + spdlog::info(" - {}", flagPair.second); + + return; + } + + // convert input flag to uppercase + char* upperFlag = new char[strlen(arg.Arg(1))]; + strcpy(upperFlag, arg.Arg(1)); + + for (int i = 0; upperFlag[i]; i++) + upperFlag[i] = toupper(upperFlag[i]); + + // resolve flag name => int flags + int resolvedFlag = FCVAR_NONE; + for (auto& flagPair : g_PrintCommandFlags) + { + if (!strcmp(flagPair.second, upperFlag)) + { + resolvedFlag = flagPair.first; + break; + } + } + + // print cvars + for (auto& map : g_pCVar->DumpToMap()) + { + if (map.second->m_nFlags & resolvedFlag) + PrintCommandHelpDialogue(map.second, map.second->m_pszName); + } + + delete[] upperFlag; +} + +void InitialiseCommandPrint() +{ + RegisterConCommand("find", ConCommand_find, "Find concommands with the specified string in their name/help text.", FCVAR_NONE); + RegisterConCommand("findflags", ConCommand_findflags, "Find concommands by flags.", FCVAR_NONE); + // help is already a command, so we need to modify the preexisting command to use our func instead + // and clear the flags also + ConCommand* helpCommand = g_pCVar->FindCommand("help"); + helpCommand->m_nFlags = FCVAR_NONE; + helpCommand->m_pCommandCallback = ConCommand_help; +}
\ No newline at end of file diff --git a/NorthstarDedicatedTest/commandprint.h b/NorthstarDedicatedTest/commandprint.h new file mode 100644 index 00000000..803cccc4 --- /dev/null +++ b/NorthstarDedicatedTest/commandprint.h @@ -0,0 +1,6 @@ +#pragma once +#include "concommand.h" + +void PrintCommandHelpDialogue(const ConCommandBase* command, const char* name); +void TryPrintCvarHelpForCommand(const char* pCommand); +void InitialiseCommandPrint();
\ No newline at end of file diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp index 280a9889..2df43fe9 100644 --- a/NorthstarDedicatedTest/dedicated.cpp +++ b/NorthstarDedicatedTest/dedicated.cpp @@ -8,6 +8,7 @@ #include "hoststate.h" #include "serverauthentication.h" #include "masterserver.h" +#include "commandprint.h" using namespace Tier0; using namespace R2; @@ -125,6 +126,7 @@ DWORD WINAPI ConsoleInputThread(PVOID pThreadParameter) { input += "\n"; Cbuf_AddText(Cbuf_GetCurrentPlayer(), input.c_str(), cmd_source_t::kCommandSrcCode); + TryPrintCvarHelpForCommand(input.c_str()); } } diff --git a/NorthstarDedicatedTest/demofixes.cpp b/NorthstarDedicatedTest/demofixes.cpp new file mode 100644 index 00000000..0cfb35f4 --- /dev/null +++ b/NorthstarDedicatedTest/demofixes.cpp @@ -0,0 +1,25 @@ +#include "pch.h" +#include "demofixes.h" +#include "convar.h" +#include "NSMem.h" + +ON_DLL_LOAD_CLIENT_RELIESON("client.dll", DemoFixes, ConVar, [](HMODULE baseAddress) +{ + // allow demo recording on loopback + NSMem::NOP((uintptr_t)GetModuleHandleA("engine.dll") + 0x8E1B1, 2); + NSMem::NOP((uintptr_t)GetModuleHandleA("engine.dll") + 0x56CC3, 2); + + // change default values of demo cvars to enable them by default, but not autorecord + // this is before Host_Init, the setvalue calls here will get overwritten by custom cfgs/launch options + ConVar* Cvar_demo_enableDemos = g_pCVar->FindVar("demo_enabledemos"); + Cvar_demo_enableDemos->m_pszDefaultValue = "1"; + Cvar_demo_enableDemos->SetValue(true); + + ConVar* Cvar_demo_writeLocalFile = g_pCVar->FindVar("demo_writeLocalFile"); + Cvar_demo_writeLocalFile->m_pszDefaultValue = "1"; + Cvar_demo_writeLocalFile->SetValue(true); + + ConVar* Cvar_demo_autoRecord = g_pCVar->FindVar("demo_autoRecord"); + Cvar_demo_autoRecord->m_pszDefaultValue = "0"; + Cvar_demo_autoRecord->SetValue(false); +})
\ No newline at end of file diff --git a/NorthstarDedicatedTest/demofixes.h b/NorthstarDedicatedTest/demofixes.h new file mode 100644 index 00000000..7b9637ef --- /dev/null +++ b/NorthstarDedicatedTest/demofixes.h @@ -0,0 +1 @@ +#pragma once
\ No newline at end of file diff --git a/NorthstarDedicatedTest/host.cpp b/NorthstarDedicatedTest/host.cpp index 5f56be4e..624809b5 100644 --- a/NorthstarDedicatedTest/host.cpp +++ b/NorthstarDedicatedTest/host.cpp @@ -3,6 +3,8 @@ #include "convar.h" #include "modmanager.h" #include "gameutils.h" +#include "commandprint.h" +#include "mapsprint.h" typedef void (*Host_InitType)(bool bDedicated); Host_InitType Host_Init; @@ -46,6 +48,10 @@ void Host_InitHook(bool bDedicated) // make servers able to run disconnect on clients g_pCVar->FindCommand("disconnect")->m_nFlags |= FCVAR_SERVER_CAN_EXECUTE; + // need to initialise these after host_init since they do stuff to preexisting concommands/convars + InitialiseCommandPrint(); + InitialiseMapsPrint(); + // run client autoexec if on client if (!bDedicated) Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec autoexec_ns_client", cmd_source_t::kCommandSrcCode); diff --git a/NorthstarDedicatedTest/mapsprint.cpp b/NorthstarDedicatedTest/mapsprint.cpp new file mode 100644 index 00000000..770fb9cf --- /dev/null +++ b/NorthstarDedicatedTest/mapsprint.cpp @@ -0,0 +1,7 @@ +#include "pch.h" +#include "mapsprint.h" + +void InitialiseMapsPrint() +{ + +}
\ No newline at end of file diff --git a/NorthstarDedicatedTest/mapsprint.h b/NorthstarDedicatedTest/mapsprint.h new file mode 100644 index 00000000..daa1df8c --- /dev/null +++ b/NorthstarDedicatedTest/mapsprint.h @@ -0,0 +1,2 @@ +#pragma once +void InitialiseMapsPrint();
\ No newline at end of file diff --git a/NorthstarDedicatedTest/miscclientfixes.cpp b/NorthstarDedicatedTest/miscclientfixes.cpp index a72e1893..777d5696 100644 --- a/NorthstarDedicatedTest/miscclientfixes.cpp +++ b/NorthstarDedicatedTest/miscclientfixes.cpp @@ -33,21 +33,6 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", MiscClientFixes, ConVar, [](HMODULE ba { HookEnabler hook; - // these functions will occasionally pass a null pointer on respawn, unsure what causes this but seems easiest just to return null if - // null, which seems to work fine fucking sucks this has to be fixed like this but unsure what exactly causes this serverside, breaks - // vanilla compatibility to a degree tho will say i have about 0 clue what exactly these functions do, testing this it doesn't even seem - // like they do much of anything i can see tbh - ENABLER_CREATEHOOK( - hook, (char*)baseAddress + 0x5A92D0, &CrashingWeaponActivityFunc0Hook, reinterpret_cast<LPVOID*>(&CrashingWeaponActivityFunc0)); - ENABLER_CREATEHOOK( - hook, (char*)baseAddress + 0x5A9310, &CrashingWeaponActivityFunc1Hook, reinterpret_cast<LPVOID*>(&CrashingWeaponActivityFunc1)); - - // experimental: allow cl_extrapolate to be enabled without cheats - { - void* ptr = (char*)baseAddress + 0x275F9D9; - *((char*)ptr) = (char)0; - } - // allow demo recording on loopback NSMem::NOP((uintptr_t)GetModuleHandleA("engine.dll") + 0x8E1B1, 2); NSMem::NOP((uintptr_t)GetModuleHandleA("engine.dll") + 0x56CC3, 2); diff --git a/NorthstarDedicatedTest/sourceconsole.cpp b/NorthstarDedicatedTest/sourceconsole.cpp index ee05cc66..e6035ac5 100644 --- a/NorthstarDedicatedTest/sourceconsole.cpp +++ b/NorthstarDedicatedTest/sourceconsole.cpp @@ -4,7 +4,7 @@ #include "sourceconsole.h" #include "sourceinterface.h" #include "concommand.h" -#include "hookutils.h" +#include "commandprint.h" SourceInterface<CGameConsole>* g_SourceGameConsole; @@ -26,89 +26,6 @@ void ConCommand_hideconsole(const CCommand& arg) (*g_SourceGameConsole)->Hide(); } -void PrintCommandHelpDialogue(const ConCommandBase* command, const char* name) -{ - if (!command) - { - spdlog::info("unknown command {}", name); - return; - } - - // build string for flags if not FCVAR_NONE - std::string flagString; - if (command->GetFlags() != FCVAR_NONE) - { - flagString = "( "; - - for (auto& flagPair : g_PrintCommandFlags) - { - if (command->GetFlags() & flagPair.first) - { - flagString += flagPair.second; - flagString += " "; - } - } - - flagString += ") "; - } - - // temp because command->IsCommand does not currently work - ConVar* cvar = g_pCVar->FindVar(command->m_pszName); - if (cvar) - spdlog::info("\"{}\" = \"{}\" {}- {}", cvar->GetBaseName(), cvar->GetString(), flagString, cvar->GetHelpText()); - else - spdlog::info("\"{}\" {} - {}", command->m_pszName, flagString, command->GetHelpText()); -} - -void ConCommand_help(const CCommand& arg) -{ - if (arg.ArgC() < 2) - { - spdlog::info("Usage: help <cvarname>"); - return; - } - - PrintCommandHelpDialogue(g_pCVar->FindCommandBase(arg.Arg(1)), arg.Arg(1)); -} - -void ConCommand_find(const CCommand& arg) -{ - if (arg.ArgC() < 2) - { - spdlog::info("Usage: find <string> [<string>...]"); - return; - } - - char pTempName[256]; - char pTempSearchTerm[256]; - - for (auto& map : g_pCVar->DumpToMap()) - { - bool bPrintCommand = true; - for (int i = 0; i < arg.ArgC() - 1; i++) - { - // make lowercase to avoid case sensitivity - strncpy(pTempName, map.second->m_pszName, sizeof(pTempName)); - strncpy(pTempSearchTerm, arg.Arg(i + 1), sizeof(pTempSearchTerm)); - - for (int i = 0; pTempName[i]; i++) - pTempName[i] = tolower(pTempName[i]); - - for (int i = 0; pTempSearchTerm[i]; i++) - pTempSearchTerm[i] = tolower(pTempSearchTerm[i]); - - if (!strstr(pTempName, pTempSearchTerm)) - { - bPrintCommand = false; - break; - } - } - - if (bPrintCommand) - PrintCommandHelpDialogue(map.second, map.second->m_pszName); - } -} - typedef void (*OnCommandSubmittedType)(CConsoleDialog* consoleDialog, const char* pCommand); OnCommandSubmittedType onCommandSubmittedOriginal; void OnCommandSubmittedHook(CConsoleDialog* consoleDialog, const char* pCommand) @@ -117,28 +34,7 @@ void OnCommandSubmittedHook(CConsoleDialog* consoleDialog, const char* pCommand) consoleDialog->m_pConsolePanel->Print(pCommand); consoleDialog->m_pConsolePanel->Print("\n"); - // try to display help text for this cvar - { - int pCommandLen = strlen(pCommand); - char* pCvarStr = new char[pCommandLen]; - strcpy(pCvarStr, pCommand); - - // trim whitespace from right - for (int i = pCommandLen - 1; i; i--) - { - if (isspace(pCvarStr[i])) - pCvarStr[i] = '\0'; - else - break; - } - - // check if we're inputting a cvar, but not setting it at all - ConVar* cvar = g_pCVar->FindVar(pCvarStr); - if (cvar) - PrintCommandHelpDialogue(&cvar->m_ConCommandBase, pCvarStr); - - delete[] pCvarStr; - } + TryPrintCvarHelpForCommand(pCommand); onCommandSubmittedOriginal(consoleDialog, pCommand); } @@ -162,8 +58,6 @@ void InitialiseConsoleOnInterfaceCreation() reinterpret_cast<LPVOID*>(&onCommandSubmittedOriginal)); } -// logging stuff - SourceConsoleSink::SourceConsoleSink() { logColours.emplace(spdlog::level::trace, SourceColor(0, 255, 255, 255)); @@ -194,11 +88,4 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", SourceConsole, ConCommand, [](HMODULE RegisterConCommand("toggleconsole", ConCommand_toggleconsole, "Show/hide the console.", FCVAR_DONTRECORD); RegisterConCommand("showconsole", ConCommand_showconsole, "Show the console.", FCVAR_DONTRECORD); RegisterConCommand("hideconsole", ConCommand_hideconsole, "Hide the console.", FCVAR_DONTRECORD); - RegisterConCommand("find", ConCommand_find, "Find concommands with the specified string in their name/help text.", FCVAR_NONE); - - // help is already a command, so we need to modify the preexisting command to use our func instead - // and clear the flags also - ConCommand* helpCommand = g_pCVar->FindCommand("help"); - helpCommand->m_nFlags = 0; - helpCommand->m_pCommandCallback = ConCommand_help; })
\ No newline at end of file |