# landscape.h

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef LANDSCAPE_H
    00013 #define LANDSCAPE_H
    00014
    00015 #include "core/geometry_type.hpp"
    00016 #include "tile_cmd.h"
    00017
    00018 static const uint SNOW_LINE_MONTHS = 12;
    00019 static const uint SNOW_LINE_DAYS   = 32;
    00020
    00025 struct SnowLine {
    00026   byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS];
    00027   byte highest_value;
    00028   byte lowest_value;
    00029 };
    00030
    00031 bool IsSnowLineSet();
    00032 void SetSnowLine(byte table[SNOW_LINE_MONTHS][SNOW_LINE_DAYS]);
    00033 byte GetSnowLine();
    00034 byte HighestSnowLine();
    00035 byte LowestSnowLine();
    00036 void ClearSnowLine();
    00037
    00038 int GetSlopeZInCorner(Slope tileh, Corner corner);
    00039 Slope GetFoundationSlope(TileIndex tile, int *z = NULL);
    00040
    00041 uint GetPartialPixelZ(int x, int y, Slope corners);
    00042 int GetSlopePixelZ(int x, int y);
    00043 void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2);
    00044
    00054 static inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
    00055 {
    00056   return GetSlopeZInCorner(tileh, corner) * TILE_HEIGHT;
    00057 }
    00058
    00067 static inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
    00068 {
    00069   assert(z != NULL);
    00070   Slope s = GetFoundationSlope(tile, z);
    00071   *z *= TILE_HEIGHT;
    00072   return s;
    00073 }
    00074
    00083 static inline Point RemapCoords(int x, int y, int z)
    00084 {
    00085   Point pt;
    00086   pt.x = (y - x) * 2 * ZOOM_LVL_BASE;
    00087   pt.y = (y + x - z) * ZOOM_LVL_BASE;
    00088   return pt;
    00089 }
    00090
    00099 static inline Point RemapCoords2(int x, int y)
    00100 {
    00101   return RemapCoords(x, y, GetSlopePixelZ(x, y));
    00102 }
    00103
    00112 static inline Point InverseRemapCoords(int x, int y)
    00113 {
    00114   Point pt = {(y * 2 - x) >> (2 + ZOOM_LVL_SHIFT), (y * 2 + x) >> (2 + ZOOM_LVL_SHIFT)};
    00115   return pt;
    00116 }
    00117
    00118 uint ApplyFoundationToSlope(Foundation f, Slope *s);
    00127 static inline uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
    00128 {
    00129   return ApplyFoundationToSlope(f, s) * TILE_HEIGHT;
    00130 }
    00131
    00132 void DrawFoundation(TileInfo *ti, Foundation f);
    00133 bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here);
    00134 bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here);
    00135
    00136 void DoClearSquare(TileIndex tile);
    00137 void RunTileLoop();
    00138
    00139 void InitializeLandscape();
    00140 void GenerateLandscape(byte mode);
    00141
    00142 #endif /* LANDSCAPE_H */