Remove BOUNDS_CHECK

It didn't do anything anyway, see 10e104f3f5.

Also fix some C89-isms.
This commit is contained in:
Tamás Bálint Misius
2023-09-02 11:59:26 +02:00
parent 46730cfc26
commit 52a4917624
98 changed files with 1581 additions and 1189 deletions

View File

@@ -54,8 +54,6 @@ constexpr auto FLAG_PHOTDECO = UINT32_C(0x00000008); // compatibility with
#define CTYPEDRAW_FUNC_ARGS Simulation *sim, int i, int t, int v
#define CTYPEDRAW_FUNC_SUBCALL_ARGS sim, i, t, v
constexpr bool BOUNDS_CHECK = true;
constexpr int OLD_PT_WIND = 147;
// Change this to change the amount of bits used to store type in pmap (and a few elements such as PIPE and CRAY)

View File

@@ -49,7 +49,6 @@ void Element::Element_ACEL()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
float multiplier;
if (parts[i].life!=0)
{
@@ -61,11 +60,13 @@ static int update(UPDATE_FUNC_ARGS)
multiplier = 1.1f;
}
parts[i].tmp = 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (!rx != !ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (!rx != !ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if(!r)
r = sim->photons[y+ry][x+rx];
if (!r)
@@ -77,6 +78,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].tmp = 1;
}
}
}
}
return 0;
}

View File

@@ -52,12 +52,13 @@ void Element::Element_ACID()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
int rt = TYP(r);
@@ -108,13 +109,15 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
for (trade = 0; trade<2; trade++)
}
}
for (auto trade = 0; trade<2; trade++)
{
rx = sim->rng.between(-2, 2);
ry = sim->rng.between(-2, 2);
if (BOUNDS_CHECK && (rx || ry))
auto rx = sim->rng.between(-2, 2);
auto ry = sim->rng.between(-2, 2);
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r) == PT_ACID && (parts[i].life > parts[ID(r)].life) && parts[i].life>0)//diffusion

View File

@@ -49,15 +49,16 @@ void Element::Element_AMTR()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if (rt!=PT_AMTR && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_VOID && rt!=PT_BHOL && rt!=PT_NBHL && rt!=PT_PRTI && rt!=PT_PRTO)
{
parts[i].life++;
@@ -73,6 +74,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->pv[y/CELL][x/CELL] -= 2.0f;
}
}
}
}
return 0;
}

View File

@@ -48,15 +48,13 @@ void Element::Element_ANAR()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
//if (parts[i].temp >= 0.23)
// parts[i].temp --;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_CFLM && sim->rng.chance(1, 4))
@@ -67,5 +65,7 @@ static int update(UPDATE_FUNC_ARGS)
sim->pv[y/CELL][x/CELL] -= 0.5;
}
}
}
}
return 0;
}

View File

@@ -53,7 +53,7 @@ static int update(UPDATE_FUNC_ARGS)
{
for (int ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int r = pmap[y+ry][x+rx];
if (!r)

View File

@@ -47,17 +47,19 @@ void Element::Element_BANG()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if(parts[i].tmp==0)
{
if(parts[i].temp>=673.0f)
parts[i].tmp = 1;
else
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_FIRE || TYP(r)==PT_PLSM || TYP(r)==PT_SPRK || TYP(r)==PT_LIGH)
@@ -65,7 +67,9 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].tmp = 1;
}
}
}
}
}
}
else if(parts[i].tmp==1)
{

View File

@@ -60,27 +60,27 @@ static int update(UPDATE_FUNC_ARGS)
}
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled)
{
int r, rx, ry, rt;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
auto r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
auto rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_STKM &&
rt!=PT_PBCN && rt!=PT_STKM2 &&
rt<PT_NUM)
{
r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_STKM &&
rt!=PT_PBCN && rt!=PT_STKM2 &&
rt<PT_NUM)
{
parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[ID(r)].ctype;
}
parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[ID(r)].ctype;
}
}
}
}
else
{

View File

@@ -53,36 +53,39 @@ constexpr float BLEND = 0.95f;
int Element_BIZR_update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, nr, ng, nb, na;
float tr, tg, tb, ta, mr, mg, mb, ma;
if(parts[i].dcolour){
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
if(parts[i].dcolour)
{
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)!=PT_BIZR && TYP(r)!=PT_BIZRG && TYP(r)!=PT_BIZRS)
{
tr = float((parts[ID(r)].dcolour>>16)&0xFF);
tg = float((parts[ID(r)].dcolour>>8)&0xFF);
tb = float((parts[ID(r)].dcolour)&0xFF);
ta = float((parts[ID(r)].dcolour>>24)&0xFF);
auto tr = float((parts[ID(r)].dcolour>>16)&0xFF);
auto tg = float((parts[ID(r)].dcolour>>8)&0xFF);
auto tb = float((parts[ID(r)].dcolour)&0xFF);
auto ta = float((parts[ID(r)].dcolour>>24)&0xFF);
mr = float((parts[i].dcolour>>16)&0xFF);
mg = float((parts[i].dcolour>>8)&0xFF);
mb = float((parts[i].dcolour)&0xFF);
ma = float((parts[i].dcolour>>24)&0xFF);
auto mr = float((parts[i].dcolour>>16)&0xFF);
auto mg = float((parts[i].dcolour>>8)&0xFF);
auto mb = float((parts[i].dcolour)&0xFF);
auto ma = float((parts[i].dcolour>>24)&0xFF);
nr = int((tr*BLEND) + (mr*(1 - BLEND)));
ng = int((tg*BLEND) + (mg*(1 - BLEND)));
nb = int((tb*BLEND) + (mb*(1 - BLEND)));
na = int((ta*BLEND) + (ma*(1 - BLEND)));
auto nr = int((tr*BLEND) + (mr*(1 - BLEND)));
auto ng = int((tg*BLEND) + (mg*(1 - BLEND)));
auto nb = int((tb*BLEND) + (mb*(1 - BLEND)));
auto na = int((ta*BLEND) + (ma*(1 - BLEND)));
parts[ID(r)].dcolour = nr<<16 | ng<<8 | nb | na<<24;
}
}
}
}
}
return 0;
}

View File

@@ -47,15 +47,16 @@ void Element::Element_BMTL()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].tmp>1)
{
parts[i].tmp--;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((TYP(r)==PT_METL || TYP(r)==PT_IRON) && sim->rng.chance(1, 100))
@@ -64,6 +65,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].tmp = (parts[i].tmp<=7) ? parts[i].tmp=1 : parts[i].tmp - sim->rng.between(0, 4);
}
}
}
}
}
else if (parts[i].tmp==1 && sim->rng.chance(1, 1000))
{

View File

@@ -50,23 +50,24 @@ void Element::Element_BOMB()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt, nb;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if (rt!=PT_BOMB && rt!=PT_EMBR && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_BCLN && rt!=PT_VIBR)
{
int rad = 8, nt;
int nxi, nxj;
sim->kill_part(i);
for (nxj=-rad; nxj<=rad; nxj++)
for (nxi=-rad; nxi<=rad; nxi++)
for (auto nxj=-rad; nxj<=rad; nxj++)
{
for (auto nxi=-rad; nxi<=rad; nxi++)
{
if ((pow((float)nxi,2))/(pow((float)rad,2))+(pow((float)nxj,2))/(pow((float)rad,2))<=1)
{
int ynxj = y + nxj, xnxi = x + nxi;
@@ -80,7 +81,7 @@ static int update(UPDATE_FUNC_ARGS)
if (nt)
sim->kill_part(ID(pmap[ynxj][xnxi]));
sim->pv[(ynxj)/CELL][(xnxi)/CELL] += 0.1f;
nb = sim->create_part(-3, xnxi, ynxj, PT_EMBR);
auto nb = sim->create_part(-3, xnxi, ynxj, PT_EMBR);
if (nb!=-1)
{
parts[nb].tmp = 2;
@@ -89,11 +90,15 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
}
}
for (auto nxj=-(rad+1); nxj<=(rad+1); nxj++)
{
for (auto nxi=-(rad+1); nxi<=(rad+1); nxi++)
{
if ((pow((float)nxi,2))/(pow((float)(rad+1),2))+(pow((float)nxj,2))/(pow((float)(rad+1),2))<=1 && !TYP(pmap[y+nxj][x+nxi]))
{
nb = sim->create_part(-3, x+nxi, y+nxj, PT_EMBR);
auto nb = sim->create_part(-3, x+nxi, y+nxj, PT_EMBR);
if (nb!=-1)
{
parts[nb].tmp = 0;
@@ -103,9 +108,13 @@ static int update(UPDATE_FUNC_ARGS)
parts[nb].vy = float(sim->rng.between(-20, 20));
}
}
}
}
return 1;
}
}
}
}
return 0;
}

View File

@@ -48,7 +48,6 @@ void Element::Element_BOYL()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
float limit = parts[i].temp / 100;
if (sim->pv[y / CELL][x / CELL] < limit)
sim->pv[y / CELL][x / CELL] += 0.001f*(limit - sim->pv[y / CELL][x / CELL]);
@@ -62,11 +61,13 @@ static int update(UPDATE_FUNC_ARGS)
sim->pv[y / CELL][x / CELL - 1] += 0.001f*(limit - sim->pv[y / CELL][x / CELL - 1]);
sim->pv[y / CELL - 1][x / CELL - 1] += 0.001f*(limit - sim->pv[y / CELL - 1][x / CELL - 1]);
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_WATR)
@@ -84,5 +85,7 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -47,17 +47,18 @@ void Element::Element_BRMT()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, tempFactor;
if (parts[i].temp > 523.15f)//250.0f+273.15f
{
tempFactor = int(1000 - ((523.15f-parts[i].temp)*2));
auto tempFactor = int(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 (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_BREC && sim->rng.chance(1, tempFactor))
@@ -70,6 +71,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->create_part(i, x, y, PT_THRM);
}
}
}
}
}
return 0;
}

View File

@@ -47,15 +47,16 @@ void Element::Element_BTRY()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry) && abs(rx)+abs(ry)<4)
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if ((rx || ry) && abs(rx)+abs(ry)<4)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if (sim->parts_avg(i,ID(r),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[ID(r)].life==0)
@@ -66,5 +67,7 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -49,12 +49,13 @@ void Element::Element_C5()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((TYP(r)!=PT_C5 && parts[ID(r)].temp<100 && sim->elements[TYP(r)].HeatConduct && (TYP(r)!=PT_HSWC||parts[ID(r)].life==10)) || TYP(r)==PT_CFLM)
@@ -68,13 +69,15 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
if (parts[i].ctype && !parts[i].life)
{
float vx = ((parts[i].tmp << 16) >> 16) / 255.0f;
float vy = (parts[i].tmp >> 16) / 255.0f;
float dx = ((parts[i].tmp2 << 16) >> 16) / 255.0f;
float dy = (parts[i].tmp2 >> 16) / 255.0f;
r = sim->create_part(-3, x, y, PT_PHOT);
auto r = sim->create_part(-3, x, y, PT_PHOT);
if (r != -1)
{
parts[r].ctype = parts[i].ctype;

View File

@@ -50,8 +50,10 @@ void Element::Element_CAUS()
static int update(UPDATE_FUNC_ARGS)
{
for (int rx = -2; rx <= 2; rx++)
{
for (int ry = -2; ry <= 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
if (rx || ry)
{
int r = pmap[y+ry][x+rx];
if (!r)
@@ -86,5 +88,7 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -50,7 +50,6 @@ void Element::Element_CBNW()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (sim->pv[y/CELL][x/CELL]<=3)
{
if (sim->pv[y/CELL][x/CELL] <= -0.5 || sim->rng.chance(1, 4000))
@@ -79,11 +78,13 @@ static int update(UPDATE_FUNC_ARGS)
}
parts[i].tmp--;
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((sim->elements[TYP(r)].Properties&TYPE_PART) && parts[i].tmp == 0 && sim->rng.chance(1, 83))
@@ -133,6 +134,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -51,27 +51,27 @@ static int update(UPDATE_FUNC_ARGS)
{
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled)
{
int r, rx, ry, rt;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
auto r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
auto rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_STKM &&
rt!=PT_PBCN && rt!=PT_STKM2 &&
rt<PT_NUM)
{
r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_STKM &&
rt!=PT_PBCN && rt!=PT_STKM2 &&
rt<PT_NUM)
{
parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[ID(r)].ctype;
}
parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[ID(r)].ctype;
}
}
}
}
else
{

View File

@@ -51,13 +51,13 @@ void Element::Element_CLST()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
float cxy = 0;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_WATR)
@@ -75,6 +75,7 @@ static int update(UPDATE_FUNC_ARGS)
}
else if (TYP(r)==PT_CLST)
{
float cxy;
if(parts[i].temp <195)
cxy = 0.05f;
else if(parts[i].temp <295)
@@ -87,6 +88,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].vy += cxy*ry;//These two can be set not to calculate over 350 later. They do virtually nothing over 0.005.
}
}
}
}
return 0;
}

View File

