Skip to content

Commit

Permalink
fix crash when PIPE finds PRTI with an invalid channel
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Nov 29, 2014
1 parent 6da5b08 commit 70a815a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/simulation/elements/PIPE.cpp
Expand Up @@ -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
{
int nnx;
for (nnx=0; nnx<80; nnx++)
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type)
int portaltmp = sim->parts[r>>8].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)
{
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++;
break;
}
Expand All @@ -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
{
int nnx;
for (nnx=0; nnx<80; nnx++)
if (!sim->portalp[sim->parts[r>>8].tmp][count][nnx].type)
int portaltmp = sim->parts[r>>8].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)
{
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++;
break;
}
Expand Down

0 comments on commit 70a815a

Please sign in to comment.