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

CMap Class Reference

Describes the world map. More...

#include <map.h>

List of all members.


map_fog.cpp - The map fog of war handling.

static CGraphicFogGraphic
 graphic for all the tiles
void CleanFogOfWar ()
 Cleanup memory for fog of war tables.

map.cpp - The map.

void Create ()
 Alocate and initialise map table.
void Init ()
 Build tables for map.
void Clean ()
 Clean the map.
void ClearTile (unsigned short type, const Vec2i &pos)
 Remove wood/rock from the map.
Vec2i MapPixelPosToTilePos (const PixelPos &mapPos) const
 convert map pixelpos coordonates into tilepos
PixelPos TilePosToMapPixelPos_TopLeft (const Vec2i &tilePos) const
 convert tilepos coordonates into map pixel pos (take the top left of the tile)
PixelPos TilePosToMapPixelPos_Center (const Vec2i &tilePos) const
 convert tilepos coordonates into map pixel pos (take the center of the tile)
unsigned short IsTileVisible (const CPlayer &player, const unsigned int index) const
bool IsFieldExplored (const CPlayer &player, const unsigned int index) const
 Check if a field for the user is explored.
void MarkSeenTile (const unsigned int index)
 Mark a tile as seen by the player.
void RegenerateForest ()
 Regenerate the forest.
void Reveal ()
 Reveal the complete map, make everything known.
bool IsTerrainResourceOnMap (const Vec2i &pos, int resource) const
bool IsTerrainResourceOnMap (const Vec2i &pos) const
bool WallOnMap (const Vec2i &pos) const
 Returns true, if wall on the map tile field.
bool HumanWallOnMap (const Vec2i &pos) const
 Returns true, if human wall on the map tile field.
bool OrcWallOnMap (const Vec2i &pos) const
 Returns true, if orc wall on the map tile field.

Public Member Functions

unsigned int getIndex (int x, int y) const
unsigned int getIndex (const Vec2i &pos) const
CMapFieldField (unsigned int index) const
bool CheckMask (const unsigned int index, const int mask) const
 Check if a field flags.
bool CheckMask (const Vec2i &pos, int mask) const
bool IsFieldVisible (const CPlayer &player, const unsigned int index) const
 Check if a field for the user is visible.
unsigned short IsTileVisible (const CPlayer &player, const Vec2i &pos) const
bool IsFieldExplored (const CPlayer &player, const Vec2i &pos)
 Check if a field for the user is explored.
bool IsFieldVisible (const CPlayer &player, const Vec2i &pos)
 Check if a field for the user is visible.
void MarkSeenTile (const Vec2i &pos)
 Mark a tile as seen by the player.
CMapFieldField (int x, int y) const
 Get the MapField at location x,y.
CMapFieldField (const Vec2i &pos) const
bool WaterOnMap (const unsigned int index) const
 Returns true, if water on the map tile field.
bool WaterOnMap (const Vec2i &pos) const
bool CoastOnMap (const unsigned int index) const
 Returns true, if coast on the map tile field.
bool CoastOnMap (const Vec2i &pos) const
void FixSelectionArea (Vec2i &minpos, Vec2i &maxpos)
map_save.cpp - Saving the map.
void Save (CFile &file) const
 Save the map.
map_wall.cpp - The map wall handling.
void HitWall (const Vec2i &pos, unsigned damage)
 Wall is hit.
void RemoveWall (const Vec2i &pos)
 Set wall on field.
void SetWall (const Vec2i &pos, int humanwall)
 Set wall on field.
unit_cache.cpp - The unit cache.
void Insert (CUnit &unit)
 Insert new unit into cache.
void Remove (CUnit &unit)
 Remove unit from cache.
void Clamp (Vec2i &pos) const

Public Attributes

CMapFieldFields
bool NoFogOfWar
 fields on map
CTileset Tileset
 fog of war disabled
std::string TileModelsFileName
 tileset data
CGraphicTileGraphic
 lua filename that loads all tilemodels
CMapInfo Info
 graphic for fog of war

Detailed Description

Describes the world map.

#include "map.h"

This class contains all information about a Stratagus map. A map is a rectangle of any size.

The map class members:

CMap::Fields

An array CMap::Info::Width * CMap::Info::Height of all fields belonging to this map.

CMap::NoFogOfWar

Flag if true, the fog of war is disabled.

CMap::Tileset

Tileset data for the map. See CTileset. This contains all information about the tile.

CMap::TileModelsFileName

Lua filename that loads all tilemodels

CMap::TileGraphic

Graphic for all the tiles

CMap::FogGraphic

Graphic for fog of war

CMap::Info

Descriptive information of the map. See CMapInfo.


Member Function Documentation

unsigned int CMap::getIndex ( int  x,
int  y 
) const [inline]

unsigned int CMap::getIndex ( const Vec2i pos  )  const [inline]

CMapField* CMap::Field ( unsigned int  index  )  const [inline]

void CMap::Create (  ) 

Alocate and initialise map table.

Alocate and initialise map table

void CMap::Init (  ) 

Build tables for map.

Initialize the fog of war. Build tables, setup functions.

void CMap::Clean (  ) 

Clean the map.

Cleanup the map module.

void CMap::CleanFogOfWar (  ) 

Cleanup memory for fog of war tables.

Cleanup the fog of war.

void CMap::ClearTile ( unsigned short  type,
const Vec2i pos 
)

