diff options
author | smatz <smatz@openttd.org> | 2009-05-26 13:16:58 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-05-26 13:16:58 +0000 |
commit | 55225433c4517e0daa514d0e4cd20660396d5008 (patch) | |
tree | 8be68ec549ba27731186dfc9e21c7a5be0c6fc36 | |
parent | 279746236bfdbcfd8f203df2de77e453402f3ad4 (diff) | |
download | openttd-55225433c4517e0daa514d0e4cd20660396d5008.tar.xz |
(svn r16432) -Feature(tte): use 'scrollto x y' in console to scroll to tile with given coordinates
-rw-r--r-- | src/console_cmds.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 6709f5f1f..787d0c647 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -155,21 +155,37 @@ DEF_CONSOLE_CMD(ConStopAllVehicles) DEF_CONSOLE_CMD(ConScrollToTile) { - if (argc == 0) { - IConsoleHelp("Center the screen on a given tile. Usage: 'scrollto <tile>'"); - IConsoleHelp("Tile can be either decimal (34161) or hexadecimal (0x4a5B)"); - return true; - } + switch (argc) { + case 0: + IConsoleHelp("Center the screen on a given tile."); + IConsoleHelp("Usage: 'scrollto <tile>' or 'scrollto <x> <y>'"); + IConsoleHelp("Numbers can be either decimal (34161) or hexadecimal (0x4a5B)."); + return true; - if (argc == 2) { - uint32 result; - if (GetArgumentInteger(&result, argv[1])) { - if (result >= MapSize()) { - IConsolePrint(CC_ERROR, "Tile does not exist"); + case 2: { + uint32 result; + if (GetArgumentInteger(&result, argv[1])) { + if (result >= MapSize()) { + IConsolePrint(CC_ERROR, "Tile does not exist"); + return true; + } + ScrollMainWindowToTile((TileIndex)result); return true; } - ScrollMainWindowToTile((TileIndex)result); - return true; + break; + } + + case 3: { + uint32 x, y; + if (GetArgumentInteger(&x, argv[1]) && GetArgumentInteger(&y, argv[2])) { + if (x >= MapSizeX() || y >= MapSizeY()) { + IConsolePrint(CC_ERROR, "Tile does not exist"); + return true; + } + ScrollMainWindowToTile(TileXY(x, y)); + return true; + } + break; } } |