I would like to bring in my side of the situation.
The var 93 (OTTD = industry->prod_level, TTDP = industry.prodmultiplier) is used for controlling the production of the industry.
It is been re-evaluated once every month. During the evaluation, callbacks are been fired and results will affect var 93.
In OTTD and in TTDP, from what we have seen code wise, if ever the var 93 reaches 4, at the end of the evaluation procedure, the system will lower the var 93 to 0 and leaves. This means that during the evaluation of the next month, the system will effectively close that industry. So it basically gives a full month for the industry to close.
Code: Select all
TTDPatch:
.decrease:
.decloop:
cmp byte [esi+industry.prodmultiplier],4
je .closedown
shr byte [esi+industry.prodmultiplier],1
add byte [esi+industry.prodrates],1
sbb byte [esi+industry.prodrates],0
shr byte [esi+industry.prodrates],1
add byte [esi+industry.prodrates+1],1
sbb byte [esi+industry.prodrates+1],0
shr byte [esi+industry.prodrates+1],1
loop .decrease
OpenTTD:
/* Decrease if needed */
while (div-- != 0 && !closeit) {
if (i->prod_level == 4) {
closeit = true;
} else {
i->prod_level >>= 1;
i->production_rate[0] = (i->production_rate[0] + 1) >> 1;
i->production_rate[1] = (i->production_rate[1] + 1) >> 1;
if (str == STR_NULL) str = indspec->production_down_text;
}
}
I post in here the code OTTD uses for this purpose:
Code: Select all
void IndustryMonthlyLoop()
{
Industry *i;
PlayerID old_player = _current_player;
_current_player = OWNER_NONE;
FOR_ALL_INDUSTRIES(i) {
UpdateIndustryStatistics(i); <----- does not affect prod_level/ var 93
if (i->prod_level == 0) { <----- has it been declared for closure?
delete i; <----- yes, close it now
} else { <----- no, let';s evaluate it
ChangeIndustryProduction(i, true); <------ evaluation been performed in here. [0]
}
}
...
[0] So, if prod_level == 4, it will be shifted to 0 right away, in orderto be able to be closed in next month loop.
The ChangeIndustryproduction function holds this code, near the end of it, that actually does the above mentionned behaviour
Code: Select all
/* Close if needed and allowed */
if (closeit && !CheckIndustryCloseDownProtection(i->type)) {
i->prod_level = 0;
str = indspec->closure_text;
}
Unless otherwise proven, we are convinced TTDP does exactly the same process.
So, all in all, it means that if ever var 93 reaches 4, the industry will be closed next month.