diff options
author | HampusM <hampus@hampusmat.com> | 2022-01-07 12:56:37 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-01-07 12:56:37 +0100 |
commit | 977c46591583a59f8d51773ffaba08b5076a426e (patch) | |
tree | a04727c2075cebe0ae8b93728c9071e164a17c43 /src | |
parent | 2876d7efdeac80085a04b8f1c509065bf323f70e (diff) |
style: fix minor code formatting issues
Diffstat (limited to 'src')
-rw-r--r-- | src/grid.c | 3 | ||||
-rw-r--r-- | src/grid.h | 1 | ||||
-rw-r--r-- | src/maze.c | 9 | ||||
-rw-r--r-- | src/maze.h | 2 | ||||
-rw-r--r-- | src/mazerator.c | 6 | ||||
-rw-r--r-- | src/position.c | 1 | ||||
-rw-r--r-- | src/position.h | 1 | ||||
-rw-r--r-- | src/utils.c | 7 |
8 files changed, 12 insertions, 18 deletions
@@ -1,7 +1,7 @@ #include "grid.h" #include "utils.h" -#include <stdlib.h> #include <stdio.h> +#include <stdlib.h> Grid grid_create(unsigned int width, unsigned int height, char *fill) { @@ -53,4 +53,3 @@ void grid_destroy(Grid grid) free(grid.grid); } - @@ -56,4 +56,3 @@ void grid_print(Grid grid); void grid_destroy(Grid grid); #endif - @@ -1,10 +1,10 @@ #include "maze.h" #include "grid.h" #include "position.h" +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdint.h> int is_pos_empty(Grid grid, Position pos) { @@ -15,10 +15,10 @@ void add_neighbour(Position neighbours[], uint8_t *neighbour_cnt, Position neigh { neighbours[*neighbour_cnt] = neighbour_pos; (*neighbour_cnt)++; - } -void get_neighbours(Grid grid, Position pos, Position neighbours[], uint8_t *neighbour_cnt) +void get_neighbours(Grid grid, Position pos, Position neighbours[], + uint8_t *neighbour_cnt) { if (pos.y != 1) { @@ -96,7 +96,7 @@ void grid_to_maze(Grid grid, Position start_pos) Position next_pos = neighbours[rand() % neighbour_cnt]; Position between_pos = position_create(pos.x, pos.y); - + if (next_pos.y != pos.y) between_pos.y += next_pos.y > pos.y ? 1 : -1; @@ -110,4 +110,3 @@ void grid_to_maze(Grid grid, Position start_pos) pos_stack_destroy(path); } - @@ -1,8 +1,8 @@ #ifndef MAZE_H #define MAZE_H -#include "position_stack.h" #include "grid.h" +#include "position_stack.h" /** * Creates a maze from a grid diff --git a/src/mazerator.c b/src/mazerator.c index 593d518..c624dc3 100644 --- a/src/mazerator.c +++ b/src/mazerator.c @@ -1,5 +1,5 @@ -#include "maze.h" #include "grid.h" +#include "maze.h" #include "position.h" #include "utils.h" #include <getopt.h> @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) { case 'w': maze_width = str_to_uint(optarg, &err); - + if (err != NULL) optarg_error(arg, err); @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) break; case 'h': maze_height = str_to_uint(optarg, &err); - + if (err != NULL) optarg_error(arg, err); diff --git a/src/position.c b/src/position.c index 937edd5..a7465ab 100644 --- a/src/position.c +++ b/src/position.c @@ -6,4 +6,3 @@ Position position_create(unsigned int x, unsigned int y) return pos; } - diff --git a/src/position.h b/src/position.h index d1bc9eb..05d21fa 100644 --- a/src/position.h +++ b/src/position.h @@ -10,4 +10,3 @@ typedef struct Position Position position_create(unsigned int x, unsigned int y); #endif - diff --git a/src/utils.c b/src/utils.c index 2657a00..5fc27d3 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,9 +1,9 @@ #include "utils.h" #include <ctype.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> #include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> void *malloc_s(unsigned long amount) { @@ -43,4 +43,3 @@ unsigned int str_to_uint(char *str, char **err) return (unsigned int)num; } - |