@@ -47,12 +47,13 @@ void Element::Element_CO2()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
{
if (parts[i].ctype==5 && sim->rng.chance(1, 2000))
@@ -86,6 +87,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
if (parts[i].temp > 9773.15 && sim->pv[y/CELL][x/CELL] > 200.0f)
{
if (sim->rng.chance(1, 5))

View File

@@ -49,39 +49,41 @@ void Element::Element_CONV()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
int ctype = TYP(parts[i].ctype);
if (ctype<=0 || ctype>=PT_NUM || !sim->elements[ctype].Enabled || ctype==PT_CONV)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
auto r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
int rt = TYP(r);
if (rt != PT_CLNE && rt != PT_PCLN &&
rt != PT_BCLN && rt != PT_STKM &&
rt != PT_PBCN && rt != PT_STKM2 &&
rt != PT_CONV && rt < PT_NUM)
{
r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
int rt = TYP(r);
if (rt != PT_CLNE && rt != PT_PCLN &&
rt != PT_BCLN && rt != PT_STKM &&
rt != PT_PBCN && rt != PT_STKM2 &&
rt != PT_CONV && rt < PT_NUM)
{
parts[i].ctype = rt;
if (rt == PT_LIFE)
parts[i].ctype |= PMAPID(parts[ID(r)].ctype);
}
parts[i].ctype = rt;
if (rt == PT_LIFE)
parts[i].ctype |= PMAPID(parts[ID(r)].ctype);
}
}
}
}
else
{
int restrictElement = sim->IsElement(parts[i].tmp) ? parts[i].tmp : 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = sim->photons[y+ry][x+rx];
auto r = sim->photons[y+ry][x+rx];
if (!r || (restrictElement && ((TYP(r) == restrictElement) == (parts[i].tmp2 == 1))))
r = pmap[y+ry][x+rx];
if (!r || (restrictElement && ((TYP(r) == restrictElement) == (parts[i].tmp2 == 1))))
@@ -91,6 +93,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->create_part(ID(r), x+rx, y+ry, TYP(parts[i].ctype), ID(parts[i].ctype));
}
}
}
}
}
return 0;
}

View File

@@ -56,26 +56,29 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].ctype<=0 || !sim->elements[TYP(parts[i].ctype)].Enabled)
{
for (int rx = -1; rx <= 1; rx++)
{
for (int ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK)
{
int r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)!=PT_CRAY && TYP(r)!=PT_PSCN && TYP(r)!=PT_INST && TYP(r)!=PT_METL && TYP(r)!=PT_SPRK && TYP(r)<PT_NUM)
{
int r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)!=PT_CRAY && TYP(r)!=PT_PSCN && TYP(r)!=PT_INST && TYP(r)!=PT_METL && TYP(r)!=PT_SPRK && TYP(r)<PT_NUM)
{
parts[i].ctype = TYP(r);
parts[i].temp = parts[ID(r)].temp;
}
parts[i].ctype = TYP(r);
parts[i].temp = parts[ID(r)].temp;
}
}
}
}
else
{
for (int rx =-1; rx <= 1; rx++)
{
for (int ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
if (rx || ry)
{
int r = pmap[y+ry][x+rx];
if (!r)
@@ -131,6 +134,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
return 0;
}

View File

@@ -49,18 +49,19 @@ void Element::Element_DCEL()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
float multiplier = 1.0f/1.1f;
if (parts[i].life!=0)
{
multiplier = 1.0f - ((parts[i].life > 100 ? 100 : (parts[i].life < 0 ? 0 : parts[i].life)) / 100.0f);
}
parts[i].tmp = 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry) && !(rx && ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if ((rx || ry) && !(rx && ry))
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
r = sim->photons[y+ry][x+rx];
if (!r)
@@ -72,6 +73,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].tmp = 1;
}
}
}
}
return 0;
}

View File

@@ -53,7 +53,6 @@ void Element::Element_DEUT()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade, np;
float gravtot = fabs(sim->gravy[(y/CELL)*XCELLS+(x/CELL)])+fabs(sim->gravx[(y/CELL)*XCELLS+(x/CELL)]);
// Prevent division by 0
float temp = std::max(1.0f, (parts[i].temp + 1));
@@ -65,11 +64,13 @@ static int update(UPDATE_FUNC_ARGS)
maxlife = maxlife*int(5.0f - 8.0f/(gravtot+2.0f));
if (parts[i].life < maxlife)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r || (parts[i].life >=maxlife))
continue;
if (TYP(r)==PT_DEUT&& sim->rng.chance(1, 3))
@@ -83,33 +84,41 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
else
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
//Leave if there is nothing to do
if (parts[i].life <= maxlife)
goto trade;
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if ((!r)&&parts[i].life>=1)//if nothing then create deut
{
np = sim->create_part(-1,x+rx,y+ry,PT_DEUT);
auto np = sim->create_part(-1,x+rx,y+ry,PT_DEUT);
if (np<0) continue;
parts[i].life--;
parts[np].temp = parts[i].temp;
parts[np].life = 0;
}
}
}
}
}
trade:
for ( trade = 0; trade<4; trade ++)
for (auto trade = 0; trade<4; trade ++)
{
rx = sim->rng.between(-2, 2);
ry = sim->rng.between(-2, 2);
if (BOUNDS_CHECK && (rx || ry))
auto rx = sim->rng.between(-2, 2);
auto ry = sim->rng.between(-2, 2);
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_DEUT&&(parts[i].life>parts[ID(r)].life)&&parts[i].life>0)//diffusion

View File

@@ -50,17 +50,18 @@ void Element::Element_DLAY()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, oldl;
oldl = parts[i].life;
auto oldl = parts[i].life;
if (parts[i].life>0)
parts[i].life--;
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 (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r || sim->parts_avg(ID(r), i,PT_INSL)==PT_INSL)
continue;
if (TYP(r)==PT_SPRK && parts[i].life==0 && parts[ID(r)].life>0 && parts[ID(r)].life<4 && parts[ID(r)].ctype==PT_PSCN)
@@ -90,7 +91,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->create_part(-1, x+rx, y+ry, PT_SPRK);
}
}
//}
}
}
return 0;
}

View File

@@ -50,39 +50,40 @@ void Element::Element_DMG()
static int update(UPDATE_FUNC_ARGS)
{
int r, rr, rx, ry, nxi, nxj, t, dist;
int rad = 25;
float angle, fx, fy;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)!=PT_DMG && TYP(r)!=PT_EMBR && TYP(r)!=PT_DMND && TYP(r)!=PT_CLNE && TYP(r)!=PT_PCLN && TYP(r)!=PT_BCLN)
{
sim->kill_part(i);
for (nxj=-rad; nxj<=rad; nxj++)
for (nxi=-rad; nxi<=rad; nxi++)
for (auto nxj=-rad; nxj<=rad; nxj++)
{
for (auto nxi=-rad; nxi<=rad; nxi++)
{
if (x+nxi>=0 && y+nxj>=0 && x+nxi<XRES && y+nxj<YRES && (nxi || nxj))
{
dist = int(sqrt(pow(nxi, 2.0f)+pow(nxj, 2.0f)));//;(pow((float)nxi,2))/(pow((float)rad,2))+(pow((float)nxj,2))/(pow((float)rad,2));
auto dist = int(sqrt(pow(nxi, 2.0f)+pow(nxj, 2.0f)));//;(pow((float)nxi,2))/(pow((float)rad,2))+(pow((float)nxj,2))/(pow((float)rad,2));
if (!dist || (dist <= rad))
{
rr = pmap[y+nxj][x+nxi];
auto rr = pmap[y+nxj][x+nxi];
if (rr)
{
angle = atan2((float)nxj, nxi);
fx = cos(angle) * 7.0f;
fy = sin(angle) * 7.0f;
auto angle = atan2((float)nxj, nxi);
auto fx = cos(angle) * 7.0f;
auto fy = sin(angle) * 7.0f;
parts[ID(rr)].vx += fx;
parts[ID(rr)].vy += fy;
sim->vx[(y+nxj)/CELL][(x+nxi)/CELL] += fx;
sim->vy[(y+nxj)/CELL][(x+nxi)/CELL] += fy;
sim->pv[(y+nxj)/CELL][(x+nxi)/CELL] += 1.0f;
t = TYP(rr);
auto t = TYP(rr);
if (t && sim->elements[t].HighPressureTransition>-1 && sim->elements[t].HighPressureTransition<PT_NUM)
sim->part_change_type(ID(rr), x+nxi, y+nxj, sim->elements[t].HighPressureTransition);
else if (t == PT_BMTL)
@@ -103,9 +104,13 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 1;
}
}
}
}
return 0;
}

View File

@@ -68,7 +68,7 @@ static int update(UPDATE_FUNC_ARGS)
{
for (int ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int r = pmap[y+ry][x+rx];
if (TYP(r) == PT_SPRK && parts[ID(r)].life == 3) //spark found, start creating

View File

@@ -48,12 +48,13 @@ void Element::Element_DSTW()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
switch (TYP(r))
{
case PT_SALT:
@@ -97,5 +98,7 @@ static int update(UPDATE_FUNC_ARGS)
continue;
}
}
}
}
return 0;
}

View File

@@ -51,19 +51,21 @@ void Element::Element_DTEC()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt, rd = parts[i].tmp2;
int rd = parts[i].tmp2;
if (rd > 25) parts[i].tmp2 = rd = 25;
if (parts[i].life)
{
parts[i].life = 0;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if (sim->parts_avg(i,ID(r),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[ID(r)].life==0)
@@ -74,14 +76,18 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
bool setFilt = false;
int photonWl = 0;
for (rx=-rd; rx<rd+1; rx++)
for (ry=-rd; ry<rd+1; ry++)
for (auto rx=-rd; rx<rd+1; rx++)
{
for (auto ry=-rd; ry<rd+1; ry++)
{
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if(!r)
r = sim->photons[y+ry][x+rx];
if(!r)
@@ -94,14 +100,18 @@ static int update(UPDATE_FUNC_ARGS)
photonWl = parts[ID(r)].ctype;
}
}
}
}
if (setFilt)
{
int nx, ny;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx=-1; rx<2; rx++)
{
for (auto ry=-1; ry<2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
nx = x+rx;
@@ -116,6 +126,8 @@ static int update(UPDATE_FUNC_ARGS)
r = pmap[ny][nx];
}
}
}
}
}
return 0;
}

View File

@@ -52,77 +52,82 @@ void Element::Element_ELEC()
static int update(UPDATE_FUNC_ARGS)
{
int r, rt, rx, ry, nb, rrx, rry;
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
if (BOUNDS_CHECK) {
r = pmap[y+ry][x+rx];
if (!r)
r = sim->photons[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
switch (rt)
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
auto r = pmap[y+ry][x+rx];
if (!r)
r = sim->photons[y+ry][x+rx];
if (!r)
continue;
auto rt = TYP(r);
switch (rt)
{
case PT_GLAS:
for (auto rrx=-1; rrx<=1; rrx++)
{
case PT_GLAS:
for (rrx=-1; rrx<=1; rrx++)
for (rry=-1; rry<=1; rry++)
if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) {
nb = sim->create_part(-1, x+rx+rrx, y+ry+rry, PT_EMBR);
if (nb!=-1) {
parts[nb].tmp = 0;
parts[nb].life = 50;
parts[nb].temp = parts[i].temp*0.8f;
parts[nb].vx = float(sim->rng.between(-10, 10));
parts[nb].vy = float(sim->rng.between(-10, 10));
}
}
sim->kill_part(i);
return 1;
case PT_LCRY:
parts[ID(r)].tmp2 = sim->rng.between(5, 9);
break;
case PT_WATR:
case PT_DSTW:
case PT_SLTW:
case PT_CBNW:
if (sim->rng.chance(1, 3))
sim->create_part(ID(r), x+rx, y+ry, PT_O2);
else
sim->create_part(ID(r), x+rx, y+ry, PT_H2);
sim->kill_part(i);
return 1;
case PT_PROT: // this is the correct reaction, not NEUT, but leaving NEUT in anyway
if (parts[ID(r)].tmp2 & 0x1)
break;
case PT_NEUT:
sim->part_change_type(ID(r), x+rx, y+ry, PT_H2);
parts[ID(r)].life = 0;
parts[ID(r)].ctype = 0;
sim->kill_part(i);
break;
case PT_DEUT:
if(parts[ID(r)].life < 6000)
parts[ID(r)].life += 1;
parts[ID(r)].temp = 0;
sim->kill_part(i);
return 1;
case PT_EXOT:
parts[ID(r)].tmp2 += 5;
parts[ID(r)].life = 1000;
break;
case PT_NONE: //seems to speed up ELEC even if it isn't used
break;
default:
if ((sim->elements[rt].Properties & PROP_CONDUCTS) && (rt!=PT_NBLE||parts[i].temp<2273.15))
for (auto rry=-1; rry<=1; rry++)
{
sim->create_part(-1, x+rx, y+ry, PT_SPRK);
sim->kill_part(i);
return 1;
if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) {
auto nb = sim->create_part(-1, x+rx+rrx, y+ry+rry, PT_EMBR);
if (nb!=-1) {
parts[nb].tmp = 0;
parts[nb].life = 50;
parts[nb].temp = parts[i].temp*0.8f;
parts[nb].vx = float(sim->rng.between(-10, 10));
parts[nb].vy = float(sim->rng.between(-10, 10));
}
}
}
break;
}
sim->kill_part(i);
return 1;
case PT_LCRY:
parts[ID(r)].tmp2 = sim->rng.between(5, 9);
break;
case PT_WATR:
case PT_DSTW:
case PT_SLTW:
case PT_CBNW:
if (sim->rng.chance(1, 3))
sim->create_part(ID(r), x+rx, y+ry, PT_O2);
else
sim->create_part(ID(r), x+rx, y+ry, PT_H2);
sim->kill_part(i);
return 1;
case PT_PROT: // this is the correct reaction, not NEUT, but leaving NEUT in anyway
if (parts[ID(r)].tmp2 & 0x1)
break;
case PT_NEUT:
sim->part_change_type(ID(r), x+rx, y+ry, PT_H2);
parts[ID(r)].life = 0;
parts[ID(r)].ctype = 0;
sim->kill_part(i);
break;
case PT_DEUT:
if(parts[ID(r)].life < 6000)
parts[ID(r)].life += 1;
parts[ID(r)].temp = 0;
sim->kill_part(i);
return 1;
case PT_EXOT:
parts[ID(r)].tmp2 += 5;
parts[ID(r)].life = 1000;
break;
case PT_NONE: //seems to speed up ELEC even if it isn't used
break;
default:
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);
return 1;
}
break;
}
}
}
return 0;
}

View File

