home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't save and load maps, save and load seeds of maps. Load via command line option.
[plomrogue]
/
keybindings.c
diff --git
a/keybindings.c
b/keybindings.c
index 1906d1d0c797c79a63e2528b6efb4fd321ab39e7..3e1b19ab9ff545b8d4728b481729b8f5751955f2 100644
(file)
--- a/
keybindings.c
+++ b/
keybindings.c
@@
-1,6
+1,7
@@
+#include <stdlib.h>
+#include <stdint.h>
#include <ncurses.h>
#include <string.h>
#include <ncurses.h>
#include <string.h>
-#include <stdlib.h>
#include "windows.h"
#include "roguelike.h"
#include "keybindings.h"
#include "windows.h"
#include "roguelike.h"
#include "keybindings.h"
@@
-8,10
+9,10
@@
void init_keybindings(struct World * world) {
// Initialize keybindings from file "keybindings".
FILE * file = fopen("keybindings", "r");
void init_keybindings(struct World * world) {
// Initialize keybindings from file "keybindings".
FILE * file = fopen("keybindings", "r");
-
in
t lines = 0;
+
uint16_
t lines = 0;
int c = 0;
int c = 0;
-
in
t linemax = 0;
-
in
t c_count = 0;
+
uint16_
t linemax = 0;
+
uint16_
t c_count = 0;
while (EOF != c) {
c_count++;
c = getc(file);
while (EOF != c) {
c_count++;
c = getc(file);
@@
-23,7
+24,7
@@
void init_keybindings(struct World * world) {
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
fseek(file, 0, SEEK_SET);
char * command = malloc(linemax);
struct KeyBinding * keybindings = malloc(lines * sizeof(struct KeyBinding));
fseek(file, 0, SEEK_SET);
char * command = malloc(linemax);
-
in
t commcount = 0;
+
uint16_
t commcount = 0;
char * cmdptr;
while (fgets(command, linemax, file)) {
keybindings[commcount].key = atoi(command);
char * cmdptr;
while (fgets(command, linemax, file)) {
keybindings[commcount].key = atoi(command);
@@
-46,8
+47,8
@@
void save_keybindings(struct World * world) {
struct KeysWinData * keyswindata = (struct KeysWinData *) world->keyswindata;
struct KeyBinding * keybindings = world->keybindings;
FILE * file = fopen("keybindings", "w");
struct KeysWinData * keyswindata = (struct KeysWinData *) world->keyswindata;
struct KeyBinding * keybindings = world->keybindings;
FILE * file = fopen("keybindings", "w");
-
in
t linemax = 0;
-
in
t i;
+
uint16_
t linemax = 0;
+
uint16_
t i;
for (i = 0; i <= keyswindata->max; i++)
if (strlen(keybindings[i].name) > linemax)
linemax = strlen(keybindings[i].name);
for (i = 0; i <= keyswindata->max; i++)
if (strlen(keybindings[i].name) > linemax)
linemax = strlen(keybindings[i].name);
@@
-59,14
+60,14
@@
void save_keybindings(struct World * world) {
free(line);
fclose(file); }
free(line);
fclose(file); }
-
in
t get_action_key (struct KeyBinding * keybindings, char * name) {
+
uint16_
t get_action_key (struct KeyBinding * keybindings, char * name) {
// Return key matching name in keybindings.
// Return key matching name in keybindings.
-
in
t i = 0;
+
uint16_
t i = 0;
while (strcmp(keybindings[i].name, name) )
i++;
return keybindings[i].key; }
while (strcmp(keybindings[i].name, name) )
i++;
return keybindings[i].key; }
-char * get_keyname(
in
t keycode) {
+char * get_keyname(
uint16_
t keycode) {
// Translate some keycodes to readable names of max 9 chars.
char * keyname;
keyname = malloc(15);
// Translate some keycodes to readable names of max 9 chars.
char * keyname;
keyname = malloc(15);
@@
-93,7
+94,7
@@
char * get_keyname(int keycode) {
else if (keycode == KEY_BACKSPACE)
sprintf(keyname, "BACKSPACE");
else if (keycode >= KEY_F0 && keycode <= KEY_F(63)) {
else if (keycode == KEY_BACKSPACE)
sprintf(keyname, "BACKSPACE");
else if (keycode >= KEY_F0 && keycode <= KEY_F(63)) {
-
in
t f = keycode - KEY_F0;
+
uint16_
t f = keycode - KEY_F0;
sprintf(keyname, "F%d", f); }
else if (keycode == KEY_DC)
sprintf(keyname, "DELETE");
sprintf(keyname, "F%d", f); }
else if (keycode == KEY_DC)
sprintf(keyname, "DELETE");