summaryrefslogtreecommitdiff
path: root/src/console_cmds.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-02-05 16:07:23 +0000
committerfrosch <frosch@openttd.org>2011-02-05 16:07:23 +0000
commit915e339d0f395305ec722925bfd8f4fdd09f30a3 (patch)
treecf6982b3ae86b563f6868379f8f6240b658d6130 /src/console_cmds.cpp
parenta4b08dddd10062f49352b5aee49e392f95e281e2 (diff)
downloadopenttd-915e339d0f395305ec722925bfd8f4fdd09f30a3.tar.xz
(svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.
Diffstat (limited to 'src/console_cmds.cpp')
-rw-r--r--src/console_cmds.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 774d2f093..a8e4c3eb8 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -35,6 +35,7 @@
#include "ai/ai_config.hpp"
#include "newgrf.h"
#include "console_func.h"
+#include "engine_base.h"
#ifdef ENABLE_NETWORK
#include "table/strings.h"
@@ -141,6 +142,26 @@ DEF_CONSOLE_CMD(ConResetEngines)
return true;
}
+DEF_CONSOLE_CMD(ConResetEnginePool)
+{
+ if (argc == 0) {
+ IConsoleHelp("Reset NewGRF allocations of engine slots. This will remove invalid engine definitions, and might make default engines available again.");
+ return true;
+ }
+
+ if (_game_mode == GM_MENU) {
+ IConsoleError("This command is only available in game and editor.");
+ return true;
+ }
+
+ if (!EngineOverrideManager::ResetToCurrentNewGRFConfig()) {
+ IConsoleError("This can only be done when there are no vehicles in the game.");
+ return true;
+ }
+
+ return true;
+}
+
#ifdef _DEBUG
DEF_CONSOLE_CMD(ConResetTile)
{
@@ -1781,6 +1802,7 @@ void IConsoleStdLibRegister()
IConsoleCmdRegister("getdate", ConGetDate);
IConsoleCmdRegister("quit", ConExit);
IConsoleCmdRegister("resetengines", ConResetEngines, ConHookNoNetwork);
+ IConsoleCmdRegister("reset_enginepool", ConResetEnginePool, ConHookNoNetwork);
IConsoleCmdRegister("return", ConReturn);
IConsoleCmdRegister("screenshot", ConScreenShot);
IConsoleCmdRegister("script", ConScript);