code cleanup: use terniaries
authorMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 07:28:43 +0000 (08:28 +0100)
committerMischa POSLAWSKY <netris@shiar.org>
Sun, 4 Mar 2007 07:28:43 +0000 (08:28 +0100)
Use terniary conditions for improved readability and reduced code
duplication.

game.c

diff --git a/game.c b/game.c
index b9d83f4afa31e44fd1e1809f731aa4af127d2d36..64acecc6928b6afae51fd8bdd642570a6d013216 100644 (file)
--- 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);