Patch: Send all trains to depot

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Splatman
Engineer
Engineer
Posts: 31
Joined: 31 Jul 2005 16:08
Location: United Kingdom

Patch: Send all trains to depot

Post 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.
Attachments
sendalltodepot.patch
Patch file v.5 (Should compile with new revisions)
(17.8 KiB) Downloaded 732 times
Last edited by Splatman on 08 Jun 2006 19:16, edited 5 times in total.
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7596
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post 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)
Image
Splatman
Engineer
Engineer
Posts: 31
Joined: 31 Jul 2005 16:08
Location: United Kingdom

Post 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.
User avatar
gkirilov
Chief Executive
Chief Executive
Posts: 696
Joined: 03 May 2005 09:32
Location: Othala

Post by gkirilov »

Good one, I'll try it.
OTTDCoop NewGRF Pack|Different sets of GRFs for TTDPatch (some of them work in OTTD) - 1|- 2|GRF sets for OTTD|OTTD nightly
Image
I hooked up my accelerator to my brake lights. I hit the gas, people behind me stop, and I'm gone.
Understeer is when you hit the wall with the front of the car. Oversteer is when you hit the wall with the rear of the car. Horsepower is how fast you hit the wall. Torque is how far you take the wall with you. Spoilers and bodykits are how much of the wall you take with you. Rollcages and windownets are how much of a mess you leave on the wall.
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Re: Patch: Send all trains to depot

Post 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 :)
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1790
Joined: 30 Mar 2005 09:43

Post 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. :-)
He's like, some kind of OpenTTD developer.
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post 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
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7596
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post 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?
Image
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post 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 :)
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Post 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
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Post 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 :).
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Post 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.
User avatar
AlienDNA
Engineer
Engineer
Posts: 97
Joined: 12 Apr 2004 08:53
Location: Leiden, Netherlands

Post 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.
"I'm gonna rip his leg off and kick him with it!", Sanjuro, Shogo-MAD
madman2003
Engineer
Engineer
Posts: 116
Joined: 20 May 2004 17:21

Post by madman2003 »

Not to mention any vehicles that are not in range of a depot, much more than a simple fix is needed.
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7596
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

Yes. Building more depots is one. :P
Image
User avatar
AlienDNA
Engineer
Engineer
Posts: 97
Joined: 12 Apr 2004 08:53
Location: Leiden, Netherlands

Post 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... :)
"I'm gonna rip his leg off and kick him with it!", Sanjuro, Shogo-MAD
Splatman
Engineer
Engineer
Posts: 31
Joined: 31 Jul 2005 16:08
Location: United Kingdom

Post 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.
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post 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?
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
Splatman
Engineer
Engineer
Posts: 31
Joined: 31 Jul 2005 16:08
Location: United Kingdom

Post 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?
Earl Sven
Engineer
Engineer
Posts: 21
Joined: 15 Dec 2005 14:18

I'm sorry I borked it!

Post 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?
Attachments
Disconnecting Train.sav
(2.13 MiB) Downloaded 384 times
Interlink Konnexions INC
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 14 guests