# 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 uint GetPartialZ(int x, int y, Slope corners);
    00039 uint GetSlopeZ(int x, int y);
    00040 void GetSlopeZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2);
    00041 int GetSlopeZInCorner(Slope tileh, Corner corner);
    00042 Slope GetFoundationSlope(TileIndex tile, uint *z);
    00043
    00052 static inline Point RemapCoords(int x, int y, int z)
    00053 {
    00054   Point pt;
    00055   pt.x = (y - x) * 2;
    00056   pt.y = y + x - z;
    00057   return pt;
    00058 }
    00059
    00068 static inline Point RemapCoords2(int x, int y)
    00069 {
    00070   return RemapCoords(x, y, GetSlopeZ(x, y));
    00071 }
    00072
    00081 static inline Point InverseRemapCoords(int x, int y)
    00082 {
    00083   Point pt = {(y * 2 - x) >> 2, (y * 2 + x) >> 2};
    00084   return pt;
    00085 }
    00086
    00087 uint ApplyFoundationToSlope(Foundation f, Slope *s);
    00088 void DrawFoundation(TileInfo *ti, Foundation f);
    00089 bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here);
    00090 bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here);
    00091
    00092 void DoClearSquare(TileIndex tile);
    00093 void RunTileLoop();
    00094
    00095 void InitializeLandscape();
    00096 void GenerateLandscape(byte mode);
    00097
    00098 #endif /* LANDSCAPE_H */