before adding day/night lighting
[oweals/minetest.git] / src / tile.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef TILE_HEADER
21 #define TILE_HEADER
22
23 #include "common_irrlicht.h"
24 #include "utility.h"
25
26 // TileID is supposed to be stored in a u16
27
28 enum TileID
29 {
30         TILE_NONE, // Nothing shown
31         TILE_STONE,
32         TILE_WATER,
33         TILE_GRASS,
34         TILE_TREE,
35         TILE_LEAVES,
36         TILE_GRASS_FOOTSTEPS,
37         TILE_MESE,
38         TILE_MUD,
39         TILE_TREE_TOP,
40         TILE_MUD_WITH_GRASS,
41         TILE_CLOUD,
42         
43         // Count of tile ids
44         TILES_COUNT
45 };
46
47 enum TileSpecialFeature
48 {
49         TILEFEAT_NONE,
50         TILEFEAT_CRACK,
51 };
52
53 struct TileCrackParam
54 {
55         bool operator==(TileCrackParam &other)
56         {
57                 return progression == other.progression;
58         }
59
60         u16 progression;
61 };
62
63 struct TileSpec
64 {
65         TileSpec()
66         {
67                 id = TILE_NONE;
68                 feature = TILEFEAT_NONE;
69         }
70
71         bool operator==(TileSpec &other)
72         {
73                 if(id != other.id)
74                         return false;
75                 if(feature != other.feature)
76                         return false;
77                 if(feature == TILEFEAT_NONE)
78                         return true;
79                 if(feature == TILEFEAT_CRACK)
80                 {
81                         return param.crack == other.param.crack;
82                 }
83                 // Invalid feature
84                 assert(0);
85                 return false;
86         }
87
88         u16 id; // Id in g_tile_materials, TILE_NONE=none
89         enum TileSpecialFeature feature;
90         union
91         {
92                 TileCrackParam crack;
93         } param;
94 };
95
96 // A mapping from tiles to names of cached textures
97 extern const char * g_tile_texture_names[TILES_COUNT];
98
99 // A mapping from tiles to materials
100 // Initialized at run-time.
101 extern video::SMaterial g_tile_materials[TILES_COUNT];
102
103 /*
104         Functions
105 */
106
107 // Initializes g_tile_materials
108 void tile_materials_preload(TextureCache &cache);
109
110 #endif