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/QRTZ.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/QRTZ.cpp')
| -rw-r--r-- | src/simulation/elements/QRTZ.cpp | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/src/simulation/elements/QRTZ.cpp b/src/simulation/elements/QRTZ.cpp index e38e11b..6e5102c 100644 --- a/src/simulation/elements/QRTZ.cpp +++ b/src/simulation/elements/QRTZ.cpp @@ -48,7 +48,7 @@ Element_QRTZ::Element_QRTZ() //#TPT-Directive ElementHeader Element_QRTZ static int update(UPDATE_FUNC_ARGS) int Element_QRTZ::update(UPDATE_FUNC_ARGS) - { +{ int r, tmp, trade, rx, ry, np; parts[i].pavg[0] = parts[i].pavg[1]; parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; @@ -71,51 +71,47 @@ int Element_QRTZ::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 >>= 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_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion + else if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 ) { tmp = parts[i].ctype - parts[r>>8].ctype; if (tmp ==1) |
