various code cleanups
[netris.git] / curses.c
index b4b0248bb66338c9f7ee5f8fb5d3ed2c88102e9e..e963cce128f580558054dbc7a87c38770f56b9a4 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -67,7 +67,7 @@ void InitScreens(void)
         * Ctrl-C during initialization might leave the terminal in a bad state.
         */
        BlockSignals(&oldMask, SIGINT, 0);
-       initscr();              //start curses
+       initscr();  //start curses
 
 #ifdef CURSES_HACK
        {
@@ -288,8 +288,8 @@ void InitFields(void)
 
        messageXPos = 2;
        messageYPos = 24;
-       if ((messageWidth = x - messageXPos - 2) > MSG_WIDTH) messageWidth = MSG_WIDTH;
-       if ((messageHeight = y - messageYPos - 1) > MSG_HEIGHT) messageHeight = MSG_HEIGHT;
+       messageWidth  = MIN(x - messageXPos - 2, MSG_WIDTH);
+       messageHeight = MIN(y - messageYPos - 1, MSG_HEIGHT);
        if (messageHeight <= 0) {
                messageWidth = 27;
                messageHeight = y - 3;
@@ -299,7 +299,7 @@ void InitFields(void)
        DrawBox(messageXPos - 2, messageYPos - 1,
                messageXPos + messageWidth + 1, messageYPos+messageHeight);
        if (msgwin = subwin(stdscr, messageHeight, messageWidth,
-                               messageYPos, messageXPos))
+                           messageYPos, messageXPos))
                scrollok(msgwin, 1);  //allow scrolling
        wmove(msgwin, messageHeight - 2, 0);
        for (scr = messageHeight - 2; scr >= 0; scr--) //display message history
@@ -351,7 +351,7 @@ void DisplayMessage(char *p)
        while (psearch = strchr(p, '\\')) {
                *psearch = '\0';
                waddstr(msgwin, p);
-               c = atoi(++psearch)+1;
+               c = atoi(++psearch) + 1;
                if (haveColor) wattrset(msgwin, A_REVERSE | COLOR_PAIR(c));
                p = ++psearch;
        } //search for color escapes (\)
@@ -513,8 +513,8 @@ void ShowScore(int scr, struct _Score score)
 
        mvaddstr(13, statusXPos, MSG_NEXT " ");
        mvaddstr(14, statusXPos + 5,  "        ");
-       ShapeIterate(Players[scr].nextShape, scr,
-               8, statusXPos/2 + (Players[scr].nextShape/4 == 5 ? 3 : 4),
+       ShapeIterate(Players[scr].nextShape, scr, 8,
+               statusXPos/2 + (Players[scr].nextShape/4 == 5 ? 3 : 4),
                GlanceFunc); //draw; stick one more to the left
        mvprintw(3, statusXPos, MSG_LEVEL, score.level);
        mvprintw(5, statusXPos, MSG_SCORE, score.score);