@@ -52,12 +52,13 @@ void Element::Element_EMBR()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((sim->elements[TYP(r)].Properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(sim->elements[TYP(r)].Properties & PROP_SPARKSETTLE))
@@ -66,6 +67,8 @@ static int update(UPDATE_FUNC_ARGS)
return 1;
}
}
}
}
return 0;
}

View File

@@ -53,15 +53,16 @@ void Element::Element_EXOT()
static int update(UPDATE_FUNC_ARGS)
{
int r, rt, rx, ry, trade, tym;
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if (rt == PT_WARP)
{
if (parts[ID(r)].tmp2>2000 && sim->rng.chance(1, 100))
@@ -107,6 +108,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
parts[i].tmp--;
parts[i].tmp2--;
@@ -136,18 +139,18 @@ static int update(UPDATE_FUNC_ARGS)
}
if (parts[i].tmp2 > 100)
{
for (trade = 0; trade < 9; trade++)
for (auto trade = 0; trade < 9; trade++)
{
rx = sim->rng.between(-2, 2);
ry = sim->rng.between(-2, 2);
if (BOUNDS_CHECK && (rx || ry))
auto rx = sim->rng.between(-2, 2);
auto ry = sim->rng.between(-2, 2);
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_EXOT && (parts[i].tmp2 > parts[ID(r)].tmp2) && parts[ID(r)].tmp2 >= 0) //diffusion
{
tym = parts[i].tmp2 - parts[ID(r)].tmp2;
auto tym = parts[i].tmp2 - parts[ID(r)].tmp2;
if (tym == 1)
{
parts[ID(r)].tmp2++;

View File

@@ -54,7 +54,7 @@ void Element::Element_FIRE()
int Element_FIRE_update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt, t = parts[i].type;
int t = parts[i].type;
switch (t)
{
case PT_PLSM:
@@ -141,14 +141,16 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
default:
break;
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
//THRM burning
if (rt==PT_THRM && (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA))
@@ -273,6 +275,8 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
sim->pv[y/CELL][x/CELL] += 0.25f * CFDS;
}
}
}
}
if (sim->legacy_enable && t!=PT_SPRK) // SPRK has no legacy reactions
updateLegacy(UPDATE_FUNC_SUBCALL_ARGS);
return 0;
@@ -280,19 +284,21 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
static int updateLegacy(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt, lpv, t = parts[i].type;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
int t = parts[i].type;
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM)
continue;
rt = TYP(r);
auto rt = TYP(r);
lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL];
auto lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL];
if (lpv < 1) lpv = 1;
if (sim->elements[rt].Meltable &&
((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK)
@@ -348,6 +354,8 @@ static int updateLegacy(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -49,16 +49,18 @@ void Element::Element_FIRW()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt, np;
if (parts[i].tmp<=0) {
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
if (parts[i].tmp<=0)
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
{
float gx, gy, multiplier;
@@ -77,6 +79,8 @@ static int update(UPDATE_FUNC_ARGS)
return 0;
}
}
}
}
}
else if (parts[i].tmp==1) {
if (parts[i].life<=0) {
@@ -90,7 +94,7 @@ static int update(UPDATE_FUNC_ARGS)
unsigned col = Renderer::firwTableAt(sim->rng.between(0, 199)).Pack();
for (int n=0; n<40; n++)
{
np = sim->create_part(-3, x, y, PT_EMBR);
auto np = sim->create_part(-3, x, y, PT_EMBR);
if (np>-1)
{
auto magnitude = sim->rng.between(40, 99) * 0.05f;

View File

@@ -48,12 +48,13 @@ void Element::Element_FOG()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((sim->elements[TYP(r)].Properties&TYPE_SOLID) && sim->rng.chance(1, 10) && parts[i].life==0 && !(TYP(r)==PT_CLNE || TYP(r)==PT_PCLN)) // TODO: should this also exclude BCLN?
@@ -65,5 +66,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life += sim->rng.between(0, 19);
}
}
}
}
return 0;
}

View File

@@ -53,17 +53,21 @@ static int update(UPDATE_FUNC_ARGS)
curlen = parts[i].tmp;
else
curlen = 10;
int r, nxx, nyy, len, nxi, nyi, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SPRK) {
for (nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; ; nyy+=nyi, nxx+=nxi, len++) {
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>curlen) {
if (TYP(r)==PT_SPRK)
{
for (auto nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; ; nyy+=nyi, nxx+=nxi, len++)
{
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>curlen)
{
break;
}
r = pmap[y+nyi+nyy][x+nxi+nxx];
@@ -76,5 +80,7 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -50,12 +50,13 @@ void Element::Element_FRZW()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_WATR && sim->rng.chance(1, 14))
@@ -63,6 +64,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
}
}
}
}
if ((parts[i].life==0 && sim->rng.chance(1, 192)) || sim->rng.chance(100-parts[i].life, 50000))
{
sim->part_change_type(i,x,y,PT_ICEI);

View File

@@ -48,12 +48,13 @@ void Element::Element_FRZZ()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_WATR && sim->rng.chance(1, 20))
@@ -64,5 +65,7 @@ static int update(UPDATE_FUNC_ARGS)
return 1;
}
}
}
}
return 0;
}

View File

@@ -49,9 +49,8 @@ void Element::Element_FSEP()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life<=0) {
r = sim->create_part(i, x, y, PT_PLSM);
auto r = sim->create_part(i, x, y, PT_PLSM);
if (r!=-1)
parts[r].life = 50;
return 1;
@@ -59,17 +58,19 @@ static int update(UPDATE_FUNC_ARGS)
else if (parts[i].life < 40) {
parts[i].life--;
if (sim->rng.chance(1, 10)) {
r = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_PLSM);
auto r = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_PLSM);
if (r>-1)
parts[r].life = 50;
}
}
else {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && parts[i].life>40 && sim->rng.chance(1, 15))
@@ -77,6 +78,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 39;
}
}
}
}
}
return 0;
}

View File

@@ -50,9 +50,8 @@ void Element::Element_FUSE()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life<=0) {
r = sim->create_part(i, x, y, PT_PLSM);
auto r = sim->create_part(i, x, y, PT_PLSM);
if (r>-1)
parts[r].life = 50;
return 1;
@@ -60,7 +59,7 @@ static int update(UPDATE_FUNC_ARGS)
else if (parts[i].life < 40) {
parts[i].life--;
if (sim->rng.chance(1, 100)) {
r = sim->create_part(-1, x + sim->rng.chance(-1, 1), y + sim->rng.chance(-1, 1), PT_PLSM);
auto r = sim->create_part(-1, x + sim->rng.chance(-1, 1), y + sim->rng.chance(-1, 1), PT_PLSM);
if (r>-1)
parts[r].life = 50;
}
@@ -74,11 +73,13 @@ static int update(UPDATE_FUNC_ARGS)
else if (parts[i].tmp<40)
parts[i].tmp--;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+700.0f) && sim->rng.chance(1, 20)))
@@ -87,5 +88,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 39;
}
}
}
}
return 0;
}

View File

@@ -50,26 +50,24 @@ void Element::Element_GBMB()
static int update(UPDATE_FUNC_ARGS)
{
int rx,ry,r;
if (parts[i].life<=0)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK)
auto r = pmap[y+ry][x+rx];
if(!r)
continue;
if(TYP(r)!=PT_BOMB && TYP(r)!=PT_GBMB &&
TYP(r)!=PT_CLNE && TYP(r)!=PT_PCLN &&
TYP(r)!=PT_DMND)
{
r = pmap[y+ry][x+rx];
if(!r)
continue;
if(TYP(r)!=PT_BOMB && TYP(r)!=PT_GBMB &&
TYP(r)!=PT_CLNE && TYP(r)!=PT_PCLN &&
TYP(r)!=PT_DMND)
{
parts[i].life=60;
break;
}
parts[i].life=60;
break;
}
}
}
}
if (parts[i].life>20)
sim->gravmap[(y/CELL)*XCELLS+(x/CELL)] = 20;

View File

@@ -50,22 +50,22 @@ void Element::Element_GEL()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
bool gel;
if (parts[i].tmp > 100)
parts[i].tmp = 100;
if (parts[i].tmp < 0)
parts[i].tmp = 0;
int absorbChanceDenom = parts[i].tmp * 10 + 500;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
gel=false;
r = pmap[y+ry][x+rx];
auto gel=false;
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
//Desaturation
switch (rt)
{
@@ -150,6 +150,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -50,12 +50,13 @@ void Element::Element_GLOW()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_WATR && sim->rng.chance(1, 400))
@@ -66,6 +67,8 @@ static int update(UPDATE_FUNC_ARGS)
return 1;
}
}
}
}
int ctype = int(sim->pv[y/CELL][x/CELL]*16);
if (ctype < 0)
ctype = 0;

View File

@@ -51,17 +51,17 @@ void Element::Element_GOLD()
static int update(UPDATE_FUNC_ARGS)
{
int rx, ry, r, rndstore;
static int checkCoordsX[] = { -4, 4, 0, 0 };
static int checkCoordsY[] = { 0, 0, -4, 4 };
//Find nearby rusted iron (BMTL with tmp 1+)
for(int j = 0; j < 8; j++){
rndstore = sim->rng.gen();
rx = (rndstore % 9)-4;
for(int j = 0; j < 8; j++)
{
auto rndstore = sim->rng.gen();
auto rx = (rndstore % 9)-4;
rndstore >>= 4;
ry = (rndstore % 9)-4;
if ((!rx != !ry) && BOUNDS_CHECK) {
r = pmap[y+ry][x+rx];
auto ry = (rndstore % 9)-4;
if ((!rx != !ry)) {
auto r = pmap[y+ry][x+rx];
if(!r) continue;
if(TYP(r)==PT_BMTL && parts[ID(r)].tmp)
{
@@ -73,18 +73,17 @@ static int update(UPDATE_FUNC_ARGS)
//Find sparks
if(!parts[i].life)
{
for(int j = 0; j < 4; j++){
rx = checkCoordsX[j];
ry = checkCoordsY[j];
if (BOUNDS_CHECK) {
r = pmap[y+ry][x+rx];
if(!r) continue;
if(TYP(r)==PT_SPRK && parts[ID(r)].life && parts[ID(r)].life<4)
{
sim->part_change_type(i, x, y, PT_SPRK);
parts[i].life = 4;
parts[i].ctype = PT_GOLD;
}
for(int j = 0; j < 4; j++)
{
auto rx = checkCoordsX[j];
auto ry = checkCoordsY[j];
auto r = pmap[y+ry][x+rx];
if(!r) continue;
if(TYP(r)==PT_SPRK && parts[ID(r)].life && parts[ID(r)].life<4)
{
sim->part_change_type(i, x, y, PT_SPRK);
parts[i].life = 4;
parts[i].ctype = PT_GOLD;
}
}
}

View File

@@ -51,7 +51,6 @@ void Element::Element_GPMP()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life!=10)
{
if (parts[i].life>0)
@@ -65,11 +64,13 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].temp = -256.0f+273.15f;
sim->gravmap[(y/CELL)*XCELLS+(x/CELL)] = 0.2f*(parts[i].temp-273.15);
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_GPMP)
@@ -80,6 +81,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].life = 10;
}
}
}
}
}
return 0;
}

View File

@@ -47,15 +47,16 @@ void Element::Element_H2()
static int update(UPDATE_FUNC_ARGS)
{
int r,rx,ry,rt;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if (sim->pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure
{
sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR);
@@ -90,6 +91,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
if (parts[i].temp > 2273.15 && sim->pv[y/CELL][x/CELL] > 50.0f)
{
if (sim->rng.chance(1, 5))
@@ -115,7 +118,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[j].temp = temp;
parts[j].tmp = 0x1;
}
rx = x + sim->rng.between(-1, 1), ry = y + sim->rng.between(-1, 1), rt = TYP(pmap[ry][rx]);
auto rx = x + sim->rng.between(-1, 1), ry = y + sim->rng.between(-1, 1), rt = TYP(pmap[ry][rx]);
if (sim->can_move[PT_PLSM][rt] || rt == PT_H2)
{
j = sim->create_part(-3,rx,ry,PT_PLSM);

View File

@@ -49,7 +49,6 @@ void Element::Element_HSWC()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life!=10)
{
if (parts[i].life>0)
@@ -58,11 +57,13 @@ static int update(UPDATE_FUNC_ARGS)
else
{
bool deserializeTemp = parts[i].tmp == 1;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
r = sim->photons[y+ry][x+rx];
if (!r)
@@ -84,6 +85,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
return 0;
}

View File

@@ -50,16 +50,17 @@ void Element::Element_ICEI()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW
{
parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP);
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SALT || TYP(r)==PT_SLTW)
@@ -77,5 +78,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].ctype = PT_FRZW;
}
}
}
}
return 0;
}

View File

@@ -49,22 +49,25 @@ void Element::Element_IGNT()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
if(parts[i].tmp==0)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_SPRK || rt==PT_LIGH || (rt==PT_IGNT && parts[ID(r)].life==1))
{
parts[i].tmp = 1;
}
}
}
}
}
else if(parts[i].life > 0)
{

View File

@@ -47,14 +47,15 @@ void Element::Element_IRON()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life)
return 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
switch (TYP(r))
{
case PT_SALT:
@@ -79,6 +80,8 @@ static int update(UPDATE_FUNC_ARGS)
break;
}
}
}
}
return 0;
succ:
sim->part_change_type(i,x,y,PT_BMTL);

View File

@@ -49,7 +49,7 @@ void Element::Element_LCRY()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, check, setto;
int check, setto;
switch (parts[i].tmp)
{
case 1:
@@ -85,11 +85,13 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 0;
return 0;
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_LCRY && parts[ID(r)].tmp == check)
@@ -97,6 +99,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].tmp = setto;
}
}
}
}
return 0;
}

View File

