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: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

The recalculation is triggered in OnTick_LinkGraph, like this:

Code: Select all

	if (_date_fract == LinkGraph::COMPONENTS_SPAWN_TICK ||
			_date_fract == LinkGraph::COMPONENTS_JOIN_TICK) {

		LinkGraphSettings &settings = _settings_game.linkgraph;

		/* This creates a fair distribution of all link graphs' turns over
		 * the available dates.
		 */
		uint interval = settings.recalc_interval;
		for (uint cargo = _date % interval; cargo < NUM_CARGO; cargo += interval) {

			/* don't calculate a link graph if the distribution is manual */
			if (settings.GetDistributionType(cargo) == DT_MANUAL) continue;

			if (_date_fract == LinkGraph::COMPONENTS_SPAWN_TICK) {
				_link_graphs[cargo].NextComponent();
			} else /* LinkGraph::COMPONENTS_JOIN_TICK */ {
				_link_graphs[cargo].Join();
			}
		}
	}
Mind that a recalculation doesn't recalculate all components of the link graph for the given cargo, only the current one. So it might take several recalculation intervals to recalculate the values for a given station if you have lots of disconnected components.

The "link graph" in this context is a partial copy of the game state calculated from the capacity measurements. It is fed through several link graph handlers which add demands and plan numbers and then "joined" back. What you see in the smallmap are the raw capacity, usage and flow numbers from the main game state.
The guy on the picture is not me, it's Alonso.
User avatar
ChillCore
Tycoon
Tycoon
Posts: 2867
Joined: 04 Oct 2008 23:05
Location: Lost in spaces

Re: Cargo Distribution

Post by ChillCore »

Thank you for the quick reply fonso.

_date is in days and _date_fract is in ticks so I might need to do some testing with COMPONENTS_SPAWN_TICK and COMPONENTS_JOIN_TICK, although that will only change the when during the day and not the actual interval.

Maybe I will also have to check the code from where OnTick_LinkGraph() is called ...
Anyway, as I mentioned, that discussion is unrelated to CargoDist. ;)
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.

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.
Auge
Chief Executive
Chief Executive
Posts: 661
Joined: 23 Oct 2006 02:07
Location: Berlin

Re: Cargo Distribution

Post by Auge »

Hello

I have crashes with newer versions of CargoDist. I use the binaries from openttdcoop.org. The crash info files are added as ZIP.

[edit]
first edit:
I saw a crash report in the OpenTTD 1.1 beta thread (OTTDmaster). It is the same error.

crash in 1.1 beta:

Code: Select all

Crash reason:
 Signal:  Abort trap (6)
 Message: Assertion failed at line 1024 of /usr/src/OpenTTD/compile/src/viewport.cpp: type < HT_DIR_END
crash in CargoDist g07bf3ca7...

Code: Select all

Crash reason:
 Signal:  Aborted (6)
 Message: Assertion failed at line 1024 of /usr/src/OpenTTD/compile/src/viewport.cpp: type < HT_DIR_END
second edit:
Should be fixed in todays nightly. See: 4327, 4328
[/edit]
Attachments
cargodist-crash.zip
(180.72 KiB) Downloaded 46 times
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

As it's a bit quiet in my student flat atm, I'm going to set up a server with the newer version, any newgrf requests, map size et?. If no I prefer not too many new grfs. It'll probably be something like:

- medium see level (few big islands)
- 256*1024 (still allowing long routes)
- hilly / mountainous
- weight 4*[1]
- hill 4%[1]

- fish (connect the islands)
- 2CC (I'm quite fond of the set, I have not yet encountered a set that allows more to choose from)
- NuTracks (perfect in combination with 2CC)
- eGRFTS (road vehicles)
- av8
- TTRS
- FIRS

[1] My findings in http://www.tt-forums.net/viewtopic.php?p=920662#p920662 show that 2CC trains are a bit too much penalised I think, so a bit of help by settings % and multiplier a bit lower


edit:Auge what version are you using? Because it would be kinda useless to set up a server with that if it keeps crashing!
edit2: nvm bad reader am I
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

I've pushed an update. Actually the problem should already be fixed in yesterday's g74238bec. Is the server already running? I'd like to take a look. You may want to test the new auto-orders. Build a vehicle and give it a stopping order. Have it stop at some stations it doesn't have an explicit order for. See what happens ;)
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- »

