about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
authorJakob Fries <jakob.fries@gmail.com>2007-08-05 15:56:32 +0000
committerJakob Fries <jakob.fries@gmail.com>2007-08-05 15:56:32 +0000
commite4829981b1d3e746a8f2b6c6cc41b8ba965c5e0e (patch)
tree126f12b869d45d12365d16d1b01e05d4099c4151 /src/engine
parent9abbb0899b3770d29937c5b761a09d0ce42ed76b (diff)
downloadzcatch-e4829981b1d3e746a8f2b6c6cc41b8ba965c5e0e.tar.gz
zcatch-e4829981b1d3e746a8f2b6c6cc41b8ba965c5e0e.zip
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/client/client.cpp1
-rw-r--r--src/engine/config.cpp26
-rw-r--r--src/engine/server/server.cpp1
3 files changed, 28 insertions, 0 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp
index 2eb8ff81..379b7a88 100644
--- a/src/engine/client/client.cpp
+++ b/src/engine/client/client.cpp
@@ -1,4 +1,5 @@
 #include <baselib/system.h>
+#include <baselib/config.h>
 #include <baselib/input.h>
 #include <baselib/audio.h>
 #include <baselib/stream/file.h>
diff --git a/src/engine/config.cpp b/src/engine/config.cpp
index fc4dff1e..fb378190 100644
--- a/src/engine/config.cpp
+++ b/src/engine/config.cpp
@@ -66,6 +66,18 @@ void config_set(const char *line)
 
 void config_load(const char *filename)
 {
+	if (filename[0] == '~')
+	{
+		char *home = getenv("HOME");
+		if (home)
+		{
+			char full_path[1024];
+			sprintf(full_path, "%s%s", home, filename+1);
+			filename = full_path;
+		}
+	}
+
+
 	dbg_msg("config/load", "loading %s", filename);
 
 	file_stream file;
@@ -84,6 +96,18 @@ void config_load(const char *filename)
 
 void config_save(const char *filename)
 {
+	if (filename[0] == '~')
+	{
+		char *home = getenv("HOME");
+		if (home)
+		{
+			char full_path[1024];
+			sprintf(full_path, "%s%s", home, filename+1);
+			filename = full_path;
+		}
+	}
+
+
 	dbg_msg("config/save", "saving config to %s", filename);
 
 	file_stream file;
@@ -101,6 +125,8 @@ void config_save(const char *filename)
 
 		file.close();
 	}
+	else
+		dbg_msg("config/save", "couldn't open %s for writing. :(", filename);
 }
 
 #define MACRO_CONFIG_INT(name,def,min,max) int config_get_ ## name (configuration *c) { return c->name; }
diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp
index 7417054e..3769157e 100644
--- a/src/engine/server/server.cpp
+++ b/src/engine/server/server.cpp
@@ -3,6 +3,7 @@
 #include <cstdlib>
 
 #include <baselib/system.h>
+#include <baselib/config.h>
 
 #include <engine/interface.h>