Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Tue Mar 19, 2019 5:04 am

All times are UTC




Post new topic  Reply to topic  [ 25 posts ]  Go to page 1 2 Next
Author Message
PostPosted: Wed Mar 19, 2008 1:33 am 
Offline
Engineer
Engineer
User avatar

Joined: Sat Aug 23, 2003 9:24 pm
Posts: 122
Probably the most stress-free train network upgrading you'll ever experience. :)

When you're upgrading your track network using the track conversion tool, to something like monorail or maglev, you'll usually get a 'train in the way' error if you try to upgrade a depot whilst a train is stopped in there. This patch autoconverts all stopped trains, and their wagons, to the first compatible train/wagon of the new track type. This vastly increases the speed of upgrading your train network - simply build up money, send all your trains to the depots, and convert the depots along with the track and all the trains will also be converted!

Any comments/code improvements/suggestions welcome!

Quote:
Version history:
v0.1 (for SVN trunk r12347):
- Initial release.

v0.2 (for SVN trunk r12421):
- Now you have to hold CTRL when converting rail to autoconvert depots with trains in.
- Extra options added to the autoreplacement code (thanks Bjarni!), now we only upgrade a depot if we can afford to upgrade ALL trains in depot.
- Significant code overhaul, split up CmdConvertRail into 2 functions as we now need to iterate through all selected tiles twice, to check whether we have the money necessary for the conversion first; we must do this manually because we had to cause this command to trigger 'notest' in DoCommand.
- When querying the cost of converting track, if only depots with trains are selected, gives a cost estimation of upgrading each depot (ie. max possible cost).
- When querying to cost of converting track, if any track or empty depots are selected, gives a cost estimation of just upgrading any selected track (ie. min possible cost).
- When actually doing the replacement, always tries to convert any selected track or empty depots first. If that was successful, goes through each found depot with trains in, and tries to convert it; does so if we can afford the conversion.
- The cost animation near the cursor will reflect the cost of upgrding any empty depots and track tiles (INCLUDING the track tiles of the upgraded depots that had trains in them!). Each upgraded depot will have its own cost animation too, indicating the cost of upgrading the trains and wagons in that depot.



Known bugs:
- Group handling probably isn't very good; currently we just get the EngineReplacement for the group ID of the train (ie. engV->group_id), but set it again using the ALL_GROUP group.
- We might need one or two more custom strings for this patch (although I haven't found the need for any more yet...)
- I'm told there may also be problems with NewGRF, as some GRF sets disallow certain cargo types for certain track types. As my patch basically uses the autoreplace code, I'm hoping that as long as autoreplace is maintained to work with NewGRF, so this patch will work.
- Some code cleanup is needed.
- Currently, if we're estimating the cost of autoreplacing trains in a depot, the command will fail if we don't have enough money. The command needs not to fail, but to return the cost estimation of replacement. This patch currently hacks around this by charging 100 million for replacement if the cost estimation fails, but this should be fixed (Bjarni needs to fix this one in the autoreplace code ;-) )
- Doesn't handle very well replacing wagons for NewGRF sets that might not allow certain cargo types on certain track types (what is the best way to handle this? Hmm.)
- Doesn't handle very well replacing train engines that can hold cargo - maybe (maybe not?) we should try to replace them with train engines that handle the same type of cargo.
- Doesn't have a GUI to specify replacements (do we want this? It would seem very complex, perhaps unnecessarily so.)


Attachments:
File comment: Patch v0.1. Intended to be applied to OpenTTD trunk r12347.
Autoconvert v0.1.patch [16.15 KiB]
Downloaded 189 times
File comment: Patch v0.2. Intended to be applied to OpenTTD trunk r12421.
Autoconvert v0.2.patch [30.81 KiB]
Downloaded 448 times
File comment: An illustration of a train being converted automatically from railway to maglev. In this case, 'orphaned' wagons in the depot are also upgraded.
Autoconvert_screenie2.png [56.75 KiB]
Downloaded 424 times

_________________
=== Jez ===


Last edited by jez on Thu Mar 27, 2008 2:28 pm, edited 7 times in total.
Top
   
PostPosted: Wed Mar 19, 2008 12:17 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
First compatible? What about allowing specifying train replacement orders across railtypes (like SH-40 -> Pegasus, Asiastar -> Chimaera) and then using these for replacement instead of "first available"? This would be more clean solution IMHO

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
   
