Update to 1.10.2
This commit is contained in:
@@ -204,7 +204,7 @@ Industry::~Industry()
|
||||
*/
|
||||
void Industry::PostDestructor(size_t index)
|
||||
{
|
||||
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, 0);
|
||||
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_FORCE_REBUILD);
|
||||
}
|
||||
|
||||
|
||||
@@ -1697,20 +1697,12 @@ static void PopulateStationsNearby(Industry *ind)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get our list of nearby stations. */
|
||||
FindStationsAroundTiles(ind->location, &ind->stations_near, false);
|
||||
|
||||
/* Test if industry can accept cargo */
|
||||
uint cargo_index;
|
||||
for (cargo_index = 0; cargo_index < lengthof(ind->accepts_cargo); cargo_index++) {
|
||||
if (ind->accepts_cargo[cargo_index] != CT_INVALID) break;
|
||||
}
|
||||
if (cargo_index >= lengthof(ind->accepts_cargo)) return;
|
||||
|
||||
/* Cargo is accepted, add industry to nearby stations nearby industry list. */
|
||||
for (Station *st : ind->stations_near) {
|
||||
st->industries_near.insert(ind);
|
||||
}
|
||||
ForAllStationsAroundTiles(ind->location, [ind](Station *st, TileIndex tile) {
|
||||
if (!IsTileType(tile, MP_INDUSTRY) || GetIndustryIndex(tile) != ind->index) return false;
|
||||
ind->stations_near.insert(st);
|
||||
st->AddIndustryToDeliver(ind);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1822,6 +1814,11 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
||||
break;
|
||||
}
|
||||
CargoID cargo = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
|
||||
/* Industries without "unlimited" cargo types support depend on the specific order/slots of cargo types.
|
||||
* They need to be able to blank out specific slots without aborting the callback sequence,
|
||||
* and solve this by returning undefined cargo indexes. Skip these. */
|
||||
if (cargo == CT_INVALID && !(indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED)) continue;
|
||||
/* Verify valid cargo */
|
||||
if (std::find(indspec->accepts_cargo, endof(indspec->accepts_cargo), cargo) == endof(indspec->accepts_cargo)) {
|
||||
/* Cargo not in spec, error in NewGRF */
|
||||
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_INPUT_CARGO_TYPES, res);
|
||||
@@ -1849,6 +1846,9 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
||||
break;
|
||||
}
|
||||
CargoID cargo = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
|
||||
/* Allow older GRFs to skip slots. */
|
||||
if (cargo == CT_INVALID && !(indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED)) continue;
|
||||
/* Verify valid cargo */
|
||||
if (std::find(indspec->produced_cargo, endof(indspec->produced_cargo), cargo) == endof(indspec->produced_cargo)) {
|
||||
/* Cargo not in spec, error in NewGRF */
|
||||
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_OUTPUT_CARGO_TYPES, res);
|
||||
@@ -1892,7 +1892,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
||||
if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) {
|
||||
for (uint j = 0; j != 50; j++) PlantRandomFarmField(i);
|
||||
}
|
||||
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, 0);
|
||||
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_FORCE_REBUILD);
|
||||
|
||||
if (!_generating_world) PopulateStationsNearby(i);
|
||||
}
|
||||
@@ -2311,6 +2311,21 @@ void Industry::RecomputeProductionMultipliers()
|
||||
}
|
||||
}
|
||||
|
||||
void Industry::FillCachedName() const
|
||||
{
|
||||
char buf[256];
|
||||
int64 args_array[] = { this->index };
|
||||
StringParameters tmp_params(args_array);
|
||||
char *end = GetStringWithArgs(buf, STR_INDUSTRY_NAME, &tmp_params, lastof(buf));
|
||||
this->cached_name.assign(buf, end);
|
||||
}
|
||||
|
||||
void ClearAllIndustryCachedNames()
|
||||
{
|
||||
for (Industry *ind : Industry::Iterate()) {
|
||||
ind->cached_name.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the #probability and #min_number fields for the industry type \a it for a running game.
|
||||
@@ -2821,7 +2836,7 @@ void IndustryDailyLoop()
|
||||
cur_company.Restore();
|
||||
|
||||
/* production-change */
|
||||
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, 1);
|
||||
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE);
|
||||
}
|
||||
|
||||
void IndustryMonthlyLoop()
|
||||
@@ -2843,7 +2858,7 @@ void IndustryMonthlyLoop()
|
||||
cur_company.Restore();
|
||||
|
||||
/* production-change */
|
||||
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, 1);
|
||||
InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, IDIWD_PRODUCTION_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user