(svn r20396) -Codechange: introduce a helper function to test whether an industry temporarily refues to accept some cargo

This commit is contained in:
yexo
2010-08-07 20:11:27 +00:00
parent 79dd7df9fb
commit 5162f28c27
4 changed files with 26 additions and 16 deletions

View File

@@ -2065,18 +2065,11 @@ static bool CheckIndustryCloseDownProtection(IndustryType type)
*/
static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accepts, bool *c_produces)
{
const IndustrySpec *indspec = GetIndustrySpec(ind->type);
if (cargo == CT_INVALID) return;
/* Check for acceptance of cargo */
for (byte j = 0; j < lengthof(ind->accepts_cargo); j++) {
if (ind->accepts_cargo[j] == CT_INVALID) continue;
if (cargo == ind->accepts_cargo[j]) {
if (HasBit(indspec->callback_mask, CBM_IND_REFUSE_CARGO)) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO,
0, GetReverseCargoTranslation(cargo, indspec->grf_prop.grffile),
ind, ind->type, ind->location.tile);
if (res == 0) continue;
}
if (cargo == ind->accepts_cargo[j] && !IndustryTemporarilyRefusesCargo(ind, cargo)) {
*c_accepts = true;
break;
}
@@ -2084,7 +2077,6 @@ static void CanCargoServiceIndustry(CargoID cargo, Industry *ind, bool *c_accept
/* Check for produced cargo */
for (byte j = 0; j < lengthof(ind->produced_cargo); j++) {
if (ind->produced_cargo[j] == CT_INVALID) continue;
if (cargo == ind->produced_cargo[j]) {
*c_produces = true;
break;