Glad to see you updating
I've been playing the custom scenario I mentioned earlier, and I noticed something odd: Mineral mine production never seems to increase even at 100% transported. This scenario is known to be slightly broken, but I thought I'd look into it anyway and see if I could figure out why.
I'm sufficiently unfamiliar with NML that I may have this totally wrong, but AFAICT the code for mineral mines works as follows:
Line 1070 sets the production level randomly to a value ranging from 6 to 32 (using the switch block starting on line 519) when a mineral mine is built.
Line 1071 sets the "random_prod_change" callback to always return CB_RESULT_IND_PROD_NO_CHANGE so mineral production cannot change randomly.
Line 1068 sets the "monthly_prod_change" callback to use a switch "switch_mineral_mine_reset_wastelander_amount".
The "switch_mineral_mine_reset_wastelander_amount" switch statement starting on line 1028 sets or clears a variable depending whether the industry has wastelanders, but doesn't change the underlying production rate.
Then actual production is determined by the "mineral_mine_produce_256_ticks" which produces at either the production rate or 2x the production rate depending on the wastelanders variable set in the other switch (which it may also update), but again, doesn't seem to change the underlying production rate.
Unless I've misunderstood, the implication seems to be that a mineral mine has a randomized production level (e.g. 16 units every 256 ticks) when it's first created, and can only ever produce at either it's initial random level or 2x that level (while consuming wastelanders).
If that's true, is it a bug or a feature?
p.s. Line numbers are from 0.3.1. The scenario is using my slightly-hacked 0.3.0, but the relevant code seems to be the same in both versions.
--------
EDIT:
I added a simple monthly production change to mineral mines by creating a new switch block that does simple increment/decrement changes based on the percent of cargo transported. It ended up looking like this:
Code: Select all
switch (FEAT_INDUSTRIES, SELF, switch_primary_prod_change, transported_last_month_pct_1) {
0..25: (production_rate_1 > 6 ? CB_RESULT_IND_PROD_DECREMENT_BY_1 : CB_RESULT_IND_PROD_NO_CHANGE);
26..75: CB_RESULT_IND_PROD_NO_CHANGE;
75..100: (production_rate_1 < 255 ? CB_RESULT_IND_PROD_INCREMENT_BY_1 : CB_RESULT_IND_PROD_NO_CHANGE);
}
switch (FEAT_INDUSTRIES, SELF, switch_mineral_mine_reset_wastelander_amount, [
STORE_PERM(LOAD_PERM(0), 1),
STORE_PERM(0, 0)
]) {
//CB_RESULT_IND_PROD_NO_CHANGE;
switch_primary_prod_change;
}
It seems to work as I intended:
I have a mineral mine that's been producing either 48 or 54 units per month for the last 53 years (AFAICT it's production rate is 6 and the production interval allows it to produce 8 or 9 times per calendar month).
I applied the code change in late November, and as of February 1 it's showing production of 63 units for the month of January, which is in the area I'd expect.
In theory a call to switch_primary_prod_change could replace the current CB_RESULT_IND_PROD_NO_CHANGE in all the wastelander-accepting industries (which I think may all suffer from the same lack of increases) as long as they only produce one cargo.
I am worried that it may break things if I deliver wastelanders to a mineral mine where production_rate_1 is already over 127, as that would give it a total production rate over 255. According to
https://newgrf-specs.tt-wiki.net/wiki/N ... _variables the limit is 255, but I'm not sure if your produce block works around that (i.e. I don't know if actual production limited to 255 units per cycle or if it's just that production_rate_1 is an 8-bit unsigned int).
p.s. In case anybody wants to use it, I am releasing the code above under a Creative Commons CCZero 1.0 License (i.e. you can do whatever you like with my code, but still need to respect Andrew350's GPL license for his stuff).
EDIT2: Added an extra conditional to the switch block so it won't almost-instantly close down unserviced mines. I should probably add some sort of counter like the NML industry example, but currently I'm too lazy so it just never lowers the production rate below 6.