X-Git-Url: https://git.piment-noir.org/?p=Project_algorithmic_C.git;a=blobdiff_plain;f=lib%2Fdebug.c;h=a9ccc608c818d767592ee363c5e96178afc20723;hp=c7f4dfb48635cd174290557a6397c9d4c3938c62;hb=acd1c2e821764097e70281ac5d0f13a7fd10f9c2;hpb=a80646b74eca11c71696dedeb674870437c5bb6f diff --git a/lib/debug.c b/lib/debug.c index c7f4dfb..a9ccc60 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -19,16 +19,29 @@ #include #include "othello.h" -#include "constants.h" #include "debug.h" +#if BUILD_TYPE == debug +void dbg_mvprintw(int y, int x, const char* debug_text, ...) { + va_list func_args; + char debug_msg[256]; + + snprintf(debug_msg, sizeof(debug_msg), "%s%s", "DEBUG: ", debug_text); + va_start(func_args, debug_text); + mvprintw(y, x, debug_msg, func_args); + va_end(func_args); +} +#else +void dbg_mvprintw(int y, int x, const char* debug_text, ...); +#endif + void display_array(int base_y, int base_x, unsigned int pawn_array[board_size][board_size]) { for (int i = 1; i <= board_size; i++) { - mvprintw(base_y + i, base_x, "%d", i); + dbg_mvprintw(base_y + i, base_x, "%d", i); for (int j = 1; j <= board_size; j++) { - mvprintw(base_y, base_x + j, "%d", j); - mvprintw(base_y + i, base_x + j, "%d", get_box_value(i, j, pawn_array)); + dbg_mvprintw(base_y, base_x + j, "%d", j); + dbg_mvprintw(base_y + i, base_x + j, "%d", get_box_value(i, j, pawn_array)); } } }