aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/concommand.cpp
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.cpp
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.cpp')
-rw-r--r--NorthstarDedicatedTest/concommand.cpp100
1 files changed, 90 insertions, 10 deletions
diff --git a/NorthstarDedicatedTest/concommand.cpp b/NorthstarDedicatedTest/concommand.cpp
index b876a05c..b455100f 100644
--- a/NorthstarDedicatedTest/concommand.cpp
+++ b/NorthstarDedicatedTest/concommand.cpp
@@ -17,17 +17,97 @@ void RegisterConCommand(const char* name, void (*callback)(const CCommand&), con
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);
AddMiscConCommands();
-} \ No newline at end of file
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns true if this is a command
+// Output : bool
+//-----------------------------------------------------------------------------
+bool ConCommand::IsCommand(void) const { return true; }
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns true if this is a command
+// Output : bool
+//-----------------------------------------------------------------------------
+bool ConCommandBase::IsCommand(void) const { return true; }
+
+//-----------------------------------------------------------------------------
+// Purpose: Has this cvar been registered
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool ConCommandBase::IsRegistered(void) const { return m_bRegistered; }
+
+//-----------------------------------------------------------------------------
+// Purpose: Test each ConCommand query before execution.
+// Input : *pCommandBase - nFlags
+// Output : False if execution is permitted, true if not.
+//-----------------------------------------------------------------------------
+bool ConCommandBase::IsFlagSet(int nFlags) const
+{
+ return false; // !TODO: Returning false on every query? (original implementation in Northstar before ConCommandBase refactor)
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Checks if ConCommand has requested flags.
+// Input : nFlags -
+// Output : True if ConCommand has nFlags.
+//-----------------------------------------------------------------------------
+bool ConCommandBase::HasFlags(int nFlags) { return m_nFlags & nFlags; }
+
+//-----------------------------------------------------------------------------
+// Purpose: Add's flags to ConCommand.
+// Input : nFlags -
+//-----------------------------------------------------------------------------
+void ConCommandBase::AddFlags(int nFlags) { m_nFlags |= nFlags; }
+
+//-----------------------------------------------------------------------------
+// Purpose: Removes flags from ConCommand.
+// Input : nFlags -
+//-----------------------------------------------------------------------------
+void ConCommandBase::RemoveFlags(int nFlags) { m_nFlags &= ~nFlags; }
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns current flags.
+// Output : int
+//-----------------------------------------------------------------------------
+int ConCommandBase::GetFlags(void) const { return m_nFlags; }
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Output : const ConCommandBase
+//-----------------------------------------------------------------------------
+ConCommandBase* ConCommandBase::GetNext(void) const { return m_pNext; }
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns the ConCommandBase help text.
+// Output : const char*
+//-----------------------------------------------------------------------------
+const char* ConCommandBase::GetHelpText(void) const { return m_pszHelpString; }
+
+//-----------------------------------------------------------------------------
+// Purpose: Copies string using local new/delete operators
+// Input : *szFrom -
+// Output : char
+//-----------------------------------------------------------------------------
+char* ConCommandBase::CopyString(const char* szFrom) const
+{
+ size_t nLen;
+ char* szTo;
+
+ nLen = strlen(szFrom);
+ if (nLen <= 0)
+ {
+ szTo = new char[1];
+ szTo[0] = 0;
+ }
+ else
+ {
+ szTo = new char[nLen + 1];
+ memmove(szTo, szFrom, nLen + 1);
+ }
+ return szTo;
+}