Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
cMap Class Reference

Encapsulates an in-game world map. More...

#include <Map.h>

Collaboration diagram for cMap:
Collaboration graph
[legend]

Public Types

typedef std::vector< ColorIDcColorList
 
typedef std::vector< cClientHandle * > cMapClientList
 
typedef std::vector< cMapDecoratorcMapDecoratorList
 
typedef Byte ColorID
 
enum  eBaseColor {
  E_BASE_COLOR_TRANSPARENT = 0 , E_BASE_COLOR_LIGHT_GREEN = 4 , E_BASE_COLOR_LIGHT_BLUE = 5 , E_BASE_COLOR_LIGHT_BROWN = 8 ,
  E_BASE_COLOR_GRAY_1 = 12 , E_BASE_COLOR_RED = 16 , E_BASE_COLOR_PALE_BLUE = 20 , E_BASE_COLOR_GRAY_2 = 24 ,
  E_BASE_COLOR_DARK_GREEN = 28 , E_BASE_COLOR_WHITE = 32 , E_BASE_COLOR_LIGHT_GRAY = 36 , E_BASE_COLOR_BROWN = 40 ,
  E_BASE_COLOR_DARK_GRAY = 44 , E_BASE_COLOR_BLUE = 48 , E_BASE_COLOR_DARK_BROWN = 52
}
 

Public Member Functions

 cMap (unsigned int a_ID, cWorld *a_World)
 Construct an empty map. More...
 
 cMap (unsigned int a_ID, int a_CenterX, int a_CenterZ, cWorld *a_World, unsigned int a_Scale=3)
 Construct an empty map at the specified coordinates. More...
 
const cMapDecorator CreateDecorator (const cEntity *a_TrackedEntity)
 
int GetCenterX (void) const
 
int GetCenterZ (void) const
 
const cColorListGetData (void) const
 
const cMapDecoratorList GetDecorators (void) const
 
eDimension GetDimension (void) const
 
unsigned int GetHeight (void) const
 
unsigned int GetID (void) const
 
AString GetName (void)
 
unsigned int GetNumPixels (void) const
 
ColorID GetPixel (unsigned int a_X, unsigned int a_Z)
 
unsigned int GetPixelWidth (void) const
 
unsigned int GetScale (void) const
 
unsigned int GetWidth (void) const
 
cWorldGetWorld (void)
 
void Resize (unsigned int a_Width, unsigned int a_Height)
 
bool SetPixel (unsigned int a_X, unsigned int a_Z, ColorID a_Data)
 
void SetPosition (int a_CenterX, int a_CenterZ)
 
void SetScale (unsigned int a_Scale)
 
void Tick ()
 Sends a map update to all registered clients Clears the list holding registered clients and decorators. More...
 
void UpdateClient (cPlayer *a_Player)
 Send next update packet to the specified player and remove invalid decorators / clients. More...
 
void UpdateRadius (cPlayer &a_Player, unsigned int a_Radius)
 Update a circular region around the specified player. More...
 
void UpdateRadius (int a_PixelX, int a_PixelZ, unsigned int a_Radius)
 Update a circular region with the specified radius and center (in pixels). More...
 

Private Member Functions

bool UpdatePixel (unsigned int a_X, unsigned int a_Z)
 Update the specified pixel. More...
 

Private Attributes

int m_CenterX
 
int m_CenterZ
 
cMapClientList m_ClientsInCurrentTick
 
cColorList m_Data
 Column-major array of colours. More...
 
cMapDecoratorList m_Decorators
 
unsigned int m_Height
 
unsigned int m_ID
 
AString m_Name
 
unsigned int m_Scale
 The zoom level, 2^scale square blocks per pixel. More...
 
unsigned int m_Width
 
cWorldm_World
 

Friends

class cMapSerializer
 

Detailed Description

Encapsulates an in-game world map.

Definition at line 82 of file Map.h.

Member Typedef Documentation

◆ cColorList

typedef std::vector<ColorID> cMap::cColorList

Definition at line 109 of file Map.h.

◆ cMapClientList

typedef std::vector<cClientHandle *> cMap::cMapClientList

Definition at line 110 of file Map.h.

◆ cMapDecoratorList

typedef std::vector<cMapDecorator> cMap::cMapDecoratorList

Definition at line 111 of file Map.h.

◆ ColorID

Definition at line 105 of file Map.h.

Member Enumeration Documentation

◆ eBaseColor

Enumerator
E_BASE_COLOR_TRANSPARENT 
E_BASE_COLOR_LIGHT_GREEN 
E_BASE_COLOR_LIGHT_BLUE 
E_BASE_COLOR_LIGHT_BROWN 
E_BASE_COLOR_GRAY_1 
E_BASE_COLOR_RED 
E_BASE_COLOR_PALE_BLUE 
E_BASE_COLOR_GRAY_2 
E_BASE_COLOR_DARK_GREEN 
E_BASE_COLOR_WHITE 
E_BASE_COLOR_LIGHT_GRAY 
E_BASE_COLOR_BROWN 
E_BASE_COLOR_DARK_GRAY 
E_BASE_COLOR_BLUE 
E_BASE_COLOR_DARK_BROWN 

Definition at line 86 of file Map.h.

Constructor & Destructor Documentation

◆ cMap() [1/2]

cMap::cMap ( unsigned int  a_ID,
cWorld a_World 
)

Construct an empty map.

Definition at line 19 of file Map.cpp.

