summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2010-08-11 18:15:20 (GMT)
committer Simon <simon@hardwired.org.uk>2010-08-11 18:15:20 (GMT)
commit51c8a487bb6a69f157997a621d521ff2f59a9625 (patch)
tree1378d4eb1a51212e60b5e9cc4959b0405ba12cde
parentd215842080aaf21003879edeed6151387412fa9d (diff)
downloadpowder-51c8a487bb6a69f157997a621d521ff2f59a9625.zip
powder-51c8a487bb6a69f157997a621d521ff2f59a9625.tar.gz
Fix Stickman crashes, update version number
-rwxr-xr-xpowder.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/powder.c b/powder.c
index 3b4dfac..5ac8e33 100755
--- a/powder.c
+++ b/powder.c
@@ -2060,6 +2060,8 @@ void update_particles_i(pixel *vid, int start, int inc){
for(nx = -2; nx <= 2; nx++)
for(ny = 0; ny>=-2; ny--)
{
+ if(!pmap[ny+y][nx+x] || (pmap[ny+y][nx+x]>>8)>=NPART)
+ continue;
if(pmap[ny+y][nx+x] && (pmap[ny+y][nx+x]&0xFF)!=0xFF
&& pstates[pmap[ny+y][nx+x]&0xFF].state != ST_SOLID
//&& (abs(nx-x)+abs(ny-y))<r //Need fix
@@ -2091,7 +2093,10 @@ void update_particles_i(pixel *vid, int start, int inc){
if(((int)(player[0])&0x08) == 0x08)
{
ny -= 2*(rand()%2)+1;
- if(pstates[pmap[ny][nx]&0xFF].state == ST_SOLID)
+ r = pmap[ny][nx];
+ if(r && (r>>8)<NPART)
+ r = 0;
+ if(pstates[r&0xFF].state == ST_SOLID)
{
create_part(-1, nx, ny, PT_SPRK);
}
@@ -2146,7 +2151,7 @@ void update_particles_i(pixel *vid, int start, int inc){
r = pmap[(int)(player[8]-ny)][(int)(player[7]+0.5)]; //This is to make coding more pleasant :-)
//For left leg
- if (r && (r&0xFF)!=PT_STKM)
+ if (r && (r>>8)<NPART && (r&0xFF)!=PT_STKM)
{
if(pstates[r&0xFF].state == ST_LIQUID || pstates[r&0xFF].state == ST_GAS) //Liquid checks
{
@@ -2168,7 +2173,7 @@ void update_particles_i(pixel *vid, int start, int inc){
r = pmap[(int)(player[16]-ny)][(int)(player[15]+0.5)];
//For right leg
- if (r && (r&0xFF)!=PT_STKM)
+ if (r && (r>>8)<NPART && (r&0xFF)!=PT_STKM)
{
if(pstates[r&0xFF].state == ST_LIQUID || pstates[r&0xFF].state == ST_GAS)
{
@@ -2211,12 +2216,12 @@ void update_particles_i(pixel *vid, int start, int inc){
//If legs touch something
r = pmap[(int)(player[8]+1.5)][(int)(player[7]+0.5)];
- if((r&0xFF)==PT_SPRK && (r&0xFF)!=0xFF) //If on charge
+ if((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
{
parts[i].life -= (int)(rand()/1000)+38;
}
- if ((r&0xFF)!=0xFF) //If hot
+ if (r && (r>>8)<NPART) //If hot
{
if(parts[r>>8].temp>=50)
{
@@ -2232,12 +2237,12 @@ void update_particles_i(pixel *vid, int start, int inc){
parts[i].life -= 1;
r = pmap[(int)(player[16]+1.5)][(int)(player[15]+0.5)];
- if((r&0xFF)==PT_SPRK && (r&0xFF)!=0xFF) //If on charge
+ if((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
{
parts[i].life -= (int)(rand()/1000)+38;
}
- if((r&0xFF)!=0xFF) //If hot
+ if(r && (r>>8)<NPART) //If hot
{
if(parts[r>>8].temp>=50)
{
@@ -2262,7 +2267,8 @@ void update_particles_i(pixel *vid, int start, int inc){
if(x+nx>=0 && y+ny>0 &&
x+nx<XRES && y+ny<YRES &&
pmap[y+ny][x+nx] &&
- (pmap[y+ny][x+nx]&0xFF)!=PT_CLNE && pmap[y+ny][x+nx]!=PT_STKM &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_CLNE &&
+ (pmap[y+ny][x+nx]&0xFF)!=PT_STKM &&
(pmap[y+ny][x+nx]&0xFF)!=0xFF)
parts[i].ctype = pmap[y+ny][x+nx]&0xFF;
} else