X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Fprocesses%2Fstate_machine.cpp;h=e2f7150dc4809960361a5c36c37cb923591e0a8b;hb=f5d845d81352418af0785b85412a35888c82486f;hp=3704bf980635bca361d0a69734a329723daa21cb;hpb=457b128b77b5b4a0b7dd3094de543de2ce1477ad;p=feisty_meow.git diff --git a/nucleus/library/processes/state_machine.cpp b/nucleus/library/processes/state_machine.cpp index 3704bf98..e2f7150d 100644 --- a/nucleus/library/processes/state_machine.cpp +++ b/nucleus/library/processes/state_machine.cpp @@ -75,20 +75,39 @@ struct override { int current; int next; int duration; : current(_current), next(_next), duration(_duration) {} }; -struct transition_info { - enum transition_type { SIMPLE, RANGE, TIMED }; - transition_type type; - int next_state; - int low_trigger, high_trigger; - int time_span; - - transition_info() {} // blank. - transition_info(int next) : type(SIMPLE), next_state(next) {} - transition_info(int next, int time) : type(TIMED), next_state(next), - time_span(time) {} - transition_info(int next, int low, int high) : type(RANGE), - next_state(next), low_trigger(low), high_trigger(high) {} -}; + struct transition_info + { + enum transition_type + { + SIMPLE, RANGE, TIMED + }; + transition_type type; + int next_state; + int low_trigger, high_trigger; + int time_span; + + // blank constructor. + transition_info() + : type(RANGE), next_state(0), low_trigger(0), high_trigger(0), time_span(0) + { + } + + transition_info(int next) + : type(SIMPLE), next_state(next), + low_trigger(0), high_trigger(0), time_span(0) + { + } + + transition_info(int next, int time) + : type(TIMED), next_state(next), time_span(time), low_trigger(0), high_trigger(0) + { + } + + transition_info(int next, int low, int high) + : type(RANGE), next_state(next), low_trigger(low), high_trigger(high), time_span(0) + { + } + }; struct state_info { int state_id; // id for this state. @@ -230,7 +249,7 @@ int transition_map::transition_index(int state_index, int next, int &start) state_info &state = (*_state_list)[state_index]; bounds_return(start, 0, state.transitions.length() - 1, common::BAD_INPUT); // loop over the transitions by using our external index. - for (start = start; start < state.transitions.length(); start++) + for (; start < state.transitions.length(); start++) if (state.transitions[start].next_state == next) { start++; // position it after this index. return start - 1; // return this index.