2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2007-12-26 11:45:43 +00:00
|
|
|
/** @file map_type.h Types related to maps. */
|
|
|
|
|
|
|
|
#ifndef MAP_TYPE_H
|
|
|
|
#define MAP_TYPE_H
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data that is stored per tile. Also used TileExtended for this.
|
|
|
|
* Look at docs/landscape.html for the exact meaning of the members.
|
|
|
|
*/
|
|
|
|
struct Tile {
|
2014-09-21 11:20:11 +00:00
|
|
|
byte type; ///< The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
|
2014-09-21 11:14:58 +00:00
|
|
|
byte height; ///< The height of the northern corner.
|
2007-12-26 11:45:43 +00:00
|
|
|
uint16 m2; ///< Primarily used for indices to towns, industries and stations
|
2015-01-26 10:27:51 +00:00
|
|
|
byte m1; ///< Primarily used for ownership information
|
2007-12-26 11:45:43 +00:00
|
|
|
byte m3; ///< General purpose
|
|
|
|
byte m4; ///< General purpose
|
|
|
|
byte m5; ///< General purpose
|
|
|
|
};
|
|
|
|
|
2020-12-27 10:44:22 +00:00
|
|
|
static_assert(sizeof(Tile) == 8);
|
2015-02-01 12:25:51 +00:00
|
|
|
|
2007-12-26 11:45:43 +00:00
|
|
|
/**
|
|
|
|
* Data that is stored per tile. Also used Tile for this.
|
|
|
|
* Look at docs/landscape.html for the exact meaning of the members.
|
|
|
|
*/
|
|
|
|
struct TileExtended {
|
2018-05-23 10:48:01 +00:00
|
|
|
byte m6; ///< General purpose
|
|
|
|
byte m7; ///< Primarily used for newgrf support
|
|
|
|
uint16 m8; ///< General purpose
|
2007-12-26 11:45:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2022-04-17 17:00:00 +00:00
|
|
|
* An offset value between two tiles.
|
2007-12-26 11:45:43 +00:00
|
|
|
*
|
2012-12-01 13:12:39 +00:00
|
|
|
* This value is used for the difference between
|
2022-04-17 17:00:00 +00:00
|
|
|
* two tiles. It can be added to a TileIndex to get
|
|
|
|
* the resulting TileIndex of the start tile applied
|
2007-12-26 11:45:43 +00:00
|
|
|
* with this saved difference.
|
|
|
|
*
|
|
|
|
* @see TileDiffXY(int, int)
|
|
|
|
*/
|
|
|
|
typedef int32 TileIndexDiff;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A pair-construct of a TileIndexDiff.
|
|
|
|
*
|
|
|
|
* This can be used to save the difference between to
|
|
|
|
* tiles as a pair of x and y value.
|
|
|
|
*/
|
|
|
|
struct TileIndexDiffC {
|
|
|
|
int16 x; ///< The x value of the coordinate
|
|
|
|
int16 y; ///< The y value of the coordinate
|
|
|
|
};
|
|
|
|
|
2009-06-20 11:25:39 +00:00
|
|
|
/** Minimal and maximal map width and height */
|
2010-05-13 09:44:44 +00:00
|
|
|
static const uint MIN_MAP_SIZE_BITS = 6; ///< Minimal size of map is equal to 2 ^ MIN_MAP_SIZE_BITS
|
2015-09-11 18:53:02 +00:00
|
|
|
static const uint MAX_MAP_SIZE_BITS = 20; ///< Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS
|
2015-09-11 21:36:15 +00:00
|
|
|
static const uint MAX_MAP_TILES_BITS = 28; ///< Maximal number of tiles in a map is equal to 2 ^ MAX_MAP_TILES_BITS.
|
2010-05-13 09:44:44 +00:00
|
|
|
static const uint MIN_MAP_SIZE = 1 << MIN_MAP_SIZE_BITS; ///< Minimal map size = 64
|
2015-09-11 21:39:01 +00:00
|
|
|
static const uint MAX_MAP_SIZE = 1 << MAX_MAP_SIZE_BITS; ///< Maximal map size = 1M
|
2015-09-11 21:36:15 +00:00
|
|
|
static const uint MAX_MAP_TILES = 1 << MAX_MAP_TILES_BITS;///< Maximal number of tiles in a map = 256M (16k x 16k)
|
2009-06-20 11:25:39 +00:00
|
|
|
|
2007-12-26 11:45:43 +00:00
|
|
|
/**
|
|
|
|
* Approximation of the length of a straight track, relative to a diagonal
|
|
|
|
* track (ie the size of a tile side).
|
|
|
|
*
|
2018-10-28 02:17:36 +00:00
|
|
|
* \#defined instead of const so it can
|
2007-12-26 11:45:43 +00:00
|
|
|
* stay integer. (no runtime float operations) Is this needed?
|
|
|
|
* Watch out! There are _no_ brackets around here, to prevent intermediate
|
|
|
|
* rounding! Be careful when using this!
|
|
|
|
* This value should be sqrt(2)/2 ~ 0.7071
|
|
|
|
*/
|
|
|
|
#define STRAIGHT_TRACK_LENGTH 7071/10000
|
|
|
|
|
2010-12-13 11:21:53 +00:00
|
|
|
/** Argument for CmdLevelLand describing what to do. */
|
|
|
|
enum LevelMode {
|
|
|
|
LM_LEVEL, ///< Level the land.
|
|
|
|
LM_LOWER, ///< Lower the land.
|
|
|
|
LM_RAISE, ///< Raise the land.
|
|
|
|
};
|
|
|
|
|
2007-12-26 11:45:43 +00:00
|
|
|
#endif /* MAP_TYPE_H */
|