mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-11-10 21:19: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:
parent
9de5b57989
commit
313c2661af
1 changed files with 28 additions and 64 deletions
|
@ -1090,15 +1090,12 @@ void entityclass::removetrigger( int t )
|
||||||
{
|
{
|
||||||
for(size_t i=0; i<blocks.size(); i++)
|
for(size_t i=0; i<blocks.size(); i++)
|
||||||
{
|
{
|
||||||
if(blocks[i].type == TRIGGER)
|
if(blocks[i].type == TRIGGER && blocks[i].trigger == t)
|
||||||
{
|
|
||||||
if (blocks[i].trigger == t)
|
|
||||||
{
|
{
|
||||||
removeblock_iter(i);
|
removeblock_iter(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void entityclass::copylinecross( int t )
|
void entityclass::copylinecross( int t )
|
||||||
{
|
{
|
||||||
|
@ -3757,16 +3754,13 @@ bool entityclass::checkdamage()
|
||||||
|
|
||||||
for (size_t j=0; j<blocks.size(); j++)
|
for (size_t j=0; j<blocks.size(); j++)
|
||||||
{
|
{
|
||||||
if (blocks[j].type == DAMAGE)
|
if (blocks[j].type == DAMAGE && help.intersects(blocks[j].rect, temprect))
|
||||||
{
|
|
||||||
if(help.intersects(blocks[j].rect, temprect))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3785,16 +3779,13 @@ bool entityclass::scmcheckdamage()
|
||||||
|
|
||||||
for (size_t j=0; j<blocks.size(); j++)
|
for (size_t j=0; j<blocks.size(); j++)
|
||||||
{
|
{
|
||||||
if (blocks[j].type == DAMAGE)
|
if (blocks[j].type == DAMAGE && help.intersects(blocks[j].rect, temprect))
|
||||||
{
|
|
||||||
if(help.intersects(blocks[j].rect, temprect))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3823,9 +3814,7 @@ int entityclass::checktrigger()
|
||||||
|
|
||||||
for (size_t j=0; j<blocks.size(); j++)
|
for (size_t j=0; j<blocks.size(); j++)
|
||||||
{
|
{
|
||||||
if (blocks[j].type == TRIGGER)
|
if (blocks[j].type == TRIGGER && help.intersects(blocks[j].rect, temprect))
|
||||||
{
|
|
||||||
if (help.intersects(blocks[j].rect, temprect))
|
|
||||||
{
|
{
|
||||||
activetrigger = blocks[j].trigger;
|
activetrigger = blocks[j].trigger;
|
||||||
return blocks[j].trigger;
|
return blocks[j].trigger;
|
||||||
|
@ -3833,7 +3822,6 @@ int entityclass::checktrigger()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3852,16 +3840,13 @@ int entityclass::checkactivity()
|
||||||
|
|
||||||
for (size_t j=0; j<blocks.size(); j++)
|
for (size_t j=0; j<blocks.size(); j++)
|
||||||
{
|
{
|
||||||
if (blocks[j].type == ACTIVITY)
|
if (blocks[j].type == ACTIVITY && help.intersects(blocks[j].rect, temprect))
|
||||||
{
|
|
||||||
if (help.intersects(blocks[j].rect, temprect))
|
|
||||||
{
|
{
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
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
|
//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++)
|
for (size_t i = 0; i < blocks.size(); i++)
|
||||||
{
|
{
|
||||||
if (true) //FIXME: remove this later (no more 'active')
|
if (blocks[i].type == BLOCK && help.intersects(blocks[i].rect, temprect))
|
||||||
{
|
|
||||||
if (blocks[i].type == BLOCK)
|
|
||||||
{
|
|
||||||
if (help.intersects(blocks[i].rect, temprect))
|
|
||||||
{
|
{
|
||||||
px = blocks[i].xp;
|
px = blocks[i].xp;
|
||||||
py = blocks[i].yp;
|
py = blocks[i].yp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3907,37 +3886,22 @@ bool entityclass::checkblocks()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < blocks.size(); i++)
|
for (size_t i = 0; i < blocks.size(); i++)
|
||||||
{
|
{
|
||||||
if (true) //FIXME: remove this later (no more 'active')
|
if(!skipdirblocks && blocks[i].type == DIRECTIONAL)
|
||||||
{
|
|
||||||
if(!skipdirblocks)
|
|
||||||
{
|
|
||||||
if (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 == 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 (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 == 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 (dx <= 0 && blocks[i].trigger == 3) if (help.intersects(blocks[i].rect, temprect)) return true;
|
||||||
}
|
}
|
||||||
}
|
if (blocks[i].type == BLOCK && help.intersects(blocks[i].rect, temprect))
|
||||||
if (blocks[i].type == BLOCK)
|
|
||||||
{
|
|
||||||
if (help.intersects(blocks[i].rect, temprect))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
if (blocks[i].type == SAFE && (dr)==1 && help.intersects(blocks[i].rect, temprect))
|
||||||
if (blocks[i].type == SAFE)
|
|
||||||
{
|
|
||||||
if( (dr)==1)
|
|
||||||
{
|
|
||||||
if (help.intersects(blocks[i].rect, temprect))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue