From 9bcafadce387f2cad2be25fd9b7871dd26d2d941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Mustoha?= Date: Mon, 15 Apr 2024 22:40:56 +0200 Subject: [PATCH] Removed some unused gfxSprite fields --- src/common/gfx/gfxSprite.cpp | 52 +++++++++++++++--------------------- src/common/gfx/gfxSprite.h | 9 ++----- src/common/sdl12wrapper.h | 4 +-- 3 files changed, 25 insertions(+), 40 deletions(-) diff --git a/src/common/gfx/gfxSprite.cpp b/src/common/gfx/gfxSprite.cpp index 9ecb41549..8f5d339c3 100644 --- a/src/common/gfx/gfxSprite.cpp +++ b/src/common/gfx/gfxSprite.cpp @@ -36,10 +36,6 @@ void gfxSprite::clearSurface() m_bltrect.h = 0; m_picture = NULL; - fHiddenPlane = false; - iHiddenDirection = 0; - iHiddenValue = 0; - fWrap = false; } @@ -191,11 +187,6 @@ bool gfxSprite::init(const std::string& filename) m_bltrect.w = (Uint16)m_picture->w; m_bltrect.h = (Uint16)m_picture->h; - m_srcrect.x = 0; - m_srcrect.y = 0; - m_srcrect.w = (Uint16)m_picture->w; - m_srcrect.h = (Uint16)m_picture->h; - cout << "done" << endl; return true; } @@ -245,46 +236,48 @@ bool gfxSprite::draw(short x, short y, short srcx, short srcy, short w, short h, m_bltrect.w = w; m_bltrect.h = h; - m_srcrect.x = srcx; - m_srcrect.y = srcy; - m_srcrect.w = w; - m_srcrect.h = h; + SDL_Rect srcrect { + srcx, + srcy, + w, + h, + }; if (sHiddenDirection > -1) { - if (gfx_adjusthiddenrects(&m_srcrect, &m_bltrect, sHiddenDirection, sHiddenValue)) + if (gfx_adjusthiddenrects(&srcrect, &m_bltrect, sHiddenDirection, sHiddenValue)) return true; } // Blit onto the screen surface - if (SDL_BlitSurface(m_picture, &m_srcrect, blitdest, &m_bltrect) < 0) { + if (SDL_BlitSurface(m_picture, &srcrect, blitdest, &m_bltrect) < 0) { fprintf(stderr, "SDL_BlitSurface error: %s\n", SDL_GetError()); return false; } if (fWrap) { if (x + w >= iWrapSize) { - m_srcrect = {srcx, srcy, w, h}; + srcrect = {srcx, srcy, w, h}; m_bltrect = {x - iWrapSize + x_shake, y + y_shake, w, h}; if (sHiddenDirection > -1) { - if (gfx_adjusthiddenrects(&m_srcrect, &m_bltrect, sHiddenDirection, sHiddenValue)) + if (gfx_adjusthiddenrects(&srcrect, &m_bltrect, sHiddenDirection, sHiddenValue)) return true; } - if (SDL_BlitSurface(m_picture, &m_srcrect, blitdest, &m_bltrect) < 0) { + if (SDL_BlitSurface(m_picture, &srcrect, blitdest, &m_bltrect) < 0) { fprintf(stderr, "SDL_BlitSurface error: %s\n", SDL_GetError()); return false; } } else if (x < 0) { - m_srcrect = {srcx, srcy, w, h}; + srcrect = {srcx, srcy, w, h}; m_bltrect = {x + iWrapSize + x_shake, y + y_shake, w, h}; if (sHiddenDirection > -1) { - if (gfx_adjusthiddenrects(&m_srcrect, &m_bltrect, sHiddenDirection, sHiddenValue)) + if (gfx_adjusthiddenrects(&srcrect, &m_bltrect, sHiddenDirection, sHiddenValue)) return true; } - if (SDL_BlitSurface(m_picture, &m_srcrect, blitdest, &m_bltrect) < 0) { + if (SDL_BlitSurface(m_picture, &srcrect, blitdest, &m_bltrect) < 0) { fprintf(stderr, "SDL_BlitSurface error: %s\n", SDL_GetError()); return false; } @@ -303,14 +296,16 @@ bool gfxSprite::drawStretch(short x, short y, short w, short h, short srcx, shor m_bltrect.w = w; m_bltrect.h = h; - m_srcrect.x = srcx; - m_srcrect.y = srcy; - m_srcrect.w = srcw; - m_srcrect.h = srch; + SDL_Rect srcrect { + srcx, + srcy, + srcw, + srch, + }; // Looks like SoftStretch doesn't respect transparent colors // I need to look into the actual SDL code to see if I can fix this - if (SDL_SCALEBLIT(m_picture, &m_srcrect, blitdest, &m_bltrect) < 0) { + if (SDL_SCALEBLIT(m_picture, &srcrect, blitdest, &m_bltrect) < 0) { fprintf(stderr, "SDL_SoftStretch error: %s\n", SDL_GetError()); return false; } @@ -336,11 +331,6 @@ int gfxSprite::getHeight() return m_picture->h; } -SDL_Surface* gfxSprite::getSurface() const -{ - return m_picture; -} - void gfxSprite::setSurface(SDL_Surface * surface) { freeSurface(); diff --git a/src/common/gfx/gfxSprite.h b/src/common/gfx/gfxSprite.h index 038bce689..72518f89c 100644 --- a/src/common/gfx/gfxSprite.h +++ b/src/common/gfx/gfxSprite.h @@ -28,8 +28,8 @@ class gfxSprite { int getWidth(); int getHeight(); - void setSurface(SDL_Surface * surface); - SDL_Surface *getSurface() const; + void setSurface(SDL_Surface* surface); + SDL_Surface* getSurface() const { return m_picture; } bool GetWrap(); void SetWrap(bool wrap); @@ -38,11 +38,6 @@ class gfxSprite { private: SDL_Surface *m_picture; SDL_Rect m_bltrect; - SDL_Rect m_srcrect; - - bool fHiddenPlane; - short iHiddenDirection; - short iHiddenValue; bool fWrap; short iWrapSize; diff --git a/src/common/sdl12wrapper.h b/src/common/sdl12wrapper.h index e26610175..9242c03d6 100644 --- a/src/common/sdl12wrapper.h +++ b/src/common/sdl12wrapper.h @@ -28,7 +28,7 @@ return (RLE ? SDL_SetSurfaceRLE(surf, RLE) : 0); } - inline int SDL_SCALEBLIT(SDL_Surface* src, SDL_Rect* srcrect, + inline int SDL_SCALEBLIT(SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect) { return SDL_BlitScaled(src, srcrect, dst, dstrect); @@ -44,7 +44,7 @@ return SDL_SetAlpha(surf, SDL_SRCALPHA | (RLE ? SDL_RLEACCEL : 0), alpha); } - inline int SDL_SCALEBLIT(SDL_Surface* src, SDL_Rect* srcrect, + inline int SDL_SCALEBLIT(SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect) { return SDL_SoftStretch(src, srcrect, dst, dstrect);