Add bounds check to textbox functions that use m

It seems to be a bit bad to blindly use `m` without checking it. In
fact, this has caused a few segfaults already, actually.
This commit is contained in:
Misa
2020-06-28 10:40:58 -07:00
committed by Ethan Lee
parent a0f10d80e5
commit c95c1ab250

View File

@@ -1141,16 +1141,31 @@ void Graphics::textboxremove()
void Graphics::textboxtimer( int t )
{
if (!INBOUNDS(m, textbox))
{
return;
}
textbox[m].timer=t;
}
void Graphics::addline( std::string t )
{
if (!INBOUNDS(m, textbox))
{
return;
}
textbox[m].addline(t);
}
void Graphics::textboxadjust()
{
if (!INBOUNDS(m, textbox))
{
return;
}
textbox[m].adjust();
}
@@ -2787,33 +2802,63 @@ void Graphics::setwarprect( int a, int b, int c, int d )
void Graphics::textboxcenter()
{
if (!INBOUNDS(m, textbox))
{
return;
}
textbox[m].centerx();
textbox[m].centery();
}
void Graphics::textboxcenterx()
{
if (!INBOUNDS(m, textbox))
{
return;
}
textbox[m].centerx();
}
int Graphics::textboxwidth()
{
if (!INBOUNDS(m, textbox))
{
return 0;
}
return textbox[m].w;
}
void Graphics::textboxmove(int xo, int yo)
{
if (!INBOUNDS(m, textbox))
{
return;
}
textbox[m].xp += xo;
textbox[m].yp += yo;
}
void Graphics::textboxmoveto(int xo)
{
if (!INBOUNDS(m, textbox))
{
return;
}
textbox[m].xp = xo;
}
void Graphics::textboxcentery()
{
if (!INBOUNDS(m, textbox))
{
return;
}
textbox[m].centery();
}