From 7899cb8088fa4a2dc08936d9aeb829561d708b8a Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 4 Apr 2020 12:19:18 -0700 Subject: [PATCH] Condense some nested else-if statements It's better to write 'else if' than 'else { if }'. --- desktop_version/src/Logic.cpp | 42 ++++++++++------------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index 4e4ec015..c1456d20 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -1044,12 +1044,9 @@ void gamelogic() { obj.entities[i].xp += 320; } - else + else if (obj.entities[i].xp > 310) { - if (obj.entities[i].xp > 310) - { - obj.entities[i].xp -= 320; - } + obj.entities[i].xp -= 320; } } } @@ -1064,12 +1061,9 @@ void gamelogic() { obj.entities[i].yp += 232; } - else + else if (obj.entities[i].yp > 226) { - if (obj.entities[i].yp > 226) - { - obj.entities[i].yp -= 232; - } + obj.entities[i].yp -= 232; } } } @@ -1088,12 +1082,9 @@ void gamelogic() { obj.entities[i].xp += 400; } - else + else if (obj.entities[i].xp > 320) { - if (obj.entities[i].xp > 320) - { - obj.entities[i].xp -= 400; - } + obj.entities[i].xp -= 400; } } else @@ -1102,12 +1093,9 @@ void gamelogic() { obj.entities[i].xp += 320; } - else + else if (obj.entities[i].xp > 310) { - if (obj.entities[i].xp > 310) - { - obj.entities[i].xp -= 320; - } + obj.entities[i].xp -= 320; } } } @@ -1134,12 +1122,9 @@ void gamelogic() { obj.entities[i].yp += 232; } - else + else if (obj.entities[i].yp > 226) { - if (obj.entities[i].yp > 226) - { - obj.entities[i].yp -= 232; - } + obj.entities[i].yp -= 232; } } } @@ -1154,12 +1139,9 @@ void gamelogic() { obj.entities[i].xp += 350; } - else + else if (obj.entities[i].xp > 320) { - if (obj.entities[i].xp > 320) - { - obj.entities[i].xp -= 350; - } + obj.entities[i].xp -= 350; } } }