1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Fix nested if-statements relating to blocks in Entity.cpp

Just like earlier, these are of the form
if (cond1) { if (cond2) { if (cond3) { thing; } } }
and are really annoying to read.

Also this removes the remnants of the 'active' system that have been
replaced with 'if (true)' conditionals in order to not add noise to the
diff.
This commit is contained in:
Misa 2020-04-03 17:06:07 -07:00 committed by Ethan Lee
parent 9de5b57989
commit 313c2661af

View file

@ -1090,15 +1090,12 @@ void entityclass::removetrigger( int t )
{
for(size_t i=0; i<blocks.size(); i++)
{
if(blocks[i].type == TRIGGER)
{
if (blocks[i].trigger == t)
if(blocks[i].type == TRIGGER && blocks[i].trigger == t)
{
removeblock_iter(i);
}
}
}
}
void entityclass::copylinecross( int t )
{
@ -3757,16 +3754,13 @@ bool entityclass::checkdamage()
for (size_t j=0; j<blocks.size(); j++)
{
if (blocks[j].type == DAMAGE)
{
if(help.intersects(blocks[j].rect, temprect))
if (blocks[j].type == DAMAGE && help.intersects(blocks[j].rect, temprect))
{
return true;
}
}
}
}
}
return false;
}
@ -3785,16 +3779,13 @@ bool entityclass::scmcheckdamage()
for (size_t j=0; j<blocks.size(); j++)
{
if (blocks[j].type == DAMAGE)
{
if(help.intersects(blocks[j].rect, temprect))
if (blocks[j].type == DAMAGE && help.intersects(blocks[j].rect, temprect))
{
return true;
}
}
}
}
}
return false;
}
@ -3823,9 +3814,7 @@ int entityclass::checktrigger()
for (size_t j=0; j<blocks.size(); j++)
{
if (blocks[j].type == TRIGGER)
{
if (help.intersects(blocks[j].rect, temprect))
if (blocks[j].type == TRIGGER && help.intersects(blocks[j].rect, temprect))
{
activetrigger = blocks[j].trigger;
return blocks[j].trigger;
@ -3833,7 +3822,6 @@ int entityclass::checktrigger()
}
}
}
}
return -1;
}
@ -3852,16 +3840,13 @@ int entityclass::checkactivity()
for (size_t j=0; j<blocks.size(); j++)
{
if (blocks[j].type == ACTIVITY)
{
if (help.intersects(blocks[j].rect, temprect))
if (blocks[j].type == ACTIVITY && help.intersects(blocks[j].rect, temprect))
{
return j;
}
}
}
}
}
return -1;
}
@ -3887,19 +3872,13 @@ bool entityclass::checkplatform()
//Return true if rectset intersects a moving platform, setups px & py to the platform x & y
for (size_t i = 0; i < blocks.size(); i++)
{
if (true) //FIXME: remove this later (no more 'active')
{
if (blocks[i].type == BLOCK)
{
if (help.intersects(blocks[i].rect, temprect))
if (blocks[i].type == BLOCK && help.intersects(blocks[i].rect, temprect))
{
px = blocks[i].xp;
py = blocks[i].yp;
return true;
}
}
}
}
return false;
}
@ -3907,37 +3886,22 @@ bool entityclass::checkblocks()
{
for (size_t i = 0; i < blocks.size(); i++)
{
if (true) //FIXME: remove this later (no more 'active')
{
if(!skipdirblocks)
{
if (blocks[i].type == DIRECTIONAL)
if(!skipdirblocks && blocks[i].type == DIRECTIONAL)
{
if (dy > 0 && blocks[i].trigger == 0) if (help.intersects(blocks[i].rect, temprect)) return true;
if (dy <= 0 && blocks[i].trigger == 1) if (help.intersects(blocks[i].rect, temprect)) return true;
if (dx > 0 && blocks[i].trigger == 2) if (help.intersects(blocks[i].rect, temprect)) return true;
if (dx <= 0 && blocks[i].trigger == 3) if (help.intersects(blocks[i].rect, temprect)) return true;
}
}
if (blocks[i].type == BLOCK)
{
if (help.intersects(blocks[i].rect, temprect))
if (blocks[i].type == BLOCK && help.intersects(blocks[i].rect, temprect))
{
return true;
}
}
if (blocks[i].type == SAFE)
{
if( (dr)==1)
{
if (help.intersects(blocks[i].rect, temprect))
if (blocks[i].type == SAFE && (dr)==1 && help.intersects(blocks[i].rect, temprect))
{
return true;
}
}
}
}
}
return false;
}