summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-08-20 14:50:59 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-20 18:37:25 (GMT)
commit5f8fba12c8ce6740a0dfabc3b04a80893e7a041d (patch)
tree78861028fbcfaad345e9c77592e8620566dbe571 /src/powder.c
parent20aba663cdb52070e2c07f94d687885e45cf6fc0 (diff)
downloadpowder-5f8fba12c8ce6740a0dfabc3b04a80893e7a041d.zip
powder-5f8fba12c8ce6740a0dfabc3b04a80893e7a041d.tar.gz
Change portal so that randomness never causes a particle to exit the same side it came in
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/powder.c b/src/powder.c
index 36f10e7..6d30e10 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -223,30 +223,19 @@ int try_move(int i, int x, int y, int nx, int ny)
if ((r&0xFF)==PT_PRTI && (parts[i].type==PT_PHOT || parts[i].type==PT_NEUT))
{
int nnx, count;
- if (nx-x<0)
+ for (count=0; count<8; count++)
{
- if (ny-y<0) count = 1;
- else if (ny-y==0) count = 2;
- else count = 3;
- }
- else if (nx-x==0)
- {
- if (ny-y<0) count = 4;
- else count = 5;
- }
- else
- {
- if (ny-y<0) count = 6;
- else if (ny-y==0) count = 7;
- else count = 8;
+ if (isign(x-nx)==isign(portal_rx[count]) && isign(y-ny)==isign(portal_ry[count]))
+ break;
}
+ count = count%8;
parts[r>>8].tmp = (int)((parts[r>>8].temp-73.15f)/100+1);
if (parts[r>>8].tmp>=CHANNELS) parts[r>>8].tmp = CHANNELS-1;
else if (parts[r>>8].tmp<0) parts[r>>8].tmp = 0;
for ( nnx=0; nnx<80; nnx++)
- if (!portalp[parts[r>>8].tmp][count-1][nnx].type)
+ if (!portalp[parts[r>>8].tmp][count][nnx].type)
{
- portalp[parts[r>>8].tmp][count-1][nnx] = parts[i];
+ portalp[parts[r>>8].tmp][count][nnx] = parts[i];
parts[i].type=PT_NONE;
break;
}