OpenTTD

Tasklist

FS#1060 - Vehicles console commands

Attached to Project: OpenTTD
Opened by Bilbo (bilbo) - Friday, 20 July 2007, 01:42 GMT
Last edited by Patric Stout (TrueBrain) - Saturday, 28 July 2007, 18:02 GMT
Type Patch
Category Core
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Low
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I have created a patch that will add train (and also plane, ship and road vehicles) console commands.

These commands allow mass-manipulations with vehicles that would be tedious to do with the gui (for example "send all planes with max. speed <500 km/h to depot" or "sell two wagons for all trains with more than 12 wagons")

It adds command "train" in console, with several subcommands for trains, similarly "road" for road vehicles, "plane" or "aircraft" for aircrafts and "ship" for ships. Also command "vehicle" that will do the command on all appropriate vehicles of any type

For full manual to all commands, see the wiki page I have created for this: https://wiki.openttd.org/index.php/Vehicle_console_commands

I think it is enough stable to be candidate for inclusion in trunk.

Patch does not break savegame or multiplayer compatibility.

Attached is the patch for 10634.

Link to forum thread: https://www.tt-forums.net/viewtopic.php?f=33&t=32964
This task depends upon

Closed by  Patric Stout (TrueBrain)
Saturday, 03 November 2007, 23:51 GMT
Reason for closing:  Won't implement
Additional comments about closing:  Patch Rejected.
Comment by Patric Stout (TrueBrain) - Monday, 23 July 2007, 16:23 GMT
How ever much I LOVE what you did, I have one minor disappointment for you: we are currently considering removing the current console and replacing it with one based on Squirrel, a light-weighted script language. Squirrel is already used for the NoAI branch and providing a way for people to make AIs in a simple way. Based on our experience there we know for sure it would make the console much much easier. So, currently we put this patch on hold, till the time Squirrel is added to trunk, and we can convert the console to it. I am sure we can port your patch by then relatively easy.

But, for all clearness, I want to underline that I love the idea of your patch. Maybe it should in fact be a nice GUI... ;)
Comment by Bilbo (bilbo) - Monday, 23 July 2007, 17:23 GMT
Well, from my personal view, I prefer console for entering such automated tasks. Although the way things are done it would be possible to slightly modify the thing so that it will allow to write some additional gui which will then call something like InternalVehicleConsoleCommand(VEH_TRAIN, MATCH_LENGTH, MATCH_NOT_EQUAL, 3, TRAIN_SELL_WAGON, 3, 5) - soliciting all the parameters via some sort of comboboxes or such ....

Well, I'll look at it once squirrel arrives to trunk...
Comment by Chris (Chris) - Saturday, 28 July 2007, 16:56 GMT
Just a little note, it should be strtoul not strtoull :) Great patch anyways!
Comment by Bilbo (bilbo) - Sunday, 29 July 2007, 21:57 GMT
strtoul will convert to long (which may be 32 bit on 32bit architecture and 64bit on 64bits)
strtoull will convert to long long (which is always 64bits)

Money is 64bits.

So I think strtoull is correct.
Comment by Chris (Chris) - Monday, 30 July 2007, 13:38 GMT
Hmmm sounds logic, but the problem was that strtoull doesn't compile with MSVC while strtoul does :) if it works with GCC everything's fine.
Comment by Bilbo (bilbo) - Tuesday, 31 July 2007, 14:10 GMT
strtoul can't handle ints over 32bits, which may be quite problem with money, as money ovger 2G is quite common.

I found this:

http://msdn2.microsoft.com/en-us/library/85zk715d(VS.80).aspx

seems _strtoui64 does the same as strtoull, so perhaps add in some header something like this:

#ifdef MSVC
#define strtoull _strtoui64
#endif

Unfortunately, I have no MSVC (only GCC), so I can't try it.
Comment by Chris (Chris) - Tuesday, 31 July 2007, 14:27 GMT
the #define does the trick, although I couldn't figure out the identifier for Visual Studio. MSVC doesn't work and _MSVC_ as it's stated on several websites doesn't work either.
Comment by Chris (Chris) - Saturday, 01 September 2007, 14:45 GMT
#ifdef _MSC_VER
#define strtoull _strtoui64 ///< required for MSVC
#endif

Is the correct way to do it :)
Comment by Patric Stout (TrueBrain) - Saturday, 03 November 2007, 23:51 GMT
As said before, we won't add such big changes in console, mostly because console is not stable, or meant for such things. Patch rejected.

Loading...