diff options
| author | cracker64 <cracker642@gmail.com> | 2013-03-02 05:42:07 (GMT) |
|---|---|---|
| committer | cracker64 <cracker642@gmail.com> | 2013-03-02 05:42:07 (GMT) |
| commit | d58100dc070be97073d1f02cdbb7a382a67c376b (patch) | |
| tree | cc0fc022e7f8524b7f9bcf5ed93eb83980596f91 /src/simulation/elements/PQRT.cpp | |
| parent | a9f4b5fe343fb0ada8934030abe6363695ea43dc (diff) | |
| download | powder-d58100dc070be97073d1f02cdbb7a382a67c376b.zip powder-d58100dc070be97073d1f02cdbb7a382a67c376b.tar.gz | |
More fixes, redid a bunch of SPRK, so far everything I've tested works fine.
Diffstat (limited to 'src/simulation/elements/PQRT.cpp')
| -rw-r--r-- | src/simulation/elements/PQRT.cpp | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/src/simulation/elements/PQRT.cpp b/src/simulation/elements/PQRT.cpp index bb03f08..2b3898f 100644 --- a/src/simulation/elements/PQRT.cpp +++ b/src/simulation/elements/PQRT.cpp @@ -48,7 +48,7 @@ Element_PQRT::Element_PQRT() //#TPT-Directive ElementHeader Element_PQRT static int update(UPDATE_FUNC_ARGS) int Element_PQRT::update(UPDATE_FUNC_ARGS) - { +{ int r, tmp, trade, rx, ry, np; // absorb SLTW if (parts[i].ctype!=-1) @@ -65,50 +65,47 @@ int Element_PQRT::update(UPDATE_FUNC_ARGS) parts[i].ctype ++; } } - // grow if absorbed SLTW + // grow and diffuse if (parts[i].ctype>0) { - for ( trade = 0; trade<5; trade ++) + bool stopgrow=false; + int rnd, sry, srx; + for ( trade = 0; trade<9; trade ++) { - rx = rand()%3-1; - ry = rand()%3-1; + rnd = rand()%0x3FF; + rx = (rnd%5)-2; + srx = (rnd%3)-1; + rnd = rnd>>3; + ry = (rnd%5)-2; + sry = (rnd%3)-1; if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) { - r = pmap[y+ry][x+rx]; - if (!r && parts[i].ctype!=0) + if (!stopgrow)//try to grow { - np = sim->create_part(-1,x+rx,y+ry,PT_QRTZ); - if (np>-1) + if (!pmap[y+sry][x+srx] && parts[i].ctype!=0) { - parts[np].tmp = parts[i].tmp; - parts[i].ctype--; - if (rand()%2) - { - parts[np].ctype=-1;//dead qrtz - } - else if (!parts[i].ctype && !(rand()%15)) + np = sim->create_part(-1,x+srx,y+sry,PT_QRTZ); + if (np>-1) { - parts[i].ctype=-1; + parts[np].tmp = parts[i].tmp; + parts[i].ctype--; + if (rand()%2) + { + parts[np].ctype=-1;//dead qrtz + } + else if (!parts[i].ctype && !(rand()%15)) + { + parts[i].ctype=-1; + } + stopgrow=true; } - break; } } - } - } - } - // diffuse absorbed SLTW - if (parts[i].ctype>0) - { - for ( trade = 0; trade<9; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { + //diffusion r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_PQRT && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion + else if ((r&0xFF)==PT_PQRT && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 ) { tmp = parts[i].ctype - parts[r>>8].ctype; if (tmp ==1) |
