1
0

convert old style casts to fix warnings

This commit is contained in:
Steven Riehl 2014-10-11 20:39:55 -06:00
parent b4170e3184
commit 856764dee8
17 changed files with 486 additions and 549 deletions

View File

@ -32,7 +32,7 @@ class cBlockArea
// tolua_end // tolua_end
DISALLOW_COPY_AND_ASSIGN(cBlockArea); DISALLOW_COPY_AND_ASSIGN(cBlockArea);
// tolua_begin // tolua_begin
public: public:
/** What data is to be queried (bit-mask) */ /** What data is to be queried (bit-mask) */
@ -43,7 +43,7 @@ public:
baLight = 4, baLight = 4,
baSkyLight = 8, baSkyLight = 8,
} ; } ;
/** The per-block strategy to use when merging another block area into this object. /** The per-block strategy to use when merging another block area into this object.
See the Merge function for the description of these */ See the Merge function for the description of these */
enum eMergeStrategy enum eMergeStrategy
@ -56,64 +56,64 @@ public:
msDifference, msDifference,
msMask, msMask,
} ; } ;
cBlockArea(void); cBlockArea(void);
~cBlockArea(); ~cBlockArea();
/** Clears the data stored to reclaim memory */ /** Clears the data stored to reclaim memory */
void Clear(void); void Clear(void);
/** Creates a new area of the specified size and contents. /** Creates a new area of the specified size and contents.
Origin is set to all zeroes. Origin is set to all zeroes.
BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light. BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light.
*/ */
void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas); void Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes = baTypes | baMetas);
/** Creates a new area of the specified size and contents. /** Creates a new area of the specified size and contents.
Origin is set to all zeroes. Origin is set to all zeroes.
BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light. BlockTypes are set to air, block metas to zero, blocklights to zero and skylights to full light.
*/ */
void Create(const Vector3i & a_Size, int a_DataTypes = baTypes | baMetas); void Create(const Vector3i & a_Size, int a_DataTypes = baTypes | baMetas);
/** Resets the origin. No other changes are made, contents are untouched. */ /** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ); void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ);
/** Resets the origin. No other changes are made, contents are untouched. */ /** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(const Vector3i & a_Origin); void SetOrigin(const Vector3i & a_Origin);
/** Reads an area of blocks specified. Returns true if successful. All coords are inclusive. */ /** Reads an area of blocks specified. Returns true if successful. All coords are inclusive. */
bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas); bool Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes = baTypes | baMetas);
/** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */ /** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */
bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const cCuboid & a_Bounds, int a_DataTypes = baTypes | baMetas); bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const cCuboid & a_Bounds, int a_DataTypes = baTypes | baMetas);
/** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */ /** Reads an area of blocks specified. Returns true if successful. The bounds are included in the read area. */
bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_Point1, const Vector3i & a_Point2, int a_DataTypes = baTypes | baMetas); bool Read(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_Point1, const Vector3i & a_Point2, int a_DataTypes = baTypes | baMetas);
// TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write // TODO: Write() is not too good an interface: if it fails, there's no way to repeat only for the parts that didn't write
// A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again // A better way may be to return a list of cBlockAreas for each part that didn't succeed writing, so that the caller may try again
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */ /** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */
bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas); bool Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas);
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */ /** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all */
bool Write(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_MinCoords, int a_DataTypes = baTypes | baMetas); bool Write(cForEachChunkProvider * a_ForEachChunkProvider, const Vector3i & a_MinCoords, int a_DataTypes = baTypes | baMetas);
/** Copies this object's contents into the specified BlockArea. */ /** Copies this object's contents into the specified BlockArea. */
void CopyTo(cBlockArea & a_Into) const; void CopyTo(cBlockArea & a_Into) const;
/** Copies the contents from the specified BlockArea into this object. */ /** Copies the contents from the specified BlockArea into this object. */
void CopyFrom(const cBlockArea & a_From); void CopyFrom(const cBlockArea & a_From);
/** For testing purposes only, dumps the area into a file. */ /** For testing purposes only, dumps the area into a file. */
void DumpToRawFile(const AString & a_FileName); void DumpToRawFile(const AString & a_FileName);
/** Crops the internal contents by the specified amount of blocks from each border. */ /** Crops the internal contents by the specified amount of blocks from each border. */
void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); void Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
/** Expands the internal contents by the specified amount of blocks from each border */ /** Expands the internal contents by the specified amount of blocks from each border */
void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void Expand(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
/** Merges another block area into this one, using the specified block combinating strategy /** Merges another block area into this one, using the specified block combinating strategy
This function combines another BlockArea into the current object. This function combines another BlockArea into the current object.
The strategy parameter specifies how individual blocks are combined together, using the table below. The strategy parameter specifies how individual blocks are combined together, using the table below.
@ -125,7 +125,7 @@ public:
| A | air | air | A | A | | A | air | air | A | A |
| air | B | B | B | B | | air | B | B | B | B |
| A | B | B | A | B | | A | B | B | A | B |
So to sum up: So to sum up:
- msOverwrite completely overwrites all blocks with the Src's blocks - msOverwrite completely overwrites all blocks with the Src's blocks
- msFillAir overwrites only those blocks that were air - msFillAir overwrites only those blocks that were air
@ -147,7 +147,7 @@ public:
| mycelium | stone | stone | ... and mycelium | mycelium | stone | stone | ... and mycelium
| A | stone | A | ... but nothing else | A | stone | A | ... but nothing else
| A | * | A | Everything else is left as it is | A | * | A | Everything else is left as it is
msSpongePrint: msSpongePrint:
Used for most generators, it allows carving out air pockets, too, and uses the Sponge as the NOP block Used for most generators, it allows carving out air pockets, too, and uses the Sponge as the NOP block
| area block | | | area block | |
@ -155,7 +155,7 @@ public:
+----------+--------+--------+ +----------+--------+--------+
| A | sponge | A | Sponge is the NOP block | A | sponge | A | Sponge is the NOP block
| * | B | B | Everything else overwrites anything | * | B | B | Everything else overwrites anything
msMask: msMask:
Combines two areas, the blocks that are the same are kept, differing ones are reset to air Combines two areas, the blocks that are the same are kept, differing ones are reset to air
| area block | | | area block | |
@ -166,68 +166,68 @@ public:
*/ */
void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy); void Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy);
/** Merges another block area into this one, using the specified block combinating strategy. /** Merges another block area into this one, using the specified block combinating strategy.
See Merge() above for details. */ See Merge() above for details. */
void Merge(const cBlockArea & a_Src, const Vector3i & a_RelMinCoords, eMergeStrategy a_Strategy); void Merge(const cBlockArea & a_Src, const Vector3i & a_RelMinCoords, eMergeStrategy a_Strategy);
/** Fills the entire block area with the specified data */ /** Fills the entire block area with the specified data */
void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f); void Fill(int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f);
/** Fills a cuboid inside the block area with the specified data */ /** Fills a cuboid inside the block area with the specified data */
void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ, void FillRelCuboid(int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
); );
/** Fills a cuboid inside the block area with the specified data. a_Cuboid must be sorted. */ /** Fills a cuboid inside the block area with the specified data. a_Cuboid must be sorted. */
void FillRelCuboid(const cCuboid & a_RelCuboid, void FillRelCuboid(const cCuboid & a_RelCuboid,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
); );
/** Draws a line from between two points with the specified data */ /** Draws a line from between two points with the specified data */
void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2, void RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int a_RelY2, int a_RelZ2,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
); );
/** Draws a line from between two points with the specified data */ /** Draws a line from between two points with the specified data */
void RelLine(const Vector3i & a_Point1, const Vector3i & a_Point2, void RelLine(const Vector3i & a_Point1, const Vector3i & a_Point2,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
); );
/** Rotates the entire area counter-clockwise around the Y axis */ /** Rotates the entire area counter-clockwise around the Y axis */
void RotateCCW(void); void RotateCCW(void);
/** Rotates the entire area clockwise around the Y axis */ /** Rotates the entire area clockwise around the Y axis */
void RotateCW(void); void RotateCW(void);
/** Mirrors the entire area around the XY plane */ /** Mirrors the entire area around the XY plane */
void MirrorXY(void); void MirrorXY(void);
/** Mirrors the entire area around the XZ plane */ /** Mirrors the entire area around the XZ plane */
void MirrorXZ(void); void MirrorXZ(void);
/** Mirrors the entire area around the YZ plane */ /** Mirrors the entire area around the YZ plane */
void MirrorYZ(void); void MirrorYZ(void);
/** Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta */ /** Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCCWNoMeta(void); void RotateCCWNoMeta(void);
/** Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta */ /** Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCWNoMeta(void); void RotateCWNoMeta(void);
/** Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta */ /** Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta */
void MirrorXYNoMeta(void); void MirrorXYNoMeta(void);
/** Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta */ /** Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta */
void MirrorXZNoMeta(void); void MirrorXZNoMeta(void);
/** Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta */ /** Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta */
void MirrorYZNoMeta(void); void MirrorYZNoMeta(void);
// Setters: // Setters:
void SetRelBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType); void SetRelBlockType (int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType);
void SetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType); void SetBlockType (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType);
@ -253,80 +253,80 @@ public:
void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); void SetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
// tolua_end // tolua_end
// These need manual exporting, tolua generates the binding as requiring 2 extra input params // These need manual exporting, tolua generates the binding as requiring 2 extra input params
void GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; void GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
void GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; void GetRelBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
// GetSize() is already exported manually to return 3 numbers, can't auto-export // GetSize() is already exported manually to return 3 numbers, can't auto-export
const Vector3i & GetSize(void) const { return m_Size; } const Vector3i & GetSize(void) const { return m_Size; }
// GetOrigin() is already exported manually to return 3 numbers, can't auto-export // GetOrigin() is already exported manually to return 3 numbers, can't auto-export
const Vector3i & GetOrigin(void) const { return m_Origin; } const Vector3i & GetOrigin(void) const { return m_Origin; }
// tolua_begin // tolua_begin
int GetSizeX(void) const { return m_Size.x; } int GetSizeX(void) const { return m_Size.x; }
int GetSizeY(void) const { return m_Size.y; } int GetSizeY(void) const { return m_Size.y; }
int GetSizeZ(void) const { return m_Size.z; } int GetSizeZ(void) const { return m_Size.z; }
/** Returns the volume of the area, as number of blocks */ /** Returns the volume of the area, as number of blocks */
int GetVolume(void) const { return m_Size.x * m_Size.y * m_Size.z; } int GetVolume(void) const { return m_Size.x * m_Size.y * m_Size.z; }
int GetOriginX(void) const { return m_Origin.x; } int GetOriginX(void) const { return m_Origin.x; }
int GetOriginY(void) const { return m_Origin.y; } int GetOriginY(void) const { return m_Origin.y; }
int GetOriginZ(void) const { return m_Origin.z; } int GetOriginZ(void) const { return m_Origin.z; }
/** Returns the datatypes that are stored in the object (bitmask of baXXX values) */ /** Returns the datatypes that are stored in the object (bitmask of baXXX values) */
int GetDataTypes(void) const; int GetDataTypes(void) const;
bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); } bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); }
bool HasBlockMetas (void) const { return (m_BlockMetas != NULL); } bool HasBlockMetas (void) const { return (m_BlockMetas != NULL); }
bool HasBlockLights (void) const { return (m_BlockLight != NULL); } bool HasBlockLights (void) const { return (m_BlockLight != NULL); }
bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != NULL); } bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != NULL); }
// tolua_end // tolua_end
// Clients can use these for faster access to all blocktypes. Be careful though! // Clients can use these for faster access to all blocktypes. Be careful though!
/** Returns the internal pointer to the block types */ /** Returns the internal pointer to the block types */
BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; } BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; }
NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block! NIBBLETYPE * GetBlockMetas (void) const { return m_BlockMetas; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block! NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight; } // NOTE: one byte per block!
NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block! NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight; } // NOTE: one byte per block!
size_t GetBlockCount(void) const { return (size_t)(m_Size.x * m_Size.y * m_Size.z); } size_t GetBlockCount(void) const { return static_cast<size_t>(m_Size.x * m_Size.y * m_Size.z); }
int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const; int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const;
protected: protected:
friend class cChunkDesc; friend class cChunkDesc;
friend class cSchematicFileSerializer; friend class cSchematicFileSerializer;
class cChunkReader : class cChunkReader :
public cChunkDataCallback public cChunkDataCallback
{ {
public: public:
cChunkReader(cBlockArea & a_Area); cChunkReader(cBlockArea & a_Area);
protected: protected:
cBlockArea & m_Area; cBlockArea & m_Area;
Vector3i m_Origin; Vector3i m_Origin;
int m_CurrentChunkX; int m_CurrentChunkX;
int m_CurrentChunkZ; int m_CurrentChunkZ;
void CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc); void CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc);
// cChunkDataCallback overrides: // cChunkDataCallback overrides:
virtual bool Coords(int a_ChunkX, int a_ChunkZ) override; virtual bool Coords(int a_ChunkX, int a_ChunkZ) override;
virtual void ChunkData(const cChunkData & a_BlockTypes) override; virtual void ChunkData(const cChunkData & a_BlockTypes) override;
} ; } ;
typedef NIBBLETYPE * NIBBLEARRAY; typedef NIBBLETYPE * NIBBLEARRAY;
Vector3i m_Origin; Vector3i m_Origin;
Vector3i m_Size; Vector3i m_Size;
/** An extra data value sometimes stored in the .schematic file. Used mainly by the WorldEdit plugin. /** An extra data value sometimes stored in the .schematic file. Used mainly by the WorldEdit plugin.
cBlockArea doesn't use this value in any way. */ cBlockArea doesn't use this value in any way. */
Vector3i m_WEOffset; Vector3i m_WEOffset;
@ -335,10 +335,10 @@ protected:
NIBBLETYPE * m_BlockMetas; // Each meta is stored as a separate byte for faster access NIBBLETYPE * m_BlockMetas; // Each meta is stored as a separate byte for faster access
NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access NIBBLETYPE * m_BlockLight; // Each light value is stored as a separate byte for faster access
NIBBLETYPE * m_BlockSkyLight; // Each light value is stored as a separate byte for faster access NIBBLETYPE * m_BlockSkyLight; // Each light value is stored as a separate byte for faster access
/** Clears the data stored and prepares a fresh new block area with the specified dimensions */ /** Clears the data stored and prepares a fresh new block area with the specified dimensions */
bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes); bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes);
// Basic Setters: // Basic Setters:
void SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array); void SetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array);
void SetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array); void SetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Value, NIBBLETYPE * a_Array);
@ -346,11 +346,11 @@ protected:
// Basic Getters: // Basic Getters:
NIBBLETYPE GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const; NIBBLETYPE GetRelNibble(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE * a_Array) const;
NIBBLETYPE GetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE * a_Array) const; NIBBLETYPE GetNibble (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE * a_Array) const;
// Crop helpers: // Crop helpers:
void CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); void CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
void CropNibbles (NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ); void CropNibbles (NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ);
// Expand helpers: // Expand helpers:
void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void ExpandBlockTypes(int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ); void ExpandNibbles (NIBBLEARRAY & a_Array, int a_SubMinX, int a_AddMaxX, int a_SubMinY, int a_AddMaxY, int a_SubMinZ, int a_AddMaxZ);
@ -361,13 +361,9 @@ protected:
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
); );
template <bool MetasValid> template <bool MetasValid>
void MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas); void MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas);
// tolua_begin // tolua_begin
} ; } ;
// tolua_end // tolua_end

View File

@ -227,9 +227,9 @@ void cBeaconEntity::GiveEffects(void)
virtual bool Item(cPlayer * a_Player) virtual bool Item(cPlayer * a_Player)
{ {
Vector3d PlayerPosition = Vector3d(a_Player->GetPosition()); Vector3d PlayerPosition = Vector3d(a_Player->GetPosition());
if (PlayerPosition.y > (double)m_PosY) if (PlayerPosition.y > static_cast<double>(m_PosY))
{ {
PlayerPosition.y = (double)m_PosY; PlayerPosition.y = static_cast<double>(m_PosY);
} }
// TODO: Vanilla minecraft uses an AABB check instead of a radius one // TODO: Vanilla minecraft uses an AABB check instead of a radius one
@ -255,7 +255,7 @@ void cBeaconEntity::GiveEffects(void)
, m_PrimaryEffect(a_PrimaryEffect) , m_PrimaryEffect(a_PrimaryEffect)
, m_SecondaryEffect(a_SecondaryEffect) , m_SecondaryEffect(a_SecondaryEffect)
, m_EffectLevel(a_EffectLevel) , m_EffectLevel(a_EffectLevel)
{}; {}
} PlayerCallback(Radius, m_PosX, m_PosY, m_PosZ, m_PrimaryEffect, SecondaryEffect, EffectLevel); } PlayerCallback(Radius, m_PosX, m_PosY, m_PosZ, m_PrimaryEffect, SecondaryEffect, EffectLevel);
GetWorld()->ForEachPlayer(PlayerCallback); GetWorld()->ForEachPlayer(PlayerCallback);
@ -288,7 +288,7 @@ void cBeaconEntity::UsedBy(cPlayer * a_Player)
OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this)); OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow(); Window = GetWindow();
} }
if (Window != NULL) if (Window != NULL)
{ {
// if (a_Player->GetWindow() != Window) // if (a_Player->GetWindow() != Window)
@ -307,7 +307,3 @@ void cBeaconEntity::SendTo(cClientHandle & a_Client)
{ {
a_Client.SendUpdateBlockEntity(*this); a_Client.SendUpdateBlockEntity(*this);
} }

View File

@ -105,7 +105,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
{ {
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width); double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width); double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
if (m_World->SpawnMob(MobX, DispY, MobZ, (eMonsterType)m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0) if (m_World->SpawnMob(MobX, DispY, MobZ, static_cast<eMonsterType>(m_Contents.GetSlot(a_SlotNum).m_ItemDamage)) >= 0)
{ {
m_Contents.ChangeSlotCount(a_SlotNum, -1); m_Contents.ChangeSlotCount(a_SlotNum, -1);
} }
@ -190,7 +190,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
void cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector) void cDispenserEntity::SpawnProjectileFromDispenser(int a_BlockX, int a_BlockY, int a_BlockZ, cProjectileEntity::eKind a_Kind, const Vector3d & a_ShootVector)
{ {
m_World->CreateProjectile((double)a_BlockX + 0.5, (double)a_BlockY + 0.5, (double)a_BlockZ + 0.5, a_Kind, NULL, NULL, &a_ShootVector); m_World->CreateProjectile(static_cast<double>(a_BlockX + 0.5), static_cast<double>(a_BlockY + 0.5), static_cast<double>(a_BlockZ + 0.5), a_Kind, NULL, NULL, &a_ShootVector);
} }
@ -275,6 +275,3 @@ bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum
m_Contents.AddItem(EmptyBucket); m_Contents.AddItem(EmptyBucket);
return true; return true;
} }

