Page 1 of 2

Patch: Send all trains to depot

Posted: 18 Apr 2006 14:55
by Splatman
Just a small patch that adds a button to the train list that sends all trains to their nearest depot (usefull when upgrading to monorail/maglev).

Update: Thanks to Thief^ my Grapical problems have been fixed. The code has been changed to a server side function, as sugested by peter1138. Now to get other vehicle types done.

v.3 Update: Added the ability to start all trains in a depot. Moved the Buttons to the bottom of the window. The Depot All button should now force every train that can route to a depot at the time it is pressed, to goto a depot and stay there. Still no support of other transport types as of yet.

v.4 Update: Added Road Vehicles

v.5 Update: Added Ships and Aircraft

Update: Updated the patch to compile with new revisions, I havent tested this, just replaced the Function call (CheckStoppedInHangar has been replaced with a new function) in the patch file.

Posted: 18 Apr 2006 15:21
by Born Acorn
Iv'e always wanted one of these. It will be good for forcing autoreplace. Could you do the same with other vehicles? (especially those pesky planes landing when i try to upgrade my airports)

Posted: 18 Apr 2006 15:39
by Splatman
Was planning on doing that anyway just want to get the GUI stuff done for trains first, then I can copy the code to the other transport types.

Posted: 18 Apr 2006 15:41
by gkirilov
Good one, I'll try it.

Re: Patch: Send all trains to depot

Posted: 18 Apr 2006 16:39
by richk67
Splatman wrote:Just a small patch that adds a button to the train list that sends all trains to their nearest depot (usefull when upgrading to monorail/maglev).

Try as I might I couldn't get the button to not resize with the window, I tried adding another panel afterwards but just got wierd graphical errors.
If this works as advertised, its straight into the Mini IN :)

Posted: 18 Apr 2006 16:43
by peter1138
Might be better as a single server-side command. Imagine if you have 500 trains, it will try sending 500 commands in an instant. Probably not good. :-)

Posted: 18 Apr 2006 17:10
by Wolf01
i hope that the "all vehicles to depot" order will make all vehicles go to depot and STAY at the depot

when you want to upgrade all the tracks (example from train to monorail) and you click on each of 500 trains on the list and send it to the depot, sometimes happen that trains enter one depot for service only and not to stop

Posted: 18 Apr 2006 18:26
by Born Acorn
Wolf01 wrote:i hope that the "all vehicles to depot" order will make all vehicles go to depot and STAY at the depot
Of course it does that. Were you expecting the "all vehicles to depot" order to make vehicles never go to depots at all?

Posted: 18 Apr 2006 18:49
by MeusH
Excellent. I'm waiting for next version, you can count on us, we will help you if you get lost in the code. Just use "search" often :)

Posted: 18 Apr 2006 19:58
by Wolf01
Born Acorn wrote:
Wolf01 wrote:i hope that the "all vehicles to depot" order will make all vehicles go to depot and STAY at the depot
Of course it does that. Were you expecting the "all vehicles to depot" order to make vehicles never go to depots at all?
no, i meant to not make vehicles service at depots as happen offten when you send them manually at depots

Posted: 18 Apr 2006 20:01
by XeryusTC
I'll try it :).

Can you also make something like this that just services all trains at the same time so they can be replaced very quickly :).

Posted: 18 Apr 2006 23:19
by l_Blue_l
i would also be nice to have a leave deport fuction after all the trains have gone to the deport.

great job.

Posted: 19 Apr 2006 07:09
by AlienDNA
What actually happens when a train leaves depot again after you send it to it's depot, is that it was already heading there. When clicking go to depot when it is already going, it returns to it's normal orders, and then quickly flips back to depot again, because it was heading there for regular maintenance. That's why it will leave when it enters the depot: it went there for maintenance.

Maybe it is a good idea to add some code that checks if the train is already heading to depot for regular maintenance or not when you click the button. If it does, don't cancel the go to depot order, but keep it, just with the addition that it will stay there when it arrives. When a depot order is manually given, and clicked again, then the status should return to normal, as it does now. I think this is essential for this patch as well, because otherwise all the trains that were heading for maintenance on the moment the grand go to depot-order was given, will leave again when they get there, making this command fail for those vehicles.

Posted: 19 Apr 2006 08:26
by madman2003
Not to mention any vehicles that are not in range of a depot, much more than a simple fix is needed.

Posted: 19 Apr 2006 09:22
by Born Acorn
Yes. Building more depots is one. :P

Posted: 19 Apr 2006 13:11
by AlienDNA
Maybe add another status color to the train numbers. Currently, normal vehicles are black, ones in depot blue, old ones red, and why not vehicles heading for depot by order yellow, and vehicles heading to depot for maintenance green? Or at least something like that. Then you'll see which trains go to depot and which ones do not. Then allow sorting based on these colors, and you're done! ;)

Of course, having a good network with enough depots is always usefull... :)

Posted: 19 Apr 2006 14:10
by Splatman
New version, see first post.

As for trains that xcan't route to a depot at the time the button is pressed you may just have to sort them out manualy, but this should take care of most trains.

Posted: 19 Apr 2006 15:04
by webfreakz.nl
Splatman wrote:New version, see first post.

As for trains that xcan't route to a depot at the time the button is pressed you may just have to sort them out manualy, but this should take care of most trains.
What about catching these train numbers and put them in a small window where you can click on it to view it's information?

Posted: 19 Apr 2006 19:33
by Splatman
New version.

Works (I think) with all transport types, I would like to get this tested a bit before I start thiking about adding other stuff (like finding trains that haven't been sent to the depot). Really needs multiplayer testing, with a lot of vehicles.

Also not sure if I am calling the functions in the right way, when the user clicks one othe the buttons a DoCommandP() is used to call one of my new functions, then my function directly calls one of the orginal functions (for example CmdSendTrainToDepot()), am I ment to be using DoCommandP() to call these as well or not?

I'm sorry I borked it!

Posted: 24 May 2006 09:33
by Earl Sven
I love this patch and I hate to break it to you that it doesnt appear to work completely 100% It has a nasty habit of giving a 'Disconnecting train' error if you hit the 'depot all' button whilst a train is in or partially in a depot. Have also had another strange error whilst using this. I am using a nightly from a few days ago, and this patch and terragenesis (so I doubt there is a conflict). I have been using it on a map with a friend we are playing multiplayer, I have posted a savegame a few seconds before I get this error, and you can see exactly what happens. Just load it up, its in pause mode, if you then hit the 'depot all' button and unpause you will see what happens. Sometimes it just crashes other times you actually see a 'disconnected train' by the depot. (Although its an MP save you can load it in SP and you will be my company).

Although I seem to get this error whatever I do now, it did work well initially, when I upgraded from Monorail to Maglev, however I wanted to go to the fastest maglev vehicle using this patch. My guess is that there is just too much fast traffic on the network and the chances of hitting the button at a point where there isnt already a train half in/out of a depot are negligible. Has anyone else had this problem with this patch where it causes a game crash when the button is pressed whilst a train is half in/out of a depot?