mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-03-22 15:19:52 +01:00
last src/simulation/element changes
PSTN, CRAY, and possibly some others will need to be modified to account for this without breaking saves. The save format will need to include PMAPBITS and adjust properly
This commit is contained in:
parent
208cf14ce8
commit
da45e0e469
@ -50,7 +50,14 @@
|
||||
|
||||
#define OLD_PT_WIND 147
|
||||
|
||||
//#define PT_NUM 161
|
||||
// Change this to change the amount of bits used to store type in pmap (and a few elements such as PIPE and CRAY)
|
||||
#define PMAPBITS 8
|
||||
#define PMAPMASK ((2<<(PMAPBITS-1))-1)
|
||||
#define ID(r) ((r)>>PMAPBITS)
|
||||
#define TYP(r) ((r)&PMAPMASK)
|
||||
#define PMAP(id, typ) ((id)<<PMAPBITS | ((typ)&PMAPMASK))
|
||||
#define PMAPID(id) ((id)<<PMAPBITS)
|
||||
|
||||
#define PT_NUM 256
|
||||
|
||||
struct playerst;
|
||||
|
@ -128,11 +128,6 @@
|
||||
#define REPLACE_MODE 0x1
|
||||
#define SPECIFIC_DELETE 0x2
|
||||
|
||||
#define ID(r) ((r)>>8)
|
||||
#define TYP(r) ((r)&0xFF)
|
||||
#define PMAP(id, typ) ((id)<<8 | ((typ)&0xFF))
|
||||
#define PMAPID(id) ((id)<<8)
|
||||
|
||||
#ifndef SIMULATIONDATA_H
|
||||
#define SIMULATIONDATA_H
|
||||
|
||||
|
@ -139,7 +139,7 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
for (int rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1 - rx1 + 1)
|
||||
{
|
||||
int np = sim->create_part(-1, x + nxi + nxx + rx1, y + nyi + nyy + ry1, parts[r].tmp&0xFF);
|
||||
int np = sim->create_part(-1, x + nxi + nxx + rx1, y + nyi + nyy + ry1, TYP(parts[r].tmp));
|
||||
if (np != -1)
|
||||
{
|
||||
parts[np].temp = parts[r].temp;
|
||||
|
@ -84,7 +84,7 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype&0xFF);
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, TYP(parts[i].ctype));
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -72,7 +72,7 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS)
|
||||
if ((ynxj < 0) || (ynxj >= YRES) || (xnxi <= 0) || (xnxi >= XRES))
|
||||
continue;
|
||||
|
||||
nt = pmap[ynxj][xnxi]&0xFF;
|
||||
nt = TYP(pmap[ynxj][xnxi]);
|
||||
if (nt!=PT_DMND && nt!=PT_CLNE && nt!=PT_PCLN && nt!=PT_BCLN && nt!=PT_VIBR)
|
||||
{
|
||||
if (nt)
|
||||
@ -89,7 +89,7 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
|
||||
for (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 && !(pmap[y+nxj][x+nxi]&0xFF))
|
||||
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);
|
||||
if (nb!=-1)
|
||||
|
@ -75,7 +75,7 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype&0xFF);
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, TYP(parts[i].ctype));
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -48,7 +48,7 @@ Element_CONV::Element_CONV()
|
||||
int Element_CONV::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, rx, ry;
|
||||
int ctype = parts[i].ctype&0xFF, ctypeExtra = ID(parts[i].ctype);
|
||||
int ctype = TYP(parts[i].ctype), ctypeExtra = ID(parts[i].ctype);
|
||||
if (ctype<=0 || ctype>=PT_NUM || !sim->elements[ctype].Enabled || ctype==PT_CONV || (ctype==PT_LIFE && (ctypeExtra<0 || ctypeExtra>=NGOL)))
|
||||
{
|
||||
for (rx=-1; rx<2; rx++)
|
||||
@ -86,7 +86,7 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r) != PT_CONV && TYP(r) != PT_DMND && TYP(r) != ctype)
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, parts[i].ctype&0xFF, ID(parts[i].ctype));
|
||||
sim->create_part(ID(r), x+rx, y+ry, TYP(parts[i].ctype), ID(parts[i].ctype));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int nxx, nyy, docontinue, nxi, nyi;
|
||||
// set ctype to things that touch it if it doesn't have one already
|
||||
if (parts[i].ctype<=0 || !sim->elements[parts[i].ctype&0xFF].Enabled)
|
||||
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++)
|
||||
@ -91,8 +91,8 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
}
|
||||
r = pmap[y+nyi+nyy][x+nxi+nxx];
|
||||
if (!sim->IsWallBlocking(x+nxi+nxx, y+nyi+nyy, parts[i].ctype&0xFF) && (!sim->pmap[y+nyi+nyy][x+nxi+nxx] || createSpark)) { // create, also set color if it has passed through FILT
|
||||
int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype&0xFF, ID(parts[i].ctype));
|
||||
if (!sim->IsWallBlocking(x+nxi+nxx, y+nyi+nyy, TYP(parts[i].ctype)) && (!sim->pmap[y+nyi+nyy][x+nxi+nxx] || createSpark)) { // create, also set color if it has passed through FILT
|
||||
int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, TYP(parts[i].ctype), ID(parts[i].ctype));
|
||||
if (nr!=-1) {
|
||||
if (colored)
|
||||
parts[nr].dcolour = colored;
|
||||
|
@ -54,7 +54,7 @@ bool InBounds(int x, int y)
|
||||
//#TPT-Directive ElementHeader Element_DRAY static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_DRAY::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int ctype = parts[i].ctype&0xFF, ctypeExtra = ID(parts[i].ctype), copyLength = parts[i].tmp, copySpaces = parts[i].tmp2;
|
||||
int ctype = TYP(parts[i].ctype), ctypeExtra = ID(parts[i].ctype), copyLength = parts[i].tmp, copySpaces = parts[i].tmp2;
|
||||
if (copySpaces < 0)
|
||||
copySpaces = parts[i].tmp2 = 0;
|
||||
if (copyLength < 0)
|
||||
@ -106,7 +106,7 @@ int Element_DRAY::update(UPDATE_FUNC_ARGS)
|
||||
// 1: if .tmp isn't set, and the element in this spot is the ctype, then stop
|
||||
// 2: if .tmp is set, stop when the length limit reaches 0
|
||||
// 3. Stop when we are out of bounds
|
||||
if ((!copyLength && (rr&0xFF) == ctype && (ctype != PT_LIFE || parts[ID(rr)].ctype == ctypeExtra))
|
||||
if ((!copyLength && TYP(rr) == ctype && (ctype != PT_LIFE || parts[ID(rr)].ctype == ctypeExtra))
|
||||
|| !(--partsRemaining && InBounds(xCurrent+xStep, yCurrent+yStep)))
|
||||
{
|
||||
copyLength -= partsRemaining;
|
||||
@ -123,9 +123,9 @@ int Element_DRAY::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
// get particle to copy
|
||||
if (isEnergy)
|
||||
type = sim->photons[yCurrent][xCurrent]&0xFF;
|
||||
type = TYP(sim->photons[yCurrent][xCurrent]);
|
||||
else
|
||||
type = pmap[yCurrent][xCurrent]&0xFF;
|
||||
type = TYP(pmap[yCurrent][xCurrent]);
|
||||
|
||||
// if sparked by PSCN, overwrite whatever is in the target location, instead of just ignoring it
|
||||
if (overwrite)
|
||||
|
@ -53,7 +53,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
switch (r&0xFF)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_SALT:
|
||||
if (!(rand()%50))
|
||||
|
@ -135,7 +135,7 @@ int Element_EMP::Trigger(Simulation *sim, int triggerCount)
|
||||
int n = sim->pmap[ry+ny][rx+nx];
|
||||
if (!n)
|
||||
continue;
|
||||
int ntype = n&0xFF;
|
||||
int ntype = TYP(n);
|
||||
n = ID(n);
|
||||
//Some elements should only be affected by wire/swch, or by a spark on inst/semiconductor
|
||||
//So not affected by spark on metl, watr etc
|
||||
|
@ -87,7 +87,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((sim->photons[y][x]&0xFF) == PT_NEUT)
|
||||
if (TYP(sim->photons[y][x]) == PT_NEUT)
|
||||
{
|
||||
if (!(rand()%7))
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ int Element_H2::update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = temp;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
rx = x+rand()%3-1, ry = y+rand()%3-1, rt = pmap[ry][rx]&0xFF;
|
||||
rx = x+rand()%3-1, ry = y+rand()%3-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);
|
||||
|
@ -52,7 +52,7 @@ Element_HEAC::Element_HEAC()
|
||||
struct Element_HEAC::IsInsulator : public std::binary_function<Simulation*,int,bool> {
|
||||
bool operator() (Simulation* a, int b)
|
||||
{
|
||||
return b && (a->elements[b&0xFF].HeatConduct == 0 || ((b&0xFF) == PT_HSWC && a->parts[ID(b)].life != 10));
|
||||
return b && (a->elements[TYP(b)].HeatConduct == 0 || (TYP(b) == PT_HSWC && a->parts[ID(b)].life != 10));
|
||||
}
|
||||
};
|
||||
//#TPT-Directive ElementHeader Element_HEAC static IsInsulator isInsulator
|
||||
|
@ -73,7 +73,7 @@ int Element_NBLE::update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = temp;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
int rx = x+rand()%3-1, ry = y+rand()%3-1, rt = pmap[ry][rx]&0xFF;
|
||||
int rx = x+rand()%3-1, ry = y+rand()%3-1, rt = TYP(pmap[ry][rx]);
|
||||
if (sim->can_move[PT_PLSM][rt] || rt == PT_NBLE)
|
||||
{
|
||||
j = sim->create_part(-3,rx,ry,PT_PLSM);
|
||||
|
@ -55,7 +55,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
|
||||
if (BOUNDS_CHECK)
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
switch (r&0xFF)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_WATR:
|
||||
if (3>(rand()%20))
|
||||
|
@ -90,7 +90,7 @@ int Element_O2::update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = MAX_TEMP;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
rx = x+rand()%3-1, ry = y+rand()%3-1, r = pmap[ry][rx]&0xFF;
|
||||
rx = x+rand()%3-1, ry = y+rand()%3-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);
|
||||
|
@ -134,7 +134,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
|
||||
|
||||
else if (parts[i].ctype!=PT_LIGH || !(rand()%30))
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype&0xFF);
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, TYP(parts[i].ctype));
|
||||
if (np>-1)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -125,7 +125,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
|
||||
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype&0xFF);
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, TYP(parts[i].ctype));
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -75,8 +75,8 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, rx, ry, np;
|
||||
int rnd, rndstore;
|
||||
if ((parts[i].tmp&0xFF)>=PT_NUM || !sim->elements[parts[i].tmp&0xFF].Enabled)
|
||||
parts[i].tmp &= ~0xFF;
|
||||
if (TYP(parts[i].tmp)>=PT_NUM || !sim->elements[TYP(parts[i].tmp)].Enabled)
|
||||
parts[i].tmp &= ~PMAPMASK;
|
||||
if (parts[i].tmp & PPIP_TMPFLAG_TRIGGERS)
|
||||
{
|
||||
int pause_changed = 0;
|
||||
@ -193,23 +193,23 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if(!r)
|
||||
r = sim->photons[y+ry][x+rx];
|
||||
if (surround_space && !r && (parts[i].tmp&0xFF)!=0) //creating at end
|
||||
if (surround_space && !r && TYP(parts[i].tmp)!=0) //creating at end
|
||||
{
|
||||
np = sim->create_part(-1,x+rx,y+ry,parts[i].tmp&0xFF);
|
||||
np = sim->create_part(-1, x+rx, y+ry, TYP(parts[i].tmp));
|
||||
if (np!=-1)
|
||||
{
|
||||
transfer_pipe_to_part(sim, parts+i, parts+np);
|
||||
}
|
||||
}
|
||||
//try eating particle at entrance
|
||||
else if ((parts[i].tmp&0xFF) == 0 && (sim->elements[TYP(r)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
|
||||
else if (TYP(parts[i].tmp) == 0 && (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 ((parts[i].tmp&0xFF) == 0 && TYP(r)==PT_STOR && parts[ID(r)].tmp>0 && sim->IsValidElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
|
||||
else if (TYP(parts[i].tmp) == 0 && TYP(r)==PT_STOR && parts[ID(r)].tmp>0 && sim->IsValidElement(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);
|
||||
@ -278,7 +278,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
|
||||
//#TPT-Directive ElementHeader Element_PIPE static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
int t = cpart->tmp & 0xFF;
|
||||
int t = TYP(cpart->tmp);
|
||||
if (t>0 && t<PT_NUM && ren->sim->elements[t].Enabled)
|
||||
{
|
||||
if (t == PT_STKM || t == PT_STKM2 || t == PT_FIGH)
|
||||
@ -318,9 +318,9 @@ int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS)
|
||||
Element::defaultGraphics(ren, &tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb);
|
||||
}
|
||||
}
|
||||
//*colr = PIXR(elements[cpart->tmp&0xFF].pcolors);
|
||||
//*colg = PIXG(elements[cpart->tmp&0xFF].pcolors);
|
||||
//*colb = PIXB(elements[cpart->tmp&0xFF].pcolors);
|
||||
//*colr = PIXR(elements[t].pcolors);
|
||||
//*colg = PIXG(elements[t].pcolors);
|
||||
//*colb = PIXB(elements[t].pcolors);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -350,12 +350,12 @@ int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS)
|
||||
//#TPT-Directive ElementHeader Element_PIPE static void transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part)
|
||||
void Element_PIPE::transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part)
|
||||
{
|
||||
part->type = (pipe->tmp & 0xFF);
|
||||
part->type = TYP(pipe->tmp);
|
||||
part->temp = pipe->temp;
|
||||
part->life = pipe->tmp2;
|
||||
part->tmp = pipe->pavg[0];
|
||||
part->ctype = pipe->pavg[1];
|
||||
pipe->tmp &= ~0xFF;
|
||||
pipe->tmp &= ~PMAPMASK;
|
||||
|
||||
if (!(sim->elements[part->type].Properties & TYPE_ENERGY))
|
||||
{
|
||||
@ -372,7 +372,7 @@ void Element_PIPE::transfer_pipe_to_part(Simulation * sim, Particle *pipe, Parti
|
||||
//#TPT-Directive ElementHeader Element_PIPE static void transfer_part_to_pipe(Particle *part, Particle *pipe)
|
||||
void Element_PIPE::transfer_part_to_pipe(Particle *part, Particle *pipe)
|
||||
{
|
||||
pipe->tmp = (pipe->tmp&~0xFF) | part->type;
|
||||
pipe->tmp = (pipe->tmp&~PMAPMASK) | part->type;
|
||||
pipe->temp = part->temp;
|
||||
pipe->tmp2 = part->life;
|
||||
pipe->pavg[0] = part->tmp;
|
||||
@ -382,19 +382,19 @@ void Element_PIPE::transfer_part_to_pipe(Particle *part, Particle *pipe)
|
||||
//#TPT-Directive ElementHeader Element_PIPE static void transfer_pipe_to_pipe(Particle *src, Particle *dest)
|
||||
void Element_PIPE::transfer_pipe_to_pipe(Particle *src, Particle *dest)
|
||||
{
|
||||
dest->tmp = (dest->tmp&~0xFF) | (src->tmp&0xFF);
|
||||
dest->tmp = (dest->tmp&~PMAPMASK) | TYP(src->tmp);
|
||||
dest->temp = src->temp;
|
||||
dest->tmp2 = src->tmp2;
|
||||
dest->pavg[0] = src->pavg[0];
|
||||
dest->pavg[1] = src->pavg[1];
|
||||
src->tmp &= ~0xFF;
|
||||
src->tmp &= ~PMAPMASK;
|
||||
}
|
||||
|
||||
//#TPT-Directive ElementHeader Element_PIPE static void pushParticle(Simulation * sim, int i, int count, int original)
|
||||
void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original)
|
||||
{
|
||||
int rndstore, rnd, rx, ry, r, x, y, np, q, notctype=(((sim->parts[i].ctype)%3)+2);
|
||||
if ((sim->parts[i].tmp&0xFF) == 0 || count >= 2)//don't push if there is nothing there, max speed of 2 per frame
|
||||
if (TYP(sim->parts[i].tmp) == 0 || 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);
|
||||
@ -415,7 +415,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
r = sim->pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
else if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && (sim->parts[ID(r)].tmp&0xFF)==0)
|
||||
else if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && TYP(sim->parts[ID(r)].tmp)==0)
|
||||
{
|
||||
transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)));
|
||||
if (ID(r) > original)
|
||||
@ -445,7 +445,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
{
|
||||
int coords = 7 - ((sim->parts[i].tmp>>10)&7);
|
||||
r = sim->pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]];
|
||||
if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && (sim->parts[ID(r)].tmp&0xFF)==0)
|
||||
if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && TYP(sim->parts[ID(r)].tmp)==0)
|
||||
{
|
||||
transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)));
|
||||
if (ID(r) > original)
|
||||
@ -468,11 +468,11 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (TYP(r) == PT_NONE) //Move particles out of pipe automatically, much faster at ends
|
||||
else if (!r) //Move particles out of pipe automatically, much faster at ends
|
||||
{
|
||||
rx = pos_1_rx[coords];
|
||||
ry = pos_1_ry[coords];
|
||||
np = sim->create_part(-1,x+rx,y+ry,sim->parts[i].tmp&0xFF);
|
||||
np = sim->create_part(-1,x+rx,y+ry,TYP(sim->parts[i].tmp));
|
||||
if (np!=-1)
|
||||
{
|
||||
transfer_pipe_to_part(sim, sim->parts+i, sim->parts+np);
|
||||
|
@ -48,16 +48,18 @@ Element_PLNT::Element_PLNT()
|
||||
Graphics = &Element_PLNT::graphics;
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
//#TPT-Directive ElementHeader Element_PLNT static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_PLNT::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, rx, ry, np, rndstore;
|
||||
std::cout << PMAPBITS << ", " << PMAPMASK << std::endl;
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
switch (r&0xFF)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_WATR:
|
||||
if (!(rand()%50))
|
||||
|
@ -83,7 +83,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
else if (sparkedBy==PT_NSCN) prop = PPIP_TMPFLAG_TRIGGER_OFF << 3;
|
||||
else if (sparkedBy==PT_INST) prop = PPIP_TMPFLAG_TRIGGER_REVERSE << 3;
|
||||
|
||||
if (prop==0 || (pmap[y][x]&0xFF)!=PT_PPIP || (parts[ID(pmap[y][x])].tmp & prop))
|
||||
if (prop==0 || TYP(pmap[y][x])!=PT_PPIP || (parts[ID(pmap[y][x])].tmp & prop))
|
||||
return;
|
||||
|
||||
coord_stack = new unsigned short[coord_stack_limit][2];
|
||||
@ -100,7 +100,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
// go left as far as possible
|
||||
while (x1>=CELL)
|
||||
{
|
||||
if ((pmap[y][x1-1]&0xFF)!=PT_PPIP)
|
||||
if (TYP(pmap[y][x1-1]) != PT_PPIP)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -109,7 +109,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
// go right as far as possible
|
||||
while (x2<XRES-CELL)
|
||||
{
|
||||
if ((pmap[y][x2+1]&0xFF)!=PT_PPIP)
|
||||
if (TYP(pmap[y][x2+1]) != PT_PPIP)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -128,7 +128,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
// Don't need to check x bounds here, because already limited to [CELL, XRES-CELL]
|
||||
if (y>=CELL+1)
|
||||
for (x=x1-1; x<=x2+1; x++)
|
||||
if ((pmap[y-1][x]&0xFF)==PT_PPIP && !(parts[ID(pmap[y-1][x])].tmp & prop))
|
||||
if (TYP(pmap[y-1][x]) == PT_PPIP && !(parts[ID(pmap[y-1][x])].tmp & prop))
|
||||
{
|
||||
coord_stack[coord_stack_size][0] = x;
|
||||
coord_stack[coord_stack_size][1] = y-1;
|
||||
@ -141,7 +141,7 @@ void Element_PPIP::flood_trigger(Simulation * sim, int x, int y, int sparkedBy)
|
||||
}
|
||||
if (y<YRES-CELL-1)
|
||||
for (x=x1-1; x<=x2+1; x++)
|
||||
if ((pmap[y+1][x]&0xFF)==PT_PPIP && !(parts[ID(pmap[y+1][x])].tmp & prop))
|
||||
if (TYP(pmap[y+1][x]) == PT_PPIP && !(parts[ID(pmap[y+1][x])].tmp & prop))
|
||||
{
|
||||
coord_stack[coord_stack_size][0] = x;
|
||||
coord_stack[coord_stack_size][1] = y+1;
|
||||
|
@ -50,7 +50,7 @@ int Element_PROT::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
sim->pv[y/CELL][x/CELL] -= .003f;
|
||||
int under = pmap[y][x];
|
||||
int utype = under & 0xFF;
|
||||
int utype = TYP(under);
|
||||
int uID = ID(under);
|
||||
switch (utype)
|
||||
{
|
||||
@ -150,7 +150,7 @@ int Element_PROT::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
//collide with other protons to make heavier materials
|
||||
int ahead = sim->photons[y][x];
|
||||
if (ID(ahead) != i && (ahead&0xFF) == PT_PROT)
|
||||
if (ID(ahead) != i && TYP(ahead) == PT_PROT)
|
||||
{
|
||||
float velocity1 = powf(parts[i].vx, 2.0f)+powf(parts[i].vy, 2.0f);
|
||||
float velocity2 = powf(parts[ID(ahead)].vx, 2.0f)+powf(parts[ID(ahead)].vy, 2.0f);
|
||||
|
@ -237,7 +237,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
|
||||
for(int c = retract; c < MAX_FRAME; c++) {
|
||||
posY = stackY + (c*newY);
|
||||
posX = stackX + (c*newX);
|
||||
if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && (sim->pmap[posY][posX]&0xFF) == PT_FRME) {
|
||||
if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && TYP(sim->pmap[posY][posX]) == PT_FRME) {
|
||||
int spaces = CanMoveStack(sim, posX, posY, realDirectionX, realDirectionY, maxSize, amount, retract, block).spaces;
|
||||
if(spaces < amount)
|
||||
amount = spaces;
|
||||
@ -249,7 +249,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
|
||||
for(int c = 1; c < MAX_FRAME; c++) {
|
||||
posY = stackY - (c*newY);
|
||||
posX = stackX - (c*newX);
|
||||
if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && (sim->pmap[posY][posX]&0xFF) == PT_FRME) {
|
||||
if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && TYP(sim->pmap[posY][posX]) == PT_FRME) {
|
||||
int spaces = CanMoveStack(sim, posX, posY, realDirectionX, realDirectionY, maxSize, amount, retract, block).spaces;
|
||||
if(spaces < amount)
|
||||
amount = spaces;
|
||||
|
@ -590,7 +590,7 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int
|
||||
}
|
||||
|
||||
if (sim->elements[TYP(r)].Properties&PROP_DEADLY)
|
||||
switch (r&0xFF)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_ACID:
|
||||
sim->parts[i].life -= 5;
|
||||
|
@ -75,7 +75,7 @@ int Element_STOR::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
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,parts[i].tmp&0xFF);
|
||||
np = sim->create_part(-1,x+rx1,y+ry1,TYP(parts[i].tmp));
|
||||
if (np!=-1)
|
||||
{
|
||||
parts[np].temp = parts[i].temp;
|
||||
|
@ -47,7 +47,7 @@ Element_SWCH::Element_SWCH()
|
||||
|
||||
bool isRedBRAY(UPDATE_FUNC_ARGS, int xc, int yc)
|
||||
{
|
||||
return (pmap[yc][xc]&0xFF) == PT_BRAY && parts[ID(pmap[yc][xc])].tmp == 2;
|
||||
return TYP(pmap[yc][xc]) == PT_BRAY && parts[ID(pmap[yc][xc])].tmp == 2;
|
||||
}
|
||||
|
||||
//#TPT-Directive ElementHeader Element_SWCH static int update(UPDATE_FUNC_ARGS)
|
||||
@ -83,7 +83,7 @@ int Element_SWCH::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 (!(pmap[y-1][x-1]&0xFF) && !(pmap[y-1][x+1]&0xFF) && (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)))
|
||||
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)))
|
||||
{
|
||||
if (parts[i].life == 10)
|
||||
parts[i].life = 9;
|
||||
|
@ -48,22 +48,24 @@ Element_TTAN::Element_TTAN()
|
||||
//#TPT-Directive ElementHeader Element_TTAN static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_TTAN::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int rx, ry, ttan = 0;
|
||||
if(nt<=2)
|
||||
int ttan = 0;
|
||||
if (nt <= 2)
|
||||
ttan = 2;
|
||||
else if(parts[i].tmp)
|
||||
else if (parts[i].tmp)
|
||||
ttan = 2;
|
||||
else if(nt<=6)
|
||||
for (rx=-1; rx<2; rx++) {
|
||||
for (ry=-1; ry<2; ry++) {
|
||||
if ((!rx != !ry) && BOUNDS_CHECK) {
|
||||
if((pmap[y+ry][x+rx]&0xFF)==PT_TTAN)
|
||||
else if (nt <= 6)
|
||||
{
|
||||
for (int rx = -1; rx <= 1; rx++)
|
||||
for (int ry = -1; ry <= 1; ry++)
|
||||
if ((!rx != !ry) && BOUNDS_CHECK)
|
||||
{
|
||||
if (TYP(pmap[y+ry][x+rx]) == PT_TTAN)
|
||||
ttan++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ttan>=2) {
|
||||
if (ttan >= 2)
|
||||
{
|
||||
sim->air->bmap_blockair[y/CELL][x/CELL] = 1;
|
||||
sim->air->bmap_blockairh[y/CELL][x/CELL] = 0x8;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
|
||||
rndstore >>= 3;
|
||||
}
|
||||
//protons make VIRS last forever
|
||||
else if ((sim->photons[y+ry][x+rx]&0xFF) == PT_PROT)
|
||||
else if (TYP(sim->photons[y+ry][x+rx]) == PT_PROT)
|
||||
{
|
||||
parts[i].pavg[1] = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user