mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-17 22:38:38 +01:00
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:
parent
28a701a756
commit
6fb893a8de
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user