diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-06-17 23:44:37 (GMT) |
|---|---|---|
| committer | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-06-17 23:44:37 (GMT) |
| commit | ae5470ca7878543f5079877c40f16060261cd6fa (patch) | |
| tree | a5ec93b1a00110827dc1fe7d789e8bbc55346372 /src/elements | |
| parent | c14704ae492834d9a888537b973a9b5a8585e3b3 (diff) | |
| download | powder-ae5470ca7878543f5079877c40f16060261cd6fa.zip powder-ae5470ca7878543f5079877c40f16060261cd6fa.tar.gz | |
Prevent stacking from ELEC+NEUT, ELEC+water, and CO2 from BUBW
Also conserve number of particles when CO2 from BUBW is absorbed by
water, and when splitting water into H2+O2 using ELEC.
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/co2.c | 11 | ||||
| -rw-r--r-- | src/elements/elec.c | 12 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/elements/co2.c b/src/elements/co2.c index acdbc99..adf85f5 100644 --- a/src/elements/co2.c +++ b/src/elements/co2.c @@ -22,10 +22,10 @@ int update_CO2(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) { r = pmap[y+ry][x+rx]; - if (20>(rand()%40000)&&parts[i].ctype==5) + if (parts[i].ctype==5 && 20>(rand()%40000)) { - parts[i].ctype = 0; - create_part(-3, x, y, PT_WATR); + if (create_part(-1, x+rx, y+ry, PT_WATR)>=0) + parts[i].ctype = 0; } if ((r>>8)>=NPART || !r) continue; @@ -39,7 +39,10 @@ int update_CO2(UPDATE_FUNC_ARGS) { if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%250)) { part_change_type(i,x,y,PT_CBNW); - kill_part(r>>8); + if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet + create_part(r>>8, x+rx, y+ry, PT_CBNW); + else + kill_part(r>>8); } } if (parts[i].temp > 9773.15 && pv[y/CELL][x/CELL] > 200.0f) diff --git a/src/elements/elec.c b/src/elements/elec.c index 2ea1dfc..2746f49 100644 --- a/src/elements/elec.c +++ b/src/elements/elec.c @@ -65,21 +65,15 @@ int update_ELEC(UPDATE_FUNC_ARGS) { if(rand()%2) { create_part(r>>8, x+rx, y+ry, PT_H2); - part_change_type(i, x, y, PT_O2); - parts[i].life = 0; - parts[i].ctype = 0; - return 1; } else { create_part(r>>8, x+rx, y+ry, PT_O2); - part_change_type(i, x, y, PT_H2); - parts[i].life = 0; - parts[i].ctype = 0; - return 1; } + kill_part(i); + return 1; } - if ((r&0xFF)==PT_NEUT) + if ((r&0xFF)==PT_NEUT && !pmap[y+ry][x+rx]) { part_change_type(r>>8, x+rx, y+ry, PT_H2); parts[r>>8].life = 0; |
