From b66d30354080029b9309683f891e8dc026e763e3 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 20 Jun 2020 19:29:50 -0700 Subject: [PATCH] De-duplicate 'ed.numcrewmates() - game.crewmates()' Any decent compiler will optimize this so that it's still only two function calls (or it gets inlined). However, it's still not very readable, so I've assigned the result to a variable and used that instead. --- desktop_version/src/Render.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 8d79211b..2911c9c2 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1970,10 +1970,12 @@ void maprender() graphics.Print( -1, FLIP(110), meta.Desc2, 196, 196, 255 - help.glow, true); graphics.Print( -1, FLIP(120), meta.Desc3, 196, 196, 255 - help.glow, true); - if(ed.numcrewmates()-game.crewmates()==1){ - graphics.Print(1,FLIP(165), help.number(ed.numcrewmates()-game.crewmates())+ " crewmate remains", 196, 196, 255 - help.glow, true); - }else if(ed.numcrewmates()-game.crewmates()>0){ - graphics.Print(1,FLIP(165), help.number(ed.numcrewmates()-game.crewmates())+ " crewmates remain", 196, 196, 255 - help.glow, true); + int remaining = ed.numcrewmates() - game.crewmates(); + + if(remaining==1){ + graphics.Print(1,FLIP(165), help.number(remaining)+ " crewmate remains", 196, 196, 255 - help.glow, true); + }else if(remaining>0){ + graphics.Print(1,FLIP(165), help.number(remaining)+ " crewmates remain", 196, 196, 255 - help.glow, true); } } #endif