diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-05 10:51:41 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-05 10:51:41 +0300 |
| commit | 3800654c56fc598bffda5b93fbe9dc7f88896fc2 (patch) | |
| tree | b4801f51fc980ecf0af98528e330b4dcae189a77 | |
| parent | 81c2e4ceed1da913d6137f7d3fd8af1ddf9faedc (diff) | |
| download | astar-3800654c56fc598bffda5b93fbe9dc7f88896fc2.tar.xz | |
Fix a rendering bug
| -rw-r--r-- | main.c | 1 | ||||
| -rw-r--r-- | map.c | 11 |
2 files changed, 8 insertions, 4 deletions
@@ -198,6 +198,7 @@ int main(int argc, char **argv) { path_free(path, height); map_editor(&map, &width, &height, &start_pos, &end_pos); + wrefresh(curscr); visited = visited_new(width, height); path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim); @@ -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"); |
