Stockpile limit

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

Post Reply
User avatar
3iff
Tycoon
Tycoon
Posts: 1094
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Stockpile limit

Post by 3iff »

I've recently been playing around with industry stockpiles (and having some success). I'm wondering if there's a limit to how large a stockpile can become at an industry?

Through occasional coding errors, I've seen 2.5m litres of alcohol at a hotel (firs based) so the limit must be higher than that, but how high? Also, does the game simply 'vanish' excess stock or does the game crash?

I wouldn't envisage huge stockpiles of cargos but I've been surprised how quickly it can build up. I'm presuming the stockpile limits are per cargo per industry.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: Stockpile limit

Post by Wahazar »

3iff wrote:I've recently been playing around with industry stockpiles (and having some success). I'm wondering if there's a limit to how large a stockpile can become at an industry?
AFAIK, it is 32ku or 64 ku, I observed than if it is overloaded, strange things happen (probably sign byte is changed).
In manpower industry set I had dynamically changed consumption rate, more stockpile, higher consumption (and production),
but I underestimated players which was able to push large amounts of supplies and overload stockpile.
Now most of the manpower industries have hardcoded stockpile level limit below 32000 units.
It is much higher than in case of ECS, therefore it is not really an issue in case of simple supply chain, but make pushing many sources into one drain more challenging (on the other hand, with manpower option, you have ability to control production level, therefore you can somewhat overcome stockpile saturation by decreasing source production).
To avoid problems with cargodist link graph refreshing and flickering of station messages, there is hysteresis loop (acceptance cut off level is higher than acceptance restore level).

PS. 2.5 Ml equal 2500 units.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Stockpile limit

Post by planetmaker »

3iff wrote:I've recently been playing around with industry stockpiles (and having some success). I'm wondering if there's a limit to how large a stockpile can become at an industry?
The limit is word size, thus 0xFFFF or ~65k. The internal volume unit is m^3 instead of the usual display unit litres, thus the limit for those is 65.535.000 litres :)
User avatar
3iff
Tycoon
Tycoon
Posts: 1094
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Stockpile limit

Post by 3iff »

Thanks both.

What happens if that's exceeded, strange things?

How can I set stockpile limits (just point me in the right direction?). My industry set is fairly low production so I doubt I would get such quantities...but you never know.

(I use litres because it's more convenient than the imperial choice, but everything else is imperial...it's mad! :lol: )
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Stockpile limit

Post by planetmaker »

3iff wrote:Thanks both.

What happens if that's exceeded, strange things?

How can I set stockpile limits (just point me in the right direction?). My industry set is fairly low production so I doubt I would get such quantities...but you never know.
The math is found in DeliverGoodsToIndustry in economy.cpp:1035

The stockpile is internally capped to the limit. The industry will accept exactly up to the limit, and then the 2nd nearest industry is delivered and so forth. The rest of the not accepted cargo is IIRC discarded if any cargo at all was accepted (but that would need checking).

In NewGRFs you set a lower stockpile limit by checking for the current stockpile and denying cargo acceptance when the stockpile exceeds the amount you define as 'your' stockpile limit:
You check in callback 'stop_accept_cargo' for waiting_cargo_1/2/3. Make sure to synchronize that with the callback 'cargo_amount_accept' for the corresponding industry tiles: http://newgrf-specs.tt-wiki.net/wiki/NML:Industries
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: Stockpile limit

Post by Wahazar »

3iff wrote: What happens if that's exceeded, strange things?
I had production level depending on stockpile amount, and observed low values of production level when stockpile reach its limit
(looks like stockpile was treated like negative number, but I didn't analysed it deeply).
3iff wrote: How can I set stockpile limits (just point me in the right direction?).
If you are using nml, you can refer for example here:
http://dev.openttdcoop.org/projects/man ... wmill.pnml
here are two switches, mentioned by planetmaker, for tile itself and for whole industry.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Stockpile limit

Post by Eddi »

planetmaker wrote:The rest of the not accepted cargo is IIRC discarded if any cargo at all was accepted (but that would need checking).
that must have been a change in behaviour. back when i was using PBI, the remaining cargo was dumped at the station, where it could be loaded back into the vehicle.
User avatar
3iff
Tycoon
Tycoon
Posts: 1094
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Stockpile limit

Post by 3iff »

Thanks everyone. I use NML. I'm slowly getting to grips with it.

Is the other one NFO? It scared the hell out of me!
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: Stockpile limit

Post by Wahazar »

Eddi wrote:that must have been a change in behaviour. back when i was using PBI, the remaining cargo was dumped at the station, where it could be loaded back into the vehicle.
It works if there is acceptance limit switch implemented, we are discussing case without stockpile limit coded into newgrf.

BTW, I just realised, that I reinvented the wheel - UK Renewal Industry Set had very similar functionality of steel mill like manpower has.
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
User avatar
3iff
Tycoon
Tycoon
Posts: 1094
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Stockpile limit

Post by 3iff »

Well the stockpile system is working well. I'm surprising myself!

I now have a problem where I want to put some extra text into the industry window. I already have a brief description in the lang file...

STR_EXTRA_SAWMILL :{BLACK}Cuts 32t of wood into lumber.
that's called via "extra_text_industry: sawmill_extra_text;"
Essentially it's just using normal FIRS code. This works fine but I want to add a calculation that says:

Production status: 5
turns with current stockpile.

Now, it seems I can have one or the other but not both at the same time. I'm hoping it's possible but I can't work out how to do it.

Also, unless I use a newline character, I get "Production status: 5turns with current stockpile." which is annoying. Is there a way to add a physical space?
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Stockpile limit

Post by Eddi »

there are two ways to combine two strings into one callback, both involve a string like this

Code: Select all

STR_CONCAT  :{STRING}{STRING}
or alternatively with a newline

Code: Select all

STR_CONCAT  :{STRING}{}{STRING}
one works statically (i.e. NML combines the string, and the game can use the combined string as one entity)

Code: Select all

return string(STR_CONCAT, string(String1), string(String2))
and the other one works dynamically (i.e. the game combines the strings, which NML kept separately)

Code: Select all

switch(blah, STORE_TEMP(string(String1) | string(String2) << 16, 0x100)) {
  return string(STR_CONCAT);
}
i don't understand your space problem. just add a space?
User avatar
3iff
Tycoon
Tycoon
Posts: 1094
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Stockpile limit

Post by 3iff »

I'd halfway found the answer via the NMLwiki, using a different method than you suggest...but yours seems a bit easier. I'll see if I can sort it out this afternoon.

The lang code is as follows.

Production Status: {WHITE}{COMMA}{BLACK} turns with current stockpile.

There's a space before 'turns' but it seems to be whitespaced out. I hope it's not as simple as adding a second space?

HEY, it does need an extra space... :oops:

Eddi, thanks for that info, seems to work fine. The number isn't working again but that's my fault. I'll pop up a screenshot once I have something functional.

As promised, a screenshot; a work in progress, still lots to adjust.
Unnamed, 26th Feb 2006.png
Unnamed, 26th Feb 2006.png (92.57 KiB) Viewed 1526 times
User avatar
3iff
Tycoon
Tycoon
Posts: 1094
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: Stockpile limit

Post by 3iff »

Well, I can confirm there is a stockpile limit, of 65535 tonnes of iron ore (for example) and any extra ore delivered just vanishes, so that's perfect...as I don't have to worry about it.

In normal gameplay I wouldn't be concerned that I would ever get stocks that high but I was testing using AI companies and they just delivered stuff everywhere.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 32 guests