From 11dbdb9314e4f1a4d60201ae5b2d6a5f6f7fc310 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Wed, 6 Jul 2011 17:08:13 +0800 Subject: [PATCH] Fix crashing when pipe has a negative tmp value --- src/graphics.c | 2 +- src/main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graphics.c b/src/graphics.c index 8bdd6fa97..a45b02dc8 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2377,7 +2377,7 @@ void draw_parts(pixel *vid) cg = PIXG(ptypes[t].pcolors); cb = PIXB(ptypes[t].pcolors); } - if (parts[i].tmp) + if (parts[i].tmp>0 && parts[i].tmp>8].ctype; - if (tctype>=PT_NUM || tctype<0 || (cr&0xFF)==PT_PHOT) - tctype = 0; if ((cr&0xFF)==PT_PIPE) { if (parts[cr>>8].tmp>8].tmp; else tctype = 0; } + if (tctype>=PT_NUM || tctype<0 || (cr&0xFF)==PT_PHOT) + tctype = 0; sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale); } else {