1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-30 08:28:29 +02:00

Condense some nested if-statements in gamelogic()

It's better to write if (cond1 && cond2) than it is to write if (cond1)
{ if (cond2) }.
This commit is contained in:
Misa 2020-04-04 12:16:16 -07:00 committed by Ethan Lee
parent 3818340011
commit e6c6c7cf60

View File

@ -1037,8 +1037,8 @@ void gamelogic()
{ {
for (size_t i = 0; i < obj.entities.size(); i++) for (size_t i = 0; i < obj.entities.size(); i++)
{ {
if(obj.entities[i].type<50){ //Don't warp warp lines if(obj.entities[i].type<50 //Don't warp warp lines
if (obj.entities[i].size < 12) //Don't wrap SWN enemies && obj.entities[i].size < 12) //Don't wrap SWN enemies
{ {
if (obj.entities[i].xp <= -10) if (obj.entities[i].xp <= -10)
{ {
@ -1053,13 +1053,12 @@ void gamelogic()
} }
} }
} }
}
for (size_t i = 0; i < obj.entities.size(); i++) for (size_t i = 0; i < obj.entities.size(); i++)
{ {
if(obj.entities[i].type<50){ //Don't warp warp lines if(obj.entities[i].type<50 //Don't warp warp lines
if (obj.entities[i].size < 12) //Don't wrap SWN enemies && obj.entities[i].size < 12) //Don't wrap SWN enemies
{ {
if (obj.entities[i].yp <= -12) if (obj.entities[i].yp <= -12)
{ {
@ -1075,13 +1074,12 @@ void gamelogic()
} }
} }
} }
}
else if (map.warpx) else if (map.warpx)
{ {
for (size_t i = 0; i < obj.entities.size(); i++) for (size_t i = 0; i < obj.entities.size(); i++)
{ {
if(obj.entities[i].type<50){ //Don't warp warp lines if(obj.entities[i].type<50 //Don't warp warp lines
if (obj.entities[i].size < 12) //Don't wrap SWN enemies && obj.entities[i].size < 12) //Don't wrap SWN enemies
{ {
if (game.roomx == 118 && game.roomy == 102 && obj.entities[i].rule==1 && !map.custommode) if (game.roomx == 118 && game.roomy == 102 && obj.entities[i].rule==1 && !map.custommode)
{ {
@ -1114,7 +1112,6 @@ void gamelogic()
} }
} }
} }
}
int player = obj.getplayer(); int player = obj.getplayer();
if (game.door_down > -2 && obj.entities[player].yp >= 238) if (game.door_down > -2 && obj.entities[player].yp >= 238)
@ -1150,8 +1147,8 @@ void gamelogic()
for (size_t i = 0; i < obj.entities.size(); i++) for (size_t i = 0; i < obj.entities.size(); i++)
{ {
if(obj.entities[i].type<50){ //Don't warp warp lines if(obj.entities[i].type<50 //Don't warp warp lines
if(obj.entities[i].rule!=0) &&obj.entities[i].rule!=0)
{ {
if (obj.entities[i].xp <= -30) if (obj.entities[i].xp <= -30)
{ {
@ -1166,7 +1163,6 @@ void gamelogic()
} }
} }
} }
}
int player = obj.getplayer(); int player = obj.getplayer();
if (game.door_left > -2 && obj.entities[player].xp < -14) if (game.door_left > -2 && obj.entities[player].xp < -14)