mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-24 20:12:42 +00:00
Codechange: make TropicZone a scoped enum (#15442)
This commit is contained in:
+14
-14
@@ -148,8 +148,8 @@ static TreeType GetRandomTreeType(TileIndex tile, uint seed)
|
||||
|
||||
case LandscapeType::Tropic:
|
||||
switch (GetTropicZone(tile)) {
|
||||
case TROPICZONE_NORMAL: return static_cast<TreeType>(seed * TREE_COUNT_SUB_TROPICAL / 256 + TREE_SUB_TROPICAL);
|
||||
case TROPICZONE_DESERT: return static_cast<TreeType>((seed > 12) ? TREE_INVALID : TREE_CACTUS);
|
||||
case TropicZone::Normal: return static_cast<TreeType>(seed * TREE_COUNT_SUB_TROPICAL / 256 + TREE_SUB_TROPICAL);
|
||||
case TropicZone::Desert: return static_cast<TreeType>((seed > 12) ? TREE_INVALID : TREE_CACTUS);
|
||||
default: return static_cast<TreeType>(seed * TREE_COUNT_RAINFOREST / 256 + TREE_RAINFOREST);
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ void PlaceTreesRandomly()
|
||||
|
||||
IncreaseGeneratingWorldProgress(GWP_TREE);
|
||||
|
||||
if (GetTropicZone(tile) == TROPICZONE_RAINFOREST && CanPlantTreesOnTile(tile, false)) {
|
||||
if (GetTropicZone(tile) == TropicZone::Rainforest && CanPlantTreesOnTile(tile, false)) {
|
||||
PlaceTree(tile, r);
|
||||
}
|
||||
} while (--i);
|
||||
@@ -463,7 +463,7 @@ uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, ui
|
||||
|
||||
if (set_zone && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) {
|
||||
for (TileIndex t : TileArea(tile).Expand(radius)) {
|
||||
if (GetTileType(t) != TileType::Void && DistanceSquare(tile, t) < radius * radius) SetTropicZone(t, TROPICZONE_RAINFOREST);
|
||||
if (GetTileType(t) != TileType::Void && DistanceSquare(tile, t) < radius * radius) SetTropicZone(t, TropicZone::Rainforest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,11 +566,11 @@ CommandCost CmdPlantTree(DoCommandFlags flags, TileIndex tile, TileIndex start_t
|
||||
/* Be a bit picky about which trees go where. */
|
||||
if (_settings_game.game_creation.landscape == LandscapeType::Tropic && treetype != TREE_INVALID && (
|
||||
/* No cacti outside the desert */
|
||||
(treetype == TREE_CACTUS && GetTropicZone(current_tile) != TROPICZONE_DESERT) ||
|
||||
(treetype == TREE_CACTUS && GetTropicZone(current_tile) != TropicZone::Desert) ||
|
||||
/* No rainforest trees outside the rainforest, except in the editor mode where it makes those tiles rainforest tile */
|
||||
(IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS) && GetTropicZone(current_tile) != TROPICZONE_RAINFOREST && _game_mode != GM_EDITOR) ||
|
||||
(IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS) && GetTropicZone(current_tile) != TropicZone::Rainforest && _game_mode != GM_EDITOR) ||
|
||||
/* And no subtropical trees in the desert/rainforest */
|
||||
(IsInsideMM(treetype, TREE_SUB_TROPICAL, TREE_TOYLAND) && GetTropicZone(current_tile) != TROPICZONE_NORMAL))) {
|
||||
(IsInsideMM(treetype, TREE_SUB_TROPICAL, TREE_TOYLAND) && GetTropicZone(current_tile) != TropicZone::Normal))) {
|
||||
msg = STR_ERROR_TREE_WRONG_TERRAIN_FOR_TREE_TYPE;
|
||||
continue;
|
||||
}
|
||||
@@ -614,7 +614,7 @@ CommandCost CmdPlantTree(DoCommandFlags flags, TileIndex tile, TileIndex start_t
|
||||
|
||||
/* When planting rainforest-trees, set tropiczone to rainforest in editor. */
|
||||
if (_game_mode == GM_EDITOR && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) {
|
||||
SetTropicZone(current_tile, TROPICZONE_RAINFOREST);
|
||||
SetTropicZone(current_tile, TropicZone::Rainforest);
|
||||
}
|
||||
}
|
||||
cost.AddCost(_price[Price::BuildTrees]);
|
||||
@@ -755,14 +755,14 @@ static void GetTileDesc_Trees(TileIndex tile, TileDesc &td)
|
||||
static void TileLoopTreesDesert(TileIndex tile)
|
||||
{
|
||||
switch (GetTropicZone(tile)) {
|
||||
case TROPICZONE_DESERT:
|
||||
case TropicZone::Desert:
|
||||
if (GetTreeGround(tile) != TreeGround::SnowOrDesert) {
|
||||
SetTreeGroundDensity(tile, TreeGround::SnowOrDesert, 3);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
|
||||
case TROPICZONE_RAINFOREST: {
|
||||
case TropicZone::Rainforest: {
|
||||
static const SoundFx forest_sounds[] = {
|
||||
SND_42_RAINFOREST_1,
|
||||
SND_43_RAINFOREST_2,
|
||||
@@ -821,10 +821,10 @@ static bool TreesOnTileCanSpread(TileIndex tile)
|
||||
/* Desert and rainforest trees need special handling. */
|
||||
if (_settings_game.game_creation.landscape == LandscapeType::Tropic) {
|
||||
switch (GetTropicZone(tile)) {
|
||||
case TROPICZONE_DESERT:
|
||||
case TropicZone::Desert:
|
||||
/* Cacti never spread. */
|
||||
return false;
|
||||
case TROPICZONE_RAINFOREST:
|
||||
case TropicZone::Rainforest:
|
||||
return (_settings_game.construction.extra_tree_placement == ETP_SPREAD_ALL || _settings_game.construction.extra_tree_placement == ETP_SPREAD_RAINFOREST);
|
||||
default:
|
||||
return _settings_game.construction.extra_tree_placement == ETP_SPREAD_ALL;
|
||||
@@ -873,7 +873,7 @@ static void TileLoop_Trees(TileIndex tile)
|
||||
case TreeGrowthStage::Grown: // regular sized tree
|
||||
if (_settings_game.game_creation.landscape == LandscapeType::Tropic &&
|
||||
GetTreeType(tile) != TREE_CACTUS &&
|
||||
GetTropicZone(tile) == TROPICZONE_DESERT) {
|
||||
GetTropicZone(tile) == TropicZone::Desert) {
|
||||
AddTreeGrowth(tile, 1);
|
||||
} else {
|
||||
switch (GB(Random(), 0, 3)) {
|
||||
@@ -979,7 +979,7 @@ static void PlantRandomTree(bool rainforest)
|
||||
uint32_t r = Random();
|
||||
TileIndex tile = RandomTileSeed(r);
|
||||
|
||||
if (rainforest && GetTropicZone(tile) != TROPICZONE_RAINFOREST) return;
|
||||
if (rainforest && GetTropicZone(tile) != TropicZone::Rainforest) return;
|
||||
if (!CanPlantTreesOnTile(tile, false)) return;
|
||||
|
||||
TreeType tree = GetRandomTreeType(tile, GB(r, 24, 8));
|
||||
|
||||
Reference in New Issue
Block a user