Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Tue Sep 26, 2017 4:33 pm

All times are UTC




Post new topic  Reply to topic  [ 82 posts ]  Go to page 1 2 3 4 5 Next
Author Message
PostPosted: Sat Jul 05, 2008 2:24 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Sun Jan 27, 2008 1:02 pm
Posts: 298
13/04/09 Update to trunk r16055

Update 25/01/09
Finally an update to trunk, scroll down to the bottom of this post for a patch file.

Update 20/10/08
Update to current trunk, including savegame bump. I also posted a combined patch file of this patch and the stop in depot order patch. See viewtopic.php?f=33&t=38317&p=738076#p738076

Major Update 25/08/08
New Features! and more. Check out this post for more info and the patch file.
Topic renamed from the way-too-long 'order jump based on waiting/accepted cargo' to 'More conditional orders'

-----------------------------
Update 11/07/2008
Changes
- If the patch hits the end of the order list without finding a 'next station', it will continue searching at the top.
- 'Next station accepts' and 'Waiting at next station' are moved to the bottom of the dropdown list, both in the GUI and internally. This should make this patch fully savegame-compatible with the trunk. However, it broke savegame compatibility with the previous version :(
- Some coding issues were fixed. I could not fix them all before I go on holiday, though. (These are my last minutes on the internet) Further improvements of coding style, better strings and more features will have to wait a few weeks.
<<file removed>>
-----------------------------

This patch adds two more options for a conditional order jump:
- Next station accepts [cargo] is true/false
- [cargo] waiting at next station is true/false
Note: 'Next station' refers to the next real station in the order list. If no such station exists in the order list, the expression evaluates to false.

These new options can have a lot of uses, especially in combination with ECS. A few examples:

1) It becomes very easy to balance pickup from several scources. If 'cargo waiting at scource A is false', then another train is already loading there and we can go somewhere else.

2) You transport coal to an ECS steel mill. If the coal stockpile is full, the train goes to the power plant instead (see picture)
Attachment:
File comment: example of conditional orders
order window.PNG
order window.PNG [ 4.13 KiB | Viewed 17821 times ]


3) Distribution of stuff like ECS vehicles or fertilizer to all the industries that need them becomes a lot easier. There is no need to send the cargo to industries whose stockpile is already full any more. See the following example order list:
Attachment:
File comment: example of conditional orders
order window 2.PNG
order window 2.PNG [ 5.1 KiB | Viewed 17820 times ]

This is my first patch (actually the first thing ever in c++). All comments/criticism regarding bugs, functionality, coding style or anything else are welcome.

