diff options
| author | Cracker64 <cracker642@gmail.com> | 2011-01-14 05:29:32 (GMT) |
|---|---|---|
| committer | Cracker64 <cracker642@gmail.com> | 2011-01-14 05:29:32 (GMT) |
| commit | b673be0ac2db3bc3806f8b21eef66c606aabf4b2 (patch) | |
| tree | 8fe9fca427cc5f9b3fe2168452e705a066b8854e /src | |
| parent | 225dab24ea41fb1456216dfbc3e0d11c5a572d29 (diff) | |
| download | powder-b673be0ac2db3bc3806f8b21eef66c606aabf4b2.zip powder-b673be0ac2db3bc3806f8b21eef66c606aabf4b2.tar.gz | |
a fix so photons can be deleted and show up on HUD :)
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 6 | ||||
| -rw-r--r-- | src/powder.c | 18 |
2 files changed, 20 insertions, 4 deletions
@@ -1737,7 +1737,11 @@ int main(int argc, char *argv[]) if(y>0 && y<sdl_scale*YRES && x>0 && x<sdl_scale*XRES) { int cr; - cr = pmap[y/sdl_scale][x/sdl_scale]; + if(photons[y/sdl_scale][x/sdl_scale]){ + cr = photons[y/sdl_scale][x/sdl_scale]; + }else{ + cr = pmap[y/sdl_scale][x/sdl_scale]; + } if(!((cr>>8)>=NPART || !cr)) { #ifdef BETA diff --git a/src/powder.c b/src/powder.c index a05ed3e..324a34f 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<NPART; j++) @@ -5266,6 +5276,8 @@ void update_particles(pixel *vid) if(t!=PT_NEUT || (pmap[y][x]&0xFF)!=PT_GLAS) pmap[y][x] = t|(i<<8); } + if(t==PT_PHOT) + photons[y][x] = t|(i<<8); NUM_PARTS ++; } else @@ -5938,7 +5950,7 @@ int flood_parts(int x, int y, int c, int cm, int bm) x1 = x2 = x; while(x1>=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<XRES-CELL) { - if((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm) + if((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm || (photons[y][x1+1]&0xFF)!=cm) { break; } |
