Update to 1.10.0-beta1
This commit is contained in:
@@ -377,7 +377,7 @@ bool FindSubsidyIndustryCargoRoute()
|
||||
|
||||
/* Select a random industry. */
|
||||
const Industry *src_ind = Industry::GetRandom();
|
||||
if (src_ind == NULL) return false;
|
||||
if (src_ind == nullptr) return false;
|
||||
|
||||
uint trans, total;
|
||||
|
||||
@@ -442,7 +442,7 @@ bool FindSubsidyCargoDestination(CargoID cid, SourceType src_type, SourceID src)
|
||||
case ST_INDUSTRY: {
|
||||
/* Select a random industry. */
|
||||
const Industry *dst_ind = Industry::GetRandom();
|
||||
if (dst_ind == NULL) return false;
|
||||
if (dst_ind == nullptr) return false;
|
||||
|
||||
/* The industry must accept the cargo */
|
||||
bool valid = std::find(dst_ind->accepts_cargo, endof(dst_ind->accepts_cargo), cid) != endof(dst_ind->accepts_cargo);
|
||||
@@ -565,7 +565,7 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type,
|
||||
|
||||
/* Remember all towns near this station (at least one house in its catchment radius)
|
||||
* which are destination of subsidised path. Do that only if needed */
|
||||
SmallVector<const Town *, 2> towns_near;
|
||||
std::vector<const Town *> towns_near;
|
||||
if (!st->rect.IsEmpty()) {
|
||||
Subsidy *s;
|
||||
FOR_ALL_SUBSIDIES(s) {
|
||||
@@ -574,15 +574,11 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type,
|
||||
if (s->cargo_type != cargo_type || s->src_type != src_type || s->src != src) continue;
|
||||
if (s->IsAwarded() && s->awarded != company) continue;
|
||||
|
||||
Rect rect = st->GetCatchmentRect();
|
||||
|
||||
for (int y = rect.top; y <= rect.bottom; y++) {
|
||||
for (int x = rect.left; x <= rect.right; x++) {
|
||||
TileIndex tile = TileXY(x, y);
|
||||
if (!IsTileType(tile, MP_HOUSE)) continue;
|
||||
const Town *t = Town::GetByTile(tile);
|
||||
if (t->cache.part_of_subsidy & POS_DST) towns_near.Include(t);
|
||||
}
|
||||
BitmapTileIterator it(st->catchment_tiles);
|
||||
for (TileIndex tile = it; tile != INVALID_TILE; tile = ++it) {
|
||||
if (!IsTileType(tile, MP_HOUSE)) continue;
|
||||
const Town *t = Town::GetByTile(tile);
|
||||
if (t->cache.part_of_subsidy & POS_DST) include(towns_near, t);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -597,18 +593,18 @@ bool CheckSubsidised(CargoID cargo_type, CompanyID company, SourceType src_type,
|
||||
if (s->cargo_type == cargo_type && s->src_type == src_type && s->src == src && (!s->IsAwarded() || s->awarded == company)) {
|
||||
switch (s->dst_type) {
|
||||
case ST_INDUSTRY:
|
||||
for (const Industry * const *ip = st->industries_near.Begin(); ip != st->industries_near.End(); ip++) {
|
||||
if (s->dst == (*ip)->index) {
|
||||
assert((*ip)->part_of_subsidy & POS_DST);
|
||||
for (Industry *ind : st->industries_near) {
|
||||
if (s->dst == ind->index) {
|
||||
assert(ind->part_of_subsidy & POS_DST);
|
||||
subsidised = true;
|
||||
if (!s->IsAwarded()) s->AwardTo(company);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ST_TOWN:
|
||||
for (const Town * const *tp = towns_near.Begin(); tp != towns_near.End(); tp++) {
|
||||
if (s->dst == (*tp)->index) {
|
||||
assert((*tp)->cache.part_of_subsidy & POS_DST);
|
||||
for (const Town *tp : towns_near) {
|
||||
if (s->dst == tp->index) {
|
||||
assert(tp->cache.part_of_subsidy & POS_DST);
|
||||
subsidised = true;
|
||||
if (!s->IsAwarded()) s->AwardTo(company);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user