From 4d80abc399b0694eb602487058d7b5865f9b4eae Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sun, 3 Apr 2011 01:37:41 +0100 Subject: [PATCH] Fix neutrons crash Also fix neutrons causing unwanted movement of parts[0] --- src/powder.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/powder.c b/src/powder.c index b178318ae..4ae5bca39 100644 --- a/src/powder.c +++ b/src/powder.c @@ -237,7 +237,7 @@ int try_move(int i, int x, int y, int nx, int ny) return 0; } - if ((pmap[ny][nx]&0xFF)==PT_CNCT)//why is this here + if ((pmap[ny][nx]&0xFF)==PT_CNCT)//stops CNCT being displaced by other particles return 0; if (parts[i].type==PT_CNCT && y>8)>=NPART) return 0; if ((s&0xFF) && (s&0xFF)>8)==e) pmap[ny][nx] = (s&~(0xFF))|parts[s>>8].type; + return 1; // if the element currently underneath neutron isn't NEUTPENETRATE, don't move anything except the neutron + // if nothing is currently underneath neutron, only move target particle + if (s) + { + pmap[ny][nx] = (s&~(0xFF))|parts[s>>8].type; + parts[s>>8].x = nx; + parts[s>>8].y = ny; + } + else pmap[ny][nx] = 0; parts[e].x = x; parts[e].y = y; pmap[y][x] = (e<<8)|parts[e].type; - parts[s>>8].x = nx; - parts[s>>8].y = ny; return 1; }