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.
This commit is contained in:
Tamás Bálint Misius 2023-06-02 08:19:32 +02:00
parent 28a701a756
commit 6fb893a8de
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -61,12 +61,17 @@ void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2<i
for (int n = 0; n < NPART && n < save->particlesCount; 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, Vec2<i
for (int n = 0; n < NPART && n < save->particlesCount; n++)
{
Particle tempPart = save->particles[n];
if (!tempPart.type)
{
continue;
}
if (elements[tempPart.type].CreateAllowed)
{