@@ -96,7 +96,7 @@ static int update(UPDATE_FUNC_ARGS)
{
for (int ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int r = pmap[y+ry][x+rx];
if (!r)

View File

@@ -67,9 +67,7 @@ static int update(UPDATE_FUNC_ARGS)
*
* tmp - angle of lighting, measured in degrees counterclockwise from the positive x direction
*/
int r,rx,ry,rt, multipler, powderful;
float angle, angle2=-1;
powderful = int(parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER);
auto powderful = int(parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER);
//Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
if (sim->aheat_enable)
{
@@ -81,14 +79,16 @@ static int update(UPDATE_FUNC_ARGS)
sim->hv[y/CELL][x/CELL] = MAX_TEMP;
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if ((surround_space || sim->elements[rt].Explosive) &&
(rt!=PT_SPNG || parts[ID(r)].life==0) &&
sim->elements[rt].Flammable && sim->rng.chance(sim->elements[rt].Flammable + int(sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f), 1000))
@@ -152,6 +152,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->pv[y/CELL][x/CELL] += powderful/400;
if (sim->elements[TYP(r)].HeatConduct) parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful/1.3, MIN_TEMP, MAX_TEMP);
}
}
}
// Deferred branch or bend; or in removal countdown stage
if (parts[i].tmp2 == 1 || parts[i].tmp2 == 3 || (parts[i].tmp2 >= 6 && parts[i].tmp2 <= 8))
{
@@ -167,14 +169,14 @@ static int update(UPDATE_FUNC_ARGS)
sim->kill_part(i);
return 1;
}
angle = float((parts[i].tmp + sim->rng.between(-30, 30)) % 360);
multipler = int(parts[i].life * 1.5) + sim->rng.between(0, parts[i].life);
rx=int(cos(angle*TPT_PI_FLT/180)*multipler);
ry=int(-sin(angle*TPT_PI_FLT/180)*multipler);
auto angle = float((parts[i].tmp + sim->rng.between(-30, 30)) % 360);
auto multipler = int(parts[i].life * 1.5) + sim->rng.between(0, parts[i].life);
auto rx=int(cos(angle*TPT_PI_FLT/180)*multipler);
auto ry=int(-sin(angle*TPT_PI_FLT/180)*multipler);
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, int(angle), parts[i].tmp2, i);
if (parts[i].tmp2 == 2)// && pNear == -1)
{
angle2 = float(((int)angle + sim->rng.between(-100, 100)) % 360);
auto angle2 = float(((int)angle + sim->rng.between(-100, 100)) % 360);
rx=int(cos(angle2*TPT_PI_FLT/180)*multipler);
ry=int(-sin(angle2*TPT_PI_FLT/180)*multipler);
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, int(angle2), parts[i].tmp2, i);

View File

@@ -80,7 +80,7 @@ static int update(UPDATE_FUNC_ARGS)
{
for (int ry = -2; ry <= 2; ++ry)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int neighborData = pmap[y + ry][x + rx];
if (!neighborData)
@@ -198,7 +198,7 @@ static int update(UPDATE_FUNC_ARGS)
{
int rx = sim->rng.between(-3, 3);
int ry = sim->rng.between(-3, 3);
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int neighborData = pmap[y + ry][x + rx];
if (TYP(neighborData) != PT_LITH)

View File

@@ -56,8 +56,10 @@ static int update(UPDATE_FUNC_ARGS)
{
parts[i].life = 0;
for (int rx = -2; rx <= 2; rx++)
{
for (int ry = -2; ry <= 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
if (rx || ry)
{
int r = pmap[y + ry][x + rx];
if (!r)
@@ -74,14 +76,17 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(ID(r), x + rx, y + ry, PT_SPRK);
}
}
}
}
}
}
bool doSerialization = false;
bool doDeserialization = false;
int life = 0;
for (int rx = -rd; rx < rd + 1; rx++)
{
for (int ry = -rd; ry < rd + 1; ry++)
{
if (x + rx >= 0 && y + ry >= 0 && x + rx < XRES && y + ry < YRES && (rx || ry))
{
int r = pmap[y + ry][x + rx];
@@ -120,10 +125,14 @@ static int update(UPDATE_FUNC_ARGS)
break;
}
}
}
}
for (int rx = -1; rx <= 1; rx++)
{
for (int ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
if (rx || ry)
{
int r = pmap[y + ry][x + rx];
if (!r)
@@ -152,6 +161,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].life = life - 0x10000000;
}
}
}
}
return 0;
}

View File

@@ -49,7 +49,6 @@ void Element::Element_MERC()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade, np;
// Max number of particles that can be condensed into one
const int absorbScale = 10000;
// Obscure division by 0 fix
@@ -70,11 +69,13 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].tmp < maxtmp)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r || (parts[i].tmp >=maxtmp))
continue;
if (TYP(r)==PT_MERC&& sim->rng.chance(1, 3))
@@ -86,18 +87,23 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
else
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (parts[i].tmp<=maxtmp)
continue;
if ((!r)&&parts[i].tmp>=1)//if nothing then create MERC
{
np = sim->create_part(-1,x+rx,y+ry,PT_MERC);
auto np = sim->create_part(-1,x+rx,y+ry,PT_MERC);
if (np<0) continue;
parts[i].tmp--;
parts[np].temp = parts[i].temp;
@@ -105,13 +111,16 @@ static int update(UPDATE_FUNC_ARGS)
parts[np].dcolour = parts[i].dcolour;
}
}
for ( trade = 0; trade<4; trade ++)
}
}
}
for (auto trade = 0; trade<4; trade ++)
{
rx = sim->rng.between(-2, 2);
ry = sim->rng.between(-2, 2);
if (BOUNDS_CHECK && (rx || ry))
auto rx = sim->rng.between(-2, 2);
auto ry = sim->rng.between(-2, 2);
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_MERC&&(parts[i].tmp>parts[ID(r)].tmp)&&parts[i].tmp>0)//diffusion

View File

@@ -54,121 +54,121 @@ void Element::Element_NEUT()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
unsigned int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL];
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK)
for (int rx = -1; rx <= 1; rx++)
{
for (int ry = -1; ry <= 1; ry++)
{
auto r = pmap[y+ry][x+rx];
switch (TYP(r))
{
r = pmap[y+ry][x+rx];
switch (TYP(r))
case PT_WATR:
if (sim->rng.chance(3, 20))
sim->part_change_type(ID(r),x+rx,y+ry,PT_DSTW);
case PT_ICEI:
case PT_SNOW:
parts[i].vx *= 0.995f;
parts[i].vy *= 0.995f;
break;
case PT_PLUT:
if (sim->rng.chance(pressureFactor, 1000))
{
case PT_WATR:
if (sim->rng.chance(3, 20))
sim->part_change_type(ID(r),x+rx,y+ry,PT_DSTW);
case PT_ICEI:
case PT_SNOW:
parts[i].vx *= 0.995f;
parts[i].vy *= 0.995f;
break;
case PT_PLUT:
if (sim->rng.chance(pressureFactor, 1000))
if (sim->rng.chance(1, 3))
{
if (sim->rng.chance(1, 3))
{
sim->create_part(ID(r), x+rx, y+ry, sim->rng.chance(2, 3) ? PT_LAVA : PT_URAN);
parts[ID(r)].temp = MAX_TEMP;
if (parts[ID(r)].type==PT_LAVA) {
parts[ID(r)].tmp = 100;
parts[ID(r)].ctype = PT_PLUT;
}
sim->create_part(ID(r), x+rx, y+ry, sim->rng.chance(2, 3) ? PT_LAVA : PT_URAN);
parts[ID(r)].temp = MAX_TEMP;
if (parts[ID(r)].type==PT_LAVA) {
parts[ID(r)].tmp = 100;
parts[ID(r)].ctype = PT_PLUT;
}
else
{
sim->create_part(ID(r), x+rx, y+ry, PT_NEUT);
parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx;
parts[ID(r)].vy = 0.25f*parts[ID(r)].vy + parts[i].vy;
}
sim->pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
Element_FIRE_update(UPDATE_FUNC_SUBCALL_ARGS);
}
break;
case PT_DEUT:
if (sim->rng.chance(pressureFactor + 1 + (parts[ID(r)].life/100), 1000))
{
DeutExplosion(sim, parts[ID(r)].life, x+rx, y+ry, restrict_flt(parts[ID(r)].temp + parts[ID(r)].life*500.0f, MIN_TEMP, MAX_TEMP), PT_NEUT);
sim->kill_part(ID(r));
}
break;
case PT_GUNP:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_DUST);
break;
case PT_DYST:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_YEST);
break;
case PT_YEST:
sim->part_change_type(ID(r),x+rx,y+ry,PT_DYST);
break;
case PT_PLEX:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_GOO);
break;
case PT_NITR:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_DESL);
break;
case PT_PLNT:
if (sim->rng.chance(1, 20))
sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
break;
case PT_DESL:
case PT_OIL:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_GAS);
break;
case PT_COAL:
if (sim->rng.chance(1, 20))
sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
break;
case PT_BCOL:
if (sim->rng.chance(1, 20))
sim->create_part(ID(r), x+rx, y+ry, PT_SAWD);
break;
case PT_DUST:
if (sim->rng.chance(1, 20))
sim->part_change_type(ID(r), x+rx, y+ry, PT_FWRK);
break;
case PT_FWRK:
if (sim->rng.chance(1, 20))
parts[ID(r)].ctype = PT_DUST;
break;
case PT_ACID:
if (sim->rng.chance(1, 20))
sim->create_part(ID(r), x+rx, y+ry, PT_ISOZ);
break;
case PT_TTAN:
if (sim->rng.chance(1, 20))
{
sim->kill_part(i);
return 1;
}
break;
case PT_EXOT:
if (sim->rng.chance(1, 20))
parts[ID(r)].life = 1500;
break;
case PT_RFRG:
if (sim->rng.chance(1, 2))
sim->create_part(ID(r), x+rx, y+ry, PT_GAS);
else
sim->create_part(ID(r), x+rx, y+ry, PT_CAUS);
break;
default:
break;
{
sim->create_part(ID(r), x+rx, y+ry, PT_NEUT);
parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx;
parts[ID(r)].vy = 0.25f*parts[ID(r)].vy + parts[i].vy;
}
sim->pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
Element_FIRE_update(UPDATE_FUNC_SUBCALL_ARGS);
}
break;
case PT_DEUT:
if (sim->rng.chance(pressureFactor + 1 + (parts[ID(r)].life/100), 1000))
{
DeutExplosion(sim, parts[ID(r)].life, x+rx, y+ry, restrict_flt(parts[ID(r)].temp + parts[ID(r)].life*500.0f, MIN_TEMP, MAX_TEMP), PT_NEUT);
sim->kill_part(ID(r));
}
break;
case PT_GUNP:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_DUST);
break;
case PT_DYST:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_YEST);
break;
case PT_YEST:
sim->part_change_type(ID(r),x+rx,y+ry,PT_DYST);
break;
case PT_PLEX:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_GOO);
break;
case PT_NITR:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_DESL);
break;
case PT_PLNT:
if (sim->rng.chance(1, 20))
sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
break;
case PT_DESL:
case PT_OIL:
if (sim->rng.chance(3, 200))
sim->part_change_type(ID(r),x+rx,y+ry,PT_GAS);
break;
case PT_COAL:
if (sim->rng.chance(1, 20))
sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
break;
case PT_BCOL:
if (sim->rng.chance(1, 20))
sim->create_part(ID(r), x+rx, y+ry, PT_SAWD);
break;
case PT_DUST:
if (sim->rng.chance(1, 20))
sim->part_change_type(ID(r), x+rx, y+ry, PT_FWRK);
break;
case PT_FWRK:
if (sim->rng.chance(1, 20))
parts[ID(r)].ctype = PT_DUST;
break;
case PT_ACID:
if (sim->rng.chance(1, 20))
sim->create_part(ID(r), x+rx, y+ry, PT_ISOZ);
break;
case PT_TTAN:
if (sim->rng.chance(1, 20))
{
sim->kill_part(i);
return 1;
}
break;
case PT_EXOT:
if (sim->rng.chance(1, 20))
parts[ID(r)].life = 1500;
break;
case PT_RFRG:
if (sim->rng.chance(1, 2))
sim->create_part(ID(r), x+rx, y+ry, PT_GAS);
else
sim->create_part(ID(r), x+rx, y+ry, PT_CAUS);
break;
default:
break;
}
}
}
return 0;
}

View File

@@ -47,12 +47,13 @@ void Element::Element_O2()
static int update(UPDATE_FUNC_ARGS)
{
int r,rx,ry;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
@@ -74,6 +75,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].tmp |= 2;
}
}
}
}
if (parts[i].temp > 9973.15 && sim->pv[y/CELL][x/CELL] > 250.0f)
{
int gravPos = ((y/CELL)*XCELLS)+(x/CELL);
@@ -95,7 +98,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[j].temp = MAX_TEMP;
parts[j].tmp = 0x1;
}
rx = x + sim->rng.between(-1, 1), ry = y + sim->rng.between(-1, 1), r = TYP(pmap[ry][rx]);
auto rx = x + sim->rng.between(-1, 1), ry = y + sim->rng.between(-1, 1), r = TYP(pmap[ry][rx]);
if (sim->can_move[PT_PLSM][r] || r == PT_O2)
{
j = sim->create_part(-3,rx,ry,PT_PLSM);

View File

@@ -54,7 +54,6 @@ constexpr float ADVECTION = 0.1f;
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
if (!parts[i].tmp2 && sim->pv[y/CELL][x/CELL]>4.0f)
parts[i].tmp2 = sim->rng.between(80, 119);
if (parts[i].tmp2)
@@ -68,27 +67,30 @@ static int update(UPDATE_FUNC_ARGS)
}
}
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK)
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
auto r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
auto rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_SPRK &&
rt!=PT_NSCN && rt!=PT_PSCN &&
rt!=PT_STKM && rt!=PT_STKM2 &&
rt!=PT_PBCN && rt<PT_NUM)
{
r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_SPRK &&
rt!=PT_NSCN && rt!=PT_PSCN &&
rt!=PT_STKM && rt!=PT_STKM2 &&
rt!=PT_PBCN && rt<PT_NUM)
{
parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[ID(r)].ctype;
}
parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[ID(r)].ctype;
}
}
}
}
if (parts[i].life!=10)
{
if (parts[i].life>0)
@@ -96,11 +98,13 @@ static int update(UPDATE_FUNC_ARGS)
}
else
{
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_PBCN)
@@ -111,11 +115,15 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].life = 10;
}
}
}
}
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled)
{
if (parts[i].ctype==PT_PHOT) {//create photons a different way
for (rx=-1; rx<2; rx++)
for (ry = -1; ry < 2; ry++)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
int r = sim->create_part(-1, x + rx, y + ry, PT_PHOT);
@@ -130,12 +138,19 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
else if (parts[i].ctype==PT_LIFE)//create life a different way
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
sim->create_part(-1, x+rx, y+ry, PT_LIFE, parts[i].tmp);
}
}
}
else if (parts[i].ctype!=PT_LIGH || sim->rng.chance(1, 30))
{
int np = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), TYP(parts[i].ctype));

