- NetworkConstantAction *action = NULL;
- ActionList *actionSet = getRunningActionSet();
- for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
- ; it != itend ; it=itNext) {
- ++itNext;
- action = static_cast<NetworkConstantAction*>(&*it);
- if (action->m_latency > 0) {
- if (action->m_latency > delta) {
- double_update(&(action->m_latency), delta, sg_surf_precision);
+ for (auto it = std::begin(*get_running_action_set()); it != std::end(*get_running_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);