diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-17 15:14:42 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-17 15:14:42 (GMT) |
| commit | 609db36f2e44aa915162422e7408726d76e7b2a1 (patch) | |
| tree | 6fb923888ead04e05a07761d311e13ec4be14cd1 /src/Renderer.cpp | |
| parent | f4e2d188c26b70e9a712906861a30cac05b2031e (diff) | |
| download | powder-609db36f2e44aa915162422e7408726d76e7b2a1.zip powder-609db36f2e44aa915162422e7408726d76e7b2a1.tar.gz | |
TPT: Check coordinates of signs before using them to read pmap or pressure 8a11b6b31d
Diffstat (limited to 'src/Renderer.cpp')
| -rw-r--r-- | src/Renderer.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 79b63ec..dba5a3b 100644 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -379,15 +379,18 @@ void Renderer::DrawSigns() //Displaying special information if (strcmp(signs[i].text, "{p}")==0) { - sprintf(buff, "Pressure: %3.2f", sim->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 = sim->pv[signs[i].y/CELL][signs[i].x/CELL]; + sprintf(buff, "Pressure: %3.2f", pressure); //...pressure g->drawtext(x+3, y+3, buff, 255, 255, 255, 255); } if (strcmp(signs[i].text, "{t}")==0) { - if (sim->pmap[signs[i].y][signs[i].x]) - sprintf(buff, "Temp: %4.2f", sim->parts[sim->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 && sim->pmap[signs[i].y][signs[i].x]) + sprintf(buff, "Temp: %4.2f", sim->parts[sim->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 g->drawtext(x+3, y+3, buff, 255, 255, 255, 255); } |
