diff --git a/extra/DSA/data.cfg b/extra/DSA/data.cfg new file mode 100644 index 0000000..4faea3d --- /dev/null +++ b/extra/DSA/data.cfg @@ -0,0 +1,49 @@ +# +# Made by Fry. +# 11.12.2016 +# + +version = "1.0"; + +application: +{ + # The starting position of the player. + engineer: + { + row = 0; + column = 0; + }; + + # The location of the exit. + exit: + { + row = 3; + column = 3; + } + + # The location of the walls. + walls = ( + { + row = 0; + column = 3; + }, + { + row = 1; + column = 1; + }, + { + row = 2; + column = 1; + }, + { + row = 2; + column = 2; + }, + { + row = 2; + column = 3; + } + ); + + +}; diff --git a/extra/DSA/matrix-cube.c b/extra/DSA/matrix-cube.c index 27d8f4b..684a498 100644 --- a/extra/DSA/matrix-cube.c +++ b/extra/DSA/matrix-cube.c @@ -3,10 +3,13 @@ Date: 10.12.2016 https://www.ryoko-rpg.ro https://github.com/Metonimie + Dependencies: + - libconfig */ #include #include #include +#include #define VISITED_MASK ( (unsigned) 1 << 4) #define DEATH_MASK ( (unsigned) 1 << 5) @@ -23,6 +26,9 @@ unsigned rows = 4; unsigned cols = 4; +// Config settings. +config_t configuration; + unsigned testM[4][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, @@ -211,25 +217,36 @@ unsigned solve_mat(unsigned c, unsigned r) { return 0; } +/* Simple test code */ + +// make_exit_cell(&testM[3][3]); +// make_wall_cell(&testM[0][3]); +// make_wall_cell(&testM[1][1]); +// make_wall_cell(&testM[2][1]); +// make_wall_cell(&testM[2][2]); +// make_wall_cell(&testM[2][3]); +// +// for (unsigned i = 0; i < rows; ++i) { +// for (unsigned j = 0; j < cols; ++j) { +// set_timmer(i, j, 6); +// } +// } +// +// print_matrix2(testM, 4, 4); +// unsigned x = solve_mat(0, 0); +// printf("Solved: %d\n", x); +// print_matrix2(testM, 4, 4); + int main(void) { + /* Initialize the configuration structure */ + config_init(&configuration); - make_exit_cell(&testM[3][3]); - make_wall_cell(&testM[0][3]); - make_wall_cell(&testM[1][1]); - make_wall_cell(&testM[2][1]); - make_wall_cell(&testM[2][2]); - make_wall_cell(&testM[2][3]); - - for (unsigned i = 0; i < rows; ++i) { - for (unsigned j = 0; j < cols; ++j) { - set_timmer(i, j, 6); - } + if ( config_read_file(&configuration, "data.cfg") != CONFIG_TRUE ) { + fprintf(stderr, "Configuration Error: %s\n", config_error_text(&configuration)); + fprintf(stderr, "File: %s on line %d\n", config_error_file(&configuration), + config_error_line(&configuration)); + return EXIT_FAILURE; } - print_matrix2(testM, 4, 4); - unsigned x = solve_mat(0, 0); - printf("Solved: %d\n", x); - print_matrix2(testM, 4, 4); - return EXIT_SUCCESS; }