Pass particle coordinates to Simulation::Save
Both Save and Load were recently migrated to block coordinates, see 7ef02a6c0b
. The expected behaviour for Save is to extend the particle-oriented rect it gets to the smallest enclosing block-oriented rect and save all blocks inside that rect, but exclude the particles that fall outside the original rect. Using block coordinates made this exclusion impossible.
This commit is contained in:
parent
9884b4108e
commit
6179071351
@ -442,7 +442,7 @@ static Rect<int> SaneSaveRect(Vec2<int> point1, Vec2<int> point2)
|
|||||||
auto tly = std::min(point1.Y, point2.Y);
|
auto tly = std::min(point1.Y, point2.Y);
|
||||||
auto brx = std::max(point1.X, point2.X);
|
auto brx = std::max(point1.X, point2.X);
|
||||||
auto bry = std::max(point1.Y, point2.Y);
|
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)
|
ByteString GameController::StampRegion(ui::Point point1, ui::Point point2)
|
||||||
@ -1146,7 +1146,7 @@ void GameController::OpenSearch(String searchText)
|
|||||||
void GameController::OpenLocalSaveWindow(bool asCurrent)
|
void GameController::OpenLocalSaveWindow(bool asCurrent)
|
||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
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)
|
if(!gameSave)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", "Unable to build save.");
|
new ErrorMessage("Error", "Unable to build save.");
|
||||||
@ -1357,7 +1357,7 @@ void GameController::OpenSaveWindow()
|
|||||||
if(gameModel->GetUser().UserID)
|
if(gameModel->GetUser().UserID)
|
||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
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)
|
if(!gameSave)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", "Unable to build save.");
|
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())
|
if(gameModel->GetSave() && gameModel->GetUser().UserID && gameModel->GetUser().Username == gameModel->GetSave()->GetUserName())
|
||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
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)
|
if(!gameSave)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", "Unable to build save.");
|
new ErrorMessage("Error", "Unable to build save.");
|
||||||
|
@ -19,7 +19,7 @@ extern int Element_LOLZ_lolz[XRES/9][YRES/9];
|
|||||||
extern int Element_LOVE_RuleTable[9][9];
|
extern int Element_LOVE_RuleTable[9][9];
|
||||||
extern int Element_LOVE_love[XRES/9][YRES/9];
|
extern int Element_LOVE_love[XRES/9][YRES/9];
|
||||||
|
|
||||||
void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2<int> blockP)
|
void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2<int> blockP) // block coordinates
|
||||||
{
|
{
|
||||||
auto save = std::unique_ptr<GameSave>(new GameSave(*originalSave));
|
auto save = std::unique_ptr<GameSave>(new GameSave(*originalSave));
|
||||||
|
|
||||||
@ -335,10 +335,10 @@ void Simulation::Load(const GameSave *originalSave, bool includePressure, Vec2<i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<GameSave> Simulation::Save(bool includePressure, Rect<int> blockR)
|
std::unique_ptr<GameSave> Simulation::Save(bool includePressure, Rect<int> partR) // particle coordinates
|
||||||
{
|
{
|
||||||
|
auto blockR = RectBetween(partR.TopLeft / CELL, partR.BottomRight / CELL);
|
||||||
auto blockP = blockR.TopLeft;
|
auto blockP = blockR.TopLeft;
|
||||||
auto partR = RectSized(blockR.TopLeft * CELL, blockR.Size() * CELL);
|
|
||||||
|
|
||||||
auto newSave = std::make_unique<GameSave>(blockR.Size());
|
auto newSave = std::make_unique<GameSave>(blockR.Size());
|
||||||
auto &possiblyCarriesType = Particle::PossiblyCarriesType();
|
auto &possiblyCarriesType = Particle::PossiblyCarriesType();
|
||||||
|
@ -121,8 +121,8 @@ public:
|
|||||||
uint64_t frameCount;
|
uint64_t frameCount;
|
||||||
bool ensureDeterminism;
|
bool ensureDeterminism;
|
||||||
|
|
||||||
void Load(const GameSave *save, bool includePressure, Vec2<int> blockP);
|
void Load(const GameSave *save, bool includePressure, Vec2<int> blockP); // block coordinates
|
||||||
std::unique_ptr<GameSave> Save(bool includePressure, Rect<int> blockR);
|
std::unique_ptr<GameSave> Save(bool includePressure, Rect<int> partR); // particle coordinates
|
||||||
void SaveSimOptions(GameSave &gameSave);
|
void SaveSimOptions(GameSave &gameSave);
|
||||||
SimulationSample GetSample(int x, int y);
|
SimulationSample GetSample(int x, int y);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user