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.
This commit is contained in:
jacksonmj 2012-06-18 00:44:37 +01:00
parent c14704ae49
commit ae5470ca78
2 changed files with 10 additions and 13 deletions

View File

@ -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)) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (20>(rand()%40000)&&parts[i].ctype==5) if (parts[i].ctype==5 && 20>(rand()%40000))
{ {
if (create_part(-1, x+rx, y+ry, PT_WATR)>=0)
parts[i].ctype = 0; parts[i].ctype = 0;
create_part(-3, x, y, PT_WATR);
} }
if ((r>>8)>=NPART || !r) if ((r>>8)>=NPART || !r)
continue; continue;
@ -39,6 +39,9 @@ int update_CO2(UPDATE_FUNC_ARGS) {
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%250)) if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%250))
{ {
part_change_type(i,x,y,PT_CBNW); part_change_type(i,x,y,PT_CBNW);
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); kill_part(r>>8);
} }
} }

View File

@ -65,21 +65,15 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
if(rand()%2) if(rand()%2)
{ {
create_part(r>>8, x+rx, y+ry, PT_H2); 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 else
{ {
create_part(r>>8, x+rx, y+ry, PT_O2); create_part(r>>8, x+rx, y+ry, PT_O2);
part_change_type(i, x, y, PT_H2); }
parts[i].life = 0; kill_part(i);
parts[i].ctype = 0;
return 1; return 1;
} }
} if ((r&0xFF)==PT_NEUT && !pmap[y+ry][x+rx])
if ((r&0xFF)==PT_NEUT)
{ {
part_change_type(r>>8, x+rx, y+ry, PT_H2); part_change_type(r>>8, x+rx, y+ry, PT_H2);
parts[r>>8].life = 0; parts[r>>8].life = 0;