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

Public Member Functions | Public Attributes | List of all members
CMap Class Reference

Describes the world map. More...

#include <map.h>

Public Member Functions

unsigned int getIndex (int x, int y) const
 
unsigned int getIndex (const Vec2i &pos) const
 
CMapFieldField (unsigned int index) const
 
CMapFieldField (int x, int y) const
 Get the MapField at location x,y. More...
 
CMapFieldField (const Vec2i &pos) const
 
bool isInitialized () const
 
void FixSelectionArea (Vec2i &minpos, Vec2i &maxpos)
 
map_wall.cpp - The map wall handling.
void HitWall (const Vec2i &pos, unsigned damage)
 Wall is hit. More...
 
void RemoveWall (const Vec2i &pos)
 Set wall on field. More...
 
void SetWall (const Vec2i &pos, bool humanwall)
 Set wall on field. More...
 
unit_cache.cpp - The unit cache.
void Insert (CUnit &unit)
 Insert new unit into cache. More...
 
void Remove (CUnit &unit)
 Remove unit from cache. More...
 
void Clamp (Vec2i &pos) const
 

Public Attributes

CMapFieldFields
 
bool NoFogOfWar
 fields on map More...
 
CTilesetTileset
 fog of war disabled More...
 
std::string TileModelsFileName
 tileset data More...
 
CGraphicTileGraphic
 lua filename that loads all tilemodels More...
 
bool isMapInitialized { false }
 graphic for all the tiles More...
 
CMapInfo Info
 

map.cpp - The map.

 CMap ()
 
 ~CMap ()
 
void AllocateTileset ()
 
void Create ()
 Alocate and initialise map table. More...
 
void Init ()
 Build tables for map. More...
 
void Clean (const bool isHardClean=false)
 Clean the map. More...
 
void ClearTile (const Vec2i &tilePos)
 Remove wood, rock or wall from the map and update nearby unit's vision if needed. More...
 
Vec2i MapPixelPosToTilePos (const PixelPos &mapPos) const
 convert map pixelpos coordonates into tilepos More...
 
PixelPos TilePosToMapPixelPos_TopLeft (const Vec2i &tilePos) const
 convert tilepos coordonates into map pixel pos (take the top left of the tile) More...
 
PixelPos TilePosToMapPixelPos_Center (const Vec2i &tilePos) const
 convert tilepos coordonates into map pixel pos (take the center of the tile) More...
 
void MarkSeenTile (CMapField &mf)
 Mark a tile as seen by the player. More...
 
void RegenerateForest ()
 Regenerate the forest. More...
 
void Reveal (MapRevealModes mode=MapRevealModes::cKnown)
 Set map reveal mode: hidden/known/fully explored. More...
 
void Save (CFile &file) const
 Save the map. More...
 
bool WallOnMap (const Vec2i &pos) const
 Returns true, if wall on the map tile field. More...
 
bool HumanWallOnMap (const Vec2i &pos) const
 Returns true, if human wall on the map tile field. More...
 
bool OrcWallOnMap (const Vec2i &pos) const
 Returns true, if orc wall on the map tile field. More...
 

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.

Constructor & Destructor Documentation

◆ CMap()

CMap::CMap ( )

◆ ~CMap()

CMap::~CMap ( )

Member Function Documentation

◆ AllocateTileset()

void CMap::AllocateTileset ( )

◆ Clamp()

void CMap::Clamp ( Vec2i pos) const

◆ Clean()

void CMap::Clean ( const bool  isHardClean = false)

Clean the map.

Cleanup the map module.

◆ ClearTile()

void CMap::ClearTile ( const Vec2i tilePos)

Remove wood, rock or wall from the map and update nearby unit's vision if needed.

Remove Wood, Rock or Wall tile from the map It checks if field is opaque and recalc vision for nearby units

Parameters
tilePosMap tile-position.

◆ Create()

void CMap::Create ( )

