mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-02-05 00:26:15 +03:00
Fix indexing out-of-bounds with miscellaneous images
This fixes indexing out-of-bounds in the functions that draw all the special images such as the elephant and teleporters. Let's make sure the game doesn't segfault.
This commit is contained in:
@@ -753,6 +753,10 @@ void Graphics::drawgui()
|
|||||||
|
|
||||||
void Graphics::drawimagecol( int t, int xp, int yp, int r = 0, int g = 0, int b = 0, bool cent/*= false*/ )
|
void Graphics::drawimagecol( int t, int xp, int yp, int r = 0, int g = 0, int b = 0, bool cent/*= false*/ )
|
||||||
{
|
{
|
||||||
|
if (!INBOUNDS(t, images))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
SDL_Rect trect;
|
SDL_Rect trect;
|
||||||
if(r+g+b != 0)
|
if(r+g+b != 0)
|
||||||
{
|
{
|
||||||
@@ -784,6 +788,10 @@ void Graphics::drawimagecol( int t, int xp, int yp, int r = 0, int g = 0, int b
|
|||||||
|
|
||||||
void Graphics::drawimage( int t, int xp, int yp, bool cent/*=false*/ )
|
void Graphics::drawimage( int t, int xp, int yp, bool cent/*=false*/ )
|
||||||
{
|
{
|
||||||
|
if (!INBOUNDS(t, images))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Rect trect;
|
SDL_Rect trect;
|
||||||
if (cent)
|
if (cent)
|
||||||
@@ -808,6 +816,11 @@ void Graphics::drawimage( int t, int xp, int yp, bool cent/*=false*/ )
|
|||||||
|
|
||||||
void Graphics::drawpartimage( int t, int xp, int yp, int wp, int hp)
|
void Graphics::drawpartimage( int t, int xp, int yp, int wp, int hp)
|
||||||
{
|
{
|
||||||
|
if (!INBOUNDS(t, images))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_Rect trect;
|
SDL_Rect trect;
|
||||||
|
|
||||||
trect.x = xp;
|
trect.x = xp;
|
||||||
@@ -2787,15 +2800,21 @@ void Graphics::drawtele(int x, int y, int t, int c)
|
|||||||
|
|
||||||
SDL_Rect telerect;
|
SDL_Rect telerect;
|
||||||
setRect(telerect, x , y, tele_rect.w, tele_rect.h );
|
setRect(telerect, x , y, tele_rect.w, tele_rect.h );
|
||||||
|
if (INBOUNDS(0, tele))
|
||||||
|
{
|
||||||
BlitSurfaceColoured(tele[0], NULL, backBuffer, &telerect, ct);
|
BlitSurfaceColoured(tele[0], NULL, backBuffer, &telerect, ct);
|
||||||
|
}
|
||||||
|
|
||||||
setcol(c);
|
setcol(c);
|
||||||
if (t > 9) t = 8;
|
if (t > 9) t = 8;
|
||||||
if (t < 0) t = 0;
|
if (t < 0) t = 0;
|
||||||
|
|
||||||
setRect(telerect, x , y, tele_rect.w, tele_rect.h );
|
setRect(telerect, x , y, tele_rect.w, tele_rect.h );
|
||||||
|
if (INBOUNDS(t, tele))
|
||||||
|
{
|
||||||
BlitSurfaceColoured(tele[t], NULL, backBuffer, &telerect, ct);
|
BlitSurfaceColoured(tele[t], NULL, backBuffer, &telerect, ct);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Uint32 Graphics::getRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
Uint32 Graphics::getRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user