Cargo Distribution

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

User avatar
FLHerne
Tycoon
Tycoon
Posts: 1543
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: Cargo Distribution

Post by FLHerne »

While thinking about tangential features, I believe a cargo*-production decrease/multiplier is almost essential with CargoDist when using some trainsets, e.g. UKRS2. Because the passengers travel much further than in trunk, the same rate of passenger creation results in far more traffic on the network than normal OTTD; with trainsets that don't provide very-high-capacity vehicles it's very difficult to actually carry all that traffic on a reasonable-looking network. So far I've been abusing one of the daylength patches to get that effect, but that has all sorts of buggy side-effects. Would it be possible to include such a feature in this patchset?

*or at least passengers/mail
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

I think (same as with the previous request concerning orders), these things combined could be tested in a patchpack. This patch solely is for the introduction of CargoDistribution, adding more functionality increases complexity and with that the possibility for eventual trunk inclusion. Just my ideas, but when introducing new features, introducing them in small parts is a wise approach.
Robbedem
Engineer
Engineer
Posts: 111
Joined: 14 Jan 2013 18:08

Re: Cargo Distribution

Post by Robbedem »

FLHerne wrote:While thinking about tangential features, I believe a cargo*-production decrease/multiplier is almost essential with CargoDist when using some trainsets, e.g. UKRS2. Because the passengers travel much further than in trunk, the same rate of passenger creation results in far more traffic on the network than normal OTTD; with trainsets that don't provide very-high-capacity vehicles it's very difficult to actually carry all that traffic on a reasonable-looking network. So far I've been abusing one of the daylength patches to get that effect, but that has all sorts of buggy side-effects. Would it be possible to include such a feature in this patchset?

*or at least passengers/mail
Funny that you mention it, I was having exactly the same problem. I posted a message in the suggestion forum: Less Passenger Generation and apparently the Canadian Cities - v1.1a NewGRF has the option to reduce passenger generation by reducing the town population. It is on the simuscape website however.
There is also an uncomplete NewGRF: Town and Industry - UK Houses
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

FLHerne wrote:While thinking about tangential features, I believe a cargo*-production decrease/multiplier is almost essential with CargoDist when using some trainsets, e.g. UKRS2. [...] So far I've been abusing one of the daylength patches to get that effect, but that has all sorts of buggy side-effects. Would it be possible to include such a feature in this patchset?
Well, obviously I don't want the buggy side effects in Cargodist. So no. You can do the same with newgrfs, as described by Robbedem. Maybe it's time to make a "Reduce pax/mail generation" newgrf that just does nothing else than that. It shouldn't be too hard to do but solve your problem. I'm wondering why everyone keeps complaining about passenger/mail generation but no one makes such a grf.
The guy on the picture is not me, it's Alonso.
User avatar
FLHerne
Tycoon
Tycoon
Posts: 1543
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: Cargo Distribution

Post by FLHerne »

fonso wrote:Well, obviously I don't want the buggy side effects in Cargodist.
I think most of the bugs (broken timetabling and animations) are down to the 'daylength' bit rather than the reduction in cargo production (which could itself be considered a bug of that daylength patch... :P ).
fonso wrote:I'm wondering why everyone keeps complaining about passenger/mail generation but no one makes such a grf.
Because there are already a lot of really good house/town sets, and it's not possible to make a grf that alters every such set that will ever exist - only the game can do that.
I don't have any problems with passenger numbers in trunk OTTD, it's that with CargoDist specifically, the number of passenger-tiles/year is far higher than existing transport and town grfs are designed for, and essentially breaking those grfs with your patch isn't ideal. :(
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Cargo Distribution

Post by planetmaker »

I do not think that cargodist should address any issue with the amount of cargo generation.

It's both, a separate issue and it can be NewGRF-addressed.

@Fonso: does Cargodist declare a global variable which possibly sets a bit per cargotype which indicates "cargodist in use" so that newgrfs might query it?
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

You can check the "distribution type" settings in the cargodist group in advanced settings. That will tell you if cargodist is in use (distribution type != "manual") for a specific cargo.
The guy on the picture is not me, it's Alonso.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Cargo Distribution

Post by planetmaker »