View File

@ -61,7 +61,7 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
{ {
// Pick one of the occupied slots: // Pick one of the occupied slots:
int OccupiedSlots[9]; int OccupiedSlots[9];
int SlotsCnt = 0; uint SlotsCnt = 0;
for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--) for (int i = m_Contents.GetNumSlots() - 1; i >= 0; i--)
{ {
if (!m_Contents.GetSlot(i).IsEmpty()) if (!m_Contents.GetSlot(i).IsEmpty())
@ -70,19 +70,19 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
SlotsCnt++; SlotsCnt++;
} }
} // for i - m_Contents[] } // for i - m_Contents[]
if (SlotsCnt == 0) if (SlotsCnt == 0)
{ {
// Nothing in the dropspenser, play the click sound // Nothing in the dropspenser, play the click sound
m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.2f); m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.2f);
return; return;
} }
int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1); int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1);
// DropSpense the item, using the specialized behavior in the subclasses: // DropSpense the item, using the specialized behavior in the subclasses:
DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]); DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]);
// Broadcast a smoke and click effects: // Broadcast a smoke and click effects:
NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
int SmokeDir = 0; int SmokeDir = 0;
@ -132,7 +132,7 @@ bool cDropSpenserEntity::Tick(float a_Dt, cChunk & a_Chunk)
{ {
return false; return false;
} }
m_ShouldDropSpense = false; m_ShouldDropSpense = false;
DropSpense(a_Chunk); DropSpense(a_Chunk);
return true; return true;
@ -160,7 +160,7 @@ void cDropSpenserEntity::UsedBy(cPlayer * a_Player)
OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this)); OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow(); Window = GetWindow();
} }
if (Window != NULL) if (Window != NULL)
{ {
if (a_Player->GetWindow() != Window) if (a_Player->GetWindow() != Window)
@ -205,7 +205,3 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
m_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ, PickupSpeedX, PickupSpeedY, PickupSpeedZ); m_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ, PickupSpeedX, PickupSpeedY, PickupSpeedZ);
} }

View File

@ -28,7 +28,7 @@ void cFlowerPotEntity::UsedBy(cPlayer * a_Player)
{ {
return; return;
} }
cItem SelectedItem = a_Player->GetInventory().GetEquippedItem(); cItem SelectedItem = a_Player->GetInventory().GetEquippedItem();
if (IsFlower(SelectedItem.m_ItemType, SelectedItem.m_ItemDamage)) if (IsFlower(SelectedItem.m_ItemType, SelectedItem.m_ItemDamage))
{ {
@ -63,7 +63,7 @@ void cFlowerPotEntity::Destroy(void)
cItems Pickups; cItems Pickups;
Pickups.Add(m_Item); Pickups.Add(m_Item);
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5); m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5);
m_Item.Empty(); m_Item.Empty();
} }
} }
@ -88,7 +88,7 @@ bool cFlowerPotEntity::IsFlower(short m_ItemType, short m_ItemData)
} }
case E_BLOCK_TALL_GRASS: case E_BLOCK_TALL_GRASS:
{ {
return (m_ItemData == (short) 2); return (m_ItemData == static_cast<short>(2));
} }
default: default:
{ {
@ -96,7 +96,3 @@ bool cFlowerPotEntity::IsFlower(short m_ItemType, short m_ItemData)
} }
} }
} }

View File

@ -67,8 +67,8 @@ void cFurnaceEntity::UsedBy(cPlayer * a_Player)
if (a_Player->GetWindow() != Window) if (a_Player->GetWindow() != Window)
{ {
a_Player->OpenWindow(Window); a_Player->OpenWindow(Window);
BroadcastProgress(PROGRESSBAR_FUEL, (short)m_LastProgressFuel); BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(m_LastProgressFuel));
BroadcastProgress(PROGRESSBAR_SMELTING, (short)m_LastProgressCook); BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(m_LastProgressCook));
} }
} }
} }
@ -112,16 +112,16 @@ bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk)
FinishOne(); FinishOne();
} }
} }
m_TimeBurned++; m_TimeBurned++;
if (m_TimeBurned >= m_FuelBurnTime) if (m_TimeBurned >= m_FuelBurnTime)
{ {
// The current fuel has been exhausted, use another one, if possible // The current fuel has been exhausted, use another one, if possible
BurnNewFuel(); BurnNewFuel();
} }
UpdateProgressBars(); UpdateProgressBars();
return true; return true;
} }
@ -166,7 +166,7 @@ void cFurnaceEntity::FinishOne()
m_Contents.ChangeSlotCount(fsOutput, m_CurrentRecipe->Out->m_ItemCount); m_Contents.ChangeSlotCount(fsOutput, m_CurrentRecipe->Out->m_ItemCount);
} }
m_Contents.ChangeSlotCount(fsInput, -m_CurrentRecipe->In->m_ItemCount); m_Contents.ChangeSlotCount(fsInput, -m_CurrentRecipe->In->m_ItemCount);
UpdateIsCooking(); UpdateIsCooking();
} }
@ -186,7 +186,7 @@ void cFurnaceEntity::BurnNewFuel(void)
SetIsCooking(false); SetIsCooking(false);
return; return;
} }
// Is the input and output ready for cooking? // Is the input and output ready for cooking?
if (!CanCookInputToOutput()) if (!CanCookInputToOutput())
{ {
@ -214,13 +214,13 @@ void cFurnaceEntity::BurnNewFuel(void)
void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
{ {
super::OnSlotChanged(a_ItemGrid, a_SlotNum); super::OnSlotChanged(a_ItemGrid, a_SlotNum);
if (m_World == NULL) if (m_World == NULL)
{ {
// The furnace isn't initialized yet, do no processing // The furnace isn't initialized yet, do no processing
return; return;
} }
ASSERT(a_ItemGrid == &m_Contents); ASSERT(a_ItemGrid == &m_Contents);
switch (a_SlotNum) switch (a_SlotNum)
{ {
@ -229,13 +229,13 @@ void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
UpdateInput(); UpdateInput();
break; break;
} }
case fsFuel: case fsFuel:
{ {
UpdateFuel(); UpdateFuel();
break; break;
} }
case fsOutput: case fsOutput:
{ {
UpdateOutput(); UpdateOutput();
@ -258,7 +258,7 @@ void cFurnaceEntity::UpdateInput(void)
m_TimeCooked = 0; m_TimeCooked = 0;
} }
m_LastInput = m_Contents.GetSlot(fsInput); m_LastInput = m_Contents.GetSlot(fsInput);
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe(); cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
m_CurrentRecipe = FR->GetRecipeFrom(m_Contents.GetSlot(fsInput)); m_CurrentRecipe = FR->GetRecipeFrom(m_Contents.GetSlot(fsInput));
if (!CanCookInputToOutput()) if (!CanCookInputToOutput())
@ -271,7 +271,7 @@ void cFurnaceEntity::UpdateInput(void)
{ {
m_NeedCookTime = m_CurrentRecipe->CookTime; m_NeedCookTime = m_CurrentRecipe->CookTime;
SetIsCooking(true); SetIsCooking(true);
// Start burning new fuel if there's no flame now: // Start burning new fuel if there's no flame now:
if (GetFuelBurnTimeLeft() <= 0) if (GetFuelBurnTimeLeft() <= 0)
{ {
@ -292,7 +292,7 @@ void cFurnaceEntity::UpdateFuel(void)
// The current fuel is still burning, don't modify anything: // The current fuel is still burning, don't modify anything:
return; return;
} }
// The current fuel is spent, try to burn some more: // The current fuel is spent, try to burn some more:
BurnNewFuel(); BurnNewFuel();
} }
@ -312,7 +312,7 @@ void cFurnaceEntity::UpdateOutput(void)
SetIsCooking(false); SetIsCooking(false);
return; return;
} }
// No need to burn new fuel, the Tick() function will take care of that // No need to burn new fuel, the Tick() function will take care of that
// Can cook, start cooking if not already underway: // Can cook, start cooking if not already underway:
@ -339,7 +339,7 @@ void cFurnaceEntity::UpdateIsCooking(void)
m_NeedCookTime = 0; m_NeedCookTime = 0;
return; return;
} }
SetIsCooking(true); SetIsCooking(true);
} }
@ -355,7 +355,7 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
// This input cannot be cooked // This input cannot be cooked
return false; return false;
} }
const cItem & Slot = m_Contents.GetSlot(fsOutput); const cItem & Slot = m_Contents.GetSlot(fsOutput);
if (Slot.IsEmpty()) if (Slot.IsEmpty())
{ {
@ -368,13 +368,13 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
// The output slot is blocked with something that cannot be stacked with the recipe's output // The output slot is blocked with something that cannot be stacked with the recipe's output
return false; return false;
} }
if (Slot.IsFullStack()) if (Slot.IsFullStack())
{ {
// Cannot add any more items to the output slot // Cannot add any more items to the output slot
return false; return false;
} }
return true; return true;
} }
@ -387,18 +387,18 @@ void cFurnaceEntity::UpdateProgressBars(void)
{ {
// In order to preserve bandwidth, an update is sent only every 10th tick // In order to preserve bandwidth, an update is sent only every 10th tick
// That's why the comparisons use the division by eight // That's why the comparisons use the division by eight
int CurFuel = (m_FuelBurnTime > 0) ? (200 - 200 * m_TimeBurned / m_FuelBurnTime) : 0; int CurFuel = (m_FuelBurnTime > 0) ? (200 - 200 * m_TimeBurned / m_FuelBurnTime) : 0;
if ((CurFuel / 8) != (m_LastProgressFuel / 8)) if ((CurFuel / 8) != (m_LastProgressFuel / 8))
{ {
BroadcastProgress(PROGRESSBAR_FUEL, (short)CurFuel); BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(CurFuel));
m_LastProgressFuel = CurFuel; m_LastProgressFuel = CurFuel;
} }
int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0; int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
if ((CurCook / 8) != (m_LastProgressCook / 8)) if ((CurCook / 8) != (m_LastProgressCook / 8))
{ {
BroadcastProgress(PROGRESSBAR_SMELTING, (short)CurCook); BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(CurCook));
m_LastProgressCook = CurCook; m_LastProgressCook = CurCook;
} }
} }
@ -415,11 +415,7 @@ void cFurnaceEntity::SetIsCooking(bool a_IsCooking)
} }
m_IsCooking = a_IsCooking; m_IsCooking = a_IsCooking;
// Light or extinguish the furnace: // Light or extinguish the furnace:
m_World->FastSetBlock(m_PosX, m_PosY, m_PosZ, m_IsCooking ? E_BLOCK_LIT_FURNACE : E_BLOCK_FURNACE, m_BlockMeta); m_World->FastSetBlock(m_PosX, m_PosY, m_PosZ, m_IsCooking ? E_BLOCK_LIT_FURNACE : E_BLOCK_FURNACE, m_BlockMeta);
} }

View File

