From b422cc9de3738e13ea57d32822c3731890a87845 Mon Sep 17 00:00:00 2001 From: Yuwei Liang Date: Sun, 11 Jul 2021 16:14:42 +0800 Subject: [PATCH] Update FallbackNode.md (#287) Fix the pseudocode in the documentation of 'Reactive Fallback' according to its source code. --- docs/FallbackNode.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/FallbackNode.md b/docs/FallbackNode.md index c0f1c83e4..7c517b45c 100644 --- a/docs/FallbackNode.md +++ b/docs/FallbackNode.md @@ -88,7 +88,6 @@ if he/she is fully rested. ??? example "See the pseudocode" ``` c++ - // index is initialized to 0 in the constructor status = RUNNING; for (int index=0; index < number_of_children; index++) @@ -96,21 +95,20 @@ if he/she is fully rested. child_status = child[index]->tick(); if( child_status == RUNNING ) { + // Suspend all subsequent siblings and return RUNNING. + HaltSubsequentSiblings(); return RUNNING; } - else if( child_status == FAILURE ) { - // continue the while loop - index++; - } - else if( child_status == SUCCESS ) { + + // if child_status == FAILURE, continue to tick next sibling + + if( child_status == SUCCESS ) { // Suspend execution and return SUCCESS. - // At the next tick, index will be the same. - HaltAllChildren(); + HaltAllChildren(); return SUCCESS; } } // all the children returned FAILURE. Return FAILURE too. - index = 0; HaltAllChildren(); return FAILURE; ```