diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-08 13:57:32 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-08 13:57:32 (GMT) |
| commit | 9b9d6283744c2164d90fece77366adf8d13abcd3 (patch) | |
| tree | f30a728cd17e605d6f2595da153f191651a79291 /src/elements | |
| parent | dd2d06425e80193d3bf59df0d2600d21bdde49ce (diff) | |
| download | powder-9b9d6283744c2164d90fece77366adf8d13abcd3.zip powder-9b9d6283744c2164d90fece77366adf8d13abcd3.tar.gz | |
Improvements to Wire
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/wire.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/elements/wire.c b/src/elements/wire.c index 920ddc9..f56e469 100644 --- a/src/elements/wire.c +++ b/src/elements/wire.c @@ -2,7 +2,6 @@ int update_WIRE(UPDATE_FUNC_ARGS) { int s,r,rx,ry,count; - s=pmap[y][x]; /* 0: wire 1: spark head @@ -10,23 +9,32 @@ int update_WIRE(UPDATE_FUNC_ARGS) { tmp is previous state, ctype is current state */ - //parts[s>>8].tmp=parts[s>>8].ctype; - parts[s>>8].ctype=0; - if(parts[s>>8].tmp==1){parts[s>>8].ctype=2; return 0;} - if(parts[s>>8].tmp==2){parts[s>>8].ctype=0; return 0;} + //parts[i].tmp=parts[i].ctype; + parts[i].ctype=0; + if(parts[i].tmp==1) + { + parts[i].ctype=2; + } + if(parts[i].tmp==2) + { + parts[i].ctype=0; + } count=0; for(rx=-1; rx<2; rx++) for(ry=-1; ry<2; ry++) + { + if(x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) { - if(x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && pmap[y+ry][x+rx] && (rx!=0 || ry!=0) && (pmap[y+ry][x+rx]&0xFF)!=0xFF) - { r = pmap[y+ry][x+rx]; - if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[s>>8].ctype=1; parts[r>>8].life=0; return 0;} - if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1){count++;} - } + if ((r>>8)>=NPART || !r) + continue; + if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[i].ctype=1; parts[r>>8].life=0; return 0;} + else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);} + else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;} } + } if(count==1 || count==2) - parts[s>>8].ctype=1; + parts[i].ctype=1; return 0; } |