@ -58,7 +58,7 @@ bool cHopperEntity::Tick(float a_Dt, cChunk & a_Chunk)
{ {
UNUSED(a_Dt); UNUSED(a_Dt);
Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge(); Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
bool res = false; bool res = false;
res = MoveItemsIn (a_Chunk, CurrentTick) || res; res = MoveItemsIn (a_Chunk, CurrentTick) || res;
res = MovePickupsIn(a_Chunk, CurrentTick) || res; res = MovePickupsIn(a_Chunk, CurrentTick) || res;
@ -74,7 +74,7 @@ void cHopperEntity::SendTo(cClientHandle & a_Client)
{ {
// The hopper entity doesn't need anything sent to the client when it's created / gets in the viewdistance // The hopper entity doesn't need anything sent to the client when it's created / gets in the viewdistance
// All the actual handling is in the cWindow UI code that gets called when the hopper is rclked // All the actual handling is in the cWindow UI code that gets called when the hopper is rclked
UNUSED(a_Client); UNUSED(a_Client);
} }
@ -91,7 +91,7 @@ void cHopperEntity::UsedBy(cPlayer * a_Player)
OpenNewWindow(); OpenNewWindow();
Window = GetWindow(); Window = GetWindow();
} }
// Open the window for the player: // Open the window for the player:
if (Window != NULL) if (Window != NULL)
{ {
@ -138,7 +138,7 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
// Too early after the previous transfer // Too early after the previous transfer
return false; return false;
} }
// Try moving an item in: // Try moving an item in:
bool res = false; bool res = false;
switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ)) switch (a_Chunk.GetBlock(m_RelX, m_PosY + 1, m_RelZ))
@ -161,17 +161,17 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
case E_BLOCK_DROPPER: case E_BLOCK_DROPPER:
case E_BLOCK_HOPPER: case E_BLOCK_HOPPER:
{ {
res = MoveItemsFromGrid(*(cBlockEntityWithItems *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ)); res = MoveItemsFromGrid(*static_cast<cBlockEntityWithItems *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ)));
break; break;
} }
} }
// If the item has been moved, reset the last tick: // If the item has been moved, reset the last tick:
if (res) if (res)
{ {
m_LastMoveItemsInTick = a_CurrentTick; m_LastMoveItemsInTick = a_CurrentTick;
} }
return res; return res;
} }
@ -205,12 +205,12 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
} }
Vector3f EntityPos = a_Entity->GetPosition(); Vector3f EntityPos = a_Entity->GetPosition();
Vector3f BlockPos(m_Pos.x + 0.5f, (float)m_Pos.y + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards Vector3f BlockPos(m_Pos.x + 0.5f, static_cast<float>(m_Pos.y) + 1, m_Pos.z + 0.5f); // One block above hopper, and search from center outwards
double Distance = (EntityPos - BlockPos).Length(); double Distance = (EntityPos - BlockPos).Length();
if (Distance < 0.5) if (Distance < 0.5)
{ {
if (TrySuckPickupIn((cPickup *)a_Entity)) if (TrySuckPickupIn(static_cast<cPickup *>(a_Entity)))
{ {
return false; return false;
} }
@ -238,9 +238,9 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
m_bFoundPickupsAbove = true; m_bFoundPickupsAbove = true;
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount; int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
if (Item.IsEmpty()) if (Item.IsEmpty())
{ {
a_Pickup->Destroy(); // Kill pickup if all items were added a_Pickup->Destroy(); // Kill pickup if all items were added
@ -280,7 +280,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
// Too early after the previous transfer // Too early after the previous transfer
return false; return false;
} }
// Get the coords of the block where to output items: // Get the coords of the block where to output items:
int OutX, OutY, OutZ; int OutX, OutY, OutZ;
NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ); NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
@ -294,7 +294,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
// Cannot output below the zero-th block level // Cannot output below the zero-th block level
return false; return false;
} }
// Convert coords to relative: // Convert coords to relative:
int OutRelX = OutX - a_Chunk.GetPosX() * cChunkDef::Width; int OutRelX = OutX - a_Chunk.GetPosX() * cChunkDef::Width;
int OutRelZ = OutZ - a_Chunk.GetPosZ() * cChunkDef::Width; int OutRelZ = OutZ - a_Chunk.GetPosZ() * cChunkDef::Width;
@ -304,7 +304,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
// The destination chunk has been unloaded, don't tick // The destination chunk has been unloaded, don't tick
return false; return false;
} }
// Call proper moving function, based on the blocktype present at the coords: // Call proper moving function, based on the blocktype present at the coords:
bool res = false; bool res = false;
switch (DestChunk->GetBlock(OutRelX, OutY, OutRelZ)) switch (DestChunk->GetBlock(OutRelX, OutY, OutRelZ))
@ -327,7 +327,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
case E_BLOCK_DROPPER: case E_BLOCK_DROPPER:
case E_BLOCK_HOPPER: case E_BLOCK_HOPPER:
{ {
cBlockEntityWithItems * BlockEntity = (cBlockEntityWithItems *)DestChunk->GetBlockEntity(OutX, OutY, OutZ); cBlockEntityWithItems * BlockEntity = static_cast<cBlockEntityWithItems *>(DestChunk->GetBlockEntity(OutX, OutY, OutZ));
if (BlockEntity == NULL) if (BlockEntity == NULL)
{ {
LOGWARNING("%s: A block entity was not found where expected at {%d, %d, %d}", __FUNCTION__, OutX, OutY, OutZ); LOGWARNING("%s: A block entity was not found where expected at {%d, %d, %d}", __FUNCTION__, OutX, OutY, OutZ);
@ -337,13 +337,13 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
break; break;
} }
} }
// If the item has been moved, reset the last tick: // If the item has been moved, reset the last tick:
if (res) if (res)
{ {
m_LastMoveItemsOutTick = a_CurrentTick; m_LastMoveItemsOutTick = a_CurrentTick;
} }
return res; return res;
} }
@ -354,7 +354,7 @@ bool cHopperEntity::MoveItemsOut(cChunk & a_Chunk, Int64 a_CurrentTick)
/// Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed. /// Moves items from a chest (dblchest) above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk) bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
{ {
cChestEntity * MainChest = (cChestEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ); cChestEntity * MainChest = static_cast<cChestEntity *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ));
if (MainChest == NULL) if (MainChest == NULL)
{ {
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ); LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
@ -365,7 +365,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
// Moved the item from the chest directly above the hopper // Moved the item from the chest directly above the hopper
return true; return true;
} }
// Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there: // Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there:
static const struct static const struct
{ {
@ -395,7 +395,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
continue; continue;
} }
cChestEntity * SideChest = (cChestEntity *)Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); cChestEntity * SideChest = static_cast<cChestEntity *>(Neighbor->GetBlockEntity(m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z));
if (SideChest == NULL) if (SideChest == NULL)
{ {
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z); LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX + Coords[i].x, m_PosY + 1, m_PosZ + Coords[i].z);
@ -409,7 +409,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
} }
return false; return false;
} }
// The chest was single and nothing could be moved // The chest was single and nothing could be moved
return false; return false;
} }
@ -421,13 +421,13 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
/// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed. /// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk) bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{ {
cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ); cFurnaceEntity * Furnace = static_cast<cFurnaceEntity *>(a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ));
if (Furnace == NULL) if (Furnace == NULL)
{ {
LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ); LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
return false; return false;
} }
// Try move from the output slot: // Try move from the output slot:
if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsOutput, true)) if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsOutput, true))
{ {
@ -435,7 +435,7 @@ bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
Furnace->SetOutputSlot(NewOutput.AddCount(-1)); Furnace->SetOutputSlot(NewOutput.AddCount(-1));
return true; return true;
} }
// No output moved, check if we can move an empty bucket out of the fuel slot: // No output moved, check if we can move an empty bucket out of the fuel slot:
if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET) if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
{ {
@ -445,7 +445,7 @@ bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
return true; return true;
} }
} }
// Nothing can be moved // Nothing can be moved
return false; return false;
} }
@ -458,7 +458,7 @@ bool cHopperEntity::MoveItemsFromGrid(cBlockEntityWithItems & a_Entity)
{ {
cItemGrid & Grid = a_Entity.GetContents(); cItemGrid & Grid = a_Entity.GetContents();
int NumSlots = Grid.GetNumSlots(); int NumSlots = Grid.GetNumSlots();
// First try adding items of types already in the hopper: // First try adding items of types already in the hopper:
for (int i = 0; i < NumSlots; i++) for (int i = 0; i < NumSlots; i++)
{ {
@ -519,7 +519,7 @@ bool cHopperEntity::MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_Sl
// Plugin disagrees with the move // Plugin disagrees with the move
continue; continue;
} }
m_Contents.ChangeSlotCount(i, 1); m_Contents.ChangeSlotCount(i, 1);
return true; return true;
} }
@ -535,7 +535,7 @@ bool cHopperEntity::MoveItemsFromSlot(cBlockEntityWithItems & a_Entity, int a_Sl
bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ) bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ)
{ {
// Try the chest directly connected to the hopper: // Try the chest directly connected to the hopper:
cChestEntity * ConnectedChest = (cChestEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); cChestEntity * ConnectedChest = static_cast<cChestEntity *>(a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ));
if (ConnectedChest == NULL) if (ConnectedChest == NULL)
{ {
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, a_BlockX, a_BlockY, a_BlockZ); LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, a_BlockX, a_BlockY, a_BlockZ);
@ -578,7 +578,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
continue; continue;
} }
cChestEntity * Chest = (cChestEntity *)Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z); cChestEntity * Chest = static_cast<cChestEntity *>(Neighbor->GetBlockEntity(a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z));
if (Chest == NULL) if (Chest == NULL)
{ {
LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d} (%d, %d)", __FUNCTION__, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z, x, z); LOGWARNING("%s: A chest entity was not found where expected, at {%d, %d, %d} (%d, %d)", __FUNCTION__, a_BlockX + Coords[i].x, a_BlockY, a_BlockZ + Coords[i].z, x, z);
@ -590,7 +590,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
} }
return false; return false;
} }
// The chest was single and nothing could be moved // The chest was single and nothing could be moved
return false; return false;
} }
@ -602,7 +602,7 @@ bool cHopperEntity::MoveItemsToChest(cChunk & a_Chunk, int a_BlockX, int a_Block
/// Moves items to the furnace at the specified coords. Returns true if contents have changed /// Moves items to the furnace at the specified coords. Returns true if contents have changed
bool cHopperEntity::MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta) bool cHopperEntity::MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_HopperMeta)
{ {
cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ); cFurnaceEntity * Furnace = static_cast<cFurnaceEntity *>(a_Chunk.GetBlockEntity(a_BlockX, a_BlockY, a_BlockZ));
if (a_HopperMeta == E_META_HOPPER_FACING_YM) if (a_HopperMeta == E_META_HOPPER_FACING_YM)
{ {
// Feed the input slot of the furnace // Feed the input slot of the furnace
@ -684,7 +684,3 @@ bool cHopperEntity::MoveItemsToSlot(cBlockEntityWithItems & a_Entity, int a_DstS
return false; return false;
} }
} }

View File

@ -79,7 +79,7 @@ bool cJukeboxEntity::EjectRecord(void)
} }
cItems Drops; cItems Drops;
Drops.push_back(cItem(m_Record, 1, 0)); Drops.push_back(cItem(static_cast<short>(m_Record), 1, 0));
m_Record = 0; m_Record = 0;
m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 8); m_World->SpawnItemPickups(Drops, m_PosX + 0.5, m_PosY + 1, m_PosZ + 0.5, 8);
m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, 0); m_World->BroadcastSoundParticleEffect(1005, m_PosX, m_PosY, m_PosZ, 0);
@ -113,7 +113,3 @@ void cJukeboxEntity::SetRecord(int a_Record)
{ {
m_Record = a_Record; m_Record = a_Record;
} }

View File