View File

@@ -52,14 +52,15 @@ void Element::Element_PCLN()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SPRK)
@@ -80,33 +81,40 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 10;
}
}
}
}
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK)
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
auto r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
auto rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_SPRK &&
rt!=PT_NSCN && rt!=PT_PSCN &&
rt!=PT_STKM && rt!=PT_STKM2 &&
rt!=PT_PBCN && rt<PT_NUM)
{
r = sim->photons[y+ry][x+rx];
if (!r)
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_SPRK &&
rt!=PT_NSCN && rt!=PT_PSCN &&
rt!=PT_STKM && rt!=PT_STKM2 &&
rt!=PT_PBCN && rt<PT_NUM)
{
parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[ID(r)].ctype;
}
parts[i].ctype = rt;
if (rt==PT_LIFE || rt==PT_LAVA)
parts[i].tmp = parts[ID(r)].ctype;
}
}
}
}
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10)
{
if (parts[i].ctype==PT_PHOT) {//create photons a different way
for (rx=-1; rx<2; rx++)
for (ry = -1; ry < 2; ry++)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
int r = sim->create_part(-1, x + rx, y + ry, PT_PHOT);
@@ -121,12 +129,19 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
else if (parts[i].ctype==PT_LIFE)//create life a different way
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
sim->create_part(-1, x+rx, y+ry, PT_LIFE, parts[i].tmp);
}
}
}
else if (parts[i].ctype != PT_LIGH || sim->rng.chance(1, 30))
{
int np = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), TYP(parts[i].ctype));

View File

@@ -56,8 +56,6 @@ void Element::Element_PHOT()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
float rr, rrr;
if (!(parts[i].ctype&0x3FFFFFFF)) {
sim->kill_part(i);
return 1;
@@ -65,54 +63,57 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].temp > 506)
if (sim->rng.chance(1, 10))
Element_FIRE_update(UPDATE_FUNC_SUBCALL_ARGS);
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK) {
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_ISOZ || TYP(r)==PT_ISZS)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_ISOZ || TYP(r)==PT_ISZS)
{
if (sim->rng.chance(1, 400))
{
if (sim->rng.chance(1, 400))
{
parts[i].vx *= 0.90f;
parts[i].vy *= 0.90f;
sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
rrr = sim->rng.between(0, 359) * 3.14159f / 180.0f;
if (TYP(r) == PT_ISOZ)
rr = sim->rng.between(128, 255) / 127.0f;
else
rr = sim->rng.between(128, 355) / 127.0f;
parts[ID(r)].vx = rr*cosf(rrr);
parts[ID(r)].vy = rr*sinf(rrr);
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
}
}
else if((TYP(r) == PT_QRTZ || TYP(r) == PT_PQRT) && !ry && !rx)//if on QRTZ
{
float a = sim->rng.between(0, 359) * 3.14159f / 180.0f;
parts[i].vx = 3.0f*cosf(a);
parts[i].vy = 3.0f*sinf(a);
if(parts[i].ctype == 0x3FFFFFFF)
parts[i].ctype = 0x1F << sim->rng.between(0, 25);
if (parts[i].life)
parts[i].life++; //Delay death
}
else if(TYP(r) == PT_BGLA && !ry && !rx)//if on BGLA
{
float a = sim->rng.between(-50, 50) * 0.001f;
float rx = cosf(a), ry = sinf(a), vx, vy;
vx = rx * parts[i].vx + ry * parts[i].vy;
vy = rx * parts[i].vy - ry * parts[i].vx;
parts[i].vx = vx;
parts[i].vy = vy;
}
else if (TYP(r) == PT_FILT && parts[ID(r)].tmp==9)
{
parts[i].vx += ((float)sim->rng.between(-500, 500))/1000.0f;
parts[i].vy += ((float)sim->rng.between(-500, 500))/1000.0f;
parts[i].vx *= 0.90f;
parts[i].vy *= 0.90f;
sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
auto rrr = sim->rng.between(0, 359) * 3.14159f / 180.0f;
int rr;
if (TYP(r) == PT_ISOZ)
rr = sim->rng.between(128, 255) / 127.0f;
else
rr = sim->rng.between(128, 355) / 127.0f;
parts[ID(r)].vx = rr*cosf(rrr);
parts[ID(r)].vy = rr*sinf(rrr);
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
}
}
else if((TYP(r) == PT_QRTZ || TYP(r) == PT_PQRT) && !ry && !rx)//if on QRTZ
{
float a = sim->rng.between(0, 359) * 3.14159f / 180.0f;
parts[i].vx = 3.0f*cosf(a);
parts[i].vy = 3.0f*sinf(a);
if(parts[i].ctype == 0x3FFFFFFF)
parts[i].ctype = 0x1F << sim->rng.between(0, 25);
if (parts[i].life)
parts[i].life++; //Delay death
}
else if(TYP(r) == PT_BGLA && !ry && !rx)//if on BGLA
{
float a = sim->rng.between(-50, 50) * 0.001f;
float rx = cosf(a), ry = sinf(a), vx, vy;
vx = rx * parts[i].vx + ry * parts[i].vy;
vy = rx * parts[i].vy - ry * parts[i].vx;
parts[i].vx = vx;
parts[i].vy = vy;
}
else if (TYP(r) == PT_FILT && parts[ID(r)].tmp==9)
{
parts[i].vx += ((float)sim->rng.between(-500, 500))/1000.0f;
parts[i].vy += ((float)sim->rng.between(-500, 500))/1000.0f;
}
}
}
return 0;
}

View File

@@ -123,8 +123,6 @@ static unsigned int nextColor(unsigned int flags)
int Element_PIPE_update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, np;
int rnd, rndstore;
if (parts[i].ctype && !sim->elements[TYP(parts[i].ctype)].Enabled)
parts[i].ctype = 0;
if (parts[i].tmp & PPIP_TMPFLAG_TRIGGERS)
@@ -144,13 +142,13 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
}
if (pause_changed)
{
int rx, ry, r;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (TYP(r) == PT_BRCK)
{
if (parts[i].tmp & PPIP_TMPFLAG_PAUSED)
@@ -160,6 +158,7 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
}
}
}
}
}
if (parts[i].tmp & PPIP_TMPFLAG_TRIGGER_REVERSE)
@@ -188,12 +187,14 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
int neighborcount = 0;
int count = 0;
// make automatic pipe pattern
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
count++;
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r) != PT_PIPE && TYP(r) != PT_PPIP)
@@ -224,6 +225,8 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
lastneighbor = ID(r);
}
}
}
}
if (neighborcount == 1)
parts[lastneighbor].tmp |= 0x100;
}
@@ -240,50 +243,47 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
if (nt)//there is something besides PIPE around current particle
{
rndstore = sim->rng.gen();
rnd = rndstore&7;
//rndstore = rndstore>>3;
rx = Element_PIPE_offsets[rnd].X;
ry = Element_PIPE_offsets[rnd].Y;
if (BOUNDS_CHECK)
auto rndstore = sim->rng.gen();
auto rnd = rndstore&7;
auto rx = Element_PIPE_offsets[rnd].X;
auto ry = Element_PIPE_offsets[rnd].Y;
auto r = pmap[y+ry][x+rx];
if(!r)
r = sim->photons[y+ry][x+rx];
if (surround_space && !r && TYP(parts[i].ctype)) //creating at end
{
r = pmap[y+ry][x+rx];
if(!r)
r = sim->photons[y+ry][x+rx];
if (surround_space && !r && TYP(parts[i].ctype)) //creating at end
auto np = sim->create_part(-1, x+rx, y+ry, TYP(parts[i].ctype));
if (np!=-1)
{
np = sim->create_part(-1, x+rx, y+ry, TYP(parts[i].ctype));
if (np!=-1)
{
Element_PIPE_transfer_pipe_to_part(sim, parts+i, parts+np, false);
}
}
//try eating particle at entrance
else if (!TYP(parts[i].ctype) && (sim->elements[TYP(r)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
{
if (TYP(r)==PT_SOAP)
Element_SOAP_detach(sim, ID(r));
transfer_part_to_pipe(parts+(ID(r)), parts+i);
sim->kill_part(ID(r));
}
else if (!TYP(parts[i].ctype) && TYP(r)==PT_STOR && sim->IsElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
{
// STOR stores properties in the same places as PIPE does
transfer_pipe_to_pipe(parts+(ID(r)), parts+i, true);
Element_PIPE_transfer_pipe_to_part(sim, parts+i, parts+np, false);
}
}
//try eating particle at entrance
else if (!TYP(parts[i].ctype) && (sim->elements[TYP(r)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
{
if (TYP(r)==PT_SOAP)
Element_SOAP_detach(sim, ID(r));
transfer_part_to_pipe(parts+(ID(r)), parts+i);
sim->kill_part(ID(r));
}
else if (!TYP(parts[i].ctype) && TYP(r)==PT_STOR && sim->IsElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
{
// STOR stores properties in the same places as PIPE does
transfer_pipe_to_pipe(parts+(ID(r)), parts+i, true);
}
}
}
}
else if (!(parts[i].tmp&(PFLAG_COLORS|PFLAG_INITIALIZING)) && parts[i].life<=10)
{
// make a border
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
{
// BRCK border
@@ -293,6 +293,7 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
}
}
}
}
if (parts[i].life <= 1)
parts[i].tmp |= PFLAG_INITIALIZING;
}
@@ -301,25 +302,33 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
{
if (!parts[i].life)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
if (!pmap[y+ry][x+rx] && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_ALLOWAIR && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_WALL && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_WALLELEC && (sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_EWALL || sim->emap[(y+ry)/CELL][(x+rx)/CELL]))
parts[i].life=50;
}
}
}
}
else if (parts[i].life==5)//check for beginning of pipe single pixel
{
int issingle = 1;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && parts[i].life)
issingle = 0;
}
}
}
if (issingle)
parts[i].tmp |= 0x100;
}
@@ -467,60 +476,56 @@ static void transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STOR)
static void pushParticle(Simulation * sim, int i, int count, int original)
{
int rndstore, rnd, rx, ry, r, x, y, np, q;
unsigned int notctype = nextColor(sim->parts[i].tmp);
if (!TYP(sim->parts[i].ctype) || count >= 2)//don't push if there is nothing there, max speed of 2 per frame
return;
x = (int)(sim->parts[i].x+0.5f);
y = (int)(sim->parts[i].y+0.5f);
auto x = (int)(sim->parts[i].x+0.5f);
auto y = (int)(sim->parts[i].y+0.5f);
if( !(sim->parts[i].tmp&0x200) )
{
//normal random push
rndstore = sim->rng.gen();
auto rndstore = sim->rng.gen();
// RAND_MAX is at least 32767 on all platforms i.e. pow(8,5)-1
// so can go 5 cycles without regenerating rndstore
// (although now we use our own randomizer so maybe should reevaluate all the rndstore usages in every element)
for (q=0; q<3; q++)//try to push 3 times
for (auto q=0; q<3; q++)//try to push 3 times
{
rnd = rndstore&7;
auto rnd = rndstore&7;
rndstore = rndstore>>3;
rx = Element_PIPE_offsets[rnd].X;
ry = Element_PIPE_offsets[rnd].Y;
if (BOUNDS_CHECK)
auto rx = Element_PIPE_offsets[rnd].X;
auto ry = Element_PIPE_offsets[rnd].Y;
auto r = sim->pmap[y+ry][x+rx];
if (!r)
continue;
else if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && (sim->parts[ID(r)].tmp&PFLAG_COLORS) != notctype && !TYP(sim->parts[ID(r)].ctype))
{
r = sim->pmap[y+ry][x+rx];
if (!r)
continue;
else if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && (sim->parts[ID(r)].tmp&PFLAG_COLORS) != notctype && !TYP(sim->parts[ID(r)].ctype))
{
transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)), false);
if (ID(r) > original)
sim->parts[ID(r)].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed
count++;
pushParticle(sim, ID(r),count,original);
}
else if (TYP(r) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
{
int portaltmp = sim->parts[ID(r)].tmp;
if (portaltmp >= CHANNELS)
portaltmp = CHANNELS-1;
else if (portaltmp < 0)
portaltmp = 0;
for (int nnx = 0; nnx < 80; nnx++)
if (!sim->portalp[portaltmp][count][nnx].type)
{
Element_PIPE_transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[portaltmp][count][nnx]), false);
count++;
break;
}
}
transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)), false);
if (ID(r) > original)
sim->parts[ID(r)].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed
count++;
pushParticle(sim, ID(r),count,original);
}
else if (TYP(r) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
{
int portaltmp = sim->parts[ID(r)].tmp;
if (portaltmp >= CHANNELS)
portaltmp = CHANNELS-1;
else if (portaltmp < 0)
portaltmp = 0;
for (int nnx = 0; nnx < 80; nnx++)
if (!sim->portalp[portaltmp][count][nnx].type)
{
Element_PIPE_transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[portaltmp][count][nnx]), false);
count++;
break;
}
}
}
}
else //predefined 1 pixel thick pipe movement
{
int coords = 7 - ((sim->parts[i].tmp>>10)&7);
r = sim->pmap[y+ Element_PIPE_offsets[coords].Y][x+ Element_PIPE_offsets[coords].X];
auto r = sim->pmap[y+ Element_PIPE_offsets[coords].Y][x+ Element_PIPE_offsets[coords].X];
if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && (sim->parts[ID(r)].tmp&PFLAG_COLORS) != notctype && !TYP(sim->parts[ID(r)].ctype))
{
transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)), false);
@@ -546,9 +551,9 @@ static void pushParticle(Simulation * sim, int i, int count, int original)
}
else if (!r) //Move particles out of pipe automatically, much faster at ends
{
rx = Element_PIPE_offsets[coords].X;
ry = Element_PIPE_offsets[coords].Y;
np = sim->create_part(-1,x+rx,y+ry,TYP(sim->parts[i].ctype));
auto rx = Element_PIPE_offsets[coords].X;
auto ry = Element_PIPE_offsets[coords].Y;
auto np = sim->create_part(-1,x+rx,y+ry,TYP(sim->parts[i].ctype));
if (np!=-1)
{
Element_PIPE_transfer_pipe_to_part(sim, sim->parts+i, sim->parts+np, false);

View File

@@ -51,18 +51,19 @@ void Element::Element_PLNT()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, np, rndstore;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
switch (TYP(r))
{
case PT_WATR:
if (sim->rng.chance(1, 50))
{
np = sim->create_part(ID(r),x+rx,y+ry,PT_PLNT);
auto np = sim->create_part(ID(r),x+rx,y+ry,PT_PLNT);
if (np<0) continue;
parts[np].life = 0;
}
@@ -83,20 +84,22 @@ static int update(UPDATE_FUNC_ARGS)
}
break;
case PT_WOOD:
rndstore = sim->rng.gen();
if (surround_space && !(rndstore%4) && parts[i].tmp==1)
{
rndstore >>= 3;
int nnx = (rndstore%3) -1;
rndstore >>= 2;
int nny = (rndstore%3) -1;
if (nnx || nny)
auto rndstore = sim->rng.gen();
if (surround_space && !(rndstore%4) && parts[i].tmp==1)
{
if (pmap[y+ry+nny][x+rx+nnx])
continue;
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE);
if (np<0) continue;
parts[np].temp = parts[i].temp;
rndstore >>= 3;
int nnx = (rndstore%3) -1;
rndstore >>= 2;
int nny = (rndstore%3) -1;
if (nnx || nny)
{
if (pmap[y+ry+nny][x+rx+nnx])
continue;
auto np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE);
if (np<0) continue;
parts[np].temp = parts[i].temp;
}
}
}
break;
@@ -104,16 +107,22 @@ static int update(UPDATE_FUNC_ARGS)
continue;
}
}
}
}
if (parts[i].life==2)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
sim->create_part(-1,x+rx,y+ry,PT_O2);
}
}
}
parts[i].life = 0;
}
if (parts[i].temp > 350 && parts[i].temp > parts[i].tmp2)

