mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-31 11:41:51 +02:00
fix CRAY INST mode ignoring length, fix CRAY going ignoring walls, fix CRAY + GOL particles, allow CRAY to create sparks
This commit is contained in:
@@ -1995,6 +1995,31 @@ void Simulation::clear_sim(void)
|
||||
}
|
||||
SetEdgeMode(edgeMode);
|
||||
}
|
||||
|
||||
bool Simulation::IsObsticle(int x, int y, int type)
|
||||
{
|
||||
if (pmap[y][x])// && (type != PT_SPRK || !(elements[pmap[y][x]&0xFF].Properties & PROP_CONDUCTS)))
|
||||
return true;
|
||||
|
||||
if (bmap[y/CELL][x/CELL])
|
||||
{
|
||||
int wall = bmap[y/CELL][x/CELL];
|
||||
if (wall == WL_ALLOWGAS && !(elements[type].Properties&TYPE_GAS))
|
||||
return true;
|
||||
else if (wall == WL_ALLOWENERGY && !(elements[type].Properties&TYPE_ENERGY))
|
||||
return true;
|
||||
else if (wall == WL_ALLOWLIQUID && elements[type].Falldown!=2)
|
||||
return true;
|
||||
else if (wall == WL_ALLOWSOLID && elements[type].Falldown!=1)
|
||||
return true;
|
||||
else if (wall == WL_ALLOWAIR || wall == WL_WALL || wall == WL_WALLELEC)
|
||||
return true;
|
||||
else if (wall == WL_EWALL && !emap[y/CELL][x/CELL])
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Simulation::init_can_move()
|
||||
{
|
||||
// can_move[moving type][type at destination]
|
||||
@@ -2818,11 +2843,10 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
||||
drawOn==PT_CLNE ||
|
||||
drawOn==PT_BCLN ||
|
||||
drawOn==PT_CONV ||
|
||||
drawOn==PT_CRAY ||
|
||||
(drawOn==PT_PCLN&&t!=PT_PSCN&&t!=PT_NSCN) ||
|
||||
(drawOn==PT_PBCN&&t!=PT_PSCN&&t!=PT_NSCN)
|
||||
)&&(
|
||||
t != PT_CLNE && t != PT_CRAY && t != PT_PCLN && t != PT_BCLN && t != PT_STKM && t != PT_STKM2 && t != PT_PBCN && t != PT_STOR && t != PT_FIGH && t != PT_CONV)
|
||||
t != PT_CLNE && t != PT_PCLN && t != PT_BCLN && t != PT_STKM && t != PT_STKM2 && t != PT_PBCN && t != PT_STOR && t != PT_FIGH && t != PT_CONV)
|
||||
)
|
||||
{
|
||||
parts[pmap[y][x]>>8].ctype = t;
|
||||
@@ -2834,6 +2858,12 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
||||
if (t==PT_LIFE && v<NGOLALT)
|
||||
parts[pmap[y][x]>>8].tmp = v;
|
||||
}
|
||||
else if (drawOn == PT_CRAY && drawOn != t && drawOn != PT_PSCN && drawOn != PT_INST && drawOn != PT_METL)
|
||||
{
|
||||
parts[pmap[y][x]>>8].ctype = t;
|
||||
if (t==PT_LIFE && v<NGOLALT)
|
||||
parts[pmap[y][x]>>8].tmp2 = v;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (photons[y][x] && (elements[t].Properties & TYPE_ENERGY))
|
||||
|
@@ -138,6 +138,7 @@ public:
|
||||
TPT_NO_INLINE int try_move(int i, int x, int y, int nx, int ny);
|
||||
TPT_NO_INLINE int eval_move(int pt, int nx, int ny, unsigned *rr);
|
||||
void init_can_move();
|
||||
bool IsObsticle(int x, int y, int type);
|
||||
void create_cherenkov_photon(int pp);
|
||||
void create_gain_photon(int pp);
|
||||
TPT_NO_INLINE void kill_part(int i);
|
||||
|
@@ -50,8 +50,9 @@ Element_CRAY::Element_CRAY()
|
||||
int Element_CRAY::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr, ry1, rx1, partsRemaining = 255;
|
||||
if (parts[i].tmp)
|
||||
if (parts[i].tmp) //how far it shoots
|
||||
partsRemaining = parts[i].tmp;
|
||||
// set ctype to things that touch it if it doesn't have one already
|
||||
if(parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled) {
|
||||
int r, rx, ry;
|
||||
for (rx=-1; rx<2; rx++)
|
||||
@@ -63,12 +64,12 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((r&0xFF)!=PT_CRAY && (r&0xFF)<PT_NUM)
|
||||
if ((r&0xFF)!=PT_CRAY && (r&0xFF)!=PT_PSCN && (r&0xFF)!=PT_INST && (r&0xFF)!=PT_METL && (r&0xFF)!=PT_SPRK && (r&0xFF)<PT_NUM)
|
||||
{
|
||||
parts[i].ctype = r&0xFF;
|
||||
}
|
||||
}
|
||||
} else if (parts[i].life==0) {
|
||||
} else if (parts[i].life==0) { // only fire when life is 0, but nothing sets the life right now
|
||||
unsigned int colored = 0;
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
@@ -77,7 +78,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) {
|
||||
if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) { //spark found, start creating
|
||||
int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
|
||||
int nostop = (parts[r>>8].ctype==PT_INST)?1:0;
|
||||
for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi) {
|
||||
@@ -85,24 +86,24 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
}
|
||||
r = pmap[y+nyi+nyy][x+nxi+nxx];
|
||||
if (!r) {
|
||||
int nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype);
|
||||
if (!sim->IsObsticle(x+nxi+nxx, y+nyi+nyy, parts[i].ctype) || (parts[i].ctype == PT_SPRK && sim->elements[r&0xFF].Properties & PROP_CONDUCTS) && !destroy) { // create, also set color if it has passed through FILT
|
||||
int nr;
|
||||
if (parts[i].ctype == PT_LIFE)
|
||||
nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype|(parts[i].tmp2<<8));
|
||||
else
|
||||
nr = sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, parts[i].ctype);
|
||||
if (nr!=-1) {
|
||||
parts[nr].dcolour = colored;
|
||||
if(!--partsRemaining)
|
||||
docontinue = 0;
|
||||
}
|
||||
} else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT
|
||||
} else if ((r&0xFF)==PT_FILT) { // get color if passed through FILT
|
||||
colored = wavelengthToDecoColour(parts[r>>8].ctype);
|
||||
} else if ((r&0xFF)==PT_CRAY || nostop) {
|
||||
docontinue = 1;
|
||||
} else if(destroy && ((r&0xFF) != PT_DMND)) {
|
||||
sim->kill_part(r>>8);
|
||||
if(!--partsRemaining)
|
||||
docontinue = 0;
|
||||
} else {
|
||||
} else if ((r&0xFF) != PT_CRAY && !nostop) {
|
||||
docontinue = 0;
|
||||
}
|
||||
if(!--partsRemaining)
|
||||
docontinue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user