@@ -180,22 +180,25 @@ TreeNode::PostScripts &TreeNode::postConditionsScripts() {
180
180
181
181
Expected<NodeStatus> TreeNode::checkPreConditions ()
182
182
{
183
+ Ast::Environment env = {config ().blackboard , config ().enums };
184
+
183
185
// check the pre-conditions
184
186
for (size_t index = 0 ; index < size_t (PreCond::COUNT_); index++)
185
187
{
186
- PreCond preID = PreCond (index);
187
188
const auto & parse_executor = _p->pre_parsed [index];
188
189
if (!parse_executor)
189
190
{
190
191
continue ;
191
192
}
192
- Ast::Environment env = {config ().blackboard , config ().enums };
193
- auto result = parse_executor (env);
194
- // what to do if the condition is true
195
- if (result.cast <bool >())
193
+
194
+ const PreCond preID = PreCond (index);
195
+
196
+ // Some preconditions are applied only when the node state is IDLE or SKIPPED
197
+ if (_p->status == NodeStatus::IDLE ||
198
+ _p->status == NodeStatus::SKIPPED)
196
199
{
197
- // Some preconditions are applied only when the node is started
198
- if (_p-> status == NodeStatus::IDLE )
200
+ // what to do if the condition is true
201
+ if (parse_executor (env). cast < bool >() )
199
202
{
200
203
if (preID == PreCond::FAILURE_IF)
201
204
{
@@ -210,15 +213,19 @@ Expected<NodeStatus> TreeNode::checkPreConditions()
210
213
return NodeStatus::SKIPPED;
211
214
}
212
215
}
216
+ // if the conditions is false
217
+ else if (preID == PreCond::WHILE_TRUE)
218
+ {
219
+ return NodeStatus::SKIPPED;
220
+ }
213
221
}
214
- else // condition is false
222
+ else if (_p-> status == NodeStatus::RUNNING && preID == PreCond::WHILE_TRUE)
215
223
{
216
- if (preID == PreCond::WHILE_TRUE)
224
+ // what to do if the condition is false
225
+ if (!parse_executor (env).cast <bool >())
217
226
{
218
- if (!isStatusCompleted (_p->status ))
219
- {
220
- halt ();
221
- }
227
+ haltNode ();
228
+ resetStatus ();
222
229
return NodeStatus::SKIPPED;
223
230
}
224
231
}
0 commit comments