This patch has one known issue; when replacing a vehicle in a depot, conditional orders and all orders following it are lost. This is not the fault of this patch, but a trunk bug (FS #2130)

The patch file is below. Patch is against r13677. Although the savegame format/version is not changed, keep in mind that savegames are not backwards compatible.

Attachment:
File comment: Patch file for r16055
more-cond-orders-r16055.patch [27.97 KiB]
Downloaded 324 times

_________________
Create your own NewGRF? Check out this tutorial!


Last edited by Hirundo on Mon Apr 13, 2009 9:41 pm, edited 6 times in total.

Top
   
PostPosted: Sat Jul 05, 2008 2:29 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Apr 24, 2004 10:43 am
Posts: 1965
Location: Venezia - Italia
Great! That's what I ever missed on conditional orders
I hope it will be applied to trunk

_________________
ImageImage
ImageImage
ImageImage
newgrf tests, see: newgrf test topic, my patches: Wolf01's Hire Point
Italian TTD Forum
Wiki Page


Top
   
PostPosted: Sat Jul 05, 2008 6:39 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Sat Apr 28, 2007 11:53 am
Posts: 191
This is really nice, looks like the conditional order are becoming mature. I have some more suggestions for conditional jumps:
- Jump to order x when Next station has all platforms occupied.
- Jump to order x when Next station has y trains loading <cargo>.


Top
   
PostPosted: Sat Jul 05, 2008 6:55 pm 
Offline
Tycoon
Tycoon

Joined: Sun Dec 09, 2007 9:28 pm
Posts: 1919
One problem...

If a train goes from station A to pick up at station B, UNLESS station B is full when it goes to station C

What happens if station B is not full when the train leaves, but by the time it gets there it is full? Or vice versa. IE if the stations are a long way away, the status won't be the same when the train actually needs to make the decision.

_________________
Jon


Top
   
PostPosted: Sat Jul 05, 2008 11:28 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Feb 09, 2006 7:15 pm
Posts: 3815
Some issues/comments; coding and conceptually:
- what is the 'next' station? Should conditional orders be processed when trying to find them? If so, don't keep infinitively searching through conditional orders (see other code handling that).
- the order list is not 'looped linked list', i.e. if the last order is a waiting/accepted cargo order it will never find the next station.
- [next station] [accepts/does not accept] [<cargo type>] looks nicer to me. Same as [next station] [has/has no] [<cargo type>].
- *Cmd must always check parameters extensively for validity; now you only test whether the cargo type is in range, but it should also check whether the cargo type is actually used.
- it is "if (", not "if(".
- "else <statement>" is not allowed. Only "if (xxx) <statement>" is allowed, otherwise always use { and }.
- _order_conditional_cargo_names will overflow when all cargo slots are used.
- _order_conditional_cargo_names and _order_conditional_cargo_dropdown should be a class member (not needed to have them while the window isn't opened).
- do not add trailing whitespace; trailing whitespace in all it's forms is not accepted.
- _order_conditional_cargo_dropdown could be replaced by a bitmask of disabled dropdown buttons in which case _order_conditional_cargo_names would contain the names of the cargo indexed by the cargo type. This makes that it is not needed to do any conversions between cargo type and dropdown index or the other way around.
- please do not add order variables in between others as that breaks savegame compatability.

A major 'problem' with this patch might be the fact that the order jump is executed at the moment the previous order is fullfiled, which might cause people complaining. So I guess some documentation is needed that for these two functions to be useful one might need to add a waypoint just before the station.


Top
   
PostPosted: Sat Jul 05, 2008 11:52 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 23, 2005 12:09 am
Posts: 3138
The waypoint solution is a very smart idea Rubidium. Thanks.
I like this patch, and waypoints are going to be very useful here; thus they will be used extensively.

_________________
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: Sun Jul 06, 2008 2:20 am 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
Swallow wrote:
This patch adds two more options for a conditional order jump:
- Next station accepts [cargo] is true/false
- [cargo] waiting at next station is true/false

When I look at the screenie, I see "Next station accepts is true/false [cargo]". Kindly make the button order match the natural language order?

_________________
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser


Top
   
PostPosted: Sun Jul 06, 2008 10:46 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Sun Jan 27, 2008 1:02 pm
Posts: 298
Thanks for the replies all. I'm kinda busy at the moment but I'll try to make a new version somewhere this week.

@Youri219: I will certainly look into it. Refining the existing code will have priority however, so it will probably have to wait until after the holidays.

@audigex: Rubidium's suggestion of waypoints will help a lot I think. It's also possible to check load percentage after going to B. If it is more than zero, the train can still decide to go to C.

@Rubidium: Thanks for the comments, that is exactly the kind of feedback I needed :)

_________________
Create your own NewGRF? Check out this tutorial!


Top
   
PostPosted: Sun Jul 06, 2008 11:54 pm 
Offline
Chief Executive
Chief Executive
User avatar

Joined: Mon Jan 15, 2007 9:45 pm
Posts: 655
Location: FRANCE
this patch is great! It certainly will help make networks more efficient.

_________________
I am little, ugly, and nasty. How do you do?


Top
   
PostPosted: Mon Jul 07, 2008 10:55 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Oct 01, 2004 3:28 pm
Posts: 313
Is there already an option like "If the train is empty, skip next station"?

Situation where this would be useful:
If playing with ECS Vectors or PBI, the train delivers cargo to a station. Now it could happen that the stockpile is full, so the train can't deliver any or all of his cargo. You set the train to go to another station which also accepts the cargo. Now it would be great if the train would check if it has still cargo left after the first station and would only then go to the second accepting station, and else to the loading station.

Hope you get what i mean :)

Greets, Tim


Top
   
PostPosted: Mon Jul 07, 2008 11:52 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9019
Location: Sol d
Timitry wrote:
Is there already an option like "If the train is empty, skip next station"?

Even in trunk.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Mon Jul 07, 2008 2:23 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Oct 01, 2004 3:28 pm
Posts: 313
Wow, i never noticed those conditional order jumps had been in trunk... Well hidden ;-)


Top
   
PostPosted: Fri Jul 11, 2008 9:41 am 
Offline
Transport Coordinator
Transport Coordinator

Joined: Sun Jan 27, 2008 1:02 pm
Posts: 298
Update in first post

_________________
Create your own NewGRF? Check out this tutorial!


Top
   
PostPosted: Sat Jul 19, 2008 7:12 am 
Offline
Traffic Manager
Traffic Manager

Joined: Wed Mar 05, 2008 10:56 am
Posts: 128
these kind of jump order are better than the "skip on remaining cargo".
specially with the ECS, but evan without it.

hope theses orders will get included in trunk ;)
Thanks for it, works very well ;)


Top
   
PostPosted: Thu Jul 31, 2008 11:49 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 28, 2007 4:21 pm
Posts: 10
Why not change controls to read

"next station" "accepts"|"doesn't accept"|"has cargo waiting"|.. <cargo type>

"is false" business is a bit clumsy:D


Top
   
