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 28 of file walklayer.h.

Constructor & Destructor Documentation

◆ WalkLayer()

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

Definition at line 25 of file walklayer.cpp.

References mTiles.

Referenced by calcMemoryLocal().

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

◆ ~WalkLayer()

WalkLayer::~WalkLayer ( )

Definition at line 34 of file walklayer.cpp.

References mTiles.

35 {
36  delete [] mTiles;
37 }
int * mTiles
Definition: walklayer.h:50

Member Function Documentation

◆ calcMemoryLocal()

int WalkLayer::calcMemoryLocal ( ) const
virtual

Reimplemented from MemoryCounter.

Definition at line 46 of file walklayer.cpp.

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

Referenced by getData().

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

◆ getCounterName()

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

Reimplemented from MemoryCounter.

Definition at line 44 of file walklayer.h.

45  { return "walk layer"; }

◆ getData()

int* WalkLayer::getData ( )
inline

Definition at line 37 of file walklayer.h.

References calcMemoryLocal(), getDataAt(), mTiles, x, and y.

Referenced by NavigationManager::loadWalkLayer().

38  { return mTiles; }
int * mTiles
Definition: walklayer.h:50

◆ getDataAt()

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

Definition at line 39 of file walklayer.cpp.

References mHeight, mTiles, and mWidth.

Referenced by getData(), and LocalPlayer::isReachable().

40 {
41  if (x < 0 || x >= mWidth || y < 0 || y >= mHeight)
42  return 0;
43  return mTiles[x + y * mWidth];
44 }
int mHeight
Definition: walklayer.h:49
int mWidth
Definition: walklayer.h:48
int * mTiles
Definition: walklayer.h:50

Field Documentation

◆ mHeight

int WalkLayer::mHeight
private

Definition at line 49 of file walklayer.h.

Referenced by calcMemoryLocal(), and getDataAt().

◆ mTiles

int* WalkLayer::mTiles
private

Definition at line 50 of file walklayer.h.

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

◆ mWidth

int WalkLayer::mWidth
private

Definition at line 48 of file walklayer.h.

Referenced by calcMemoryLocal(), and getDataAt().


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