[teeworlds] [PATCHES] Fix datadir search

  • From: Bruno Tarquini <btarquini@xxxxxxxxx>
  • To: teeworlds@xxxxxxxxxxxxx
  • Date: Mon, 02 Feb 2009 00:27:54 +0100

Hi !

Here are three patches for fix datadir search under Gentoo linux
(https://bugs.gentoo.org/show_bug.cgi?id=206287)

Bruno.

--------------------------------------------------------------
Make datadir search works.
- datadir is the dir with data, not his parent.
- also correct a typo (coma missed)

diff -r 9582fcee983b -r b009aa51f960 src/engine/e_engine.c
--- a/src/engine/e_engine.c    Sun Feb 01 20:50:22 2009 +0100
+++ b/src/engine/e_engine.c    Sun Feb 01 21:10:15 2009 +0100
@@ -572,9 +572,9 @@
     /* 5) check for all default locations */
     {
         const char *sdirs[] = {
-            "/usr/share/teeworlds",
-            "/usr/local/share/teeworlds"
-            "/opt/teeworlds"
+            "/usr/share/teeworlds/data",
+            "/usr/local/share/teeworlds/data",
+            "/opt/teeworlds/data"
         };
         const int sdirs_count = sizeof(sdirs) / sizeof(sdirs[0]);


--------------------------------------------------------------
add */share/games/* locations for datadir search
gentoo games policies want all data games under /usr/share/games

diff -r b009aa51f960 -r e495fa1b6398 src/engine/e_engine.c
--- a/src/engine/e_engine.c    Sun Feb 01 21:10:15 2009 +0100
+++ b/src/engine/e_engine.c    Sun Feb 01 21:19:01 2009 +0100
@@ -573,7 +573,9 @@
     {
         const char *sdirs[] = {
             "/usr/share/teeworlds/data",
+            "/usr/share/games/teeworlds/data",
             "/usr/local/share/teeworlds/data",
+            "/usr/local/share/games/teeworlds/data",
             "/opt/teeworlds/data"
         };
         const int sdirs_count = sizeof(sdirs) / sizeof(sdirs[0]);


--------------------------------------------------------------
fix data search for PWD
if there is a subdirectory "data" in PWD and it is not related to teeworlds,
reject it.
I have a private "data" dir in my home directory, and it conflict during
search

diff -r e495fa1b6398 -r c1502459a920 src/engine/e_engine.c
--- a/src/engine/e_engine.c    Sun Feb 01 21:19:01 2009 +0100
+++ b/src/engine/e_engine.c    Sun Feb 01 21:37:17 2009 +0100
@@ -539,14 +539,15 @@
     }
    
     /* 2) use data-dir in PWD if present */
-    if(fs_is_dir("data"))
+    /* test subdir "/mapres" to reject unrelated "data" dir in PWD */
+    if(fs_is_dir("data/mapres"))
     {
         strcpy(datadir, "data");
         return 0;
     }
    
     /* 3) use compiled-in data-dir if present */
-    if (fs_is_dir(DATA_DIR))
+    if (fs_is_dir(DATA_DIR "/mapres"))
     {
         strcpy(datadir, DATA_DIR);
         return 0;




Other related posts: