Fix particle maps sometimes being stale when pasting
This restrict effects of paste-time de-stacking to positions under particles being pasted. If this is not done, particles beyond the paste area can be wrongfully killed, see #889.
This commit is contained in:
parent
853c47b0bd
commit
d02242714e
@ -87,7 +87,8 @@ int Simulation::Load(const GameSave * originalSave, bool includePressure, int fu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int r;
|
RecalcFreeParticles(false);
|
||||||
|
|
||||||
bool doFullScan = false;
|
bool doFullScan = false;
|
||||||
for (int n = 0; n < NPART && n < save->particlesCount; n++)
|
for (int n = 0; n < NPART && n < save->particlesCount; n++)
|
||||||
{
|
{
|
||||||
@ -133,13 +134,13 @@ int Simulation::Load(const GameSave * originalSave, bool includePressure, int fu
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((r = pmap[y][x]))
|
if (pmap[y][x])
|
||||||
{
|
{
|
||||||
// Particle already exists in this location. Set pmap to 0, then kill it and all stacked particles in the loop below
|
// Particle already exists in this location. Set pmap to 0, then kill it and all stacked particles in the loop below
|
||||||
pmap[y][x] = 0;
|
pmap[y][x] = 0;
|
||||||
doFullScan = true;
|
doFullScan = true;
|
||||||
}
|
}
|
||||||
else if ((r = photons[y][x]))
|
else if (photons[y][x])
|
||||||
{
|
{
|
||||||
// Particle already exists in this location. Set photons to 0, then kill it and all stacked particles in the loop below
|
// Particle already exists in this location. Set photons to 0, then kill it and all stacked particles in the loop below
|
||||||
photons[y][x] = 0;
|
photons[y][x] = 0;
|
||||||
@ -169,7 +170,6 @@ int Simulation::Load(const GameSave * originalSave, bool includePressure, int fu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
|
||||||
// Map of soap particles loaded into this save, old ID -> new ID
|
// Map of soap particles loaded into this save, old ID -> new ID
|
||||||
std::map<unsigned int, unsigned int> soapList;
|
std::map<unsigned int, unsigned int> soapList;
|
||||||
for (int n = 0; n < NPART && n < save->particlesCount; n++)
|
for (int n = 0; n < NPART && n < save->particlesCount; n++)
|
||||||
@ -209,7 +209,7 @@ int Simulation::Load(const GameSave * originalSave, bool includePressure, int fu
|
|||||||
// Allocate particle (this location is guaranteed to be empty due to "full scan" logic above)
|
// Allocate particle (this location is guaranteed to be empty due to "full scan" logic above)
|
||||||
if (pfree == -1)
|
if (pfree == -1)
|
||||||
break;
|
break;
|
||||||
i = pfree;
|
auto i = pfree;
|
||||||
pfree = parts[i].life;
|
pfree = parts[i].life;
|
||||||
if (i > parts_lastActiveIndex)
|
if (i > parts_lastActiveIndex)
|
||||||
parts_lastActiveIndex = i;
|
parts_lastActiveIndex = i;
|
||||||
|
Reference in New Issue
Block a user