From 22e5643611c29d1034046f8e05f828cf7cce3ecb Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 27 Jul 2022 10:22:19 +0200 Subject: [PATCH] fix crash when graphic for flipped missile is loaded already as sprite --- src/include/video.h | 2 +- src/missile/missile.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/include/video.h b/src/include/video.h index 1cc9e3ca2..1505e229a 100644 --- a/src/include/video.h +++ b/src/include/video.h @@ -174,7 +174,7 @@ public: // minor programmatic editing features void OverlayGraphic(CGraphic *other, bool mask = false); - inline bool IsLoaded() const { return Surface != NULL; } + inline bool IsLoaded(bool flipped = false) const { return Surface != NULL && (!flipped || SurfaceFlip != NULL); } //guichan virtual void *_getData() const { return Surface; } diff --git a/src/missile/missile.cpp b/src/missile/missile.cpp index 79879b509..035085965 100644 --- a/src/missile/missile.cpp +++ b/src/missile/missile.cpp @@ -83,7 +83,7 @@ extern NumberDesc *Damage; /// Damage calculation for missile. */ void MissileType::LoadMissileSprite() { - if (this->G && !this->G->IsLoaded()) { + if (this->G && !this->G->IsLoaded(this->Flip)) { this->G->Load(); if (this->Flip) { this->G->Flip(); @@ -495,7 +495,7 @@ static int MissileVisibleInViewport(const CViewport &vp, const Missile &missile) void MissileType::DrawMissileType(int frame, const PixelPos &pos) const { #ifdef DYNAMIC_LOAD - if (!this->G->IsLoaded()) { + if (!this->G->IsLoaded(this->Flip)) { ((MissileType*)this)->LoadMissileSprite(); } #endif @@ -540,7 +540,7 @@ void Missile::DrawMissile(const CViewport &vp) const // FIXME: I should copy SourcePlayer for second level missiles. if (sunit && sunit->Player) { #ifdef DYNAMIC_LOAD - if (!this->Type->G->IsLoaded()) { + if (!this->Type->G->IsLoaded(this->Type->Flip)) { ((MissileType*)this->Type)->LoadMissileSprite(); } #endif