Leave the original GameSave alone in Simulation::Load
This commit is contained in:
parent
816b9eda3d
commit
d675d483bd
2
.gitignore
vendored
2
.gitignore
vendored
@ -90,4 +90,4 @@ screenshot_*
|
|||||||
*.opensdf
|
*.opensdf
|
||||||
*.sdf
|
*.sdf
|
||||||
/font/
|
/font/
|
||||||
|
compile_commands.json
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "common/tpt-minmax.h"
|
#include "common/tpt-minmax.h"
|
||||||
|
|
||||||
GameSave::GameSave(GameSave & save):
|
GameSave::GameSave(const GameSave & save):
|
||||||
majorVersion(save.majorVersion),
|
majorVersion(save.majorVersion),
|
||||||
waterEEnabled(save.waterEEnabled),
|
waterEEnabled(save.waterEEnabled),
|
||||||
legacyEnable(save.legacyEnable),
|
legacyEnable(save.legacyEnable),
|
||||||
|
@ -113,7 +113,7 @@ public:
|
|||||||
int pmapbits;
|
int pmapbits;
|
||||||
|
|
||||||
GameSave();
|
GameSave();
|
||||||
GameSave(GameSave & save);
|
GameSave(const GameSave & save);
|
||||||
GameSave(int width, int height);
|
GameSave(int width, int height);
|
||||||
GameSave(char * data, int dataSize);
|
GameSave(char * data, int dataSize);
|
||||||
GameSave(std::vector<char> data);
|
GameSave(std::vector<char> data);
|
||||||
|
@ -42,15 +42,16 @@ 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];
|
||||||
|
|
||||||
int Simulation::Load(GameSave * save, bool includePressure)
|
int Simulation::Load(const GameSave * save, bool includePressure)
|
||||||
{
|
{
|
||||||
return Load(save, includePressure, 0, 0);
|
return Load(save, includePressure, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Simulation::Load(GameSave * save, bool includePressure, int fullX, int fullY)
|
int Simulation::Load(const GameSave * originalSave, bool includePressure, int fullX, int fullY)
|
||||||
{
|
{
|
||||||
if (!save)
|
if (!originalSave)
|
||||||
return 1;
|
return 1;
|
||||||
|
auto save = std::unique_ptr<GameSave>(new GameSave(*originalSave));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
save->Expand();
|
save->Expand();
|
||||||
@ -77,9 +78,8 @@ int Simulation::Load(GameSave * save, bool includePressure, int fullX, int fullY
|
|||||||
}
|
}
|
||||||
if(save->palette.size())
|
if(save->palette.size())
|
||||||
{
|
{
|
||||||
for(std::vector<GameSave::PaletteItem>::iterator iter = save->palette.begin(), end = save->palette.end(); iter != end; ++iter)
|
for(auto &pi : save->palette)
|
||||||
{
|
{
|
||||||
GameSave::PaletteItem pi = *iter;
|
|
||||||
if (pi.second > 0 && pi.second < PT_NUM)
|
if (pi.second > 0 && pi.second < PT_NUM)
|
||||||
{
|
{
|
||||||
int myId = 0;
|
int myId = 0;
|
||||||
@ -5356,7 +5356,7 @@ void Simulation::SetCustomGOL(std::vector<CustomGOLData> newCustomGol)
|
|||||||
customGol = newCustomGol;
|
customGol = newCustomGol;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Simulation::ElementResolve(int type, int ctype)
|
String Simulation::ElementResolve(int type, int ctype) const
|
||||||
{
|
{
|
||||||
if (type == PT_LIFE)
|
if (type == PT_LIFE)
|
||||||
{
|
{
|
||||||
@ -5376,7 +5376,7 @@ String Simulation::ElementResolve(int type, int ctype)
|
|||||||
return "Empty";
|
return "Empty";
|
||||||
}
|
}
|
||||||
|
|
||||||
String Simulation::BasicParticleInfo(Particle const &sample_part)
|
String Simulation::BasicParticleInfo(Particle const &sample_part) const
|
||||||
{
|
{
|
||||||
StringBuilder sampleInfo;
|
StringBuilder sampleInfo;
|
||||||
int type = sample_part.type;
|
int type = sample_part.type;
|
||||||
|
@ -115,8 +115,8 @@ public:
|
|||||||
int sandcolour_frame;
|
int sandcolour_frame;
|
||||||
int deco_space;
|
int deco_space;
|
||||||
|
|
||||||
int Load(GameSave * save, bool includePressure);
|
int Load(const GameSave * save, bool includePressure);
|
||||||
int Load(GameSave * save, bool includePressure, int x, int y);
|
int Load(const GameSave * save, bool includePressure, int x, int y);
|
||||||
GameSave * Save(bool includePressure);
|
GameSave * Save(bool includePressure);
|
||||||
GameSave * Save(bool includePressure, int x1, int y1, int x2, int y2);
|
GameSave * Save(bool includePressure, int x1, int y1, int x2, int y2);
|
||||||
void SaveSimOptions(GameSave * gameSave);
|
void SaveSimOptions(GameSave * gameSave);
|
||||||
@ -135,10 +135,10 @@ public:
|
|||||||
int eval_move(int pt, int nx, int ny, unsigned *rr);
|
int eval_move(int pt, int nx, int ny, unsigned *rr);
|
||||||
void init_can_move();
|
void init_can_move();
|
||||||
bool IsWallBlocking(int x, int y, int type);
|
bool IsWallBlocking(int x, int y, int type);
|
||||||
bool IsElement(int type) {
|
bool IsElement(int type) const {
|
||||||
return (type > 0 && type < PT_NUM && elements[type].Enabled);
|
return (type > 0 && type < PT_NUM && elements[type].Enabled);
|
||||||
}
|
}
|
||||||
bool IsElementOrNone(int type) {
|
bool IsElementOrNone(int type) const {
|
||||||
return (type >= 0 && type < PT_NUM && elements[type].Enabled);
|
return (type >= 0 && type < PT_NUM && elements[type].Enabled);
|
||||||
}
|
}
|
||||||
void create_cherenkov_photon(int pp);
|
void create_cherenkov_photon(int pp);
|
||||||
@ -221,8 +221,8 @@ public:
|
|||||||
static int remainder_p(int x, int y);
|
static int remainder_p(int x, int y);
|
||||||
static float remainder_p(float x, float y);
|
static float remainder_p(float x, float y);
|
||||||
|
|
||||||
String ElementResolve(int type, int ctype);
|
String ElementResolve(int type, int ctype) const;
|
||||||
String BasicParticleInfo(Particle const &sample_part);
|
String BasicParticleInfo(Particle const &sample_part) const;
|
||||||
|
|
||||||
|
|
||||||
struct CustomGOLData
|
struct CustomGOLData
|
||||||
|
Loading…
Reference in New Issue
Block a user