mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r23049) -Fix [FS#4810]: Use the same forest-check for the vegetation-map colour as for nearby station names.
This commit is contained in:
parent
3e5a758390
commit
3eddb9c23f
|
@ -138,6 +138,8 @@ void PlantRandomFarmField(const Industry *i);
|
|||
|
||||
void ReleaseDisastersTargetingIndustry(IndustryID);
|
||||
|
||||
bool IsTileForestIndustry(TileIndex tile);
|
||||
|
||||
#define FOR_ALL_INDUSTRIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Industry, industry_index, var, start)
|
||||
#define FOR_ALL_INDUSTRIES(var) FOR_ALL_INDUSTRIES_FROM(var, 0)
|
||||
|
||||
|
|
|
@ -911,6 +911,30 @@ static void ChangeTileOwner_Industry(TileIndex tile, Owner old_owner, Owner new_
|
|||
if (i->founder == old_owner) i->founder = (new_owner == INVALID_OWNER) ? OWNER_NONE : new_owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the tile is a forest.
|
||||
* @param tile the tile to investigate.
|
||||
* @return true if and only if the tile is a forest
|
||||
*/
|
||||
bool IsTileForestIndustry(TileIndex tile)
|
||||
{
|
||||
/* Check for industry tile */
|
||||
if (!IsTileType(tile, MP_INDUSTRY)) return false;
|
||||
|
||||
const Industry *ind = Industry::GetByTile(tile);
|
||||
|
||||
/* Check for organic industry (i.e. not processing or extractive) */
|
||||
if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_ORGANIC) == 0) return false;
|
||||
|
||||
/* Check for wood production */
|
||||
for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||
/* The industry produces wood. */
|
||||
if (ind->produced_cargo[i] != CT_INVALID && CargoSpec::Get(ind->produced_cargo[i])->label == 'WOOD') return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
|
||||
|
||||
static bool IsBadFarmFieldTile(TileIndex tile)
|
||||
|
|
|
@ -532,7 +532,7 @@ static inline uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t)
|
|||
return (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) ? MKCOLOUR_XXXX(PC_BARE_LAND) : _vegetation_clear_bits[GetClearGround(tile)];
|
||||
|
||||
case MP_INDUSTRY:
|
||||
return GetIndustrySpec(Industry::GetByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR_XXXX(PC_GREEN) : MKCOLOUR_XXXX(PC_DARK_RED);
|
||||
return IsTileForestIndustry(tile) ? MKCOLOUR_XXXX(PC_GREEN) : MKCOLOUR_XXXX(PC_DARK_RED);
|
||||
|
||||
case MP_TREES:
|
||||
if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT || GetTreeGround(tile) == TREE_GROUND_ROUGH_SNOW) {
|
||||
|
|
|
@ -180,29 +180,6 @@ static bool CMSATree(TileIndex tile)
|
|||
return IsTileType(tile, MP_TREES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the tile is a forest.
|
||||
* @param tile the tile to investigate.
|
||||
* @return true if and only if the tile is a forest
|
||||
*/
|
||||
static bool CMSAForest(TileIndex tile)
|
||||
{
|
||||
/* No industry */
|
||||
if (!IsTileType(tile, MP_INDUSTRY)) return false;
|
||||
|
||||
const Industry *ind = Industry::GetByTile(tile);
|
||||
|
||||
/* No extractive industry */
|
||||
if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_ORGANIC) == 0) return false;
|
||||
|
||||
for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||
/* The industry produces wood. */
|
||||
if (ind->produced_cargo[i] != CT_INVALID && CargoSpec::Get(ind->produced_cargo[i])->label == 'WOOD') return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#define M(x) ((x) - STR_SV_STNAME)
|
||||
|
||||
enum StationNaming {
|
||||
|
@ -322,7 +299,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n
|
|||
/* Check woods */
|
||||
if (HasBit(free_names, M(STR_SV_STNAME_WOODS)) && (
|
||||
CountMapSquareAround(tile, CMSATree) >= 8 ||
|
||||
CountMapSquareAround(tile, CMSAForest) >= 2)
|
||||
CountMapSquareAround(tile, IsTileForestIndustry) >= 2)
|
||||
) {
|
||||
return _settings_game.game_creation.landscape == LT_TROPIC ? STR_SV_STNAME_FOREST : STR_SV_STNAME_WOODS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue