1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-18 10:38:31 +02:00

Rename INBOUNDS() macro to INBOUNDS_VEC()

Since there's an INBOUNDS_ARR() macro, it's much better to specify the
macro for the vector is a macro for the vector, to avoid confusion.

All usages of this macro have been renamed accordingly.
This commit is contained in:
Misa 2020-09-08 00:31:44 -07:00 committed by Ethan Lee
parent fae14f4e98
commit 7ed495c373
6 changed files with 46 additions and 46 deletions

View File

@ -4499,7 +4499,7 @@ void entityclass::entitymapcollision( int t )
void entityclass::movingplatformfix( int t, int j )
{
if (!INBOUNDS(t, entities) || !INBOUNDS(j, entities))
if (!INBOUNDS_VEC(t, entities) || !INBOUNDS_VEC(j, entities))
{
puts("movingplatformfix() out-of-bounds!");
return;
@ -4652,7 +4652,7 @@ void entityclass::entitycollisioncheck()
void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
{
if (!INBOUNDS(i, entities) || !INBOUNDS(j, entities))
if (!INBOUNDS_VEC(i, entities) || !INBOUNDS_VEC(j, entities))
{
puts("collisioncheck() out-of-bounds!");
return;
@ -4679,7 +4679,7 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
int drawframe1 = entities[i].drawframe;
int drawframe2 = entities[j].drawframe;
std::vector<SDL_Surface*>& spritesvec = graphics.flipmode ? graphics.flipsprites : graphics.sprites;
if (INBOUNDS(drawframe1, spritesvec) && INBOUNDS(drawframe2, spritesvec)
if (INBOUNDS_VEC(drawframe1, spritesvec) && INBOUNDS_VEC(drawframe2, spritesvec)
&& graphics.Hitest(spritesvec[drawframe1],
colpoint1, spritesvec[drawframe2], colpoint2))
{
@ -4774,7 +4774,7 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
void entityclass::stuckprevention(int t)
{
if (!INBOUNDS(t, entities))
if (!INBOUNDS_VEC(t, entities))
{
puts("stuckprevention() out-of-bounds!");
return;

View File

@ -167,7 +167,7 @@ int Graphics::font_idx(uint32_t ch) {
void Graphics::drawspritesetcol(int x, int y, int t, int c)
{
if (!INBOUNDS(t, sprites))
if (!INBOUNDS_VEC(t, sprites))
{
return;
}
@ -380,7 +380,7 @@ void Graphics::PrintAlpha( int _x, int _y, std::string _s, int r, int g, int b,
fontRect.y = tpoint.y ;
idx = font_idx(curr);
if (INBOUNDS(idx, font))
if (INBOUNDS_VEC(idx, font))
{
BlitSurfaceColoured( font[idx], NULL, backBuffer, &fontRect , ct);
}
@ -422,7 +422,7 @@ void Graphics::bigprint( int _x, int _y, std::string _s, int r, int g, int b, b
*/
idx = font_idx(curr);
if (INBOUNDS(idx, font))
if (INBOUNDS_VEC(idx, font))
{
SDL_Surface* tempPrint = ScaleSurface(font[idx], font[idx]->w *sc,font[idx]->h *sc);
SDL_Rect printrect = { static_cast<Sint16>((_x) + bfontpos), static_cast<Sint16>(_y) , static_cast<Sint16>((bfont_rect.w*sc)+1), static_cast<Sint16>((bfont_rect.h * sc)+1)};
@ -475,7 +475,7 @@ void Graphics::PrintOffAlpha( int _x, int _y, std::string _s, int r, int g, int
fontRect.y = tpoint.y ;
idx = font_idx(curr);
if (INBOUNDS(idx, font))
if (INBOUNDS_VEC(idx, font))
{
BlitSurfaceColoured( font[idx], NULL, backBuffer, &fontRect , ct);
}
@ -534,7 +534,7 @@ void Graphics::RPrint( int _x, int _y, std::string _s, int r, int g, int b, bool
fontRect.y = tpoint.y ;
idx = font_idx(curr);
if (INBOUNDS(idx, font))
if (INBOUNDS_VEC(idx, font))
{
BlitSurfaceColoured( font[idx], NULL, backBuffer, &fontRect , ct);
}
@ -636,7 +636,7 @@ void Graphics::drawsprite(int x, int y, int t, Uint32 c)
void Graphics::drawtile( int x, int y, int t )
{
if (!INBOUNDS(t, tiles))
if (!INBOUNDS_VEC(t, tiles))
{
WHINE_ONCE("drawtile() out-of-bounds!")
return;
@ -660,7 +660,7 @@ void Graphics::drawtile( int x, int y, int t )
void Graphics::drawtile2( int x, int y, int t )
{
if (!INBOUNDS(t, tiles2))
if (!INBOUNDS_VEC(t, tiles2))
{
WHINE_ONCE("drawtile2() out-of-bounds!")
return;
@ -686,7 +686,7 @@ void Graphics::drawtile2( int x, int y, int t )
void Graphics::drawtile3( int x, int y, int t, int off, int height_subtract /*= 0*/ )
{
t += off * 30;
if (!INBOUNDS(t, tiles3))
if (!INBOUNDS_VEC(t, tiles3))
{
WHINE_ONCE("drawtile3() out-of-bounds!")
return;
@ -698,7 +698,7 @@ void Graphics::drawtile3( int x, int y, int t, int off, int height_subtract /*=
void Graphics::drawentcolours( int x, int y, int t)
{
if (!INBOUNDS(t, entcolours))
if (!INBOUNDS_VEC(t, entcolours))
{
WHINE_ONCE("drawentcolours() out-of-bounds!")
return;
@ -709,7 +709,7 @@ void Graphics::drawentcolours( int x, int y, int t)
void Graphics::drawtowertile( int x, int y, int t )
{
if (!INBOUNDS(t, tiles2))
if (!INBOUNDS_VEC(t, tiles2))
{
WHINE_ONCE("drawtowertile() out-of-bounds!")
return;
@ -722,7 +722,7 @@ void Graphics::drawtowertile( int x, int y, int t )
void Graphics::drawtowertile3( int x, int y, int t, int off )
{
t += off*30;
if (!INBOUNDS(t, tiles3))
if (!INBOUNDS_VEC(t, tiles3))
{
WHINE_ONCE("drawtowertile3() out-of-bounds!")
return;
@ -895,7 +895,7 @@ void Graphics::updatetextboxes()
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))
if (!INBOUNDS_VEC(t, images))
{
return;
}
@ -930,7 +930,7 @@ 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*/ )
{
if (!INBOUNDS(t, images))
if (!INBOUNDS_VEC(t, images))
{
return;
}
@ -958,7 +958,7 @@ 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)
{
if (!INBOUNDS(t, images))
if (!INBOUNDS_VEC(t, images))
{
return;
}
@ -1181,7 +1181,7 @@ void Graphics::textboxremove()
void Graphics::textboxtimer( int t )
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("textboxtimer() out-of-bounds!");
return;
@ -1192,7 +1192,7 @@ void Graphics::textboxtimer( int t )
void Graphics::addline( std::string t )
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("addline() out-of-bounds!");
return;
@ -1203,7 +1203,7 @@ void Graphics::addline( std::string t )
void Graphics::textboxadjust()
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("textboxadjust() out-of-bounds!");
return;
@ -1372,7 +1372,7 @@ void Graphics::drawmenu( int cr, int cg, int cb, bool levelmenu /*= false*/ )
void Graphics::drawcoloredtile( int x, int y, int t, int r, int g, int b )
{
if (!INBOUNDS(t, tiles))
if (!INBOUNDS_VEC(t, tiles))
{
return;
}
@ -1620,7 +1620,7 @@ void Graphics::drawentities()
case 0:
{
// Sprites
if (!INBOUNDS(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
{
continue;
}
@ -1688,7 +1688,7 @@ void Graphics::drawentities()
}
case 1:
// Tiles
if (!INBOUNDS(obj.entities[i].drawframe, tiles))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, tiles))
{
continue;
}
@ -1703,7 +1703,7 @@ void Graphics::drawentities()
case 8:
{
// Special: Moving platform, 4 tiles or 8 tiles
if (!INBOUNDS(obj.entities[i].drawframe, (*tilesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*tilesvec)))
{
continue;
}
@ -1770,7 +1770,7 @@ void Graphics::drawentities()
// Note: This code is in the 4-tile code
break;
case 9: // Really Big Sprite! (2x2)
if (!INBOUNDS(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
{
continue;
}
@ -1809,7 +1809,7 @@ void Graphics::drawentities()
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe + 13],NULL, backBuffer, &drawRect, ct);
break;
case 10: // 2x1 Sprite
if (!INBOUNDS(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
{
continue;
}
@ -1836,7 +1836,7 @@ void Graphics::drawentities()
drawimagecol(3, xp, yp - yoff);
break;
case 12: // Regular sprites that don't wrap
if (!INBOUNDS(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
{
continue;
}
@ -1895,7 +1895,7 @@ void Graphics::drawentities()
case 13:
{
//Special for epilogue: huge hero!
if (!INBOUNDS(obj.entities[i].drawframe, (*spritesvec)))
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
{
continue;
}
@ -2767,7 +2767,7 @@ void Graphics::menuoffrender()
void Graphics::drawhuetile( int x, int y, int t )
{
if (!INBOUNDS(t, tiles))
if (!INBOUNDS_VEC(t, tiles))
{
return;
}
@ -2820,7 +2820,7 @@ void Graphics::setwarprect( int a, int b, int c, int d )
void Graphics::textboxcenter()
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("textboxcenter() out-of-bounds!");
return;
@ -2832,7 +2832,7 @@ void Graphics::textboxcenter()
void Graphics::textboxcenterx()
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("textboxcenterx() out-of-bounds!");
return;
@ -2843,7 +2843,7 @@ void Graphics::textboxcenterx()
int Graphics::textboxwidth()
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("textboxwidth() out-of-bounds!");
return 0;
@ -2854,7 +2854,7 @@ int Graphics::textboxwidth()
void Graphics::textboxmove(int xo, int yo)
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("textboxmove() out-of-bounds!");
return;
@ -2866,7 +2866,7 @@ void Graphics::textboxmove(int xo, int yo)
void Graphics::textboxmoveto(int xo)
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("textboxmoveto() out-of-bounds!");
return;
@ -2877,7 +2877,7 @@ void Graphics::textboxmoveto(int xo)
void Graphics::textboxcentery()
{
if (!INBOUNDS(m, textbox))
if (!INBOUNDS_VEC(m, textbox))
{
puts("textboxcentery() out-of-bounds!");
return;
@ -3013,7 +3013,7 @@ void Graphics::bigrprint(int x, int y, std::string& t, int r, int g, int b, bool
while (iter != t.end()) {
cur = utf8::unchecked::next(iter);
idx = font_idx(cur);
if (INBOUNDS(idx, font))
if (INBOUNDS_VEC(idx, font))
{
SDL_Surface* tempPrint = ScaleSurface(font[idx], font[idx]->w *sc,font[idx]->h *sc);
SDL_Rect printrect = { Sint16((x) + bfontpos), Sint16(y) , Sint16(bfont_rect.w*sc), Sint16(bfont_rect.h * sc)};
@ -3030,7 +3030,7 @@ void Graphics::drawtele(int x, int y, int t, Uint32 c)
SDL_Rect telerect;
setRect(telerect, x , y, tele_rect.w, tele_rect.h );
if (INBOUNDS(0, tele))
if (INBOUNDS_VEC(0, tele))
{
BlitSurfaceColoured(tele[0], NULL, backBuffer, &telerect, ct);
}
@ -3040,7 +3040,7 @@ void Graphics::drawtele(int x, int y, int t, Uint32 c)
if (t < 0) t = 0;
setRect(telerect, x , y, tele_rect.w, tele_rect.h );
if (INBOUNDS(t, tele))
if (INBOUNDS_VEC(t, tele))
{
BlitSurfaceColoured(tele[t], NULL, backBuffer, &telerect, ct);
}
@ -3086,7 +3086,7 @@ void Graphics::setcolreal(Uint32 t)
void Graphics::drawforetile(int x, int y, int t)
{
if (!INBOUNDS(t, tiles))
if (!INBOUNDS_VEC(t, tiles))
{
WHINE_ONCE("drawforetile() out-of-bounds!")
return;
@ -3110,7 +3110,7 @@ void Graphics::drawforetile(int x, int y, int t)
void Graphics::drawforetile2(int x, int y, int t)
{
if (!INBOUNDS(t, tiles2))
if (!INBOUNDS_VEC(t, tiles2))
{
WHINE_ONCE("drawforetile2() out-of-bounds!")
return;
@ -3135,7 +3135,7 @@ void Graphics::drawforetile2(int x, int y, int t)
void Graphics::drawforetile3(int x, int y, int t, int off)
{
t += off * 30;
if (!INBOUNDS(t, tiles3))
if (!INBOUNDS_VEC(t, tiles3))
{
WHINE_ONCE("drawforetile3() out-of-bounds!")
return;

View File

@ -889,7 +889,7 @@ void mapclass::warpto(int rx, int ry , int t, int tx, int ty)
{
gotoroom(rx, ry);
game.teleport = false;
if (INBOUNDS(t, obj.entities))
if (INBOUNDS_VEC(t, obj.entities))
{
obj.entities[t].xp = tx * 8;
obj.entities[t].yp = (ty * 8) - obj.entities[t].h;

View File

@ -182,7 +182,7 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade
if (t != -1)
{
currentsong = t;
if (!INBOUNDS(t, musicTracks))
if (!INBOUNDS_VEC(t, musicTracks))
{
puts("play() out-of-bounds!");
currentsong = -1;

View File

@ -17,7 +17,7 @@ bool is_positive_num(const std::string& str, bool hex);
bool endsWith(const std::string& str, const std::string& suffix);
#define INBOUNDS(index, vector) ((int) index >= 0 && (int) index < (int) vector.size())
#define INBOUNDS_VEC(index, vector) ((int) index >= 0 && (int) index < (int) vector.size())
#define INBOUNDS_ARR(index, array) ((int) index >= 0 && (int) index < (int) SDL_arraysize(array))
#define WHINE_ONCE(message) \

View File

@ -2997,7 +2997,7 @@ void editorrender()
for (int i = 0; i < (int)ed.ghosts.size(); i++) {
if (i <= ed.currentghosts) { // We don't want all of them to show up at once :)
if (ed.ghosts[i].rx != ed.levx || ed.ghosts[i].ry != ed.levy
|| !INBOUNDS(ed.ghosts[i].frame, graphics.sprites))
|| !INBOUNDS_VEC(ed.ghosts[i].frame, graphics.sprites))
continue;
point tpoint;
tpoint.x = ed.ghosts[i].x;