OpenTTD
landscape.h
Go to the documentation of this file.
1 /* $Id: landscape.h 23735 2012-01-03 20:26:05Z rubidium $ */
2 
3 /*
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/>.
8  */
9 
12 #ifndef LANDSCAPE_H
13 #define LANDSCAPE_H
14 
15 #include "core/geometry_type.hpp"
16 #include "tile_cmd.h"
17 
18 static const uint SNOW_LINE_MONTHS = 12;
19 static const uint SNOW_LINE_DAYS = 32;
20 
25 struct SnowLine {
28  byte lowest_value;
29 };
30 
31 bool IsSnowLineSet();
33 byte GetSnowLine();
34 byte HighestSnowLine();
35 byte LowestSnowLine();
36 void ClearSnowLine();
37 
38 int GetSlopeZInCorner(Slope tileh, Corner corner);
39 Slope GetFoundationSlope(TileIndex tile, int *z = NULL);
40 
41 uint GetPartialPixelZ(int x, int y, Slope corners);
42 int GetSlopePixelZ(int x, int y);
43 void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2);
44 
54 static inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
55 {
56  return GetSlopeZInCorner(tileh, corner) * TILE_HEIGHT;
57 }
58 
67 static inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
68 {
69  assert(z != NULL);
70  Slope s = GetFoundationSlope(tile, z);
71  *z *= TILE_HEIGHT;
72  return s;
73 }
74 
83 static inline Point RemapCoords(int x, int y, int z)
84 {
85  Point pt;
86  pt.x = (y - x) * 2 * ZOOM_LVL_BASE;
87  pt.y = (y + x - z) * ZOOM_LVL_BASE;
88  return pt;
89 }
90 
99 static inline Point RemapCoords2(int x, int y)
100 {
101  return RemapCoords(x, y, GetSlopePixelZ(x, y));
102 }
103 
112 static inline Point InverseRemapCoords(int x, int y)
113 {
114  Point pt = {(y * 2 - x) >> (2 + ZOOM_LVL_SHIFT), (y * 2 + x) >> (2 + ZOOM_LVL_SHIFT)};
115  return pt;
116 }
117 
128 {
129  return ApplyFoundationToSlope(f, s) * TILE_HEIGHT;
130 }
131 
132 void DrawFoundation(TileInfo *ti, Foundation f);
133 bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here);
134 bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here);
135 
136 void DoClearSquare(TileIndex tile);
137 void RunTileLoop();
138 
139 void InitializeLandscape();
140 void GenerateLandscape(byte mode);
141 
142 #endif /* LANDSCAPE_H */