From 6fb893a8de235d0d8bdf152a9f48e8c3b14d0407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Fri, 2 Jun 2023 08:19:32 +0200 Subject: [PATCH] Fix random particles disappearing when pasting Because apparently GameSaves can have type = 0 particles. Also possibly fix other odd phenomena. Background: I moved all spawnability checks to the previous loop over particles in 2e2c3181b568 and removed all of them from this loop. It turns out that I should have at least left the type == 0 check alone, because that's what ultimately prevented particles from being added to the simulation. --- src/simulation/Simulation.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 9b88986d0..14f87fabe 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -61,12 +61,17 @@ void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2particlesCount; n++) { Particle *tempPart = &save->particles[n]; + auto &type = tempPart->type; + if (!type) + { + continue; + } + tempPart->x += (float)partP.X; tempPart->y += (float)partP.Y; int x = int(tempPart->x + 0.5f); int y = int(tempPart->y + 0.5f); - auto &type = tempPart->type; // Check various scenarios where we are unable to spawn the element, and set type to 0 to block spawning later if (!InBounds(x, y)) @@ -160,6 +165,10 @@ void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2particlesCount; n++) { Particle tempPart = save->particles[n]; + if (!tempPart.type) + { + continue; + } if (elements[tempPart.type].CreateAllowed) {