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
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

It's indeed not so easily expressed in a mathematical formula. There are quite a lot of parameters and the notation would get kind of messy. It's probably easier to understand the source code. Look at src/linkgraph/demands.cpp. That's where the transport demand between nodes in the link graph and thus stations in the game is calculated. Destinations are assigned according to the demands calculated there.
The guy on the picture is not me, it's Alonso.
User avatar
BlueEagle_nl
Transport Coordinator
Transport Coordinator
Posts: 352
Joined: 28 Jan 2006 09:44
Skype: tilly5014
Location: Tillywood, The Netherlands

Re: Cargo Distribution

Post by BlueEagle_nl »

Hi alll,

Trying to play around with release gc0e22a3f released last monday, and I noticed fonts are a little bit too tiny to remain playable... See screenshot below.

I'm running a Windows 8 32bits PC, have the game windowed (also tried full screen and different resolutions: no effect). Also tried deleting openttd.cfg, and switching back and forth between Original and OpenGFX, but that also had no effect.
Vanilla OTTD has no font issues whatsoever, so it seems to be in the patch...

Hope you can come up for a solution ;-) Loved to play with the patch on my old Ubuntu machine, and can't actually play without it anymore ;-)

Greets,
Blueeagle_NL

[edit]Seems to be something up with the language settings: English (UK) and English (US) have no issues :O... Small Fonts reported in at least Dutch, Danish and French[/edit]
Attachments
Damn Small Prints...
Damn Small Prints...
TinyFonts.png (446.93 KiB) Viewed 1942 times
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Cargo Distribution

Post by Alberth »

Yep, those languages use characters not in the standard font, so they switch to a font at your system that does have them, apparently it picks a font for testing your eye quality :)
You may want to set a saner font as explained at http://wiki.openttd.org/FAQ_troubleshoo ... ll_to_read
JamieW
Engineer
Engineer
Posts: 3
Joined: 16 Feb 2013 03:57

Re: Cargo Distribution

Post by JamieW »

It seems waiting cargo (passengers) keeps resetting to zero at stations. Running a city circular bus route with 5 stations and let TT run at full speed, after a few years the passengers waiting at the stops build up to 1 or 2 thousand then keeps resetting to 0.

Started to noticed this in the last couple of releases, Donwloaded 04-Nov-2012 version to test that and in that version the waiting seems ok.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Seems I forgot to fix one occurrence of Truncate() in my refactoring effort. That's actually one I introduce in a later commit so it wasn't actually there when I refactored that code. So much about the problems of managing long patch queues...

Anyway, the problem will be fixed in tonight's build. Thanks for the report. This one was easy to reproduce. However, in the general case it's much easier for me to debug those things if you provide a savegame. The problem will usually be fixed faster, too. If you provide a savegame for a bug, in cases where the bug has not damaged the savegame, I will build you a savegame-compatible but fixed binary (32bit-Windows or 64bit-Linux) of cargodist on request. (If/when I find the bug, that is ...)

Code: Select all

--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -3329,7 +3329,7 @@ static void UpdateStationRating(Station *st)
                                         * decrease the flow of incoming cargo. */
 
                                        StationCargoAmountMap waiting_per_source;
-                                       ge->cargo.Truncate(waiting, &waiting_per_source);
+                                       ge->cargo.Truncate(ge->cargo.Count() - waiting, &waiting_per_source);
                                        for (StationCargoAmountMap::iterator i(waiting_per_source.begin()); i != waiting_per_so
                                                Station *source_station = Station::GetIfValid(i->first);
                                                if (source_station == NULL) continue;
The guy on the picture is not me, it's Alonso.
JamieW
Engineer
Engineer
Posts: 3
Joined: 16 Feb 2013 03:57

Re: Cargo Distribution

Post by JamieW »

Thanks, quick fix and quick reply. :bow:

Noted about uploading the saved game but as it was happening every game and very easy to reproduce, i knew you`d find it.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Cargo Distribution

Post by Alberth »

JamieW wrote:it was happening every game and very easy to reproduce, i knew you`d find it.
The problem is not finding, the problem is time and distraction. When puzzling about a problem, you need all your attention for the actual problem you're looking into. You cannot afford to get distracted by anything else.
Thus, the first thing any developer does is to create a setup where the problem is reproducible in about 10 seconds. That alone can take hours, time that cannot be spent on the problem you really want to solve.

As an illustration:
Before I became a dev, people were making cargo-dest. I submitted several bug reports with problems. In one case, I spent about 2 hours to setup a sequence of steps to follow to reproduce a problem. Afterwards, the devs reported they fixed the problem in 15 minutes due to my detailed report.

In other words, I gave them 2 extra hours for working on other problems.
JamieW
Engineer
Engineer
Posts: 3
Joined: 16 Feb 2013 03:57

Re: Cargo Distribution

Post by JamieW »

The ga715aacf update seems to have made the passenger numbers a little bit less eratic but the amount is still rolling over to zero.

Here 'Detbridge' station builds up to about 1580 passengers waiting until 11 Feb then resets. I havn`t really played with any other cargo so I can`t say if its just happening to passengers.
Attachments
Detbridge Transport, 2nd Feb 1953.sav
(330.29 KiB) Downloaded 26 times
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Thanks a lot. That's a related bug. The "waiting" thing obviously must not be > cargo.Count() anymore. There's actually a comment warning about that very effect one line above the problematic expression ... :/ The new version being built tonight will be savegame compatible with ga715aacf.

Code: Select all

diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index afce80c..763146c 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -3300,7 +3300,9 @@ static void UpdateStationRating(Station *st)
                                        uint32 r = Random();
                                        if (rating <= (int)GB(r, 0, 7)) {
                                                /* Need to have int, otherwise it will just overflow etc. */
-                                               waiting = max((int)waiting - (int)((GB(r, 8, 2) - 1) * num_dests), 0);
+                                               int remove = (int)GB(r, 8, 2) - 1;
+                                               if (remove > 0) waiting -= min(waiting, remove * num_dests);
+                                               assert(waiting <= ge->cargo.Count());
                                                waiting_changed = true;
                                        }
                                }
