diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 299b2e7b7..351ffb9de 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -442,7 +442,7 @@ static Rect SaneSaveRect(Vec2 point1, Vec2 point2) auto tly = std::min(point1.Y, point2.Y); auto brx = std::max(point1.X, point2.X); auto bry = std::max(point1.Y, point2.Y); - return RectBetween(Vec2{ tlx, tly } / CELL, Vec2{ brx, bry } / CELL); + return RectBetween(Vec2{ tlx, tly }, Vec2{ brx, bry }); } ByteString GameController::StampRegion(ui::Point point1, ui::Point point2) @@ -1146,7 +1146,7 @@ void GameController::OpenSearch(String searchText) void GameController::OpenLocalSaveWindow(bool asCurrent) { Simulation * sim = gameModel->GetSimulation(); - auto gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour(), CELLS.OriginRect()); + auto gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour(), RES.OriginRect()); if(!gameSave) { new ErrorMessage("Error", "Unable to build save."); @@ -1357,7 +1357,7 @@ void GameController::OpenSaveWindow() if(gameModel->GetUser().UserID) { Simulation * sim = gameModel->GetSimulation(); - auto gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour(), CELLS.OriginRect()); + auto gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour(), RES.OriginRect()); if(!gameSave) { new ErrorMessage("Error", "Unable to build save."); @@ -1399,7 +1399,7 @@ void GameController::SaveAsCurrent() if(gameModel->GetSave() && gameModel->GetUser().UserID && gameModel->GetUser().Username == gameModel->GetSave()->GetUserName()) { Simulation * sim = gameModel->GetSimulation(); - auto gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour(), CELLS.OriginRect()); + auto gameSave = sim->Save(gameModel->GetIncludePressure() != gameView->ShiftBehaviour(), RES.OriginRect()); if(!gameSave) { new ErrorMessage("Error", "Unable to build save."); diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 117d725e7..4053c6e88 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -19,7 +19,7 @@ extern int Element_LOLZ_lolz[XRES/9][YRES/9]; extern int Element_LOVE_RuleTable[9][9]; extern int Element_LOVE_love[XRES/9][YRES/9]; -void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2 blockP) +void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2 blockP) // block coordinates { auto save = std::unique_ptr(new GameSave(*originalSave)); @@ -335,10 +335,10 @@ void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2 Simulation::Save(bool includePressure, Rect blockR) +std::unique_ptr Simulation::Save(bool includePressure, Rect partR) // particle coordinates { + auto blockR = RectBetween(partR.TopLeft / CELL, partR.BottomRight / CELL); auto blockP = blockR.TopLeft; - auto partR = RectSized(blockR.TopLeft * CELL, blockR.Size() * CELL); auto newSave = std::make_unique(blockR.Size()); auto &possiblyCarriesType = Particle::PossiblyCarriesType(); diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index 57632d8b9..f274d36cc 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -121,8 +121,8 @@ public: uint64_t frameCount; bool ensureDeterminism; - void Load(const GameSave *save, bool includePressure, Vec2 blockP); - std::unique_ptr Save(bool includePressure, Rect blockR); + void Load(const GameSave *save, bool includePressure, Vec2 blockP); // block coordinates + std::unique_ptr Save(bool includePressure, Rect partR); // particle coordinates void SaveSimOptions(GameSave &gameSave); SimulationSample GetSample(int x, int y);