Applied Stephen Just's patch 2926028: search for data directory relative to the executable,
which allows STK to be started/debugged in VS without having to set a working directory. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4439 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
b34f4d238b
commit
d6b91f8fc3
@ -90,7 +90,7 @@ FileManager* file_manager = 0;
|
||||
* exists) changed in reInit().
|
||||
*
|
||||
*/
|
||||
FileManager::FileManager()
|
||||
FileManager::FileManager(char *argv[])
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
// irrLicht's createDevice method has a nasty habit of messing the CWD.
|
||||
@ -108,18 +108,30 @@ FileManager::FileManager()
|
||||
m_file_system = m_device->getFileSystem();
|
||||
m_is_full_path = false;
|
||||
|
||||
irr::io::path exe_path;
|
||||
|
||||
// Also check for data dirs relative to the path of the executable.
|
||||
// This is esp. useful for Visual Studio, since it's not necessary
|
||||
// to define the working directory when debugging, it works automatically.
|
||||
if(m_file_system->existFile(argv[0]))
|
||||
exe_path = m_file_system->getFileDir(argv[0]);
|
||||
|
||||
if ( getenv ( "SUPERTUXKART_DATADIR" ) != NULL )
|
||||
m_root_dir= getenv ( "SUPERTUXKART_DATADIR" ) ;
|
||||
#ifdef __APPLE__
|
||||
else if( macSetBundlePathIfRelevant( m_root_dir ) ) { /* nothing to do */ }
|
||||
#endif
|
||||
// else if(m_file_system->existFile("/Developer/games/supertuxkart/data/stk_config.xml"))
|
||||
// m_root_dir = "/Developer/games/supertuxkart" ;
|
||||
// FIXME - existFile() fails to detect the file, even though it exists, on my computer
|
||||
else if(m_file_system->existFile("data/stk_config.xml"))
|
||||
m_root_dir = "." ;
|
||||
else if(m_file_system->existFile("../data/stk_config.xml"))
|
||||
m_root_dir = ".." ;
|
||||
else if(m_file_system->existFile(exe_path+"/data/stk_config.xml"))
|
||||
m_root_dir = exe_path.c_str();
|
||||
else if(m_file_system->existFile(exe_path+"/../data/stk_config.xml"))
|
||||
{
|
||||
m_root_dir = exe_path.c_str();
|
||||
m_root_dir += "/..";
|
||||
}
|
||||
else
|
||||
#ifdef SUPERTUXKART_DATADIR
|
||||
m_root_dir = SUPERTUXKART_DATADIR ;
|
||||
|
@ -53,7 +53,7 @@ private:
|
||||
io::path createAbsoluteFilename(const std::string &f);
|
||||
|
||||
public:
|
||||
FileManager();
|
||||
FileManager(char *argv[]);
|
||||
~FileManager();
|
||||
void setDevice(IrrlichtDevice *device);
|
||||
void dropFileSystem();
|
||||
|
@ -492,9 +492,9 @@ int handleCmdLine(int argc, char **argv)
|
||||
//=============================================================================
|
||||
/** Initialises the minimum number of managers to get access to user_config.
|
||||
*/
|
||||
void initUserConfig()
|
||||
void initUserConfig(char *argv[])
|
||||
{
|
||||
file_manager = new FileManager();
|
||||
file_manager = new FileManager(argv);
|
||||
translations = new Translations(); // needs file_manager
|
||||
user_config = new UserConfig(); // needs file_manager
|
||||
} // initUserConfig
|
||||
@ -579,7 +579,8 @@ int main(int argc, char *argv[] )
|
||||
// Init the minimum managers so that user config exists, then
|
||||
// handle all command line options that do not need (or must
|
||||
// not have) other managers initialised:
|
||||
initUserConfig();
|
||||
initUserConfig(argv); // argv passed so config file can be
|
||||
// found more reliably
|
||||
handleCmdLinePreliminary(argc, argv);
|
||||
|
||||
initRest();
|
||||
|
Loading…
Reference in New Issue
Block a user