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 41379ded7e
commit 2d3d03cc38
2 changed files with 14 additions and 3 deletions

View File

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

View File

@ -127,6 +127,9 @@ public:
/** The difference is \a after - \a before. */
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)
virtual std::string GetDataPath();
@ -140,5 +143,6 @@ public:
virtual void Usleep(int usecs) = 0;
private:
std::string m_basePath;
std::vector<std::unique_ptr<SystemTimeStamp>> m_timeStamps;
};