Fix possible crash when creating stamps

The save's blockSize was set one cell too short, so extend it by one (by using RectBetween). This fixes a crash when serializing save data that had particles outside its range.
This commit is contained in:
jacob1
2024-10-15 23:12:35 -04:00
parent 948f6bf27f
commit 6a903ed132

View File

@@ -312,7 +312,7 @@ void Simulation::Load(const GameSave *save, bool includePressure, Vec2<int> bloc
std::unique_ptr<GameSave> Simulation::Save(bool includePressure, Rect<int> partR) // particle coordinates std::unique_ptr<GameSave> Simulation::Save(bool includePressure, Rect<int> partR) // particle coordinates
{ {
auto blockR = RectSized(partR.pos / CELL, partR.size / CELL); auto blockR = RectBetween(partR.pos / CELL, (partR.pos + partR.size) / CELL);
auto blockP = blockR.pos; auto blockP = blockR.pos;
auto newSave = std::make_unique<GameSave>(blockR.size); auto newSave = std::make_unique<GameSave>(blockR.size);