From 266944c9d27b4bf2458feb4de4c5403fb9f38858 Mon Sep 17 00:00:00 2001 From: MrSimbax Date: Mon, 25 Feb 2019 23:00:05 +0100 Subject: [PATCH] Use SDL_GetBasePath() instead of physfs because it's buggy in old version --- src/common/system/system.cpp | 13 ++++++++++--- src/common/system/system.h | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/common/system/system.cpp b/src/common/system/system.cpp index 2ef642ab..c1886852 100644 --- a/src/common/system/system.cpp +++ b/src/common/system/system.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include std::unique_ptr 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 } diff --git a/src/common/system/system.h b/src/common/system/system.h index 36e736c9..7912f27a 100644 --- a/src/common/system/system.h +++ b/src/common/system/system.h @@ -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> m_timeStamps; };