File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -88,29 +88,27 @@ if he/she is fully rested.
88
88
89
89
??? example "See the pseudocode"
90
90
``` c++
91
- // index is initialized to 0 in the constructor
92
91
status = RUNNING;
93
92
94
93
for (int index=0; index < number_of_children; index++)
95
94
{
96
95
child_status = child[index]->tick();
97
96
98
97
if( child_status == RUNNING ) {
98
+ // Suspend all subsequent siblings and return RUNNING.
99
+ HaltSubsequentSiblings();
99
100
return RUNNING;
100
101
}
101
- else if( child_status == FAILURE ) {
102
- // continue the while loop
103
- index++;
104
- }
105
- else if( child_status == SUCCESS ) {
102
+
103
+ // if child_status == FAILURE, continue to tick next sibling
104
+
105
+ if( child_status == SUCCESS ) {
106
106
// Suspend execution and return SUCCESS.
107
- // At the next tick, index will be the same.
108
- HaltAllChildren();
107
+ HaltAllChildren();
109
108
return SUCCESS;
110
109
}
111
110
}
112
111
// all the children returned FAILURE. Return FAILURE too.
113
- index = 0;
114
112
HaltAllChildren();
115
113
return FAILURE;
116
114
```
You can’t perform that action at this time.
0 commit comments