From b673be0ac2db3bc3806f8b21eef66c606aabf4b2 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Fri, 14 Jan 2011 00:29:32 -0500 Subject: [PATCH] a fix so photons can be deleted and show up on HUD :) --- includes/powder.h | 2 ++ src/main.c | 6 +++++- src/powder.c | 18 +++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 87e53f827..068edb22c 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -673,6 +673,8 @@ extern int pfree; extern unsigned pmap[YRES][XRES]; unsigned cb_pmap[YRES][XRES]; +unsigned photons[YRES][XRES]; + int try_move(int i, int x, int y, int nx, int ny); void kill_part(int i); diff --git a/src/main.c b/src/main.c index 452103f5a..a12ff9b48 100644 --- a/src/main.c +++ b/src/main.c @@ -1737,7 +1737,11 @@ int main(int argc, char *argv[]) if(y>0 && y0 && x>8)>=NPART || !cr)) { #ifdef BETA diff --git a/src/powder.c b/src/powder.c index a05ed3e6a..324a34f36 100644 --- a/src/powder.c +++ b/src/powder.c @@ -595,6 +595,8 @@ inline int create_part(int p, int x, int y, int t) } return -1; } + if(photons[y][x] && t==PT_PHOT) + return -1; if(pfree == -1) return -1; i = pfree; @@ -699,6 +701,8 @@ inline int create_part(int p, int x, int y, int t) 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 pmap[y][x] = t|(i<<8); + if(t==PT_PHOT) + photons[y][x] = t|(i<<8); else if(t==PT_STKM) { if(isplayer==0) @@ -909,7 +913,12 @@ inline void delete_part(int x, int y) if(x<0 || y<0 || x>=XRES || y>=YRES) return; - i = pmap[y][x]; + if(photons[y][x]){ + i = photons[y][x]; + } else { + i = pmap[y][x]; + } + if(!i || (i>>8)>=NPART) return; if((parts[i>>8].type==SLALT)||SLALT==0) @@ -5252,6 +5261,7 @@ void update_particles(pixel *vid) isplayer = 0; //Needed for player spawning isplayer2 = 0; memset(pmap, 0, sizeof(pmap)); + memset(photons, 0, sizeof(photons)); r = rand()%2; NUM_PARTS = 0; for(j=0; j=CELL) { - if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm) + if((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm || (photons[y][x1-1]&0xFF)!=cm) { break; } @@ -5946,7 +5958,7 @@ int flood_parts(int x, int y, int c, int cm, int bm) } while(x2