mirror of https://github.com/OpenTTD/OpenTTD
(svn r23457) -Codechange: introduce Industry::TileBelongsToIndustry() to simplify code checking for that
parent
e7777f44b9
commit
6aae285b72
|
@ -376,7 +376,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
|
||||||
static void DestructIndustry(Industry *i)
|
static void DestructIndustry(Industry *i)
|
||||||
{
|
{
|
||||||
for (TileIndex tile = 0; tile != MapSize(); tile++) {
|
for (TileIndex tile = 0; tile != MapSize(); tile++) {
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == i->index) {
|
if (i->TileBelongsToIndustry(tile)) {
|
||||||
ResetIndustryConstructionStage(tile);
|
ResetIndustryConstructionStage(tile);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,16 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
|
||||||
|
|
||||||
void RecomputeProductionMultipliers();
|
void RecomputeProductionMultipliers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given tile belongs to this industry.
|
||||||
|
* @param tile The tile to check.
|
||||||
|
* @return True if the tils is part of this industry.
|
||||||
|
*/
|
||||||
|
inline bool TileBelongsToIndustry(TileIndex tile) const
|
||||||
|
{
|
||||||
|
return IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == this->index;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the industry of the given tile
|
* Get the industry of the given tile
|
||||||
* @param tile the tile to get the industry from
|
* @param tile the tile to get the industry from
|
||||||
|
|
|
@ -248,7 +248,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, uint32 p
|
||||||
/* Get random tile bits at offset param */
|
/* Get random tile bits at offset param */
|
||||||
case 0x61:
|
case 0x61:
|
||||||
tile = GetNearbyTile(parameter, tile, false);
|
tile = GetNearbyTile(parameter, tile, false);
|
||||||
return (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0;
|
return industry->TileBelongsToIndustry(tile) ? GetIndustryRandomBits(tile) : 0;
|
||||||
|
|
||||||
/* Land info of nearby tiles */
|
/* Land info of nearby tiles */
|
||||||
case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY, false, object->grffile->grf_version >= 8);
|
case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY, false, object->grffile->grf_version >= 8);
|
||||||
|
@ -256,7 +256,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, uint32 p
|
||||||
/* Animation stage of nearby tiles */
|
/* Animation stage of nearby tiles */
|
||||||
case 0x63:
|
case 0x63:
|
||||||
tile = GetNearbyTile(parameter, tile, false);
|
tile = GetNearbyTile(parameter, tile, false);
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
|
if (industry->TileBelongsToIndustry(tile)) {
|
||||||
return GetAnimationFrame(tile);
|
return GetAnimationFrame(tile);
|
||||||
}
|
}
|
||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
|
|
|
@ -345,7 +345,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
uint32 random = Random();
|
uint32 random = Random();
|
||||||
TILE_AREA_LOOP(tile, ind->location) {
|
TILE_AREA_LOOP(tile, ind->location) {
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
|
if (ind->TileBelongsToIndustry(tile)) {
|
||||||
if (StartStopIndustryTileAnimation(tile, iat, random)) {
|
if (StartStopIndustryTileAnimation(tile, iat, random)) {
|
||||||
SB(random, 0, 16, Random());
|
SB(random, 0, 16, Random());
|
||||||
} else {
|
} else {
|
||||||
|
@ -429,7 +429,7 @@ void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
|
||||||
{
|
{
|
||||||
uint32 reseed_industry = 0;
|
uint32 reseed_industry = 0;
|
||||||
TILE_AREA_LOOP(tile, ind->location) {
|
TILE_AREA_LOOP(tile, ind->location) {
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
|
if (ind->TileBelongsToIndustry(tile)) {
|
||||||
DoTriggerIndustryTile(tile, trigger, ind, reseed_industry);
|
DoTriggerIndustryTile(tile, trigger, ind, reseed_industry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue