1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 08:06:13 +01:00

</KILL ALL> fix

This commit is contained in:
Asbelos 2022-03-31 10:11:34 +01:00
parent 6826e01bd3
commit 8085d03d65

View File

@ -357,27 +357,27 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) {
default: default:
break; break;
} }
// check KILL ALL here, otherwise the next validation confuses ALL with a flag
if (p[0]==HASH_KEYWORD_KILL && p[1]==HASH_KEYWORD_ALL) {
while (loopTask) delete loopTask; // destructor changes loopTask
return true;
}
// all other / commands take 1 parameter 0 to MAX_FLAGS-1 // all other / commands take 1 parameter 0 to MAX_FLAGS-1
if (paramCount!=2 || p[1]<0 || p[1]>=MAX_FLAGS) return false; if (paramCount!=2 || p[1]<0 || p[1]>=MAX_FLAGS) return false;
switch (p[0]) { switch (p[0]) {
case HASH_KEYWORD_KILL: // Kill taskid|ALL case HASH_KEYWORD_KILL: // Kill taskid|ALL
{ {
if (p[1]==HASH_KEYWORD_ALL) {
while (loopTask) delete loopTask;
return true;
}
RMFT2 * task=loopTask; RMFT2 * task=loopTask;
while(task) { while(task) {
if (task->taskId==p[1]) { if (task->taskId==p[1]) {
delete task; delete task;
return true; return true;
} }
task=task->next; task=task->next;
if (task==loopTask) break; if (task==loopTask) break;
} }
} }
return false; return false;