From 3800654c56fc598bffda5b93fbe9dc7f88896fc2 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Sun, 5 Apr 2026 10:51:41 +0300 Subject: Fix a rendering bug --- map.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'map.c') diff --git a/map.c b/map.c index a433dc0..cbfe333 100644 --- a/map.c +++ b/map.c @@ -220,8 +220,9 @@ Map file_plaintext_map(char *filename, size_t *width, size_t *height, Position * /* FIXME: clean up better maybe idk. There's a bug where parts of path may not be rendered if goal slightly above start in an empty area */ /* FIXME: yeah there are plenty of bugs. the path just doesn't get rendered correctrly at times, even if it's calculated just fine. AND IT's SPECIFICALLY AFTER map_editor() WHAT IN THE ACTUAL FUCK AAAAAAAAAAAAAAAAAAAAAAAAAAAAA*/ void draw_map(Map map, size_t width, size_t height, Position start, Position goal, Position *cursor, Path path, char **visited, PositionPQ *frontier) { - /* I think it flickers less when we do that */ - wnoutrefresh(stdscr); + /* I think it flickers less when we do that + * UPD: it was causing a bug, so I commented it out. I don't know why either */ + //wnoutrefresh(stdscr); /* Clean up the area around the map */ for (ssize_t i = -1; i <= (ssize_t)(width*2 + 4); i++) { /* Horizontal */ @@ -254,7 +255,7 @@ void draw_map(Map map, size_t width, size_t height, Position start, Position goa /* Draw field */ if (map != NULL) { - char c; /* The char for the current tile */ + char c = '\0'; /* The char for the current tile */ for (size_t i = 0; i < height; i++) { for (size_t j = 0; j < width; j++) { int color_pair = 0; /* The color pair of the current char */ @@ -372,7 +373,8 @@ void draw_map(Map map, size_t width, size_t height, Position start, Position goa } attroff(A_BOLD); - doupdate(); + /* Read the comment at the start of this function */ + //doupdate(); } void map_free(Map map, size_t height) { @@ -396,6 +398,7 @@ void print_map_out(Map map, size_t width, size_t height) { } void map_editor(Map *map, size_t *width, size_t *height, Position *start, Position *goal) { + clear(); draw_map(*map, *width, *height, *start, *goal, NULL, NULL, NULL, NULL); mvprintw(*height + map_offset_y + 1, map_offset_x - 2, "You've entered the map editor. 'q' to quit"); -- cgit v1.2.3