The guy on the picture is not me, it's Alonso.
bokkie
Transport Coordinator
Transport Coordinator
Posts: 327
Joined: 19 Jan 2007 19:26

Re: Cargo Distribution

Post by bokkie »

https://secure.openttd.org/hg/openttd/trunk.hg/shortlog

Something's happening... 1.3 has branched off so we just might be looking for a 1.4 inclusion :) Thumbs up for your perseverence Fonso!
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

The savegame-compatible version is the out-of-schedule built g8d7fe8cf-cd, not the additional scheduled build that will be done later.
The guy on the picture is not me, it's Alonso.
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

Indeed, nice to see some of those commits there. Though it I think they're more code preparations for the possible inclusion of CargoDist.
User avatar
Jacko
Tycoon
Tycoon
Posts: 2386
Joined: 13 May 2011 17:11
Location: In an alternate Universe

Re: Cargo Distribution

Post by Jacko »

Interesting behaviour here..
I'm not sure if its supposed to happen, but there seems to be a really high rate of passenger attraction to stations,
this screen demonstrates the situation
Nanthead Transport, 30th Jul 1958.png
(91.34 KiB) Downloaded 4 times
I build a small station in the middle of a town with 1100 or so population, it is served fairly regularly and trains have around 300 pax capacity
yet after a short there are around 1400 people waiting...? That's more than the town's population!

Does anyone know whats going on here?

EDIT: (version according to OTTD itself is gbc6b29cd-cd)
"O2 is for noobs, real people breath O3" ~ said sometime by Me

All comments from me may or may not be true and do not take them word-for-word

Feel Free to join me and some other people in The Nations Game - its actually quite fun.

1000th Post at Wed Feb 08, 2012 8:43 am
2000th post at Sun Apr 14, 2013 10:22 am
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

Could you please post a savegame? This doens't help really as we don't know what the routes are the passengers take. In general it can be said that passenger production in OpenTTD is rather high, however this doesn't become apparent while playing a normal game, you really start to notice this when playing CD games.
User avatar
Jacko
Tycoon
Tycoon
Posts: 2386
Joined: 13 May 2011 17:11
Location: In an alternate Universe

Re: Cargo Distribution

Post by Jacko »

here
but careful, you're probably going to need to hunt for NewGrfs
Nanthead Transport, 18th Sep 1958.sav
(5.34 MiB) Downloaded 26 times
seems really odd to me
"O2 is for noobs, real people breath O3" ~ said sometime by Me

All comments from me may or may not be true and do not take them word-for-word

Feel Free to join me and some other people in The Nations Game - its actually quite fun.

1000th Post at Wed Feb 08, 2012 8:43 am
2000th post at Sun Apr 14, 2013 10:22 am
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Can you please tell me where to get modern_set.grf, pgs2w.GRF and your version of the Canadian stations set? For the canadian stations it says version 0.3d and I though I had that, but apparently I either have some broken grf or it's a different version than I think it is (or the GUI is inconsistent ...)

Anyway, there are a lot of newgrfs that change passenger generation. Could it be that one of those missing ones is such a thing?
The guy on the picture is not me, it's Alonso.
User avatar
Jacko
Tycoon
Tycoon
Posts: 2386
Joined: 13 May 2011 17:11
Location: In an alternate Universe

Re: Cargo Distribution

Post by Jacko »

"O2 is for noobs, real people breath O3" ~ said sometime by Me

All comments from me may or may not be true and do not take them word-for-word

Feel Free to join me and some other people in The Nations Game - its actually quite fun.

1000th Post at Wed Feb 08, 2012 8:43 am
2000th post at Sun Apr 14, 2013 10:22 am
Kaos
Engineer
Engineer
Posts: 7
Joined: 14 Feb 2013 09:04

Re: Cargo Distribution

Post by Kaos »

Fonso, thank you for this great mod, I always thought TT was missing cargo destinations.

I'm sure you've answered this before, you probably explain it in the code review thread, but I don't quite get it: In my current game I created one small island with four towns and now have about 10 docks with lots of waiting passengers. And at least 20 passenger ferries, half going one, half going the other way round, visiting every dock. However, ships arrive at docks, are nowhere near full and don't pick anybody up - even though lots of people want to go to in that direction (though maybe 3, 4 docks away).

Why is that? Is it because cargo is reserved for specific ships? Is it because they also have the choice to use a bus system and prefer that (even though it is helplessly overloaded/underserved)?

Or is it best to only offer direct connections? But 9+8+7+6+5+4+3+2+1= 45 different routes (direct connections between all the 10 docks) is a bit of a hassle. Instead, maybe I should just have ferries running from one dock to the next? And passengers will have to transfer up to 4 times until they reach their destination?
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

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

Re: Cargo Distribution

Post by FLHerne »

I've encountered similar trouble in a couple of my games; if there are multiple possible routes between two points (particularly noticeable if there are parallel express/semi-fast/stopping services on the same route), you can get big pile-ups of people who ignore one train, going non-stop to their destination, so that they can catch a subsequent stopping service that follows exactly the same route to the same station, but calls at one other station in between... :roll:
Of course this can also happen the other way (less silly-looking), where they all ignore slightly slower services to wait for the express.

Presumably this also applies if there are ships with parallel bus services, although I don't think I've tried that.
Try expanding the entries in the 'waiting cargo' and look at the 'via' lines: do they all want to go via the next bus stop in that direction?
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.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 12 guests