home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed off-by-one error encountered while changing default key for 'reload_wins' command.
[plomrogue]
/
src
/
keybindings.c
diff --git
a/src/keybindings.c
b/src/keybindings.c
index 6fabea65ed499074ef9deb3e65077e8572f0ab64..121304bdadd9ed2d773adf6eed374f4c8a034bd4 100644
(file)
--- a/
src/keybindings.c
+++ b/
src/keybindings.c
@@
-16,14
+16,15
@@
extern void init_keybindings(struct World * world)
{
extern void init_keybindings(struct World * world)
{
- FILE * file = fopen("keybindings", "r");
+ FILE * file = fopen("
config/
keybindings", "r");
uint16_t lines, linemax;
uint16_t lines, linemax;
- textfile_sizes(file, &linemax, &lines);
+ char * err = "textfile_sizes() in init_keybindings() returns error.";
+ exit_err(textfile_sizes(file, &linemax, &lines), world, err);
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
char * command = malloc(linemax);
uint16_t commcount = 0;
char * cmdptr;
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
char * command = malloc(linemax);
uint16_t commcount = 0;
char * cmdptr;
- while (fgets(command, linemax, file))
+ while (fgets(command, linemax
+ 1
, file))
{
keybindings[commcount].key = atoi(command);
cmdptr = strchr(command, ' ') + 1;
{
keybindings[commcount].key = atoi(command);
cmdptr = strchr(command, ' ') + 1;
@@
-49,7
+50,7
@@
extern void save_keybindings(struct World * world)
struct KeysWinData * keyswindata = (struct KeysWinData *)
world->keyswindata;
struct KeyBinding * keybindings = world->keybindings;
struct KeysWinData * keyswindata = (struct KeysWinData *)
world->keyswindata;
struct KeyBinding * keybindings = world->keybindings;
- FILE * file = fopen("keybindings", "w");
+ FILE * file = fopen("
config/
keybindings", "w");
uint16_t linemax = 0;
uint16_t i;
for (i = 0; i <= keyswindata->max; i++)
uint16_t linemax = 0;
uint16_t i;
for (i = 0; i <= keyswindata->max; i++)