I'm going to set it up tonight (CET) or tomorrow morning.

edit:
So apparently there already was a newer version again: going for openttd-cargodist-g003d86e4-windows-win32 then. Using all standard banana grfs EXEPT FOR TTRS! As I've been working on remote desktop to the server, I've not yet thoroughly tested whether settings are as I like 'm.

- hilly, few big islands (use ships or a lot of terraforming, I'm not going to moderate this, it's up to youself).
- g003d86e4
- it's running with ddesync=3, you could connect that way as well if you're looking to help find possible desync issues.
- server info
- a few station tile sets for those looking to change the way their stations look.

edit2: I've made a small start, if you're feeling like continuing my company, feel free to do so. I think today I'm going to play Civ V a bit.
Arie-
Director
Director
Posts: 593
Joined: 20 Jan 2009 16:07

Re: Cargo Distribution

Post by Arie- »

Hey Fonso, sorry for the disconnect. But my server is having issues again, I before posted something on this right here. And I'm still trying to figure out what it is, as my server is being listed as offline, but clients are able to connect. I just cannot understand what I'm doing wrong, I've been forwarding ports all my life (not for real, but just to get an idea). Especially this log illustrates this issue. I start my server, all is fine, it's registerd by the master server etc. (please note the updated data here, which was this morning), but like 15 minutes later, near the bottom of the log linked to in this post as an example, things start to fail. However, clients can still connect.

Edit:
So I saw your "automatic orders" showcase, (at least) one issue with that currently, I keep getting the "to little orders" message. I don't know the exact English sentence as language currently is set to Dutch).
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Arie- wrote:So I saw your "automatic orders" showcase, (at least) one issue with that currently, I keep getting the "to little orders" message. I don't know the exact English sentence as language currently is set to Dutch).
Yes, that's kind of an extreme example. You have to switch off that particular warning if you want to do things like this. And you can't send the vehicles to a depot as you don't know in which direction they'll go on when the reappear. As there is no manual order, no automatic orders are ever deleted and the order list would fill up indefinitely if a vehicle goes the wrong direction. However, the classical example is a train which goes along some track with a few stations on it, but only has orders for the first and last ones. A setup like this doesn't give you any warnings and auto-deletes any remaining automatic orders when the train reaches the destination of a manual order.
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- »

I've made some changes to the server. There's a save game running now with a nice starting network, for everyone to use. One possible issue however, I've made a newgrf parameter change after gamestart: running and purchase costs of the 2CC trainset, I hope this won't cause any problems.
If you want to continue with the available company: next step is to hook up a few primary industries with supplies of the machine factory. Also for future handiness: please sort the trains into groups ;)
bokkie
Transport Coordinator
Transport Coordinator
Posts: 327
Joined: 19 Jan 2007 19:26

Re: Cargo Distribution

Post by bokkie »

I see your intermediate stops patch has been added into trunk and beta, congratulations! Maybe another small step towards the inclusion of cargodist in trunk :) maybe in 2011 ;) I applaud your perseverance in updating cargodist, IIRC most earlier attempts didn't last this long.
a.locritani
Engineer
Engineer
Posts: 111
Joined: 08 Feb 2007 11:59
Skype: a.locritani
Location: Italy

Re: Cargo Distribution

Post by a.locritani »

Hi Fonso,
i want just to signal that there's something strange with subsidies: A subsidy is still offered if a direct connection between two towns or industries does not exist but a indirect connection exists.

I can't remember if I have already notified this thing in the past, sorry...
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

a.locritani wrote:i want just to signal that there's something strange with subsidies: A subsidy is still offered if a direct connection between two towns or industries does not exist but a indirect connection exists.
Contrary to popular belief subsidies are generated based _only_ on the following factors:
  • the source must produce (more than 0 of) the cargo and the destination must accept it
  • percentage of goods transported at the source must be at most 42
  • distance between source and destination must be at most 70 tiles
