Files
@ r24616:e90bc612c587
Branch filter:
Location: cpp/openttd-patchpack/source/src/landscape.h - annotation
r24616:e90bc612c587
5.0 KiB
text/x-c
Update: Translations from eints
korean: 2 changes by telk5093
finnish: 2 changes by hpiirai
dutch: 49 changes by Afoklala
spanish: 16 changes by Luis45ccs
french: 7 changes by dimensi0n
polish: 2 changes by yazalo
korean: 2 changes by telk5093
finnish: 2 changes by hpiirai
dutch: 49 changes by Afoklala
spanish: 16 changes by Luis45ccs
french: 7 changes by dimensi0n
polish: 2 changes by yazalo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6343:4d2d12eee7b9 r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a r8121:d05602c69734 r8138:f851b4cbdad1 r8119:8fdb3a371896 r15173:a59afd6301a6 r15173:a59afd6301a6 r6343:4d2d12eee7b9 r15610:623a23fb6560 r15610:623a23fb6560 r15613:193c12018337 r15613:193c12018337 r6343:4d2d12eee7b9 r10260:88d82a40120c r10260:88d82a40120c r11206:4cc3157af9d3 r6343:4d2d12eee7b9 r6343:4d2d12eee7b9 r11962:0e3a6981e508 r6343:4d2d12eee7b9 r11962:0e3a6981e508 r11962:0e3a6981e508 r11962:0e3a6981e508 r11962:0e3a6981e508 r6453:b0b56773284a r18246:8bbceed09429 r23607:36c15679007d r18246:8bbceed09429 r18245:fb370bf5a3c0 r18258:596f9f391ce0 r23201:f37d3515c110 r18245:fb370bf5a3c0 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r23607:36c15679007d r18246:8bbceed09429 r18246:8bbceed09429 r18260:9616113792ef r18246:8bbceed09429 r23607:36c15679007d r18246:8bbceed09429 r18248:133cf25ab512 r18246:8bbceed09429 r18246:8bbceed09429 r6453:b0b56773284a r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a r18462:a1ba75a7f741 r18462:a1ba75a7f741 r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r14458:24b07b6f49f4 r6453:b0b56773284a r6453:b0b56773284a r18245:fb370bf5a3c0 r6453:b0b56773284a r6453:b0b56773284a r14461:1eaa78e19f25 r14461:1eaa78e19f25 r14461:1eaa78e19f25 r14461:1eaa78e19f25 r14461:1eaa78e19f25 r14461:1eaa78e19f25 r14461:1eaa78e19f25 r23198:6e6852ceb3fb r14461:1eaa78e19f25 r14461:1eaa78e19f25 r14461:1eaa78e19f25 r18462:a1ba75a7f741 r14461:1eaa78e19f25 r14461:1eaa78e19f25 r14461:1eaa78e19f25 r23607:36c15679007d r23198:6e6852ceb3fb r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r18246:8bbceed09429 r7335:93bf5f4b6ce4 r14150:e63335af522e r14150:e63335af522e r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a r6453:b0b56773284a | /*
* 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/>.
*/
/** @file landscape.h Functions related to OTTD's landscape. */
#ifndef LANDSCAPE_H
#define LANDSCAPE_H
#include "core/geometry_type.hpp"
#include "tile_cmd.h"
static const uint SNOW_LINE_MONTHS = 12; ///< Number of months in the snow line table.
static const uint SNOW_LINE_DAYS = 32; ///< Number of days in each month in the snow line table.
/**
* Structure describing the height of the snow line each day of the year
* @ingroup SnowLineGroup
*/
struct SnowLine {
byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]; ///< Height of the snow line each day of the year
byte highest_value; ///< Highest snow line of the year
byte lowest_value; ///< Lowest snow line of the year
};
bool IsSnowLineSet();
void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]);
byte GetSnowLine();
byte HighestSnowLine();
byte LowestSnowLine();
void ClearSnowLine();
int GetSlopeZInCorner(Slope tileh, Corner corner);
Slope GetFoundationSlope(TileIndex tile, int *z = nullptr);
uint GetPartialPixelZ(int x, int y, Slope corners);
int GetSlopePixelZ(int x, int y);
int GetSlopePixelZOutsideMap(int x, int y);
void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2);
/**
* Determine the Z height of a corner relative to TileZ.
*
* @pre The slope must not be a halftile slope.
*
* @param tileh The slope.
* @param corner The corner.
* @return Z position of corner relative to TileZ.
*/
static inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
{
return GetSlopeZInCorner(tileh, corner) * TILE_HEIGHT;
}
/**
* Get slope of a tile on top of a (possible) foundation
* If a tile does not have a foundation, the function returns the same as GetTilePixelSlope.
*
* @param tile The tile of interest.
* @param z returns the z of the foundation slope. (Can be nullptr, if not needed)
* @return The slope on top of the foundation.
*/
static inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
{
assert(z != nullptr);
Slope s = GetFoundationSlope(tile, z);
*z *= TILE_HEIGHT;
return s;
}
/**
* Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
* @param x X world or tile coordinate (runs in SW direction in the 2D view).
* @param y Y world or tile coordinate (runs in SE direction in the 2D view).
* @param z Z world or tile coordinate (runs in N direction in the 2D view).
* @return Equivalent coordinate in the 2D view.
* @see RemapCoords2
*/
static inline Point RemapCoords(int x, int y, int z)
{
Point pt;
pt.x = (y - x) * 2 * ZOOM_LVL_BASE;
pt.y = (y + x - z) * ZOOM_LVL_BASE;
return pt;
}
/**
* Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
* Same as #RemapCoords, except the Z coordinate is read from the map.
* @param x X world or tile coordinate (runs in SW direction in the 2D view).
* @param y Y world or tile coordinate (runs in SE direction in the 2D view).
* @return Equivalent coordinate in the 2D view.
* @see RemapCoords
*/
static inline Point RemapCoords2(int x, int y)
{
return RemapCoords(x, y, GetSlopePixelZ(x, y));
}
/**
* Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
* Function assumes <tt>z == 0</tt>. For other values of \p z, add \p z to \a y before the call.
* @param x X coordinate of the 2D coordinate.
* @param y Y coordinate of the 2D coordinate.
* @return X and Y components of equivalent world or tile coordinate.
* @note Inverse of #RemapCoords function. Smaller values may get rounded.
* @see InverseRemapCoords2
*/
static inline Point InverseRemapCoords(int x, int y)
{
Point pt = {(y * 2 - x) >> (2 + ZOOM_LVL_SHIFT), (y * 2 + x) >> (2 + ZOOM_LVL_SHIFT)};
return pt;
}
Point InverseRemapCoords2(int x, int y, bool clamp_to_map = false, bool *clamped = nullptr);
uint ApplyFoundationToSlope(Foundation f, Slope *s);
/**
* Applies a foundation to a slope.
*
* @pre Foundation and slope must be valid combined.
* @param f The #Foundation.
* @param s The #Slope to modify.
* @return Increment to the tile Z coordinate.
*/
static inline uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
{
return ApplyFoundationToSlope(f, s) * TILE_HEIGHT;
}
void DrawFoundation(TileInfo *ti, Foundation f);
bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here);
bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here);
void DoClearSquare(TileIndex tile);
void RunTileLoop();
void InitializeLandscape();
void GenerateLandscape(byte mode);
#endif /* LANDSCAPE_H */
|