aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@xglobe.in>2020-04-03 19:50:50 +0200
committerOmar Polo <op@xglobe.in>2020-04-03 19:50:50 +0200
commit3d4cf639d759c4ea4f04142474946fa585959d77 (patch)
tree7367db1af4b76f3dc929c59fdd5cc7dd44fb7d3b
parentc5b63edc72c15c4d9274768a67a0b65438cd4998 (diff)
downloadtext-adventure-3d4cf639d759c4ea4f04142474946fa585959d77.tar.gz
text-adventure-3d4cf639d759c4ea4f04142474946fa585959d77.tar.bz2
added config file
only the PROMPT is configurable as of now tho.
-rw-r--r--Makefile6
-rw-r--r--adventure.h2
-rw-r--r--config.h8
-rw-r--r--io.c2
4 files changed, 16 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index b3d136d..92b8f27 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,11 @@ all: adventure
OBJ = match.o parseexec.o toggle.c inventory.o \
misc.o object.o io.o adventure.o
-adventure: object.h ${OBJ}
+# making every object depending on object.h may be too aggressive,
+# but will surely avoid some nasty bugs (I hope at least.)
+${OBJ}: adventure.h config.h object.h
+
+adventure: ${OBJ}
${CC} -o adventure ${OBJ} ${LDFLAGS}
object.c: object.data data_to_c.awk
diff --git a/adventure.h b/adventure.h
index a90e0d0..846be84 100644
--- a/adventure.h
+++ b/adventure.h
@@ -3,6 +3,8 @@
#include <stddef.h>
+#include "config.h"
+
enum distance {
dist_player,
dist_held,
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..14fe660
--- /dev/null
+++ b/config.h
@@ -0,0 +1,8 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#ifndef PROMPT
+#define PROMPT "~> "
+#endif
+
+#endif
diff --git a/io.c b/io.c
index af13159..14790a6 100644
--- a/io.c
+++ b/io.c
@@ -11,7 +11,7 @@ char *line = NULL;
int
getinput()
{
- line = readline("~> ");
+ line = readline(PROMPT);
if (line && *line)
add_history(line);
return line != NULL;