summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2005-06-16 00:54:19 +0000
committermatthijs <matthijs@openttd.org>2005-06-16 00:54:19 +0000
commit2e42c8279365a1b2ccca613606f6dcd5feee62bd (patch)
tree68358b8898a90071cfa6791a6a2ecdc1d93bfa2d
parent8607bbf06d0fd1781c6ea7cb551327bfde2a6b4b (diff)
downloadopenttd-2e42c8279365a1b2ccca613606f6dcd5feee62bd.tar.xz
(svn r2445) * Add: "stopall" console command, which forcibly stops all vehicles (useful for debugging).
-rw-r--r--console_cmds.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/console_cmds.c b/console_cmds.c
index 26bcea04e..cb7b57860 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -13,6 +13,7 @@
#include "command.h"
#include "settings.h"
#include "hal.h" /* for file list */
+#include "vehicle.h"
// ** scriptfile handling ** //
static FILE *_script_file;
@@ -87,6 +88,28 @@ static void IConsoleHelp(const char *str)
IConsolePrintF(_icolour_warn, "- %s", str);
}
+DEF_CONSOLE_CMD(ConStopAllVehicles)
+{
+ Vehicle* v;
+ if (argc == 0) {
+ IConsoleHelp("Stops all vehicles in the game. Use at your own risk... Usage: 'stopall'");
+ return true;
+ }
+
+ FOR_ALL_VEHICLES(v) {
+ if (IsValidVehicle(v)) {
+ /* Code ripped from CmdStartStopTrain. Can't call it, because of
+ * ownership problems, so we'll duplicate some code, for now */
+ if (v->type == VEH_Train)
+ v->u.rail.days_since_order_progr = 0;
+ v->vehstatus |= VS_STOPPED;
+ InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
+ InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
+ }
+ }
+ return true;
+}
+
DEF_CONSOLE_CMD(ConResetEngines)
{
if (argc == 0) {
@@ -1236,6 +1259,7 @@ void IConsoleStdLibRegister(void)
IConsoleCmdRegister("cd", ConChangeDirectory);
IConsoleCmdRegister("pwd", ConPrintWorkingDirectory);
IConsoleCmdRegister("clear", ConClearBuffer);
+ IConsoleCmdRegister("stopall", ConStopAllVehicles);
IConsoleAliasRegister("dir", "ls");
IConsoleAliasRegister("newmap", "newgame");
@@ -1267,6 +1291,7 @@ void IConsoleStdLibRegister(void)
IConsoleCmdRegister("status", ConStatus);
IConsoleCmdHookAdd("status", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
IConsoleCmdHookAdd("resetengines", ICONSOLE_HOOK_ACCESS, ConHookNoNetwork);
+ IConsoleCmdHookAdd("stopall", ICONSOLE_HOOK_ACCESS, ConHookNoNetwork);
IConsoleCmdRegister("rcon", ConRcon);
IConsoleCmdHookAdd("rcon", ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork);