Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/release-windows.yml # src/company_base.h # src/company_cmd.cpp # src/company_gui.cpp # src/console_cmds.cpp # src/economy.cpp # src/economy_cmd.h # src/fios.h # src/goal.cpp # src/group_gui.cpp # src/network/core/config.h # src/network/network_admin.cpp # src/newgrf_config.cpp # src/os/windows/win32.cpp # src/saveload/afterload.cpp # src/saveload/company_sl.cpp # src/saveload/saveload.cpp # src/saveload/saveload_error.hpp # src/settings_gui.cpp # src/ship_cmd.cpp # src/stdafx.h # src/story.cpp # src/story_base.h # src/string.cpp # src/table/settings/economy_settings.ini # src/tests/CMakeLists.txt # src/tests/math_func.cpp
This commit is contained in:
@@ -506,9 +506,7 @@ DEF_CONSOLE_CMD(ConLoad)
|
||||
if (item != nullptr) {
|
||||
if (GetAbstractFileType(item->type) == FT_SAVEGAME) {
|
||||
_switch_mode = SM_LOAD_GAME;
|
||||
_file_to_saveload.SetMode(item->type);
|
||||
_file_to_saveload.SetName(FiosBrowseTo(item));
|
||||
_file_to_saveload.SetTitle(item->title);
|
||||
_file_to_saveload.Set(*item);
|
||||
} else {
|
||||
IConsolePrintF(CC_ERROR, "%s: Not a savegame.", file);
|
||||
}
|
||||
@@ -533,7 +531,7 @@ DEF_CONSOLE_CMD(ConRemove)
|
||||
_console_file_list.ValidateFileList();
|
||||
const FiosItem *item = _console_file_list.FindItem(file);
|
||||
if (item != nullptr) {
|
||||
if (unlink(item->name) != 0) {
|
||||
if (unlink(item->name.c_str()) != 0) {
|
||||
IConsolePrintF(CC_ERROR, "%s: Failed to delete file", file);
|
||||
}
|
||||
} else {
|
||||
@@ -555,7 +553,7 @@ DEF_CONSOLE_CMD(ConListFiles)
|
||||
|
||||
_console_file_list.ValidateFileList(true);
|
||||
for (uint i = 0; i < _console_file_list.size(); i++) {
|
||||
IConsolePrintF(CC_DEFAULT, "%d) %s", i, _console_file_list[i].title);
|
||||
IConsolePrintF(CC_DEFAULT, "%d) %s", i, _console_file_list[i].title.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -2096,7 +2094,7 @@ static ContentType StringToContentType(const char *str)
|
||||
{
|
||||
static const char * const inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" };
|
||||
for (uint i = 1 /* there is no type 0 */; i < lengthof(inv_lookup); i++) {
|
||||
if (strcasecmp(str, inv_lookup[i]) == 0) return (ContentType)i;
|
||||
if (StrEqualsIgnoreCase(str, inv_lookup[i])) return (ContentType)i;
|
||||
}
|
||||
return CONTENT_TYPE_END;
|
||||
}
|
||||
@@ -2154,17 +2152,17 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "update") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "update")) {
|
||||
_network_content_client.RequestContentList((argc > 2) ? StringToContentType(argv[2]) : CONTENT_TYPE_END);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "upgrade") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "upgrade")) {
|
||||
_network_content_client.SelectUpgrade();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "select") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "select")) {
|
||||
if (argc <= 2) {
|
||||
/* List selected content */
|
||||
IConsolePrintF(CC_WHITE, "id, type, state, name");
|
||||
@@ -2172,7 +2170,7 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
if ((*iter)->state != ContentInfo::SELECTED && (*iter)->state != ContentInfo::AUTOSELECTED) continue;
|
||||
OutputContentState(*iter);
|
||||
}
|
||||
} else if (strcasecmp(argv[2], "all") == 0) {
|
||||
} else if (StrEqualsIgnoreCase(argv[2], "all")) {
|
||||
/* The intention of this function was that you could download
|
||||
* everything after a filter was applied; but this never really
|
||||
* took off. Instead, a select few people used this functionality
|
||||
@@ -2186,12 +2184,12 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "unselect") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "unselect")) {
|
||||
if (argc <= 2) {
|
||||
IConsoleError("You must enter the id.");
|
||||
return false;
|
||||
}
|
||||
if (strcasecmp(argv[2], "all") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[2], "all")) {
|
||||
_network_content_client.UnselectAll();
|
||||
} else {
|
||||
_network_content_client.Unselect((ContentID)atoi(argv[2]));
|
||||
@@ -2199,7 +2197,7 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "state") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "state")) {
|
||||
IConsolePrintF(CC_WHITE, "id, type, state, name");
|
||||
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
|
||||
if (argc > 2 && strcasestr((*iter)->name.c_str(), argv[2]) == nullptr) continue;
|
||||
@@ -2208,7 +2206,7 @@ DEF_CONSOLE_CMD(ConContent)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "download") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "download")) {
|
||||
uint files;
|
||||
uint bytes;
|
||||
_network_content_client.DownloadSelectedContent(files, bytes);
|
||||
@@ -2235,7 +2233,7 @@ DEF_CONSOLE_CMD(ConFont)
|
||||
|
||||
FontSize argfs;
|
||||
for (argfs = FS_BEGIN; argfs < FS_END; argfs++) {
|
||||
if (argc > 1 && strcasecmp(argv[1], FontSizeToName(argfs)) == 0) break;
|
||||
if (argc > 1 && StrEqualsIgnoreCase(argv[1], FontSizeToName(argfs))) break;
|
||||
}
|
||||
|
||||
/* First argument must be a FontSize. */
|
||||
@@ -2249,8 +2247,8 @@ DEF_CONSOLE_CMD(ConFont)
|
||||
|
||||
byte arg_index = 2;
|
||||
/* We may encounter "aa" or "noaa" but it must be the last argument. */
|
||||
if (strcasecmp(argv[arg_index], "aa") == 0 || strcasecmp(argv[arg_index], "noaa") == 0) {
|
||||
aa = strncasecmp(argv[arg_index++], "no", 2) != 0;
|
||||
if (StrEqualsIgnoreCase(argv[arg_index], "aa") || StrEqualsIgnoreCase(argv[arg_index], "noaa")) {
|
||||
aa = !StrStartsWithIgnoreCase(argv[arg_index++], "no");
|
||||
if (argc > arg_index) return false;
|
||||
} else {
|
||||
/* For <name> we want a string. */
|
||||
@@ -2271,8 +2269,8 @@ DEF_CONSOLE_CMD(ConFont)
|
||||
|
||||
if (argc > arg_index) {
|
||||
/* Last argument must be "aa" or "noaa". */
|
||||
if (strcasecmp(argv[arg_index], "aa") != 0 && strcasecmp(argv[arg_index], "noaa") != 0) return false;
|
||||
aa = strncasecmp(argv[arg_index++], "no", 2) != 0;
|
||||
if (!StrEqualsIgnoreCase(argv[arg_index], "aa") && !StrEqualsIgnoreCase(argv[arg_index], "noaa")) return false;
|
||||
aa = !StrStartsWithIgnoreCase(argv[arg_index++], "no");
|
||||
if (argc > arg_index) return false;
|
||||
}
|
||||
|
||||
@@ -2415,7 +2413,7 @@ DEF_CONSOLE_CMD(ConListDirs)
|
||||
|
||||
std::set<std::string> seen_dirs;
|
||||
for (const SubdirNameMap &sdn : subdir_name_map) {
|
||||
if (strcasecmp(argv[1], sdn.name) != 0) continue;
|
||||
if (!StrEqualsIgnoreCase(argv[1], sdn.name)) continue;
|
||||
bool found = false;
|
||||
for (Searchpath sp : _valid_searchpaths) {
|
||||
/* Get the directory */
|
||||
@@ -3382,7 +3380,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
|
||||
}
|
||||
|
||||
/* "select" sub-command */
|
||||
if (strncasecmp(argv[1], "sel", 3) == 0 && argc >= 3) {
|
||||
if (StrStartsWithIgnoreCase(argv[1], "sel") && argc >= 3) {
|
||||
for (size_t argnum = 2; argnum < argc; ++argnum) {
|
||||
int grfnum = atoi(argv[argnum]);
|
||||
if (grfnum < 1 || grfnum > (int)files.size()) { // safe cast, files.size() should not be larger than a few hundred in the most extreme cases
|
||||
@@ -3400,9 +3398,9 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
|
||||
}
|
||||
|
||||
/* "unselect" sub-command */
|
||||
if (strncasecmp(argv[1], "uns", 3) == 0 && argc >= 3) {
|
||||
if (StrStartsWithIgnoreCase(argv[1], "uns") && argc >= 3) {
|
||||
for (size_t argnum = 2; argnum < argc; ++argnum) {
|
||||
if (strcasecmp(argv[argnum], "all") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[argnum], "all")) {
|
||||
_newgrf_profilers.clear();
|
||||
break;
|
||||
}
|
||||
@@ -3419,7 +3417,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
|
||||
}
|
||||
|
||||
/* "start" sub-command */
|
||||
if (strncasecmp(argv[1], "sta", 3) == 0) {
|
||||
if (StrStartsWithIgnoreCase(argv[1], "sta")) {
|
||||
std::string grfids;
|
||||
size_t started = 0;
|
||||
for (NewGRFProfiler &pr : _newgrf_profilers) {
|
||||
@@ -3455,13 +3453,13 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
|
||||
}
|
||||
|
||||
/* "stop" sub-command */
|
||||
if (strncasecmp(argv[1], "sto", 3) == 0) {
|
||||
if (StrStartsWithIgnoreCase(argv[1], "sto")) {
|
||||
NewGRFProfiler::FinishAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
/* "abort" sub-command */
|
||||
if (strncasecmp(argv[1], "abo", 3) == 0) {
|
||||
if (StrStartsWithIgnoreCase(argv[1], "abo")) {
|
||||
for (NewGRFProfiler &pr : _newgrf_profilers) {
|
||||
pr.Abort();
|
||||
}
|
||||
@@ -3660,17 +3658,17 @@ DEF_CONSOLE_CMD(ConDumpInfo)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "roadtypes") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "roadtypes")) {
|
||||
ConDumpRoadTypes(argc, argv);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "railtypes") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "railtypes")) {
|
||||
ConDumpRailTypes(argc, argv);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[1], "cargotypes") == 0) {
|
||||
if (StrEqualsIgnoreCase(argv[1], "cargotypes")) {
|
||||
ConDumpCargoTypes(argc, argv);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user