diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp index 95f7c0834..ec957670a 100644 --- a/src/simulation/elements/PIPE.cpp +++ b/src/simulation/elements/PIPE.cpp @@ -457,6 +457,13 @@ void Element_PIPE_transfer_pipe_to_part(Simulation * sim, Particle *pipe, Partic else { pipe->ctype = 0; + + // If deco originated from particle, and not PIPE, then copy it + if (pipe->tmp & PFLAG_PARTICLE_DECO) + { + part->dcolour = pipe->dcolour; + pipe->dcolour = 0; + } } } @@ -472,6 +479,12 @@ static void transfer_part_to_pipe(Particle *part, Particle *pipe) pipe->tmp2 = part->life; pipe->tmp3 = part->tmp; pipe->tmp4 = part->ctype; + + if (part->dcolour && !pipe->dcolour) + { + pipe->dcolour = part->dcolour; + pipe->tmp |= PFLAG_PARTICLE_DECO; + } } static void transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STOR) @@ -486,6 +499,18 @@ static void transfer_pipe_to_pipe(Particle *src, Particle *dest, bool STOR) { dest->ctype = src->ctype; src->ctype = 0; + + if (src->tmp & PFLAG_PARTICLE_DECO) + { + // Even if source pipe has particle deco, don't override existing pipe deco. Just delete source deco only. + if (!dest->dcolour) + { + dest->dcolour = src->dcolour; + dest->tmp |= PFLAG_PARTICLE_DECO; + } + src->dcolour = 0; + src->tmp &= ~PFLAG_PARTICLE_DECO; + } } if ((dest->tmp & PFLAG_CAN_CONDUCT) == 0) diff --git a/src/simulation/elements/PIPE.h b/src/simulation/elements/PIPE.h index f7055a204..25cba410c 100644 --- a/src/simulation/elements/PIPE.h +++ b/src/simulation/elements/PIPE.h @@ -15,6 +15,7 @@ void Element_PPIP_flood_trigger(Simulation * sim, int x, int y, int sparkedBy); // 0x000E0000 PIPE color data stored here constexpr int PFLAG_CAN_CONDUCT = 0x00000001; +constexpr int PFLAG_PARTICLE_DECO = 0x00000002; // differentiate particle deco from pipe deco constexpr int PFLAG_NORMALSPEED = 0x00010000; constexpr int PFLAG_INITIALIZING = 0x00020000; // colors haven't been set yet constexpr int PFLAG_COLOR_RED = 0x00040000;