fonso wrote:You can check the "distribution type" settings in the cargodist group in advanced settings. That will tell you if cargodist is in use (distribution type != "manual") for a specific cargo.
Yes... but is it exposed to NewGRFs? (I definitely would like to hear frosch's opinion about that, but I think in the light of this discussion it might be good to give NewGRFs knowledge about that fact)
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

planetmaker wrote:Yes... but is it exposed to NewGRFs? (I definitely would like to hear frosch's opinion about that, but I think in the light of this discussion it might be good to give NewGRFs knowledge about that fact)
Can't NewGRFs query settings somehow? I faintly remember reading something like that. Otherwise it's not exposed, yet. I don't know the NewGRF API very well, so I'm not sure about the details but it shouldn't be too hard to add some callback or property that queries the distribution type somewhere. Mind that you can change the distribution types during the game. It's not a static thing you can use to initialize the NewGRFs.
The guy on the picture is not me, it's Alonso.
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

newgrfs cannot read all settings, only those exposed through "_ttdpatch_flags" in newgrf.cpp

as far as i can see there is a bit for cargo destinations reserved there, but not one per cargo type/class
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2822
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Cargo Distribution

Post by ChillCore »

I agree that pax reduction is needed when playing CargoD*st games.
I also agree that this is a seperate issue from CargoD*st and shoud be tackled as such.

Perhaps the NewGRF way is the best way but if it is not possible ... the cargo reduction patch never caused me any trouble/extra work whatsoever.
I am still using the one that was release with CargoDest and I do not recall having ever changed one line in it (functionality wise that is).
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Cargo Distribution

Post by planetmaker »

fonso wrote:
planetmaker wrote:Yes... but is it exposed to NewGRFs? (I definitely would like to hear frosch's opinion about that, but I think in the light of this discussion it might be good to give NewGRFs knowledge about that fact)
Can't NewGRFs query settings somehow? I faintly remember reading something like that. Otherwise it's not exposed, yet. I don't know the NewGRF API very well, so I'm not sure about the details but it shouldn't be too hard to add some callback or property that queries the distribution type somewhere. Mind that you can change the distribution types during the game. It's not a static thing you can use to initialize the NewGRFs.
In general settings are not accessible to NewGRFs; each needs separate exposure.

Code: Select all

	_ttdpatch_flags[3] =                                                      (0 << 0x00)  // newcargodistribution
is quoted from newgrf.cpp:7713. That bit indicates whether cargodist is in use or not, accessible to NewGRFs. That needs to be set to one, if any cargodist is active at all and stay at 0, if not used for any cargo. But honestly that might come a bit short, given that cargodist can act on each cargo separately.

Thus I'd add a separate variable (0x15?) which can communicate the details for the cargos in static uint32 GetPatchVariable(uint8 param)
(newgrf.cpp:6315). I'd chose uint32 as bitmask, one bit per (possible) cargo in the same order as the cargos in that particular game.
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

you'd probably need a 60+ variable that gets as parameter an entry in the cargo translation table. (which can have more than 32 entries)

but is that really necessary? how many people are really going to change their GRF behaviour depending on whether destinations are enabled or not for each cargo individually?
Robbedem
Engineer
Engineer
Posts: 111
Joined: 14 Jan 2013 18:08

Re: Cargo Distribution

Post by Robbedem »

Eddi wrote:but is that really necessary? how many people are really going to change their GRF behaviour depending on whether destinations are enabled or not for each cargo individually?
True, I think passengers, mail and valuables are the most important because they are generated and accepted at the same place causing the increased amount of 'goods' on the network.

About something different: does cargodist generate cargo based on the influence area, on the number of links in the graph or a combination?
(If I have an overcrowded station, can I make it less crowded by adding a new link to somewhere else or will this only create more passengers/mail in return?)
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

CargoDist does not change the amount of cargo you get, only where it goes.
User avatar
FLHerne
Tycoon
Tycoon
Posts: 1543
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: Cargo Distribution

Post by FLHerne »

Eddi wrote:CargoDist does not change the amount of cargo you get, only where it goes.
It doesn't change the amount of cargo you get, but it causes each unit of cargo to go further (because it has to go to a specific station, not just the next one along*), and so the number of cargo-tiles/month (i.e. the network capacity needed) is much higher.

*this applies much more to passengers/mail, because players tend to concentrate other cargos and send them a long way to specific places in trunk, so grfs are already balanced for that.

e.g.: If you have three passenger stations A-B-C-D:
- In trunk, passengers will get on at A, and all of them will get off at B, then some other ones get on, etc. All segments of the route carry only the passengers from the stations at each end of that segment.
- In CDist, some passengers from A will stay on at B, and some might even carry on all the way to D. So if before the passengers from B just fitted into the train, there now isn't enough space for them - the segment B-C is carrying a lot of passengers from A and D as well as those from B and C.
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
User avatar
YSH
Engineer
Engineer
Posts: 101
Joined: 15 Jan 2008 15:05

Re: Cargo Distribution

Post by YSH »

My game, using cargodist version geef1f48f-cd just crashed while making changes to a station.
Attachments
crash.sav
(3.91 MiB) Downloaded 24 times
crash.png
(169.53 KiB) Downloaded 2 times
crash.log.txt
(13.34 KiB) Downloaded 41 times
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: Cargo Distribution

Post by Transportman »

YSH wrote:My game, using cargodist version geef1f48f-cd just crashed while making changes to a station.
That looks like an old bug in trunk that has been fixed in r25132 (removes the cause of the stray reservation) and r25152 (removes the stray reservations already in your game).
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
m00se
Engineer
Engineer
Posts: 6
Joined: 28 Apr 2013 17:13

Re: Cargo Distribution

Post by m00se »

I just spend my whole weekend with Cargodist, and I do really love it. I do have a question regarding the payments however; an example will make it clear:
On the Europa map I have a lot of trains transporting passengers and mail to a station in Paris, I also have an airport just outside Paris (does not even accept passengers) which connect to London etc. These trains and the planes are not making a lot of money, often even loosing a lot. However: the short train connection from the Paris train station to the airport is making millions...
So, the overall profit is pretty good, but I get this constant messages about trains and planes loosing money, although their indirect profit is huge (if I would remove them the train to the airport won't make money anymore of course). Any ideas?
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

the profit calculation tends to overestimate the final income for feeder trains, so there is a setting to reduce the feeder share. default value is 70% of the estimation. if you get frequent negative final income, you should reduce that value even more. (this will not change the amount of money you get, but it will change the balance between the first and the last vehicle(s) in the chain)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 33 guests