mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-21 15:41:35 +02:00
fix crash when PIPE finds PRTI with an invalid channel
This commit is contained in:
@@ -454,11 +454,15 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
|||||||
}
|
}
|
||||||
else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
|
else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
|
||||||
{
|
{
|
||||||
int nnx;
|
int portaltmp = sim->parts[r>>8].tmp;
|
||||||
for (nnx=0; nnx<80; nnx++)
|
if (portaltmp >= CHANNELS)
|
||||||
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type)
|
portaltmp = CHANNELS-1;
|
||||||
|
else if (portaltmp < 0)
|
||||||
|
portaltmp = 0;
|
||||||
|
for (int nnx = 0; nnx < 80; nnx++)
|
||||||
|
if (!sim->portalp[portaltmp][count][nnx].type)
|
||||||
{
|
{
|
||||||
transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[sim->parts[r>>8].tmp][count][nnx]));
|
transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[portaltmp][count][nnx]));
|
||||||
count++;
|
count++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -480,11 +484,15 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
|||||||
}
|
}
|
||||||
else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
|
else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase
|
||||||
{
|
{
|
||||||
int nnx;
|
int portaltmp = sim->parts[r>>8].tmp;
|
||||||
for (nnx=0; nnx<80; nnx++)
|
if (portaltmp >= CHANNELS)
|
||||||
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type)
|
portaltmp = CHANNELS-1;
|
||||||
|
else if (portaltmp < 0)
|
||||||
|
portaltmp = 0;
|
||||||
|
for (int nnx = 0; nnx < 80; nnx++)
|
||||||
|
if (!sim->portalp[portaltmp][count][nnx].type)
|
||||||
{
|
{
|
||||||
transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[sim->parts[r>>8].tmp][count][nnx]));
|
transfer_pipe_to_part(sim, sim->parts+i, &(sim->portalp[portaltmp][count][nnx]));
|
||||||
count++;
|
count++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user