Changeset - r1939:10860cca6c4e
[Not reviewed]
master
0 1 0
matthijs - 19 years ago 2005-06-16 00:54:19
matthijs@openttd.org
(svn r2445) * Add: "stopall" console command, which forcibly stops all vehicles (useful for debugging).
1 file changed with 25 insertions and 0 deletions:
0 comments (0 inline, 0 general)
console_cmds.c
Show inline comments
 
@@ -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);
0 comments (0 inline, 0 general)