Alocate and initialise map table.

Alocate and initialise map table

◆ Field() [1/3]

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

◆ Field() [2/3]

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

Get the MapField at location x,y.

◆ Field() [3/3]

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

◆ FixSelectionArea()

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

◆ getIndex() [1/2]

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

◆ getIndex() [2/2]

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

◆ HitWall()

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

Wall is hit.

Wall is hit with damage.

Parameters
posMap tile-position of wall.
damageDamage done to wall.

◆ HumanWallOnMap()

bool CMap::HumanWallOnMap ( const Vec2i pos) const

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

Human wall on map tile.

Parameters
posmap tile position.
Returns
True if human wall, false otherwise.

◆ Init()

void CMap::Init ( )

Build tables for map.

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

◆ Insert()

void CMap::Insert ( CUnit unit)

Insert new unit into cache.

Insert new unit into cache.

Parameters
unitUnit pointer to place in cache.

◆ isInitialized()

bool CMap::isInitialized ( ) const
inline

◆ MapPixelPosToTilePos()

Vec2i CMap::MapPixelPosToTilePos ( const PixelPos mapPos) const

convert map pixelpos coordonates into tilepos

◆ MarkSeenTile()

void CMap::MarkSeenTile ( CMapField mf)

Mark a tile as seen by the player.

Path of the current map.

Marks seen tile – used mainly for the Fog Of War

Parameters
mfMapField-position.

◆ OrcWallOnMap()

bool CMap::OrcWallOnMap ( const Vec2i pos) const

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

Orc wall on map tile.

Parameters
posmap tile position.
Returns
True if orcish wall, false otherwise.

◆ RegenerateForest()

void CMap::RegenerateForest ( )

Regenerate the forest.

Regenerate forest.

◆ Remove()

void CMap::Remove ( CUnit unit)

Remove unit from cache.

Remove unit from cache.

Parameters
unitUnit pointer to remove from cache.

◆ RemoveWall()

void CMap::RemoveWall ( const Vec2i pos)

Set wall on field.

Remove wall from the map.

Parameters
posMap position.

FIXME: support more walls of different races.

◆ Reveal()

void CMap::Reveal ( MapRevealModes  mode = MapRevealModes::cKnown)

Set map reveal mode: hidden/known/fully explored.

Reveal the entire map.

We can't do "unrevealing" yet

◆ Save()

void CMap::Save ( CFile file) const

Save the map.

Save the complete map.

Parameters
fileOutput file.

◆ SetWall()

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

Set wall on field.

Set wall onto the map.

Parameters
posMap position.
humanwallFlag, if true set a human wall.
Todo:
FIXME: support for more races.

Refresh vision of nearby units in case is walls are set as opaque field

Refresh vision of nearby units in case is walls are set as opaque field

◆ TilePosToMapPixelPos_Center()

PixelPos CMap::TilePosToMapPixelPos_Center ( const Vec2i tilePos) const

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

◆ TilePosToMapPixelPos_TopLeft()

PixelPos CMap::TilePosToMapPixelPos_TopLeft ( const Vec2i tilePos) const

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

◆ WallOnMap()

bool CMap::WallOnMap ( const Vec2i pos) const

Returns true, if wall on the map tile field.

Wall on map tile.

Parameters
posmap tile position.
Returns
True if wall, false otherwise.

Member Data Documentation

◆ Fields

CMapField* CMap::Fields

◆ Info

CMapInfo CMap::Info

◆ isMapInitialized

bool CMap::isMapInitialized { false }

graphic for all the tiles

◆ NoFogOfWar

bool CMap::NoFogOfWar

fields on map

◆ TileGraphic

CGraphic* CMap::TileGraphic

lua filename that loads all tilemodels

◆ TileModelsFileName

std::string CMap::TileModelsFileName

tileset data

◆ Tileset

CTileset* CMap::Tileset

fog of war disabled


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.