@ -45,7 +45,7 @@ void cSignEntity::SetLines(const AString & a_Line1, const AString & a_Line2, con
void cSignEntity::SetLine(int a_Index, const AString & a_Line) void cSignEntity::SetLine(int a_Index, const AString & a_Line)
{ {
if ((a_Index < 0) || (a_Index >= (int)ARRAYCOUNT(m_Line))) if ((a_Index < 0) || (a_Index >= static_cast<int>(ARRAYCOUNT(m_Line))))
{ {
LOGWARNING("%s: setting a non-existent line %d (value \"%s\"", __FUNCTION__, a_Index, a_Line.c_str()); LOGWARNING("%s: setting a non-existent line %d (value \"%s\"", __FUNCTION__, a_Index, a_Line.c_str());
return; return;
@ -59,7 +59,7 @@ void cSignEntity::SetLine(int a_Index, const AString & a_Line)
AString cSignEntity::GetLine(int a_Index) const AString cSignEntity::GetLine(int a_Index) const
{ {
if ((a_Index < 0) || (a_Index >= (int)ARRAYCOUNT(m_Line))) if ((a_Index < 0) || (a_Index >= static_cast<int>(ARRAYCOUNT(m_Line))))
{ {
LOGWARNING("%s: requesting a non-existent line %d", __FUNCTION__, a_Index); LOGWARNING("%s: requesting a non-existent line %d", __FUNCTION__, a_Index);
return ""; return "";
@ -75,7 +75,3 @@ void cSignEntity::SendTo(cClientHandle & a_Client)
{ {
a_Client.SendUpdateSign(m_PosX, m_PosY, m_PosZ, m_Line[0], m_Line[1], m_Line[2], m_Line[3]); a_Client.SendUpdateSign(m_PosX, m_PosY, m_PosZ, m_Line[0], m_Line[1], m_Line[2], m_Line[3]);
} }

View File

@ -66,7 +66,7 @@ public:
/// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column /// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column
typedef HEIGHTTYPE HeightMap[Width * Width]; typedef HEIGHTTYPE HeightMap[Width * Width];
/** The type used for any biomemap operations and storage inside MCServer, /** The type used for any biomemap operations and storage inside MCServer,
using MCServer biomes (need not correspond to client representation!) using MCServer biomes (need not correspond to client representation!)
idx = x + Width * z // Need to verify this with the protocol spec, currently unknown! idx = x + Width * z // Need to verify this with the protocol spec, currently unknown!
@ -95,8 +95,8 @@ public:
a_X = a_X - a_ChunkX * Width; a_X = a_X - a_ChunkX * Width;
a_Z = a_Z - a_ChunkZ * Width; a_Z = a_Z - a_ChunkZ * Width;
} }
/// Converts absolute block coords to chunk coords: /// Converts absolute block coords to chunk coords:
inline static void BlockToChunk(int a_X, int a_Z, int & a_ChunkX, int & a_ChunkZ) inline static void BlockToChunk(int a_X, int a_Z, int & a_ChunkX, int & a_ChunkZ)
{ {
@ -165,15 +165,15 @@ public:
ASSERT((a_Z >= 0) && (a_Z < Width)); ASSERT((a_Z >= 0) && (a_Z < Width));
a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)] = a_Type; a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)] = a_Type;
} }
inline static void SetBlock(BLOCKTYPE * a_BlockTypes, int a_Index, BLOCKTYPE a_Type) inline static void SetBlock(BLOCKTYPE * a_BlockTypes, int a_Index, BLOCKTYPE a_Type)
{ {
ASSERT((a_Index >= 0) && (a_Index <= NumBlocks)); ASSERT((a_Index >= 0) && (a_Index <= NumBlocks));
a_BlockTypes[a_Index] = a_Type; a_BlockTypes[a_Index] = a_Type;
} }
inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_X, int a_Y, int a_Z) inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_X, int a_Y, int a_Z)
{ {
ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_X >= 0) && (a_X < Width));
@ -181,39 +181,39 @@ public:
ASSERT((a_Z >= 0) && (a_Z < Width)); ASSERT((a_Z >= 0) && (a_Z < Width));
return a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)]; return a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)];
} }
inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_Idx) inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_Idx)
{ {
ASSERT((a_Idx >= 0) && (a_Idx < NumBlocks)); ASSERT((a_Idx >= 0) && (a_Idx < NumBlocks));
return a_BlockTypes[a_Idx]; return a_BlockTypes[a_Idx];
} }
inline static int GetHeight(const HeightMap & a_HeightMap, int a_X, int a_Z) inline static int GetHeight(const HeightMap & a_HeightMap, int a_X, int a_Z)
{ {
ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width)); ASSERT((a_Z >= 0) && (a_Z < Width));
return a_HeightMap[a_X + Width * a_Z]; return a_HeightMap[a_X + Width * a_Z];
} }
inline static void SetHeight(HeightMap & a_HeightMap, int a_X, int a_Z, unsigned char a_Height) inline static void SetHeight(HeightMap & a_HeightMap, int a_X, int a_Z, unsigned char a_Height)
{ {
ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width)); ASSERT((a_Z >= 0) && (a_Z < Width));
a_HeightMap[a_X + Width * a_Z] = a_Height; a_HeightMap[a_X + Width * a_Z] = a_Height;
} }
inline static EMCSBiome GetBiome(const BiomeMap & a_BiomeMap, int a_X, int a_Z) inline static EMCSBiome GetBiome(const BiomeMap & a_BiomeMap, int a_X, int a_Z)
{ {
ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width)); ASSERT((a_Z >= 0) && (a_Z < Width));
return a_BiomeMap[a_X + Width * a_Z]; return a_BiomeMap[a_X + Width * a_Z];
} }
inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome) inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
{ {
ASSERT((a_X >= 0) && (a_X < Width)); ASSERT((a_X >= 0) && (a_X < Width));
@ -226,11 +226,11 @@ public:
{ {
if ((a_BlockIdx > -1) && (a_BlockIdx < NumBlocks)) if ((a_BlockIdx > -1) && (a_BlockIdx < NumBlocks))
{ {
if ((size_t)(a_BlockIdx / 2) >= a_Buffer.size()) if (static_cast<size_t>((a_BlockIdx / 2)) >= a_Buffer.size())
{ {
return (a_IsSkyLightNibble ? 0xff : 0); return (a_IsSkyLightNibble ? 0xff : 0);
} }
return (a_Buffer[(size_t)(a_BlockIdx / 2)] >> ((a_BlockIdx & 1) * 4)) & 0x0f; return (a_Buffer[static_cast<size_t>(a_BlockIdx / 2)] >> ((a_BlockIdx & 1) * 4)) & 0x0f;
} }
ASSERT(!"cChunkDef::GetNibble(): index out of chunk range!"); ASSERT(!"cChunkDef::GetNibble(): index out of chunk range!");
return 0; return 0;
@ -241,7 +241,7 @@ public:
{ {
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1)) if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{ {
size_t Index = (size_t)MakeIndexNoCheck(x, y, z); size_t Index = static_cast<size_t>(MakeIndexNoCheck(x, y, z));
if ((Index / 2) >= a_Buffer.size()) if ((Index / 2) >= a_Buffer.size())
{ {
return (a_IsSkyLightNibble ? 0xff : 0); return (a_IsSkyLightNibble ? 0xff : 0);
@ -258,7 +258,7 @@ public:
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1)) if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{ {
int Index = MakeIndexNoCheck(x, y, z); int Index = MakeIndexNoCheck(x, y, z);
return (a_Buffer[(size_t)(Index / 2)] >> ((Index & 1) * 4)) & 0x0f; return (a_Buffer[static_cast<size_t>(Index / 2)] >> ((Index & 1) * 4)) & 0x0f;
} }
ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!"); ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!");
return 0; return 0;
@ -272,11 +272,11 @@ public:
ASSERT(!"cChunkDef::SetNibble(): index out of range!"); ASSERT(!"cChunkDef::SetNibble(): index out of range!");
return; return;
} }
if ((size_t)(a_BlockIdx / 2) >= a_Buffer.size()) if (static_cast<size_t>(a_BlockIdx / 2) >= a_Buffer.size())
{ {
a_Buffer.resize((size_t)((a_BlockIdx / 2) + 1)); a_Buffer.resize(static_cast<size_t>((a_BlockIdx / 2) + 1));
} }
a_Buffer[(size_t)(a_BlockIdx / 2)] = PackNibble(a_Buffer, (size_t)a_BlockIdx, a_Nibble); a_Buffer[static_cast<size_t>(a_BlockIdx / 2)] = PackNibble(a_Buffer, static_cast<size_t>(a_BlockIdx), a_Nibble);
} }
@ -292,7 +292,7 @@ public:
return; return;
} }
size_t Index = (size_t)MakeIndexNoCheck(x, y, z); size_t Index = static_cast<size_t>(MakeIndexNoCheck(x, y, z));
if ((Index / 2) >= a_Buffer.size()) if ((Index / 2) >= a_Buffer.size())
{ {
a_Buffer.resize(((Index / 2) + 1)); a_Buffer.resize(((Index / 2) + 1));
@ -336,7 +336,7 @@ public:
/// Called for clients that are in Chunk1 and not in Chunk2, /// Called for clients that are in Chunk1 and not in Chunk2,
virtual void Removed(cClientHandle * a_Client) = 0; virtual void Removed(cClientHandle * a_Client) = 0;
/// Called for clients that are in Chunk2 and not in Chunk1. /// Called for clients that are in Chunk2 and not in Chunk1.
virtual void Added(cClientHandle * a_Client) = 0; virtual void Added(cClientHandle * a_Client) = 0;
} ; } ;
@ -373,9 +373,9 @@ class cChunkCoords
public: public:
int m_ChunkX; int m_ChunkX;
int m_ChunkZ; int m_ChunkZ;
cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {} cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {}
bool operator == (const cChunkCoords & a_Other) const bool operator == (const cChunkCoords & a_Other) const
{ {
return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ)); return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ));
@ -432,12 +432,12 @@ public:
int y; int y;
int z; int z;
X Data; X Data;
cCoordWithData(int a_X, int a_Y, int a_Z) : cCoordWithData(int a_X, int a_Y, int a_Z) :
x(a_X), y(a_Y), z(a_Z), Data() x(a_X), y(a_Y), z(a_Z), Data()
{ {
} }
cCoordWithData(int a_X, int a_Y, int a_Z, const X & a_Data) : cCoordWithData(int a_X, int a_Y, int a_Z, const X & a_Data) :
x(a_X), y(a_Y), z(a_Z), Data(a_Data) x(a_X), y(a_Y), z(a_Z), Data(a_Data)
{ {
@ -478,7 +478,3 @@ public:
typedef cCoordWithDoubleData <BLOCKTYPE, bool> cCoordWithBlockAndBool; typedef cCoordWithDoubleData <BLOCKTYPE, bool> cCoordWithBlockAndBool;
typedef std::vector<cCoordWithBlockAndBool> cCoordWithBlockAndBoolVector; typedef std::vector<cCoordWithBlockAndBool> cCoordWithBlockAndBoolVector;

View File

@ -39,7 +39,7 @@ enum eBlockFace
BLOCK_FACE_YP = 1, // Interacting with the Y+ face of the block BLOCK_FACE_YP = 1, // Interacting with the Y+ face of the block
BLOCK_FACE_ZM = 2, // Interacting with the Z- face of the block BLOCK_FACE_ZM = 2, // Interacting with the Z- face of the block
BLOCK_FACE_ZP = 3, // Interacting with the Z+ face of the block BLOCK_FACE_ZP = 3, // Interacting with the Z+ face of the block
// Synonyms using the (deprecated) world directions: // Synonyms using the (deprecated) world directions:
BLOCK_FACE_BOTTOM = BLOCK_FACE_YM, // Interacting with the bottom face of the block BLOCK_FACE_BOTTOM = BLOCK_FACE_YM, // Interacting with the bottom face of the block
BLOCK_FACE_TOP = BLOCK_FACE_YP, // Interacting with the top face of the block BLOCK_FACE_TOP = BLOCK_FACE_YP, // Interacting with the top face of the block
@ -101,7 +101,7 @@ enum eClickAction
caDblClick, caDblClick,
// Add new actions here // Add new actions here
caUnknown = 255, caUnknown = 255,
// Keep this list in sync with ClickActionToString() function below! // Keep this list in sync with ClickActionToString() function below!
} ; } ;
@ -116,14 +116,14 @@ enum eGameMode
eGameMode_Creative = 1, eGameMode_Creative = 1,
eGameMode_Adventure = 2, eGameMode_Adventure = 2,
eGameMode_Spectator = 3, eGameMode_Spectator = 3,
// Easier-to-use synonyms: // Easier-to-use synonyms:
gmNotSet = eGameMode_NotSet, gmNotSet = eGameMode_NotSet,
gmSurvival = eGameMode_Survival, gmSurvival = eGameMode_Survival,
gmCreative = eGameMode_Creative, gmCreative = eGameMode_Creative,
gmAdventure = eGameMode_Adventure, gmAdventure = eGameMode_Adventure,
gmSpectator = eGameMode_Spectator, gmSpectator = eGameMode_Spectator,
// These two are used to check GameMode for validity when converting from integers. // These two are used to check GameMode for validity when converting from integers.
gmMax, // Gets automatically assigned gmMax, // Gets automatically assigned
gmMin = 0, gmMin = 0,
@ -138,7 +138,7 @@ enum eWeather
eWeather_Sunny = 0, eWeather_Sunny = 0,
eWeather_Rain = 1, eWeather_Rain = 1,
eWeather_ThunderStorm = 2, eWeather_ThunderStorm = 2,
// Easier-to-use synonyms: // Easier-to-use synonyms:
wSunny = eWeather_Sunny, wSunny = eWeather_Sunny,
wRain = eWeather_Rain, wRain = eWeather_Rain,
@ -218,7 +218,7 @@ inline const char * ClickActionToString(eClickAction a_ClickAction)
case caLeftPaintEnd: return "caLeftPaintEnd"; case caLeftPaintEnd: return "caLeftPaintEnd";
case caRightPaintEnd: return "caRightPaintEnd"; case caRightPaintEnd: return "caRightPaintEnd";
case caDblClick: return "caDblClick"; case caDblClick: return "caDblClick";
case caUnknown: return "caUnknown"; case caUnknown: return "caUnknown";
} }
ASSERT(!"Unknown click action"); ASSERT(!"Unknown click action");
@ -472,7 +472,7 @@ inline void AddFaceDirection(int & a_BlockX, unsigned char & a_BlockY, int & a_B
{ {
int Y = a_BlockY; int Y = a_BlockY;
AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse); AddFaceDirection(a_BlockX, Y, a_BlockZ, a_BlockFace, a_bInverse);
a_BlockY = Clamp<unsigned char>((unsigned char)Y, 0, 255); a_BlockY = Clamp<unsigned char>(static_cast<unsigned char>(Y), 0, 255);
} }
@ -556,7 +556,7 @@ enum eMessageType
mtPrivateMessage, // Player to player messaging identifier mtPrivateMessage, // Player to player messaging identifier
mtJoin, // A player has joined the server mtJoin, // A player has joined the server
mtLeave, // A player has left the server mtLeave, // A player has left the server
// Common aliases: // Common aliases:
mtFail = mtFailure, mtFail = mtFailure,
mtError = mtFailure, mtError = mtFailure,
@ -626,9 +626,9 @@ namespace ItemCategory
|| (a_ItemID == E_ITEM_GOLD_HOE) || (a_ItemID == E_ITEM_GOLD_HOE)
|| (a_ItemID == E_ITEM_DIAMOND_HOE); || (a_ItemID == E_ITEM_DIAMOND_HOE);
} }
inline bool IsShovel(short a_ItemID) inline bool IsShovel(short a_ItemID)
{ {
return (a_ItemID == E_ITEM_WOODEN_SHOVEL) return (a_ItemID == E_ITEM_WOODEN_SHOVEL)
@ -648,9 +648,9 @@ namespace ItemCategory
|| IsHoe ( a_ItemID) || IsHoe ( a_ItemID)
|| IsShovel ( a_ItemID); || IsShovel ( a_ItemID);
} }
inline bool IsHelmet(short a_ItemType) inline bool IsHelmet(short a_ItemType)
{ {
return ( return (
@ -700,9 +700,9 @@ namespace ItemCategory
(a_ItemType == E_ITEM_DIAMOND_BOOTS) (a_ItemType == E_ITEM_DIAMOND_BOOTS)
); );
} }
inline bool IsArmor(short a_ItemType) inline bool IsArmor(short a_ItemType)
{ {
return ( return (
@ -715,7 +715,3 @@ namespace ItemCategory
} }
// tolua_end // tolua_end

View File

@ -84,13 +84,13 @@ public:
etFloater, etFloater,
etItemFrame, etItemFrame,
etPainting, etPainting,
// Common variations // Common variations
etMob = etMonster, // DEPRECATED, use etMonster instead! etMob = etMonster, // DEPRECATED, use etMonster instead!
} ; } ;
// tolua_end // tolua_end
enum eEntityStatus enum eEntityStatus
{ {
// TODO: Investiagate 0, 1, and 5 as Wiki.vg is not certain // TODO: Investiagate 0, 1, and 5 as Wiki.vg is not certain
@ -127,22 +127,22 @@ public:
// Informs client to explode a firework based on its metadata // Informs client to explode a firework based on its metadata
esFireworkExploding = 17, esFireworkExploding = 17,
} ; } ;
static const int FIRE_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in fire static const int FIRE_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in fire
static const int FIRE_DAMAGE = 1; ///< Damage to deal when standing in fire static const int FIRE_DAMAGE = 1; ///< Damage to deal when standing in fire
static const int LAVA_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in lava static const int LAVA_TICKS_PER_DAMAGE = 10; ///< Ticks to wait between damaging an entity when it stands in lava
static const int LAVA_DAMAGE = 5; ///< Damage to deal when standing in lava static const int LAVA_DAMAGE = 5; ///< Damage to deal when standing in lava
static const int BURN_TICKS_PER_DAMAGE = 20; ///< Ticks to wait between damaging an entity when it is burning static const int BURN_TICKS_PER_DAMAGE = 20; ///< Ticks to wait between damaging an entity when it is burning
static const int BURN_DAMAGE = 1; ///< Damage to deal when the entity is burning static const int BURN_DAMAGE = 1; ///< Damage to deal when the entity is burning
static const int BURN_TICKS = 200; ///< Ticks to keep an entity burning after it has stood in lava / fire static const int BURN_TICKS = 200; ///< Ticks to keep an entity burning after it has stood in lava / fire
static const int MAX_AIR_LEVEL = 300; ///< Maximum air an entity can have static const int MAX_AIR_LEVEL = 300; ///< Maximum air an entity can have
static const int DROWNING_TICKS = 20; ///< Number of ticks per heart of damage static const int DROWNING_TICKS = 20; ///< Number of ticks per heart of damage
static const int VOID_BOUNDARY = -46; ///< Y position to begin applying void damage static const int VOID_BOUNDARY = -46; ///< Y position to begin applying void damage
static const int FALL_DAMAGE_HEIGHT = 4; ///< Y difference after which fall damage is applied static const int FALL_DAMAGE_HEIGHT = 4; ///< Y difference after which fall damage is applied
cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
virtual ~cEntity(); virtual ~cEntity();
@ -151,9 +151,9 @@ public:
virtual bool Initialize(cWorld & a_World); virtual bool Initialize(cWorld & a_World);
// tolua_begin // tolua_begin
eEntityType GetEntityType(void) const { return m_EntityType; } eEntityType GetEntityType(void) const { return m_EntityType; }
bool IsEnderCrystal(void) const { return (m_EntityType == etEnderCrystal); } bool IsEnderCrystal(void) const { return (m_EntityType == etEnderCrystal); }
bool IsPlayer (void) const { return (m_EntityType == etPlayer); } bool IsPlayer (void) const { return (m_EntityType == etPlayer); }
bool IsPickup (void) const { return (m_EntityType == etPickup); } bool IsPickup (void) const { return (m_EntityType == etPickup); }
@ -168,16 +168,16 @@ public:
bool IsFloater (void) const { return (m_EntityType == etFloater); } bool IsFloater (void) const { return (m_EntityType == etFloater); }
bool IsItemFrame (void) const { return (m_EntityType == etItemFrame); } bool IsItemFrame (void) const { return (m_EntityType == etItemFrame); }
bool IsPainting (void) const { return (m_EntityType == etPainting); } bool IsPainting (void) const { return (m_EntityType == etPainting); }
/// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) /// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true)
virtual bool IsA(const char * a_ClassName) const; virtual bool IsA(const char * a_ClassName) const;
/// Returns the topmost class name for the object /// Returns the topmost class name for the object
virtual const char * GetClass(void) const; virtual const char * GetClass(void) const;
// Returns the class name of this class // Returns the class name of this class
static const char * GetClassStatic(void); static const char * GetClassStatic(void);
/// Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). /// Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent).
virtual const char * GetParentClass(void) const; virtual const char * GetParentClass(void) const;
@ -200,9 +200,9 @@ public:
double GetSpeedY (void) const { return m_Speed.y; } double GetSpeedY (void) const { return m_Speed.y; }
double GetSpeedZ (void) const { return m_Speed.z; } double GetSpeedZ (void) const { return m_Speed.z; }
double GetWidth (void) const { return m_Width; } double GetWidth (void) const { return m_Width; }
int GetChunkX(void) const {return (int)floor(m_Pos.x / cChunkDef::Width); } int GetChunkX(void) const {return static_cast<int>(floor(m_Pos.x / cChunkDef::Width)); }
int GetChunkZ(void) const {return (int)floor(m_Pos.z / cChunkDef::Width); } int GetChunkZ(void) const {return static_cast<int>(floor(m_Pos.z / cChunkDef::Width)); }
void SetHeadYaw (double a_HeadYaw); void SetHeadYaw (double a_HeadYaw);
void SetHeight (double a_Height); void SetHeight (double a_Height);
@ -219,21 +219,21 @@ public:
/** Sets the speed of the entity, measured in m / sec */ /** Sets the speed of the entity, measured in m / sec */
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
/** Sets the speed of the entity, measured in m / sec */ /** Sets the speed of the entity, measured in m / sec */
void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); } void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
/** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */ /** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedX(double a_SpeedX); void SetSpeedX(double a_SpeedX);
/** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */ /** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedY(double a_SpeedY); void SetSpeedY(double a_SpeedY);
/** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */ /** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedZ(double a_SpeedZ); void SetSpeedZ(double a_SpeedZ);
void SetWidth (double a_Width); void SetWidth (double a_Width);
void AddPosX (double a_AddPosX); void AddPosX (double a_AddPosX);
void AddPosY (double a_AddPosY); void AddPosY (double a_AddPosY);
void AddPosZ (double a_AddPosZ); void AddPosZ (double a_AddPosZ);
@ -244,7 +244,7 @@ public:
void AddSpeedX (double a_AddSpeedX); void AddSpeedX (double a_AddSpeedX);
void AddSpeedY (double a_AddSpeedY); void AddSpeedY (double a_AddSpeedY);
void AddSpeedZ (double a_AddSpeedZ); void AddSpeedZ (double a_AddSpeedZ);
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways); virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways);
void SteerVehicle(float a_Forward, float a_Sideways); void SteerVehicle(float a_Forward, float a_Sideways);
@ -256,56 +256,56 @@ public:
/// Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called /// Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called
void TakeDamage(cEntity & a_Attacker); void TakeDamage(cEntity & a_Attacker);
/// Makes this entity take the specified damage. The final damage is calculated using current armor, then DoTakeDamage() called /// Makes this entity take the specified damage. The final damage is calculated using current armor, then DoTakeDamage() called
void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, double a_KnockbackAmount); void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, double a_KnockbackAmount);
/// Makes this entity take the specified damage. The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage() /// Makes this entity take the specified damage. The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage()
void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount); void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount);
float GetGravity(void) const { return m_Gravity; } float GetGravity(void) const { return m_Gravity; }
void SetGravity(float a_Gravity) { m_Gravity = a_Gravity; } void SetGravity(float a_Gravity) { m_Gravity = a_Gravity; }
/// Sets the rotation to match the speed vector (entity goes "face-forward") /// Sets the rotation to match the speed vector (entity goes "face-forward")
void SetYawFromSpeed(void); void SetYawFromSpeed(void);
/// Sets the pitch to match the speed vector (entity gies "face-forward") /// Sets the pitch to match the speed vector (entity gies "face-forward")
void SetPitchFromSpeed(void); void SetPitchFromSpeed(void);
// tolua_end // tolua_end
/** Makes this entity take damage specified in the a_TDI. /** Makes this entity take damage specified in the a_TDI.
The TDI is sent through plugins first, then applied. The TDI is sent through plugins first, then applied.
If it returns false, the entity hasn't receive any damage. */ If it returns false, the entity hasn't receive any damage. */
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI); virtual bool DoTakeDamage(TakeDamageInfo & a_TDI);
// tolua_begin // tolua_begin
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items /// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
virtual int GetRawDamageAgainst(const cEntity & a_Receiver); virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
/** Returns whether armor will protect against the passed damage type **/ /** Returns whether armor will protect against the passed damage type **/
virtual bool ArmorCoversAgainst(eDamageType a_DamageType); virtual bool ArmorCoversAgainst(eDamageType a_DamageType);
/// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover /// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover
virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage); virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage);
/// Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit /// Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit
virtual double GetKnockbackAmountAgainst(const cEntity & a_Receiver); virtual double GetKnockbackAmountAgainst(const cEntity & a_Receiver);
/// Returns the curently equipped weapon; empty item if none /// Returns the curently equipped weapon; empty item if none
virtual cItem GetEquippedWeapon(void) const { return cItem(); } virtual cItem GetEquippedWeapon(void) const { return cItem(); }
/// Returns the currently equipped helmet; empty item if none /// Returns the currently equipped helmet; empty item if none
virtual cItem GetEquippedHelmet(void) const { return cItem(); } virtual cItem GetEquippedHelmet(void) const { return cItem(); }
/// Returns the currently equipped chestplate; empty item if none /// Returns the currently equipped chestplate; empty item if none
virtual cItem GetEquippedChestplate(void) const { return cItem(); } virtual cItem GetEquippedChestplate(void) const { return cItem(); }
/// Returns the currently equipped leggings; empty item if none /// Returns the currently equipped leggings; empty item if none
virtual cItem GetEquippedLeggings(void) const { return cItem(); } virtual cItem GetEquippedLeggings(void) const { return cItem(); }
/// Returns the currently equipped boots; empty item if none /// Returns the currently equipped boots; empty item if none
virtual cItem GetEquippedBoots(void) const { return cItem(); } virtual cItem GetEquippedBoots(void) const { return cItem(); }
@ -317,20 +317,20 @@ public:
/// Heals the specified amount of HPs /// Heals the specified amount of HPs
virtual void Heal(int a_HitPoints); virtual void Heal(int a_HitPoints);
/// Returns the health of this entity /// Returns the health of this entity
int GetHealth(void) const { return m_Health; } int GetHealth(void) const { return m_Health; }
/// Sets the health of this entity; doesn't broadcast any hurt animation /// Sets the health of this entity; doesn't broadcast any hurt animation
void SetHealth(int a_Health); void SetHealth(int a_Health);
// tolua_end // tolua_end
virtual void Tick(float a_Dt, cChunk & a_Chunk); virtual void Tick(float a_Dt, cChunk & a_Chunk);
/// Handles the physics of the entity - updates position based on speed, updates speed based on environment /// Handles the physics of the entity - updates position based on speed, updates speed based on environment
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk); virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk);
/// Updates the state related to this entity being on fire /// Updates the state related to this entity being on fire
virtual void TickBurning(cChunk & a_Chunk); virtual void TickBurning(cChunk & a_Chunk);
@ -341,34 +341,34 @@ public:
Returns true if MoveToWorld() was called, false if not Returns true if MoveToWorld() was called, false if not
*/ */
virtual bool DetectPortal(void); virtual bool DetectPortal(void);
/// Handles when the entity is in the void /// Handles when the entity is in the void
virtual void TickInVoid(cChunk & a_Chunk); virtual void TickInVoid(cChunk & a_Chunk);
/// Called when the entity starts burning /// Called when the entity starts burning
virtual void OnStartedBurning(void); virtual void OnStartedBurning(void);
/// Called when the entity finishes burning /// Called when the entity finishes burning
virtual void OnFinishedBurning(void); virtual void OnFinishedBurning(void);
// tolua_begin // tolua_begin
/// Sets the maximum value for the health /// Sets the maximum value for the health
void SetMaxHealth(int a_MaxHealth); void SetMaxHealth(int a_MaxHealth);
int GetMaxHealth(void) const { return m_MaxHealth; } int GetMaxHealth(void) const { return m_MaxHealth; }
/// Sets whether the entity is fireproof /// Sets whether the entity is fireproof
void SetIsFireproof(bool a_IsFireproof); void SetIsFireproof(bool a_IsFireproof);
bool IsFireproof(void) const { return m_IsFireproof; } bool IsFireproof(void) const { return m_IsFireproof; }
/// Puts the entity on fire for the specified amount of ticks /// Puts the entity on fire for the specified amount of ticks
void StartBurning(int a_TicksLeftBurning); void StartBurning(int a_TicksLeftBurning);
/// Stops the entity from burning, resets all burning timers /// Stops the entity from burning, resets all burning timers
void StopBurning(void); void StopBurning(void);
// tolua_end // tolua_end
/** Descendants override this function to send a command to the specified client to spawn the entity on the client. /** Descendants override this function to send a command to the specified client to spawn the entity on the client.
@ -377,10 +377,10 @@ public:
virtual void SpawnOn(cClientHandle & a_Client) = 0; virtual void SpawnOn(cClientHandle & a_Client) = 0;
// tolua_begin // tolua_begin
/// Teleports to the entity specified /// Teleports to the entity specified
virtual void TeleportToEntity(cEntity & a_Entity); virtual void TeleportToEntity(cEntity & a_Entity);
/// Teleports to the coordinates specified /// Teleports to the coordinates specified
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ);
@ -389,7 +389,7 @@ public:
/** Moves entity to specified world, taking a world name */ /** Moves entity to specified world, taking a world name */
bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true); bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true);
// tolua_end // tolua_end
virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn); virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn);
@ -399,16 +399,16 @@ public:
/** Sets the world the entity will be leaving */ /** Sets the world the entity will be leaving */
void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; } void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; }
/// Updates clients of changes in the entity. /// Updates clients of changes in the entity.
virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL); virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL);
/// Attaches to the specified entity; detaches from any previous one first /// Attaches to the specified entity; detaches from any previous one first
void AttachTo(cEntity * a_AttachTo); void AttachTo(cEntity * a_AttachTo);
/// Detaches from the currently attached entity, if any /// Detaches from the currently attached entity, if any
virtual void Detach(void); virtual void Detach(void);
/// Makes sure head yaw is not over the specified range. /// Makes sure head yaw is not over the specified range.
void WrapHeadYaw(); void WrapHeadYaw();
@ -417,9 +417,9 @@ public:
/// Makes speed is not over 20. Max speed is 20 blocks / second /// Makes speed is not over 20. Max speed is 20 blocks / second
void WrapSpeed(); void WrapSpeed();
// tolua_begin // tolua_begin
// COMMON metadata flags; descendants may override the defaults: // COMMON metadata flags; descendants may override the defaults:
virtual bool IsOnFire (void) const {return (m_TicksLeftBurning > 0); } virtual bool IsOnFire (void) const {return (m_TicksLeftBurning > 0); }
virtual bool IsCrouched (void) const {return false; } virtual bool IsCrouched (void) const {return false; }
@ -437,15 +437,15 @@ public:
/** Gets number of ticks this entity has existed for */ /** Gets number of ticks this entity has existed for */
long int GetTicksAlive(void) const { return m_TicksAlive; } long int GetTicksAlive(void) const { return m_TicksAlive; }
/** Gets the invulnerable ticks from the entity */ /** Gets the invulnerable ticks from the entity */
int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; } int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
/** Set the invulnerable ticks from the entity */ /** Set the invulnerable ticks from the entity */
void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; } void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; }
// tolua_end // tolua_end
/// Called when the specified player right-clicks this entity /// Called when the specified player right-clicks this entity
virtual void OnRightClicked(cPlayer & a_Player) {} virtual void OnRightClicked(cPlayer & a_Player) {}
@ -462,38 +462,38 @@ public:
protected: protected:
static cCriticalSection m_CSCount; static cCriticalSection m_CSCount;
static int m_EntityCount; static int m_EntityCount;
/** Measured in meter/second (m/s) */ /** Measured in meter/second (m/s) */
Vector3d m_Speed; Vector3d m_Speed;
int m_UniqueID; int m_UniqueID;
int m_Health; int m_Health;
int m_MaxHealth; int m_MaxHealth;
/// The entity to which this entity is attached (vehicle), NULL if none /// The entity to which this entity is attached (vehicle), NULL if none
cEntity * m_AttachedTo; cEntity * m_AttachedTo;
/// The entity which is attached to this entity (rider), NULL if none /// The entity which is attached to this entity (rider), NULL if none
cEntity * m_Attachee; cEntity * m_Attachee;
/** Stores whether head yaw has been set manually */ /** Stores whether head yaw has been set manually */
bool m_bDirtyHead; bool m_bDirtyHead;
/** Stores whether our yaw/pitch/roll (body orientation) has been set manually */ /** Stores whether our yaw/pitch/roll (body orientation) has been set manually */
bool m_bDirtyOrientation; bool m_bDirtyOrientation;
/** Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client /** Stores whether we have sent a Velocity packet with a speed of zero (no speed) to the client
Ensures that said packet is sent only once */ Ensures that said packet is sent only once */
bool m_bHasSentNoSpeed; bool m_bHasSentNoSpeed;
/** Stores if the entity is on the ground */ /** Stores if the entity is on the ground */
bool m_bOnGround; bool m_bOnGround;
/** Stores gravity that is applied to an entity every tick /** Stores gravity that is applied to an entity every tick
For realistic effects, this should be negative. For spaaaaaaace, this can be zero or even positive */ For realistic effects, this should be negative. For spaaaaaaace, this can be zero or even positive */
float m_Gravity; float m_Gravity;
/** Last position sent to client via the Relative Move or Teleport packets (not Velocity) /** Last position sent to client via the Relative Move or Teleport packets (not Velocity)
Only updated if cEntity::BroadcastMovementUpdate() is called! */ Only updated if cEntity::BroadcastMovementUpdate() is called! */
Vector3d m_LastPos; Vector3d m_LastPos;
@ -508,31 +508,31 @@ protected:
cWorld * m_WorldTravellingFrom; cWorld * m_WorldTravellingFrom;
eEntityType m_EntityType; eEntityType m_EntityType;
cWorld * m_World; cWorld * m_World;
/// Whether the entity is capable of taking fire or lava damage. /// Whether the entity is capable of taking fire or lava damage.
bool m_IsFireproof; bool m_IsFireproof;
/// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire()) /// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire())
int m_TicksSinceLastBurnDamage; int m_TicksSinceLastBurnDamage;
/// Time, in ticks, since the last damage dealt by standing in lava. Reset to zero when moving out of lava. /// Time, in ticks, since the last damage dealt by standing in lava. Reset to zero when moving out of lava.
int m_TicksSinceLastLavaDamage; int m_TicksSinceLastLavaDamage;
/// Time, in ticks, since the last damage dealt by standing in fire. Reset to zero when moving out of fire. /// Time, in ticks, since the last damage dealt by standing in fire. Reset to zero when moving out of fire.
int m_TicksSinceLastFireDamage; int m_TicksSinceLastFireDamage;
/// Time, in ticks, until the entity extinguishes its fire /// Time, in ticks, until the entity extinguishes its fire
int m_TicksLeftBurning; int m_TicksLeftBurning;
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void. /// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
int m_TicksSinceLastVoidDamage; int m_TicksSinceLastVoidDamage;
/** Does the actual speed-setting. The default implementation just sets the member variable value; /** Does the actual speed-setting. The default implementation just sets the member variable value;
overrides can provide further processing, such as forcing players to move at the given speed. */ overrides can provide further processing, such as forcing players to move at the given speed. */
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
virtual void Destroyed(void) {} // Called after the entity has been destroyed virtual void Destroyed(void) {} // Called after the entity has been destroyed
/** Applies friction to an entity /** Applies friction to an entity
@ -543,7 +543,7 @@ protected:
/** Called in each tick to handle air-related processing i.e. drowning */ /** Called in each tick to handle air-related processing i.e. drowning */
virtual void HandleAir(void); virtual void HandleAir(void);
/** Called once per tick to set IsSwimming and IsSubmerged */ /** Called once per tick to set IsSwimming and IsSubmerged */
virtual void SetSwimState(cChunk & a_Chunk); virtual void SetSwimState(cChunk & a_Chunk);
@ -568,29 +568,29 @@ protected:
/** Portal delay timer and cooldown boolean data */ /** Portal delay timer and cooldown boolean data */
sPortalCooldownData m_PortalCooldownData; sPortalCooldownData m_PortalCooldownData;
/** The number of ticks this entity has been alive for */ /** The number of ticks this entity has been alive for */
long int m_TicksAlive; long int m_TicksAlive;
private: private:
/** Measured in degrees, [-180, +180) */ /** Measured in degrees, [-180, +180) */
double m_HeadYaw; double m_HeadYaw;
/** Measured in degrees, [-180, +180) */ /** Measured in degrees, [-180, +180) */
Vector3d m_Rot; Vector3d m_Rot;
/** Position of the entity's XZ center and Y bottom */ /** Position of the entity's XZ center and Y bottom */
Vector3d m_Pos; Vector3d m_Pos;
/** Measured in meter / second */ /** Measured in meter / second */
Vector3d m_WaterSpeed; Vector3d m_WaterSpeed;
/** Measured in Kilograms (Kg) */ /** Measured in Kilograms (Kg) */
double m_Mass; double m_Mass;
/** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */ /** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */
double m_Width; double m_Width;
/** Height of the entity (Y axis) */ /** Height of the entity (Y axis) */
double m_Height; double m_Height;
@ -600,7 +600,3 @@ private:
} ; // tolua_export } ; // tolua_export
typedef std::list<cEntity *> cEntityList; typedef std::list<cEntity *> cEntityList;

