diff options
| author | oy <Tom_Adams@web.de> | 2011-01-07 19:33:29 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-01-07 19:33:29 +0100 |
| commit | 26f7c67895dd49e8ed91bf7a4c67aff485119087 (patch) | |
| tree | be08db0707e22f0c4a0077a7b1558c55bceaa0ae /src/engine/shared/console.cpp | |
| parent | 41b8022aa1a941a4b2f3095dd4f8600daf4cd168 (diff) | |
| download | zcatch-26f7c67895dd49e8ed91bf7a4c67aff485119087.tar.gz zcatch-26f7c67895dd49e8ed91bf7a4c67aff485119087.zip | |
fixed console parsing when using the exec command. Closes #381
Diffstat (limited to 'src/engine/shared/console.cpp')
| -rw-r--r-- | src/engine/shared/console.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
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(); } |