Use SDL_GetBasePath() instead of physfs because it's buggy in old version

modernize-cmake-1
MrSimbax 2019-02-25 23:00:05 +01:00
parent 7268bcca11
commit 266944c9d2
2 changed files with 14 additions and 3 deletions

View File

@ -36,7 +36,7 @@
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <physfs.h> #include <SDL2/SDL.h>
std::unique_ptr<CSystemUtils> CSystemUtils::Create() std::unique_ptr<CSystemUtils> CSystemUtils::Create()
{ {
@ -177,12 +177,19 @@ float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *afte
return result; return result;
} }
std::string CSystemUtils::GetBasePath()
{
if (m_basePath.empty())
m_basePath = SDL_GetBasePath();
return m_basePath;
}
std::string CSystemUtils::GetDataPath() std::string CSystemUtils::GetDataPath()
{ {
#if DEV_BUILD #if DEV_BUILD
return std::string{"./"} + COLOBOT_DEFAULT_DATADIR; return std::string{"./"} + COLOBOT_DEFAULT_DATADIR;
#else #else
return std::string{PHYSFS_getBaseDir()} + COLOBOT_DEFAULT_DATADIR; return GetBasePath() + COLOBOT_DEFAULT_DATADIR;
#endif #endif
} }
@ -191,7 +198,7 @@ std::string CSystemUtils::GetLangPath()
#if DEV_BUILD #if DEV_BUILD
return std::string{"./"} + COLOBOT_I18N_DIR; return std::string{"./"} + COLOBOT_I18N_DIR;
#else #else
return std::string{PHYSFS_getBaseDir()} + COLOBOT_I18N_DIR; return GetBasePath() + COLOBOT_I18N_DIR;
#endif #endif
} }

View File

@ -127,6 +127,9 @@ public:
/** The difference is \a after - \a before. */ /** The difference is \a after - \a before. */
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0; virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0;
//! Returns the path where the executable binary is located
virtual std::string GetBasePath();
//! Returns the data path (containing textures, levels, helpfiles, etc) //! Returns the data path (containing textures, levels, helpfiles, etc)
virtual std::string GetDataPath(); virtual std::string GetDataPath();
@ -140,5 +143,6 @@ public:
virtual void Usleep(int usecs) = 0; virtual void Usleep(int usecs) = 0;
private: private:
std::string m_basePath;
std::vector<std::unique_ptr<SystemTimeStamp>> m_timeStamps; std::vector<std::unique_ptr<SystemTimeStamp>> m_timeStamps;
}; };