[xmoto-dev] [Fwd: Re: Bug#407193: xmoto: should not read config.dat in current directory]

[ Thread Index | Date Index | More lists.tuxfamily.org/xmoto-dev Archives ]


hum, he nice bug isn't it ?
This is because xmoto.exe is next to config.dat on windows.
Rasmus,
any idea to not break the windows behavior ? (nicer than a IFDEF WINDOWS...)

Nicolas
--- Begin Message ---
Salut Brice,

Merci, pour le patch, je transmets aux autorités compétentes.

++

Sam.


Brice Goglin wrote:
> Package: xmoto
> Version: 0.2.4-2
> Severity: normal
> 
> Hi,
> 
> I spent a couple days wondering why my xmoto was losing its config.
> It was not running in windowed mode anymore, while the config file was
> ok and modifying the config and saving was working.
> It was actually caused by a file named 'config.dat' in my home directory.
> This file has absolutely nothing to do with xmoto, and I never thought
> such a common filename could cause a problem to any program.
> xmoto actually reads config.dat in the current dir. If not found, it
> reads $HOME/.xmoto/. If not found, it reads the common file (that I
> apparently don't have in my system, btw).
> 
> I would recommend one of the following change:
> 1) read $PWD/.xmoto/config.dat instead on $PWD/config.dat. A simple
> patch is attached to do so. It would be enough to avoid conflicts
> with other programs using config.dat as a filename.
> 2) don't read anything in $PWD. But, add an command line option
> -config to specify a config file to try before $HOME/.xmoto/config.dat
> This solution is probably better, but harder to code for somebody
> with no clue about xmoto source code.
> 
> By the way, the manpage does not say all what it should about where
> config.dat is read from.
> 
> thanks,
> Brice
> 
> 
> 
> --- xmoto-0.2.4.orig/src/VFileIO.cpp
> +++ xmoto-0.2.4/src/VFileIO.cpp
> @@ -424,7 +424,7 @@
>      }
>      else {
>        /* Try current working dir */
> -      pfh->fp = fopen(Path.c_str(),"rb");
> +      pfh->fp = fopen((m_CurrentDir + std::string("/") + Path).c_str(),"rb");
>        if(pfh->fp == NULL) {
>          /* No luck. Try the user-dir then */
>          pfh->fp = fopen((m_UserDir + std::string("/") + Path).c_str(),"rb");        
> @@ -977,7 +977,7 @@
>    /*===========================================================================
>    Initialize file system fun
>    ===========================================================================*/
> -  std::string FS::m_UserDir="",FS::m_DataDir; /* Globals */
> +  std::string FS::m_CurrentDir="",FS::m_UserDir="",FS::m_DataDir; /* Globals */
>    bool FS::m_bGotDataDir;
>    std::string FS::m_BinDataFile = "";
>    int FS::m_nNumPackFiles = 0;
> @@ -985,6 +985,7 @@
>      
>    void FS::init(std::string AppDir) {    
>      m_bGotDataDir = false;
> +    m_CurrentDir = "";
>      m_UserDir = "";
>      m_DataDir = "";
>    
> @@ -1003,6 +1004,7 @@
>        /* Valid path? */
>        if(isDir(cModulePath)) {
>          /* Alright, use this dir */    
> +        m_CurrentDir = cModulePath;
>          m_UserDir = cModulePath;
>          m_DataDir = cModulePath;     
>          
> @@ -1011,6 +1013,9 @@
>        else throw Exception("invalid process directory");
>             
>      #else /* Assume unix-like */
> +      /* Store current dir */
> +      m_CurrentDir = std::string(".") + AppDir;
> +
>        /* Determine users home dir, so we can find out where to get/save user 
>          files */
>        m_UserDir = getenv("HOME");            
> --- xmoto-0.2.4.orig/src/VFileIO.h
> +++ xmoto-0.2.4/src/VFileIO.h
> @@ -184,7 +184,7 @@
>        static void _FindFilesRecursive(const std::string &Dir,const std::string &Wildcard,std::vector<std::string> &List);
>        
>        /* Data */
> -      static std::string m_UserDir,m_DataDir;
> +      static std::string m_CurrentDir,m_UserDir,m_DataDir;
>        static bool m_bGotDataDir;
>        
>        static std::string m_BinDataFile;      
> 
> 
> 
> 
> -- System Information:
> Debian Release: 4.0
>   APT prefers testing
>   APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
> Architecture: i386 (i686)
> Shell:  /bin/sh linked to /bin/bash
> Kernel: Linux 2.6.20-rc4=panpancucul
> Locale: LANG=C, LC_CTYPE=fr_FR@euro (charmap=ISO-8859-15)
> 
> Versions of packages xmoto depends on:
> ii  libbz2-1.0                1.0.3-6        high-quality block-sorting file co
> ii  libc6                     2.3.6.ds1-8    GNU C Library: Shared libraries
> ii  libcurl3                  7.15.5-1       Multi-protocol file transfer libra
> ii  libgcc1                   1:4.1.1-21     GCC support library
> ii  libgl1-mesa-glx [libgl1]  6.5.1-0.5      A free implementation of the OpenG
> ii  libjpeg62                 6b-13          The Independent JPEG Group's JPEG 
> ii  liblua5.1-0               5.1.1-2        Simple, extensible, embeddable pro
> ii  libode0c2                 1:0.5-5        Open Dynamics Engine - runtime lib
> ii  libpng12-0                1.2.15~beta5-1 PNG library - runtime
> ii  libsdl-mixer1.2           1.2.6-1.1+b2   mixer library for Simple DirectMed
> ii  libsdl1.2debian           1.2.11-7       Simple DirectMedia Layer
> ii  libstdc++6                4.1.1-21       The GNU Standard C++ Library v3
> ii  xmoto-data                0.2.4-2        2D motocross platform game
> ii  zlib1g                    1:1.2.3-13     compression library - runtime
> 
> xmoto recommends no packages.
> 
> -- no debconf information



--- End Message ---


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/