about summary refs log tree commit diff
path: root/src/engine/shared/console.h
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-01-07 19:33:29 +0100
committeroy <Tom_Adams@web.de>2011-01-07 19:33:29 +0100
commit26f7c67895dd49e8ed91bf7a4c67aff485119087 (patch)
treebe08db0707e22f0c4a0077a7b1558c55bceaa0ae /src/engine/shared/console.h
parent41b8022aa1a941a4b2f3095dd4f8600daf4cd168 (diff)
downloadzcatch-26f7c67895dd49e8ed91bf7a4c67aff485119087.tar.gz
zcatch-26f7c67895dd49e8ed91bf7a4c67aff485119087.zip
fixed console parsing when using the exec command. Closes #381
Diffstat (limited to 'src/engine/shared/console.h')
-rw-r--r--src/engine/shared/console.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h
index 5cacfd90..30f53cf7 100644
--- a/src/engine/shared/console.h
+++ b/src/engine/shared/console.h
@@ -66,6 +66,29 @@ class CConsole : public IConsole
 		
 		const char *m_pCommand;
 		const char *m_apArgs[MAX_PARTS];
+
+		CResult() : IResult()
+		{
+			mem_zero(m_aStringStorage, sizeof(m_aStringStorage));
+			m_pArgsStart = 0;
+			m_pCommand = 0;
+			mem_zero(m_apArgs, sizeof(m_apArgs));
+		}
+
+		CResult &operator =(const CResult &Other)
+		{
+			if(this != &Other)
+			{
+				IResult::operator=(Other);
+				int Offset = m_aStringStorage - Other.m_aStringStorage;
+				mem_copy(m_aStringStorage, Other.m_aStringStorage, sizeof(m_aStringStorage));
+				m_pArgsStart = Other.m_pArgsStart + Offset;
+				m_pCommand = Other.m_pCommand + Offset;
+				for(int i = 0; i < Other.m_NumArgs; ++i)
+					m_apArgs[i] = Other.m_apArgs[i] + Offset;
+			}
+			return *this;
+		}
 		
 		void AddArgument(const char *pArg)
 		{
@@ -97,14 +120,17 @@ class CConsole : public IConsole
 		{
 			CQueueEntry *pEntry = static_cast<CQueueEntry *>(m_Queue.Allocate(sizeof(CQueueEntry)));
 			pEntry->m_pNext = 0;
-			m_pLast->m_pNext = pEntry;
+			if(!m_pFirst)
+				m_pFirst = pEntry;
+			if(m_pLast)
+				m_pLast->m_pNext = pEntry;
 			m_pLast = pEntry;
+			(void)new(&(pEntry->m_Result)) CResult;
 		}
 		void Reset()
 		{
 			m_Queue.Reset();
-			m_pFirst = m_pLast = static_cast<CQueueEntry *>(m_Queue.Allocate(sizeof(CQueueEntry)));
-			m_pLast->m_pNext = 0;
+			m_pFirst = m_pLast = 0;
 		}
 	} m_ExecutionQueue;