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

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 isOpaque() const;
200 
202  bool CheckMask(int mask) const;
203 
205  bool WaterOnMap() const;
206 
208  bool CoastOnMap() const;
209 
211  bool ForestOnMap() const;
212 
214  bool Cost4OnMap() const;
215 
217  bool Cost5OnMap() const;
218 
220  bool Cost6OnMap() const;
221 
223  bool RockOnMap() const;
224 
226  bool isDecorative() const;
227 
228  bool isAWall() const;
229  bool isHuman() const;
230  bool isAHumanWall() const;
231  bool isAOrcWall() const;
232 
233  bool IsTerrainResourceOnMap(int resource) const;
234  bool IsTerrainResourceOnMap() const;
235 
236  unsigned char getCost() const { return cost; }
237  unsigned int getFlag() const { return Flags; }
238  void setGraphicTile(unsigned int tile) { this->tile = tile; }
239 #ifdef DEBUG
240  int64_t lastAStarCost;
241 #endif
242 private:
243 #ifdef DEBUG
244  unsigned int tilesetTile;
245 #endif
246  unsigned short tile;
247 public:
248  unsigned int Flags;
249 private:
250  unsigned char cost;
251 public:
252  unsigned int Value;
254 
256 };
257 
258 extern PixelSize PixelTileSize;
259 
261 
262 #endif // !__MAP_TILE_H__
263 
CPlayer
Diplomacy states for CommandDiplomacy.
Definition: player.h:83
CMapField::isAWall
bool isAWall() const
Definition: mapfield.cpp:312
CMapField::isHuman
bool isHuman() const
Definition: mapfield.cpp:316
CMapField::isOpaque
bool isOpaque() const
Check if a field is opaque for field of view.
Definition: mapfield.cpp:249
CMapFieldPlayerInfo::CMapFieldPlayerInfo
CMapFieldPlayerInfo()
Definition: tile.h:153
CMapFieldPlayerInfo::SeenTile
unsigned short SeenTile
Definition: tile.h:178
CUnitCache
Definition: unit_cache.h:50
CMapField::getCost
unsigned char getCost() const
Definition: tile.h:236
CMapField::Cost4OnMap
bool Cost4OnMap() const
Returns true, if any terrain resource giving Cost4 on the map tile field.
Definition: mapfield.cpp:281
CMapFieldPlayerInfo::Radar
unsigned char Radar[PlayerMax]
Visiblity for cloaking.
Definition: tile.h:181
CMapField::Cost6OnMap
bool Cost6OnMap() const
Returns true, if any terrain resource giving Cost6 on the map tile field.
Definition: mapfield.cpp:295
CMapFieldPlayerInfo::IsTeamVisible
bool IsTeamVisible(const CPlayer &player) const
Definition: mapfield.cpp:370
CMapField::WaterOnMap
bool WaterOnMap() const
Returns true, if water on the map tile field.
Definition: mapfield.cpp:262
CMapField::Value
unsigned int Value
unit cost to move in this tile
Definition: tile.h:252
vec2i.h
CMapField::Flags
unsigned int Flags
graphic tile number
Definition: tile.h:248
CMapFieldPlayerInfo::VisCloak
unsigned char VisCloak[PlayerMax]
Seen counter 0 unexplored.
Definition: tile.h:180
CMapField::RockOnMap
bool RockOnMap() const
Returns true, if coast on the map tile field.
Definition: mapfield.cpp:301
CMapField::isAOrcWall
bool isAOrcWall() const
Definition: mapfield.cpp:326
Vec2T< int >
CMapField::parse
void parse(lua_State *l)
Definition: mapfield.cpp:183
CMapFieldPlayerInfo
Definition: tile.h:150
PlayerMax
constexpr unsigned char PlayerMax
Definition: settings.h:62
CMapField::playerInfo
CMapFieldPlayerInfo playerInfo
A unit on the map field.
Definition: tile.h:255
CMapField::UnitCache
CUnitCache UnitCache
HP for walls/Wood Regeneration, value of stored resource for forest or harvestable terrain.
Definition: tile.h:253
CMapField::Cost5OnMap
bool Cost5OnMap() const
Returns true, if any terrain resource giving Cost5 on the map tile field.
Definition: mapfield.cpp:288
CMapField::setGraphicTile
void setGraphicTile(unsigned int tile)
Definition: tile.h:238
CMapField::IsTerrainResourceOnMap
bool IsTerrainResourceOnMap() const
Definition: mapfield.cpp:75
CMapField::Save
void Save(CFile &file) const
Definition: mapfield.cpp:115
CMapField::ForestOnMap
bool ForestOnMap() const
Returns true, if water on the map tile field.
Definition: mapfield.cpp:274
CMapField::CheckMask
bool CheckMask(int mask) const
Check if a field flags.
Definition: mapfield.cpp:256
CMapField::setTileIndex
void setTileIndex(const CTileset &tileset, unsigned int tileIndex, int value)
Definition: mapfield.cpp:85
unit_cache.h
CMapField::isAHumanWall
bool isAHumanWall() const
Definition: mapfield.cpp:321
CMapFieldPlayerInfo::Visible
unsigned short Visible[PlayerMax]
last seen tile (FOW)
Definition: tile.h:179
CMapField::CoastOnMap
bool CoastOnMap() const
Returns true, if coast on the map tile field.
Definition: mapfield.cpp:268
CMapFieldPlayerInfo::TeamVisibilityState
unsigned char TeamVisibilityState(const CPlayer &player) const
Definition: mapfield.cpp:336
CMapField::isDecorative
bool isDecorative() const
Returns true if the field should not need mixing with the surroundings.
Definition: mapfield.cpp:307
CMapFieldPlayerInfo::RadarJammer
unsigned char RadarJammer[PlayerMax]
Visiblity for radar.
Definition: tile.h:182
CMapField::getGraphicTile
unsigned int getGraphicTile() const
Definition: tile.h:196
CTileset
Tileset definition.
Definition: tileset.h:126
CMapField
Describes a field of the map.
Definition: tile.h:186
CMapFieldPlayerInfo::IsVisible
bool IsVisible(const CPlayer &player) const
Definition: mapfield.cpp:364
PixelTileSize
PixelSize PixelTileSize
CMapField::getFlag
unsigned int getFlag() const
Definition: tile.h:237
CMapFieldPlayerInfo::IsExplored
bool IsExplored(const CPlayer &player) const
Check if a field for the user is explored.
Definition: mapfield.cpp:359
CFile
Definition: iolib.h:102
CMapField::CMapField
CMapField()
Definition: mapfield.cpp:49
(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.