all in-game messages in include
[netris.git] / curses.c
index 57bfee76b3ecb375ae17b332a6c4829d64885767..b60433e97e86134e402444fb5dc8cc8518a7453c 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -536,11 +536,13 @@ void window_msg(int player, char *message)
 { //put a message over player's field
        if (!window[player].shown) return;
        if (message) {
-               char s[MAX_BOARD_WIDTH+1];
-               memset(s, ' ', MAX_BOARD_WIDTH);
-               memcpy(&s[(window[player].size * Players[player].boardWidth / 2) - (strlen(message) / 2)],
-                       message, strlen(message));
-               s[window[player].size * Players[player].boardWidth] = 0;
+               const int fieldsize = Players[player].boardWidth * window[player].size;
+               const int centered = (fieldsize - strlen(message)) / 2;
+               char s[fieldsize + 1];
+
+               memset(s, ' ', fieldsize);
+               memcpy(&s[centered], message, strlen(message));
+               s[fieldsize] = 0;
 #ifdef HAVE_NCURSES
                attrset(A_REVERSE);
 #else
@@ -597,24 +599,24 @@ void window_msg_status(int player)
        if (Players[player].alive > 0)
                if (Players[player].flags & SCF_paused)
                        if (Game.started > 1)
-                               window_msg_wide(player, "PAUSED");
+                               window_msg_wide(player, MSG_PLAYER_PAUSE);
                        else
-                               window_msg_wide(player, "NOT READY");
+                               window_msg_wide(player, MSG_PLAYER_JOIN);
                else
                        if (Game.started > 1)
                                window_msg(player, NULL);
                        else
-                               window_msg_wide(player, "READY");
+                               window_msg_wide(player, MSG_PLAYER_START);
        else if (!Players[player].alive)
-               window_msg_wide(player, "GAME OVER");
+               window_msg_wide(player, MSG_PLAYER_STOP);
        else
-               window_msg_wide(player, "EMPTY");
+               window_msg_wide(player, MSG_PLAYER_PART);
 }
 
 
 void status_tick(void)
 { //display timer
-       mvprintw(statusYPos, statusXPos, "timer %7.0f ", CurTimeval() / 1e6);
+       mvprintw(statusYPos, statusXPos, MSG_TIME, CurTimeval() / 1e6);
 }
 
 void ScheduleFullRedraw(void)