mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 04:01:56 +02:00
Fix some issues in elementCount
Count goes negative if an element is killed due to .life=0 on the same frame an elementRecount is scheduled element count skyrockets when recount is scheduled during game pause Element count increases by a static amount when undoing, because it schedules a recount without clearing the old counts
This commit is contained in:
@@ -545,6 +545,7 @@ Snapshot * Simulation::CreateSnapshot()
|
|||||||
void Simulation::Restore(const Snapshot & snap)
|
void Simulation::Restore(const Snapshot & snap)
|
||||||
{
|
{
|
||||||
parts_lastActiveIndex = NPART-1;
|
parts_lastActiveIndex = NPART-1;
|
||||||
|
std::fill(elementCount, elementCount+PT_NUM, 0);
|
||||||
elementRecount = true;
|
elementRecount = true;
|
||||||
force_stacking_check = true;
|
force_stacking_check = true;
|
||||||
|
|
||||||
@@ -4710,6 +4711,9 @@ void Simulation::RecalcFreeParticles(bool do_life_dec)
|
|||||||
lastPartUsed = i;
|
lastPartUsed = i;
|
||||||
NUM_PARTS ++;
|
NUM_PARTS ++;
|
||||||
|
|
||||||
|
if (elementRecount && t >= 0 && t < PT_NUM && elements[t].Enabled)
|
||||||
|
elementCount[t]++;
|
||||||
|
|
||||||
//decrease particle life
|
//decrease particle life
|
||||||
if (do_life_dec && (!sys_pause || framerender))
|
if (do_life_dec && (!sys_pause || framerender))
|
||||||
{
|
{
|
||||||
@@ -4738,9 +4742,6 @@ void Simulation::RecalcFreeParticles(bool do_life_dec)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elementRecount)
|
|
||||||
elementCount[t]++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -4764,7 +4765,7 @@ void Simulation::RecalcFreeParticles(bool do_life_dec)
|
|||||||
parts[lastPartUnused].life = parts_lastActiveIndex+1;
|
parts[lastPartUnused].life = parts_lastActiveIndex+1;
|
||||||
}
|
}
|
||||||
parts_lastActiveIndex = lastPartUsed;
|
parts_lastActiveIndex = lastPartUsed;
|
||||||
if (elementRecount && (!sys_pause || framerender))
|
if (elementRecount)
|
||||||
elementRecount = false;
|
elementRecount = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user