From: Mischa POSLAWSKY Date: Sun, 4 Mar 2007 07:28:43 +0000 (+0100) Subject: code cleanup: use terniaries X-Git-Url: http://git.shiar.net/netris.git/commitdiff_plain/7314868989ef0df88c44603419a4d50e94682fd8 code cleanup: use terniaries Use terniary conditions for improved readability and reduced code duplication. --- diff --git a/game.c b/game.c index b9d83f4..64acecc 100644 --- a/game.c +++ b/game.c @@ -123,8 +123,7 @@ void HandleOption(char tag, char *value) { switch (tag) { case 'a': //ascii - if (value && !strcasecmp(value, "0")) Sets.ascii = 0; - else Sets.ascii = 1; + Sets.ascii = value && !strcasecmp(value, "0") ? 0 : 1; Sets.drawstyle &= ~Sets.ascii; break; case 'c': //connect @@ -150,12 +149,10 @@ void HandleOption(char tag, char *value) Sets.dropmode = value ? atoi(value) : 1; break; case 'C': //color - if (value && !strcasecmp(value, "1")) Sets.color = 1; - else Sets.color = 0; + Sets.color = value && strcasecmp(value, "0") ? 1 : 0; break; case 'S': //slowterm - if (value && !strcasecmp(value, "1")) Sets.standout = 1; - else Sets.standout = 0; + Sets.standout = value && !strcasecmp(value, "0") ? 1 : 0; break; case 'k': //keys MapKeys(value);