From f0b6bb6974c823c4b5a7deffce0748f2ff6370de Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Tue, 14 Apr 2026 18:25:30 +0300 Subject: Change how messages are written, clean up differently --- map.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'map.h') diff --git a/map.h b/map.h index b2b3ff4..23a8773 100644 --- a/map.h +++ b/map.h @@ -3,16 +3,16 @@ #include #include "structs.h" +#include "config.h" #include "path.h" #include "priority_queue.h" -/* Prints a message at the line right below the map. Multiline messages are undefined behaviour */ -#define message(height, ...) { \ - if (move((height) + map_offset_y + 1, map_offset_x - 2) != ERR) { clrtoeol(); /* Clear the line */\ - mvprintw((height) + map_offset_y + 1, map_offset_x - 2, __VA_ARGS__); }} - extern int map_offset_x; extern int map_offset_y; +extern char message[MESSAGE_MAX_SIZE]; + +#define set_message(...) snprintf(message, MESSAGE_MAX_SIZE, __VA_ARGS__); +#define clear_message() message[0] = 0; /* Returns an empty map of given size */ Map empty_map(size_t width, size_t height); @@ -53,6 +53,8 @@ void map_to_file_plaintext(char *filename, Map map, size_t width, size_t height, * path could be NULL to draw a map with no path. So can cursor, frontier and visited */ void draw_map(Map map, size_t width, size_t height, Position start, Position goal, Position *cursor, Path path, char **visited, PositionPQ *frontier); +void print_message(size_t height); + /* Frees all the memory reserved for the map */ void map_free(Map map, size_t height); -- cgit v1.2.3