Remove disabled elements when simulating. Fix crash when kill_part is run on elements with invalid types
This commit is contained in:
parent
69b788ba7d
commit
7018e46fac
@ -2477,7 +2477,7 @@ void Simulation::kill_part(int i)//kills particle number i
|
|||||||
if (parts[i].type == PT_NONE)
|
if (parts[i].type == PT_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(elementCount[parts[i].type] && parts[i].type)
|
if(parts[i].type > 0 && parts[i].type < PT_NUM && elementCount[parts[i].type] && parts[i].type)
|
||||||
elementCount[parts[i].type]--;
|
elementCount[parts[i].type]--;
|
||||||
if (parts[i].type == PT_STKM)
|
if (parts[i].type == PT_STKM)
|
||||||
{
|
{
|
||||||
@ -3352,7 +3352,7 @@ void Simulation::update_particles_i(int start, int inc)
|
|||||||
if (parts[i].type)
|
if (parts[i].type)
|
||||||
{
|
{
|
||||||
t = parts[i].type;
|
t = parts[i].type;
|
||||||
if (t<0 || t>=PT_NUM)
|
if (t<0 || t>=PT_NUM || !elements[i].Enabled)
|
||||||
{
|
{
|
||||||
kill_part(i);
|
kill_part(i);
|
||||||
continue;
|
continue;
|
||||||
@ -4588,11 +4588,14 @@ Simulation::Simulation():
|
|||||||
memcpy(platent, platentT, latentCount * sizeof(unsigned int));
|
memcpy(platent, platentT, latentCount * sizeof(unsigned int));
|
||||||
free(platentT);
|
free(platentT);
|
||||||
|
|
||||||
elements = new Element[PT_NUM];
|
//elements = new Element[PT_NUM];
|
||||||
std::vector<Element> elementList = GetElements();
|
std::vector<Element> elementList = GetElements();
|
||||||
for(int i = 0; i < elementList.size(); i++)
|
for(int i = 0; i < PT_NUM; i++)
|
||||||
{
|
{
|
||||||
elements[i] = elementList[i];
|
if(i < elementList.size())
|
||||||
|
elements[i] = elementList[i];
|
||||||
|
else
|
||||||
|
elements[i] = Element_NONE();
|
||||||
}
|
}
|
||||||
|
|
||||||
tools = GetTools();
|
tools = GetTools();
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
#include "WallType.h"
|
#include "WallType.h"
|
||||||
#include "GOLMenu.h"
|
#include "GOLMenu.h"
|
||||||
#include "MenuSection.h"
|
#include "MenuSection.h"
|
||||||
|
#include "elements/Element.h"
|
||||||
|
|
||||||
#define CHANNELS ((int)(MAX_TEMP-73)/100+2)
|
#define CHANNELS ((int)(MAX_TEMP-73)/100+2)
|
||||||
|
|
||||||
class Snapshot;
|
class Snapshot;
|
||||||
class Element;
|
|
||||||
class SimTool;
|
class SimTool;
|
||||||
class Brush;
|
class Brush;
|
||||||
struct SimulationSample;
|
struct SimulationSample;
|
||||||
@ -47,7 +47,8 @@ public:
|
|||||||
Air * air;
|
Air * air;
|
||||||
|
|
||||||
std::vector<sign> signs;
|
std::vector<sign> signs;
|
||||||
Element * elements;
|
Element elements[PT_NUM];
|
||||||
|
//Element * elements;
|
||||||
std::vector<SimTool*> tools;
|
std::vector<SimTool*> tools;
|
||||||
unsigned int * platent;
|
unsigned int * platent;
|
||||||
wall_type wtypes[UI_WALLCOUNT];
|
wall_type wtypes[UI_WALLCOUNT];
|
||||||
|
Loading…
Reference in New Issue
Block a user