PostPosted: Wed Aug 06, 2008 12:04 am 
Offline
Chairman
Chairman
User avatar

Joined: Sat May 12, 2007 1:09 am
Posts: 882
Location: Northeastern USA
I've used this a few times now, and I like it! :)

First time, I had trains hauling coal and iron ore (in the same train) to a PBI steelmill. Of course, the coal mine is producing much more than the iron ore mine. Eventually the coal stockpile would get full and the mill station would stop accepting coal. So I set the trains up to stop first at the steelmill, then at a nearby power plant before returning to the mine. Then I added "if 'load percent' = 0, 'skip to'" the order for the iron mine station. Worked perfectly.

Next use was on trains hauling lumber and goods in one direction, and wood and goods in the other, with several stops. The forest on that line wasn't producing very much yet, but the sawmill was getting wood from the other direction, so I had lots of trains on that line. The trains transfering from the forest to the wood pickup were using full load. So a train would arrive with wood, the next 3 or so trains would load wood, then the next few would stop for no reason since the station was empty. I used "if 'waiting at next station' = 'wood' is false, 'skip to'" the next station, so that the trains would just roll on by the wood pickup on the bypass track if it was empty. Really reduced congestion and increased throughput on that line.

_________________
Who is John Galt?


Top
   
PostPosted: Wed Aug 06, 2008 7:17 pm 
Offline
Engineer
Engineer

Joined: Thu Dec 13, 2007 5:29 pm
Posts: 27
Hi,

your patch ist great. I tried successfull to build a self regulating network similar to this one:
viewtopic.php?f=29&t=38704

The great advantage with your patch is, than you only neet a waypoint in front of every loading station and one for looping. Just add some conditions and all the feeder-hack-thing in the other thread can be skipped.

My only problem is that the building of the order is a little time expensive :). So I tried to write a patch to build an order automatically, but I had to discover that my C++ knowlegde is as bad as the documentation for OpenTDD ;)

Is anybody able to give me a hint how I could extent the following order: (as many code as possible :) )

Code:
Waypoint
Station
Waypoint
Station
...
---
LoopWaypoint
UnloadingStation


To:
Code:
-Begin-
Jump Next
 Waypoint
 Jump Next
  Station
  Jump End
-Next-
Jump Next
 Waypoint
 Jump Next
  Station
  Jump End
-Next-
...
---
LoopWaypoint
Jump Begin
-End-
UnloadingStation


where Jump Next is "jump on nothing waiting at next station".


I hope you understand my problem.


Top
   
PostPosted: Thu Aug 07, 2008 2:02 pm 
Offline
Engineer
Engineer

Joined: Thu Dec 13, 2007 5:29 pm
Posts: 27
I could implement my idea, and thought everything works fine, until I restarted and loaded the game. Now I get an TOO_MANY_ORDER error on loading. Can anybody tell me where this error is raised?


Top
   
PostPosted: Mon Aug 25, 2008 7:18 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Sun Jan 27, 2008 1:02 pm
Posts: 298
After quite some time finally a much-needed update to this patch. The good news is that the update is a big one. It features:

> A New Feature: Jump if next station has X platforms free. With this option one can for example divert traffic away from overcrowding stations and towards empty stations.

> Yet Another New Feature: Jump XX percent of times. The good thing is that this is non-random. So if you set it to, for example, 50%, your vehicle will jump the first, third, fifth time and so on. This also works for shared vehicles. With this option, it is possible to equally divide traffic between different stations / mainline lanes etc. Or to let only a quarter of the trains stop in that tiny village with 10 passengers/month.

> Better strings for existing features: Next station accepts/does not accept X and Next station has/does not have X waiting. Since I am no native English speaker nor a GUI hero, it may not be perfect. Suggestions for improvements are welcome.

> Behind-the-scenes improvements in code.

Picture:
Attachment:
order window 3.PNG
order window 3.PNG [ 10.24 KiB | Viewed 15693 times ]


Suggestions / comments / criticism / bug reports are welcome. (Well, I hope no bugs :wink: )

Note that I will create a split version of (parts of) this patch if this is requested.

EDIT: Patch file is now obsolete


Attachments:
File comment: the patch, for r14173
more-cond-orders-r14173.patch [27.89 KiB]
Downloaded 253 times

_________________
Create your own NewGRF? Check out this tutorial!


Last edited by Hirundo on Mon Oct 20, 2008 7:00 pm, edited 1 time in total.
Top
   
PostPosted: Tue Aug 26, 2008 11:22 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Apr 24, 2004 10:43 am
Posts: 1965
Location: Venezia - Italia
Really nice new additions :D
Congratulations for this patch, I wish it will be in trunk

_________________
ImageImage
ImageImage
ImageImage
newgrf tests, see: newgrf test topic, my patches: Wolf01's Hire Point
Italian TTD Forum
Wiki Page


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 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-2017 phpBB Limited

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