Skip to content

Commit e356478

Browse files
committed
Fix input action validation check
Input actions can also be created during assembly. This is the case for Physical connections.
1 parent 361a999 commit e356478

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/environment.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ void Environment::register_reactor(Reactor* reactor) {
5555

5656
void Environment::register_input_action(BaseAction* action) {
5757
reactor_assert(action != nullptr);
58-
validate(this->phase() == Phase::Construction, "Input actions may only be registered during construction phase!");
58+
validate(this->phase() == Phase::Construction || this->phase() == Phase::Assembly,
59+
"Input actions may only be registered during construction or assembly phase!");
5960
[[maybe_unused]] bool result = input_actions_.insert(action).second;
6061
reactor_assert(result);
6162
run_forever_ = true;

lib/reactor.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ ReactorElement::ReactorElement(const std::string& name, ReactorElement::Type typ
6565
, environment_(environment) {
6666
reactor_assert(environment != nullptr);
6767
validate(type == Type::Reactor || type == Type::Action, "Only reactors and actions can be owned by the environment!");
68-
validate(this->environment_->phase() == Phase::Construction,
69-
"Reactor elements can only be created during construction phase!");
7068

7169
switch (type) {
7270
case Type::Action:
71+
validate(this->environment_->phase() == Phase::Construction || this->environment_->phase() == Phase::Assembly,
72+
"Actions can only be created during construction or assembly phase!");
7373
Statistics::increment_actions();
7474
break;
7575
case Type::Reactor:
76+
validate(this->environment_->phase() == Phase::Construction,
77+
"Reactors can only be created during construction phase!");
7678
Statistics::increment_reactor_instances();
7779
break;
7880
default:

0 commit comments

Comments
 (0)