From 26f7c67895dd49e8ed91bf7a4c67aff485119087 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 7 Jan 2011 19:33:29 +0100 Subject: fixed console parsing when using the exec command. Closes #381 --- src/engine/shared/console.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/engine/shared/console.cpp') diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index 2a290cb3..987e252b 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -217,7 +217,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr) { while(pStr && *pStr) { - CResult *pResult = new(&m_ExecutionQueue.m_pLast->m_Result) CResult; + CResult Result; const char *pEnd = pStr; const char *pNextPart = 0; int InString = 0; @@ -245,24 +245,24 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr) pEnd++; } - if(ParseStart(pResult, pStr, (pEnd-pStr) + 1) != 0) + if(ParseStart(&Result, pStr, (pEnd-pStr) + 1) != 0) return; - CCommand *pCommand = FindCommand(pResult->m_pCommand, m_FlagMask); + CCommand *pCommand = FindCommand(Result.m_pCommand, m_FlagMask); if(pCommand) { int IsStrokeCommand = 0; - if(pResult->m_pCommand[0] == '+') + if(Result.m_pCommand[0] == '+') { // insert the stroke direction token - pResult->AddArgument(m_paStrokeStr[Stroke]); + Result.AddArgument(m_paStrokeStr[Stroke]); IsStrokeCommand = 1; } if(Stroke || IsStrokeCommand) { - if(ParseArgs(pResult, pCommand->m_pParams)) + if(ParseArgs(&Result, pCommand->m_pParams)) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "Invalid arguments... Usage: %s %s", pCommand->m_pName, pCommand->m_pParams); @@ -270,18 +270,19 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr) } else if(m_StoreCommands && pCommand->m_Flags&CFGFLAG_STORE) { + m_ExecutionQueue.AddEntry(); m_ExecutionQueue.m_pLast->m_pfnCommandCallback = pCommand->m_pfnCallback; m_ExecutionQueue.m_pLast->m_pCommandUserData = pCommand->m_pUserData; - m_ExecutionQueue.AddEntry(); + m_ExecutionQueue.m_pLast->m_Result = Result; } else - pCommand->m_pfnCallback(pResult, pCommand->m_pUserData); + pCommand->m_pfnCallback(&Result, pCommand->m_pUserData); } } else if(Stroke) { char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "No such command: %s.", pResult->m_pCommand); + str_format(aBuf, sizeof(aBuf), "No such command: %s.", Result.m_pCommand); Print(OUTPUT_LEVEL_STANDARD, "Console", aBuf); } @@ -569,7 +570,7 @@ void CConsole::StoreCommands(bool Store) { if(!Store) { - for(CExecutionQueue::CQueueEntry *pEntry = m_ExecutionQueue.m_pFirst; pEntry != m_ExecutionQueue.m_pLast; pEntry = pEntry->m_pNext) + for(CExecutionQueue::CQueueEntry *pEntry = m_ExecutionQueue.m_pFirst; pEntry; pEntry = pEntry->m_pNext) pEntry->m_pfnCommandCallback(&pEntry->m_Result, pEntry->m_pCommandUserData); m_ExecutionQueue.Reset(); } -- cgit 1.4.1