mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix error
This commit is contained in:
parent
78eb7ba86e
commit
ffc853ecd2
5 changed files with 41 additions and 23 deletions
|
@ -105,3 +105,8 @@
|
||||||
// The intent is to ensure that the rendering doesn't turn terribly blurry
|
// The intent is to ensure that the rendering doesn't turn terribly blurry
|
||||||
// when filtering is enabled.
|
// when filtering is enabled.
|
||||||
#define TEXTURE_FILTER_MIN_SIZE 192U
|
#define TEXTURE_FILTER_MIN_SIZE 192U
|
||||||
|
|
||||||
|
|
||||||
|
// Luanti config filenames
|
||||||
|
#define CONFIGFILE "luanti.conf"
|
||||||
|
#define LEGACY_CONFIGFILE "minetest.conf"
|
||||||
|
|
26
src/main.cpp
26
src/main.cpp
|
@ -60,8 +60,6 @@ extern "C" {
|
||||||
#error ==================================
|
#error ==================================
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CONFIGFILE "luanti.conf"
|
|
||||||
#define LEGACY_CONFIGFILE "minetest.conf"
|
|
||||||
#define DEBUGFILE "debug.txt"
|
#define DEBUGFILE "debug.txt"
|
||||||
#define DEFAULT_SERVER_PORT 30000
|
#define DEFAULT_SERVER_PORT 30000
|
||||||
|
|
||||||
|
@ -743,28 +741,10 @@ static void startup_message()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
|
||||||
static std::string xdg_get_config_dir() {
|
|
||||||
const char *const xdg_config_home = getenv("XDG_CONFIG_HOME");
|
|
||||||
if (xdg_config_home)
|
|
||||||
return std::string(xdg_config_home) + DIR_DELIM "luanti";
|
|
||||||
|
|
||||||
const char *const home = getenv("HOME");
|
|
||||||
// In rare cases the HOME environment variable may be unset
|
|
||||||
FATAL_ERROR_IF(!home,
|
|
||||||
"Required environment variable HOME is not set");
|
|
||||||
return std::string(home) + DIR_DELIM ".config" DIR_DELIM "luanti";
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool read_config_file(const Settings &cmd_args)
|
static bool read_config_file(const Settings &cmd_args)
|
||||||
{
|
{
|
||||||
// Path of configuration file in use
|
// Path of configuration file in use
|
||||||
sanity_check(g_settings_path.empty()); // Sanity check
|
sanity_check(g_settings_path.empty()); // Sanity check
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
|
||||||
fs::CreateAllDirs(xdg_get_config_dir());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cmd_args.exists("config")) {
|
if (cmd_args.exists("config")) {
|
||||||
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
|
bool r = g_settings->readConfigFile(cmd_args.get("config").c_str());
|
||||||
if (!r) {
|
if (!r) {
|
||||||
|
@ -775,9 +755,9 @@ static bool read_config_file(const Settings &cmd_args)
|
||||||
g_settings_path = cmd_args.get("config");
|
g_settings_path = cmd_args.get("config");
|
||||||
} else {
|
} else {
|
||||||
std::vector<std::string> filenames;
|
std::vector<std::string> filenames;
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
std::optional<std::string> platform_specific_filename = porting::getPlatformSpecificConfigFile();
|
||||||
filenames.push_back(xdg_get_config_dir() + DIR_DELIM CONFIGFILE);
|
if (platform_specific_filename != std::nullopt)
|
||||||
#endif
|
filenames.push_back(platform_specific_filename.value());
|
||||||
// Legacy configuration file location
|
// Legacy configuration file location
|
||||||
filenames.push_back(porting::path_user + DIR_DELIM + LEGACY_CONFIGFILE);
|
filenames.push_back(porting::path_user + DIR_DELIM + LEGACY_CONFIGFILE);
|
||||||
// Very legacy configuration file location
|
// Very legacy configuration file location
|
||||||
|
|
|
@ -474,6 +474,7 @@ void migrateLegacyDirs() {
|
||||||
#elif defined(__ANDROID__)
|
#elif defined(__ANDROID__)
|
||||||
|
|
||||||
extern bool setSystemPaths(); // defined in porting_android.cpp
|
extern bool setSystemPaths(); // defined in porting_android.cpp
|
||||||
|
extern void migrateLegacyDirs(); // defined in porting_android.cpp
|
||||||
|
|
||||||
|
|
||||||
//// XDG systems
|
//// XDG systems
|
||||||
|
@ -1015,4 +1016,28 @@ void TriggerMemoryTrim()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
std::optional<std::string> getPlatformSpecificConfigFile() {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||||
|
static std::string xdg_get_config_dir() {
|
||||||
|
const char *const xdg_config_home = getenv("XDG_CONFIG_HOME");
|
||||||
|
if (xdg_config_home)
|
||||||
|
return std::string(xdg_config_home) + DIR_DELIM "luanti";
|
||||||
|
return std::string(getHomeOrFail()) + DIR_DELIM ".config" DIR_DELIM "luanti";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> getPlatformSpecificConfigFile() {
|
||||||
|
std::string config_home = xdg_get_config_dir();
|
||||||
|
fs::CreateAllDirs(config_home);
|
||||||
|
return config_home + DIR_DELIM CONFIGFILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
std::optional<std::string> getPlatformSpecificConfigFile() {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} //namespace porting
|
} //namespace porting
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
// Be mindful of what you include here!
|
// Be mindful of what you include here!
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <optional>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "irrlichttypes.h" // u64
|
#include "irrlichttypes.h" // u64
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
@ -121,6 +122,8 @@ void initializePaths();
|
||||||
|
|
||||||
void migrateLegacyDirs();
|
void migrateLegacyDirs();
|
||||||
|
|
||||||
|
std::optional<std::string> getPlatformSpecificConfigFile();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return system information
|
Return system information
|
||||||
e.g. "Linux/3.12.7 x86_64"
|
e.g. "Linux/3.12.7 x86_64"
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace porting {
|
||||||
void cleanupAndroid();
|
void cleanupAndroid();
|
||||||
std::string getLanguageAndroid();
|
std::string getLanguageAndroid();
|
||||||
bool setSystemPaths(); // used in porting.cpp
|
bool setSystemPaths(); // used in porting.cpp
|
||||||
|
void migrateLegacyDirs(); // used in porting.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int SDL_Main(int _argc, char *_argv[])
|
extern "C" int SDL_Main(int _argc, char *_argv[])
|
||||||
|
@ -99,6 +100,10 @@ static std::string readJavaString(jstring j_str)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void migrateLegacyDirs() {
|
||||||
|
// Real migration in android/
|
||||||
|
}
|
||||||
|
|
||||||
bool setSystemPaths()
|
bool setSystemPaths()
|
||||||
{
|
{
|
||||||
// Set user and share paths
|
// Set user and share paths
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue