Preserve deco in pipe, as long as the pipe wasn't already decorated

This commit is contained in:
jacob1
2025-02-27 00:37:05 -05:00
parent 38b7111821
commit e2e2568200
2 changed files with 26 additions and 0 deletions

View File

@@ -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)

View File

@@ -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;