4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file landscape.h Functions related to OTTD's landscape. */
15 #include "core/geometry_type.hpp"
18 static const uint SNOW_LINE_MONTHS
= 12; ///< Number of months in the snow line table.
19 static const uint SNOW_LINE_DAYS
= 32; ///< Number of days in each month in the snow line table.
22 * Structure describing the height of the snow line each day of the year
23 * @ingroup SnowLineGroup
26 byte table
[SNOW_LINE_MONTHS
][SNOW_LINE_DAYS
]; ///< Height of the snow line each day of the year
27 byte highest_value
; ///< Highest snow line of the year
28 byte lowest_value
; ///< Lowest snow line of the year
32 void SetSnowLine(byte table
[SNOW_LINE_MONTHS
][SNOW_LINE_DAYS
]);
34 byte
HighestSnowLine();
35 byte
LowestSnowLine();
38 uint
GetPartialZ(int x
, int y
, Slope corners
);
39 uint
GetSlopeZ(int x
, int y
);
40 void GetSlopeZOnEdge(Slope tileh
, DiagDirection edge
, int *z1
, int *z2
);
41 int GetSlopeZInCorner(Slope tileh
, Corner corner
);
42 Slope
GetFoundationSlope(TileIndex tile
, uint
*z
);
45 * Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
46 * @param x X world or tile coordinate (runs in SW direction in the 2D view).
47 * @param y Y world or tile coordinate (runs in SE direction in the 2D view).
48 * @param z Z world or tile coordinate (runs in N direction in the 2D view).
49 * @return Equivalent coordinate in the 2D view.
52 static inline Point
RemapCoords(int x
, int y
, int z
)
61 * Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
62 * Same as #RemapCoords, except the Z coordinate is read from the map.
63 * @param x X world or tile coordinate (runs in SW direction in the 2D view).
64 * @param y Y world or tile coordinate (runs in SE direction in the 2D view).
65 * @return Equivalent coordinate in the 2D view.
68 static inline Point
RemapCoords2(int x
, int y
)
70 return RemapCoords(x
, y
, GetSlopeZ(x
, y
));
74 * Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
75 * Function assumes <tt>z == 0</tt>. For other values of \p z, add \p z to \a y before the call.
76 * @param x X coordinate of the 2D coordinate.
77 * @param y Y coordinate of the 2D coordinate.
78 * @return X and Y components of equivalent world or tile coordinate.
79 * @note Inverse of #RemapCoords function. Smaller values may get rounded.
81 static inline Point
InverseRemapCoords(int x
, int y
)
83 Point pt
= {(y
* 2 - x
) >> 2, (y
* 2 + x
) >> 2};
87 uint
ApplyFoundationToSlope(Foundation f
, Slope
*s
);
88 void DrawFoundation(TileInfo
*ti
, Foundation f
);
89 bool HasFoundationNW(TileIndex tile
, Slope slope_here
, uint z_here
);
90 bool HasFoundationNE(TileIndex tile
, Slope slope_here
, uint z_here
);
92 void DoClearSquare(TileIndex tile
);
95 void InitializeLandscape();
96 void GenerateLandscape(byte mode
);
98 #endif /* LANDSCAPE_H */