From 9c305113ed9e6b1ee47521d92b9b3b7ee81cf8d5 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 4 May 2024 16:29:21 +0200 Subject: Reformatted game_str() --- FICS/gamedb.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/FICS/gamedb.c b/FICS/gamedb.c index f2e5fda..8f538e1 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -187,25 +187,27 @@ PUBLIC char *game_time_str(int wt, int winc, int bt, int binc) return tstr; } -PUBLIC char *game_str(int rated, int wt, int winc, int bt, int binc, - char *cat, char *board) +PUBLIC char * +game_str(int rated, int wt, int winc, int bt, int binc, char *cat, char *board) { - static char tstr[200]; - - if (cat && cat[0] && board && board[0] && - (strcmp(cat, "standard") || strcmp(board, "standard"))) { - sprintf(tstr, "%s %s%s Loaded from %s/%s", - rstr[rated], - bstr[game_isblitz(wt / 60, winc, bt / 60, binc, cat, board)], - game_time_str(wt / 60, winc, bt / 60, binc), - cat, board); - } else { - sprintf(tstr, "%s %s%s", - rstr[rated], - bstr[game_isblitz(wt / 60, winc, bt / 60, binc, cat, board)], - game_time_str(wt / 60, winc, bt / 60, binc)); - } - return tstr; + static char tstr[200] = { '\0' }; + + if (cat && cat[0] && board && board[0] && (strcmp(cat, "standard") || + strcmp(board, "standard"))) { + msnprintf(tstr, sizeof(tstr), "%s %s%s Loaded from %s/%s", + rstr[rated], + bstr[game_isblitz(wt / 60, winc, bt / 60, binc, cat, board)], + game_time_str(wt / 60, winc, bt / 60, binc), + cat, + board); + } else { + msnprintf(tstr, sizeof(tstr), "%s %s%s", + rstr[rated], + bstr[game_isblitz(wt / 60, winc, bt / 60, binc, cat, board)], + game_time_str(wt / 60, winc, bt / 60, binc)); + } + + return tstr; } PUBLIC int -- cgit v1.2.3