mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Fix nested if-statement chains relating to entities in Entity.cpp
These would be of the form if (cond1) { if (cond2) { if (cond3) { thing; } } } which is really annoying to read and could've been written as if (cond1 && cond2 && cond3) { thing; } so that's what I'm fixing here. There will be another commit later that fixes this but in places related to blocks.
This commit is contained in:
parent
e40a4c3948
commit
2f3eeccdf0
1 changed files with 72 additions and 85 deletions
|
@ -4106,11 +4106,8 @@ float entityclass::hplatformat()
|
|||
//Returns first entity of horizontal platform at (px, py), -1000 otherwise.
|
||||
for (size_t i = 0; i < entities.size(); i++)
|
||||
{
|
||||
if (entities[i].rule == 2)
|
||||
{
|
||||
if (entities[i].behave >= 2)
|
||||
{
|
||||
if (entities[i].xp == px && entities[i].yp == py)
|
||||
if (entities[i].rule == 2 && entities[i].behave >= 2
|
||||
&& entities[i].xp == px && entities[i].yp == py)
|
||||
{
|
||||
if (entities[i].behave == 8) //threadmill!
|
||||
{
|
||||
|
@ -4126,8 +4123,6 @@ float entityclass::hplatformat()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1000;
|
||||
}
|
||||
|
||||
|
@ -4161,9 +4156,8 @@ bool entityclass::entityhlinecollide( int t, int l )
|
|||
bool entityclass::entityvlinecollide( int t, int l )
|
||||
{
|
||||
//Returns true is entity t collided with the vertical line l.
|
||||
if(entities[t].yp + entities[t].cy+entities[t].h>=entities[l].yp)
|
||||
{
|
||||
if(entities[t].yp + entities[t].cy<=entities[l].yp+entities[l].h)
|
||||
if(entities[t].yp + entities[t].cy+entities[t].h>=entities[l].yp
|
||||
&& entities[t].yp + entities[t].cy<=entities[l].yp+entities[l].h)
|
||||
{
|
||||
linetemp = 0;
|
||||
|
||||
|
@ -4175,14 +4169,13 @@ bool entityclass::entityvlinecollide( int t, int l )
|
|||
if (linetemp > -4 && linetemp < 4) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool entityclass::entitywarphlinecollide(int t, int l) {
|
||||
//Returns true is entity t collided with the horizontal line l.
|
||||
if(entities[t].xp + entities[t].cx+entities[t].w>=entities[l].xp){
|
||||
if(entities[t].xp + entities[t].cx<=entities[l].xp+entities[l].w){
|
||||
if(entities[t].xp + entities[t].cx+entities[t].w>=entities[l].xp
|
||||
&&entities[t].xp + entities[t].cx<=entities[l].xp+entities[l].w){
|
||||
linetemp = 0;
|
||||
if (entities[l].yp < 120) {
|
||||
//Top line
|
||||
|
@ -4208,14 +4201,13 @@ bool entityclass::entitywarphlinecollide(int t, int l) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool entityclass::entitywarpvlinecollide(int t, int l) {
|
||||
//Returns true is entity t collided with the vertical warp line l.
|
||||
if(entities[t].yp + entities[t].cy+entities[t].h>=entities[l].yp){
|
||||
if (entities[t].yp + entities[t].cy <= entities[l].yp + entities[l].h) {
|
||||
if(entities[t].yp + entities[t].cy+entities[t].h>=entities[l].yp
|
||||
&& entities[t].yp + entities[t].cy <= entities[l].yp + entities[l].h) {
|
||||
linetemp = 0;
|
||||
if (entities[l].xp < 160) {
|
||||
//Left hand line
|
||||
|
@ -4237,7 +4229,6 @@ bool entityclass::entitywarpvlinecollide(int t, int l) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4566,23 +4557,19 @@ void entityclass::customwarplinecheck(int i) {
|
|||
//We test entity to entity
|
||||
for (int j = 0; j < (int) entities.size(); j++) {
|
||||
if (i != j) {//Active
|
||||
if (entities[i].rule == 0 && entities[j].rule == 5) { //Player vs vertical line!
|
||||
if (entities[j].type == 51 || entities[j].type == 52) {
|
||||
if (entitywarpvlinecollide(i, j)) {
|
||||
if (entities[i].rule == 0 && entities[j].rule == 5 //Player vs vertical line!
|
||||
&& (entities[j].type == 51 || entities[j].type == 52)
|
||||
&& entitywarpvlinecollide(i, j)) {
|
||||
customwarpmodevon = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entities[i].rule == 0 && entities[j].rule == 7){ //Player vs horizontal WARP line
|
||||
if (entities[j].type == 53 || entities[j].type == 54) {
|
||||
if (entitywarphlinecollide(i, j)) {
|
||||
if (entities[i].rule == 0 && entities[j].rule == 7 //Player vs horizontal WARP line
|
||||
&& (entities[j].type == 53 || entities[j].type == 54)
|
||||
&& entitywarphlinecollide(i, j)) {
|
||||
customwarpmodehon = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void entityclass::entitycollisioncheck()
|
||||
|
|
Loading…
Reference in a new issue