Change: by default, make "unload all" leave stations empty (#9301)

(cherry picked from commit 7648483364)
pull/326/head
Patric Stout 3 years ago committed by Jonathan G Rennison
parent 3411203e5d
commit 563884105f

@ -79,10 +79,22 @@ static bool IsValidSearchPath(Searchpath sp)
return sp < _searchpaths.size() && !_searchpaths[sp].empty();
}
static void FillValidSearchPaths()
static void FillValidSearchPaths(bool only_local_path)
{
_valid_searchpaths.clear();
for (Searchpath sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) {
if (only_local_path) {
switch (sp) {
case SP_WORKING_DIR: // Can be influence by "-c" option.
case SP_BINARY_DIR: // Most likely contains all the language files.
case SP_AUTODOWNLOAD_DIR: // Otherwise we cannot download in-game content.
break;
default:
continue;
}
}
if (IsValidSearchPath(sp)) _valid_searchpaths.emplace_back(sp);
}
}
@ -958,11 +970,12 @@ std::string _personal_dir;
* fill all other paths (save dir, autosave dir etc) and
* make the save and scenario directories.
* @param exe the path from the current path to the executable
* @param only_local_path Whether we shouldn't fill searchpaths with global folders.
*/
void DeterminePaths(const char *exe)
void DeterminePaths(const char *exe, bool only_local_path)
{
DetermineBasePaths(exe);
FillValidSearchPaths();
FillValidSearchPaths(only_local_path);
#ifdef USE_XDG
std::string config_home;
@ -1029,6 +1042,13 @@ void DeterminePaths(const char *exe)
/* We are using the XDG configuration home for the config file,
* then store the rest in the XDG data home folder. */
_personal_dir = _searchpaths[SP_PERSONAL_DIR_XDG];
if (only_local_path) {
/* In case of XDG and we only want local paths and we detected that
* the user either manually indicated the XDG path or didn't use
* "-c" option, we change the working-dir to the XDG personal-dir,
* as this is most likely what the user is expecting. */
_searchpaths[SP_WORKING_DIR] = _searchpaths[SP_PERSONAL_DIR_XDG];
}
} else
#endif
{
@ -1053,8 +1073,9 @@ void DeterminePaths(const char *exe)
/* If we have network we make a directory for the autodownloading of content */
_searchpaths[SP_AUTODOWNLOAD_DIR] = _personal_dir + "content_download" PATHSEP;
DEBUG(misc, 4, "%s added as search path", _searchpaths[SP_AUTODOWNLOAD_DIR].c_str());
FioCreateDirectory(_searchpaths[SP_AUTODOWNLOAD_DIR]);
FillValidSearchPaths();
FillValidSearchPaths(only_local_path);
/* Create the directory for each of the types of content */
const Subdirectory dirs[] = { SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR };

@ -27,7 +27,7 @@ const char *FiosGetScreenshotDir();
void SanitizeFilename(char *filename);
void AppendPathSeparator(std::string &buf);
void DeterminePaths(const char *exe);
void DeterminePaths(const char *exe, bool only_local_path);
std::unique_ptr<char[]> ReadFileToMem(const std::string &filename, size_t &lenp, size_t maxsize);
bool FileExists(const std::string &filename);
bool ExtractTar(const std::string &tar_filename, Subdirectory subdir);

@ -249,6 +249,7 @@ static void ShowHelp()
" -M music_set = Force the music set (see below)\n"
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
" -x = Never save configuration changes to disk\n"
" -X = Don't use global folders to search for files\n"
" -q savegame = Write some information about the savegame and exit\n"
" -Z = Write detailed version information and exit\n"
"\n",
@ -681,6 +682,7 @@ static const OptionData _options[] = {
GETOPT_SHORT_VALUE('G'),
GETOPT_SHORT_VALUE('c'),
GETOPT_SHORT_NOVAL('x'),
GETOPT_SHORT_NOVAL('X'),
GETOPT_SHORT_VALUE('q'),
GETOPT_SHORT_VALUE('K'),
GETOPT_SHORT_NOVAL('h'),
@ -710,6 +712,7 @@ int openttd_main(int argc, char *argv[])
std::unique_ptr<AfterNewGRFScan> scanner(new AfterNewGRFScan());
bool dedicated = false;
char *debuglog_conn = nullptr;
bool only_local_path = false;
extern bool _dedicated_forks;
_dedicated_forks = false;
@ -792,7 +795,7 @@ int openttd_main(int argc, char *argv[])
break;
case 'q':
case 'K': {
DeterminePaths(argv[0]);
DeterminePaths(argv[0], only_local_path);
if (StrEmpty(mgo.opt)) {
ret = 1;
return ret;
@ -833,6 +836,7 @@ int openttd_main(int argc, char *argv[])
CrashLog::VersionInfoLog();
return ret;
}
case 'X': only_local_path = true; break;
case 'h':
i = -2; // Force printing of help.
break;
@ -846,7 +850,7 @@ int openttd_main(int argc, char *argv[])
*
* The next two functions are needed to list the graphics sets. We can't do them earlier
* because then we cannot show it on the debug console as that hasn't been configured yet. */
DeterminePaths(argv[0]);
DeterminePaths(argv[0], only_local_path);
TarScanner::DoScan(TarScanner::BASESET);
BaseGraphics::FindSets();
BaseSounds::FindSets();
@ -855,7 +859,7 @@ int openttd_main(int argc, char *argv[])
return ret;
}
DeterminePaths(argv[0]);
DeterminePaths(argv[0], only_local_path);
TarScanner::DoScan(TarScanner::BASESET);
if (dedicated) DEBUG(net, 0, "Starting dedicated version %s", _openttd_revision);

Loading…
Cancel
Save