Replace pstates and some pressure ifs with array.

This commit is contained in:
jacksonmj 2011-01-07 14:47:10 +00:00
parent 1ab4d328a6
commit b661418d7e
2 changed files with 285 additions and 121 deletions

View File

@ -284,8 +284,22 @@ struct part_state
int burn;
float btemp;
};
typedef struct part_state part_state;
struct part_transition
{
float plv; // transition occurs if pv is lower than this
int plt;
float phv; // transition occurs if pv is higher than this
int pht;
float tlv; // transition occurs if t is lower than this
int tlt;
float thv; // transition occurs if t is higher than this
int tht;
};
typedef struct part_transition part_transition;
//Should probably be const.
/* Weight Help
* 1 = Gas ||
@ -586,6 +600,170 @@ static part_state pstates[PT_NUM] =
/* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
/* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
};
// temporarily define abbreviations for impossible p/t values
#define IPL -257.0f
#define IPH 257.0f
#define ITL MIN_TEMP-1
#define ITH MAX_TEMP+1
// no transition (PT_NONE means kill part)
#define NT -1
// special transition - lava ctypes etc need extra code
// TODO: use update_ELEM functions for special transitions, only use this table for the simple ones
#define ST PT_NUM
static part_transition ptransitions[PT_NUM] =
{
// Name plv plt phv pht tlv tlt thv tht
/* NONE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* DUST */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* WATR */ {IPL, NT, IPH, NT, 273.15f,PT_ICEI, 373.0f, PT_WTRV},
/* OIL */ {IPL, NT, IPH, NT, ITL, NT, 333.0f, PT_GAS},
/* FIRE */ {IPL, NT, IPH, NT, ITL, NT, 2773.0f,PT_PLSM},
/* STNE */ {IPL, NT, IPH, NT, ITL, NT, 983.0f, PT_LAVA},
/* LAVA */ {IPL, NT, IPH, NT, 2573.15f,ST, ITH, NT}, // 2573.15f is highest melt pt of possible ctypes
/* GUN */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE},
/* NITR */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE},
/* CLNE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GAS */ {-6.0f, PT_OIL, 6.0f, PT_OIL, ITL, NT, 573.0f, PT_FIRE},
/* C-4 */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE},
/* GOO */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* ICE */ {IPL, NT, 0.8f, PT_SNOW, ITL, NT, 233.0f, ST},
/* METL */ {IPL, NT, IPH, NT, ITL, NT, 1273.0f,PT_LAVA},
/* SPRK */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* SNOW */ {IPL, NT, IPH, NT, ITL, NT, 273.0f, PT_WATR},
/* WOOD */ {IPL, NT, IPH, NT, ITL, NT, 873.0f, PT_FIRE},
/* NEUT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* PLUT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* PLNT */ {IPL, NT, IPH, NT, ITL, NT, 573.0f, PT_FIRE},
/* ACID */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* VOID */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* WTRV */ {IPL, NT, IPH, NT, 371.0f, ST, ITH, NT},
/* CNCT */ {IPL, NT, IPH, NT, ITL, NT, 1123.0f,PT_LAVA},
/* DSTW */ {IPL, NT, IPH, NT, 273.15f,PT_ICEI, 373.0f, PT_WTRV},
/* SALT */ {IPL, NT, IPH, NT, ITL, NT, 1173.0f,PT_LAVA},
/* SLTW */ {IPL, NT, IPH, NT, 233.0f, PT_ICEI, 483.0f, ST},
/* DMND */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* BMTL */ {IPL, NT, 1.0f, ST, ITL, NT, 1273.0f,PT_LAVA},
/* BRMT */ {IPL, NT, IPH, NT, ITL, NT, 1273.0f,PT_LAVA},
/* PHOT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* URAN */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* WAX */ {IPL, NT, IPH, NT, ITL, NT, 319.0f, PT_MWAX},
/* MWAX */ {IPL, NT, IPH, NT, 318.0f, PT_WAX, 673.0f, PT_FIRE},
/* PSCN */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA},
/* NSCN */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA},
/* LNTG */ {IPL, NT, IPH, NT, 63.0f, PT_NICE, 77.0f, PT_NONE},
/* INSL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* BHOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* WHOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* RBDM */ {IPL, NT, IPH, NT, ITL, NT, 312.0f, PT_LRBD},//, 961.0f, PT_FIRE},
/* LRBD */ {IPL, NT, IPH, NT, 311.0f, PT_RBDM, 961.0f, PT_FIRE},
/* NTCT */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA},
/* SAND */ {IPL, NT, IPH, NT, ITL, NT, 1973.0f,PT_LAVA},
/* GLAS */ {IPL, NT, IPH, NT, ITL, NT, 1973.0f,PT_LAVA},
/* PTCT */ {IPL, NT, IPH, NT, ITL, NT, 1414.0f,PT_LAVA},
/* BGLA */ {IPL, NT, IPH, NT, ITL, NT, 1973.0f,PT_LAVA},
/* THDR */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* PLSM */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* ETRD */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* NICE */ {IPL, NT, IPH, NT, ITL, NT, 63.1f, PT_LNTG},
/* NBLE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* BTRY */ {IPL, NT, IPH, NT, ITL, NT, 2273.0f,PT_PLSM},
/* LCRY */ {IPL, NT, IPH, NT, ITL, NT, 1273.0f,PT_BGLA},
/* STKM */ {IPL, NT, IPH, NT, ITL, NT, 620.0f, PT_FIRE},
/* SWCH */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* SMKE */ {IPL, NT, IPH, NT, ITL, NT, 625.0f, PT_FIRE},
/* DESL */ {IPL, NT, 5.0f, PT_FIRE, ITL, NT, 335.0f, PT_FIRE},
/* COAL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* LO2 */ {IPL, NT, IPH, NT, ITL, NT, 90.1f, PT_O2},
/* O2 */ {IPL, NT, IPH, NT, 90.0f, PT_LO2, ITH, NT},
/* INWR */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA},
/* YEST */ {IPL, NT, IPH, NT, ITL, NT, 373.0f, PT_DYST},
/* DYST */ {IPL, NT, IPH, NT, ITL, NT, 473.0f, PT_DUST},
/* THRM */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GLOW */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* BRCK */ {IPL, NT, 8.8f, PT_STNE, ITL, NT, 1223.0f,PT_LAVA},
/* HFLM */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* FIRW */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* FUSE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* FSEP */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* AMtr */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* BCOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* PCLN */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* HSWC */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* IRON */ {IPL, NT, IPH, NT, ITL, NT, 1687.0f,PT_LAVA},
/* MORT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* SPNG */ {IPL, NT, IPH, NT, ITL, NT, 2730.0f,PT_FIRE},
/* RIME */ {IPL, NT, IPH, NT, ITL, NT, 273.15f,PT_WATR},
/* FOG */ {IPL, NT, IPH, NT, ITL, NT, 373.15f,PT_WTRV},
/* BCLN */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* LOVE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* WTF */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* WARP */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* PUMP */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* FWRK */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* PIPE */ {IPL, NT, 10.0f, PT_BRMT, ITL, NT, ITH, NT},
/* FRZZ */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* FRZW */ {IPL, NT, IPH, NT, ITL, NT, 53.0f, PT_ICEI},
/* GRAV */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* BIZR */ {IPL, NT, IPH, NT, 100.0f, PT_BIZRG, 400.0f, PT_BIZRS},
/* BIZRG*/ {IPL, NT, IPH, NT, ITL, NT, 100.0f, PT_BIZR},//, 400.0f, PT_BIZRS},
/* BIZRS*/ {IPL, NT, IPH, NT, 400.0f, PT_BIZR, ITH, NT},// 100.0f, PT_BIZRG},
/* INST */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* ISOZ */ {IPL, NT, IPH, NT, 160.0f, PT_ISZS, ITH, NT},
/* ISZS */ {IPL, NT, IPH, NT, ITL, NT, 300.0f, PT_ISOZ},
/* PRTI */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* PRTO */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* PSTE */ {IPL, NT, 0.5f, PT_PSTS, ITL, NT, 747.0f, PT_BRCK},
/* PSTS */ {0.5f, PT_PSTE, IPH, NT, ITL, NT, ITH, NT},
/* ANAR */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* VINE */ {IPL, NT, IPH, NT, ITL, NT, 573.0f, PT_FIRE},
/* INVS */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* EQVE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* SPWN2*/ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* SPAWN*/ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* SHLD1*/ {IPL, NT, 7.0f, PT_NONE, ITL, NT, ITH, NT},
/* SHLD2*/ {IPL, NT, 15.0f, PT_NONE, ITL, NT, ITH, NT},
/* SHLD3*/ {IPL, NT, 25.0f, PT_NONE, ITL, NT, ITH, NT},
/* SHLD4*/ {IPL, NT, 40.0f, PT_NONE, ITL, NT, ITH, NT},
/* LOlZ */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* WIFI */ {IPL, NT, 15.0f, PT_BRMT, ITL, NT, ITH, NT},
/* FILT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* ARAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* BRAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* STKM2*/ {IPL, NT, IPH, NT, ITL, NT, 620.0f, PT_FIRE},
/* BOMB */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* C-5 */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* SING */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* QRTZ */ {IPL, NT, IPH, NT, ITL, NT, 2573.15f,PT_LAVA},
/* PQRT */ {IPL, NT, IPH, NT, ITL, NT, 2573.15f,PT_LAVA},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
};
#undef IPL
#undef IPH
#undef ITL
#undef ITH
#undef NT
#undef ST
static int grule[NGOL][9] =
{
// 0,1,2,3,4,5,6,7,8 live=1 spawn=2 spawn&live=3

View File

@ -1610,39 +1610,35 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].life = rand()%50+120;
}
}
if (t==PT_GAS && pv[y/CELL][x/CELL]<-6.0f)
t = parts[i].type = PT_OIL;
if (t==PT_DESL && pv[y/CELL][x/CELL]>5.0f)
{ // Only way I know to make it
t = parts[i].type = PT_FIRE; // combust under pressure.
parts[i].life = rand()%50+120;
s = 1;
if (pv[y/CELL][x/CELL]>ptransitions[t].phv&&ptransitions[t].pht>-1) {
if (ptransitions[t].pht!=PT_NUM)
t = ptransitions[t].pht;
else if (t==PT_BMTL) {
if (pv[y/CELL][x/CELL]>2.5f)
t = PT_BRMT;
else if (pv[y/CELL][x/CELL]>1.0f && parts[i].tmp==1)
t = PT_BRMT;
else s = 0;
}
if (t==PT_GAS && pv[y/CELL][x/CELL]>6.0f)
t = parts[i].type = PT_OIL;
if (t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f)
t = parts[i].type = PT_BRMT;
if (t==PT_BMTL && pv[y/CELL][x/CELL]>1.0f && parts[i].tmp==1)
t = parts[i].type = PT_BRMT;
if (t==PT_BRCK && pv[y/CELL][x/CELL]>8.8f)
t = parts[i].type = PT_STNE;
if (t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f)
t = parts[i].type = PT_BRMT;
if (t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f)
t = parts[i].type = PT_PSTS;
if (t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f)
t = parts[i].type = PT_PSTE;
if (t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f)
t = parts[i].type = PT_NONE;
if (t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f)
t = parts[i].type = PT_NONE;
if (t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f)
t = parts[i].type = PT_NONE;
if (t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f)
t = parts[i].type = PT_NONE;
if (t==PT_WIFI && pv[y/CELL][x/CELL]>15.0f)
t = parts[i].type = PT_BRMT;
//if(t==PT_GLAS && pv[y/CELL][x/CELL]>4.0f)
// t = parts[i].type = PT_BGLA;
else s = 0;
} else if (pv[y/CELL][x/CELL]<ptransitions[t].plv&&ptransitions[t].plt>-1) {
if (ptransitions[t].plt!=PT_NUM)
t = ptransitions[t].plt;
else s = 0;
}
else s = 0;
if (s) {
parts[i].type = t;
if (t==PT_FIRE)
parts[i].life = rand()%50+120;
if (t==PT_NONE) {
kill_part(i);
goto killed;
}
}
if (t==PT_GLAS)
{
parts[i].pavg[0] = parts[i].pavg[1];
@ -1701,7 +1697,7 @@ void update_particles_i(pixel *vid, int start, int inc)
h_count = 0;
if (t==PT_ICEI && !parts[i].ctype)
parts[i].ctype = PT_WATR;
if (ptypes[t].hconduct>(rand()%250)&&!(parts[i].type==PT_HSWC&&parts[i].life!=10))
if (ptypes[t].hconduct>(rand()%250)&&(t!=PT_HSWC||parts[i].life==10))
{
for (nx=-1; nx<2; nx++)
{
@ -1712,7 +1708,10 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if ((r>>8)>=NPART || !r)
continue;
if (parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[r>>8].type==PT_BRAY&&parts[i].type==PT_FILT)&&!(parts[i].type==PT_BRAY&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZR&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZRG&&parts[r>>8].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZR&&parts[i].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZRG&&parts[i].type==PT_FILT))
rt = parts[r>>8].type;
if (rt!=PT_NONE&&t!=PT_NONE&&ptypes[rt].hconduct&&(rt!=PT_HSWC||parts[r>>8].life==10)
&&(t!=PT_FILT||(rt!=PT_BRAY&&rt!=PT_BIZR&&rt!=PT_BIZRG))
&&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG)))
{
h_count++;
c_heat += parts[r>>8].temp;
@ -1730,96 +1729,88 @@ void update_particles_i(pixel *vid, int start, int inc)
r = pmap[y+ny][x+nx];
if ((r>>8)>=NPART || !r)
continue;
if (parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[r>>8].type==PT_BRAY&&parts[i].type==PT_FILT)&&!(parts[i].type==PT_BRAY&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZR&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZRG&&parts[r>>8].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZR&&parts[i].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZRG&&parts[i].type==PT_FILT))
rt = parts[r>>8].type;
if (rt!=PT_NONE&&t!=PT_NONE&&ptypes[rt].hconduct&&(rt!=PT_HSWC||parts[r>>8].life==10)
&&(t!=PT_FILT||(rt!=PT_BRAY&&rt!=PT_BIZR&&rt!=PT_BIZRG))
&&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG)))
{
parts[r>>8].temp = parts[i].temp;
}
}
}
}
if (pt>=pstates[t].btemp&&pstates[t].burn)
{
t = parts[i].type = pstates[t].burn;
if (t==PT_FIRE||t==PT_PLSM)
parts[i].life = rand()%50+120;
}
else if ((pt<=pstates[t].stemp||(t==PT_LAVA&&(pt<=pstates[parts[i].ctype].ltemp)))&&pstates[t].solid)
{
if (t==PT_LAVA&&parts[i].ctype)
{
parts[i].life = 0;
if (parts[i].ctype==PT_THRM)
{
parts[i].tmp = 0;
parts[i].ctype = PT_BMTL;
}
if (parts[i].ctype==PT_PLUT)
{
parts[i].tmp = 0;
parts[i].ctype = PT_LAVA;
}
t = parts[i].type = parts[i].ctype;
parts[i].ctype = PT_NONE;
}
else if (pstates[t].solid==PT_ICEI&&pt<=pstates[t].stemp)
{
parts[i].ctype = parts[i].type;
t = parts[i].type = PT_ICEI;
}
else
{
parts[i].life = 0;
t = parts[i].type = pstates[t].solid;
}
}
else if ((pt>=pstates[t].ltemp&&(pt<=pstates[t].gtemp||!pstates[t].gas)&&pstates[t].state==ST_SOLID&&pstates[t].liquid)||(t==PT_ICEI&&pt>pstates[parts[i].ctype].stemp))
{
if (pstates[t].liquid==PT_LAVA)
{
parts[i].life = rand()%120+240;
parts[i].ctype = (parts[i].type==PT_BRMT)?PT_BMTL:parts[i].type;
parts[i].ctype = (parts[i].ctype==PT_SAND)?PT_GLAS:parts[i].ctype;
parts[i].ctype = (parts[i].ctype==PT_BGLA)?PT_GLAS:parts[i].ctype;
parts[i].ctype = (parts[i].ctype==PT_PQRT)?PT_QRTZ:parts[i].ctype;
t = parts[i].type = pstates[t].liquid;
}
else if (t==PT_ICEI&&parts[i].ctype)
{
t = parts[i].type = parts[i].ctype;
parts[i].ctype = PT_NONE;
}
else
{
t = parts[i].type = pstates[t].liquid;
}
}
else if (pt-ctemp<=pstates[t].ltemp&&pstates[t].liquid&&pstates[t].state==ST_GAS)
{
t = parts[i].type = pstates[t].liquid;
}
else if (pt-ctemp>=pstates[t].gtemp&&(pstates[t].gas||parts[i].type==PT_LNTG)&&(pstates[t].state==ST_LIQUID||pstates[t].state==ST_SOLID))
{
if (t==PT_SLTW&&1>rand()%6)
{
t = parts[i].type = PT_SALT;
}
else
{
if ((t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)&&pt>=pstates[t].gtemp)
{
t = parts[i].type = pstates[t].gas;
}
s = 1;
if (pt>ptransitions[t].thv&&ptransitions[t].tht>-1) {
if (ptransitions[t].tht!=PT_NUM)
t = ptransitions[t].tht;
else if (t==PT_ICEI) {
if (parts[i].ctype&&parts[i].ctype!=PT_ICEI) {
if (ptransitions[parts[i].ctype].tlt==PT_ICEI&&pt<=ptransitions[parts[i].ctype].tlv) s = 0;
else {
t = parts[i].type = pstates[t].gas;
t = parts[i].ctype;
parts[i].ctype = PT_NONE;
parts[i].life = 0;
}
}
else if (pt>274.0f) t = PT_WATR;
else s = 0;
}
else if (t==PT_SLTW) {
if (1>rand()%6) t = PT_SALT;
else t = PT_WTRV;
}
else s = 0;
} else if (pt<ptransitions[t].tlv&&ptransitions[t].tlt>-1) {
if (ptransitions[t].tlt!=PT_NUM)
t = ptransitions[t].tlt;
else if (t==PT_WTRV) {
if (pt<273.0f) t = PT_RIME;
else t = PT_DSTW;
}
else if (t==PT_LAVA) {
if (parts[i].ctype&&parts[i].ctype!=PT_LAVA) {
if (ptransitions[parts[i].ctype].tht==PT_LAVA&&pt>=ptransitions[parts[i].ctype].thv) s = 0;
else if (parts[i].ctype==PT_THRM&&pt>=ptransitions[PT_BMTL].thv) s = 0;
else {
t = parts[i].ctype;
parts[i].ctype = PT_NONE;
if (t==PT_THRM) {
parts[i].tmp = 0;
t = PT_BMTL;
}
}
}
else if (pt<973.0f) t = PT_STNE;
else s = 0;
}
else s = 0;
if (s) parts[i].life = 0;
}
else s = 0;
if (s) {
if (t==PT_ICEI||t==PT_LAVA)
parts[i].ctype = parts[i].type;
if (pstates[t].state==ST_GAS&&pstates[parts[i].type].state!=ST_GAS)
pv[y/CELL][x/CELL] += 0.50f;
parts[i].type = t;
if (t==PT_FIRE||t==PT_PLSM||t==PT_HFLM)
parts[i].life = rand()%50+120;
if (t==PT_LAVA) {
if (parts[i].ctype==PT_BRMT) parts[i].ctype = PT_BMTL;
else if (parts[i].ctype==PT_SAND) parts[i].ctype = PT_GLAS;
else if (parts[i].ctype==PT_BGLA) parts[i].ctype = PT_GLAS;
else if (parts[i].ctype==PT_PQRT) parts[i].ctype = PT_QRTZ;
parts[i].life = rand()%120+240;
}
if (t==PT_NONE) {
kill_part(i);
goto killed;
}
}
if (t==PT_FIRE)
parts[i].life = rand()%50+120;
if (t==PT_HFLM)
parts[i].life = rand()%50+120;
}
}
if (t==PT_URAN && pv[y/CELL][x/CELL]>0.0f)
{
float atemp = parts[i].temp + (-MIN_TEMP);
@ -1833,11 +1824,6 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[i].tmp--;
parts[i].temp = 3500;
}
if (parts[i].ctype==PT_PLUT&&parts[i].tmp>0)
{
parts[i].tmp--;
parts[i].temp = MAX_TEMP;
}
}
pt = parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP);
}