ManaPlus
Public Member Functions | Private Attributes | Friends
MapHeights Class Reference

#include <mapheights.h>

Inheritance diagram for MapHeights:
MemoryCounter

Public Member Functions

 MapHeights (const int width, const int height)
 
 ~MapHeights ()
 
void setHeight (const int x, const int y, const uint8_t height)
 
uint8_t getHeight (const int x, const int y) const
 
int calcMemoryLocal () const
 
std::string getCounterName () const
 
- Public Member Functions inherited from MemoryCounter
 MemoryCounter ()
 
virtual ~MemoryCounter ()
 
int calcMemory (const int level) const
 
virtual int calcMemoryChilds (const int level) const
 

Private Attributes

int mWidth
 
int mHeight
 
uint8_t * mTiles
 

Friends

class Map
 

Detailed Description

Definition at line 31 of file mapheights.h.

Constructor & Destructor Documentation

◆ MapHeights()

MapHeights::MapHeights ( const int  width,
const int  height 
)

Definition at line 26 of file mapheights.cpp.

27  :
28  MemoryCounter(),
29  mWidth(width),
30  mHeight(height),
31  mTiles(new uint8_t[mWidth * mHeight])
32 {
33  memset(mTiles, 0, mWidth * mHeight);
34 }
int mWidth
Definition: mapheights.h:56
int mHeight
Definition: mapheights.h:57
uint8_t * mTiles
Definition: mapheights.h:58

References mHeight, mTiles, and mWidth.

Referenced by calcMemoryLocal().

◆ ~MapHeights()

MapHeights::~MapHeights ( )

Definition at line 36 of file mapheights.cpp.

37 {
38  delete [] mTiles;
39 }

References mTiles.

Member Function Documentation

◆ calcMemoryLocal()

int MapHeights::calcMemoryLocal ( ) const
virtual

Reimplemented from MemoryCounter.

Definition at line 46 of file mapheights.cpp.

47 {
48  return static_cast<int>(sizeof(MapHeights)) +
49  mWidth * mHeight;
50 }
MapHeights(const int width, const int height)
Definition: mapheights.cpp:26

References MapHeights(), mHeight, and mWidth.

◆ getCounterName()

std::string MapHeights::getCounterName ( ) const
inlinevirtual

Reimplemented from MemoryCounter.

Definition at line 52 of file mapheights.h.

53  { return "heights layer"; }

◆ getHeight()

uint8_t MapHeights::getHeight ( const int  x,
const int  y 
) const
inline

Definition at line 44 of file mapheights.h.

45  {
46  return (x < mWidth &&
47  y < mHeight) ? mTiles[x + y * mWidth] : CAST_U8(0U);
48  }
#define CAST_U8
Definition: cast.h:27

References CAST_U8, mHeight, mTiles, mWidth, x, and y.

◆ setHeight()

void MapHeights::setHeight ( const int  x,
const int  y,
const uint8_t  height 
)

Definition at line 41 of file mapheights.cpp.

42 {
43  mTiles[x + y * mWidth] = height;
44 }

References mTiles, mWidth, x, and y.

Referenced by setTile().

Friends And Related Function Documentation

◆ Map

friend class Map
friend

Definition at line 34 of file mapheights.h.

Field Documentation

◆ mHeight

int MapHeights::mHeight
private

Definition at line 57 of file mapheights.h.

Referenced by calcMemoryLocal(), getHeight(), and MapHeights().

◆ mTiles

uint8_t* MapHeights::mTiles
private

Definition at line 58 of file mapheights.h.

Referenced by getHeight(), MapHeights(), setHeight(), and ~MapHeights().

◆ mWidth

int MapHeights::mWidth
private

Definition at line 56 of file mapheights.h.

Referenced by calcMemoryLocal(), getHeight(), MapHeights(), and setHeight().


The documentation for this class was generated from the following files: