summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-25 18:42:53 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-25 18:42:53 (GMT)
commita033fe7e496cfb5c6f4ec78e607408418858e765 (patch)
treea94e07b4cad1b0e81809682c5b48eee88c075e7e /src
parenta5d6c56f8cb5eab1d0c9823142c61de97230ee94 (diff)
downloadpowder-a033fe7e496cfb5c6f4ec78e607408418858e765.zip
powder-a033fe7e496cfb5c6f4ec78e607408418858e765.tar.gz
TPT: Add ptypes.enabled checks to a few more places 61f39f5464
Diffstat (limited to 'src')
-rw-r--r--src/simulation/Simulation.cpp3
-rw-r--r--src/simulation/elements/BCLN.cpp2
-rw-r--r--src/simulation/elements/CLNE.cpp2
-rw-r--r--src/simulation/elements/CONV.cpp4
-rw-r--r--src/simulation/elements/NEUT.cpp2
-rw-r--r--src/simulation/elements/PBCN.cpp4
-rw-r--r--src/simulation/elements/PCLN.cpp4
-rw-r--r--src/simulation/elements/SPRK.cpp2
-rw-r--r--src/simulation/elements/STKM.cpp2
9 files changed, 13 insertions, 12 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index b5d07bc..88457c3 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -167,7 +167,8 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2)
Particle tempPart = parts[i];
tempPart.x -= fullX;
tempPart.y -= fullY;
- *newSave << tempPart;
+ if(elements[tempPart.type].Enabled)
+ *newSave << tempPart;
}
}
diff --git a/src/simulation/elements/BCLN.cpp b/src/simulation/elements/BCLN.cpp
index 457a9aa..80a5d44 100644
--- a/src/simulation/elements/BCLN.cpp
+++ b/src/simulation/elements/BCLN.cpp
@@ -57,7 +57,7 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS)
parts[i].vx += advection*sim->vx[y/CELL][x/CELL];
parts[i].vy += advection*sim->vy[y/CELL][x/CELL];
}
- if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
+ if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
diff --git a/src/simulation/elements/CLNE.cpp b/src/simulation/elements/CLNE.cpp
index 62c67c0..6ffe4f1 100644
--- a/src/simulation/elements/CLNE.cpp
+++ b/src/simulation/elements/CLNE.cpp
@@ -49,7 +49,7 @@ Element_CLNE::Element_CLNE()
//#TPT-Directive ElementHeader Element_CLNE static int update(UPDATE_FUNC_ARGS)
int Element_CLNE::update(UPDATE_FUNC_ARGS)
{
- if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
+ if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
diff --git a/src/simulation/elements/CONV.cpp b/src/simulation/elements/CONV.cpp
index 4ee4682..de31d73 100644
--- a/src/simulation/elements/CONV.cpp
+++ b/src/simulation/elements/CONV.cpp
@@ -50,7 +50,7 @@ Element_CONV::Element_CONV()
int Element_CONV::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
- if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
+ if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
@@ -72,7 +72,7 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
}
}
}
- else if(parts[i].ctype>0 && parts[i].ctype<PT_NUM && parts[i].ctype!=PT_CONV) {
+ else if(parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype]->Enabled && parts[i].ctype!=PT_CONV) {
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp
index 0d882d8..4641370 100644
--- a/src/simulation/elements/NEUT.cpp
+++ b/src/simulation/elements/NEUT.cpp
@@ -172,7 +172,7 @@ int Element_NEUT::create_n_parts(Simulation * sim, int n, int x, int y, float vx
if (n>340) {
n = 340;
}
- if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM)
+ if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM || !sim->elements[t].Enabled)
return -1;
for (c=0; c<n; c++) {
diff --git a/src/simulation/elements/PBCN.cpp b/src/simulation/elements/PBCN.cpp
index 088f807..e3bc7ce 100644
--- a/src/simulation/elements/PBCN.cpp
+++ b/src/simulation/elements/PBCN.cpp
@@ -65,7 +65,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
return 1;
}
}
- if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
+ if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
@@ -105,7 +105,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
}
}
}
- if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && parts[i].life==10) {
+ if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10) {
if (parts[i].ctype==PT_PHOT) {//create photons a different way
for (rx=-1; rx<2; rx++)
{
diff --git a/src/simulation/elements/PCLN.cpp b/src/simulation/elements/PCLN.cpp
index 1b814b0..7e6b3d7 100644
--- a/src/simulation/elements/PCLN.cpp
+++ b/src/simulation/elements/PCLN.cpp
@@ -74,7 +74,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
parts[i].life = 10;
}
}
- if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
+ if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT)))
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
@@ -95,7 +95,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
parts[i].tmp = parts[r>>8].ctype;
}
}
- if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && parts[i].life==10) {
+ if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && parts[i].life==10) {
if (parts[i].ctype==PT_PHOT) {//create photons a different way
for (rx=-1; rx<2; rx++)
{
diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp
index aa2efeb..4cccdbb 100644
--- a/src/simulation/elements/SPRK.cpp
+++ b/src/simulation/elements/SPRK.cpp
@@ -56,7 +56,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
{
if (ct==PT_WATR||ct==PT_SLTW||ct==PT_PSCN||ct==PT_NSCN||ct==PT_ETRD||ct==PT_INWR)
parts[i].temp = R_TEMP + 273.15f;
- if (ct<=0 || ct>=PT_NUM)
+ if (ct<=0 || ct>=PT_NUM || !sim->elements[parts[i].ctype].Enabled)
ct = PT_METL;
sim->part_change_type(i,x,y,ct);
parts[i].ctype = PT_NONE;
diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp
index ee35105..1dd3347 100644
--- a/src/simulation/elements/STKM.cpp
+++ b/src/simulation/elements/STKM.cpp
@@ -85,7 +85,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
float gvx, gvy;
float gx, gy, dl, dr;
- if ((parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Falldown>0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT || parts[i].ctype == PT_LIGH)
+ if ((parts[i].ctype>0 && parts[i].ctype<PT_NUM && sim->elements[parts[i].ctype].Enabled && sim->elements[parts[i].ctype].Falldown>0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT || parts[i].ctype == PT_LIGH)
playerp->elem = parts[i].ctype;
playerp->frames++;