summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-07-15 21:42:43 (GMT)
committer jacob1 <jfu614@gmail.com>2013-07-15 21:42:43 (GMT)
commite0d982367b71d3d1eb14c91c5d27b571550d935f (patch)
tree94c1d398c823b9e42fc583a09e5eaef4f183e7de /src/simulation
parentf4432b47599a2b93276658f887b97ccd2eb35875 (diff)
downloadpowder-e0d982367b71d3d1eb14c91c5d27b571550d935f.zip
powder-e0d982367b71d3d1eb14c91c5d27b571550d935f.tar.gz
fix bug where saving and loading elements in saves relied on the name being consistent between versions. The palette should only be used for lua elements
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/Simulation.cpp11
-rw-r--r--src/simulation/Simulation.h1
-rw-r--r--src/simulation/elements/TUNG.cpp2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index 816591a..de92fff 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -57,7 +57,7 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
for(std::vector<GameSave::PaletteItem>::iterator iter = save->palette.begin(), end = save->palette.end(); iter != end; ++iter)
{
GameSave::PaletteItem pi = *iter;
- if(pi.second >= 0 && pi.second < PT_NUM)
+ if(pi.second >= DEFAULT_PT_NUM && pi.second < PT_NUM)
{
int myId = 0;//pi.second;
for(int i = 0; i < PT_NUM; i++)
@@ -243,7 +243,7 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
if(storedParts)
{
- for(int i = 0; i < PT_NUM; i++)
+ for(int i = DEFAULT_PT_NUM; i < PT_NUM; i++)
{
if(elements[i].Enabled && elementCount[i])
{
@@ -3175,14 +3175,13 @@ void Simulation::delete_part(int x, int y)//calls kill_part with the particle lo
void Simulation::update_particles_i(int start, int inc)
{
int i, j, x, y, t, nx, ny, r, surround_space, s, lt, rt, nt, nnx, nny, q, golnum, z, neighbors;
- float mv, dx, dy, ix, iy, lx, ly, nrx, nry, dp, ctemph, ctempl, gravtot;
+ float mv, dx, dy, nrx, nry, dp, ctemph, ctempl, gravtot;
int fin_x, fin_y, clear_x, clear_y, stagnant;
float fin_xf, fin_yf, clear_xf, clear_yf;
float nn, ct1, ct2, swappage;
float pt = R_TEMP;
float c_heat = 0.0f;
int h_count = 0;
- int starti = (start*-1);
int surround[8];
int surround_hconduct[8];
int lighting_ok=1;
@@ -4786,9 +4785,9 @@ Simulation::Simulation():
unsigned int * platentT = LoadLatent(latentCount);
memcpy(platent, platentT, latentCount * sizeof(unsigned int));
free(platentT);
-
- //elements = new Element[PT_NUM];
+
std::vector<Element> elementList = GetElements();
+ DEFAULT_PT_NUM = elementList.size();
for(int i = 0; i < PT_NUM; i++)
{
if(i < elementList.size())
diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h
index 82adb6f..349ab12 100644
--- a/src/simulation/Simulation.h
+++ b/src/simulation/Simulation.h
@@ -114,6 +114,7 @@ public:
int pretty_powder;
int sandcolour;
int sandcolour_frame;
+ int DEFAULT_PT_NUM;
int Load(GameSave * save);
int Load(int x, int y, GameSave * save);
diff --git a/src/simulation/elements/TUNG.cpp b/src/simulation/elements/TUNG.cpp
index 1666346..9b5f61d 100644
--- a/src/simulation/elements/TUNG.cpp
+++ b/src/simulation/elements/TUNG.cpp
@@ -58,7 +58,7 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS)
bool splode = false;
if(parts[i].temp > 2400.0)
{
- int r, rx, ry, rt;
+ int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))