From 8d66b62e3d237cca2a8489cae21001170d58d590 Mon Sep 17 00:00:00 2001 From: Pilihp Date: Tue, 26 Feb 2013 18:42:36 -0500 Subject: [PATCH] Lots of small optimizations and things, nothing should be functionally different. Only gotten through a few elements, more later. --- src/simulation/elements/ACEL.cpp | 24 ++--- src/simulation/elements/ACID.cpp | 8 +- src/simulation/elements/AMTR.cpp | 8 +- src/simulation/elements/ANAR.cpp | 46 ++++---- src/simulation/elements/BANG.cpp | 13 +-- src/simulation/elements/BIZR.cpp | 4 +- src/simulation/elements/BIZRG.cpp | 83 +------------- src/simulation/elements/BIZRS.cpp | 83 +------------- src/simulation/elements/BMTL.cpp | 5 +- src/simulation/elements/BREC.cpp | 17 +-- src/simulation/elements/BRMT.cpp | 17 ++- src/simulation/elements/BTRY.cpp | 8 +- src/simulation/elements/CBNW.cpp | 172 +++++++++++++++--------------- src/simulation/elements/CONV.cpp | 10 +- 14 files changed, 173 insertions(+), 325 deletions(-) diff --git a/src/simulation/elements/ACEL.cpp b/src/simulation/elements/ACEL.cpp index 143e19560..12f408c4b 100644 --- a/src/simulation/elements/ACEL.cpp +++ b/src/simulation/elements/ACEL.cpp @@ -60,18 +60,18 @@ int Element_ACEL::update(UPDATE_FUNC_ARGS) { multiplier = 1.1f; } - parts[i].tmp = 0; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) - continue; - if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) - { + parts[i].tmp = 0; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; + if (!r) + continue; + if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) + { parts[r>>8].vx *= multiplier; parts[r>>8].vy *= multiplier; parts[i].tmp = 1; diff --git a/src/simulation/elements/ACID.cpp b/src/simulation/elements/ACID.cpp index fb6cb81b6..6501ba00b 100644 --- a/src/simulation/elements/ACID.cpp +++ b/src/simulation/elements/ACID.cpp @@ -102,12 +102,12 @@ int Element_ACID::update(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; - if ((r&0xFF)==PT_ACID&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion + if ((r&0xFF)==PT_ACID && (parts[i].life>parts[r>>8].life) && parts[i].life>0)//diffusion { int temp = parts[i].life - parts[r>>8].life; - if (temp ==1) + if (temp==1) { parts[r>>8].life ++; parts[i].life --; @@ -141,4 +141,4 @@ int Element_ACID::graphics(GRAPHICS_FUNC_ARGS) } -Element_ACID::~Element_ACID() {} \ No newline at end of file +Element_ACID::~Element_ACID() {} diff --git a/src/simulation/elements/AMTR.cpp b/src/simulation/elements/AMTR.cpp index ff25bb62a..818377707 100644 --- a/src/simulation/elements/AMTR.cpp +++ b/src/simulation/elements/AMTR.cpp @@ -49,7 +49,7 @@ Element_AMTR::Element_AMTR() //#TPT-Directive ElementHeader Element_AMTR static int update(UPDATE_FUNC_ARGS) int Element_AMTR::update(UPDATE_FUNC_ARGS) { - int r, rx, ry; + int r, rx, ry, rt; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx= 0.23) - // parts[i].temp --; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxrand()%22) - { - sim->part_change_type(i,x,y,PT_HFLM); - parts[i].life = rand()%150+50; - parts[r>>8].temp = parts[i].temp = 0; - sim->pv[y/CELL][x/CELL] -= 0.5; - } - } - } - return 0; + //if (parts[i].temp >= 0.23) + // parts[i].temp --; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%22) + { + sim->part_change_type(i,x,y,PT_HFLM); + parts[i].life = rand()%150+50; + parts[r>>8].temp = parts[i].temp = 0; + sim->pv[y/CELL][x/CELL] -= 0.5; + } + } + } + return 0; } -Element_ANAR::~Element_ANAR() {} \ No newline at end of file +Element_ANAR::~Element_ANAR() {} diff --git a/src/simulation/elements/BANG.cpp b/src/simulation/elements/BANG.cpp index 8922e0ecc..9d9bfbb1b 100644 --- a/src/simulation/elements/BANG.cpp +++ b/src/simulation/elements/BANG.cpp @@ -62,11 +62,7 @@ int Element_BANG::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) - { - parts[i].tmp = 1; - } - else if ((r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH) + if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH) { parts[i].tmp = 1; } @@ -86,9 +82,9 @@ int Element_BANG::update(UPDATE_FUNC_ARGS) { parts[i].tmp = 3; } - else if(parts[i].tmp>=3) + else { - float otemp = parts[i].temp-275.13f; + float otemp = parts[i].temp-273.15f; //Explode!! sim->pv[y/CELL][x/CELL] += 0.5f; parts[i].tmp = 0; @@ -97,14 +93,13 @@ int Element_BANG::update(UPDATE_FUNC_ARGS) if(!(rand()%2)) { sim->create_part(i, x, y, PT_FIRE); - parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP); } else { sim->create_part(i, x, y, PT_SMKE); parts[i].life = rand()%50+500; - parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP); } + parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP); } else { diff --git a/src/simulation/elements/BIZR.cpp b/src/simulation/elements/BIZR.cpp index 13df996bc..f2327de98 100644 --- a/src/simulation/elements/BIZR.cpp +++ b/src/simulation/elements/BIZR.cpp @@ -82,7 +82,7 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS) } } } - if(((r = sim->photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT) + if(((r = sim->photons[y][x])&0xFF)==PT_PHOT) { sim->part_change_type(r>>8, x, y, PT_ELEC); parts[r>>8].ctype = 0; @@ -121,4 +121,4 @@ int Element_BIZR::graphics(GRAPHICS_FUNC_ARGS) } -Element_BIZR::~Element_BIZR() {} \ No newline at end of file +Element_BIZR::~Element_BIZR() {} diff --git a/src/simulation/elements/BIZRG.cpp b/src/simulation/elements/BIZRG.cpp index 1e5f27ffe..48856bd70 100644 --- a/src/simulation/elements/BIZRG.cpp +++ b/src/simulation/elements/BIZRG.cpp @@ -42,83 +42,8 @@ Element_BIZRG::Element_BIZRG() HighTemperature = 100.0f; HighTemperatureTransition = PT_BIZR; - Update = &Element_BIZRG::update; - Graphics = &Element_BIZRG::graphics; + Update = &Element_BIZR::update; + Graphics = &Element_BIZR::graphics; } - -//#TPT-Directive ElementHeader Element_BIZRG static int update(UPDATE_FUNC_ARGS) -int Element_BIZRG::update(UPDATE_FUNC_ARGS) - { - int r, rx, ry, nr, ng, nb, na; - float tr, tg, tb, ta, mr, mg, mb, ma; - float blend; - if(parts[i].dcolour){ - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].dcolour>>16)&0xFF; - tg = (parts[r>>8].dcolour>>8)&0xFF; - tb = (parts[r>>8].dcolour)&0xFF; - ta = (parts[r>>8].dcolour>>24)&0xFF; - - mr = (parts[i].dcolour>>16)&0xFF; - mg = (parts[i].dcolour>>8)&0xFF; - mb = (parts[i].dcolour)&0xFF; - ma = (parts[i].dcolour>>24)&0xFF; - - nr = (tr*blend) + (mr*(1-blend)); - ng = (tg*blend) + (mg*(1-blend)); - nb = (tb*blend) + (mb*(1-blend)); - na = (ta*blend) + (ma*(1-blend)); - - parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; - } - } - } - if(((r = sim->photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT) - { - sim->part_change_type(r>>8, x, y, PT_ELEC); - parts[r>>8].ctype = 0; - } - return 0; -} - - -//#TPT-Directive ElementHeader Element_BIZRG static int graphics(GRAPHICS_FUNC_ARGS) -int Element_BIZRG::graphics(GRAPHICS_FUNC_ARGS) - //BIZR, BIZRG, BIZRS -{ - int x = 0; - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - if(fabs(cpart->vx)+fabs(cpart->vy)>0) - { - *firea = 255; - *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); - *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); - *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); - *pixel_mode |= FIRE_ADD; - } - return 0; -} - - -Element_BIZRG::~Element_BIZRG() {} \ No newline at end of file +//BIZRG update is in BIZR.cpp +Element_BIZRG::~Element_BIZRG() {} diff --git a/src/simulation/elements/BIZRS.cpp b/src/simulation/elements/BIZRS.cpp index 439a72355..fe2a8cf55 100644 --- a/src/simulation/elements/BIZRS.cpp +++ b/src/simulation/elements/BIZRS.cpp @@ -42,83 +42,8 @@ Element_BIZRS::Element_BIZRS() HighTemperature = ITH; HighTemperatureTransition = NT; - Update = &Element_BIZRS::update; - Graphics = &Element_BIZRS::graphics; + Update = &Element_BIZR::update; + Graphics = &Element_BIZR::graphics; } - -//#TPT-Directive ElementHeader Element_BIZRS static int update(UPDATE_FUNC_ARGS) -int Element_BIZRS::update(UPDATE_FUNC_ARGS) - { - int r, rx, ry, nr, ng, nb, na; - float tr, tg, tb, ta, mr, mg, mb, ma; - float blend; - if(parts[i].dcolour){ - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].dcolour>>16)&0xFF; - tg = (parts[r>>8].dcolour>>8)&0xFF; - tb = (parts[r>>8].dcolour)&0xFF; - ta = (parts[r>>8].dcolour>>24)&0xFF; - - mr = (parts[i].dcolour>>16)&0xFF; - mg = (parts[i].dcolour>>8)&0xFF; - mb = (parts[i].dcolour)&0xFF; - ma = (parts[i].dcolour>>24)&0xFF; - - nr = (tr*blend) + (mr*(1-blend)); - ng = (tg*blend) + (mg*(1-blend)); - nb = (tb*blend) + (mb*(1-blend)); - na = (ta*blend) + (ma*(1-blend)); - - parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; - } - } - } - if(((r = sim->photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT) - { - sim->part_change_type(r>>8, x, y, PT_ELEC); - parts[r>>8].ctype = 0; - } - return 0; -} - - -//#TPT-Directive ElementHeader Element_BIZRS static int graphics(GRAPHICS_FUNC_ARGS) -int Element_BIZRS::graphics(GRAPHICS_FUNC_ARGS) - //BIZR, BIZRG, BIZRS -{ - int x = 0; - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - if(fabs(cpart->vx)+fabs(cpart->vy)>0) - { - *firea = 255; - *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); - *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); - *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); - *pixel_mode |= FIRE_ADD; - } - return 0; -} - - -Element_BIZRS::~Element_BIZRS() {} \ No newline at end of file +//BIZRS update is in BIZR.cpp +Element_BIZRS::~Element_BIZRS() {} diff --git a/src/simulation/elements/BMTL.cpp b/src/simulation/elements/BMTL.cpp index adc5289bc..26c086ba5 100644 --- a/src/simulation/elements/BMTL.cpp +++ b/src/simulation/elements/BMTL.cpp @@ -60,8 +60,7 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = parts[r>>8].type; - if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100))) + if (((r&0xFF)==PT_METL || (r&0xFF)==PT_IRON) && 1>(rand()/(RAND_MAX/100))) { sim->part_change_type(r>>8,x+rx,y+ry,PT_BMTL); parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; @@ -77,4 +76,4 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS) } -Element_BMTL::~Element_BMTL() {} \ No newline at end of file +Element_BMTL::~Element_BMTL() {} diff --git a/src/simulation/elements/BREC.cpp b/src/simulation/elements/BREC.cpp index e260a7cf4..f5ae4a1da 100644 --- a/src/simulation/elements/BREC.cpp +++ b/src/simulation/elements/BREC.cpp @@ -50,13 +50,18 @@ Element_BREC::Element_BREC() int Element_BREC::update(UPDATE_FUNC_ARGS) { int np; - if (1>rand()%200 && (sim->pv[y/CELL][x/CELL] > 30.0f) && parts[i].temp>9000 && parts[i].life>0) + if (parts[i].life) { - sim->part_change_type(i, x ,y ,PT_EXOT); - parts[i].life = 1000; - } - if ((sim->pv[y/CELL][x/CELL] > 10.0f) && (parts[i].life>0)) { - parts[i].temp = parts[i].temp + (sim->pv[y/CELL][x/CELL])/8; + if (sim->pv[y/CELL][x/CELL]>10.0f) + { + if (parts[i].temp>9000 && sim->pv[y/CELL][x/CELL]>30.0f && 1>rand()%200) + { + sim->part_change_type(i, x ,y ,PT_EXOT); + parts[i].life = 1000; + } + parts[i].temp = parts[i].temp + (sim->pv[y/CELL][x/CELL])/8; + } + } return 0; } diff --git a/src/simulation/elements/BRMT.cpp b/src/simulation/elements/BRMT.cpp index 55eb24377..0e366300a 100644 --- a/src/simulation/elements/BRMT.cpp +++ b/src/simulation/elements/BRMT.cpp @@ -50,8 +50,11 @@ Element_BRMT::Element_BRMT() int Element_BRMT::update(UPDATE_FUNC_ARGS) { int r, rx, ry, rt, tempFactor; - if (parts[i].temp > (250.0f+273.15f)) + if (parts[i].temp > 523.15f)//250.0f+273.15f { + tempFactor = 1000 - ((523.15f-parts[i].temp)*2); + if(tempFactor < 2) + tempFactor = 2; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx>8].type; - tempFactor = 1000 - (((250.0f+273.15f)-parts[i].temp)*2); - if(tempFactor < 2) - tempFactor = 2; - if ((rt==PT_BREC) && 1 > (rand()%tempFactor)) + if ((r&0xFF)==PT_BREC && 1>(rand()%tempFactor)) { if(rand()%2) { sim->create_part(r>>8, x+rx, y+ry, PT_THRM); } else - { sim->create_part(i, x, y, PT_THRM); - } - return 1; + sim->create_part(i, x, y, PT_THRM); //part_change_type(r>>8,x+rx,y+ry,PT_BMTL); //parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; } @@ -82,4 +79,4 @@ int Element_BRMT::update(UPDATE_FUNC_ARGS) } -Element_BRMT::~Element_BRMT() {} \ No newline at end of file +Element_BRMT::~Element_BRMT() {} diff --git a/src/simulation/elements/BTRY.cpp b/src/simulation/elements/BTRY.cpp index efbb3d2e4..4f1e81015 100644 --- a/src/simulation/elements/BTRY.cpp +++ b/src/simulation/elements/BTRY.cpp @@ -52,15 +52,15 @@ int Element_BTRY::update(UPDATE_FUNC_ARGS) int r, rx, ry, rt; for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx=0 && y+ry>0 && x+rx>8].type; + rt = (r&0xFF); if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL) { - if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(rx)+abs(ry) < 4) + if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0) { parts[r>>8].life = 4; parts[r>>8].ctype = rt; @@ -72,4 +72,4 @@ int Element_BTRY::update(UPDATE_FUNC_ARGS) } -Element_BTRY::~Element_BTRY() {} \ No newline at end of file +Element_BTRY::~Element_BTRY() {} diff --git a/src/simulation/elements/CBNW.cpp b/src/simulation/elements/CBNW.cpp index 433175061..87240d8cd 100644 --- a/src/simulation/elements/CBNW.cpp +++ b/src/simulation/elements/CBNW.cpp @@ -49,92 +49,90 @@ Element_CBNW::Element_CBNW() //#TPT-Directive ElementHeader Element_CBNW static int update(UPDATE_FUNC_ARGS) int Element_CBNW::update(UPDATE_FUNC_ARGS) { - int r, rx, ry, oldt; - oldt = parts[i].tmp; - if (sim->pv[y/CELL][x/CELL]<=3) - { - if(20>(rand()%80000)) - { - sim->part_change_type(i,x,y,PT_CO2); - parts[i].ctype = 5; - sim->pv[y/CELL][x/CELL] += 0.5f; - } - else if(sim->pv[y/CELL][x/CELL]<=-0.5) - { - sim->part_change_type(i,x,y,PT_CO2); - parts[i].ctype = 5; - sim->pv[y/CELL][x/CELL] += 0.5f; - } - } - if (parts[i].tmp>0) - parts[i].tmp--; - if(!(rand()%200)) - { - parts[i].tmp2 = rand()%40; - } else if(parts[i].tmp2!=20) { - parts[i].tmp2 -= (parts[i].tmp2>20)?1:-1; - } - if(oldt==1) - { - //Explode - if(rand()%4) - { - sim->part_change_type(i,x,y,PT_CO2); - parts[i].ctype = 5; - sim->pv[y/CELL][x/CELL] += 0.2f; - } - } - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxelements[r&0xFF].Properties&TYPE_PART) && parts[i].tmp == 0 && 1>(rand()%250)) - { - //Start explode - parts[i].tmp = rand()%25;//(rand()%100)+50; - } - else if((sim->elements[r&0xFF].Properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%20000)) - { - if(rand()%2) - { - sim->part_change_type(i,x,y,PT_CO2); - parts[i].ctype = 5; - sim->pv[y/CELL][x/CELL] += 0.2f; - } - } - if ((r&0xFF)==PT_CBNW) - { - if(!parts[i].tmp && parts[r>>8].tmp) - { - parts[i].tmp = parts[r>>8].tmp; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[i].tmp--; - } - else if(parts[i].tmp && !parts[r>>8].tmp) - { - parts[r>>8].tmp = parts[i].tmp; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[r>>8].tmp++; - } - } - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) - { - sim->part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - parts[i].ctype = PT_WATR; - } - if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ - sim->kill_part(r>>8); - if(1>(rand()%150)){ - sim->kill_part(i); - return 1; - } - } - } - return 0; + int r, rx, ry; + if (sim->pv[y/CELL][x/CELL]<=3) + { + if(sim->pv[y/CELL][x/CELL]<=-0.5) + { + sim->part_change_type(i,x,y,PT_CO2); + parts[i].ctype = 5; + sim->pv[y/CELL][x/CELL] += 0.5f; + } + else if(1>(rand()%4000)) + { + sim->part_change_type(i,x,y,PT_CO2); + parts[i].ctype = 5; + sim->pv[y/CELL][x/CELL] += 0.5f; + } + } + if (parts[i].tmp2!=20) { + parts[i].tmp2 -= (parts[i].tmp2>20)?1:-1; + } + else if(!(rand()%200)) + { + parts[i].tmp2 = rand()%40; + } + + if(parts[i].tmp>0) + { + //Explode + if(parts[i].tmp==1 && rand()%4) + { + sim->part_change_type(i,x,y,PT_CO2); + parts[i].ctype = 5; + sim->pv[y/CELL][x/CELL] += 0.2f; + } + parts[i].tmp--; + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxelements[r&0xFF].Properties&TYPE_PART) && parts[i].tmp == 0 && 1>(rand()%250)) + { + //Start explode + parts[i].tmp = rand()%25;//(rand()%100)+50; + } + else if((r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && (sim->elements[r&0xFF].Properties&TYPE_SOLID) && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%40000)) + { + sim->part_change_type(i,x,y,PT_CO2); + parts[i].ctype = 5; + sim->pv[y/CELL][x/CELL] += 0.2f; + + } + if ((r&0xFF)==PT_CBNW) + { + if(!parts[i].tmp && parts[r>>8].tmp) + { + parts[i].tmp = parts[r>>8].tmp; + if((r>>8)>i) //If the other particle hasn't been life updated + parts[i].tmp--; + } + else if(parts[i].tmp && !parts[r>>8].tmp) + { + parts[r>>8].tmp = parts[i].tmp; + if((r>>8)>i) //If the other particle hasn't been life updated + parts[r>>8].tmp++; + } + } + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) + { + sim->part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + parts[i].ctype = PT_WATR; + } + if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ + sim->kill_part(r>>8); + if(1>(rand()%150)){ + sim->kill_part(i); + return 1; + } + } + } + return 0; } @@ -150,4 +148,4 @@ int Element_CBNW::graphics(GRAPHICS_FUNC_ARGS) } -Element_CBNW::~Element_CBNW() {} \ No newline at end of file +Element_CBNW::~Element_CBNW() {} diff --git a/src/simulation/elements/CONV.cpp b/src/simulation/elements/CONV.cpp index 65775163b..8f2f0c657 100644 --- a/src/simulation/elements/CONV.cpp +++ b/src/simulation/elements/CONV.cpp @@ -50,7 +50,7 @@ Element_CONV::Element_CONV() int Element_CONV::update(UPDATE_FUNC_ARGS) { int r, rx, ry; - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) + if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || parts[i].ctype==PT_CONV || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) { for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) @@ -72,7 +72,9 @@ int Element_CONV::update(UPDATE_FUNC_ARGS) } } } - else if(parts[i].ctype>0 && parts[i].ctypeelements[parts[i].ctype].Enabled && parts[i].ctype!=PT_CONV) { + else + { + bool life = parts[i].ctype==PT_LIFE; for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>=0 && x+rxcreate_part(r>>8, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); + if (life) sim->create_part(r>>8, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); else sim->create_part(r>>8, x+rx, y+ry, parts[i].ctype); } } @@ -93,4 +95,4 @@ int Element_CONV::update(UPDATE_FUNC_ARGS) } -Element_CONV::~Element_CONV() {} \ No newline at end of file +Element_CONV::~Element_CONV() {}