From ad9b32b7417d0837c485b6c9b802cc90aa51c521 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 7 Aug 2010 20:22:25 +0200 Subject: added the possibility to store commands within the console and execute them later on when everything is initialised correctly - fixes several possible startup crashes and the "Support bans in server configuration"-ticket --- src/engine/shared/console.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/engine/shared/console.h') diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h index 9064fa86..9c127ae0 100644 --- a/src/engine/shared/console.h +++ b/src/engine/shared/console.h @@ -2,6 +2,7 @@ #define ENGINE_SHARED_CONSOLE_H #include +#include "memheap.h" class CConsole : public IConsole { @@ -25,6 +26,8 @@ class CConsole : public IConsole }; int m_FlagMask; + bool m_StoreCommands; + const char *m_paStrokeStr[2]; CCommand *m_pFirstCommand; class CExecFile @@ -75,6 +78,34 @@ class CConsole : public IConsole int ParseStart(CResult *pResult, const char *pString, int Length); int ParseArgs(CResult *pResult, const char *pFormat); + class CExecutionQueue + { + CHeap m_Queue; + + public: + struct CQueueEntry + { + CQueueEntry *m_pNext; + FCommandCallback m_pfnCommandCallback; + void *m_pCommandUserData; + CResult m_Result; + } *m_pFirst, *m_pLast; + + void AddEntry() + { + CQueueEntry *pEntry = static_cast(m_Queue.Allocate(sizeof(CQueueEntry))); + pEntry->m_pNext = 0; + m_pLast->m_pNext = pEntry; + m_pLast = pEntry; + } + void Reset() + { + m_Queue.Reset(); + m_pFirst = m_pLast = static_cast(m_Queue.Allocate(sizeof(CQueueEntry))); + m_pLast->m_pNext = 0; + } + } m_ExecutionQueue; + CCommand *FindCommand(const char *pName, int FlagMask); public: @@ -86,6 +117,7 @@ public: virtual void ParseArguments(int NumArgs, const char **ppArguments); virtual void Register(const char *pName, const char *pParams, int Flags, FCommandCallback pfnFunc, void *pUser, const char *pHelp); virtual void Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser); + virtual void StoreCommands(bool Store); virtual void ExecuteLine(const char *pStr); virtual void ExecuteFile(const char *pFilename); -- cgit 1.4.1