Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Map Class Reference

#include <map.h>

Inheritance diagram for Map:

Persistence List of all members.

Public Member Functions

 Map (const uint width, const uint height)
void SaveTo (std::fstream &rfs)
void LoadFrom (std::fstream &rfs)
OPENCITY_ERR_CODE ChangeHeight (const uint &rcuiW, const uint &rcuiH, const OPENCITY_MAP_VARIATION &enumVar)
void SetLayer (const Layer *layer)
const OC_BYTE & GetLinearHeight (const uint &rcuiIndex) const
const uint GetMaxLinear () const
void GetSquareHeight (const uint &rcuiW, const uint &rcuiH, OC_BYTE tabH[]) const
const signed char GetSquareMinHeight (const uint &rcuiW, const uint &rcuiL) const
const signed char GetSquareMaxHeight (const uint &rcuiW, const uint &rcuiH) const
const bool IsSquarePlane (const uint &rcuiW, const uint &rcuiH) const
const bool IsSquareLinearPlane (const uint &rcuiLinearIndex)
const bool GetNeighbourWH (const uint &rcuiMapW, const uint &rcuiMapH, uint &ruiNbrW, uint &ruiNbrH, const OPENCITY_DIRECTION &enumDir) const
void GetPossibleWH (uint &rW, uint &rH, const int &deltaW, const int &deltaH) const

Private Member Functions

void _Linear2WH (const uint &linear, uint &w, uint &h) const
uint _WH2Linear (const uint &w, const uint &h, uint &linear) const

Private Attributes

uint _uiMapWidth
uint _uiMapHeight
OC_BYTE * _btabSquareHeight
const Layer_pclayer
 we need this to know if a square can be safely raised up or lowered down

Detailed Description

A "Map" object contains an array of square's OY height. Each square has 4 values of heights. They match the map square's corners.

Definition at line 33 of file map.h.

Member Function Documentation

void Map::_Linear2WH const uint &  linear,
uint &  w,
uint &  h
const [private]

Convert the linear index to the square's W,H coordinates

Definition at line 343 of file map.cpp.

uint Map::_WH2Linear const uint &  w,
const uint &  h,
uint &  linear
const [inline, private]

Convert the W,H coordinates to the linear index according to the datas stocked inside the class

Must be dishtinguished from structure linear index

Definition at line 355 of file map.cpp.

Referenced by ChangeHeight(), and GetSquareHeight().

OPENCITY_ERR_CODE Map::ChangeHeight const uint &  rcuiW,
const uint &  rcuiH,

Change the square's OY heights. The square is designated by its W,H coordinates. ( OX, OZ OpenGL coordinates )

Definition at line 103 of file map.cpp.

References _pclayer, _WH2Linear(), Layer::ContainStructure(), GetPossibleWH(), and GetSquareHeight().

const bool Map::GetNeighbourWH const uint &  rcuiMapW,
const uint &  rcuiMapH,
uint &  ruiNbrW,
uint &  ruiNbrH,

Calculate the WH coordinates of the neighbour square given the direction

true if the WH of the neighbour were found false otherwise (the current square is located at the edge of the map)

Definition at line 272 of file map.cpp.

Referenced by BuildingLayer::_BuildPathStructure().

void Map::GetPossibleWH uint &  rW,
uint &  rH,
const int &  deltaW,
const int &  deltaH

Calculate the new possible WH given the changes. If the delta values are too big to be incorporated in the new WH, the new WH values are cliped to the map edges

Definition at line 318 of file map.cpp.

Referenced by BuildingLayer::_DestroyStructure(), ChangeHeight(), and Simulator::CheckRange().

void Map::GetSquareHeight const uint &  rcuiW,
const uint &  rcuiH,
OC_BYTE  tabH[]

Get all the 4 heights of a square designated by its W,H. The corner's height is returned in the following order: left-up, left-down, right-down, right-up

rcuiW,rcuiH The W, L (x, y) map coordinates
tabH The height table

Definition at line 187 of file map.cpp.

References _WH2Linear().

Referenced by Renderer::_DisplayTerrain(), ChangeHeight(), GraphicManager::DisplayGC(), GraphicManager::DisplayStructure(), and GraphicManager::DisplayTerrain().

void Map::LoadFrom std::fstream &  rfs  )  [virtual]

Load the data from the specified stream

rfs A reference to a file stream which is ready for reading
See also:

Implements Persistence.

Definition at line 83 of file map.cpp.

Referenced by City::_Load().

void Map::SaveTo std::fstream &  rfs  )  [virtual]

Save the data to the specified fstream

rfs A reference to a file stream which is ready for writing
See also:

Implements Persistence.

Definition at line 68 of file map.cpp.

Referenced by City::_Save().

The documentation for this class was generated from the following files:
Generated on Sat Nov 11 10:21:11 2006 for OpenCity by  doxygen 1.4.2