Merge branch 'master' into jgrpp-beta

# Conflicts:
#	src/command.cpp
#	src/console_cmds.cpp
#	src/group_gui.cpp
#	src/lang/catalan.txt
#	src/lang/czech.txt
#	src/lang/danish.txt
#	src/lang/greek.txt
#	src/lang/hungarian.txt
#	src/lang/irish.txt
#	src/lang/japanese.txt
#	src/lang/luxembourgish.txt
#	src/lang/norwegian_bokmal.txt
#	src/lang/romanian.txt
#	src/lang/russian.txt
#	src/lang/serbian.txt
#	src/lang/simplified_chinese.txt
#	src/lang/slovak.txt
#	src/lang/spanish_MX.txt
#	src/lang/swedish.txt
#	src/lang/tamil.txt
#	src/lang/traditional_chinese.txt
#	src/lang/turkish.txt
#	src/lang/ukrainian.txt
#	src/lang/vietnamese.txt
#	src/network/network.cpp
#	src/network/network_client.cpp
#	src/network/network_func.h
#	src/network/network_internal.h
#	src/network/network_server.cpp
#	src/network/network_server.h
#	src/saveload/afterload.cpp
#	src/saveload/newgrf_sl.cpp
#	src/saveload/saveload.h
#	src/script/script_instance.cpp
#	src/toolbar_gui.cpp
#	src/toolbar_gui.h
#	src/vehicle_gui.cpp
#	src/widgets/rail_widget.h
#	src/widgets/vehicle_widget.h
#	src/window.cpp
This commit is contained in:
Jonathan G Rennison
2021-11-03 00:45:12 +00:00
143 changed files with 3271 additions and 755 deletions

View File

@@ -60,6 +60,8 @@
#include "event_logs.h"
#include <time.h>
#include <set>
#include "safeguards.h"
/* scriptfile handling */
@@ -2174,6 +2176,71 @@ DEF_CONSOLE_CMD(ConNewGRFReload)
return true;
}
DEF_CONSOLE_CMD(ConListDirs)
{
struct SubdirNameMap {
Subdirectory subdir; ///< Index of subdirectory type
const char *name; ///< UI name for the directory
bool default_only; ///< Whether only the default (first existing) directory for this is interesting
};
static const SubdirNameMap subdir_name_map[] = {
/* Game data directories */
{ BASESET_DIR, "baseset", false },
{ NEWGRF_DIR, "newgrf", false },
{ AI_DIR, "ai", false },
{ AI_LIBRARY_DIR, "ailib", false },
{ GAME_DIR, "gs", false },
{ GAME_LIBRARY_DIR, "gslib", false },
{ SCENARIO_DIR, "scenario", false },
{ HEIGHTMAP_DIR, "heightmap", false },
/* Default save locations for user data */
{ SAVE_DIR, "save", true },
{ AUTOSAVE_DIR, "autosave", true },
{ SCREENSHOT_DIR, "screenshot", true },
};
if (argc != 2) {
IConsoleHelp("List all search paths or default directories for various categories.");
IConsoleHelp("Usage: list_dirs <category>");
std::string cats = subdir_name_map[0].name;
bool first = true;
for (const SubdirNameMap &sdn : subdir_name_map) {
if (!first) cats = cats + ", " + sdn.name;
first = false;
}
IConsolePrintF(CC_WARNING, "Valid categories: %s", cats.c_str());
return true;
}
std::set<std::string> seen_dirs;
for (const SubdirNameMap &sdn : subdir_name_map) {
if (strcasecmp(argv[1], sdn.name) != 0) continue;
bool found = false;
for (Searchpath sp : _valid_searchpaths) {
/* Get the directory */
std::string path = FioGetDirectory(sp, sdn.subdir);
/* Check it hasn't already been listed */
if (seen_dirs.find(path) != seen_dirs.end()) continue;
seen_dirs.insert(path);
/* Check if exists and mark found */
bool exists = FileExists(path);
found |= exists;
/* Print */
if (!sdn.default_only || exists) {
IConsolePrintF(exists ? CC_DEFAULT : CC_INFO, "%s %s", path.c_str(), exists ? "[ok]" : "[not found]");
if (sdn.default_only) break;
}
}
if (!found) {
IConsolePrintF(CC_ERROR, "No directories exist for category %s", argv[1]);
}
return true;
}
IConsolePrintF(CC_ERROR, "Invalid category name: %s", argv[1]);
return false;
}
DEF_CONSOLE_CMD(ConResetBlockedHeliports)
{
if (argc == 0) {
@@ -3387,6 +3454,7 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("list_settings", ConListSettings);
IConsole::CmdRegister("gamelog", ConGamelogPrint);
IConsole::CmdRegister("rescan_newgrf", ConRescanNewGRF);
IConsole::CmdRegister("list_dirs", ConListDirs);
IConsole::AliasRegister("dir", "ls");
IConsole::AliasRegister("del", "rm %+");