View File

@@ -71,7 +71,7 @@ static int update(UPDATE_FUNC_ARGS)
{
int rx = sim->portal_rx[count];
int ry = sim->portal_ry[count];
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int r = pmap[y+ry][x+rx];
if (!r || TYP(r) == PT_STOR)

View File

@@ -48,105 +48,107 @@ void Element::Element_PRTO()
}
/*these are the count values of where the particle gets stored, depending on where it came from
0 1 2
7 . 3
6 5 4
PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
0 1 2
7 . 3
6 5 4
PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in
PRTO does +/-1 to the count, so it doesn't jam as easily
*/
static int update(UPDATE_FUNC_ARGS)
{
int r, nnx, rx, ry, np, fe = 0;
int count = 0;
int fe = 0;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
for (count=0; count<8; count++)
for (auto count=0; count<8; count++)
{
rx = sim->portal_rx[count];
ry = sim->portal_ry[count];
if (BOUNDS_CHECK && (rx || ry))
auto rx = sim->portal_rx[count];
auto ry = sim->portal_ry[count];
if (rx || ry)
{
auto r = pmap[y+ry][x+rx];
if (!r)
{
r = pmap[y+ry][x+rx];
if (!r)
fe = 1;
for (auto nnx =0 ; nnx<80; nnx++)
{
fe = 1;
for ( nnx =0 ; nnx<80; nnx++)
int randomness = (count + sim->rng.between(-1, 1) + 4) % 8;//add -1,0,or 1 to count
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
{
int randomness = (count + sim->rng.between(-1, 1) + 4) % 8;//add -1,0,or 1 to count
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
sim->create_part(-1,x+1,y,PT_SPRK);
sim->create_part(-1,x+1,y+1,PT_SPRK);
sim->create_part(-1,x+1,y-1,PT_SPRK);
sim->create_part(-1,x,y-1,PT_SPRK);
sim->create_part(-1,x,y+1,PT_SPRK);
sim->create_part(-1,x-1,y+1,PT_SPRK);
sim->create_part(-1,x-1,y,PT_SPRK);
sim->create_part(-1,x-1,y-1,PT_SPRK);
memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
break;
}
else if (sim->portalp[parts[i].tmp][randomness][nnx].type)
{
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
sim->player.spwn = 0;
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
sim->player2.spwn = 0;
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH)
{
sim->create_part(-1,x+1,y,PT_SPRK);
sim->create_part(-1,x+1,y+1,PT_SPRK);
sim->create_part(-1,x+1,y-1,PT_SPRK);
sim->create_part(-1,x,y-1,PT_SPRK);
sim->create_part(-1,x,y+1,PT_SPRK);
sim->create_part(-1,x-1,y+1,PT_SPRK);
sim->create_part(-1,x-1,y,PT_SPRK);
sim->create_part(-1,x-1,y-1,PT_SPRK);
memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
break;
sim->fighcount--;
sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 0;
}
else if (sim->portalp[parts[i].tmp][randomness][nnx].type)
auto np = sim->create_part(-1, x+rx, y+ry, sim->portalp[parts[i].tmp][randomness][nnx].type);
if (np<0)
{
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
sim->player.spwn = 0;
sim->player.spwn = 1;
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
sim->player2.spwn = 0;
sim->player2.spwn = 1;
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH)
{
sim->fighcount--;
sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 0;
}
np = sim->create_part(-1, x+rx, y+ry, sim->portalp[parts[i].tmp][randomness][nnx].type);
if (np<0)
{
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM)
sim->player.spwn = 1;
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2)
sim->player2.spwn = 1;
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH)
{
sim->fighcount++;
sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1;
}
continue;
}
if (parts[np].type==PT_FIGH)
{
// Release the fighters[] element allocated by create_part, the one reserved when the fighter went into the portal will be used
sim->fighters[(unsigned char)parts[np].tmp].spwn = 0;
sim->fighcount++;
sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1;
}
if (sim->portalp[parts[i].tmp][randomness][nnx].vx == 0.0f && sim->portalp[parts[i].tmp][randomness][nnx].vy == 0.0f)
{
// particles that have passed from PIPE into PRTI have lost their velocity, so use the velocity of the newly created particle if the particle in the portal has no velocity
float tmp_vx = parts[np].vx;
float tmp_vy = parts[np].vy;
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
parts[np].vx = tmp_vx;
parts[np].vy = tmp_vy;
}
else
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
parts[np].x = float(x+rx);
parts[np].y = float(y+ry);
memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
break;
continue;
}
if (parts[np].type==PT_FIGH)
{
// Release the fighters[] element allocated by create_part, the one reserved when the fighter went into the portal will be used
sim->fighters[(unsigned char)parts[np].tmp].spwn = 0;
sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1;
}
if (sim->portalp[parts[i].tmp][randomness][nnx].vx == 0.0f && sim->portalp[parts[i].tmp][randomness][nnx].vy == 0.0f)
{
// particles that have passed from PIPE into PRTI have lost their velocity, so use the velocity of the newly created particle if the particle in the portal has no velocity
float tmp_vx = parts[np].vx;
float tmp_vy = parts[np].vy;
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
parts[np].vx = tmp_vx;
parts[np].vy = tmp_vy;
}
else
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
parts[np].x = float(x+rx);
parts[np].y = float(y+ry);
memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
break;
}
}
}
}
}
if (fe) {
if (fe)
{
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
if (!sim->parts[i].life) parts[i].life = sim->rng.gen();
if (!sim->parts[i].ctype) parts[i].ctype = sim->rng.gen();
sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for (r = 0; r < 4; r++) {
if (orbd[r]<254) {
for (auto r = 0; r < 4; r++)
{
if (orbd[r]<254)
{
orbd[r] += 16;
if (orbd[r]>254) {
orbd[r] = 0;
@@ -157,15 +159,17 @@ static int update(UPDATE_FUNC_ARGS)
orbl[r] += 1;
orbl[r] = orbl[r]%255;
}
//orbl[r] += 1;
//orbl[r] = orbl[r]%255;
} else {
}
else
{
orbd[r] = 0;
orbl[r] = sim->rng.between(0, 254);
}
}
sim->orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl);
} else {
}
else
{
parts[i].life = 0;
parts[i].ctype = 0;
}

View File

@@ -48,19 +48,20 @@ void Element::Element_PSNS()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
if ((parts[i].tmp == 0 && sim->pv[y/CELL][x/CELL] > parts[i].temp-273.15f) || (parts[i].tmp == 2 && sim->pv[y/CELL][x/CELL] < parts[i].temp-273.15f))
{
for (rx = -2; rx <= 2; rx++)
for (ry = -2; ry <= 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
{
rt = TYP(r);
auto rt = TYP(r);
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)
{
parts[ID(r)].life = 4;
@@ -69,6 +70,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
if (parts[i].tmp == 1)
{
@@ -76,16 +79,17 @@ static int update(UPDATE_FUNC_ARGS)
float photonWl = sim->pv[y / CELL][x / CELL];
if (setFilt)
{
int nx, ny;
for (rx = -1; rx <= 1; rx++)
for (ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y + ry][x + rx];
auto r = pmap[y + ry][x + rx];
if (!r)
continue;
nx = x + rx;
ny = y + ry;
auto nx = x + rx;
auto ny = y + ry;
while (TYP(r) == PT_FILT)
{
parts[ID(r)].ctype = 0x10000000 + int(round(photonWl) - MIN_PRESSURE);
@@ -96,6 +100,8 @@ static int update(UPDATE_FUNC_ARGS)
r = pmap[ny][nx];
}
}
}
}
}
}
return 0;

View File

@@ -83,14 +83,16 @@ static int update(UPDATE_FUNC_ARGS)
int maxSize = parts[i].tmp ? parts[i].tmp : DEFAULT_LIMIT;
int armLimit = parts[i].tmp2 ? parts[i].tmp2 : DEFAULT_ARM_LIMIT;
int state = 0;
int r, nxx, nyy, nxi, nyi, rx, ry;
int directionX = 0, directionY = 0;
if (state == PISTON_INACTIVE) {
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry) && (!rx || !ry))
if (state == PISTON_INACTIVE)
{
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if ((rx || ry) && (!rx || !ry))
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SPRK && parts[ID(r)].life==3) {
@@ -100,13 +102,18 @@ static int update(UPDATE_FUNC_ARGS)
state = PISTON_RETRACT;
}
}
}
}
}
if(state == PISTON_EXTEND || state == PISTON_RETRACT) {
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry) && (!rx || !ry))
if (state == PISTON_EXTEND || state == PISTON_RETRACT)
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if ((rx || ry) && (!rx || !ry))
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r) == PT_PSTN && !parts[ID(r)].life)
@@ -119,7 +126,9 @@ static int update(UPDATE_FUNC_ARGS)
int armCount = 0;
directionX = rx;
directionY = ry;
for (nxx = 0, nyy = 0, nxi = directionX, nyi = directionY; ; nyy += nyi, nxx += nxi) {
auto nxi = directionX, nyi = directionY;
for (auto nxx = 0, nyy = 0; ; nyy += nyi, nxx += nxi)
{
if (!(x+nxx<XRES && y+nyy<YRES && x+nxx >= 0 && y+nyy >= 0)) {
break;
}
@@ -190,7 +199,8 @@ static int update(UPDATE_FUNC_ARGS)
return 0;
}
}
}
}
}
return 0;
}

View File

@@ -54,7 +54,7 @@ static void wtrv_reactions(int wtrv1_id, UPDATE_FUNC_ARGS)
{
for (int ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int r = pmap[y + ry][x + rx];
if (!r || ID(r) == wtrv1_id)
@@ -79,7 +79,7 @@ static void hygn_reactions(int hygn1_id, UPDATE_FUNC_ARGS)
{
for (int ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int r = pmap[y + ry][x + rx];
if (!r || ID(r) == hygn1_id)
@@ -167,7 +167,7 @@ static int update(UPDATE_FUNC_ARGS)
{
for (int ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int r = pmap[y + ry][x + rx];
if (!r)

View File

@@ -52,7 +52,6 @@ void Element::Element_PUMP()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life != 10)
{
if (parts[i].life>0)
@@ -65,8 +64,9 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].temp <= MIN_PRESSURE+273.15f)
parts[i].temp = MIN_PRESSURE+273.15f;
for (rx = -1; rx <= 1; rx++)
for (ry = -1; ry <= 1; ry++)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (parts[i].tmp != 1)
{
@@ -86,11 +86,14 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
for (rx = -2; rx <= 2; rx++)
for (ry = -2; ry <= 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
}
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r) == PT_PUMP)
@@ -101,6 +104,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].life = 10;
}
}
}
}
}
return 0;
}

