ManaPlus
Public Member Functions | Private Attributes
WalkLayer Class Reference

#include <walklayer.h>

Inheritance diagram for WalkLayer:
Resource MemoryCounter

Public Member Functions

 WalkLayer (const int width, const int height)
 
 ~WalkLayer ()
 
int * getData ()
 
int getDataAt (const int x, const int y) const
 
int calcMemoryLocal () const
 
std::string getCounterName () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
 ~Resource ()
 
virtual void incRef ()
 
virtual void decRef ()
 
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
 
int * mTiles
 

Additional Inherited Members

- Data Fields inherited from Resource
time_t mTimeStamp
 
std::string mIdPath
 
std::string mSource
 
unsigned int mRefCount
 
bool mProtected
 
bool mNotCount
 

Detailed Description

Definition at line 29 of file walklayer.h.

Constructor & Destructor Documentation

◆ WalkLayer()

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

Definition at line 26 of file walklayer.cpp.

26  :
27  Resource(),
28  mWidth(width),
29  mHeight(height),
30  mTiles(new int[width * height])
31 {
32  std::fill_n(mTiles, width * height, 0);
33 }
Resource()
Definition: resource.h:40
int mHeight
Definition: walklayer.h:50
int * mTiles
Definition: walklayer.h:51
int mWidth
Definition: walklayer.h:49

References mTiles.

Referenced by calcMemoryLocal().

◆ ~WalkLayer()

WalkLayer::~WalkLayer ( )

Definition at line 35 of file walklayer.cpp.

36 {
37  delete [] mTiles;
38 }

References mTiles.

Member Function Documentation

◆ calcMemoryLocal()

int WalkLayer::calcMemoryLocal ( ) const
virtual

Reimplemented from MemoryCounter.

Definition at line 47 of file walklayer.cpp.

48 {
49  return Resource::calcMemoryLocal() +
50  static_cast<int>(sizeof(WalkLayer) +
51  sizeof(int) * mWidth * mHeight);
52 }
int calcMemoryLocal() const
Definition: resource.cpp:76
WalkLayer(const int width, const int height)
Definition: walklayer.cpp:26

References Resource::calcMemoryLocal(), mHeight, mWidth, and WalkLayer().

◆ getCounterName()

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

Reimplemented from MemoryCounter.

Definition at line 45 of file walklayer.h.

46  { return "walk layer"; }

◆ getData()

int* WalkLayer::getData ( )
inline

Definition at line 38 of file walklayer.h.

39  { return mTiles; }

References mTiles.

Referenced by NavigationManager::loadWalkLayer().

◆ getDataAt()

int WalkLayer::getDataAt ( const int  x,
const int  y 
) const

Definition at line 40 of file walklayer.cpp.

41 {
42  if (x < 0 || x >= mWidth || y < 0 || y >= mHeight)
43  return 0;
44  return mTiles[x + y * mWidth];
45 }

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

Referenced by LocalPlayer::isReachable().

Field Documentation

◆ mHeight

int WalkLayer::mHeight
private

Definition at line 50 of file walklayer.h.

Referenced by calcMemoryLocal(), and getDataAt().

◆ mTiles

int* WalkLayer::mTiles
private

Definition at line 51 of file walklayer.h.

Referenced by getData(), getDataAt(), WalkLayer(), and ~WalkLayer().

◆ mWidth

int WalkLayer::mWidth
private

Definition at line 49 of file walklayer.h.

Referenced by calcMemoryLocal(), and getDataAt().


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