From e0f5244ed39d35463dc4dad0ae39a4080e4227d5 Mon Sep 17 00:00:00 2001 From: Andrew Copland Date: Tue, 24 Dec 2024 19:38:12 +0000 Subject: [PATCH] Invert the texture location reading --- src/Sfx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Sfx.cpp b/src/Sfx.cpp index f14bce4104..caba56eaba 100644 --- a/src/Sfx.cpp +++ b/src/Sfx.cpp @@ -194,6 +194,8 @@ void SfxManager::Add(const Body *b, SFX_TYPE t) void SfxManager::AddExplosion(Body *b) { + if (!b) return; + SfxManager *sfxman = AllocSfxInFrame(b->GetFrame()); if (!sfxman) return; @@ -311,7 +313,8 @@ void SfxManager::RenderAll(Renderer *renderer, FrameId fId, FrameId camFrameId) vector2f SfxManager::CalculateOffset(const enum SFX_TYPE type, const Sfx &inst) { if (m_materialData[type].effect == Graphics::EFFECT_BILLBOARD_ATLAS) { - const int spriteframe = inst.AgeBlend() * (m_materialData[type].num_textures - 1); + const Uint32 max_texture = (m_materialData[type].num_textures); + const int spriteframe = max_texture - (inst.AgeBlend() * max_texture); // count DOWN from the maximum texture to zero const Sint32 numImgsWide = m_materialData[type].num_imgs_wide; const int u = (spriteframe % numImgsWide); // % is the "modulo operator", the remainder of i / width; const int v = (spriteframe / numImgsWide); // where "/" is an integer division