Check coordinates of signs before using them to read pmap or pressure
This commit is contained in:
parent
ff6aa0227d
commit
8a11b6b31d
@ -3056,15 +3056,18 @@ void render_signs(pixel *vid_buf)
|
|||||||
//Displaying special information
|
//Displaying special information
|
||||||
if (strcmp(signs[i].text, "{p}")==0)
|
if (strcmp(signs[i].text, "{p}")==0)
|
||||||
{
|
{
|
||||||
sprintf(buff, "Pressure: %3.2f", pv[signs[i].y/CELL][signs[i].x/CELL]); //...pressure
|
float pressure = 0.0f;
|
||||||
|
if (signs[i].x>=0 && signs[i].x<XRES && signs[i].y>=0 && signs[i].y<YRES)
|
||||||
|
pressure = pv[signs[i].y/CELL][signs[i].x/CELL];
|
||||||
|
sprintf(buff, "Pressure: %3.2f", pressure); //...pressure
|
||||||
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
|
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
if (strcmp(signs[i].text, "{t}")==0)
|
if (strcmp(signs[i].text, "{t}")==0)
|
||||||
{
|
{
|
||||||
if (pmap[signs[i].y][signs[i].x])
|
if (signs[i].x>=0 && signs[i].x<XRES && signs[i].y>=0 && signs[i].y<YRES && pmap[signs[i].y][signs[i].x])
|
||||||
sprintf(buff, "Temp: %4.2f", parts[pmap[signs[i].y][signs[i].x]>>8].temp-273.15); //...tempirature
|
sprintf(buff, "Temp: %4.2f", parts[pmap[signs[i].y][signs[i].x]>>8].temp-273.15); //...temperature
|
||||||
else
|
else
|
||||||
sprintf(buff, "Temp: 0.00"); //...tempirature
|
sprintf(buff, "Temp: 0.00"); //...temperature
|
||||||
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
|
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user