mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-10-31 15:20:10 +00:00
(svn r23457) -Codechange: introduce Industry::TileBelongsToIndustry() to simplify code checking for that
This commit is contained in:
parent
e7777f44b9
commit
6aae285b72
@ -376,7 +376,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
|
||||
static void DestructIndustry(Industry *i)
|
||||
{
|
||||
for (TileIndex tile = 0; tile != MapSize(); tile++) {
|
||||
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == i->index) {
|
||||
if (i->TileBelongsToIndustry(tile)) {
|
||||
ResetIndustryConstructionStage(tile);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
@ -77,6 +77,16 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
|
||||
|
||||
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
|
||||
* @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 */
|
||||
case 0x61:
|
||||
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 */
|
||||
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 */
|
||||
case 0x63:
|
||||
tile = GetNearbyTile(parameter, tile, false);
|
||||
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
|
||||
if (industry->TileBelongsToIndustry(tile)) {
|
||||
return GetAnimationFrame(tile);
|
||||
}
|
||||
return 0xFFFFFFFF;
|
||||
|
@ -345,7 +345,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge
|
||||
bool ret = true;
|
||||
uint32 random = Random();
|
||||
TILE_AREA_LOOP(tile, ind->location) {
|
||||
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) {
|
||||
if (ind->TileBelongsToIndustry(tile)) {
|
||||
if (StartStopIndustryTileAnimation(tile, iat, random)) {
|
||||
SB(random, 0, 16, Random());
|
||||
} else {
|
||||
@ -429,7 +429,7 @@ void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger)
|
||||
{
|
||||
uint32 reseed_industry = 0;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user