Skip to content

Commit

Permalink
fix loading saves with stacked particles
Browse files Browse the repository at this point in the history
  • Loading branch information
krawthekrow authored and jacob1 committed Dec 20, 2017
1 parent e956e7c commit 7ce0f47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/gui/filebrowser/FileBrowserActivity.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <sstream>
#include <iostream>
#include <algorithm>
#include "FileBrowserActivity.h"
#include "gui/interface/Label.h"
#include "gui/interface/Textbox.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ class LoadFilesTask: public Task
virtual bool doWork()
{
std::vector<std::string> files = Client::Ref().DirectorySearch(directory, search, ".cps");

sort(files.rbegin(), files.rend());

notifyProgress(-1);
for(std::vector<std::string>::iterator iter = files.begin(), end = files.end(); iter != end; ++iter)
Expand Down
4 changes: 1 addition & 3 deletions src/simulation/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,13 @@ int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure
elementCount[parts[r>>8].type]--;
parts[r>>8] = tempPart;
i = r>>8;
pmap[y][x] = tempPart.type | i<<8;
elementCount[tempPart.type]++;
}
else if ((r = photons[y][x]))
{
elementCount[parts[r>>8].type]--;
parts[r>>8] = tempPart;
i = r>>8;
photons[y][x] = tempPart.type | i<<8;
elementCount[tempPart.type]++;
}
//Allocate new particle
Expand All @@ -144,7 +142,6 @@ int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure
if (i > parts_lastActiveIndex)
parts_lastActiveIndex = i;
parts[i] = tempPart;
pmap[y][x] = tempPart.type | i<<8;
elementCount[tempPart.type]++;
}

Expand Down Expand Up @@ -194,6 +191,7 @@ int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure
parts_lastActiveIndex = NPART-1;
force_stacking_check = true;
Element_PPIP::ppip_changed = 1;
RecalcFreeParticles(false);

// fix SOAP links using soapList, a map of old particle ID -> new particle ID
// loop through every old particle (loaded from save), and convert .tmp / .tmp2
Expand Down

0 comments on commit 7ce0f47

Please sign in to comment.