mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-24 03:56:43 +00:00
103 lines
5.1 KiB
C
103 lines
5.1 KiB
C
/*
|
|
* This file is part of OpenTTD.
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
|
|
*/
|
|
|
|
/** @file tile_type.h Types related to tiles. */
|
|
|
|
#ifndef TILE_TYPE_H
|
|
#define TILE_TYPE_H
|
|
|
|
#include "core/strong_typedef_type.hpp"
|
|
|
|
static constexpr uint TILE_SIZE = 16; ///< Tile size in world coordinates.
|
|
static constexpr uint TILE_UNIT_MASK = TILE_SIZE - 1; ///< For masking in/out the inner-tile world coordinate units.
|
|
static constexpr uint TILE_PIXELS = 32; ///< Pixel distance between tile columns/rows in #ZOOM_BASE.
|
|
static constexpr uint TILE_HEIGHT = 8; ///< Height of a height level in world coordinate AND in pixels in #ZOOM_BASE.
|
|
|
|
static constexpr uint MAX_BUILDING_PIXELS = 200; ///< Maximum height of a building in pixels in #ZOOM_BASE. (Also applies to "bridge buildings" on the bridge floor.)
|
|
static constexpr int MAX_VEHICLE_PIXEL_X = 192; ///< Maximum width of a vehicle in pixels in #ZOOM_BASE.
|
|
static constexpr int MAX_VEHICLE_PIXEL_Y = 96; ///< Maximum height of a vehicle in pixels in #ZOOM_BASE.
|
|
|
|
static constexpr uint MAX_TILE_HEIGHT = 255; ///< Maximum allowed tile height
|
|
|
|
static constexpr uint MIN_HEIGHTMAP_HEIGHT = 1; ///< Lowest possible peak value for heightmap creation
|
|
static constexpr uint MIN_CUSTOM_TERRAIN_TYPE = 1; ///< Lowest possible peak value for world generation
|
|
|
|
static constexpr uint MIN_MAP_HEIGHT_LIMIT = 15; ///< Lower bound of maximum allowed heightlevel (in the construction settings)
|
|
static constexpr uint MAX_MAP_HEIGHT_LIMIT = MAX_TILE_HEIGHT; ///< Upper bound of maximum allowed heightlevel (in the construction settings)
|
|
|
|
static constexpr uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snowline height
|
|
static constexpr uint DEF_SNOWLINE_HEIGHT = 10; ///< Default snowline height
|
|
static constexpr uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum allowed snowline height
|
|
|
|
static constexpr uint DEF_SNOW_COVERAGE = 40; ///< Default snow coverage.
|
|
static constexpr uint DEF_DESERT_COVERAGE = 50; ///< Default desert coverage.
|
|
|
|
static constexpr size_t TILE_TYPE_BITS = 4; ///< How many bits in map array are dedicated for type of each tile.
|
|
|
|
/**
|
|
* The different types of tiles.
|
|
*
|
|
* Each tile belongs to one type, according whatever is build on it.
|
|
*
|
|
* @note A railway with a crossing street is marked as TileType::Road.
|
|
*/
|
|
enum class TileType : uint8_t {
|
|
Clear, ///< A tile without any structures, i.e. grass, rocks, farm fields etc.
|
|
Railway, ///< A tile with railway.
|
|
Road, ///< A tile with road and/or tram tracks.
|
|
House, ///< A house by a town.
|
|
Trees, ///< Tile with one or more trees.
|
|
Station, ///< A tile of a station or airport.
|
|
Water, ///< Water tile.
|
|
Void, ///< Invisible tiles at the SW and SE border.
|
|
Industry, ///< Part of an industry.
|
|
TunnelBridge, ///< Tunnel entry/exit and bridge heads.
|
|
Object, ///< Contains objects such as transmitters and owned land.
|
|
End, ///< End marker.
|
|
MaxSize = 1U << TILE_TYPE_BITS, ///< The maximum possible number of tile types to be stored in map.
|
|
};
|
|
|
|
static_assert(TileType::End <= TileType::MaxSize);
|
|
|
|
/**
|
|
* Additional infos of a tile on a tropic game.
|
|
*
|
|
* The tropiczone is not modified during gameplay. It mainly affects tree growth. (desert tiles are visible though)
|
|
*
|
|
* In randomly generated maps:
|
|
* TropicZone::Desert: Generated everywhere, if there is neither water nor mountains (TileHeight >= 4) in a certain distance from the tile.
|
|
* TropicZone::Rainforest: Generated everywhere, if there is no desert in a certain distance from the tile.
|
|
* TropicZone::Normal: Everywhere else, i.e. between desert and rainforest and on sea (if you clear the water).
|
|
*
|
|
* In scenarios:
|
|
* TropicZone::Normal: Default value.
|
|
* TropicZone::Desert: Placed manually.
|
|
* TropicZone::Rainforest: Placed if you plant certain rainforest-trees.
|
|
*/
|
|
enum class TropicZone : uint8_t {
|
|
Normal = 0, ///< Normal tropiczone
|
|
Desert = 1, ///< Tile is desert
|
|
Rainforest = 2, ///< Rainforest tile
|
|
};
|
|
|
|
/**
|
|
* The index/ID of a Tile.
|
|
*
|
|
* It is compatible with int32 / int64 for easy math throughout the code.
|
|
*/
|
|
using TileIndex = StrongType::Typedef<uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int32_t>, StrongType::Compatible<int64_t>>;
|
|
|
|
/* Make sure the size is as expected. */
|
|
static_assert(sizeof(TileIndex) == 4);
|
|
|
|
/**
|
|
* The very nice invalid tile marker
|
|
*/
|
|
inline constexpr TileIndex INVALID_TILE = TileIndex{ (uint32_t)-1 };
|
|
|
|
#endif /* TILE_TYPE_H */
|