aboutsummaryrefslogtreecommitdiff
path: root/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'map.c')
-rw-r--r--map.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/map.c b/map.c
index dd062ce..28a87ea 100644
--- a/map.c
+++ b/map.c
@@ -841,16 +841,17 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
/* Wait for BUTTON1_RELEASED */
while ((ch = getch()) == KEY_MOUSE && getmouse(&event) == OK && !(event.bstate & BUTTON1_RELEASED)) {
- if (event.y <= map_offset_y) continue;
+ int line_y = event.y;
+ if (event.y <= map_offset_y) line_y = 1 + map_offset_y;
draw_map(*map, NULL, *width, *height, *start, *goal, NULL, path, visited, NULL);
for (size_t i = map_offset_x; i < *width*2 + map_offset_x; i++) {
- mvaddch(event.y, i, '=');
+ mvaddch(line_y, i, '=');
}
- mvprintw(event.y, map_offset_x, "%u", event.y - map_offset_y);
+ mvprintw(line_y, map_offset_x, "%u", line_y - map_offset_y);
};
size_t new_height = event.y - map_offset_y;
- if (event.y <= map_offset_y) continue;
+ if (event.y <= map_offset_y) new_height = 1;
Map new_map = empty_map(*width, new_height);
map_copy(*map, *width, *height, new_map, *width, new_height);
@@ -891,17 +892,17 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
/* Wait for BUTTON1_RELEASED */
while ((ch = getch()) == KEY_MOUSE && getmouse(&event) == OK && !(event.bstate & BUTTON1_RELEASED)) {
size_t new_width = (event.x - map_offset_x) / 2;
- if (event.x <= map_offset_x || new_width == 0) continue;
+ if (event.x <= map_offset_x || new_width == 0) new_width = 1;
draw_map(*map, NULL, *width, *height, *start, *goal, NULL, path, visited, NULL);
for (size_t i = map_offset_y; i < *height + map_offset_y; i++) {
mvaddch(i, new_width * 2 + map_offset_x, '|');
mvaddch(i, new_width * 2 + map_offset_x + 1, '|');
}
- mvprintw(map_offset_y, new_width*2 + map_offset_x, "%u", (event.x - map_offset_x) / 2);
+ mvprintw(map_offset_y, new_width*2 + map_offset_x, "%zu", new_width);
};
new_width = (event.x - map_offset_x) / 2;
- if (event.x <= map_offset_x || new_width == 0) continue;
+ if (event.x <= map_offset_x || new_width == 0) new_width = 1;
Map new_map = empty_map(new_width, *height);
map_copy(*map, *width, *height, new_map, new_width, *height);