From 3b3a173dc95ca298c8472a3a2042f0e4e8198629 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 17 Mar 2011 21:42:07 +0000 Subject: [PATCH] Remove neutrons from pmap --- src/main.c | 3 ++- src/powder.c | 43 +++++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/main.c b/src/main.c index f8ea58ff7..572ac19b4 100644 --- a/src/main.c +++ b/src/main.c @@ -339,7 +339,8 @@ void *build_save(int *size, int x0, int y0, int w, int h) y = (int)(parts[i].y+0.5f); if (x>=x0 && x=y0 && y> 8; if (r && e>8)==e) pmap[ny][nx] = (s&~(0xFF))|parts[s>>8].type; + 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; + } + if ((pmap[ny][nx]>>8)==e) pmap[ny][nx] = 0; parts[e].x += x-nx; parts[e].y += y-ny; @@ -457,7 +471,7 @@ inline void part_change_type(int i, int x, int y, int t) if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART || t<0 || t>=PT_NUM) return; parts[i].type = t; - if (t==PT_PHOT)// || t==PT_NEUT) + if (t==PT_PHOT || t==PT_NEUT) { photons[y][x] = t|(i<<8); if ((pmap[y][x]>>8)==i) @@ -505,9 +519,9 @@ inline int create_n_parts(int n, int x, int y, float vx, float vy, int t) parts[i].ctype = 0; parts[i].temp += (n*17); parts[i].tmp = 0; - if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && !pmap[y][x])// && t!=PT_NEUT) + if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT && !pmap[y][x]) pmap[y][x] = t|(i<<8); - else if (t==PT_PHOT && !photons[y][x]) + else if ((t==PT_PHOT||t==PT_NEUT) && !photons[y][x]) photons[y][x] = t|(i<<8); pv[y/CELL][x/CELL] += 6.0f * CFDS; @@ -627,7 +641,7 @@ inline int create_part(int p, int x, int y, int t) } return -1; } - if (photons[y][x] && t==PT_PHOT) + if (photons[y][x] && (t==PT_PHOT||t==PT_NEUT)) return -1; if (pfree == -1) return -1; @@ -735,8 +749,6 @@ inline int create_part(int p, int x, int y, int t) parts[i].vx = 3.0f*cosf(a); parts[i].vy = 3.0f*sinf(a); } - if (t==PT_PHOT) - photons[y][x] = t|(i<<8); if (t==PT_STKM) { if (isplayer==0) @@ -855,7 +867,9 @@ inline int create_part(int p, int x, int y, int t) } if (t==PT_BIZR||t==PT_BIZRG) parts[i].ctype = 0x47FFFF; - if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT)// && t!=PT_NEUT) is this needed? it breaks floodfill, Yes photons should not be placed in the PMAP + if (t==PT_PHOT||t==PT_NEUT) + photons[y][x] = t|(i<<8); + if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT) // is this needed? it breaks floodfill, Yes photons should not be placed in the PMAP pmap[y][x] = t|(i<<8); return i; @@ -2051,13 +2065,13 @@ killed: if (ny!=y || nx!=x) { if ((pmap[y][x]>>8)==i) pmap[y][x] = 0; - else if (t==PT_PHOT&&(photons[y][x]>>8)==i) photons[y][x] = 0; + else if ((photons[y][x]>>8)==i) photons[y][x] = 0; if (nx=XRES-CELL || ny=YRES-CELL) { kill_part(i); continue; } - if (t==PT_PHOT) + if (t==PT_PHOT||t==PT_NEUT) photons[ny][nx] = t|(i<<8); else pmap[ny][nx] = t|(i<<8); @@ -2092,12 +2106,13 @@ void update_particles(pixel *vid) t = parts[i].type; x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f); - if (x>=0 && y>=0 && x=0 && y>=0 && x