_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tile.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2008 by Vladi Shabanski, Lutz Sammer,
14 // Jimmy Salmon and Rafal Bursig
15 //
16 // This program is free software; you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation; only version 2 of the License.
19 //
20 // This program is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU General Public License for more details.
24 //
25 // You should have received a copy of the GNU General Public License
26 // along with this program; if not, write to the Free Software
27 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 // 02111-1307, USA.
29 
30 #ifndef __MAP_TILE_H__
31 #define __MAP_TILE_H__
32 
34 
35 
36 /*----------------------------------------------------------------------------
37 -- Documentation
38 ----------------------------------------------------------------------------*/
39 
131 /*----------------------------------------------------------------------------
132 -- Includes
133 ----------------------------------------------------------------------------*/
134 
135 #ifndef __UNIT_CACHE_H__
136 #include "unit_cache.h"
137 #endif
138 
139 #include <vec2i.h>
140 
141 class CFile;
142 class CPlayer;
143 class CTileset;
144 struct lua_State;
145 
146 /*----------------------------------------------------------------------------
147 -- Map - field
148 ----------------------------------------------------------------------------*/
149 
151 {
152 public:
154  {
155  memset(Visible, 0, sizeof(Visible));
156  memset(VisCloak, 0, sizeof(VisCloak));
157  memset(Radar, 0, sizeof(Radar));
158  memset(RadarJammer, 0, sizeof(RadarJammer));
159  }
160 
162  bool IsExplored(const CPlayer &player) const;
163 
165  bool IsVisible(const CPlayer &player) const;
166  bool IsTeamVisible(const CPlayer &player) const;
175  unsigned char TeamVisibilityState(const CPlayer &player) const;
176 
177 public:
178  unsigned short SeenTile;
179  unsigned short Visible[PlayerMax];
180  unsigned char VisCloak[PlayerMax];
181  unsigned char Radar[PlayerMax];
182  unsigned char RadarJammer[PlayerMax];
183 };
184 
187 {
188 public:
189  CMapField();
190 
191  void Save(CFile &file) const;
192  void parse(lua_State *l);
193 
194  void setTileIndex(const CTileset &tileset, unsigned int tileIndex, int value);
195 
196  unsigned int getGraphicTile() const { return tile; }
197 
199  bool CheckMask(int mask) const;
200 
202  bool WaterOnMap() const;
203 
205  bool CoastOnMap() const;
206 
208  bool ForestOnMap() const;
209 
211  bool RockOnMap() const;
212 
213  bool isAWall() const;
214  bool isHuman() const;
215  bool isAHumanWall() const;
216  bool isAOrcWall() const;
217 
218  bool IsTerrainResourceOnMap(int resource) const;
219  bool IsTerrainResourceOnMap() const;
220 
221  unsigned char getCost() const { return cost; }
222  unsigned int getFlag() const { return Flags; }
223  void setGraphicTile(unsigned int tile) { this->tile = tile; }
224 private:
225 #ifdef DEBUG
226  unsigned int tilesetTile;
227 #endif
228  unsigned short tile;
229 public:
230  unsigned short Flags;
231 private:
232  unsigned char cost;
233 public:
234  // FIXME: Value should be removed, walls and regeneration can be handled differently.
235  unsigned char Value;
237 
239 };
240 
241 extern PixelSize PixelTileSize;
242 
244 
245 #endif // !__MAP_TILE_H__
246 
CMapFieldPlayerInfo playerInfo
A unit on the map field.
Definition: tile.h:238
unsigned short SeenTile
Definition: tile.h:178
bool isAOrcWall() const
Definition: mapfield.cpp:250
CUnitCache UnitCache
HP for walls/ Wood Regeneration.
Definition: tile.h:236
bool CheckMask(int mask) const
Check if a field flags.
Definition: mapfield.cpp:207
void setGraphicTile(unsigned int tile)
Definition: tile.h:223
unsigned char Radar[PlayerMax]
Visiblity for cloaking.
Definition: tile.h:181
bool isAWall() const
Definition: mapfield.cpp:236
#define PlayerMax
Definition: stratagus.h:157
Definition: tile.h:150
unsigned int getGraphicTile() const
Definition: tile.h:196
unsigned short Visible[PlayerMax]
last seen tile (FOW)
Definition: tile.h:179
Tileset definition.
Definition: tileset.h:118
CMapField()
Definition: mapfield.cpp:48
Definition: iolib.h:101
void parse(lua_State *l)
Definition: mapfield.cpp:153
bool IsExplored(const CPlayer &player) const
Check if a field for the user is explored.
Definition: mapfield.cpp:283
bool WaterOnMap() const
Returns true, if water on the map tile field.
Definition: mapfield.cpp:213
bool CoastOnMap() const
Returns true, if coast on the map tile field.
Definition: mapfield.cpp:219
unsigned char VisCloak[PlayerMax]
Seen counter 0 unexplored.
Definition: tile.h:180
CMapFieldPlayerInfo()
Definition: tile.h:153
bool isHuman() const
Definition: mapfield.cpp:240
bool RockOnMap() const
Returns true, if coast on the map tile field.
Definition: mapfield.cpp:231
void Save(CFile &file) const
Definition: mapfield.cpp:97
void setTileIndex(const CTileset &tileset, unsigned int tileIndex, int value)
Definition: mapfield.cpp:78
unsigned int getFlag() const
Definition: tile.h:222
bool IsTeamVisible(const CPlayer &player) const
Definition: mapfield.cpp:294
PixelSize PixelTileSize
unsigned char getCost() const
Definition: tile.h:221
Definition: unit_cache.h:50
unsigned char TeamVisibilityState(const CPlayer &player) const
Definition: mapfield.cpp:260
unsigned char Value
unit cost to move in this tile
Definition: tile.h:235
Diplomacy states for CommandDiplomacy.
Definition: player.h:79
bool isAHumanWall() const
Definition: mapfield.cpp:245
bool IsTerrainResourceOnMap() const
Definition: mapfield.cpp:68
unsigned short Flags
graphic tile number
Definition: tile.h:230
Describes a field of the map.
Definition: tile.h:186
unsigned char RadarJammer[PlayerMax]
Visiblity for radar.
Definition: tile.h:182
bool ForestOnMap() const
Returns true, if water on the map tile field.
Definition: mapfield.cpp:225
bool IsVisible(const CPlayer &player) const
Definition: mapfield.cpp:288
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.