View File

@ -19,7 +19,7 @@ class cPickup :
public cEntity public cEntity
{ {
typedef cEntity super; typedef cEntity super;
public: public:
// tolua_end // tolua_end
@ -37,10 +37,10 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
/** Returns the number of ticks that this entity has existed */ /** Returns the number of ticks that this entity has existed */
int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export int GetAge(void) const { return static_cast<int>(m_Timer / 50); } // tolua_export
/** Set the number of ticks that this entity has existed */ /** Set the number of ticks that this entity has existed */
void SetAge(int a_Age) { m_Timer = (float)(a_Age * 50); } // tolua_export void SetAge(int a_Age) { m_Timer = static_cast<float>(a_Age * 50); } // tolua_export
/** Returns true if the pickup has already been collected */ /** Returns true if the pickup has already been collected */
bool IsCollected(void) const { return m_bCollected; } // tolua_export bool IsCollected(void) const { return m_bCollected; } // tolua_export
@ -59,7 +59,3 @@ private:
bool m_bIsPlayerCreated; bool m_bIsPlayerCreated;
}; // tolua_export }; // tolua_export

View File

@ -19,11 +19,11 @@
// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, // Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
// Copyright (C) 2000 - 2009, Richard J. Wagner // Copyright (C) 2000 - 2009, Richard J. Wagner
// All rights reserved. // All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions // modification, are permitted provided that the following conditions
// are met: // are met:
// //
// 1. Redistributions of source code must retain the above copyright // 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. // notice, this list of conditions and the following disclaimer.
// //
@ -31,10 +31,10 @@
// notice, this list of conditions and the following disclaimer in the // notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution. // documentation and/or other materials provided with the distribution.
// //
// 3. The names of its contributors may not be used to endorse or promote // 3. The names of its contributors may not be used to endorse or promote
// products derived from this software without specific prior written // products derived from this software without specific prior written
// permission. // permission.
// //
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -63,13 +63,13 @@ class MTRand {
// Data // Data
public: public:
typedef UInt32 uint32; // unsigned integer type, at least 32 bits typedef UInt32 uint32; // unsigned integer type, at least 32 bits
enum { N = 624 }; // length of state vector enum { N = 624 }; // length of state vector
enum { SAVE = N + 1 }; // length of array for save() enum { SAVE = N + 1 }; // length of array for save()
protected: protected:
enum { M = 397 }; // period parameter enum { M = 397 }; // period parameter
uint32 state[N]; // internal state uint32 state[N]; // internal state
uint32 *pNext; // next value to get from state uint32 *pNext; // next value to get from state
uint32 left; // number of values left before reload needed uint32 left; // number of values left before reload needed
@ -80,11 +80,11 @@ public:
MTRand( uint32 *const bigSeed, uint32 const seedLength = N ); // or array MTRand( uint32 *const bigSeed, uint32 const seedLength = N ); // or array
MTRand(); // auto-initialize with /dev/urandom or time() and clock() MTRand(); // auto-initialize with /dev/urandom or time() and clock()
MTRand( const MTRand& o ); // copy MTRand( const MTRand& o ); // copy
// Do NOT use for CRYPTOGRAPHY without securely hashing several returned // Do NOT use for CRYPTOGRAPHY without securely hashing several returned
// values together, otherwise the generator state can be learned after // values together, otherwise the generator state can be learned after
// reading 624 consecutive values. // reading 624 consecutive values.
// Access to 32-bit random numbers // Access to 32-bit random numbers
uint32 randInt(); // integer in [0,2^32-1] uint32 randInt(); // integer in [0,2^32-1]
uint32 randInt( const uint32 n ); // integer in [0,n] for n < 2^32 uint32 randInt( const uint32 n ); // integer in [0,n] for n < 2^32
@ -95,18 +95,18 @@ public:
double randDblExc(); // real number in (0,1) double randDblExc(); // real number in (0,1)
double randDblExc( const double n ); // real number in (0,n) double randDblExc( const double n ); // real number in (0,n)
double operator()(); // same as rand() double operator()(); // same as rand()
// Access to 53-bit random numbers (capacity of IEEE double precision) // Access to 53-bit random numbers (capacity of IEEE double precision)
double rand53(); // real number in [0,1) double rand53(); // real number in [0,1)
// Access to nonuniform random number distributions // Access to nonuniform random number distributions
double randNorm( const double mean = 0.0, const double stddev = 1.0 ); double randNorm( const double mean = 0.0, const double stddev = 1.0 );
// Re-seeding functions with same behavior as initializers // Re-seeding functions with same behavior as initializers
void seed( const uint32 oneSeed ); void seed( const uint32 oneSeed );
void seed( uint32 *const bigSeed, const uint32 seedLength = N ); void seed( uint32 *const bigSeed, const uint32 seedLength = N );
void seed(); void seed();
// Saving and loading generator state // Saving and loading generator state
void save( uint32* saveArray ) const; // to array of size SAVE void save( uint32* saveArray ) const; // to array of size SAVE
void load( uint32 *const loadArray ); // from such array void load( uint32 *const loadArray ); // from such array
@ -136,9 +136,9 @@ inline MTRand::uint32 MTRand::hash( time_t t, clock_t c )
// Get a uint32 from t and c // Get a uint32 from t and c
// Better than uint32(x) in case x is floating point in [0,1] // Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk) // Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
static uint32 differ = 0; // guarantee time-based seeds will change static uint32 differ = 0; // guarantee time-based seeds will change
uint32 h1 = 0; uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t; unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i ) for( size_t i = 0; i < sizeof(t); ++i )
@ -185,7 +185,7 @@ inline void MTRand::reload()
for( i = M; --i; ++p ) for( i = M; --i; ++p )
*p = twist( p[MmN], p[0], p[1] ); *p = twist( p[MmN], p[0], p[1] );
*p = twist( p[MmN], p[0], state[0] ); *p = twist( p[MmN], p[0], state[0] );
left = N, pNext = state; left = N, pNext = state;
} }
@ -207,7 +207,7 @@ inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength )
initialize(19650218UL); initialize(19650218UL);
uint32 i = 1; uint32 i = 1;
uint32 j = 0; uint32 j = 0;
uint32 k = ( (uint32)N > seedLength ? (uint32)N : seedLength ); uint32 k = ( static_cast<uint32>(N) > seedLength ? static_cast<uint32>(N) : seedLength );
for( ; k; --k ) for( ; k; --k )
{ {
state[i] = state[i] =
@ -235,7 +235,7 @@ inline void MTRand::seed()
{ {
// Seed the generator with an array from /dev/urandom if available // Seed the generator with an array from /dev/urandom if available
// Otherwise use a hash of time() and clock() values // Otherwise use a hash of time() and clock() values
// First try getting an array from /dev/urandom // First try getting an array from /dev/urandom
/* // Commented out by FakeTruth because doing this 200 times a tick is SUUUUPEERRR SLOW!!~~!\D5Ne /* // Commented out by FakeTruth because doing this 200 times a tick is SUUUUPEERRR SLOW!!~~!\D5Ne
@ -252,7 +252,7 @@ inline void MTRand::seed()
if( success ) { seed( bigSeed, N ); return; } if( success ) { seed( bigSeed, N ); return; }
} }
*/ */
// Was not successful, so use time() and clock() instead // Was not successful, so use time() and clock() instead
seed( hash( time(NULL), clock() ) ); seed( hash( time(NULL), clock() ) );
} }
@ -280,10 +280,10 @@ inline MTRand::uint32 MTRand::randInt()
{ {
// Pull a 32-bit integer from the generator state // Pull a 32-bit integer from the generator state
// Every other access function simply transforms the numbers extracted here // Every other access function simply transforms the numbers extracted here
if( left == 0 ) reload(); if( left == 0 ) reload();
--left; --left;
uint32 s1; uint32 s1;
s1 = *pNext++; s1 = *pNext++;
s1 ^= (s1 >> 11); s1 ^= (s1 >> 11);
@ -302,7 +302,7 @@ inline MTRand::uint32 MTRand::randInt( const uint32 n )
used |= used >> 4; used |= used >> 4;
used |= used >> 8; used |= used >> 8;
used |= used >> 16; used |= used >> 16;
// Draw numbers until one is found in [0,n] // Draw numbers until one is found in [0,n]
uint32 i; uint32 i;
do do

View File

@ -35,12 +35,12 @@ public:
mfNoSpawn, mfNoSpawn,
mfUnhandled, // Nothing. Be sure this is the last and the others are in order mfUnhandled, // Nothing. Be sure this is the last and the others are in order
} ; } ;
// tolua_end // tolua_end
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState; enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality; enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality;
/** Creates the mob object. /** Creates the mob object.
If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig() If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig()
a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22)) a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22))
@ -49,47 +49,47 @@ public:
cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
CLASS_PROTODEF(cMonster) CLASS_PROTODEF(cMonster)
virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override; virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
virtual bool ReachedDestination(void); virtual bool ReachedDestination(void);
// tolua_begin // tolua_begin
eMonsterType GetMobType(void) const {return m_MobType; } eMonsterType GetMobType(void) const {return m_MobType; }
eFamily GetMobFamily(void) const; eFamily GetMobFamily(void) const;
// tolua_end // tolua_end
virtual void CheckEventSeePlayer(void); virtual void CheckEventSeePlayer(void);
virtual void EventSeePlayer(cEntity * a_Player); virtual void EventSeePlayer(cEntity * a_Player);
/// Reads the monster configuration for the specified monster name and assigns it to this object. /// Reads the monster configuration for the specified monster name and assigns it to this object.
void GetMonsterConfig(const AString & a_Name); void GetMonsterConfig(const AString & a_Name);
/** Returns whether this mob is undead (skeleton, zombie, etc.) */ /** Returns whether this mob is undead (skeleton, zombie, etc.) */
virtual bool IsUndead(void); virtual bool IsUndead(void);
virtual void EventLosePlayer(void); virtual void EventLosePlayer(void);
virtual void CheckEventLostPlayer(void); virtual void CheckEventLostPlayer(void);
virtual void InStateIdle (float a_Dt); virtual void InStateIdle (float a_Dt);
virtual void InStateChasing (float a_Dt); virtual void InStateChasing (float a_Dt);
virtual void InStateEscaping(float a_Dt); virtual void InStateEscaping(float a_Dt);
int GetAttackRate() { return (int)m_AttackRate; } int GetAttackRate() { return static_cast<int>(m_AttackRate); }
void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; } void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; }
void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; } void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; }
void SetAttackDamage(int a_AttackDamage) { m_AttackDamage = a_AttackDamage; } void SetAttackDamage(int a_AttackDamage) { m_AttackDamage = a_AttackDamage; }
void SetSightDistance(int a_SightDistance) { m_SightDistance = a_SightDistance; } void SetSightDistance(int a_SightDistance) { m_SightDistance = a_SightDistance; }
float GetDropChanceWeapon() { return m_DropChanceWeapon; } float GetDropChanceWeapon() { return m_DropChanceWeapon; }
float GetDropChanceHelmet() { return m_DropChanceHelmet; } float GetDropChanceHelmet() { return m_DropChanceHelmet; }
float GetDropChanceChestplate() { return m_DropChanceChestplate; } float GetDropChanceChestplate() { return m_DropChanceChestplate; }
@ -102,7 +102,7 @@ public:
void SetDropChanceLeggings(float a_DropChanceLeggings) { m_DropChanceLeggings = a_DropChanceLeggings; } void SetDropChanceLeggings(float a_DropChanceLeggings) { m_DropChanceLeggings = a_DropChanceLeggings; }
void SetDropChanceBoots(float a_DropChanceBoots) { m_DropChanceBoots = a_DropChanceBoots; } void SetDropChanceBoots(float a_DropChanceBoots) { m_DropChanceBoots = a_DropChanceBoots; }
void SetCanPickUpLoot(bool a_CanPickUpLoot) { m_CanPickUpLoot = a_CanPickUpLoot; } void SetCanPickUpLoot(bool a_CanPickUpLoot) { m_CanPickUpLoot = a_CanPickUpLoot; }
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick /// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; } void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
@ -113,7 +113,7 @@ public:
virtual bool IsBaby (void) const { return false; } virtual bool IsBaby (void) const { return false; }
virtual bool IsTame (void) const { return false; } virtual bool IsTame (void) const { return false; }
virtual bool IsSitting (void) const { return false; } virtual bool IsSitting (void) const { return false; }
// tolua_begin // tolua_begin
/** Returns true if the monster has a custom name. */ /** Returns true if the monster has a custom name. */
@ -135,10 +135,10 @@ public:
/// Translates MobType enum to a string, empty string if unknown /// Translates MobType enum to a string, empty string if unknown
static AString MobTypeToString(eMonsterType a_MobType); static AString MobTypeToString(eMonsterType a_MobType);
/// Translates MobType string to the enum, mtInvalidType if not recognized /// Translates MobType string to the enum, mtInvalidType if not recognized
static eMonsterType StringToMobType(const AString & a_MobTypeName); static eMonsterType StringToMobType(const AString & a_MobTypeName);
/// Returns the mob family based on the type /// Returns the mob family based on the type
static eFamily FamilyFromType(eMonsterType a_MobType); static eFamily FamilyFromType(eMonsterType a_MobType);
@ -146,7 +146,7 @@ public:
static int GetSpawnDelay(cMonster::eFamily a_MobFamily); static int GetSpawnDelay(cMonster::eFamily a_MobFamily);
// tolua_end // tolua_end
/** Creates a new object of the specified mob. /** Creates a new object of the specified mob.
a_MobType is the type of the mob to be created a_MobType is the type of the mob to be created
Asserts and returns null if mob type is not specified Asserts and returns null if mob type is not specified
@ -154,7 +154,7 @@ public:
static cMonster * NewMonsterFromType(eMonsterType a_MobType); static cMonster * NewMonsterFromType(eMonsterType a_MobType);
protected: protected:
/* ======= PATHFINDING ======= */ /* ======= PATHFINDING ======= */
/** A pointer to the entity this mobile is aiming to reach */ /** A pointer to the entity this mobile is aiming to reach */
@ -168,7 +168,7 @@ protected:
/** Stores if mobile is currently moving towards the ultimate, final destination */ /** Stores if mobile is currently moving towards the ultimate, final destination */
bool m_bMovingToDestination; bool m_bMovingToDestination;
/** Finds the first non-air block position (not the highest, as cWorld::GetHeight does) /** Finds the first non-air block position (not the highest, as cWorld::GetHeight does)
If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1 If current Y is nonsolid, goes down to try to find a solid block, then returns that + 1
If current Y is solid, goes up to find first nonsolid block, and returns that */ If current Y is solid, goes up to find first nonsolid block, and returns that */
@ -227,14 +227,14 @@ protected:
int m_AttackRange; int m_AttackRange;
float m_AttackInterval; float m_AttackInterval;
int m_SightDistance; int m_SightDistance;
float m_DropChanceWeapon; float m_DropChanceWeapon;
float m_DropChanceHelmet; float m_DropChanceHelmet;
float m_DropChanceChestplate; float m_DropChanceChestplate;
float m_DropChanceLeggings; float m_DropChanceLeggings;
float m_DropChanceBoots; float m_DropChanceBoots;
bool m_CanPickUpLoot; bool m_CanPickUpLoot;
void HandleDaylightBurning(cChunk & a_Chunk); void HandleDaylightBurning(cChunk & a_Chunk);
bool m_BurnsInDaylight; bool m_BurnsInDaylight;
@ -242,22 +242,18 @@ protected:
/** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/ /** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0); void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
/** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/ /** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/
void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0); void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0);
/** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/ /** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/
void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel); void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel);
/** Adds armor that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/ /** Adds armor that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/
void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel); void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel);
/** Adds weapon that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/ /** Adds weapon that is equipped with the chance saved in m_DropChance[...] (this will be greter than 1 if piccked up or 0.085 + (0.01 per LootingLevel) if born with) to the drop*/
void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel); void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel);
} ; // tolua_export } ; // tolua_export

