1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Flatten share/ and user/ in the source and for the RUN_IN_PLACE build

This commit is contained in:
Perttu Ahola 2012-03-19 23:54:56 +02:00
parent 19ed3bb193
commit 97b693052c
122 changed files with 57 additions and 43 deletions

View file

@ -313,7 +313,8 @@ endif()
if(BUILD_CLIENT)
install(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../share/" DESTINATION ${SHAREDIR})
#install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../sounds/base/pack" DESTINATION "${SHAREDIR}/sounds/base/")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../textures/base/pack" DESTINATION "${SHAREDIR}/textures/base/")
if(USE_GETTEXT)
foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})

View file

@ -1034,12 +1034,7 @@ int main(int argc, char *argv[])
// Check if the world is found from the default directory, and if
// not, see if the legacy world directory exists.
world_path = porting::path_user + DIR_DELIM + "worlds" + DIR_DELIM + "world";
#ifdef RUN_IN_PLACE
std::string legacy_world_path = porting::path_user + DIR_DELIM +
".." + DIR_DELIM + "world";
#else
std::string legacy_world_path = porting::path_user + DIR_DELIM + "world";
#endif
if(!fs::PathExists(world_path) && fs::PathExists(legacy_world_path)){
errorstream<<"Warning: Using legacy world directory \""
<<legacy_world_path<<"\""<<std::endl;

View file

@ -123,8 +123,9 @@ void signal_handler_init(void)
Path mangler
*/
std::string path_share = ".." DIR_DELIM "share";
std::string path_user = ".." DIR_DELIM "user";
// Default to RUN_IN_PLACE style relative paths
std::string path_share = "..";
std::string path_user = "..";
std::string getDataPath(const char *subpath)
{
@ -167,8 +168,8 @@ void initializePaths()
assert(len < buflen);
pathRemoveFile(buf, '\\');
path_share = std::string(buf) + "\\..\\share";
path_user = std::string(buf) + "\\..\\user";
path_share = std::string(buf) + "\\..";
path_user = std::string(buf) + "\\..";
/*
Linux
@ -183,8 +184,8 @@ void initializePaths()
pathRemoveFile(buf, '/');
path_share = std::string(buf) + "/../share";
path_user = std::string(buf) + "/../user";
path_share = std::string(buf) + "/..";
path_user = std::string(buf) + "/..";
/*
OS X
@ -194,8 +195,8 @@ void initializePaths()
//TODO: Get path of executable. This assumes working directory is bin/
dstream<<"WARNING: Relative path not properly supported on OS X and FreeBSD"
<<std::endl;
path_share = std::string("../share");
path_user = std::string("../user");
path_share = std::string("..");
path_user = std::string("..");
#endif
@ -222,8 +223,8 @@ void initializePaths()
assert(len < buflen);
pathRemoveFile(buf, '\\');
// Use ".\bin\..\share"
path_share = std::string(buf) + "\\..\\share";
// Use ".\bin\.."
path_share = std::string(buf) + "\\..";
// Use "C:\Documents and Settings\user\Application Data\<PROJECT_NAME>"
len = GetEnvironmentVariable("APPDATA", buf, buflen);
@ -247,7 +248,7 @@ void initializePaths()
//path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME;
if (!fs::PathExists(path_share)) {
dstream<<"WARNING: system-wide share not found at \""<<path_share<<"\"";
path_share = std::string(buf) + "/../share";
path_share = std::string(buf) + "/..";
dstream<<"WARNING: Using \""<<path_share<<"\" instead."<<std::endl;
}

View file

@ -124,12 +124,7 @@ std::vector<WorldSpec> getAvailableWorlds()
}
// Check old world location
do{
#ifdef RUN_IN_PLACE
std::string fullpath = porting::path_user + DIR_DELIM + ".."
+ DIR_DELIM + "world";
#else
std::string fullpath = porting::path_user + DIR_DELIM + "world";
#endif
if(!fs::PathExists(fullpath))
break;
std::string name = "Old World";