Remove wood/rock from the map.

Remove wood from the map.

Parameters:
type TileType to clear
pos Map tile-position.

Vec2i CMap::MapPixelPosToTilePos ( const PixelPos mapPos  )  const

convert map pixelpos coordonates into tilepos

PixelPos CMap::TilePosToMapPixelPos_TopLeft ( const Vec2i tilePos  )  const

convert tilepos coordonates into map pixel pos (take the top left of the tile)

PixelPos CMap::TilePosToMapPixelPos_Center ( const Vec2i tilePos  )  const

convert tilepos coordonates into map pixel pos (take the center of the tile)

unsigned short CMap::IsTileVisible ( const CPlayer player,
const unsigned int  index 
) const

Find out if a field is seen (By player, or by shared vision) This function will return > 1 with no fog of war.

Parameters:
player Player to check for.
index flat tile index adress.
Returns:
0 unexplored, 1 explored, > 1 visible.

bool CMap::CheckMask ( const unsigned int  index,
const int  mask 
) const [inline]

Check if a field flags.

bool CMap::CheckMask ( const Vec2i pos,
int  mask 
) const [inline]

bool CMap::IsFieldExplored ( const CPlayer player,
const unsigned int  index 
) const

Check if a field for the user is explored.

bool CMap::IsFieldVisible ( const CPlayer player,
const unsigned int  index 
) const [inline]

Check if a field for the user is visible.

unsigned short CMap::IsTileVisible ( const CPlayer player,
const Vec2i pos 
) const [inline]

bool CMap::IsFieldExplored ( const CPlayer player,
const Vec2i pos 
) [inline]

Check if a field for the user is explored.

bool CMap::IsFieldVisible ( const CPlayer player,
const Vec2i pos 
) [inline]

Check if a field for the user is visible.

void CMap::MarkSeenTile ( const unsigned int  index  ) 

Mark a tile as seen by the player.

Path of the current map.

Marks seen tile -- used mainly for the Fog Of War

Parameters:
x Map X tile-position.
y Map Y tile-position.

void CMap::MarkSeenTile ( const Vec2i pos  )  [inline]

Mark a tile as seen by the player.

void CMap::RegenerateForest (  ) 

Regenerate the forest.

Regenerate forest.

void CMap::Reveal (  ) 

Reveal the complete map, make everything known.

Reveal the entire map.

void CMap::Save ( CFile file  )  const

Save the map.

Save the complete map.

Parameters:
file Output file.

CMapField* CMap::Field ( int  x,
int  y 
) const [inline]

Get the MapField at location x,y.

CMapField* CMap::Field ( const Vec2i pos  )  const [inline]

bool CMap::IsTerrainResourceOnMap ( const Vec2i pos,
int  resource 
) const

bool CMap::IsTerrainResourceOnMap ( const Vec2i pos  )  const

void CMap::HitWall ( const Vec2i pos,
unsigned  damage 
)

Wall is hit.

Wall is hit with damage.

Parameters:
pos Map tile-position of wall.
damage Damage done to wall.

void CMap::RemoveWall ( const Vec2i pos  ) 

Set wall on field.

Remove wall from the map.

Parameters:
pos Map position.

void CMap::SetWall ( const Vec2i pos,
int  humanwall 
)

Set wall on field.

Set wall onto the map.

Parameters:
pos Map position.
humanwall Flag, if true set a human wall.
Todo:
FIXME: support for more races.

bool CMap::WallOnMap ( const Vec2i pos  )  const

Returns true, if wall on the map tile field.

Wall on map tile.

Parameters:
pos map tile position.
Returns:
True if wall, false otherwise.

bool CMap::HumanWallOnMap ( const Vec2i pos  )  const

Returns true, if human wall on the map tile field.

Human wall on map tile.

Parameters:
pos map tile position.
Returns:
True if human wall, false otherwise.

bool CMap::OrcWallOnMap ( const Vec2i pos  )  const

Returns true, if orc wall on the map tile field.

Orc wall on map tile.

Parameters:
pos map tile position.
Returns:
True if orcish wall, false otherwise.

bool CMap::WaterOnMap ( const unsigned int  index  )  const [inline]

Returns true, if water on the map tile field.

bool CMap::WaterOnMap ( const Vec2i pos  )  const [inline]

Water on map tile.

Parameters:
pos map tile position.
Returns:
True if water, false otherwise.

bool CMap::CoastOnMap ( const unsigned int  index  )  const [inline]

Returns true, if coast on the map tile field.

bool CMap::CoastOnMap ( const Vec2i pos  )  const [inline]

Coast on map tile.

Parameters:
pos map tile position.
Returns:
True if coast, false otherwise.

void CMap::Insert ( CUnit unit  ) 

Insert new unit into cache.

Insert new unit into cache.

Parameters:
unit Unit pointer to place in cache.

void CMap::Remove ( CUnit unit  ) 

Remove unit from cache.

Remove unit from cache.

Parameters:
unit Unit pointer to remove from cache.

void CMap::Clamp ( Vec2i pos  )  const

void CMap::FixSelectionArea ( Vec2i minpos,
Vec2i maxpos 
) [inline]


Member Data Documentation

fields on map

fog of war disabled

tileset data

lua filename that loads all tilemodels

graphic for all the tiles

graphic for fog of war


The documentation for this class was generated from the following files:
(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.