From 864b6abd4e23871213b9a2c3554f5951dd757016 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Wed, 27 Feb 2008 11:53:43 +0000 Subject: [PATCH] Bugfix, tracks were not found if STK was started in (e.g.) src. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1601 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/loader.cpp | 15 ++++++++------- src/loader.hpp | 3 ++- src/main.cpp | 2 +- src/track_manager.cpp | 3 +-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/loader.cpp b/src/loader.cpp index bdc3dbd25..76841500a 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -119,12 +119,13 @@ Loader::~Loader() void Loader::makePath(std::string& path, const std::string& dir, const std::string& fname) const { struct stat mystat; - + for(std::vector::const_iterator i = m_search_path.begin(); i != m_search_path.end(); ++i) { - if(dir !="") path+=(*i)+DIR_SEPARATOR+dir; - if(fname!="") path+=(*i)+DIR_SEPARATOR+fname; + path=*i; + if(dir !="") path+=DIR_SEPARATOR+dir; + if(fname!="") path+=DIR_SEPARATOR+fname; if(stat(path.c_str(), &mystat) >= 0) return; } @@ -284,9 +285,9 @@ std::string Loader::getPath(const char* FNAME) const } // getPath //----------------------------------------------------------------------------- -void Loader::listFiles(std::set& result, const std::string& dir) - const - { +void Loader::listFiles(std::set& result, const std::string& dir, + bool is_full_path) const +{ struct stat mystat; // don't list directories with a slash on the end, it'll fail on win32 @@ -297,7 +298,7 @@ void Loader::listFiles(std::set& result, const std::string& dir) for(std::vector::const_iterator i = m_search_path.begin(); i != m_search_path.end(); ++i) { - std::string path = *i+DIR_SEPARATOR+dir; + std::string path = is_full_path ? dir : *i+DIR_SEPARATOR+dir; if(stat(path.c_str(), &mystat) < 0) continue; diff --git a/src/loader.hpp b/src/loader.hpp index 6683f2044..bbf18f99a 100644 --- a/src/loader.hpp +++ b/src/loader.hpp @@ -55,7 +55,8 @@ public: std::string getPath(const char* name) const; std::string getPath(const std::string name) const {return getPath(name.c_str());} - void listFiles(std::set& result, const std::string& dir) + void listFiles(std::set& result, const std::string& dir, + bool is_full_path=false) const; void addSearchPath(const std::string& path); diff --git a/src/main.cpp b/src/main.cpp index 9b0a2520e..5aa79534c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -203,7 +203,7 @@ int handleCmdLine(int argc, char **argv) fprintf ( stdout, _(" Available tracks:\n") ); for (size_t i = 0; i != track_manager->getTrackCount(); i++) fprintf ( stdout, "\t%10s: %s\n", - track_manager->getTrack(i)->getIdent(), + track_manager->getTrack(i)->getIdent().c_str(), track_manager->getTrack(i)->getName()); fprintf ( stdout, _("Use --track N to choose track.\n\n")); diff --git a/src/track_manager.cpp b/src/track_manager.cpp index 806f4e1ef..62693a086 100644 --- a/src/track_manager.cpp +++ b/src/track_manager.cpp @@ -72,11 +72,10 @@ TrackManager::loadTrackList () { // Load up a list of tracks - and their names std::set files; - loader->listFiles(files, loader->getTrackDir()); + loader->listFiles(files, loader->getTrackDir(), /*is_full_path*/ true); for(std::set::iterator i = files.begin(); i != files.end(); ++i) { if(*i=="." || *i=="..") continue; - std::string config_file; try {