Skip to content

Commit

Permalink
Removed some unused gfxSprite fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Apr 16, 2024
1 parent 52ab74e commit 79e360c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 38 deletions.
52 changes: 21 additions & 31 deletions src/common/gfx/gfxSprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ void gfxSprite::clearSurface()
m_bltrect.h = 0;
m_picture = NULL;

fHiddenPlane = false;
iHiddenDirection = 0;
iHiddenValue = 0;

fWrap = false;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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();
Expand Down
9 changes: 2 additions & 7 deletions src/common/gfx/gfxSprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 79e360c

Please sign in to comment.