Ticket #4071: anim.diff

File anim.diff, 1.3 KB (added by sanderd17, 8 years ago)
  • source/graphics/UnitAnimation.cpp

     
    7777
    7878    // Recursively add all props
    7979    const std::vector<CModel::Prop>& props = model->GetProps();
    80     for (std::vector<CModel::Prop>::const_iterator it = props.begin(); it != props.end(); ++it)
     80    for (const CModel::Prop& prop : props)
    8181    {
    82         CModel* propModel = it->m_Model->ToCModel();
     82        CModel* propModel = prop.m_Model->ToCModel();
    8383        if (propModel)
    84             AddModel(propModel, it->m_ObjectEntry);
     84            AddModel(propModel, prop.m_ObjectEntry);
    8585    }
    8686}
    8787
     
    237237                // we're handling the root model
    238238                // choose animations from the complete state
    239239                anim = it->object->GetRandomAnimation(m_State);
    240                 m_AnimationName = anim->m_Name;
    241240                // if we use a new animation name,
    242241                // update the animations of all non-root models
     242                // sync with the root model, unless the root model could
     243                // only resort to the "idle" state.
     244                if (anim->m_Name != "idle")
     245                    m_AnimationName = anim->m_Name;
     246                else
     247                    m_AnimationName = m_State;
    243248                if (it->anim->m_Name != m_AnimationName)
    244249                    for (SModelAnimState animState : m_AnimStates)
    245250                        if (animState.model != m_Model)