From 1405c10046bced478010531e826384dababa1339 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 3 Jan 2018 00:13:06 -0500 Subject: [PATCH] fix STOR->PRTI transfer --- src/simulation/elements/PIPE.cpp | 18 ++++++++++++++---- src/simulation/elements/PRTI.cpp | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp index a1b495b716..35487aa5f1 100644 --- a/src/simulation/elements/PIPE.cpp +++ b/src/simulation/elements/PIPE.cpp @@ -359,15 +359,25 @@ int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS) return 0; } -//#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) +//#TPT-Directive ElementHeader Element_PIPE static void transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part, bool STOR=false) +void Element_PIPE::transfer_pipe_to_part(Simulation * sim, Particle *pipe, Particle *part, bool STOR) { - part->type = TYP(pipe->ctype); + // STOR also calls this function to move particles from STOR to PRTI + // PIPE was changed, so now PIPE and STOR don't use the same particle storage format + if (STOR) + { + part->type = TYP(pipe->tmp); + pipe->tmp = 0; + } + else + { + part->type = TYP(pipe->ctype); + pipe->ctype = 0; + } part->temp = pipe->temp; part->life = pipe->tmp2; part->tmp = pipe->pavg[0]; part->ctype = pipe->pavg[1]; - pipe->ctype = 0; if (!(sim->elements[part->type].Properties & TYPE_ENERGY)) { diff --git a/src/simulation/elements/PRTI.cpp b/src/simulation/elements/PRTI.cpp index db1a7f29a1..956c295a82 100644 --- a/src/simulation/elements/PRTI.cpp +++ b/src/simulation/elements/PRTI.cpp @@ -94,7 +94,7 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS) if (sim->IsValidElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) { // STOR uses same format as PIPE, so we can use this function to do the transfer - Element_PIPE::transfer_pipe_to_part(sim, parts+(ID(r)), &sim->portalp[parts[i].tmp][count][nnx]); + Element_PIPE::transfer_pipe_to_part(sim, parts+(ID(r)), &sim->portalp[parts[i].tmp][count][nnx], true); break; } }