◆ cMap() [2/2]

cMap::cMap ( unsigned int  a_ID,
int  a_CenterX,
int  a_CenterZ,
cWorld a_World,
unsigned int  a_Scale = 3 
)

Construct an empty map at the specified coordinates.

Definition at line 36 of file Map.cpp.

Member Function Documentation

◆ CreateDecorator()

const cMapDecorator cMap::CreateDecorator ( const cEntity a_TrackedEntity)

Definition at line 265 of file Map.cpp.

◆ GetCenterX()

int cMap::GetCenterX ( void  ) const
inline

Definition at line 149 of file Map.h.

◆ GetCenterZ()

int cMap::GetCenterZ ( void  ) const
inline

Definition at line 150 of file Map.h.

◆ GetData()

const cColorList& cMap::GetData ( void  ) const
inline

Definition at line 170 of file Map.h.

◆ GetDecorators()

const cMapDecoratorList cMap::GetDecorators ( void  ) const
inline

Definition at line 168 of file Map.h.

◆ GetDimension()

eDimension cMap::GetDimension ( void  ) const

Definition at line 185 of file Map.cpp.

◆ GetHeight()

unsigned int cMap::GetHeight ( void  ) const
inline

Definition at line 145 of file Map.h.

◆ GetID()

unsigned int cMap::GetID ( void  ) const
inline

Definition at line 152 of file Map.h.

◆ GetName()

AString cMap::GetName ( void  )
inline

Definition at line 156 of file Map.h.

◆ GetNumPixels()

unsigned int cMap::GetNumPixels ( void  ) const

Definition at line 256 of file Map.cpp.

◆ GetPixel()

cMap::ColorID cMap::GetPixel ( unsigned int  a_X,
unsigned int  a_Z 
)

Definition at line 240 of file Map.cpp.

◆ GetPixelWidth()

unsigned int cMap::GetPixelWidth ( void  ) const

Definition at line 324 of file Map.cpp.

◆ GetScale()

unsigned int cMap::GetScale ( void  ) const
inline

Definition at line 147 of file Map.h.

◆ GetWidth()

unsigned int cMap::GetWidth ( void  ) const
inline

Definition at line 144 of file Map.h.

◆ GetWorld()

cWorld* cMap::GetWorld ( void  )
inline

Definition at line 154 of file Map.h.

◆ Resize()

void cMap::Resize ( unsigned int  a_Width,
unsigned int  a_Height 
)

Definition at line 195 of file Map.cpp.

◆ SetPixel()

bool cMap::SetPixel ( unsigned int  a_X,
unsigned int  a_Z,
cMap::ColorID  a_Data 
)

Definition at line 222 of file Map.cpp.

◆ SetPosition()

void cMap::SetPosition ( int  a_CenterX,
int  a_CenterZ 
)

Definition at line 212 of file Map.cpp.

◆ SetScale()

void cMap::SetScale ( unsigned int  a_Scale)
inline

Definition at line 138 of file Map.h.

◆ Tick()

void cMap::Tick ( )

Sends a map update to all registered clients Clears the list holding registered clients and decorators.

Definition at line 53 of file Map.cpp.

◆ UpdateClient()

void cMap::UpdateClient ( cPlayer a_Player)

Send next update packet to the specified player and remove invalid decorators / clients.

Definition at line 174 of file Map.cpp.

◆ UpdatePixel()

bool cMap::UpdatePixel ( unsigned int  a_X,
unsigned int  a_Z 
)
private

Update the specified pixel.

Definition at line 110 of file Map.cpp.

◆ UpdateRadius() [1/2]

void cMap::UpdateRadius ( cPlayer a_Player,
unsigned int  a_Radius 
)

Update a circular region around the specified player.

Definition at line 96 of file Map.cpp.

◆ UpdateRadius() [2/2]

void cMap::UpdateRadius ( int  a_PixelX,
int  a_PixelZ,
unsigned int  a_Radius 
)

Update a circular region with the specified radius and center (in pixels).

Definition at line 67 of file Map.cpp.

Friends And Related Function Documentation

◆ cMapSerializer

friend class cMapSerializer
friend

Definition at line 199 of file Map.h.

Member Data Documentation

◆ m_CenterX

int cMap::m_CenterX
private

Definition at line 185 of file Map.h.

◆ m_CenterZ

int cMap::m_CenterZ
private

Definition at line 186 of file Map.h.

◆ m_ClientsInCurrentTick

cMapClientList cMap::m_ClientsInCurrentTick
private

Definition at line 193 of file Map.h.

◆ m_Data

cColorList cMap::m_Data
private

Column-major array of colours.

Definition at line 189 of file Map.h.

◆ m_Decorators

cMapDecoratorList cMap::m_Decorators
private

Definition at line 195 of file Map.h.

◆ m_Height

unsigned int cMap::m_Height
private

Definition at line 180 of file Map.h.

◆ m_ID

unsigned int cMap::m_ID
private

Definition at line 177 of file Map.h.

◆ m_Name

AString cMap::m_Name
private

Definition at line 197 of file Map.h.

◆ m_Scale

unsigned int cMap::m_Scale
private

The zoom level, 2^scale square blocks per pixel.

Definition at line 183 of file Map.h.

◆ m_Width

unsigned int cMap::m_Width
private

Definition at line 179 of file Map.h.

◆ m_World

cWorld* cMap::m_World
private

Definition at line 191 of file Map.h.


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