added more cvsignores because scons is placing .sconsign files all over the place :-/
[supertux.git] / lib / app / setup.cpp
index 5ddcb01..6245e49 100644 (file)
@@ -17,6 +17,8 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <config.h>
+
 #include <cassert>
 #include <cstdio>
 #include <iostream>
@@ -90,6 +92,7 @@ int FileSystem::fwriteable(const std::string& filename)
     {
       return false;
     }
+  fclose(fi);
   return true;
 }
 
@@ -284,6 +287,12 @@ void Setup::directories(void)
 
   mkdir((st_dir + "/levels").c_str(), 0755);
 
+  // try current directory as datadir
+  if(datadir.empty()) {
+      if(FileSystem::faccessible("./data/intro.txt"))
+          datadir = "./data";
+  }
+
   // User has not that a datadir, so we try some magic
   if (datadir.empty())
     {
@@ -297,16 +306,21 @@ void Setup::directories(void)
         }
       else
         {
-          std::string exedir = std::string(dirname(exe_file)) + "/";
-          
-          datadir = exedir + "../../data"; // SuperTux run from source dir
+         std::string exedir = std::string(dirname(exe_file)) + "/";
+         
+          datadir = exedir + "../data"; // SuperTux run from source dir
           if (access(datadir.c_str(), F_OK) != 0)
             {
+             datadir = exedir + "../../data";  //SuperTux run from source dir (with libtool script)
+             
+             if (access(datadir.c_str(), F_OK) != 0)
+             {
               datadir = exedir + "../share/" + package_symbol_name; // SuperTux run from PATH
               if (access(datadir.c_str(), F_OK) != 0) 
                 { // If all fails, fall back to compiled path
                   datadir = DATA_PREFIX; 
                 }
+             }
             }
         }
 #else
@@ -740,7 +754,7 @@ void Setup::parseargs(int argc, char * argv[])
       else if (strcmp(argv[i], "--version") == 0)
         {
           /* Show version: */
-          printf((package_name + package_version + "\n").c_str() );
+          printf((package_name + " " + package_version + "\n").c_str() );
           exit(0);
         }
       else if (strcmp(argv[i], "--disable-sound") == 0)