PostPosted: Wed Mar 19, 2008 12:43 pm 
Offline
Engineer
Engineer

Joined: Tue Apr 17, 2007 12:19 pm
Posts: 75
Good idea, although your implementation needs many issues ironed out.

_________________
Want to make a real difference? Australia HOPE International - Bringing hope to African orphans and widows.


Top
   
PostPosted: Wed Mar 19, 2008 12:44 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Aug 23, 2003 9:24 pm
Posts: 122
Bilbo wrote:
First compatible? What about allowing specifying train replacement orders across railtypes (like SH-40 -> Pegasus, Asiastar -> Chimaera) and then using these for replacement instead of "first available"? This would be more clean solution IMHO

Yep, but that would need a relatively involved GUI, which could be done I guess but I don't really need it for my games. You could also do the autoconversion with the first available vehicle, then figure out which vehicle had been used as the replacement, then setup autoreplace to replace that vehicle with the one you wanted.

_________________
=== Jez ===


Top
   
PostPosted: Wed Mar 19, 2008 6:37 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Wed Jan 04, 2006 6:16 pm
Posts: 222
Location: Alphen aan den Rijn, The Netherlands
Isn't there already a replace vehicle gui? Couldn't that be used for replacements?

Or let the tool convert just the depo, and use the replace gui to replace the vehicles?

_________________
NukeBuster

Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: irc://irc.oftc.net/transportempire !

OpenTTD patch(es): Password at join


Top
   
PostPosted: Wed Mar 19, 2008 6:56 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Aug 23, 2003 9:24 pm
Posts: 122
There is an autoreplace GUI, but it can currently only replace vehicles with others of the same track type; it can't convert between track types.

_________________
=== Jez ===


Top
   
PostPosted: Wed Mar 19, 2008 9:16 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6559
Location: The Netherlands
jez wrote:
There is an autoreplace GUI...

We know :wink: But one could expand upon the current GUI.

Anyways, I like your feature. Personally, I wouldn't mind upgrading all trains, and then running another replace sequence to get the trains I like. Specifying beforehand would be a more sensible solution though.

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
   
PostPosted: Thu Mar 20, 2008 12:33 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 23, 2005 12:09 am
Posts: 3138
Still better this patch than manually replacing. :)

_________________
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.


Top
   
PostPosted: Thu Mar 20, 2008 11:35 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
Current GUI could be used and it would be expanded to allow entering replace orders across track types. When coverting between track typess, these cross-track orders would then be performed. When the vehicle gets into the depot, only orders for same track type would be done.

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
   
PostPosted: Fri Mar 21, 2008 6:07 am 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Mon Mar 10, 2008 2:45 am
Posts: 247
Location: Australia
thanks

_________________
Nintendo DS OpenTTD ---- Latest YAPP Patch ---- OpenTTD Wiki ---- Image ---- Transport Tycoon PSX
Australia Scenario V1.0 ---- Luukland's Tasmania Scenario ---- Italy Scenario 0.35 --- Build A Town Patch


Top
   
PostPosted: Sat Mar 22, 2008 9:22 pm 
Offline
Engineer
Engineer

Joined: Sat Nov 18, 2006 11:39 am
Posts: 38
amazing :), thx a lot...

I didn't try it, because I dont have night build yet, but I will buy it as soon as possible...

question > I dont really understand this bug with Groups of trains... It means, that it is not able to convert more trains in one depot or it means, that we shouldnt convert more depots together?

_________________
Hi all


Top
   
PostPosted: Sat Mar 22, 2008 9:38 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Mon Mar 10, 2008 2:45 am
Posts: 247
Location: Australia
Could someone please post there openttd.exe with the patch already installed?

Thanks

_________________
Nintendo DS OpenTTD ---- Latest YAPP Patch ---- OpenTTD Wiki ---- Image ---- Transport Tycoon PSX
Australia Scenario V1.0 ---- Luukland's Tasmania Scenario ---- Italy Scenario 0.35 --- Build A Town Patch


Top
   
PostPosted: Sat Mar 22, 2008 9:49 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Apr 14, 2004 3:18 pm
Posts: 312
Location: Fr
This is very good !!!

I like the idea very much.

it's very fast, and if you are not happy you can change train by replacing tools (GUI) as you want.

