- NetworkConstantAction* action = nullptr;
- ActionList* actionSet = getRunningActionSet();
- ActionList::iterator it(actionSet->begin());
- ActionList::iterator itNext = it;
- ActionList::iterator itend(actionSet->end());
- for (; it != itend; it = itNext) {
- ++itNext;
- action = static_cast<NetworkConstantAction*>(&*it);
- if (action->latency_ > 0) {
- if (action->latency_ > delta) {
- double_update(&(action->latency_), delta, sg_surf_precision);
+ for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
+ NetworkConstantAction& action = static_cast<NetworkConstantAction&>(*it);
+ ++it; // increment iterator here since the following calls to action.finish() may invalidate it
+ if (action.latency_ > 0) {
+ if (action.latency_ > delta) {
+ double_update(&action.latency_, delta, sg_surf_precision);