1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Standardize on using reference to tilesvec/spritesvec instead of pointer

This cleans up the code readability a bit, as it's nicer to use
reference syntax when indexing an array instead of that ugly pointer
syntax.
This commit is contained in:
Misa 2020-10-19 23:55:49 -07:00 committed by Ethan Lee
parent 5eab074e4d
commit 688b23b85d

View file

@ -1600,25 +1600,9 @@ void Graphics::drawentities()
bool custom_gray = false;
#endif
std::vector<SDL_Surface*> *tilesvec;
if (map.custommode && !map.finalmode)
{
tilesvec = &entcolours;
}
else
{
tilesvec = &tiles;
}
std::vector<SDL_Surface*>& tilesvec = (map.custommode && !map.finalmode) ? entcolours : tiles;
std::vector<SDL_Surface*> *spritesvec;
if (flipmode)
{
spritesvec = &flipsprites;
}
else
{
spritesvec = &sprites;
}
std::vector<SDL_Surface*>& spritesvec = flipmode ? flipsprites : sprites;
int yoff;
if (map.towermode)
@ -1645,7 +1629,7 @@ void Graphics::drawentities()
case 0:
{
// Sprites
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
{
continue;
}
@ -1656,7 +1640,7 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
//screenwrapping!
point wrappedPoint;
@ -1693,21 +1677,21 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += wrappedPoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
}
if (wrapY && map.warpy)
{
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += wrappedPoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
}
if (wrapX && wrapY && map.warpx && map.warpy)
{
drawRect = sprites_rect;
drawRect.x += wrappedPoint.x;
drawRect.y += wrappedPoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
}
break;
}
@ -1728,7 +1712,7 @@ void Graphics::drawentities()
case 8:
{
// Special: Moving platform, 4 tiles or 8 tiles
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*tilesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, tilesvec))
{
continue;
}
@ -1749,11 +1733,11 @@ void Graphics::drawentities()
{
colourTransform temp_ct;
temp_ct.colour = 0xFFFFFFFF;
BlitSurfaceTinted((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, temp_ct);
BlitSurfaceTinted(tilesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, temp_ct);
}
else
{
BlitSurfaceStandard((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
BlitSurfaceStandard(tilesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
}
}
break;
@ -1795,7 +1779,7 @@ void Graphics::drawentities()
// Note: This code is in the 4-tile code
break;
case 9: // Really Big Sprite! (2x2)
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
{
continue;
}
@ -1807,7 +1791,7 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
tpoint.x = xp+32;
tpoint.y = yp - yoff;
@ -1815,7 +1799,7 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe+1],NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe+1],NULL, backBuffer, &drawRect, ct);
tpoint.x = xp;
tpoint.y = yp+32 - yoff;
@ -1823,7 +1807,7 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe+12],NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe+12],NULL, backBuffer, &drawRect, ct);
tpoint.x = xp+32;
tpoint.y = yp+32 - yoff;
@ -1831,10 +1815,10 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe + 13],NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe + 13],NULL, backBuffer, &drawRect, ct);
break;
case 10: // 2x1 Sprite
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
{
continue;
}
@ -1846,7 +1830,7 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
tpoint.x = xp+32;
tpoint.y = yp - yoff;
@ -1854,14 +1838,14 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe+1],NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe+1],NULL, backBuffer, &drawRect, ct);
break;
case 11: //The fucking elephant
setcolreal(obj.entities[i].realcol);
drawimagecol(3, xp, yp - yoff);
break;
case 12: // Regular sprites that don't wrap
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
{
continue;
}
@ -1872,7 +1856,7 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
//if we're outside the screen, we need to draw indicators
@ -1920,7 +1904,7 @@ void Graphics::drawentities()
case 13:
{
//Special for epilogue: huge hero!
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
{
continue;
}
@ -1928,7 +1912,7 @@ void Graphics::drawentities()
tpoint.x = xp; tpoint.y = yp - yoff;
setcolreal(obj.entities[i].realcol);
SDL_Rect drawRect = {Sint16(obj.entities[i].xp ), Sint16(obj.entities[i].yp - yoff), Sint16(sprites_rect.x * 6), Sint16(sprites_rect.y * 6 ) };
SDL_Surface* TempSurface = ScaleSurface( (*spritesvec)[obj.entities[i].drawframe], 6 * sprites_rect.w,6* sprites_rect.h );
SDL_Surface* TempSurface = ScaleSurface( spritesvec[obj.entities[i].drawframe], 6 * sprites_rect.w,6* sprites_rect.h );
BlitSurfaceColoured(TempSurface, NULL , backBuffer, &drawRect, ct );
SDL_FreeSurface(TempSurface);