for thoses who say "you must extend GUI to allow replacing across rail type", I would reply :
- it's longer : you have to select each train type (imagine you have 5 differents train types...)
- you will change every train on your network, you cannot work on a part of it (or you had to manage groups etc...)
so, this is not a good idea.


Top
   
PostPosted: Sat Mar 22, 2008 10:21 pm 
Offline
Engineer
Engineer
User avatar

Joined: Sat Aug 23, 2003 9:24 pm
Posts: 122
libik wrote:
question > I dont really understand this bug with Groups of trains... It means, that it is not able to convert more trains in one depot or it means, that we shouldnt convert more depots together?

I'm going to investigate this one a bit more. There are groups of trains, and I need to find out more but I think it's possible to group them and treat different groups differently when it comes to autoconversion. We need to handle that properly with this patch.

leno4 wrote:
Could someone please post there openttd.exe with the patch already installed?
Thanks

When I have a newer version that's more robust with fewer bugs I will post such an exe. :-)

_________________
=== Jez ===


Top
   
PostPosted: Sat Mar 22, 2008 10:29 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Mon Mar 10, 2008 2:45 am
Posts: 247
Location: Australia
jez wrote:
libik wrote:
question > I dont really understand this bug with Groups of trains... It means, that it is not able to convert more trains in one depot or it means, that we shouldnt convert more depots together?

I'm going to investigate this one a bit more. There are groups of trains, and I need to find out more but I think it's possible to group them and treat different groups differently when it comes to autoconversion. We need to handle that properly with this patch.

leno4 wrote:
Could someone please post there openttd.exe with the patch already installed?
Thanks

When I have a newer version that's more robust with fewer bugs I will post such an exe. :-)

Thanks a lot

_________________
Nintendo DS OpenTTD ---- Latest YAPP Patch ---- OpenTTD Wiki ---- Image ---- Transport Tycoon PSX
Australia Scenario V1.0 ---- Luukland's Tasmania Scenario ---- Italy Scenario 0.35 --- Build A Town Patch


Top
   
PostPosted: Sun Mar 23, 2008 12:06 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
fabca2 wrote:
for thoses who say "you must extend GUI to allow replacing across rail type", I would reply :
- it's longer : you have to select each train type (imagine you have 5 differents train types...)


You specify 5 replacements, then you can proceed in converting entire network. Much easier than deleting 100 trains by hand and then creating 100 new one.
If you use some newGRF's, you may want to specify which replacements you want, instead of relying on some automatic selection (which may or may not be good).

fabca2 wrote:
- you will change every train on your network, you cannot work on a part of it (or you had to manage groups etc...)


No. Only trains in depots that are hit by the "convert track" tool gets changed, so you have very precise selection of what parts get converted. Cross-type replace orders would be ignored when train just enters the depot. These would be only for the autoconverter.

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
   
PostPosted: Sun Mar 23, 2008 5:32 pm 
Offline
Engineer
Engineer

Joined: Sat Nov 18, 2006 11:39 am
Posts: 38
how to install this patch?

_________________
Hi all


Top
   
PostPosted: Sun Mar 23, 2008 6:33 pm 
Offline
Tycoon
Tycoon

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 3653
libik wrote:
how to install this patch?

Read viewtopic.php?f=33&t=21678


Top
   
PostPosted: Thu Mar 27, 2008 12:07 am 
Offline
Engineer
Engineer
User avatar

Joined: Sat Aug 23, 2003 9:24 pm
Posts: 122
I'm releasing my new version of this patch. :-) As you can see from the v0.2 version history, I've made quite a few changes and things are a bit nicer now, especially thanks to Bjarni's hard work in improving the train autoreplace code. Still one or two bugs to contend with, though.

Note that you now need to hold CTRL when you convert track for this autoreplacement to happen; otherwise you still get the old behaviour.

This new version isn't very well tested, so suggestions and bug reports are welcome.

OpenTTD devs, I'd appreciate starting to get some code reviews from you if you feel like it, too. :-)

_________________
=== Jez ===


Top
   
PostPosted: Fri Apr 04, 2008 4:14 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Tue Oct 03, 2006 7:17 am
Posts: 288
Location: The hague, Netherlands
I get

About to do DepotCost... tileindex: 161454
Illegal instruction (core dumped)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 25 posts ]  Go to page 1 2 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.
Hosted by Zernebok Hosting.