summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-08-19 13:19:06 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-19 19:29:34 (GMT)
commit075bf06c715b5f198916360350f06acd88e9be90 (patch)
tree3714284b4ab37b212da9ddd4a792d1fd8b348ac0 /src
parentac4ffb8d5dbb2e3fe10a979e0cdc6c34a2a8a31f (diff)
downloadpowder-075bf06c715b5f198916360350f06acd88e9be90.zip
powder-075bf06c715b5f198916360350f06acd88e9be90.tar.gz
Fix crash in prerender_save when STKM is near bottom of save
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 696cab9..9078386 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -4441,35 +4441,29 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
j=d[p++];
if (j<PT_NUM && j>0)
{
- if (j==PT_STKM)
+ if (j==PT_STKM || j==PT_STKM2)
{
- //Stickman drawing
- for (k=-2; k<=1; k++)
+ pixel lc, hc=PIXRGB(255, 224, 178);
+ if (j==PT_STKM) lc = PIXRGB(255, 255, 255);
+ else lc = PIXRGB(100, 100, 255);
+ //only need to check upper bound of y coord - lower bounds and x<w are checked in draw_line
+ draw_line(fb , x-2, y-2, x+2, y-2, PIXR(lc), PIXG(lc), PIXB(lc), w);
+ if (y+2<h)
{
- fb[(y-2)*w+x+k] = PIXRGB(255, 224, 178);
- fb[(y+2)*w+x+k+1] = PIXRGB(255, 224, 178);
- fb[(y+k+1)*w+x-2] = PIXRGB(255, 224, 178);
- fb[(y+k)*w+x+2] = PIXRGB(255, 224, 178);
+ draw_line(fb , x-2, y+2, x+2, y+2, PIXR(lc), PIXG(lc), PIXB(lc), w);
+ draw_line(fb , x-2, y-2, x-2, y+2, PIXR(lc), PIXG(lc), PIXB(lc), w);
+ draw_line(fb , x+2, y-2, x+2, y+2, PIXR(lc), PIXG(lc), PIXB(lc), w);
}
- draw_line(fb , x, y+3, x-1, y+6, 255, 255, 255, w);
- draw_line(fb , x-1, y+6, x-3, y+12, 255, 255, 255, w);
- draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w);
- draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w);
- }
- else if (j==PT_STKM2)
- {
- //Stickman drawing
- for (k=-2; k<=1; k++)
+ if (y+6<h)
+ {
+ draw_line(fb , x, y+3, x-1, y+6, PIXR(hc), PIXG(hc), PIXB(hc), w);
+ draw_line(fb , x, y+3, x+1, y+6, PIXR(hc), PIXG(hc), PIXB(hc), w);
+ }
+ if (y+12<h)
{
- fb[(y-2)*w+x+k] = PIXRGB(255, 224, 178);
- fb[(y+2)*w+x+k+1] = PIXRGB(255, 224, 178);
- fb[(y+k+1)*w+x-2] = PIXRGB(255, 224, 178);
- fb[(y+k)*w+x+2] = PIXRGB(255, 224, 178);
+ draw_line(fb , x-1, y+6, x-3, y+12, PIXR(hc), PIXG(hc), PIXB(hc), w);
+ draw_line(fb , x+1, y+6, x+3, y+12, PIXR(hc), PIXG(hc), PIXB(hc), w);
}
- draw_line(fb , x, y+3, x-1, y+6, 255, 255, 255, w);
- draw_line(fb , x-1, y+6, x-3, y+12, 255, 255, 255, w);
- draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w);
- draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w);
}
else
fb[y*w+x] = ptypes[j].pcolors;