Small optimizations number 2.

This commit is contained in:
cracker64 2013-02-27 00:11:23 -05:00
parent a62467c74e
commit 27e3e12518
19 changed files with 211 additions and 272 deletions

View File

@ -72,11 +72,11 @@ int Element_CLST::update(UPDATE_FUNC_ARGS)
{
if(parts[i].temp <195)
cxy = 0.05;
if(parts[i].temp >= 195 && parts[i].temp <295)
else if(parts[i].temp >= 195 && parts[i].temp <295)
cxy = 0.015;
if(parts[i].temp >= 295 && parts[i].temp <350)
else if(parts[i].temp >= 295 && parts[i].temp <350)
cxy = 0.01;
if(parts[i].temp >= 350)
else
cxy = 0.005;
parts[i].vx += cxy*rx;
parts[i].vy += cxy*ry;//These two can be set not to calculate over 350 later. They do virtually nothing over 0.005.

View File

@ -55,47 +55,48 @@ int Element_CO2::update(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 (parts[i].ctype==5 && 20>(rand()%40000))
{
if (sim->create_part(-1, x+rx, y+ry, PT_WATR)>=0)
parts[i].ctype = 0;
}
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_FIRE){
sim->kill_part(r>>8);
if(1>(rand()%150)){
if(!(rand()%150)){
sim->kill_part(i);
return 1;
}
}
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%250))
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%250))
{
sim->part_change_type(r>>8, x+rx, y+ry, 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
sim->create_part(i, x, y, PT_WATR);
else
{
sim->kill_part(i);
return 1;
}
}
}
if (parts[i].ctype==5 && !(rand()%83))
{
if (sim->create_part(-1, x+rx, y+ry, PT_WATR)>=0)
parts[i].ctype = 0;
}
if (parts[i].temp > 9773.15 && sim->pv[y/CELL][x/CELL] > 200.0f)
{
if (rand()%5 < 1)
if (!(rand()%5))
{
int j;
sim->create_part(i,x,y,PT_O2);
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT);
if (j != -1)
parts[j].temp = 15000;
parts[j].temp = MAX_TEMP;
if (!(rand()%50))
{
j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC);
if (j != -1)
parts[j].temp = 15000;
parts[j].temp = MAX_TEMP;
}
parts[i].temp = 15000;
parts[i].temp = MAX_TEMP;
sim->pv[y/CELL][x/CELL] += 100;
}
}

View File

@ -60,19 +60,15 @@ int Element_DEST::update(UPDATE_FUNC_ARGS)
if (parts[i].life<=0 || parts[i].life>37)
{
parts[i].life=30+rand()%20;
parts[i].temp+=20000;
sim->pv[y/CELL][x/CELL]+=60.0f;
}
parts[i].temp+=10000;
if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT)
{
sim->pv[y/CELL][x/CELL]+=20.0f;
parts[i].temp+=18000;
if (rand()%2==0)
if (rand()%2)
{
float orig_temp = parts[r>>8].temp;
sim->create_part(r>>8, x+rx, y+ry, PT_NEUT);
parts[r>>8].temp = restrict_flt(orig_temp+40000.0f, MIN_TEMP, MAX_TEMP);
parts[r>>8].temp = MAX_TEMP;
sim->pv[y/CELL][x/CELL] += 10.0f;
parts[i].life-=4;
}
@ -81,23 +77,17 @@ int Element_DEST::update(UPDATE_FUNC_ARGS)
{
sim->create_part(r>>8, x+rx, y+ry, PT_PLSM);
}
else if (rand()%3==0)
else if (!rand()%3)
{
sim->kill_part(r>>8);
parts[i].life -= 4*((sim->elements[r&0xFF].Properties&TYPE_SOLID)?3:1);
if (parts[i].life<=0)
parts[i].life=1;
parts[i].temp+=10000;
}
else
{
if (sim->elements[r&0xFF].HeatConduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP);
}
topv=sim->pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900;
if (topv>40.0f)
topv=40.0f;
sim->pv[y/CELL][x/CELL]+=40.0f+topv;
parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP);
else if (sim->elements[r&0xFF].HeatConduct)
parts[r>>8].temp = MAX_TEMP;
parts[i].temp=MAX_TEMP;
sim->pv[y/CELL][x/CELL]+=80.0f;
return 0;
}

View File

@ -53,13 +53,8 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS)
oldl = parts[i].life;
if (parts[i].life>0)
parts[i].life--;
//if (parts[i].life==1)
//{
if (parts[i].temp>=MAX_TEMP+273.15f)
parts[i].temp = MAX_TEMP+273.15f;
if (parts[i].temp<= 1.0f+273.15f)
parts[i].temp = 1.0f+273.15f;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))

View File

@ -85,7 +85,7 @@ int Element_DMG::update(UPDATE_FUNC_ARGS)
sim->pv[(y+nxj)/CELL][(x+nxi)/CELL] += 1.0f;
t = parts[rr>>8].type;
t = rr&0xFF;
if(t && sim->elements[t].HighPressureTransition>-1 && sim->elements[t].HighPressureTransition<PT_NUM)
sim->part_change_type(rr>>8, x+nxi, y+nxj, sim->elements[t].HighPressureTransition);
else if(t == PT_BMTL)

View File

@ -49,7 +49,7 @@ Element_DSTW::Element_DSTW()
//#TPT-Directive ElementHeader Element_DSTW static int update(UPDATE_FUNC_ARGS)
int Element_DSTW::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
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<XRES && y+ry<YRES && (rx || ry))
@ -57,29 +57,30 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%250))
rt = r&0xFF;
if (rt==PT_SALT && !(rand()%250))
{
sim->part_change_type(i,x,y,PT_SLTW);
// on average, convert 3 DSTW to SLTW before SALT turns into SLTW
if (rand()%3==0)
if (!rand()%3)
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
}
if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && 1>(rand()%500))
if ((rt==PT_WATR||rt==PT_SLTW) && !(rand()%500))
{
sim->part_change_type(i,x,y,PT_WATR);
}
if ((r&0xFF)==PT_SLTW && 1>(rand()%10000))
if (rt==PT_SLTW && !(rand()%10000))
{
sim->part_change_type(i,x,y,PT_SLTW);
}
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>12.0f) && 1>(rand()%500))
if ((rt==PT_RBDM||rt==PT_LRBD) && (sim->legacy_enable||parts[i].temp>12.0f) && !(rand()%500))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
}
if ((r&0xFF)==PT_FIRE){
if (rt==PT_FIRE){
sim->kill_part(r>>8);
if(1>(rand()%150)){
if(!(rand()%150)){
sim->kill_part(i);
return 1;
}

View File

@ -61,7 +61,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = parts[r>>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)
@ -82,7 +82,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx];
if(!r)
continue;
if (parts[r>>8].type == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[r>>8].ctype || !parts[i].tmp))
if ((r&0xFF) == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[r>>8].ctype || !parts[i].tmp))
parts[i].life = 1;
}
return 0;

View File