View File

@@ -49,14 +49,15 @@ void Element::Element_PVOD()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SPRK)
@@ -77,6 +78,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 10;
}
}
}
}
return 0;
}

View File

@@ -51,7 +51,7 @@ void Element::Element_QRTZ()
int Element_QRTZ_update(UPDATE_FUNC_ARGS)
{
int r, tmp, trade, rx, ry, np, t = parts[i].type;
int t = parts[i].type;
if (t == PT_QRTZ)
{
auto press = int(sim->pv[y/CELL][x/CELL] * 64);
@@ -67,11 +67,14 @@ int Element_QRTZ_update(UPDATE_FUNC_ARGS)
parts[i].life = 5;
// absorb SLTW
if (parts[i].tmp != -1)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
else if (TYP(r)==PT_SLTW && sim->rng.chance(1, 500))
@@ -80,26 +83,28 @@ int Element_QRTZ_update(UPDATE_FUNC_ARGS)
parts[i].tmp++;
}
}
}
}
}
// grow and diffuse
if (parts[i].tmp > 0 && (parts[i].vx*parts[i].vx + parts[i].vy*parts[i].vy)<0.2f && parts[i].life<=0)
{
bool stopgrow = false;
int rnd, sry, srx;
for (trade = 0; trade < 9; trade++)
for (auto trade = 0; trade < 9; trade++)
{
rnd = sim->rng.gen() % 0x3FF;
rx = (rnd%5)-2;
srx = (rnd%3)-1;
auto rnd = sim->rng.gen() % 0x3FF;
auto rx = (rnd%5)-2;
auto srx = (rnd%3)-1;
rnd >>= 3;
ry = (rnd%5)-2;
sry = (rnd%3)-1;
if (BOUNDS_CHECK && (rx || ry))
auto ry = (rnd%5)-2;
auto sry = (rnd%3)-1;
if (rx || ry)
{
if (!stopgrow)//try to grow
{
if (!pmap[y+sry][x+srx] && parts[i].tmp!=0)
{
np = sim->create_part(-1,x+srx,y+sry,PT_QRTZ);
auto np = sim->create_part(-1,x+srx,y+sry,PT_QRTZ);
if (np>-1)
{
parts[np].temp = parts[i].temp;
@@ -127,12 +132,12 @@ int Element_QRTZ_update(UPDATE_FUNC_ARGS)
}
}
//diffusion
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
else if (TYP(r)==PT_QRTZ && (parts[i].tmp>parts[ID(r)].tmp) && parts[ID(r)].tmp>=0)
{
tmp = parts[i].tmp - parts[ID(r)].tmp;
auto tmp = parts[i].tmp - parts[ID(r)].tmp;
if (tmp ==1)
{
parts[ID(r)].tmp++;

View File

@@ -48,12 +48,13 @@ void Element::Element_RIME()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SPRK)
@@ -67,5 +68,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = parts[ID(r)].life;
}
}
}
}
return 0;
}

View File

@@ -47,12 +47,13 @@ void Element::Element_SHLD1()
static int update(UPDATE_FUNC_ARGS)
{
int r, nnx, nny, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
else if (TYP(r)==PT_SPRK&&parts[i].life==0)
@@ -62,8 +63,9 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(i,x,y,PT_SHLD2);
parts[i].life = 7;
}
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)
for (auto nnx = -1; nnx <= 1; nnx++)
{
for (auto nny = -1; nny <= 1; nny++)
{
if (!pmap[y+ry+nny][x+rx+nnx])
{
@@ -71,6 +73,7 @@ static int update(UPDATE_FUNC_ARGS)
//parts[ID(pmap[y+ny+nny][x+nx+nnx])].life=7;
}
}
}
}
else if (TYP(r) == PT_SHLD3 && sim->rng.chance(2, 5))
{
@@ -78,5 +81,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 7;
}
}
}
}
return 0;
}

View File

@@ -47,12 +47,13 @@ void Element::Element_SHLD2()
static int update(UPDATE_FUNC_ARGS)
{
int r, nnx, nny, rx, ry, np;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
{
if (parts[i].life>0)
@@ -66,16 +67,18 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(i,x,y,PT_SHLD3);
parts[i].life = 7;
}
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)
for (auto nnx = -1; nnx <= 1; nnx++)
{
for (auto nny = -1; nny <= 1; nny++)
{
if (!pmap[y+ry+nny][x+rx+nnx])
{
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
auto np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
}
}
}
}
else if (TYP(r) == PT_SHLD4 && sim->rng.chance(2, 5))
{
@@ -83,5 +86,7 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 7;
}
}
}
}
return 0;
}

View File

@@ -47,17 +47,18 @@ void Element::Element_SHLD3()
static int update(UPDATE_FUNC_ARGS)
{
int r, nnx, nny, rx, ry, np;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
{
if (sim->rng.chance(1, 2500))
{
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
auto np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
sim->part_change_type(i,x,y,PT_SHLD2);
@@ -76,18 +77,22 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(i,x,y,PT_SHLD4);
parts[i].life = 7;
}
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)
for (auto nnx = -1; nnx <= 1; nnx++)
{
for (auto nny = -1; nny <= 1; nny++)
{
if (!pmap[y+ry+nny][x+rx+nnx])
{
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
auto np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
}
}
}
}
}
}
}
return 0;
}

View File

@@ -47,17 +47,18 @@ void Element::Element_SHLD4()
static int update(UPDATE_FUNC_ARGS)
{
int r, nnx, nny, rx, ry, np;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
{
if (sim->rng.chance(1, 5500))
{
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
auto np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
sim->part_change_type(i,x,y,PT_SHLD2);
@@ -71,16 +72,22 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].life = 7;
}
else if (TYP(r)==PT_SPRK&&parts[i].life==0)
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)
{
for (auto nnx = -1; nnx <= 1; nnx++)
{
for (auto nny = -1; nny <= 1; nny++)
{
if (!pmap[y+ry+nny][x+rx+nnx])
{
np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
auto np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
if (np<0) continue;
parts[np].life=7;
}
}
}
}
}
}
}
return 0;
}

View File

@@ -49,9 +49,7 @@ void Element::Element_SING()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, cry, crx, spawncount;
int singularity = -parts[i].life;
float angle, v;
if (sim->pv[y/CELL][x/CELL]<singularity)
sim->pv[y/CELL][x/CELL] += 0.1f*(singularity-sim->pv[y/CELL][x/CELL]);
@@ -67,16 +65,18 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].life<1) {
//Pop!
for (rx=-1; rx<2; rx++) {
crx = (x/CELL)+rx;
for (ry=-1; ry<2; ry++) {
cry = (y/CELL)+ry;
for (auto rx = -1; rx <= 1; rx++)
{
auto crx = (x/CELL)+rx;
for (auto ry = -1; ry <= 1; ry++)
{
auto cry = (y/CELL)+ry;
if (cry >= 0 && crx >= 0 && crx < XCELLS && cry < YCELLS) {
sim->pv[cry][crx] += (float)parts[i].tmp;
}
}
}
spawncount = std::abs(parts[i].tmp);
auto spawncount = std::abs(parts[i].tmp);
spawncount = (spawncount>255) ? 3019 : int(std::pow((double)(spawncount/8), 2)*TPT_PI_FLT);
for (int j = 0;j < spawncount; j++)
{
@@ -96,8 +96,8 @@ static int update(UPDATE_FUNC_ARGS)
if (nb!=-1) {
parts[nb].life = sim->rng.between(0, 299);
parts[nb].temp = MAX_TEMP/2;
angle = sim->rng.uniform01()*2.0f*TPT_PI_FLT;
v = sim->rng.uniform01()*5.0f;
auto angle = sim->rng.uniform01()*2.0f*TPT_PI_FLT;
auto v = sim->rng.uniform01()*5.0f;
parts[nb].vx = v*cosf(angle);
parts[nb].vy = v*sinf(angle);
}
@@ -107,11 +107,13 @@ static int update(UPDATE_FUNC_ARGS)
sim->kill_part(i);
return 1;
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)!=PT_DMND&& sim->rng.chance(1, 3))
@@ -141,6 +143,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->kill_part(ID(r));
}
}
}
}
return 0;
}

View File

@@ -47,12 +47,13 @@ void Element::Element_SLTW()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
switch (TYP(r))
{
case PT_SALT:
@@ -89,5 +90,7 @@ static int update(UPDATE_FUNC_ARGS)
continue;
}
}
}
}
return 0;
}

View File

@@ -49,16 +49,17 @@ void Element::Element_SNOW()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW
{
parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP);
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((TYP(r)==PT_SALT || TYP(r)==PT_SLTW) && sim->rng.chance(1, 333))
@@ -67,5 +68,7 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
}
}
}
}
return 0;
}

View File

@@ -95,9 +95,6 @@ constexpr float BLEND = 0.85f;
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, nr, ng, nb, na;
float tr, tg, tb, ta;
//0x01 - bubble on/off
//0x02 - first mate yes/no
//0x04 - "back" mate yes/no
@@ -143,25 +140,32 @@ static int update(UPDATE_FUNC_ARGS)
}
if(!(parts[i].ctype&2))
{
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((parts[ID(r)].type == PT_SOAP) && (parts[ID(r)].ctype&1) && !(parts[ID(r)].ctype&4))
attach(parts, i, ID(r));
}
}
}
}
else
{
if (parts[i].life<=0)
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r && !sim->bmap[(y+ry)/CELL][(x+rx)/CELL])
continue;
if (parts[i].temp>FREEZING)
@@ -198,6 +202,9 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
}
if(parts[i].ctype&2)
{
@@ -235,26 +242,30 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 10;
}
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)!=PT_SOAP)
{
tr = float((parts[ID(r)].dcolour>>16)&0xFF);
tg = float((parts[ID(r)].dcolour>>8)&0xFF);
tb = float((parts[ID(r)].dcolour)&0xFF);
ta = float((parts[ID(r)].dcolour>>24)&0xFF);
nr = int(tr*BLEND);
ng = int(tg*BLEND);
nb = int(tb*BLEND);
na = int(ta*BLEND);
auto tr = float((parts[ID(r)].dcolour>>16)&0xFF);
auto tg = float((parts[ID(r)].dcolour>>8)&0xFF);
auto tb = float((parts[ID(r)].dcolour)&0xFF);
auto ta = float((parts[ID(r)].dcolour>>24)&0xFF);
auto nr = int(tr*BLEND);
auto ng = int(tg*BLEND);
auto nb = int(tb*BLEND);
auto na = int(ta*BLEND);
parts[ID(r)].dcolour = nr<<16 | ng<<8 | nb | na<<24;
}
}
}
}
return 0;
}

View File

@@ -49,16 +49,17 @@ void Element::Element_SPNG()
static int update(UPDATE_FUNC_ARGS)
{
int r, trade, rx, ry, tmp, np;
int limit = 50;
if (parts[i].life<limit && sim->pv[y/CELL][x/CELL]<=3&&sim->pv[y/CELL][x/CELL]>=-3&&parts[i].temp<=374.0f)
{
int absorbChanceDenom = parts[i].life*10000/limit + 500;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
switch (TYP(r))
{
case PT_WATR:
@@ -98,31 +99,39 @@ static int update(UPDATE_FUNC_ARGS)
continue;
}
}
}
}
}
else
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if ((!r)&&parts[i].life>=1)//if nothing then create water
{
np = sim->create_part(-1,x+rx,y+ry,PT_WATR);
auto np = sim->create_part(-1,x+rx,y+ry,PT_WATR);
if (np>-1) parts[i].life--;
}
}
for ( trade = 0; trade<9; trade ++)
}
}
}
for (auto trade = 0; trade<9; trade ++)
{
rx = sim->rng.between(-2, 2);
ry = sim->rng.between(-2, 2);
if (BOUNDS_CHECK && (rx || ry))
auto rx = sim->rng.between(-2, 2);
auto ry = sim->rng.between(-2, 2);
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SPNG&&(parts[i].life>parts[ID(r)].life)&&parts[i].life>0)//diffusion
{
tmp = parts[i].life - parts[ID(r)].life;
auto tmp = parts[i].life - parts[ID(r)].life;
if (tmp ==1)
{
parts[ID(r)].life ++;
@@ -138,14 +147,16 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
tmp = 0;
auto tmp = 0;
if (parts[i].life>0)
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_FIRE)
@@ -157,20 +168,25 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].life--;
}
}
}
}
}
if (tmp && parts[i].life>3)
parts[i].life -= parts[i].life/3;
if (tmp>1)
tmp = tmp/2;
if (tmp || parts[i].temp>=374)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if ((!r)&&parts[i].life>=1)//if nothing then create steam
{
np = sim->create_part(-1,x+rx,y+ry,PT_WTRV);
auto np = sim->create_part(-1,x+rx,y+ry,PT_WTRV);
if (np>-1)
{
parts[np].temp = parts[i].temp;
@@ -180,6 +196,9 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
if (tmp>0)
{
if (parts[i].life>tmp)

View File

@@ -52,7 +52,7 @@ void Element::Element_SPRK()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, nearp, pavg, ct = parts[i].ctype, sender, receiver;
int ct = parts[i].ctype;
Element_FIRE_update(UPDATE_FUNC_SUBCALL_ARGS);
if (parts[i].life<=0)
@@ -88,7 +88,7 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].life==1)
{
int Element_ETRD_nearestSparkablePart(Simulation *sim, int targetId);
nearp = Element_ETRD_nearestSparkablePart(sim, i);
auto nearp = Element_ETRD_nearestSparkablePart(sim, i);
if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL)
{
sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), PT_PLSM);
@@ -116,11 +116,13 @@ static int update(UPDATE_FUNC_ARGS)
case PT_TESC:
if (parts[i].tmp>300)
parts[i].tmp=300;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (r)
continue;
if (parts[i].tmp>4 && sim->rng.chance(1, parts[i].tmp*parts[i].tmp/20+6))
@@ -145,13 +147,17 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
break;
case PT_IRON:
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_DSTW || TYP(r)==PT_SLTW || TYP(r)==PT_WATR)
@@ -163,6 +169,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(ID(r),x+rx,y+ry,PT_H2);
}
}
}
}
break;
case PT_TUNG:
if(parts[i].temp < 3595.0){
@@ -171,16 +179,18 @@ static int update(UPDATE_FUNC_ARGS)
default:
break;
}
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
receiver = TYP(r);
sender = ct;
pavg = sim->parts_avg(ID(r), i,PT_INSL);
auto receiver = TYP(r);
auto sender = ct;
auto pavg = sim->parts_avg(ID(r), i,PT_INSL);
//receiver is the element SPRK is trying to conduct to
//sender is the element the SPRK is on
//First, some checks usually for (de)activation of elements
@@ -363,6 +373,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
}
}
}
}
return 0;
}

