diff options
| author | jacksonmj <jacksonmj@jacksonmj.none> | 2011-01-10 00:46:34 (GMT) |
|---|---|---|
| committer | jacksonmj <jacksonmj@jacksonmj.none> | 2011-01-10 00:46:34 (GMT) |
| commit | 855281295fbc23366e8b84d7c8e55816d6f47a87 (patch) | |
| tree | 761d7cbaf37e3f10b1ee97f72d34f1da70d6732d /src/elements/prto.c | |
| parent | 88d107f18a9c6d37493a953142a503d963ec37b1 (diff) | |
| download | powder-855281295fbc23366e8b84d7c8e55816d6f47a87.zip powder-855281295fbc23366e8b84d7c8e55816d6f47a87.tar.gz | |
More update functions cleanup.
Diffstat (limited to 'src/elements/prto.c')
| -rw-r--r-- | src/elements/prto.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/elements/prto.c b/src/elements/prto.c index acaa689..a5d2c7e 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -1,16 +1,15 @@ #include <powder.h> int update_PRTO(UPDATE_FUNC_ARGS) { - int r, nnx; + int r, nnx, rx, ry, np; int count = 0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); - for (ny=1; ny>-2; ny--) - for (nx=1; nx>-2; nx--) - if (x+nx>=0 && y+ny>0 && - x+nx<XRES && y+ny<YRES && (nx || ny)) + 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)) { + r = pmap[y+ry][x+rx]; count ++; - r = pmap[y+ny][x+nx]; if ((r>>8)>=NPART || r) continue; if (!r) @@ -22,7 +21,7 @@ int update_PRTO(UPDATE_FUNC_ARGS) { randomness=1; if (randomness>8) randomness=8; - if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)//todo. make it look better + if (portal[parts[i].tmp][randomness-1][nnx]==PT_SPRK)// TODO: make it look better { create_part(-1,x+1,y,portal[parts[i].tmp][randomness-1][nnx]); create_part(-1,x+1,y+1,portal[parts[i].tmp][randomness-1][nnx]); @@ -38,8 +37,9 @@ int update_PRTO(UPDATE_FUNC_ARGS) { } else if (portal[parts[i].tmp][randomness-1][nnx]) { - create_part(-1,x+nx,y+ny,portal[parts[i].tmp][randomness-1][nnx]); - parts[pmap[y+ny][x+nx]>>8].temp = portaltemp[parts[i].tmp][randomness-1][nnx]; + np = create_part(-1,x+rx,y+ry,portal[parts[i].tmp][randomness-1][nnx]); + if (np<0) continue; + parts[np].temp = portaltemp[parts[i].tmp][randomness-1][nnx]; portal[parts[i].tmp][randomness-1][nnx] = 0; portaltemp[parts[i].tmp][randomness-1][nnx] = 0; break; |
