X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=src%2Fkeybindings.c;h=2f27da9d04c256f3359470cead3a2623fe4e4644;hb=35cdeffc062d3d87f1526bbff10c401b56b1345a;hp=b6ff412c6f734fbb48093d7ddcdf9cc539af27e8;hpb=e9d8b1aca776341c9cdaa2ea6406336661d82a76;p=plomrogue
diff --git a/src/keybindings.c b/src/keybindings.c
index b6ff412..2f27da9 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -1,28 +1,18 @@
-#include
+#include "keybindings.h"
#include
+#include
#include
#include
#include "windows.h"
-#include "roguelike.h"
-#include "keybindings.h"
+#include "misc.h"
+#include "main.h"
void init_keybindings(struct World * world) {
// Initialize keybindings from file "keybindings".
FILE * file = fopen("keybindings", "r");
- uint16_t lines = 0;
- int c = 0;
- uint16_t linemax = 0;
- uint16_t c_count = 0;
- while (EOF != c) {
- c_count++;
- c = getc(file);
- if ('\n' == c) {
- if (c_count > linemax)
- linemax = c_count + 1;
- c_count = 0;
- lines++; } }
+ uint16_t lines, linemax;
+ textfile_sizes (file, &linemax, &lines);
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
- fseek(file, 0, SEEK_SET);
char * command = malloc(linemax);
uint16_t commcount = 0;
char * cmdptr;