Transform default game/locale data paths based on executable name
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Fri, 20 Feb 2009 16:30:37 +0000 (16:30 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Fri, 20 Feb 2009 16:30:37 +0000 (16:30 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@2776 78b8d119-cf0a-0410-b17c-f493084dd1d7

Makefile
ball/main.c
putt/main.c
share/base_config.c
share/base_config.h
share/lang.c
share/mapc.c

index 5b95896..4c7df4a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -133,6 +133,7 @@ MAPC_OBJS := \
        share/solid.o       \
        share/binary.o      \
        share/base_config.o \
+       share/common.o      \
        share/mapc.o
 BALL_OBJS := \
        share/lang.o        \
index 3224153..89db1c9 100644 (file)
@@ -338,6 +338,8 @@ int main(int argc, char *argv[])
     SDL_Joystick *joy = NULL;
     int t1, t0, uniform;
 
+    config_exec_path = argv[0];
+
     lang_init("neverball", CONFIG_LOCALE);
 
     text_init();
index a0f53ce..bed759d 100644 (file)
@@ -193,6 +193,8 @@ int main(int argc, char *argv[])
     int camera = 0;
     SDL_Joystick *joy = NULL;
 
+    config_exec_path = argv[0];
+
     srand((int) time(NULL));
 
     lang_init("neverball", CONFIG_LOCALE);
index 6df2fae..5dd5d03 100644 (file)
@@ -21,6 +21,7 @@
 #include "base_config.h"
 #include "glext.h"
 #include "vec3.h"
+#include "common.h"
 
 /*---------------------------------------------------------------------------*/
 
@@ -82,6 +83,8 @@ const char *config_user(const char *file)
 
 /*---------------------------------------------------------------------------*/
 
+const char *config_exec_path;
+
 /*
  * Attempt to find  the game data directory.  Search  the command line
  * parameter,  the environment,  and the  hard-coded default,  in that
@@ -103,9 +106,11 @@ int config_data_path(const char *path, const char *file)
         return 1;
     }
 
-    if (config_test(CONFIG_DATA, file))
+    dir = path_resolve(config_exec_path, CONFIG_DATA);
+
+    if (config_test(dir, file))
     {
-        strncpy(data_path, CONFIG_DATA, MAXSTR);
+        strncpy(data_path, dir, MAXSTR);
         return 1;
     }
 
index ba8c6c0..0ac6a76 100644 (file)
@@ -99,6 +99,8 @@
 const char *config_data(const char *);
 const char *config_user(const char *);
 
+extern const char *config_exec_path;
+
 int  config_data_path(const char *, const char *);
 int  config_user_path(const char *);
 
index 4ae2f8e..76f010b 100644 (file)
@@ -20,6 +20,8 @@
 #include <errno.h>
 
 #include "lang.h"
+#include "common.h"
+#include "base_config.h"
 
 /*---------------------------------------------------------------------------*/
 
@@ -32,6 +34,9 @@ void lang_init(const char *domain, const char *default_dir)
 #if ENABLE_NLS
     char *dir = getenv("NEVERBALL_LOCALE");
 
+    if (!dir)
+        dir = path_resolve(config_exec_path, default_dir);
+
     errno = 0;
 
     if (!setlocale(LC_ALL, ""))
@@ -44,7 +49,7 @@ void lang_init(const char *domain, const char *default_dir)
 
     setlocale(LC_NUMERIC, "C");
 
-    bindtextdomain(domain, dir ? dir : default_dir);
+    bindtextdomain(domain, dir);
     bind_textdomain_codeset(domain, DEFAULT_CODESET);
     textdomain(domain);
 #else
index 732f814..c448cd1 100644 (file)
@@ -2440,6 +2440,8 @@ int main(int argc, char *argv[])
     struct s_file f;
     FILE *fin;
 
+    config_exec_path = argv[0];
+
     if (argc > 2)
     {
         if (argc > 3 && strcmp(argv[3], "--debug") == 0)