View File

@ -31,20 +31,20 @@ protected:
/// The overriden Execute() method should check this value periodically and terminate if this is true /// The overriden Execute() method should check this value periodically and terminate if this is true
volatile bool m_ShouldTerminate; volatile bool m_ShouldTerminate;
public: public:
cIsThread(const AString & iThreadName); cIsThread(const AString & iThreadName);
virtual ~cIsThread(); virtual ~cIsThread();
/// Starts the thread; returns without waiting for the actual start /// Starts the thread; returns without waiting for the actual start
bool Start(void); bool Start(void);
/// Signals the thread to terminate and waits until it's finished /// Signals the thread to terminate and waits until it's finished
void Stop(void); void Stop(void);
/// Waits for the thread to finish. Doesn't signalize the ShouldTerminate flag /// Waits for the thread to finish. Doesn't signalize the ShouldTerminate flag
bool Wait(void); bool Wait(void);
/// Returns the OS-dependent thread ID for the caller's thread /// Returns the OS-dependent thread ID for the caller's thread
static unsigned long GetCurrentID(void); static unsigned long GetCurrentID(void);
@ -53,7 +53,7 @@ public:
protected: protected:
AString m_ThreadName; AString m_ThreadName;
// Value used for "no handle": // Value used for "no handle":
#ifdef _WIN32 #ifdef _WIN32
#define NULL_HANDLE NULL #define NULL_HANDLE NULL
@ -62,34 +62,34 @@ protected:
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
DWORD m_ThreadID; DWORD m_ThreadID;
HANDLE m_Handle; HANDLE m_Handle;
static DWORD __stdcall thrExecute(LPVOID a_Param) static DWORD __stdcall thrExecute(LPVOID a_Param)
{ {
// Create a window so that the thread can be identified by 3rd party tools: // Create a window so that the thread can be identified by 3rd party tools:
HWND IdentificationWnd = CreateWindowA("STATIC", ((cIsThread *)a_Param)->m_ThreadName.c_str(), 0, 0, 0, 0, WS_OVERLAPPED, NULL, NULL, NULL, NULL); HWND IdentificationWnd = CreateWindowA("STATIC", ((cIsThread *)a_Param)->m_ThreadName.c_str(), 0, 0, 0, 0, WS_OVERLAPPED, NULL, NULL, NULL, NULL);
// Run the thread: // Run the thread:
((cIsThread *)a_Param)->Execute(); ((cIsThread *)a_Param)->Execute();
// Destroy the identification window: // Destroy the identification window:
DestroyWindow(IdentificationWnd); DestroyWindow(IdentificationWnd);
return 0; return 0;
} }
#else // _WIN32 #else // _WIN32
pthread_t m_Handle; pthread_t m_Handle;
static void * thrExecute(void * a_Param) static void * thrExecute(void * a_Param)
{ {
((cIsThread *)a_Param)->Execute(); (static_cast<cIsThread *>(a_Param))->Execute();
return NULL; return NULL;
} }
#endif // else _WIN32 #endif // else _WIN32
} ; } ;
@ -98,7 +98,3 @@ protected:
#endif // CISTHREAD_H_INCLUDED #endif // CISTHREAD_H_INCLUDED

View File

