Skip to content

Commit

Permalink
fix ambient heat not loading in ctrl+c paste, fix pressure resetting …
Browse files Browse the repository at this point in the history
…to 0 when loading saves without pressure
  • Loading branch information
jacob1 committed Nov 24, 2017
1 parent 78fb27b commit 3529f6f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
32 changes: 18 additions & 14 deletions src/client/GameSave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@ extern "C"
#include "hmap.h"
}

GameSave::GameSave(GameSave & save) :
waterEEnabled(save.waterEEnabled),
legacyEnable(save.legacyEnable),
gravityEnable(save.gravityEnable),
aheatEnable(save.aheatEnable),
paused(save.paused),
gravityMode(save.gravityMode),
airMode(save.airMode),
edgeMode(save.edgeMode),
signs(save.signs),
palette(save.palette),
expanded(save.expanded),
hasOriginalData(save.hasOriginalData),
originalData(save.originalData)
GameSave::GameSave(GameSave & save):
waterEEnabled(save.waterEEnabled),
legacyEnable(save.legacyEnable),
gravityEnable(save.gravityEnable),
aheatEnable(save.aheatEnable),
paused(save.paused),
gravityMode(save.gravityMode),
airMode(save.airMode),
edgeMode(save.edgeMode),
signs(save.signs),
palette(save.palette),
expanded(save.expanded),
hasOriginalData(save.hasOriginalData),
originalData(save.originalData)
{
InitData();
hasPressure = save.hasPressure;
hasAmbientHeat = save.hasAmbientHeat;
if (save.expanded)
{
setSize(save.blockWidth, save.blockHeight);
Expand Down Expand Up @@ -149,6 +151,7 @@ void GameSave::InitData()
velocityY = NULL;
ambientHeat = NULL;
fromNewerVersion = false;
hasPressure = false;
hasAmbientHeat = false;
authors.clear();
}
Expand Down Expand Up @@ -843,6 +846,7 @@ void GameSave::readOPS(char * data, int dataLength)
pressure[blockY+y][blockX+x] = ((i+(i2<<8))/128.0f)-256;
}
}
hasPressure = true;
}

//Read vx data
Expand Down
1 change: 1 addition & 0 deletions src/client/GameSave.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class GameSave

int blockWidth, blockHeight;
bool fromNewerVersion;
bool hasPressure;
bool hasAmbientHeat;

//Simulation data
Expand Down
10 changes: 7 additions & 3 deletions src/simulation/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,12 @@ int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure
}
if (includePressure)
{
pv[saveBlockY+blockY][saveBlockX+blockX] = save->pressure[saveBlockY][saveBlockX];
vx[saveBlockY+blockY][saveBlockX+blockX] = save->velocityX[saveBlockY][saveBlockX];
vy[saveBlockY+blockY][saveBlockX+blockX] = save->velocityY[saveBlockY][saveBlockX];
if (save->hasPressure)
{
pv[saveBlockY+blockY][saveBlockX+blockX] = save->pressure[saveBlockY][saveBlockX];
vx[saveBlockY+blockY][saveBlockX+blockX] = save->velocityX[saveBlockY][saveBlockX];
vy[saveBlockY+blockY][saveBlockX+blockX] = save->velocityY[saveBlockY][saveBlockX];
}
if (save->hasAmbientHeat)
hv[saveBlockY+blockY][saveBlockX+blockX] = save->ambientHeat[saveBlockY][saveBlockX];
}
Expand Down Expand Up @@ -387,6 +390,7 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2, bool i
newSave->velocityX[saveBlockY][saveBlockX] = vx[saveBlockY+blockY][saveBlockX+blockX];
newSave->velocityY[saveBlockY][saveBlockX] = vy[saveBlockY+blockY][saveBlockX+blockX];
newSave->ambientHeat[saveBlockY][saveBlockX] = hv[saveBlockY+blockY][saveBlockX+blockX];
newSave->hasPressure = true;
newSave->hasAmbientHeat = true;
}
}
Expand Down

0 comments on commit 3529f6f

Please sign in to comment.