Everything else is more or less random. So the same thing as a.locritani is experiencing could also happen in trunk with directly connected places if the capacity of your link is small enough to keep the percentage of goods transported below 42. The subsidy generation code doesn't check if any goods are already being transported from the source to the destination. If you get a subsidy for an already existing route you're being subsidized to increase its capacity. Of course with cargodist you'll probably have to increase other routes' capacities as well to really get the percentage up.
The guy on the picture is not me, it's Alonso.
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: Cargo Distribution

Post by Wasila »

How's the trunk inclusion thing going?
a.locritani
Engineer
Engineer
Posts: 111
Joined: 08 Feb 2007 11:59
Skype: a.locritani
Location: Italy

Re: Cargo Distribution

Post by a.locritani »

fonso wrote:
a.locritani wrote:i want just to signal that there's something strange with subsidies: A subsidy is still offered if a direct connection between two towns or industries does not exist but a indirect connection exists.
Contrary to popular belief subsidies are generated based _only_ on the following factors:
  • the source must produce (more than 0 of) the cargo and the destination must accept it
  • percentage of goods transported at the source must be at most 42
  • distance between source and destination must be at most 70 tiles
Everything else is more or less random. So the same thing as a.locritani is experiencing could also happen in trunk with directly connected places if the capacity of your link is small enough to keep the percentage of goods transported below 42. The subsidy generation code doesn't check if any goods are already being transported from the source to the destination. If you get a subsidy for an already existing route you're being subsidized to increase its capacity. Of course with cargodist you'll probably have to increase other routes' capacities as well to really get the percentage up.
Thanks for clarification about subsidies and sorry for the "wrong" bug report.
User avatar
fonso
President
President
Posts: 948
Joined: 13 Oct 2007 08:28

Re: Cargo Distribution

Post by fonso »

Wasila wrote:How's the trunk inclusion thing going?
I'm cleaning up smallmap-stats atm. The most visible change for you is that the mouse-over feature has been removed. It wasn't in tune with the general style of the game and it was very complex in terms of implementation. I hope it won't be missed too much. Otherwise I might implement something similar, but involving a click on a station in the smallmap. I'll probably remove the zoom-in feature, too, as the devs have repeatedly stated that they don't like it.
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- »

Do the devs currently like what you've made, this question more in respect to game play than actually how you've implemented the functionality. Regarding the small map zoom in, I get the argument that it adds nothing besides what we already see in normal view, however with lots of buses / small stations etc. in a town, the zoom in functionality is very useful.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: Cargo Distribution

Post by Alberth »

Arie- wrote:however with lots of buses / small stations etc. in a town, the zoom in functionality is very useful.
Did you notice by accident the large zoomed-in view just underneath the smallmap window?
WWW
President
President
Posts: 920
Joined: 28 Jan 2005 20:37

Re: Cargo Distribution

Post by WWW »

Alberth wrote:
Arie- wrote:however with lots of buses / small stations etc. in a town, the zoom in functionality is very useful.
Did you notice by accident the large zoomed-in view just underneath the smallmap window?
Also extra viewports somewhat remove the need for that.
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: Cargo Distribution

Post by Wasila »

fonso wrote:
Wasila wrote:How's the trunk inclusion thing going?
I'm cleaning up smallmap-stats atm. The most visible change for you is that the mouse-over feature has been removed. It wasn't in tune with the general style of the game and it was very complex in terms of implementation. I hope it won't be missed too much. Otherwise I might implement something similar, but involving a click on a station in the smallmap. I'll probably remove the zoom-in feature, too, as the devs have repeatedly stated that they don't like it.
Glad to hear it - good to see that you're still working on it.
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution

Post by Eddi »

WWW wrote:
Alberth wrote:
Arie- wrote:however with lots of buses / small stations etc. in a town, the zoom in functionality is very useful.
Did you notice by accident the large zoomed-in view just underneath the smallmap window?
Also extra viewports somewhat remove the need for that.
neither main nor extra viewports have the ability to draw an overlay of the connected stations and their link capacity/usage.

on that note, maybe the station window should show outgoing/incoming capacity/usage for each nexthop?
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Bing [Bot] and 11 guests