From e0d982367b71d3d1eb14c91c5d27b571550d935f Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 15 Jul 2013 17:42:43 -0400 Subject: [PATCH] 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 --- src/simulation/Simulation.cpp | 11 +++++------ src/simulation/Simulation.h | 1 + src/simulation/elements/TUNG.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 816591a26..de92fff9e 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::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 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 82adb6f2c..349ab1282 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 1666346be..9b5f61da9 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))