mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-21 01:59:44 +00:00
Codechange: use enum class for ClearGround
This commit is contained in:
committed by
Peter Nelson
parent
17cab9b29d
commit
5c2a37d03e
+24
-24
@@ -38,11 +38,11 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlags flags)
|
||||
ClearGround ground = GetClearGround(tile);
|
||||
uint8_t density = GetClearDensity(tile);
|
||||
if (IsSnowTile(tile)) {
|
||||
price.AddCost(_price[clear_price_table[ground]]);
|
||||
price.AddCost(_price[clear_price_table[to_underlying(ground)]]);
|
||||
/* Add a little more for removing snow. */
|
||||
price.AddCost(std::abs(_price[Price::ClearRough] - _price[Price::ClearGrass]));
|
||||
} else if (ground != CLEAR_GRASS || density != 0) {
|
||||
price.AddCost(_price[clear_price_table[ground]]);
|
||||
} else if (ground != ClearGround::Grass || density != 0) {
|
||||
price.AddCost(_price[clear_price_table[to_underlying(ground)]]);
|
||||
}
|
||||
|
||||
if (flags.Test(DoCommandFlag::Execute)) DoClearSquare(tile);
|
||||
@@ -118,7 +118,7 @@ static void DrawTile_Clear(TileInfo *ti)
|
||||
if (IsSnowTile(ti->tile)) {
|
||||
uint8_t density = GetClearDensity(ti->tile);
|
||||
DrawGroundSprite(_clear_land_sprites_snow_desert[density] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
||||
if (GetClearGround(ti->tile) == CLEAR_ROCKS) {
|
||||
if (GetClearGround(ti->tile) == ClearGround::Rocks) {
|
||||
/* There 4 levels of snowy overlay rocks, each with 19 sprites. */
|
||||
++density;
|
||||
DrawGroundSprite(SPR_OVERLAY_ROCKS_BASE + (density * 19) + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
||||
@@ -129,15 +129,15 @@ static void DrawTile_Clear(TileInfo *ti)
|
||||
}
|
||||
|
||||
switch (GetClearGround(ti->tile)) {
|
||||
case CLEAR_GRASS:
|
||||
case ClearGround::Grass:
|
||||
DrawClearLandTile(ti, GetClearDensity(ti->tile));
|
||||
break;
|
||||
|
||||
case CLEAR_ROUGH:
|
||||
case ClearGround::Rough:
|
||||
DrawHillyLandTile(ti);
|
||||
break;
|
||||
|
||||
case CLEAR_ROCKS:
|
||||
case ClearGround::Rocks:
|
||||
if (GetTropicZone(ti->tile) == TROPICZONE_DESERT) {
|
||||
DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
||||
DrawGroundSprite(SPR_OVERLAY_ROCKS_BASE + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
||||
@@ -146,12 +146,12 @@ static void DrawTile_Clear(TileInfo *ti)
|
||||
}
|
||||
break;
|
||||
|
||||
case CLEAR_FIELDS:
|
||||
case ClearGround::Fields:
|
||||
DrawGroundSprite(_clear_land_sprites_farmland[GetFieldType(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
||||
DrawClearLandFence(ti);
|
||||
break;
|
||||
|
||||
case CLEAR_DESERT:
|
||||
case ClearGround::Desert:
|
||||
DrawGroundSprite(_clear_land_sprites_snow_desert[GetClearDensity(ti->tile)] + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
|
||||
break;
|
||||
}
|
||||
@@ -173,13 +173,13 @@ static Foundation GetFoundation_Clear(TileIndex, Slope)
|
||||
|
||||
static void UpdateFences(TileIndex tile)
|
||||
{
|
||||
assert(IsTileType(tile, TileType::Clear) && IsClearGround(tile, CLEAR_FIELDS));
|
||||
assert(IsTileType(tile, TileType::Clear) && IsClearGround(tile, ClearGround::Fields));
|
||||
bool dirty = false;
|
||||
|
||||
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
|
||||
if (GetFence(tile, dir) != 0) continue;
|
||||
TileIndex neighbour = tile + TileOffsByDiagDir(dir);
|
||||
if (IsTileType(neighbour, TileType::Clear) && IsClearGround(neighbour, CLEAR_FIELDS)) continue;
|
||||
if (IsTileType(neighbour, TileType::Clear) && IsClearGround(neighbour, ClearGround::Fields)) continue;
|
||||
SetFence(tile, dir, 3);
|
||||
dirty = true;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ static void TileLoopClearDesert(TileIndex tile)
|
||||
|
||||
/* Current desert level - 0 if it is not desert */
|
||||
uint current = 0;
|
||||
if (ground == CLEAR_DESERT || ground == CLEAR_ROCKS) current = GetClearDensity(tile);
|
||||
if (ground == ClearGround::Desert || ground == ClearGround::Rocks) current = GetClearDensity(tile);
|
||||
|
||||
/* Expected desert level - 0 if it shouldn't be desert */
|
||||
uint expected = 0;
|
||||
@@ -251,13 +251,13 @@ static void TileLoopClearDesert(TileIndex tile)
|
||||
|
||||
if (current == expected) return;
|
||||
|
||||
if (ground == CLEAR_ROCKS) {
|
||||
SetClearGroundDensity(tile, CLEAR_ROCKS, expected);
|
||||
if (ground == ClearGround::Rocks) {
|
||||
SetClearGroundDensity(tile, ClearGround::Rocks, expected);
|
||||
} else if (expected == 0) {
|
||||
SetClearGroundDensity(tile, CLEAR_GRASS, 3);
|
||||
SetClearGroundDensity(tile, ClearGround::Grass, 3);
|
||||
} else {
|
||||
/* Transition from clear to desert is not smooth (after clearing desert tile) */
|
||||
SetClearGroundDensity(tile, CLEAR_DESERT, expected);
|
||||
SetClearGroundDensity(tile, ClearGround::Desert, expected);
|
||||
}
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
@@ -276,7 +276,7 @@ static void TileLoop_Clear(TileIndex tile)
|
||||
if (IsSnowTile(tile)) return;
|
||||
|
||||
switch (GetClearGround(tile)) {
|
||||
case CLEAR_GRASS:
|
||||
case ClearGround::Grass:
|
||||
if (GetClearDensity(tile) == 3) return;
|
||||
|
||||
if (_game_mode != GM_EDITOR) {
|
||||
@@ -288,11 +288,11 @@ static void TileLoop_Clear(TileIndex tile)
|
||||
AddClearDensity(tile, 1);
|
||||
}
|
||||
} else {
|
||||
SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3);
|
||||
SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? ClearGround::Grass : ClearGround::Rough, 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case CLEAR_FIELDS:
|
||||
case ClearGround::Fields:
|
||||
UpdateFences(tile);
|
||||
|
||||
if (_game_mode == GM_EDITOR) return;
|
||||
@@ -306,7 +306,7 @@ static void TileLoop_Clear(TileIndex tile)
|
||||
|
||||
if (GetIndustryIndexOfField(tile) == IndustryID::Invalid() && GetFieldType(tile) >= 7) {
|
||||
/* This farmfield is no longer farmfield, so make it grass again */
|
||||
MakeClear(tile, CLEAR_GRASS, 2);
|
||||
MakeClear(tile, ClearGround::Grass, 2);
|
||||
} else {
|
||||
uint field_type = GetFieldType(tile);
|
||||
field_type = (field_type < 8) ? field_type + 1 : 0;
|
||||
@@ -334,7 +334,7 @@ void GenerateClearTile()
|
||||
do {
|
||||
IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY);
|
||||
tile = RandomTile();
|
||||
if (IsTileType(tile, TileType::Clear) && !IsClearGround(tile, CLEAR_DESERT)) SetClearGroundDensity(tile, CLEAR_ROUGH, 3);
|
||||
if (IsTileType(tile, TileType::Clear) && !IsClearGround(tile, ClearGround::Desert)) SetClearGroundDensity(tile, ClearGround::Rough, 3);
|
||||
} while (--i);
|
||||
|
||||
/* add rocky tiles */
|
||||
@@ -349,7 +349,7 @@ void GenerateClearTile()
|
||||
for (;;) {
|
||||
TileIndex tile_new;
|
||||
|
||||
SetClearGroundDensity(tile, CLEAR_ROCKS, 3);
|
||||
SetClearGroundDensity(tile, ClearGround::Rocks, 3);
|
||||
MarkTileDirtyByTile(tile);
|
||||
do {
|
||||
if (--j == 0) goto get_out;
|
||||
@@ -379,10 +379,10 @@ static void GetTileDesc_Clear(TileIndex tile, TileDesc &td)
|
||||
{STR_LAI_CLEAR_DESCRIPTION_DESERT, STR_EMPTY},
|
||||
};
|
||||
|
||||
if (!IsSnowTile(tile) && IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) {
|
||||
if (!IsSnowTile(tile) && IsClearGround(tile, ClearGround::Grass) && GetClearDensity(tile) == 0) {
|
||||
td.str = STR_LAI_CLEAR_DESCRIPTION_BARE_LAND;
|
||||
} else {
|
||||
const auto &[name, snowy_name] = clear_land_str[GetClearGround(tile)];
|
||||
const auto &[name, snowy_name] = clear_land_str[to_underlying(GetClearGround(tile))];
|
||||
td.str = IsSnowTile(tile) ? snowy_name : name;
|
||||
}
|
||||
td.owner[0] = GetTileOwner(tile);
|
||||
|
||||
+22
-22
@@ -16,12 +16,12 @@
|
||||
/**
|
||||
* Ground types. Valid densities in comments after the enum.
|
||||
*/
|
||||
enum ClearGround : uint8_t {
|
||||
CLEAR_GRASS = 0, ///< 0-3
|
||||
CLEAR_ROUGH = 1, ///< 3
|
||||
CLEAR_ROCKS = 2, ///< 3
|
||||
CLEAR_FIELDS = 3, ///< 3
|
||||
CLEAR_DESERT = 5, ///< 1,3
|
||||
enum class ClearGround : uint8_t {
|
||||
Grass = 0, ///< Plain grass with dirt transition (0-3)
|
||||
Rough = 1, ///< Rough mounds (3)
|
||||
Rocks = 2, ///< Rocks with snow transition (0-3)
|
||||
Fields = 3, ///< Farm fields (3)
|
||||
Desert = 5, ///< Desert with transition (1,3)
|
||||
};
|
||||
|
||||
|
||||
@@ -145,19 +145,19 @@ inline void SetClearCounter(Tile t, uint c)
|
||||
inline void SetClearGroundDensity(Tile t, ClearGround type, uint density)
|
||||
{
|
||||
assert(IsTileType(t, TileType::Clear)); // XXX incomplete
|
||||
t.m5() = 0 << 5 | type << 2 | density;
|
||||
t.m5() = 0 << 5 | to_underlying(type) << 2 | density;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the field type (production stage) of the field
|
||||
* @param t the field to get the type of
|
||||
* @pre GetClearGround(t) == CLEAR_FIELDS
|
||||
* @pre GetClearGround(t) == ClearGround::Fields
|
||||
* @return the field type
|
||||
*/
|
||||
inline uint GetFieldType(Tile t)
|
||||
{
|
||||
assert(GetClearGround(t) == CLEAR_FIELDS);
|
||||
assert(GetClearGround(t) == ClearGround::Fields);
|
||||
return GB(t.m3(), 0, 4);
|
||||
}
|
||||
|
||||
@@ -165,23 +165,23 @@ inline uint GetFieldType(Tile t)
|
||||
* Set the field type (production stage) of the field
|
||||
* @param t the field to get the type of
|
||||
* @param f the field type
|
||||
* @pre GetClearGround(t) == CLEAR_FIELDS
|
||||
* @pre GetClearGround(t) == ClearGround::Fields
|
||||
*/
|
||||
inline void SetFieldType(Tile t, uint f)
|
||||
{
|
||||
assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete
|
||||
assert(GetClearGround(t) == ClearGround::Fields); // XXX incomplete
|
||||
SB(t.m3(), 0, 4, f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the industry (farm) that made the field
|
||||
* @param t the field to get creating industry of
|
||||
* @pre GetClearGround(t) == CLEAR_FIELDS
|
||||
* @pre GetClearGround(t) == ClearGround::Fields
|
||||
* @return the industry that made the field
|
||||
*/
|
||||
inline IndustryID GetIndustryIndexOfField(Tile t)
|
||||
{
|
||||
assert(GetClearGround(t) == CLEAR_FIELDS);
|
||||
assert(GetClearGround(t) == ClearGround::Fields);
|
||||
return(IndustryID) t.m2();
|
||||
}
|
||||
|
||||
@@ -189,11 +189,11 @@ inline IndustryID GetIndustryIndexOfField(Tile t)
|
||||
* Set the industry (farm) that made the field
|
||||
* @param t the field to get creating industry of
|
||||
* @param i the industry that made the field
|
||||
* @pre GetClearGround(t) == CLEAR_FIELDS
|
||||
* @pre GetClearGround(t) == ClearGround::Fields
|
||||
*/
|
||||
inline void SetIndustryIndexOfField(Tile t, IndustryID i)
|
||||
{
|
||||
assert(GetClearGround(t) == CLEAR_FIELDS);
|
||||
assert(GetClearGround(t) == ClearGround::Fields);
|
||||
t.m2() = i.base();
|
||||
}
|
||||
|
||||
@@ -202,12 +202,12 @@ inline void SetIndustryIndexOfField(Tile t, IndustryID i)
|
||||
* Is there a fence at the given border?
|
||||
* @param t the tile to check for fences
|
||||
* @param side the border to check
|
||||
* @pre IsClearGround(t, CLEAR_FIELDS)
|
||||
* @pre IsClearGround(t, ClearGround::Fields)
|
||||
* @return 0 if there is no fence, otherwise the fence type
|
||||
*/
|
||||
inline uint GetFence(Tile t, DiagDirection side)
|
||||
{
|
||||
assert(IsClearGround(t, CLEAR_FIELDS));
|
||||
assert(IsClearGround(t, ClearGround::Fields));
|
||||
switch (side) {
|
||||
default: NOT_REACHED();
|
||||
case DIAGDIR_SE: return GB(t.m4(), 2, 3);
|
||||
@@ -222,11 +222,11 @@ inline uint GetFence(Tile t, DiagDirection side)
|
||||
* @param t the tile to check for fences
|
||||
* @param side the border to check
|
||||
* @param h 0 if there is no fence, otherwise the fence type
|
||||
* @pre IsClearGround(t, CLEAR_FIELDS)
|
||||
* @pre IsClearGround(t, ClearGround::Fields)
|
||||
*/
|
||||
inline void SetFence(Tile t, DiagDirection side, uint h)
|
||||
{
|
||||
assert(IsClearGround(t, CLEAR_FIELDS));
|
||||
assert(IsClearGround(t, ClearGround::Fields));
|
||||
switch (side) {
|
||||
default: NOT_REACHED();
|
||||
case DIAGDIR_SE: SB(t.m4(), 2, 3, h); break;
|
||||
@@ -272,7 +272,7 @@ inline void MakeField(Tile t, uint field_type, IndustryID industry)
|
||||
t.m2() = industry.base();
|
||||
t.m3() = field_type;
|
||||
t.m4() = 0 << 5 | 0 << 2;
|
||||
SetClearGroundDensity(t, CLEAR_FIELDS, 3);
|
||||
SetClearGroundDensity(t, ClearGround::Fields, 3);
|
||||
SB(t.m6(), 2, 6, 0);
|
||||
t.m7() = 0;
|
||||
t.m8() = 0;
|
||||
@@ -288,8 +288,8 @@ inline void MakeSnow(Tile t, uint density = 0)
|
||||
{
|
||||
assert(!IsSnowTile(t));
|
||||
SetBit(t.m3(), 4);
|
||||
if (GetClearGround(t) == CLEAR_FIELDS) {
|
||||
SetClearGroundDensity(t, CLEAR_GRASS, density);
|
||||
if (GetClearGround(t) == ClearGround::Fields) {
|
||||
SetClearGroundDensity(t, ClearGround::Grass, density);
|
||||
} else {
|
||||
SetClearDensity(t, density);
|
||||
}
|
||||
|
||||
+3
-3
@@ -390,7 +390,7 @@ static void GreyscaleToMapHeights(uint img_width, uint img_height, std::span<con
|
||||
}
|
||||
/* Only clear the tiles within the map area. */
|
||||
if (IsInnerTile(tile)) {
|
||||
MakeClear(tile, CLEAR_GRASS, 3);
|
||||
MakeClear(tile, ClearGround::Grass, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -433,7 +433,7 @@ void FixSlopes()
|
||||
/* Height was changed so now there's a chance, more likely at higher altitude, of the
|
||||
* tile turning into rock. */
|
||||
if (IsInnerTile(tile) && RandomRange(max_height) <= current_height) {
|
||||
MakeClear(tile, CLEAR_ROCKS, 3);
|
||||
MakeClear(tile, ClearGround::Rocks, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -462,7 +462,7 @@ void FixSlopes()
|
||||
/* Height was changed so now there's a chance, more likely at higher altitude, of the
|
||||
* tile turning into rock. */
|
||||
if (IsInnerTile(tile) && RandomRange(max_height) <= current_height) {
|
||||
MakeClear(tile, CLEAR_ROCKS, 3);
|
||||
MakeClear(tile, ClearGround::Rocks, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ Industry::~Industry()
|
||||
|
||||
/* Remove the farmland and convert it to regular tiles over time. */
|
||||
for (TileIndex tile_cur : ta) {
|
||||
if (IsTileType(tile_cur, TileType::Clear) && IsClearGround(tile_cur, CLEAR_FIELDS) &&
|
||||
if (IsTileType(tile_cur, TileType::Clear) && IsClearGround(tile_cur, ClearGround::Fields) &&
|
||||
GetIndustryIndexOfField(tile_cur) == this->index) {
|
||||
SetIndustryIndexOfField(tile_cur, IndustryID::Invalid());
|
||||
}
|
||||
@@ -1004,9 +1004,9 @@ static bool IsSuitableForFarmField(TileIndex tile, bool allow_fields, bool allow
|
||||
case TileType::Clear:
|
||||
if (IsSnowTile(tile)) return false;
|
||||
switch (GetClearGround(tile)) {
|
||||
case CLEAR_DESERT: return false;
|
||||
case CLEAR_ROUGH: return allow_rough;
|
||||
case CLEAR_FIELDS: return allow_fields;
|
||||
case ClearGround::Desert: return false;
|
||||
case ClearGround::Rough: return allow_rough;
|
||||
case ClearGround::Fields: return allow_fields;
|
||||
default: return true;
|
||||
}
|
||||
case TileType::Trees: return GetTreeGround(tile) != TREE_GROUND_SHORE && (allow_rough || GetTreeGround(tile) != TREE_GROUND_ROUGH);
|
||||
@@ -1029,9 +1029,9 @@ static void SetupFarmFieldFence(TileIndex tile, int size, uint8_t type, DiagDire
|
||||
do {
|
||||
tile = Map::WrapToMap(tile);
|
||||
|
||||
if (IsTileType(tile, TileType::Clear) && IsClearGround(tile, CLEAR_FIELDS)) {
|
||||
if (IsTileType(tile, TileType::Clear) && IsClearGround(tile, ClearGround::Fields)) {
|
||||
TileIndex neighbour = tile + neighbour_diff;
|
||||
if (!IsTileType(neighbour, TileType::Clear) || !IsClearGround(neighbour, CLEAR_FIELDS) || GetFence(neighbour, ReverseDiagDir(side)) == 0) {
|
||||
if (!IsTileType(neighbour, TileType::Clear) || !IsClearGround(neighbour, ClearGround::Fields) || GetFence(neighbour, ReverseDiagDir(side)) == 0) {
|
||||
/* Add fence as long as neighbouring tile does not already have a fence in the same position. */
|
||||
uint8_t or_ = type;
|
||||
|
||||
|
||||
@@ -618,8 +618,8 @@ public:
|
||||
|
||||
/* Clear farmland. */
|
||||
for (const auto tile : Map::Iterate()) {
|
||||
if (IsTileType(tile, TileType::Clear) && GetClearGround(tile) == CLEAR_FIELDS) {
|
||||
MakeClear(tile, CLEAR_GRASS, 3);
|
||||
if (IsTileType(tile, TileType::Clear) && GetClearGround(tile) == ClearGround::Fields) {
|
||||
MakeClear(tile, ClearGround::Grass, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -545,7 +545,7 @@ void DoClearSquare(TileIndex tile)
|
||||
if (MayAnimateTile(tile)) DeleteAnimatedTile(tile, true);
|
||||
|
||||
bool remove = IsDockingTile(tile);
|
||||
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0);
|
||||
MakeClear(tile, ClearGround::Grass, _generating_world ? 3 : 0);
|
||||
MarkTileDirtyByTile(tile);
|
||||
if (remove) RemoveDockingTile(tile);
|
||||
|
||||
@@ -845,7 +845,7 @@ void InitializeLandscape()
|
||||
{
|
||||
for (uint y = _settings_game.construction.freeform_edges ? 1 : 0; y < Map::MaxY(); y++) {
|
||||
for (uint x = _settings_game.construction.freeform_edges ? 1 : 0; x < Map::MaxX(); x++) {
|
||||
MakeClear(TileXY(x, y), CLEAR_GRASS, 3);
|
||||
MakeClear(TileXY(x, y), ClearGround::Grass, 3);
|
||||
SetTileHeight(TileXY(x, y), 0);
|
||||
SetTropicZone(TileXY(x, y), TROPICZONE_NORMAL);
|
||||
ClearBridgeMiddle(TileXY(x, y));
|
||||
@@ -1012,7 +1012,7 @@ static void CreateDesertOrRainForest(uint desert_tropic_line)
|
||||
|
||||
auto allows_rainforest = [tile](auto &offset) {
|
||||
TileIndex t = AddTileIndexDiffCWrap(tile, offset);
|
||||
return t == INVALID_TILE || !IsTileType(t, TileType::Clear) || !IsClearGround(t, CLEAR_DESERT);
|
||||
return t == INVALID_TILE || !IsTileType(t, TileType::Clear) || !IsClearGround(t, ClearGround::Desert);
|
||||
};
|
||||
if (std::all_of(std::begin(_make_desert_or_rainforest_data), std::end(_make_desert_or_rainforest_data), allows_rainforest)) {
|
||||
SetTropicZone(tile, TROPICZONE_RAINFOREST);
|
||||
@@ -1128,7 +1128,7 @@ static void MakeWetlands(TileIndex centre, uint height, uint river_length)
|
||||
MakeRiverAndModifyDesertZoneAround(tile);
|
||||
} else if (IsTileType(tile, TileType::Clear)) {
|
||||
/* This tile is ground, which we always make rough. */
|
||||
SetClearGroundDensity(tile, CLEAR_ROUGH, 3);
|
||||
SetClearGroundDensity(tile, ClearGround::Rough, 3);
|
||||
/* Maybe place trees? */
|
||||
if (has_trees && _settings_game.game_creation.tree_placer != TreePlacer::None) {
|
||||
PlaceTree(tile, Random(), true);
|
||||
|
||||
@@ -465,7 +465,7 @@ static void FixOwnerOfRailTrack(Tile t)
|
||||
}
|
||||
|
||||
/* if it's not a crossing, make it clean land */
|
||||
MakeClear(t, CLEAR_GRASS, 0);
|
||||
MakeClear(t, ClearGround::Grass, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1252,7 +1252,7 @@ bool AfterLoadGame()
|
||||
}
|
||||
} else {
|
||||
if (GB(t.m5(), 3, 2) == 0) {
|
||||
MakeClear(t, CLEAR_GRASS, 3);
|
||||
MakeClear(t, ClearGround::Grass, 3);
|
||||
} else {
|
||||
if (!IsTileFlat(t)) {
|
||||
MakeShore(t);
|
||||
@@ -1477,9 +1477,9 @@ bool AfterLoadGame()
|
||||
* plant new ones. */
|
||||
if (IsSavegameVersionBefore(SLV_32)) {
|
||||
for (const auto t : Map::Iterate()) {
|
||||
if (IsTileType(t, TileType::Clear) && IsClearGround(t, CLEAR_FIELDS)) {
|
||||
if (IsTileType(t, TileType::Clear) && IsClearGround(t, ClearGround::Fields)) {
|
||||
/* remove fields */
|
||||
MakeClear(t, CLEAR_GRASS, 3);
|
||||
MakeClear(t, ClearGround::Grass, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2434,8 +2434,8 @@ bool AfterLoadGame()
|
||||
if (IsSavegameVersionBefore(SLV_135)) {
|
||||
for (auto t : Map::Iterate()) {
|
||||
if (IsTileType(t, TileType::Clear)) {
|
||||
if (GetClearGround(t) == ClearGround{4}) { // CLEAR_SNOW becomes CLEAR_GRASS with IsSnowTile() set.
|
||||
SetClearGroundDensity(t, CLEAR_GRASS, GetClearDensity(t));
|
||||
if (GetClearGround(t) == ClearGround{4}) { // CLEAR_SNOW becomes ClearGround::Grass with IsSnowTile() set.
|
||||
SetClearGroundDensity(t, ClearGround::Grass, GetClearDensity(t));
|
||||
SetBit(t.m3(), 4);
|
||||
} else {
|
||||
ClrBit(t.m3(), 4);
|
||||
@@ -2915,13 +2915,13 @@ bool AfterLoadGame()
|
||||
/* We store 4 fences in the field tiles instead of only SE and SW. */
|
||||
for (auto t : Map::Iterate()) {
|
||||
if (!IsTileType(t, TileType::Clear) && !IsTileType(t, TileType::Trees)) continue;
|
||||
if (IsTileType(t, TileType::Clear) && IsClearGround(t, CLEAR_FIELDS)) continue;
|
||||
if (IsTileType(t, TileType::Clear) && IsClearGround(t, ClearGround::Fields)) continue;
|
||||
uint fence = GB(t.m4(), 5, 3);
|
||||
if (fence != 0 && IsTileType(TileAddXY(t, 1, 0), TileType::Clear) && IsClearGround(TileAddXY(t, 1, 0), CLEAR_FIELDS)) {
|
||||
if (fence != 0 && IsTileType(TileAddXY(t, 1, 0), TileType::Clear) && IsClearGround(TileAddXY(t, 1, 0), ClearGround::Fields)) {
|
||||
SetFence(TileAddXY(t, 1, 0), DIAGDIR_NE, fence);
|
||||
}
|
||||
fence = GB(t.m4(), 2, 3);
|
||||
if (fence != 0 && IsTileType(TileAddXY(t, 0, 1), TileType::Clear) && IsClearGround(TileAddXY(t, 0, 1), CLEAR_FIELDS)) {
|
||||
if (fence != 0 && IsTileType(TileAddXY(t, 0, 1), TileType::Clear) && IsClearGround(TileAddXY(t, 0, 1), ClearGround::Fields)) {
|
||||
SetFence(TileAddXY(t, 0, 1), DIAGDIR_NW, fence);
|
||||
}
|
||||
SB(t.m4(), 2, 3, 0);
|
||||
|
||||
@@ -123,21 +123,21 @@
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
|
||||
return (::IsTileType(tile, TileType::Clear) && ::IsClearGround(tile, CLEAR_FIELDS));
|
||||
return (::IsTileType(tile, TileType::Clear) && ::IsClearGround(tile, ClearGround::Fields));
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTile::IsRockTile(TileIndex tile)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
|
||||
return (::IsTileType(tile, TileType::Clear) && ::GetClearGround(tile) == ::CLEAR_ROCKS);
|
||||
return (::IsTileType(tile, TileType::Clear) && ::GetClearGround(tile) == ::ClearGround::Rocks);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTile::IsRoughTile(TileIndex tile)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
|
||||
return (::IsTileType(tile, TileType::Clear) && ::GetClearGround(tile) == ::CLEAR_ROUGH);
|
||||
return (::IsTileType(tile, TileType::Clear) && ::GetClearGround(tile) == ::ClearGround::Rough);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTile::IsSnowTile(TileIndex tile)
|
||||
@@ -151,7 +151,7 @@
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
|
||||
return (::IsTileType(tile, TileType::Clear) && ::IsClearGround(tile, CLEAR_DESERT));
|
||||
return (::IsTileType(tile, TileType::Clear) && ::IsClearGround(tile, ClearGround::Desert));
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTile::IsHouseTile(TileIndex tile)
|
||||
|
||||
@@ -549,11 +549,11 @@ static inline uint32_t GetSmallMapVegetationPixels(TileIndex tile, TileType t)
|
||||
switch (t) {
|
||||
case TileType::Clear:
|
||||
if (IsSnowTile(tile)) return MKCOLOUR_XXXX(PC_LIGHT_BLUE);
|
||||
if (IsClearGround(tile, CLEAR_GRASS)) {
|
||||
if (IsClearGround(tile, ClearGround::Grass)) {
|
||||
if (GetClearDensity(tile) < 3) return MKCOLOUR_XXXX(PC_BARE_LAND);
|
||||
if (GetTropicZone(tile) == TROPICZONE_RAINFOREST) return MKCOLOUR_XXXX(PC_RAINFOREST);
|
||||
}
|
||||
return _vegetation_clear_bits[GetClearGround(tile)];
|
||||
return _vegetation_clear_bits[to_underlying(GetClearGround(tile))];
|
||||
|
||||
case TileType::Industry:
|
||||
return IsTileForestIndustry(tile) ? MKCOLOUR_XXXX(PC_GREEN) : MKCOLOUR_XXXX(PC_DARK_RED);
|
||||
|
||||
@@ -87,7 +87,7 @@ static void GenerateRockyArea(TileIndex end, TileIndex start)
|
||||
[[fallthrough]];
|
||||
|
||||
case TileType::Clear:
|
||||
MakeClear(tile, CLEAR_ROCKS, 3);
|
||||
MakeClear(tile, ClearGround::Rocks, 3);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
+1
-1
@@ -1002,7 +1002,7 @@ static void TgenSetTileHeight(TileIndex tile, int height)
|
||||
|
||||
/* Only clear the tiles within the map area. */
|
||||
if (IsInnerTile(tile)) {
|
||||
MakeClear(tile, CLEAR_GRASS, 3);
|
||||
MakeClear(tile, ClearGround::Grass, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2151,7 +2151,7 @@ static CommandCost TownCanBePlacedHere(TileIndex tile, bool check_surrounding)
|
||||
switch (GetTileType(t)) {
|
||||
case TileType::Clear:
|
||||
/* Don't allow rough tiles, as they are likely wetlands. */
|
||||
if (GetClearGround(t) == CLEAR_ROUGH) continue;
|
||||
if (GetClearGround(t) == ClearGround::Rough) continue;
|
||||
break;
|
||||
|
||||
case TileType::Trees:
|
||||
|
||||
+15
-15
@@ -53,7 +53,7 @@ static const uint16_t EDITOR_TREE_DIV = 5; ///< Game editor tr
|
||||
* This is true for clear ground without farms or rocks.
|
||||
*
|
||||
* @param tile the tile of interest
|
||||
* @param allow_desert Allow planting trees on CLEAR_DESERT?
|
||||
* @param allow_desert Allow planting trees on ClearGround::Desert?
|
||||
* @return true if trees can be built.
|
||||
*/
|
||||
static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert)
|
||||
@@ -63,8 +63,8 @@ static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert)
|
||||
return !IsBridgeAbove(tile) && IsCoast(tile) && !IsSlopeWithOneCornerRaised(GetTileSlope(tile));
|
||||
|
||||
case TileType::Clear:
|
||||
return !IsBridgeAbove(tile) && !IsClearGround(tile, CLEAR_FIELDS) && !IsClearGround(tile, CLEAR_ROCKS) &&
|
||||
(allow_desert || !IsClearGround(tile, CLEAR_DESERT));
|
||||
return !IsBridgeAbove(tile) && !IsClearGround(tile, ClearGround::Fields) && !IsClearGround(tile, ClearGround::Rocks) &&
|
||||
(allow_desert || !IsClearGround(tile, ClearGround::Desert));
|
||||
|
||||
default: return false;
|
||||
}
|
||||
@@ -98,15 +98,15 @@ static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, Tree
|
||||
case TileType::Clear: {
|
||||
ClearGround clearground = GetClearGround(tile);
|
||||
if (IsSnowTile(tile)) {
|
||||
ground = clearground == CLEAR_ROUGH ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT;
|
||||
ground = clearground == ClearGround::Rough ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT;
|
||||
} else {
|
||||
switch (clearground) {
|
||||
case CLEAR_GRASS: ground = TREE_GROUND_GRASS; break;
|
||||
case CLEAR_ROUGH: ground = TREE_GROUND_ROUGH; break;
|
||||
case ClearGround::Grass: ground = TREE_GROUND_GRASS; break;
|
||||
case ClearGround::Rough: ground = TREE_GROUND_ROUGH; break;
|
||||
default: ground = TREE_GROUND_SNOW_DESERT; break;
|
||||
}
|
||||
}
|
||||
if (clearground != CLEAR_ROUGH) density = GetClearDensity(tile);
|
||||
if (clearground != ClearGround::Rough) density = GetClearDensity(tile);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -574,8 +574,8 @@ CommandCost CmdPlantTree(DoCommandFlags flags, TileIndex tile, TileIndex start_t
|
||||
if (IsTileType(current_tile, TileType::Clear)) {
|
||||
/* Remove fields or rocks. Note that the ground will get barrened */
|
||||
switch (GetClearGround(current_tile)) {
|
||||
case CLEAR_FIELDS:
|
||||
case CLEAR_ROCKS: {
|
||||
case ClearGround::Fields:
|
||||
case ClearGround::Rocks: {
|
||||
CommandCost ret = Command<Commands::LandscapeClear>::Do(flags, current_tile);
|
||||
if (ret.Failed()) return ret;
|
||||
cost.AddCost(ret.GetCost());
|
||||
@@ -891,7 +891,7 @@ static void TileLoop_Trees(TileIndex tile)
|
||||
if (!CanPlantTreesOnTile(tile, false)) return;
|
||||
|
||||
/* Don't plant trees, if ground was freshly cleared */
|
||||
if (IsTileType(tile, TileType::Clear) && GetClearGround(tile) == CLEAR_GRASS && !IsSnowTile(tile) && GetClearDensity(tile) != 3) return;
|
||||
if (IsTileType(tile, TileType::Clear) && GetClearGround(tile) == ClearGround::Grass && !IsSnowTile(tile) && GetClearDensity(tile) != 3) return;
|
||||
|
||||
PlantTreesOnTile(tile, treetype, 0, TreeGrowthStage::Growing1);
|
||||
|
||||
@@ -916,20 +916,20 @@ static void TileLoop_Trees(TileIndex tile)
|
||||
/* just one tree, change type into TileType::Clear */
|
||||
switch (GetTreeGround(tile)) {
|
||||
case TREE_GROUND_SHORE: MakeShore(tile); break;
|
||||
case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, GetTreeDensity(tile)); break;
|
||||
case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break;
|
||||
case TREE_GROUND_GRASS: MakeClear(tile, ClearGround::Grass, GetTreeDensity(tile)); break;
|
||||
case TREE_GROUND_ROUGH: MakeClear(tile, ClearGround::Rough, 3); break;
|
||||
case TREE_GROUND_ROUGH_SNOW: {
|
||||
uint density = GetTreeDensity(tile);
|
||||
MakeClear(tile, CLEAR_ROUGH, 3);
|
||||
MakeClear(tile, ClearGround::Rough, 3);
|
||||
MakeSnow(tile, density);
|
||||
break;
|
||||
}
|
||||
default: // snow or desert
|
||||
if (_settings_game.game_creation.landscape == LandscapeType::Tropic) {
|
||||
MakeClear(tile, CLEAR_DESERT, GetTreeDensity(tile));
|
||||
MakeClear(tile, ClearGround::Desert, GetTreeDensity(tile));
|
||||
} else {
|
||||
uint density = GetTreeDensity(tile);
|
||||
MakeClear(tile, CLEAR_GRASS, 3);
|
||||
MakeClear(tile, ClearGround::Grass, 3);
|
||||
MakeSnow(tile, density);
|
||||
}
|
||||
break;
|
||||
|
||||
+1
-1
@@ -1260,7 +1260,7 @@ static void DoDryUp(TileIndex tile)
|
||||
assert(IsCoast(tile));
|
||||
|
||||
if (Command<Commands::LandscapeClear>::Do(DoCommandFlag::Execute, tile).Succeeded()) {
|
||||
MakeClear(tile, CLEAR_GRASS, 3);
|
||||
MakeClear(tile, ClearGround::Grass, 3);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user