@ -53,7 +53,7 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
float rr, rrr;
parts[i].pavg[0] = x;
parts[i].pavg[1] = y;
if(pmap[y][x]==PT_GLOW)
if(pmap[y][x]==PT_GLOW)//move into movement code
{
sim->part_change_type(i, x, y, PT_PHOT);
}
@ -65,7 +65,8 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_GLAS)
rt = r&0xFF;
if (rt==PT_GLAS)
{
for (rrx=-1; rrx<=1; rrx++)
{
@ -95,30 +96,25 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
sim->kill_part(i);
return 1;
}
if ((r&0xFF)==PT_LCRY)
if (rt==PT_LCRY)
{
parts[r>>8].tmp2 = 5+rand()%5;
}
if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_CBNW)
{
if(rand()<RAND_MAX/3)
if (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW || rt==PT_CBNW)
{
if(!(rand()%3))
sim->create_part(r>>8, x+rx, y+ry, PT_O2);
return 1;
}
else
{
sim->create_part(r>>8, x+rx, y+ry, PT_H2);
return 1;
}
}
if ((r&0xFF)==PT_NEUT && !pmap[y+ry][x+rx])
if (rt==PT_NEUT)
{
sim->part_change_type(r>>8, x+rx, y+ry, PT_H2);
parts[r>>8].life = 0;
parts[r>>8].ctype = 0;
}
if ((r&0xFF)==PT_DEUT)
if (rt==PT_DEUT)
{
if(parts[r>>8].life < 6000)
parts[r>>8].life += 1;
@ -126,12 +122,12 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
sim->kill_part(i);
return 1;
}
if ((r&0xFF)==PT_EXOT)
if (rt==PT_EXOT)
{
parts[r>>8].tmp2 += 5;
parts[r>>8].life = 1000;
}
if ((sim->elements[r&0xFF].Properties & PROP_CONDUCTS) && ((r&0xFF)!=PT_NBLE||parts[i].temp<2273.15))
if ((sim->elements[rt].Properties & PROP_CONDUCTS) && (rt!=PT_NBLE||parts[i].temp<2273.15))
{
sim->create_part(-1, x+rx, y+ry, PT_SPRK);
sim->kill_part(i);

View File

@ -60,13 +60,10 @@ int Element_EMP::update(UPDATE_FUNC_ARGS)
if (!r)
continue;
if ((r&0xFF)==PT_SPRK && parts[r>>8].life>0 && parts[r>>8].life<4)
{
ok=1;
break;
goto ok;
}
}
if (!ok)
return 0;
ok:
parts[i].life=220;
sim->emp_decor += 3;
if (sim->emp_decor > 40)
@ -83,11 +80,11 @@ int Element_EMP::update(UPDATE_FUNC_ARGS)
parts[r].ctype==PT_NTCT || parts[r].ctype==PT_INST || parts[r].ctype==PT_SWCH) || t==PT_WIRE || t==PT_SWCH)
{
is_elec=1;
if (sim->elements[parts[r].type].HeatConduct && rand()%100==0)
if (sim->elements[parts[r].type].HeatConduct && !(rand()%100))
parts[r].temp = restrict_flt(parts[r].temp+3000.0f, MIN_TEMP, MAX_TEMP);
if (rand()%80==0)
if (!(rand()%80))
sim->part_change_type(r, rx, ry, PT_BREC);
else if (rand()%120==0)
else if (!(rand()%120))
sim->part_change_type(r, rx, ry, PT_NTCT);
}
@ -98,55 +95,49 @@ int Element_EMP::update(UPDATE_FUNC_ARGS)
n = pmap[ry+ny][rx+nx];
if (!n)
continue;
/*if ((n&0xFF)==PT_BTRY && rand()%60==0)
{
part_change_type(n>>8, rx+nx, ry+ny, PT_PLSM);
parts[n>>8].life=rand()%100+70;
parts[n>>8].temp+=3000;
}*/
nt = n&0xFF;
//Some elements should only be affected by wire/swch, or by a spark on inst/semiconductor
//So not affected by spark on metl, watr etc
if (is_elec)
{
if (((n&0xFF)==PT_METL || (n&0xFF)==PT_BMTL) && rand()%280==0)
if ((nt==PT_METL || nt==PT_BMTL) && !(rand()%280))
{
parts[n>>8].temp = restrict_flt(parts[n>>8].temp+3000.0f, MIN_TEMP, MAX_TEMP);
}
if ((n&0xFF)==PT_BMTL && rand()%160==0)
if (nt==PT_BMTL && !(rand()%160))
{
sim->part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL);//TODO: Redundant, was this meant to be BRMT or something?
sim->part_change_type(n>>8, rx+nx, ry+ny, PT_BRMT);
parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP);
}
if ((n&0xFF)==PT_METL && rand()%300==0)
if (nt==PT_METL && !(rand()%300))
{
sim->part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL);
}
if ((n&0xFF)==PT_WIFI && rand()%8==0)
if (nt==PT_WIFI && !(rand()%8))
{
//Randomise channel
parts[n>>8].temp = rand()%MAX_TEMP;
}
if ((n&0xFF)==PT_WIFI && rand()%16==0)
if (nt==PT_WIFI && !(rand()%16))
{
sim->create_part(n>>8, rx+nx, ry+ny, PT_BREC);
parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP);
}
}
if ((n&0xFF)==PT_SWCH && rand()%100==0)
if (nt==PT_SWCH && !(rand()%100))
{
sim->part_change_type(n>>8, rx+nx, ry+ny, PT_BREC);
}
if ((n&0xFF)==PT_SWCH && rand()%100==0)
if (nt==PT_SWCH && !(rand()%100))
{
parts[n>>8].temp = restrict_flt(parts[n>>8].temp+2000.0f, MIN_TEMP, MAX_TEMP);
}
if ((n&0xFF)==PT_ARAY && rand()%60==0)
if (nt==PT_ARAY && !(rand()%60))
{
sim->create_part(n>>8, rx+nx, ry+ny, PT_BREC);
parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP);
}
if (t==PT_DLAY && rand()%70==0)
if (nt==PT_DLAY && !(rand()%70))
{
//Randomise delay
parts[n>>8].temp = (rand()%256) + 273.15f;

View File

@ -48,42 +48,36 @@ Element_EXOT::Element_EXOT()
//#TPT-Directive ElementHeader Element_EXOT static int update(UPDATE_FUNC_ARGS)
int Element_EXOT::update(UPDATE_FUNC_ARGS) {
int r, rt, rx, ry, nb, rrx, rry, trade, tym, t;
t = parts[i].type;
int r, rt, rx, ry, nb, rrx, rry, trade, tym;
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry)) {
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF) == PT_WARP)
rt = r&0xFF;
if (rt == PT_WARP)
{
if (parts[r>>8].tmp2>2000)
if (1>rand()%100)
if (parts[r>>8].tmp2>2000 && !(rand()%100))
{
parts[i].tmp2 += 100;
}
}
else if ((r&0xFF) == PT_EXOT && parts[r>>8].life == 1500 && 1>rand()%1000)
else if (rt == PT_EXOT && parts[r>>8].life == 1500 && !(rand()%1000))
parts[i].life = 1500;
else if ((r&0xFF) == PT_LAVA)
else if (rt == PT_LAVA)
{
if (parts[r>>8].ctype == PT_TTAN && 1>rand()%10)
if (parts[r>>8].ctype == PT_TTAN && !(rand()%10))
{
parts[r>>8].ctype = PT_VIBR;
sim->kill_part(i);
return 1;
}
/*else if (parts[r>>8].ctype == PT_VIBR && 1>rand()%1000)
{
sim->kill_part(i);
return 1;
}*/
}
if ((parts[i].tmp>245) && (parts[i].life>1000))
if ((r&0xFF)!=PT_EXOT && (r&0xFF)!=PT_BREC && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_WARP && (r&0xFF)!=PT_NEUT)
if (rt!=PT_EXOT && rt!=PT_BREC && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PRTI && rt!=PT_PRTO && rt!=PT_PCLN && rt!=PT_PHOT && rt!=PT_VOID && rt!=PT_NBHL && rt!=PT_WARP && rt!=PT_NEUT)
{
sim->create_part(i, x, y, parts[r>>8].type);
sim->create_part(i, x, y, rt);
return 0;
}
}
@ -121,7 +115,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==t && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion
if ((r&0xFF)==PT_EXOT && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion
{
tym = parts[i].tmp2 - parts[r>>8].tmp2;
if (tym ==1)

View File

@ -48,7 +48,6 @@ Element_FIGH::Element_FIGH()
//#TPT-Directive ElementHeader Element_FIGH static int update(UPDATE_FUNC_ARGS)
int Element_FIGH::update(UPDATE_FUNC_ARGS)
{
playerst* figh = &sim->fighters[(unsigned char)parts[i].tmp];
@ -57,9 +56,9 @@ int Element_FIGH::update(UPDATE_FUNC_ARGS)
parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man
//Set target cords
if (sim->player.spwn && sim->player2.spwn)
if (sim->player2.spwn)
{
if ((pow((float)sim->player.legs[2]-x, 2) + pow((float)sim->player.legs[3]-y, 2))<=
if (sim->player.spwn && (pow((float)sim->player.legs[2]-x, 2) + pow((float)sim->player.legs[3]-y, 2))<=
(pow((float)sim->player2.legs[2]-x, 2) + pow((float)sim->player2.legs[3]-y, 2)))
{
tarx = (unsigned int)sim->player.legs[2];
@ -72,21 +71,12 @@ int Element_FIGH::update(UPDATE_FUNC_ARGS)
}
parts[i].tmp2 = 1;
}
else
{
if (sim->player.spwn)
else if (sim->player.spwn)
{
tarx = (unsigned int)sim->player.legs[2];
tary = (unsigned int)sim->player.legs[3];
parts[i].tmp2 = 1;
}
if (sim->player2.spwn)
{
tarx = (unsigned int)sim->player2.legs[2];
tary = (unsigned int)sim->player2.legs[3];
parts[i].tmp2 = 1;
}
}
switch (parts[i].tmp2)
{
@ -98,8 +88,7 @@ int Element_FIGH::update(UPDATE_FUNC_ARGS)
|| sim->elements[figh->elem].Temperature>=323 || sim->elements[figh->elem].Temperature<=243)
figh->comm = (int)figh->comm | 0x08;
}
else
if (tarx<x)
else if (tarx<x)
{
if(!(sim->eval_move(PT_FIGH, figh->legs[4]-10, figh->legs[5]+6, NULL)
&& sim->eval_move(PT_FIGH, figh->legs[4]-10, figh->legs[5]+3, NULL)))

View File

@ -52,30 +52,26 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
int r, rx, ry, rt, t = parts[i].type;
if (t==PT_PLSM && parts[i].ctype == PT_NBLE && parts[i].life <=1)
{
t = PT_NBLE;
sim->part_change_type(i,x,y,t);
sim->part_change_type(i,x,y,PT_NBLE);
parts[i].life = 0;
}
if (t==PT_FIRE && parts[i].life <=1)
{
if ((parts[i].tmp&0x3) == 3){
t = PT_DSTW;
sim->part_change_type(i,x,y,t);
sim->part_change_type(i,x,y,PT_DSTW);
parts[i].life = 0;
parts[i].ctype = PT_FIRE;
}
else if (parts[i].temp<625)
{
t = PT_SMKE;
sim->part_change_type(i,x,y,t);
sim->part_change_type(i,x,y,PT_SMKE);
parts[i].life = rand()%20+250;
}
}
if (t==PT_PLSM && parts[i].life <=1)
{
if ((parts[i].tmp&0x3) == 3){
t = PT_DSTW;
sim->part_change_type(i,x,y,t);
sim->part_change_type(i,x,y,PT_DSTW);
parts[i].life = 0;
parts[i].ctype = PT_FIRE;
}
@ -89,7 +85,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
continue;
if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM)
continue;
rt = parts[r>>8].type;
rt = r&0xFF;
if ((surround_space || sim->elements[rt].Explosive) &&
(t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) &&
(t!=PT_PHOT || rt!=PT_INSL) &&
@ -123,12 +119,11 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
rt = r&0xFF;
lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL];
if (lpv < 1) lpv = 1;
if (t!=PT_SPRK && sim->elements[rt].Meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&
sim->elements[rt].Meltable*lpv>(rand()%1000))
if (t!=PT_SPRK && sim->elements[rt].Meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&sim->elements[rt].Meltable*lpv>(rand()%1000))
{
if (t!=PT_LAVA || parts[i].life>0)
{
parts[r>>8].ctype = (rt==PT_BRMT)?PT_BMTL:parts[r>>8].type;
parts[r>>8].ctype = (rt==PT_BRMT)?PT_BMTL:(r&0xFF);
parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype;
sim->part_change_type(r>>8,x+rx,y+ry,PT_LAVA);
parts[r>>8].life = rand()%120+240;
@ -136,9 +131,8 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
else
{
parts[i].life = 0;
t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
parts[i].ctype = PT_NONE;//rt;
sim->part_change_type(i,x,y,t);
sim->part_change_type(i,x,y,(parts[i].ctype)?parts[i].ctype:PT_STNE);
return 1;
}
}
@ -153,8 +147,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
if (t==PT_LAVA)
{
parts[i].life = 0;
t = parts[i].type = PT_STNE;
sim->part_change_type(i,x,y,t);
sim->part_change_type(i,x,y,PT_STNE);
}
}
if (t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW))
@ -168,9 +161,8 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
if (t==PT_LAVA)
{
parts[i].life = 0;
t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE;
parts[i].ctype = PT_NONE;
sim->part_change_type(i,x,y,t);
sim->part_change_type(i,x,y,(parts[i].ctype)?parts[i].ctype:PT_STNE);
}
}
}

View File

@ -62,7 +62,7 @@ int Element_FIRW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = parts[r>>8].type;
rt = r&0xFF;
if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
{
float gx, gy, multiplier;
@ -89,7 +89,7 @@ int Element_FIRW::update(UPDATE_FUNC_ARGS)
parts[i].flags &= ~FLAG_STAGNANT;
}
}
else if (parts[i].tmp>=2)
else //if (parts[i].tmp>=2)
{
float angle, magnitude;
int caddress = (rand()%200)*3;

View File

@ -57,7 +57,7 @@ int Element_FOG::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (sim->elements[r&0xFF].State==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN?
if (sim->elements[r&0xFF].State==ST_SOLID && !(rand()%10) && parts[i].life==0 && !((r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN?
{
sim->part_change_type(i,x,y,PT_RIME);
}

View File

@ -57,18 +57,12 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&5>rand()%70)
if ((r&0xFF)==PT_WATR && !(rand()%14))
{
sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW);
}
}
if (parts[i].life==0&&13>rand()%2500)
{
sim->part_change_type(i,x,y,PT_ICEI);
parts[i].ctype=PT_FRZW;
parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP);
}
else if ((100-(parts[i].life))>rand()%50000)
if ((parts[i].life==0 && !(rand()%192)) || (100-(parts[i].life))>rand()%50000 )
{
sim->part_change_type(i,x,y,PT_ICEI);
parts[i].ctype=PT_FRZW;

View File

@ -57,18 +57,15 @@ int Element_FRZZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&5>rand()%100)
if ((r&0xFF)==PT_WATR && !(rand()%20))
{
sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW);
parts[r>>8].life = 100;
parts[i].type = PT_NONE;
}
}
if (parts[i].type==PT_NONE) {
sim->kill_part(i);
return 1;
}
}
return 0;
}

View File

@ -55,11 +55,12 @@ int Element_FSEP::update(UPDATE_FUNC_ARGS)
if (r!=-1)
parts[r].life = 50;
return 1;
} else if (parts[i].life < 40) {
}
else if (parts[i].life < 40) {
parts[i].life--;
if ((rand()%10)==0) {
r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM);
if (r!=-1)
if (!(rand()%10)) {
r = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_PLSM);
if (r>-1)
parts[r].life = 50;
}
}
@ -71,14 +72,12 @@ int Element_FSEP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && 1>(rand()%15))
if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && parts[i].life>40 && !(rand()%15))
{
if (parts[i].life>40) {
parts[i].life = 39;
}
}
}
}
return 0;
}

View File

@ -52,25 +52,26 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS)
int r, rx, ry;
if (parts[i].life<=0) {
r = sim->create_part(i, x, y, PT_PLSM);
if (r!=-1)
if (r>-1)
parts[r].life = 50;
return 1;
} else if (parts[i].life < 40) {
parts[i].life--;
if ((rand()%100)==0) {
r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM);
if (r!=-1)
if (!(rand()%100)) {
r = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_PLSM);
if (r>-1)
parts[r].life = 50;
}
}
if ((sim->pv[y/CELL][x/CELL] > 2.7f) && parts[i].tmp>40)
parts[i].tmp=39;
else if (parts[i].tmp<40&&parts[i].tmp>0)
parts[i].tmp--;
else if (parts[i].tmp<=0) {
sim->create_part(i, x, y, PT_FSEP);
return 1;
}
else if (parts[i].tmp<40)
parts[i].tmp--;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
@ -78,11 +79,10 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20)))
if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && parts[i].life>40 && !(rand()%20)))
{
if (parts[i].life>40) {
parts[i].life = 39;
}
}
}
return 0;

View File

@ -83,8 +83,6 @@ int Element_FWRK::update(UPDATE_FUNC_ARGS)
return 0;
}
}
if (parts[i].life>=45)
parts[i].life=0;
if (parts[i].life<3&&parts[i].life>0)
{
int r = (rand()%245+11);
@ -113,6 +111,8 @@ int Element_FWRK::update(UPDATE_FUNC_ARGS)
sim->kill_part(i);
return 1;
}
if (parts[i].life>=45)
parts[i].life=0;
return 0;
}