TPT: Add ptypes.enabled checks to a few more places 61f39f5464

This commit is contained in:
Simon Robertshaw 2012-07-25 19:42:53 +01:00
parent a5d6c56f8c
commit a033fe7e49
9 changed files with 13 additions and 12 deletions

View File

@ -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;
}
}

View File

@ -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++)

View File

@ -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++)

View File

@ -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)

View File

@ -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++) {

View File

@ -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++)
{

View File

@ -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++)
{

View File

@ -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;

View File

@ -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++;