aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/concommand.h
diff options
context:
space:
mode:
authorKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-02-23 22:27:08 +0100
committerGitHub <noreply@github.com>2022-02-23 18:27:08 -0300
commit4f28a07d0562ca905bbcdb010b69604c330194bb (patch)
tree32ce0e8b0eff10cba6944a561e3538931a6033b6 /NorthstarDedicatedTest/concommand.h
parent8c9f34283f8670dda98959d0785d682e6f652a93 (diff)
downloadNorthstarLauncher-4f28a07d0562ca905bbcdb010b69604c330194bb.tar.gz
NorthstarLauncher-4f28a07d0562ca905bbcdb010b69604c330194bb.zip
ConVar class rebuild (#90)
* Implement CCvar class with mapped out vtable funcs * Rebuilded ConVar class + code overhaul to use new system * ConVar class is now properly mapped out for r2 (0x80 in size). * Reimplemented and exposed all frequently used ConVar class methods to the SDK. * Implement frequently used CCvar class methods. * Implement all CCVarIteratorInternal class methods. * Performed additional cleanup over the SDK to use new system instead. * ConVar class improvements + rebuilded ConCommand struct * Fix actual struct size for ConCommand
Diffstat (limited to 'NorthstarDedicatedTest/concommand.h')
-rw-r--r--NorthstarDedicatedTest/concommand.h79
1 files changed, 55 insertions, 24 deletions
diff --git a/NorthstarDedicatedTest/concommand.h b/NorthstarDedicatedTest/concommand.h
index c7458794..b1342163 100644
--- a/NorthstarDedicatedTest/concommand.h
+++ b/NorthstarDedicatedTest/concommand.h
@@ -1,26 +1,15 @@
#pragma once
-#include "convar.h"
-// taken from ttf2sdk
-class ConCommand
+// From Source SDK
+class ConCommandBase;
+class IConCommandBaseAccessor
{
- unsigned char unknown[0x68];
-
public:
- virtual void EngineDestructor(void) {}
- virtual bool IsCommand(void) const { return false; }
- virtual bool IsFlagSet(int flag) { return false; }
- virtual void AddFlags(int flags) {}
- virtual void RemoveFlags(int flags) {}
- virtual int GetFlags() const { return 0; }
- virtual const char* GetName(void) const { return nullptr; }
- virtual const char* GetHelpText(void) const { return nullptr; }
- virtual bool IsRegistered(void) const { return false; }
- // NOTE: there are more virtual methods here
- // NOTE: Not using the engine's destructor here because it doesn't do anything useful for us
+ // Flags is a combination of FCVAR flags in cvar.h.
+ // hOut is filled in with a handle to the variable.
+ virtual bool RegisterConCommandBase(ConCommandBase* pVar) = 0;
};
-// From Source SDK
class CCommand
{
public:
@@ -50,15 +39,10 @@ class CCommand
};
inline int CCommand::MaxCommandLength() { return COMMAND_MAX_LENGTH - 1; }
-
inline int64_t CCommand::ArgC() const { return m_nArgc; }
-
inline const char** CCommand::ArgV() const { return m_nArgc ? (const char**)m_ppArgv : NULL; }
-
inline const char* CCommand::ArgS() const { return m_nArgv0Size ? &m_pArgSBuffer[m_nArgv0Size] : ""; }
-
inline const char* CCommand::GetCommandString() const { return m_nArgc ? m_pArgSBuffer : ""; }
-
inline const char* CCommand::Arg(int nIndex) const
{
// FIXME: Many command handlers appear to not be particularly careful
@@ -68,9 +52,56 @@ inline const char* CCommand::Arg(int nIndex) const
return "";
return m_ppArgv[nIndex];
}
-
inline const char* CCommand::operator[](int nIndex) const { return Arg(nIndex); }
+// From r5reloaded
+class ConCommandBase
+{
+ public:
+ bool HasFlags(int nFlags);
+ void AddFlags(int nFlags);
+ void RemoveFlags(int nFlags);
+
+ bool IsCommand(void) const;
+ bool IsRegistered(void) const;
+ bool IsFlagSet(int nFlags) const;
+ static bool IsFlagSet(ConCommandBase* pCommandBase, int nFlags); // For hooking to engine's implementation.
+
+ int GetFlags(void) const;
+ ConCommandBase* GetNext(void) const;
+ const char* GetHelpText(void) const;
+
+ char* CopyString(const char* szFrom) const;
+
+ void* m_pConCommandBaseVTable; // 0x0000
+ ConCommandBase* m_pNext; // 0x0008
+ bool m_bRegistered; // 0x0010
+ char pad_0011[7]; // 0x0011 <- 3 bytes padding + unk int32.
+ const char* m_pszName; // 0x0018
+ const char* m_pszHelpString; // 0x0020
+ int m_nFlags; // 0x0028
+ ConCommandBase* s_pConCommandBases; // 0x002C
+ IConCommandBaseAccessor* s_pAccessor; // 0x0034
+}; // Size: 0x0040
+
+// taken from ttf2sdk
+class ConCommand : public ConCommandBase
+{
+ friend class CCVar;
+
+ public:
+ ConCommand(void){}; // !TODO: Rebuild engine constructor in SDK instead.
+ ConCommand(const char* szName, const char* szHelpString, int nFlags, void* pCallback, void* pCommandCompletionCallback);
+ void Init(void);
+ bool IsCommand(void) const;
+
+ void* m_pCommandCallback{}; // 0x0040 <- starts from 0x40 since we inherit ConCommandBase.
+ void* m_pCompletionCallback{}; // 0x0048 <- defaults to sub_180417410 ('xor eax, eax').
+ int m_nCallbackFlags{}; // 0x0050
+ char pad_0054[4]; // 0x0054
+ int unk0; // 0x0058
+ int unk1; // 0x005C
+}; // Size: 0x0060
+
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