diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-01-19 22:32:28 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-25 13:33:21 (GMT) |
| commit | 8a11b6b31d253b3d54daa8afadf92b4073c5f127 (patch) | |
| tree | 7a2a7f362a337ba7c65327cb7fbf432b7958e88b /src | |
| parent | ff6aa0227db6ca9e3572775064af625210b04374 (diff) | |
| download | powder-8a11b6b31d253b3d54daa8afadf92b4073c5f127.zip powder-8a11b6b31d253b3d54daa8afadf92b4073c5f127.tar.gz | |
Check coordinates of signs before using them to read pmap or pressure
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/graphics.c b/src/graphics.c index aa72139..c460725 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3056,15 +3056,18 @@ void render_signs(pixel *vid_buf) //Displaying special information 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); } if (strcmp(signs[i].text, "{t}")==0) { - if (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 + 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); //...temperature 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); } |