View File

@@ -53,16 +53,17 @@ void Element::Element_STOR()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, np, rx1, ry1;
if (!sim->IsElementOrNone(parts[i].tmp))
parts[i].tmp = 0;
if(parts[i].life && !parts[i].tmp)
parts[i].life--;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if ((ID(r))>=NPART || !r)
continue;
if (!parts[i].tmp && !parts[i].life && TYP(r)!=PT_STOR && !(sim->elements[TYP(r)].Properties&TYPE_SOLID) && (!parts[i].ctype || TYP(r)==parts[i].ctype))
@@ -78,9 +79,11 @@ static int update(UPDATE_FUNC_ARGS)
}
if(parts[i].tmp && TYP(r)==PT_SPRK && parts[ID(r)].ctype==PT_PSCN && parts[ID(r)].life>0 && parts[ID(r)].life<4)
{
for(ry1 = 1; ry1 >= -1; ry1--){
for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscillate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1)
np = sim->create_part(-1,x+rx1,y+ry1,TYP(parts[i].tmp));
for(auto ry1 = 1; ry1 >= -1; ry1--)
{
for(auto rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1) // Oscillate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1)
{
auto np = sim->create_part(-1,x+rx1,y+ry1,TYP(parts[i].tmp));
if (np!=-1)
{
parts[np].temp = parts[i].temp;
@@ -95,6 +98,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -54,18 +54,20 @@ static bool isRedBRAY(UPDATE_FUNC_ARGS, int xc, int yc)
static int update(UPDATE_FUNC_ARGS)
{
int r, rt, rx, ry;
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (sim->parts_avg(i,ID(r),PT_INSL)!=PT_INSL) {
rt = TYP(r);
if (sim->parts_avg(i,ID(r),PT_INSL)!=PT_INSL)
{
auto rt = TYP(r);
if (rt==PT_SWCH)
{
if (parts[i].life>=10&&parts[ID(r)].life<10&&parts[ID(r)].life>0)
@@ -83,6 +85,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
//turn SWCH on/off from two red BRAYS. There must be one either above or below, and one either left or right to work, and it can't come from the side, it must be a diagonal beam
if (!TYP(pmap[y-1][x-1]) && !TYP(pmap[y-1][x+1]) && (isRedBRAY(UPDATE_FUNC_SUBCALL_ARGS, x, y-1) || isRedBRAY(UPDATE_FUNC_SUBCALL_ARGS, x, y+1)) && (isRedBRAY(UPDATE_FUNC_SUBCALL_ARGS, x+1, y) || isRedBRAY(UPDATE_FUNC_SUBCALL_ARGS, x-1, y)))
{

View File

@@ -50,16 +50,17 @@ void Element::Element_THDR()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
bool kill=false;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -2; rx <= 2; rx++)
{
for (auto ry = -2; ry <= 2; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
auto rt = TYP(r);
if ((sim->elements[TYP(r)].Properties&PROP_CONDUCTS) && parts[ID(r)].life==0 && !(rt==PT_WATR||rt==PT_SLTW) && parts[ID(r)].ctype!=PT_SPRK)
{
parts[ID(r)].ctype = parts[ID(r)].type;
@@ -79,6 +80,8 @@ static int update(UPDATE_FUNC_ARGS)
kill=true;
}
}
}
}
if (kill) {
sim->kill_part(i);
return 1;

View File

@@ -56,8 +56,10 @@ static int update(UPDATE_FUNC_ARGS)
{
parts[i].life = 0;
for (int rx = -2; rx <= 2; rx++)
{
for (int ry = -2; ry <= 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
if (rx || ry)
{
int r = pmap[y+ry][x+rx];
if (!r)
@@ -75,6 +77,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
bool setFilt = false;
int photonWl = 0;
@@ -99,16 +103,17 @@ static int update(UPDATE_FUNC_ARGS)
}
if (setFilt)
{
int nx, ny;
for (int rx = -1; rx <= 1; rx++)
{
for (int ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
if (rx || ry)
{
int r = pmap[y+ry][x+rx];
if (!r)
continue;
nx = x + rx;
ny = y + ry;
auto nx = x + rx;
auto ny = y + ry;
while (TYP(r) == PT_FILT)
{
parts[ID(r)].ctype = 0x10000000 + photonWl;
@@ -119,6 +124,8 @@ static int update(UPDATE_FUNC_ARGS)
r = pmap[ny][nx];
}
}
}
}
}
return 0;
}

View File

@@ -56,12 +56,16 @@ static int update(UPDATE_FUNC_ARGS)
else if (nt <= 6)
{
for (int rx = -1; rx <= 1; rx++)
{
for (int ry = -1; ry <= 1; ry++)
if ((!rx != !ry) && BOUNDS_CHECK)
{
if (!rx != !ry)
{
if (TYP(pmap[y+ry][x+rx]) == PT_TTAN)
ttan++;
}
}
}
}
if (ttan >= 2)

View File

@@ -57,17 +57,20 @@ static int update(UPDATE_FUNC_ARGS)
if(parts[i].temp > 2400.0)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if(TYP(r) == PT_O2)
{
splode = true;
}
}
}
}
}
if((parts[i].temp > MELTING_POINT && sim->rng.chance(1, 20)) || splode)
{

View File

@@ -50,8 +50,7 @@ void Element::Element_VIBR()
int Element_VIBR_update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rndstore = 0;
int trade, transfer;
int rndstore = 0;
if (!parts[i].life) //if not exploding
{
//Heat absorption code
@@ -86,10 +85,10 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
rndstore = sim->rng.gen();
if (parts[i].life < 300)
{
rx = rndstore%3-1;
ry = (rndstore>>2)%3-1;
auto rx = rndstore%3-1;
auto ry = (rndstore>>2)%3-1;
rndstore = rndstore >> 4;
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (TYP(r) && TYP(r) != PT_BREC && (sim->elements[TYP(r)].Properties&PROP_CONDUCTS) && !parts[ID(r)].life)
{
parts[ID(r)].life = 4;
@@ -100,16 +99,13 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
//Release all heat
if (parts[i].life < 500)
{
rx = rndstore%7-3;
ry = (rndstore>>3)%7-3;
if(BOUNDS_CHECK)
auto rx = rndstore%7-3;
auto ry = (rndstore>>3)%7-3;
auto r = pmap[y+ry][x+rx];
if (TYP(r) && TYP(r)!=PT_VIBR && TYP(r)!=PT_BVBR && sim->elements[TYP(r)].HeatConduct && (TYP(r)!=PT_HSWC||parts[ID(r)].life==10))
{
r = pmap[y+ry][x+rx];
if (TYP(r) && TYP(r)!=PT_VIBR && TYP(r)!=PT_BVBR && sim->elements[TYP(r)].HeatConduct && (TYP(r)!=PT_HSWC||parts[ID(r)].life==10))
{
parts[ID(r)].temp += parts[i].tmp*3;
parts[i].tmp = 0;
}
parts[ID(r)].temp += parts[i].tmp*3;
parts[i].tmp = 0;
}
}
//Explosion code
@@ -145,11 +141,13 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
}
}
//Neighbor check loop
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (parts[i].life)
@@ -187,22 +185,24 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
sim->pv[y/CELL][x/CELL] -= 1;
}
}
for (trade = 0; trade < 9; trade++)
}
}
for (auto trade = 0; trade < 9; trade++)
{
if (!(trade%2))
rndstore = sim->rng.gen();
rx = rndstore%7-3;
auto rx = rndstore%7-3;
rndstore >>= 3;
ry = rndstore%7-3;
auto ry = rndstore%7-3;
rndstore >>= 3;
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (TYP(r) != PT_VIBR && TYP(r) != PT_BVBR)
continue;
if (parts[i].tmp > parts[ID(r)].tmp)
{
transfer = parts[i].tmp - parts[ID(r)].tmp;
auto transfer = parts[i].tmp - parts[ID(r)].tmp;
parts[ID(r)].tmp += transfer/2;
parts[i].tmp -= transfer/2;
break;

View File

@@ -52,19 +52,19 @@ void Element::Element_VINE()
static int update(UPDATE_FUNC_ARGS)
{
int r, np, rx, ry, rndstore = sim->rng.gen();
rx = (rndstore % 3) - 1;
int rndstore = sim->rng.gen();
auto rx = (rndstore % 3) - 1;
rndstore >>= 2;
ry = (rndstore % 3) - 1;
auto ry = (rndstore % 3) - 1;
rndstore >>= 2;
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!(rndstore % 15))
sim->part_change_type(i, x, y, PT_PLNT);
else if (!r)
{
np = sim->create_part(-1,x+rx,y+ry,PT_VINE);
auto np = sim->create_part(-1,x+rx,y+ry,PT_VINE);
if (np<0) return 0;
parts[np].temp = parts[i].temp;
sim->part_change_type(i,x,y,PT_PLNT);

View File

@@ -55,7 +55,7 @@ int Element_VIRS_update(UPDATE_FUNC_ARGS)
{
//tmp3 measures how many frames until it is cured (0 if still actively spreading and not being cured)
//tmp4 measures how many frames until it dies
int r, rx, ry, rndstore = sim->rng.gen();
int rndstore = sim->rng.gen();
if (parts[i].tmp3)
{
parts[i].tmp3 -= (rndstore & 0x1) ? 0:1;
@@ -81,12 +81,13 @@ int Element_VIRS_update(UPDATE_FUNC_ARGS)
rndstore >>= 3;
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
@@ -142,6 +143,7 @@ int Element_VIRS_update(UPDATE_FUNC_ARGS)
else if (!rx && !ry)
rndstore = sim->rng.gen();
}
}
return 0;
}

View File

@@ -56,8 +56,10 @@ static int update(UPDATE_FUNC_ARGS)
{
parts[i].life = 0;
for (int rx = -2; rx <= 2; rx++)
{
for (int ry = -2; ry <= 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
if (rx || ry)
{
int r = pmap[y + ry][x + rx];
if (!r)
@@ -73,6 +75,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
}
bool doSerialization = false;
bool doDeserialization = false;
@@ -126,8 +130,10 @@ static int update(UPDATE_FUNC_ARGS)
}
for (int rx = -1; rx <= 1; rx++)
{
for (int ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
if (rx || ry)
{
int r = pmap[y + ry][x + rx];
if (!r)
@@ -166,6 +172,8 @@ static int update(UPDATE_FUNC_ARGS)
}
}
}
}
}
return 0;
}

View File

@@ -62,7 +62,7 @@ static int update(UPDATE_FUNC_ARGS)
{
int rx = sim->rng.between(-1, 1);
int ry = sim->rng.between(-1, 1);
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
int r = pmap[y + ry][x + rx];
if (!r)

View File

@@ -48,12 +48,13 @@ void Element::Element_WATR()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SALT && sim->rng.chance(1, 50))
@@ -90,5 +91,7 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(ID(r),x+rx,y+ry,PT_STNE);
}
}
}
}
return 0;
}

View File

@@ -49,15 +49,16 @@ void Element::Element_WIFI()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
// wireless[][0] - whether channel is active on this frame
@@ -77,6 +78,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->ISWIRE = 2;
}
}
}
}
return 0;
}

View File

@@ -49,7 +49,7 @@ void Element::Element_WIRE()
static int update(UPDATE_FUNC_ARGS)
{
int r,rx,ry,count=0;
int count=0;
/*
0: wire
1: spark head
@@ -67,12 +67,13 @@ static int update(UPDATE_FUNC_ARGS)
{
parts[i].ctype=0;
}
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (BOUNDS_CHECK && (rx || ry))
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_SPRK && parts[ID(r)].life==3 && parts[ID(r)].ctype==PT_PSCN)
@@ -86,6 +87,7 @@ static int update(UPDATE_FUNC_ARGS)
count++;
}
}
}
if (count==1 || count==2)
parts[i].ctype=1;
return 0;

View File

@@ -48,12 +48,13 @@ void Element::Element_WTRV()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && sim->rng.chance(1, 100))
@@ -63,6 +64,8 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].ctype = PT_WATR;
}
}
}
}
if(parts[i].temp>1273&&parts[i].ctype==PT_FIRE)
parts[i].temp-=parts[i].temp/1000;
return 0;

View File

@@ -47,12 +47,13 @@ void Element::Element_YEST()
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
for (auto rx = -1; rx <= 1; rx++)
{
for (auto ry = -1; ry <= 1; ry++)
{
if (rx || ry)
{
r = pmap[y+ry][x+rx];
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (TYP(r)==PT_DYST && sim->rng.chance(1, 6) && !sim->legacy_enable)
@@ -60,6 +61,8 @@ static int update(UPDATE_FUNC_ARGS)
sim->part_change_type(i,x,y,PT_DYST);
}
}
}
}
if (parts[i].temp > 303 && parts[i].temp < 317) {
sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_YEST);
}