Merge branch 'jgrpp' into jgrpp-beta

# Conflicts:
#	src/settings.cpp
#	src/settings_gui.cpp
#	src/settings_internal.h
#	src/table/company_settings.ini
#	src/table/currency_settings.ini
#	src/table/gameopt_settings.ini
#	src/table/misc_settings.ini
#	src/table/settings.h.preamble
#	src/table/settings.ini
#	src/table/win32_settings.ini
#	src/table/window_settings.ini
This commit is contained in:
Jonathan G Rennison
2021-10-08 18:12:04 +01:00
66 changed files with 1239 additions and 643 deletions

View File

@@ -55,6 +55,9 @@
#include "base_media_base.h"
#include "debug_settings.h"
#include "walltime_func.h"
#include "debug_desync.h"
#include "scope_info.h"
#include "event_logs.h"
#include <time.h>
#include "safeguards.h"
@@ -173,11 +176,24 @@ DEF_CONSOLE_HOOK(ConHookNoNetwork)
return CHR_ALLOW;
}
/**
* Check if are either in singleplayer or a server.
* @return True iff we are either in singleplayer or a server.
*/
DEF_CONSOLE_HOOK(ConHookServerOrNoNetwork)
{
if (_networking && !_network_server) {
if (echo) IConsoleError("This command is only available to a network server.");
return CHR_DISALLOW;
}
return CHR_ALLOW;
}
DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
{
if (_settings_client.gui.newgrf_developer_tools) {
if (_game_mode == GM_MENU) {
if (echo) IConsoleError("This command is only available in game and editor.");
if (echo) IConsoleError("This command is only available in-game and in the editor.");
return CHR_DISALLOW;
}
return ConHookNoNetwork(echo);
@@ -222,7 +238,7 @@ DEF_CONSOLE_CMD(ConResetEnginePool)
}
if (_game_mode == GM_MENU) {
IConsoleError("This command is only available in game and editor.");
IConsoleError("This command is only available in-game and in the editor.");
return true;
}
@@ -683,6 +699,11 @@ DEF_CONSOLE_CMD(ConPauseGame)
return true;
}
if (_game_mode == GM_MENU) {
IConsoleError("This command is only available in-game and in the editor.");
return true;
}
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) {
DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
if (!_networking) IConsolePrint(CC_DEFAULT, "Game paused.");
@@ -700,6 +721,11 @@ DEF_CONSOLE_CMD(ConUnpauseGame)
return true;
}
if (_game_mode == GM_MENU) {
IConsoleError("This command is only available in-game and in the editor.");
return true;
}
if ((_pause_mode & PM_PAUSED_NORMAL) != PM_UNPAUSED) {
DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE);
if (!_networking) IConsolePrint(CC_DEFAULT, "Game unpaused.");
@@ -2218,6 +2244,19 @@ DEF_CONSOLE_CMD(ConDumpCommandLog)
return true;
}
DEF_CONSOLE_CMD(ConDumpSpecialEventsLog)
{
if (argc == 0) {
IConsoleHelp("Dump log of special events.");
return true;
}
char buffer[32768];
DumpSpecialEventsLog(buffer, lastof(buffer));
PrintLineByLine(buffer);
return true;
}
DEF_CONSOLE_CMD(ConDumpDesyncMsgLog)
{
if (argc == 0) {
@@ -2593,6 +2632,23 @@ DEF_CONSOLE_CMD(ConDumpCargoTypes)
return true;
}
DEF_CONSOLE_CMD(ConDumpVehicle)
{
if (argc != 2) {
IConsoleHelp("Debug: Show vehicle information. Usage: 'dump_vehicle <vehicle-id>'");
return true;
}
const Vehicle *v = Vehicle::GetIfValid(atoi(argv[1]));
if (v != nullptr) {
IConsolePrint(CC_DEFAULT, scope_dumper().VehicleInfo(v));
} else {
IConsolePrint(CC_DEFAULT, "No such vehicle");
}
return true;
}
/**
* Dump the state of a tile on the map.
* param x tile number or tile x coordinate.
@@ -2648,7 +2704,7 @@ DEF_CONSOLE_CMD(ConDumpTile)
DEF_CONSOLE_CMD(ConCheckCaches)
{
if (argc == 0) {
IConsoleHelp("Debug: Check caches");
IConsoleHelp("Debug: Check caches. Usage: 'check_caches [<broadcast>]'");
return true;
}
@@ -2658,8 +2714,7 @@ DEF_CONSOLE_CMD(ConCheckCaches)
if (broadcast) {
DoCommandP(0, 0, 0, CMD_DESYNC_CHECK);
} else {
extern void CheckCaches(bool force_check, std::function<void(const char *)> log);
CheckCaches(true, nullptr);
CheckCaches(true, nullptr, CHECK_CACHE_ALL | CHECK_CACHE_EMIT_LOG);
}
return true;
@@ -3369,8 +3424,8 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("unban", ConUnBan, ConHookServerOnly);
IConsole::CmdRegister("banlist", ConBanList, ConHookServerOnly);
IConsole::CmdRegister("pause", ConPauseGame, ConHookServerOnly);
IConsole::CmdRegister("unpause", ConUnpauseGame, ConHookServerOnly);
IConsole::CmdRegister("pause", ConPauseGame, ConHookServerOrNoNetwork);
IConsole::CmdRegister("unpause", ConUnpauseGame, ConHookServerOrNoNetwork);
IConsole::CmdRegister("company_pw", ConCompanyPassword, ConHookNeedNetwork);
IConsole::AliasRegister("company_password", "company_pw %+");
@@ -3422,6 +3477,7 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("getfulldate", ConGetFullDate, nullptr, true);
IConsole::CmdRegister("dump_command_log", ConDumpCommandLog, nullptr, true);
IConsole::CmdRegister("dump_special_events_log", ConDumpSpecialEventsLog, nullptr, true);
IConsole::CmdRegister("dump_desync_msgs", ConDumpDesyncMsgLog, nullptr, true);
IConsole::CmdRegister("dump_inflation", ConDumpInflation, nullptr, true);
IConsole::CmdRegister("dump_cpdp_stats", ConDumpCpdpStats, nullptr, true);
@@ -3436,6 +3492,7 @@ void IConsoleStdLibRegister()
IConsole::CmdRegister("dump_rail_types", ConDumpRailTypes, nullptr, true);
IConsole::CmdRegister("dump_bridge_types", ConDumpBridgeTypes, nullptr, true);
IConsole::CmdRegister("dump_cargo_types", ConDumpCargoTypes, nullptr, true);
IConsole::CmdRegister("dump_vehicle", ConDumpVehicle, nullptr, true);
IConsole::CmdRegister("dump_tile", ConDumpTile, nullptr, true);
IConsole::CmdRegister("check_caches", ConCheckCaches, nullptr, true);
IConsole::CmdRegister("show_town_window", ConShowTownWindow, nullptr, true);