@ -84,7 +84,7 @@ class cWorld :
public: public:
// tolua_end // tolua_end
/** A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the destructor */ /** A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the destructor */
class cLock : class cLock :
public cCSLock public cCSLock
@ -94,7 +94,7 @@ public:
cLock(cWorld & a_World); cLock(cWorld & a_World);
} ; } ;
/** A common ancestor for all tasks queued onto the tick thread */ /** A common ancestor for all tasks queued onto the tick thread */
class cTask class cTask
{ {
@ -102,10 +102,10 @@ public:
virtual ~cTask() {} virtual ~cTask() {}
virtual void Run(cWorld & a_World) = 0; virtual void Run(cWorld & a_World) = 0;
} ; } ;
typedef std::vector<cTask *> cTasks; typedef std::vector<cTask *> cTasks;
class cTaskSaveAllChunks : class cTaskSaveAllChunks :
public cTask public cTask
{ {
@ -113,7 +113,7 @@ public:
// cTask overrides: // cTask overrides:
virtual void Run(cWorld & a_World) override; virtual void Run(cWorld & a_World) override;
} ; } ;
class cTaskUnloadUnusedChunks : class cTaskUnloadUnusedChunks :
public cTask public cTask
@ -142,7 +142,7 @@ public:
{ {
return "cWorld"; return "cWorld";
} }
// tolua_begin // tolua_begin
int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; } int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; }
@ -159,7 +159,7 @@ public:
virtual Int64 GetWorldAge (void) const override { return m_WorldAge; } virtual Int64 GetWorldAge (void) const override { return m_WorldAge; }
virtual int GetTimeOfDay(void) const override { return m_TimeOfDay; } virtual int GetTimeOfDay(void) const override { return m_TimeOfDay; }
void SetTicksUntilWeatherChange(int a_WeatherInterval) void SetTicksUntilWeatherChange(int a_WeatherInterval)
{ {
m_WeatherInterval = a_WeatherInterval; m_WeatherInterval = a_WeatherInterval;
@ -168,42 +168,42 @@ public:
virtual void SetTimeOfDay(int a_TimeOfDay) override virtual void SetTimeOfDay(int a_TimeOfDay) override
{ {
m_TimeOfDay = a_TimeOfDay; m_TimeOfDay = a_TimeOfDay;
m_TimeOfDaySecs = (double)a_TimeOfDay / 20.0; m_TimeOfDaySecs = static_cast<double>(a_TimeOfDay) / 20.0;
UpdateSkyDarkness(); UpdateSkyDarkness();
BroadcastTimeUpdate(); BroadcastTimeUpdate();
} }
/** Returns the default weather interval for the specific weather type. /** Returns the default weather interval for the specific weather type.
Returns -1 for any unknown weather. */ Returns -1 for any unknown weather. */
int GetDefaultWeatherInterval(eWeather a_Weather); int GetDefaultWeatherInterval(eWeather a_Weather);
/** Returns the current game mode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable */ /** Returns the current game mode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable */
eGameMode GetGameMode(void) const { return m_GameMode; } eGameMode GetGameMode(void) const { return m_GameMode; }
/** Returns true if the world is in Creative mode */ /** Returns true if the world is in Creative mode */
bool IsGameModeCreative(void) const { return (m_GameMode == gmCreative); } bool IsGameModeCreative(void) const { return (m_GameMode == gmCreative); }
/** Returns true if the world is in Survival mode */ /** Returns true if the world is in Survival mode */
bool IsGameModeSurvival(void) const { return (m_GameMode == gmSurvival); } bool IsGameModeSurvival(void) const { return (m_GameMode == gmSurvival); }
/** Returns true if the world is in Adventure mode */ /** Returns true if the world is in Adventure mode */
bool IsGameModeAdventure(void) const { return (m_GameMode == gmAdventure); } bool IsGameModeAdventure(void) const { return (m_GameMode == gmAdventure); }
/** Returns true if the world is in Spectator mode */ /** Returns true if the world is in Spectator mode */
bool IsGameModeSpectator(void) const { return (m_GameMode == gmSpectator); } bool IsGameModeSpectator(void) const { return (m_GameMode == gmSpectator); }
bool IsPVPEnabled(void) const { return m_bEnabledPVP; } bool IsPVPEnabled(void) const { return m_bEnabledPVP; }
bool IsDeepSnowEnabled(void) const { return m_IsDeepSnowEnabled; } bool IsDeepSnowEnabled(void) const { return m_IsDeepSnowEnabled; }
bool ShouldLavaSpawnFire(void) const { return m_ShouldLavaSpawnFire; } bool ShouldLavaSpawnFire(void) const { return m_ShouldLavaSpawnFire; }
bool VillagersShouldHarvestCrops(void) const { return m_VillagersShouldHarvestCrops; } bool VillagersShouldHarvestCrops(void) const { return m_VillagersShouldHarvestCrops; }
virtual eDimension GetDimension(void) const { return m_Dimension; } virtual eDimension GetDimension(void) const { return m_Dimension; }
/** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */ /** Returns the world height at the specified coords; waits for the chunk to get loaded / generated */
virtual int GetHeight(int a_BlockX, int a_BlockZ); virtual int GetHeight(int a_BlockX, int a_BlockZ);
// tolua_end // tolua_end
/** Retrieves the world height at the specified coords; returns false if chunk not loaded / generated */ /** Retrieves the world height at the specified coords; returns false if chunk not loaded / generated */
@ -258,35 +258,35 @@ public:
void BroadcastTimeUpdate (const cClientHandle * a_Exclude = NULL); void BroadcastTimeUpdate (const cClientHandle * a_Exclude = NULL);
virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) override;
void BroadcastWeather (eWeather a_Weather, const cClientHandle * a_Exclude = NULL); void BroadcastWeather (eWeather a_Weather, const cClientHandle * a_Exclude = NULL);
virtual cBroadcastInterface & GetBroadcastManager(void) override virtual cBroadcastInterface & GetBroadcastManager(void) override
{ {
return *this; return *this;
} }
/** If there is a block entity at the specified coords, sends it to the client specified */ /** If there is a block entity at the specified coords, sends it to the client specified */
void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client); void SendBlockEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cClientHandle & a_Client);
void MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ); void MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ);
void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false); void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false);
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ); void MarkChunkSaving(int a_ChunkX, int a_ChunkZ);
void MarkChunkSaved (int a_ChunkX, int a_ChunkZ); void MarkChunkSaved (int a_ChunkX, int a_ChunkZ);
/** Puts the chunk data into a queue to be set into the chunkmap in the tick thread. /** Puts the chunk data into a queue to be set into the chunkmap in the tick thread.
If the chunk data doesn't contain valid biomes, the biomes are calculated before adding the data into the queue. */ If the chunk data doesn't contain valid biomes, the biomes are calculated before adding the data into the queue. */
void QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData); void QueueSetChunkData(const cSetChunkDataPtr & a_SetChunkData);
void ChunkLighted( void ChunkLighted(
int a_ChunkX, int a_ChunkZ, int a_ChunkX, int a_ChunkZ,
const cChunkDef::BlockNibbles & a_BlockLight, const cChunkDef::BlockNibbles & a_BlockLight,
const cChunkDef::BlockNibbles & a_SkyLight const cChunkDef::BlockNibbles & a_SkyLight
); );
bool GetChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataCallback & a_Callback); bool GetChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataCallback & a_Callback);
/** Gets the chunk's blocks, only the block types */ /** Gets the chunk's blocks, only the block types */
bool GetChunkBlockTypes(int a_ChunkX, int a_ChunkZ, BLOCKTYPE * a_BlockTypes); bool GetChunkBlockTypes(int a_ChunkX, int a_ChunkZ, BLOCKTYPE * a_BlockTypes);
/** Returns true iff the chunk is in the loader / generator queue. */ /** Returns true iff the chunk is in the loader / generator queue. */
bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const; bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const;
@ -294,10 +294,10 @@ public:
bool IsChunkValid(int a_ChunkX, int a_ChunkZ) const; bool IsChunkValid(int a_ChunkX, int a_ChunkZ) const;
bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const; bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) const;
/** Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading*/ /** Queues a task to unload unused chunks onto the tick thread. The prefferred way of unloading*/
void QueueUnloadUnusedChunks(void); // tolua_export void QueueUnloadUnusedChunks(void); // tolua_export
void CollectPickupsByPlayer(cPlayer * a_Player); void CollectPickupsByPlayer(cPlayer * a_Player);
/** Adds the player to the world. /** Adds the player to the world.
@ -319,21 +319,21 @@ public:
/** Finds a player from a partial or complete player name and calls the callback - case-insensitive */ /** Finds a player from a partial or complete player name and calls the callback - case-insensitive */
bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action) // TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true); cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player
/** Adds the entity into its appropriate chunk; takes ownership of the entity ptr. /** Adds the entity into its appropriate chunk; takes ownership of the entity ptr.
The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread. */ The entity is added lazily - this function only puts it in a queue that is then processed by the Tick thread. */
void AddEntity(cEntity * a_Entity); void AddEntity(cEntity * a_Entity);
bool HasEntity(int a_UniqueID); bool HasEntity(int a_UniqueID);
/** Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true */ /** Calls the callback for each entity in the entire world; returns true if all entities processed, false if the callback aborted by returning true */
bool ForEachEntity(cEntityCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachEntity(cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
/** Calls the callback for each entity in the specified chunk; returns true if all entities processed, false if the callback aborted by returning true */ /** Calls the callback for each entity in the specified chunk; returns true if all entities processed, false if the callback aborted by returning true */
bool ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback & a_Callback); // Exported in ManualBindings.cpp
@ -347,36 +347,36 @@ public:
/** Compares clients of two chunks, calls the callback accordingly */ /** Compares clients of two chunks, calls the callback accordingly */
void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback & a_Callback); void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback & a_Callback);
/** Adds client to a chunk, if not already present; returns true if added, false if present */ /** Adds client to a chunk, if not already present; returns true if added, false if present */
bool AddChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client); bool AddChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
/** Removes client from the chunk specified */ /** Removes client from the chunk specified */
void RemoveChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client); void RemoveChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
/** Removes the client from all chunks it is present in */ /** Removes the client from all chunks it is present in */
void RemoveClientFromChunks(cClientHandle * a_Client); void RemoveClientFromChunks(cClientHandle * a_Client);
/** Sends the chunk to the client specified, if the client doesn't have the chunk yet. /** Sends the chunk to the client specified, if the client doesn't have the chunk yet.
If chunk not valid, the request is postponed (ChunkSender will send that chunk when it becomes valid + lighted). */ If chunk not valid, the request is postponed (ChunkSender will send that chunk when it becomes valid + lighted). */
void SendChunkTo(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client); void SendChunkTo(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
/** Sends the chunk to the client specified, even if the client already has the chunk. /** Sends the chunk to the client specified, even if the client already has the chunk.
If the chunk's not valid, the request is postponed (ChunkSender will send that chunk when it becomes valid + lighted). */ If the chunk's not valid, the request is postponed (ChunkSender will send that chunk when it becomes valid + lighted). */
void ForceSendChunkTo(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client); void ForceSendChunkTo(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
/** Removes client from ChunkSender's queue of chunks to be sent */ /** Removes client from ChunkSender's queue of chunks to be sent */
void RemoveClientFromChunkSender(cClientHandle * a_Client); void RemoveClientFromChunkSender(cClientHandle * a_Client);
/** Touches the chunk, causing it to be loaded or generated */ /** Touches the chunk, causing it to be loaded or generated */
void TouchChunk(int a_ChunkX, int a_ChunkZ); void TouchChunk(int a_ChunkX, int a_ChunkZ);
/** Marks the chunk as failed-to-load: */ /** Marks the chunk as failed-to-load: */
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ); void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ);
/** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as UpdateSign() */ /** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as UpdateSign() */
bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp bool SetSignLines(int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
/** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as SetSignLines() */ /** Sets the sign text, asking plugins for permission first. a_Player is the player who this change belongs to, may be NULL. Returns true if sign text changed. Same as SetSignLines() */
bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp bool UpdateSign(int a_X, int a_Y, int a_Z, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player = NULL); // Exported in ManualBindings.cpp
@ -391,25 +391,25 @@ public:
/** Regenerate the given chunk: */ /** Regenerate the given chunk: */
void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
/** Generates the given chunk */ /** Generates the given chunk */
void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
/** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */ /** Queues a chunk for lighting; a_Callback is called after the chunk is lighted */
void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = NULL); void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = NULL);
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ); bool IsChunkLighted(int a_ChunkX, int a_ChunkZ);
/** Calls the callback for each chunk in the coords specified (all cords are inclusive). Returns true if all chunks have been processed successfully */ /** Calls the callback for each chunk in the coords specified (all cords are inclusive). Returns true if all chunks have been processed successfully */
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override; virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override;
// tolua_begin // tolua_begin
/** Sets the block at the specified coords to the specified value. /** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed. Full processing, incl. updating neighbors, is performed.
*/ */
void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true); void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true);
/** Sets the block at the specified coords to the specified value. /** Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates. The replacement doesn't trigger block updates.
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block) The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
@ -418,7 +418,7 @@ public:
{ {
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta); m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
} }
/** Queues a SetBlock() with the specified parameters after the specified number of ticks. /** Queues a SetBlock() with the specified parameters after the specified number of ticks.
Calls SetBlock(), so performs full processing of the replaced block. Calls SetBlock(), so performs full processing of the replaced block.
*/ */
@ -426,12 +426,12 @@ public:
{ {
m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, GetWorldAge() + a_TickDelay, a_PreviousBlockType); m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, GetWorldAge() + a_TickDelay, a_PreviousBlockType);
} }
BLOCKTYPE GetBlock (int a_BlockX, int a_BlockY, int a_BlockZ) BLOCKTYPE GetBlock (int a_BlockX, int a_BlockY, int a_BlockZ)
{ {
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ); return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
} }
NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ) NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ)
{ {
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
@ -439,37 +439,37 @@ public:
void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData); void SetBlockMeta (int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData);
NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ); NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ);
NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ); NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ);
// tolua_end // tolua_end
bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); // TODO: Exported in ManualBindings.cpp bool GetBlockTypeMeta (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); // TODO: Exported in ManualBindings.cpp
bool GetBlockInfo (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); // TODO: Exported in ManualBindings.cpp bool GetBlockInfo (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight); // TODO: Exported in ManualBindings.cpp
// TODO: NIBBLETYPE GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ); // TODO: NIBBLETYPE GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ);
// tolua_begin // tolua_begin
// Vector3i variants: // Vector3i variants:
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); } void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta); }
BLOCKTYPE GetBlock (const Vector3i & a_Pos) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z); } BLOCKTYPE GetBlock (const Vector3i & a_Pos) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z); }
NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z); } NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z); }
void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData); } void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData); }
// tolua_end // tolua_end
/** Writes the block area into the specified coords. /** Writes the block area into the specified coords.
Returns true if all chunks have been processed. Returns true if all chunks have been processed.
Prefer cBlockArea::Write() instead, this is the internal implementation; cBlockArea does error checking, too. Prefer cBlockArea::Write() instead, this is the internal implementation; cBlockArea does error checking, too.
a_DataTypes is a bitmask of cBlockArea::baXXX constants ORed together. a_DataTypes is a bitmask of cBlockArea::baXXX constants ORed together.
*/ */
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override; virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override;
// tolua_begin // tolua_begin
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */ /** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) override; virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) override;
/** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified: */ /** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified: */
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) override; virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) override;
/** Spawns an falling block entity at the given position. It returns the UniqueID of the spawned falling block. */ /** Spawns an falling block entity at the given position. It returns the UniqueID of the spawned falling block. */
int SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta); int SpawnFallingBlock(int a_X, int a_Y, int a_Z, BLOCKTYPE BlockType, NIBBLETYPE BlockMeta);
@ -486,10 +486,10 @@ public:
/** Replaces world blocks with a_Blocks, if they are of type a_FilterBlockType */ /** Replaces world blocks with a_Blocks, if they are of type a_FilterBlockType */
void ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_FilterBlockType); void ReplaceBlocks(const sSetBlockVector & a_Blocks, BLOCKTYPE a_FilterBlockType);
/** Retrieves block types of the specified blocks. If a chunk is not loaded, doesn't modify the block. Returns true if all blocks were read. */ /** Retrieves block types of the specified blocks. If a chunk is not loaded, doesn't modify the block. Returns true if all blocks were read. */
bool GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure); bool GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure);
// tolua_begin // tolua_begin
bool DigBlock (int a_X, int a_Y, int a_Z); bool DigBlock (int a_X, int a_Y, int a_Z);
virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) override; virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) override;
@ -500,21 +500,21 @@ public:
/** Wakes up the simulators for the specified block */ /** Wakes up the simulators for the specified block */
virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) override; virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) override;
/** Wakes up the simulators for the specified area of blocks */ /** Wakes up the simulators for the specified area of blocks */
void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ); void WakeUpSimulatorsInArea(int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ);
// tolua_end // tolua_end
inline cSimulatorManager * GetSimulatorManager(void) { return m_SimulatorManager; } inline cSimulatorManager * GetSimulatorManager(void) { return m_SimulatorManager; }
inline cFluidSimulator * GetWaterSimulator(void) { return m_WaterSimulator; } inline cFluidSimulator * GetWaterSimulator(void) { return m_WaterSimulator; }
inline cFluidSimulator * GetLavaSimulator (void) { return m_LavaSimulator; } inline cFluidSimulator * GetLavaSimulator (void) { return m_LavaSimulator; }
inline cRedstoneSimulator<cChunk, cWorld> * GetRedstoneSimulator(void) { return m_RedstoneSimulator; } inline cRedstoneSimulator<cChunk, cWorld> * GetRedstoneSimulator(void) { return m_RedstoneSimulator; }
/** Calls the callback for each block entity in the specified chunk; returns true if all block entities processed, false if the callback aborted by returning true */ /** Calls the callback for each block entity in the specified chunk; returns true if all block entities processed, false if the callback aborted by returning true */
bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback & a_Callback); // Exported in ManualBindings.cpp
/** Calls the callback for each chest in the specified chunk; returns true if all chests processed, false if the callback aborted by returning true */ /** Calls the callback for each chest in the specified chunk; returns true if all chests processed, false if the callback aborted by returning true */
bool ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachChestInChunk(int a_ChunkX, int a_ChunkZ, cChestCallback & a_Callback); // Exported in ManualBindings.cpp
@ -529,7 +529,7 @@ public:
/** Calls the callback for each furnace in the specified chunk; returns true if all furnaces processed, false if the callback aborted by returning true */ /** Calls the callback for each furnace in the specified chunk; returns true if all furnaces processed, false if the callback aborted by returning true */
bool ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback & a_Callback); // Exported in ManualBindings.cpp bool ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback & a_Callback); // Exported in ManualBindings.cpp
/** Does an explosion with the specified strength at the specified coordinate /** Does an explosion with the specified strength at the specified coordinate
a_SourceData exact type depends on the a_Source: a_SourceData exact type depends on the a_Source:
| esOther | void * | | esOther | void * |
@ -580,29 +580,29 @@ public:
/** Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found */ /** Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found */
bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Exported in ManualBindings.cpp bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Exported in ManualBindings.cpp
/** a_Player is using block entity at [x, y, z], handle that: */ /** a_Player is using block entity at [x, y, z], handle that: */
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ); } // tolua_export void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ); } // tolua_export
/** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */ /** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback); bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback);
void GrowTreeImage(const sSetBlockVector & a_Blocks); void GrowTreeImage(const sSetBlockVector & a_Blocks);
// tolua_begin // tolua_begin
/** Grows a tree at the specified coords, either from a sapling there, or based on the biome */ /** Grows a tree at the specified coords, either from a sapling there, or based on the biome */
void GrowTree (int a_BlockX, int a_BlockY, int a_BlockZ); void GrowTree (int a_BlockX, int a_BlockY, int a_BlockZ);
/** Grows a tree at the specified coords, based on the sapling meta provided */ /** Grows a tree at the specified coords, based on the sapling meta provided */
void GrowTreeFromSapling(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_SaplingMeta); void GrowTreeFromSapling(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_SaplingMeta);
/** Grows a tree at the specified coords, based on the biome in the place */ /** Grows a tree at the specified coords, based on the biome in the place */
void GrowTreeByBiome (int a_BlockX, int a_BlockY, int a_BlockZ); void GrowTreeByBiome (int a_BlockX, int a_BlockY, int a_BlockZ);
/** Grows the plant at the specified block to its ripe stage (bonemeal used); returns false if the block is not growable. If a_IsBonemeal is true, block is not grown if not allowed in world.ini */ /** Grows the plant at the specified block to its ripe stage (bonemeal used); returns false if the block is not growable. If a_IsBonemeal is true, block is not grown if not allowed in world.ini */
bool GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal = false); bool GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal = false);
/** Grows a cactus present at the block specified by the amount of blocks specified, up to the max height specified in the config */ /** Grows a cactus present at the block specified by the amount of blocks specified, up to the max height specified in the config */
void GrowCactus(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow); void GrowCactus(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow);
@ -611,18 +611,18 @@ public:
/** Grows a sugarcane present at the block specified by the amount of blocks specified, up to the max height specified in the config */ /** Grows a sugarcane present at the block specified by the amount of blocks specified, up to the max height specified in the config */
void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow); void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow);
/** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */ /** Returns the biome at the specified coords. Reads the biome from the chunk, if loaded, otherwise uses the world generator to provide the biome value */
EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ); EMCSBiome GetBiomeAt(int a_BlockX, int a_BlockZ);
/** Sets the biome at the specified coords. Returns true if successful, false if not (chunk not loaded). /** Sets the biome at the specified coords. Returns true if successful, false if not (chunk not loaded).
Doesn't resend the chunk to clients, use ForceSendChunkTo() for that. */ Doesn't resend the chunk to clients, use ForceSendChunkTo() for that. */
bool SetBiomeAt(int a_BlockX, int a_BlockZ, EMCSBiome a_Biome); bool SetBiomeAt(int a_BlockX, int a_BlockZ, EMCSBiome a_Biome);
/** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded). /** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded).
(Re)sends the chunks to their relevant clients if successful. */ (Re)sends the chunks to their relevant clients if successful. */
bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome); bool SetAreaBiome(int a_MinX, int a_MaxX, int a_MinZ, int a_MaxZ, EMCSBiome a_Biome);
/** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded). /** Sets the biome at the area. Returns true if successful, false if any subarea failed (chunk not loaded).
(Re)sends the chunks to their relevant clients if successful. (Re)sends the chunks to their relevant clients if successful.
The cuboid needn't be sorted. */ The cuboid needn't be sorted. */
@ -630,7 +630,7 @@ public:
/** Returns the name of the world */ /** Returns the name of the world */
const AString & GetName(void) const { return m_WorldName; } const AString & GetName(void) const { return m_WorldName; }
/** Returns the name of the world.ini file used by this world */ /** Returns the name of the world.ini file used by this world */
const AString & GetIniFileName(void) const {return m_IniFileName; } const AString & GetIniFileName(void) const {return m_IniFileName; }
@ -661,18 +661,18 @@ public:
AString GetLinkedOverworldName(void) const { return m_OverworldName; } AString GetLinkedOverworldName(void) const { return m_OverworldName; }
void SetLinkedOverworldName(const AString & a_Name) { m_OverworldName = a_Name; } void SetLinkedOverworldName(const AString & a_Name) { m_OverworldName = a_Name; }
// tolua_end // tolua_end
/** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */ /** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */
void SaveAllChunks(void); void SaveAllChunks(void);
/** Queues a task to save all chunks onto the tick thread. The prefferred way of saving chunks from external sources */ /** Queues a task to save all chunks onto the tick thread. The prefferred way of saving chunks from external sources */
void QueueSaveAllChunks(void); // tolua_export void QueueSaveAllChunks(void); // tolua_export
/** Queues a task onto the tick thread. The task object will be deleted once the task is finished */ /** Queues a task onto the tick thread. The task object will be deleted once the task is finished */
void QueueTask(cTask * a_Task); // Exported in ManualBindings.cpp void QueueTask(cTask * a_Task); // Exported in ManualBindings.cpp
/** Queues a task onto the tick thread, with the specified delay. /** Queues a task onto the tick thread, with the specified delay.
The task object will be deleted once the task is finished */ The task object will be deleted once the task is finished */
void ScheduleTask(int a_DelayTicks, cTask * a_Task); void ScheduleTask(int a_DelayTicks, cTask * a_Task);
@ -690,13 +690,13 @@ public:
inline size_t GetStorageSaveQueueLength(void) { return m_Storage.GetSaveQueueLength(); } // tolua_export inline size_t GetStorageSaveQueueLength(void) { return m_Storage.GetSaveQueueLength(); } // tolua_export
void InitializeSpawn(void); void InitializeSpawn(void);
/** Starts threads that belong to this world */ /** Starts threads that belong to this world */
void Start(void); void Start(void);
/** Stops threads that belong to this world (part of deinit) */ /** Stops threads that belong to this world (part of deinit) */
void Stop(void); void Stop(void);
/** Processes the blocks queued for ticking with a delay (m_BlockTickQueue[]) */ /** Processes the blocks queued for ticking with a delay (m_BlockTickQueue[]) */
void TickQueuedBlocks(void); void TickQueuedBlocks(void);
@ -714,34 +714,34 @@ public:
// tolua_begin // tolua_begin
/** Casts a thunderbolt at the specified coords */ /** Casts a thunderbolt at the specified coords */
void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ); void CastThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ);
/** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */ /** Sets the specified weather; resets weather interval; asks and notifies plugins of the change */
void SetWeather(eWeather a_NewWeather); void SetWeather(eWeather a_NewWeather);
/** Forces a weather change in the next game tick */ /** Forces a weather change in the next game tick */
void ChangeWeather(void); void ChangeWeather(void);
/** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */ /** Returns the current weather. Instead of comparing values directly to the weather constants, use IsWeatherXXX() functions, if possible */
eWeather GetWeather(void) const { return m_Weather; } eWeather GetWeather(void) const { return m_Weather; }
/** Returns true if the current weather is sun */ /** Returns true if the current weather is sun */
bool IsWeatherSunny(void) const { return (m_Weather == wSunny); } bool IsWeatherSunny(void) const { return (m_Weather == wSunny); }
/** Returns true if it is sunny at the specified location. This takes into account biomes. */ /** Returns true if it is sunny at the specified location. This takes into account biomes. */
bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ) bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ)
{ {
return (IsWeatherSunny() || IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); return (IsWeatherSunny() || IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
} }
/** Returns true if the current weather is rain */ /** Returns true if the current weather is rain */
bool IsWeatherRain(void) const { return (m_Weather == wRain); } bool IsWeatherRain(void) const { return (m_Weather == wRain); }
/** Returns true if it is raining at the specified location. This takes into account biomes. */ /** Returns true if it is raining at the specified location. This takes into account biomes. */
bool IsWeatherRainAt(int a_BlockX, int a_BlockZ) bool IsWeatherRainAt(int a_BlockX, int a_BlockZ)
{ {
return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
} }
/** Returns true if the current weather is stormy */ /** Returns true if the current weather is stormy */
bool IsWeatherStorm(void) const { return (m_Weather == wStorm); } bool IsWeatherStorm(void) const { return (m_Weather == wStorm); }
@ -750,10 +750,10 @@ public:
{ {
return (IsWeatherStorm() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ))); return (IsWeatherStorm() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
} }
/** Returns true if the current weather has any precipitation - rain, storm or snow */ /** Returns true if the current weather has any precipitation - rain, storm or snow */
bool IsWeatherWet(void) const { return !IsWeatherSunny(); } bool IsWeatherWet(void) const { return !IsWeatherSunny(); }
/** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */ /** Returns true if it is raining, stormy or snowing at the specified location. This takes into account biomes. */
virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ) virtual bool IsWeatherWetAt(int a_BlockX, int a_BlockZ)
{ {
@ -765,33 +765,33 @@ public:
cChunkGenerator & GetGenerator(void) { return m_Generator; } cChunkGenerator & GetGenerator(void) { return m_Generator; }
cWorldStorage & GetStorage (void) { return m_Storage; } cWorldStorage & GetStorage (void) { return m_Storage; }
cChunkMap * GetChunkMap (void) { return m_ChunkMap; } cChunkMap * GetChunkMap (void) { return m_ChunkMap; }
/** Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call */ /** Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call */
void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export void SetNextBlockTick(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
int GetMaxSugarcaneHeight(void) const { return m_MaxSugarcaneHeight; } // tolua_export int GetMaxSugarcaneHeight(void) const { return m_MaxSugarcaneHeight; } // tolua_export
int GetMaxCactusHeight (void) const { return m_MaxCactusHeight; } // tolua_export int GetMaxCactusHeight (void) const { return m_MaxCactusHeight; } // tolua_export
bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */ /** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) override; // tolua_export virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) override; // tolua_export
int SpawnMobFinalize(cMonster* a_Monster); int SpawnMobFinalize(cMonster* a_Monster);
/** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise /** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise
Item parameter used currently for Fireworks to correctly set entity metadata based on item metadata Item parameter used currently for Fireworks to correctly set entity metadata based on item metadata
*/ */
int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = NULL); // tolua_export int CreateProjectile(double a_PosX, double a_PosY, double a_PosZ, cProjectileEntity::eKind a_Kind, cEntity * a_Creator, const cItem * a_Item, const Vector3d * a_Speed = NULL); // tolua_export
/** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */ /** Returns a random number from the m_TickRand in range [0 .. a_Range]. To be used only in the tick thread! */
int GetTickRandomNumber(unsigned a_Range) { return (int)(m_TickRand.randInt(a_Range)); } int GetTickRandomNumber(unsigned a_Range) { return static_cast<int>(m_TickRand.randInt(a_Range)); }
/** Appends all usernames starting with a_Text (case-insensitive) into Results */ /** Appends all usernames starting with a_Text (case-insensitive) into Results */
void TabCompleteUserName(const AString & a_Text, AStringVector & a_Results); void TabCompleteUserName(const AString & a_Text, AStringVector & a_Results);
/** Get the current darkness level based on the time */ /** Get the current darkness level based on the time */
NIBBLETYPE GetSkyDarkness() { return m_SkyDarkness; } NIBBLETYPE GetSkyDarkness() { return m_SkyDarkness; }
/** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk. /** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter for the specified chunk.
If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of
whether it has any clients or not. whether it has any clients or not.
@ -802,43 +802,43 @@ public:
private: private:
friend class cRoot; friend class cRoot;
class cTickThread : class cTickThread :
public cIsThread public cIsThread
{ {
typedef cIsThread super; typedef cIsThread super;
public: public:
cTickThread(cWorld & a_World); cTickThread(cWorld & a_World);
protected: protected:
cWorld & m_World; cWorld & m_World;
// cIsThread overrides: // cIsThread overrides:
virtual void Execute(void) override; virtual void Execute(void) override;
} ; } ;
/** Implementation of the callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */ /** Implementation of the callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
class cChunkGeneratorCallbacks : class cChunkGeneratorCallbacks :
public cChunkGenerator::cChunkSink, public cChunkGenerator::cChunkSink,
public cChunkGenerator::cPluginInterface public cChunkGenerator::cPluginInterface
{ {
cWorld * m_World; cWorld * m_World;
// cChunkSink overrides: // cChunkSink overrides:
virtual void OnChunkGenerated (cChunkDesc & a_ChunkDesc) override; virtual void OnChunkGenerated (cChunkDesc & a_ChunkDesc) override;
virtual bool IsChunkValid (int a_ChunkX, int a_ChunkZ) override; virtual bool IsChunkValid (int a_ChunkX, int a_ChunkZ) override;
virtual bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) override; virtual bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) override;
virtual bool IsChunkQueued (int a_ChunkX, int a_ChunkZ) override; virtual bool IsChunkQueued (int a_ChunkX, int a_ChunkZ) override;
// cPluginInterface overrides: // cPluginInterface overrides:
virtual void CallHookChunkGenerating(cChunkDesc & a_ChunkDesc) override; virtual void CallHookChunkGenerating(cChunkDesc & a_ChunkDesc) override;
virtual void CallHookChunkGenerated (cChunkDesc & a_ChunkDesc) override; virtual void CallHookChunkGenerated (cChunkDesc & a_ChunkDesc) override;
public: public:
cChunkGeneratorCallbacks(cWorld & a_World); cChunkGeneratorCallbacks(cWorld & a_World);
} ; } ;
/** A container for tasks that have been scheduled for a specific game tick */ /** A container for tasks that have been scheduled for a specific game tick */
class cScheduledTask class cScheduledTask
@ -846,14 +846,14 @@ private:
public: public:
Int64 m_TargetTick; Int64 m_TargetTick;
cTask * m_Task; cTask * m_Task;
/** Creates a new scheduled task; takes ownership of the task object passed to it. */ /** Creates a new scheduled task; takes ownership of the task object passed to it. */
cScheduledTask(Int64 a_TargetTick, cTask * a_Task) : cScheduledTask(Int64 a_TargetTick, cTask * a_Task) :
m_TargetTick(a_TargetTick), m_TargetTick(a_TargetTick),
m_Task(a_Task) m_Task(a_Task)
{ {
} }
virtual ~cScheduledTask() virtual ~cScheduledTask()
{ {
delete m_Task; delete m_Task;
@ -872,15 +872,15 @@ private:
AString m_OverworldName; AString m_OverworldName;
AString m_IniFileName; AString m_IniFileName;
/** Name of the storage schema used to load and save chunks */ /** Name of the storage schema used to load and save chunks */
AString m_StorageSchema; AString m_StorageSchema;
int m_StorageCompressionFactor; int m_StorageCompressionFactor;
/** The dimension of the world, used by the client to provide correct lighting scheme */ /** The dimension of the world, used by the client to provide correct lighting scheme */
eDimension m_Dimension; eDimension m_Dimension;
/** This random generator is to be used only in the Tick() method, and thus only in the World-Tick-thread (MTRand is not exactly thread-safe) */ /** This random generator is to be used only in the Tick() method, and thus only in the World-Tick-thread (MTRand is not exactly thread-safe) */
MTRand m_TickRand; MTRand m_TickRand;
@ -909,7 +909,7 @@ private:
bool m_IsDeepSnowEnabled; bool m_IsDeepSnowEnabled;
bool m_ShouldLavaSpawnFire; bool m_ShouldLavaSpawnFire;
bool m_VillagersShouldHarvestCrops; bool m_VillagersShouldHarvestCrops;
std::vector<BlockTickQueueItem *> m_BlockTickQueue; std::vector<BlockTickQueueItem *> m_BlockTickQueue;
std::vector<BlockTickQueueItem *> m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue std::vector<BlockTickQueueItem *> m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue
@ -919,12 +919,12 @@ private:
cFluidSimulator * m_LavaSimulator; cFluidSimulator * m_LavaSimulator;
cFireSimulator * m_FireSimulator; cFireSimulator * m_FireSimulator;
cRedstoneSimulator<cChunk, cWorld> * m_RedstoneSimulator; cRedstoneSimulator<cChunk, cWorld> * m_RedstoneSimulator;
cCriticalSection m_CSPlayers; cCriticalSection m_CSPlayers;
cPlayerList m_Players; cPlayerList m_Players;
cWorldStorage m_Storage; cWorldStorage m_Storage;
unsigned int m_MaxPlayers; unsigned int m_MaxPlayers;
cChunkMap * m_ChunkMap; cChunkMap * m_ChunkMap;
@ -934,7 +934,7 @@ private:
eWeather m_Weather; eWeather m_Weather;
int m_WeatherInterval; int m_WeatherInterval;
int m_MaxCactusHeight; int m_MaxCactusHeight;
int m_MaxSugarcaneHeight; int m_MaxSugarcaneHeight;
bool m_IsCactusBonemealable; bool m_IsCactusBonemealable;
@ -951,7 +951,7 @@ private:
/** Whether command blocks are enabled or not */ /** Whether command blocks are enabled or not */
bool m_bCommandBlocksEnabled; bool m_bCommandBlocksEnabled;
/** Whether prefixes such as [INFO] are prepended to SendMessageXXX() / BroadcastChatXXX() functions */ /** Whether prefixes such as [INFO] are prepended to SendMessageXXX() / BroadcastChatXXX() functions */
bool m_bUseChatPrefixes; bool m_bUseChatPrefixes;
@ -965,43 +965,43 @@ private:
/** Name of the end world */ /** Name of the end world */
AString m_EndWorldName; AString m_EndWorldName;
cChunkGenerator m_Generator; cChunkGenerator m_Generator;
cScoreboard m_Scoreboard; cScoreboard m_Scoreboard;
cMapManager m_MapManager; cMapManager m_MapManager;
/** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */ /** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
cChunkGeneratorCallbacks m_GeneratorCallbacks; cChunkGeneratorCallbacks m_GeneratorCallbacks;
cChunkSender m_ChunkSender; cChunkSender m_ChunkSender;
cLightingThread m_Lighting; cLightingThread m_Lighting;
cTickThread m_TickThread; cTickThread m_TickThread;
/** Guards the m_Tasks */ /** Guards the m_Tasks */
cCriticalSection m_CSTasks; cCriticalSection m_CSTasks;
/** Tasks that have been queued onto the tick thread; guarded by m_CSTasks */ /** Tasks that have been queued onto the tick thread; guarded by m_CSTasks */
cTasks m_Tasks; cTasks m_Tasks;
/** Guards the m_ScheduledTasks */ /** Guards the m_ScheduledTasks */
cCriticalSection m_CSScheduledTasks; cCriticalSection m_CSScheduledTasks;
/** Tasks that have been queued to be executed on the tick thread at target tick in the future. /** Tasks that have been queued to be executed on the tick thread at target tick in the future.
Ordered by increasing m_TargetTick. Ordered by increasing m_TargetTick.
Guarded by m_CSScheduledTasks */ Guarded by m_CSScheduledTasks */
cScheduledTasks m_ScheduledTasks; cScheduledTasks m_ScheduledTasks;
/** Guards m_Clients */ /** Guards m_Clients */
cCriticalSection m_CSClients; cCriticalSection m_CSClients;
/** List of clients in this world, these will be ticked by this world */ /** List of clients in this world, these will be ticked by this world */
cClientHandleList m_Clients; cClientHandleList m_Clients;
/** Clients that are scheduled for removal (ticked in another world), waiting for TickClients() to remove them */ /** Clients that are scheduled for removal (ticked in another world), waiting for TickClients() to remove them */
cClientHandleList m_ClientsToRemove; cClientHandleList m_ClientsToRemove;
/** Clients that are scheduled for adding, waiting for TickClients to add them */ /** Clients that are scheduled for adding, waiting for TickClients to add them */
cClientHandleList m_ClientsToAdd; cClientHandleList m_ClientsToAdd;
@ -1016,10 +1016,10 @@ private:
/** List of players that are scheduled for adding, waiting for the Tick thread to add them. */ /** List of players that are scheduled for adding, waiting for the Tick thread to add them. */
cPlayerList m_PlayersToAdd; cPlayerList m_PlayersToAdd;
/** CS protecting m_SetChunkDataQueue. */ /** CS protecting m_SetChunkDataQueue. */
cCriticalSection m_CSSetChunkDataQueue; cCriticalSection m_CSSetChunkDataQueue;
/** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */ /** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */
cSetChunkDataPtrs m_SetChunkDataQueue; cSetChunkDataPtrs m_SetChunkDataQueue;
@ -1031,16 +1031,16 @@ private:
/** Handles the weather in each tick */ /** Handles the weather in each tick */
void TickWeather(float a_Dt); void TickWeather(float a_Dt);
/** Handles the mob spawning/moving/destroying each tick */ /** Handles the mob spawning/moving/destroying each tick */
void TickMobs(float a_Dt); void TickMobs(float a_Dt);
/** Executes all tasks queued onto the tick thread */ /** Executes all tasks queued onto the tick thread */
void TickQueuedTasks(void); void TickQueuedTasks(void);
/** Executes all tasks queued onto the tick thread */ /** Executes all tasks queued onto the tick thread */
void TickScheduledTasks(void); void TickScheduledTasks(void);
/** Ticks all clients that are in this world */ /** Ticks all clients that are in this world */
void TickClients(float a_Dt); void TickClients(float a_Dt);
@ -1076,7 +1076,3 @@ private:
void SetChunkData(cSetChunkData & a_SetChunkData); void SetChunkData(cSetChunkData & a_SetChunkData);
}; // tolua_export }; // tolua_export