Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when changing sprite atlas and sprite has an invalid animation #7550

Merged
merged 2 commits into from Apr 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion engine/gamesys/src/gamesys/components/comp_sprite.cpp
Expand Up @@ -1400,7 +1400,8 @@ namespace dmGameSystem
// Since the animation referred to the old texture, we need to update it
if (res == dmGameObject::PROPERTY_RESULT_OK)
{
uint32_t* anim_id = GetTextureSet(component, component->m_Resource)->m_AnimationIds.Get(component->m_CurrentAnimation);
TextureSetResource* texture_set = GetTextureSet(component, component->m_Resource);
uint32_t* anim_id = texture_set->m_AnimationIds.Get(component->m_CurrentAnimation);
if (anim_id)
{
PlayAnimation(component, component->m_CurrentAnimation, GetCursor(component), component->m_PlaybackRate);
Expand All @@ -1410,6 +1411,10 @@ namespace dmGameSystem
component->m_Playing = 0;
AGulev marked this conversation as resolved.
Show resolved Hide resolved
component->m_CurrentAnimation = 0x0;
component->m_CurrentAnimationFrame = 0;
dmGameSystemDDF::TextureSet* texture_set_ddf = texture_set->m_TextureSet;
if (texture_set_ddf->m_Animations.m_Count <= component->m_AnimationID) {
component->m_AnimationID = 0;
}
}
}
return res;
Expand Down