summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/AllToLua.pkg14
-rw-r--r--src/Bindings/CMakeLists.txt208
-rw-r--r--src/BlockArea.h136
-rw-r--r--src/BlockEntities/BeaconEntity.cpp14
-rw-r--r--src/BlockEntities/DispenserEntity.cpp7
-rw-r--r--src/BlockEntities/DropSpenserEntity.cpp16
-rw-r--r--src/BlockEntities/FlowerPotEntity.cpp10
-rw-r--r--src/BlockEntities/FurnaceEntity.cpp36
-rw-r--r--src/BlockEntities/FurnaceEntity.h2
-rw-r--r--src/BlockEntities/HopperEntity.cpp66
-rw-r--r--src/BlockEntities/JukeboxEntity.cpp6
-rw-r--r--src/BlockEntities/SignEntity.cpp8
-rw-r--r--src/ChunkDef.h64
-rw-r--r--src/Defines.h38
-rw-r--r--src/Entities/ArrowEntity.h45
-rw-r--r--src/Entities/Entity.h182
-rw-r--r--src/Entities/ExpBottleEntity.h17
-rw-r--r--src/Entities/FireChargeEntity.h15
-rw-r--r--src/Entities/FireworkEntity.cpp13
-rw-r--r--src/Entities/FireworkEntity.h32
-rw-r--r--src/Entities/GhastFireballEntity.h15
-rw-r--r--src/Entities/HangingEntity.cpp30
-rw-r--r--src/Entities/HangingEntity.h29
-rw-r--r--src/Entities/ItemFrame.cpp16
-rw-r--r--src/Entities/ItemFrame.h17
-rw-r--r--src/Entities/Painting.h13
-rw-r--r--src/Entities/Pickup.h10
-rw-r--r--src/Entities/ProjectileEntity.h20
-rw-r--r--src/Entities/SplashPotionEntity.h18
-rw-r--r--src/Entities/ThrownEggEntity.cpp21
-rw-r--r--src/Entities/ThrownEggEntity.h34
-rw-r--r--src/Entities/ThrownEnderPearlEntity.cpp22
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h34
-rw-r--r--src/Entities/ThrownSnowballEntity.cpp25
-rw-r--r--src/Entities/ThrownSnowballEntity.h34
-rw-r--r--src/Entities/WitherSkullEntity.h12
-rw-r--r--src/MersenneTwister.h44
-rw-r--r--src/Mobs/Monster.h60
-rw-r--r--src/OSSupport/IsThread.h36
-rw-r--r--src/Protocol/Protocol17x.cpp2
-rw-r--r--src/Protocol/Protocol18x.cpp2
-rw-r--r--src/World.h284
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp24
-rw-r--r--src/WorldStorage/WSSAnvil.cpp43
44 files changed, 944 insertions, 830 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 73de98e22..1bff26b0e 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -33,15 +33,27 @@ $cfile "../StringUtils.h"
$cfile "../Defines.h"
$cfile "../ChatColor.h"
$cfile "../ClientHandle.h"
+$cfile "../Entities/ArrowEntity.h"
$cfile "../Entities/Entity.h"
+$cfile "../Entities/EntityEffect.h"
+$cfile "../Entities/ExpBottleEntity.h"
+$cfile "../Entities/FireChargeEntity.h"
+$cfile "../Entities/FireworkEntity.h"
$cfile "../Entities/Floater.h"
+$cfile "../Entities/GhastFireballEntity.h"
+$cfile "../Entities/HangingEntity.h"
+$cfile "../Entities/ItemFrame.h"
$cfile "../Entities/Pawn.h"
$cfile "../Entities/Player.h"
$cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h"
+$cfile "../Entities/SplashPotionEntity.h"
+$cfile "../Entities/ThrownEggEntity.h"
+$cfile "../Entities/ThrownEnderPearlEntity.h"
+$cfile "../Entities/ThrownSnowballEntity.h"
$cfile "../Entities/TNTEntity.h"
-$cfile "../Entities/EntityEffect.h"
+$cfile "../Entities/WitherSkullEntity.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index 5c56231c6..d47579cd6 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -5,131 +5,133 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
include_directories (".")
SET (SRCS
- Bindings.cpp
- DeprecatedBindings.cpp
- LuaChunkStay.cpp
- LuaState.cpp
- LuaWindow.cpp
- ManualBindings.cpp
- ManualBindings_RankManager.cpp
- Plugin.cpp
- PluginLua.cpp
- PluginManager.cpp
- WebPlugin.cpp
+ Bindings.cpp
+ DeprecatedBindings.cpp
+ LuaChunkStay.cpp
+ LuaState.cpp
+ LuaWindow.cpp
+ ManualBindings.cpp
+ ManualBindings_RankManager.cpp
+ Plugin.cpp
+ PluginLua.cpp
+ PluginManager.cpp
+ WebPlugin.cpp
)
SET (HDRS
- Bindings.h
- DeprecatedBindings.h
- LuaChunkStay.h
- LuaFunctions.h
- LuaState.h
- LuaWindow.h
- ManualBindings.h
- Plugin.h
- PluginLua.h
- PluginManager.h
- WebPlugin.h
- tolua++.h
+ Bindings.h
+ DeprecatedBindings.h
+ LuaChunkStay.h
+ LuaFunctions.h
+ LuaState.h
+ LuaWindow.h
+ ManualBindings.h
+ Plugin.h
+ PluginLua.h
+ PluginManager.h
+ WebPlugin.h
+ tolua++.h
)
# List all the files that are generated as part of the Bindings build process
set (BINDING_OUTPUTS
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
)
set(BINDING_DEPENDENCIES
- tolua
- ../Bindings/virtual_method_hooks.lua
- ../Bindings/AllToLua.pkg
- ../Bindings/LuaFunctions.h
- ../Bindings/LuaWindow.h
- ../Bindings/Plugin.h
- ../Bindings/PluginLua.h
- ../Bindings/PluginManager.h
- ../Bindings/WebPlugin.h
- ../BiomeDef.h
- ../BlockArea.h
+ tolua
+ ../Bindings/virtual_method_hooks.lua
+ ../Bindings/AllToLua.pkg
+ ../Bindings/LuaFunctions.h
+ ../Bindings/LuaWindow.h
+ ../Bindings/Plugin.h
+ ../Bindings/PluginLua.h
+ ../Bindings/PluginManager.h
+ ../Bindings/WebPlugin.h
+ ../BiomeDef.h
+ ../BlockArea.h
../BlockEntities/BeaconEntity.h
- ../BlockEntities/BlockEntity.h
- ../BlockEntities/BlockEntityWithItems.h
- ../BlockEntities/ChestEntity.h
- ../BlockEntities/DispenserEntity.h
- ../BlockEntities/DropSpenserEntity.h
- ../BlockEntities/DropperEntity.h
- ../BlockEntities/FurnaceEntity.h
- ../BlockEntities/HopperEntity.h
- ../BlockEntities/JukeboxEntity.h
- ../BlockEntities/NoteEntity.h
- ../BlockEntities/SignEntity.h
- ../BlockEntities/MobHeadEntity.h
- ../BlockEntities/FlowerPotEntity.h
- ../BlockID.h
- ../BoundingBox.h
- ../ChatColor.h
- ../ChunkDef.h
- ../ClientHandle.h
- ../CraftingRecipes.h
- ../Cuboid.h
- ../Defines.h
- ../Enchantments.h
- ../Entities/EntityEffect.h
- ../Entities/Entity.h
- ../Entities/Floater.h
- ../Entities/Pawn.h
- ../Entities/Painting.h
- ../Entities/Pickup.h
- ../Entities/Player.h
- ../Entities/ProjectileEntity.h
- ../Entities/ArrowEntity.h
- ../Entities/ThrownEggEntity.h
- ../Entities/ThrownEnderPearlEntity.h
- ../Entities/ExpBottleEntity.h
- ../Entities/ThrownSnowballEntity.h
- ../Entities/FireChargeEntity.h
- ../Entities/FireworkEntity.h
- ../Entities/GhastFireballEntity.h
- ../Entities/TNTEntity.h
- ../Entities/ExpOrb.h
- ../Entities/HangingEntity.h
- ../Entities/ItemFrame.h
- ../Generating/ChunkDesc.h
- ../Inventory.h
- ../Item.h
- ../ItemGrid.h
- ../Mobs/Monster.h
- ../OSSupport/File.h
- ../Root.h
- ../Server.h
- ../StringUtils.h
- ../Tracer.h
- ../UI/Window.h
- ../Vector3.h
- ../WebAdmin.h
- ../World.h
+ ../BlockEntities/BlockEntity.h
+ ../BlockEntities/BlockEntityWithItems.h
+ ../BlockEntities/ChestEntity.h
+ ../BlockEntities/DispenserEntity.h
+ ../BlockEntities/DropSpenserEntity.h
+ ../BlockEntities/DropperEntity.h
+ ../BlockEntities/FurnaceEntity.h
+ ../BlockEntities/HopperEntity.h
+ ../BlockEntities/JukeboxEntity.h
+ ../BlockEntities/NoteEntity.h
+ ../BlockEntities/SignEntity.h
+ ../BlockEntities/MobHeadEntity.h
+ ../BlockEntities/FlowerPotEntity.h
+ ../BlockID.h
+ ../BoundingBox.h
+ ../ChatColor.h
+ ../ChunkDef.h
+ ../ClientHandle.h
+ ../CraftingRecipes.h
+ ../Cuboid.h
+ ../Defines.h
+ ../Enchantments.h
+ ../Entities/ArrowEntity.h
+ ../Entities/Entity.h
+ ../Entities/EntityEffect.h
+ ../Entities/ExpBottleEntity.h
+ ../Entities/FireChargeEntity.h
+ ../Entities/FireworkEntity.h
+ ../Entities/Floater.h
+ ../Entities/GhastFireballEntity.h
+ ../Entities/HangingEntity.h
+ ../Entities/ItemFrame.h
+ ../Entities/Pawn.h
+ ../Entities/Player.h
+ ../Entities/Painting.h
+ ../Entities/Pickup.h
+ ../Entities/ProjectileEntity.h
+ ../Entities/SplashPotionEntity.h
+ ../Entities/ThrownEggEntity.h
+ ../Entities/ThrownEnderPearlEntity.h
+ ../Entities/ThrownSnowballEntity.h
+ ../Entities/TNTEntity.h
+ ../Entities/WitherSkullEntity.h
+ ../Generating/ChunkDesc.h
+ ../Inventory.h
+ ../Item.h
+ ../ItemGrid.h
+ ../Mobs/Monster.h
+ ../OSSupport/File.h
+ ../Root.h
+ ../Server.h
+ ../StringUtils.h
+ ../Tracer.h
+ ../UI/Window.h
+ ../Vector3.h
+ ../WebAdmin.h
+ ../World.h
)
if (NOT MSVC)
- ADD_CUSTOM_COMMAND(
- # add any new generated bindings here
- OUTPUT ${BINDING_OUTPUTS}
+ ADD_CUSTOM_COMMAND(
+ # add any new generated bindings here
+ OUTPUT ${BINDING_OUTPUTS}
- # Regenerate bindings:
- COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ # Regenerate bindings:
+ COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- # add any new generation dependencies here
- DEPENDS ${BINDING_DEPENDENCIES}
- )
+ # add any new generation dependencies here
+ DEPENDS ${BINDING_DEPENDENCIES}
+ )
endif ()
+
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if(NOT MSVC)
- add_library(Bindings ${SRCS} ${HDRS})
+ add_library(Bindings ${SRCS} ${HDRS})
- target_link_libraries(Bindings lua sqlite tolualib polarssl)
+ target_link_libraries(Bindings lua sqlite tolualib polarssl)
endif()
diff --git a/src/BlockArea.h b/src/BlockArea.h
index 86f7c4f2d..003872635 100644
--- a/src/BlockArea.h
+++ b/src/BlockArea.h
@@ -32,7 +32,7 @@ class cBlockArea
// tolua_end
DISALLOW_COPY_AND_ASSIGN(cBlockArea);
// tolua_begin
-
+
public:
/** What data is to be queried (bit-mask) */
@@ -43,7 +43,7 @@ public:
baLight = 4,
baSkyLight = 8,
} ;
-
+
/** The per-block strategy to use when merging another block area into this object.
See the Merge function for the description of these */
enum eMergeStrategy
@@ -56,64 +56,64 @@ public:
msDifference,
msMask,
} ;
-
+
cBlockArea(void);
~cBlockArea();
-
+
/** Clears the data stored to reclaim memory */
void Clear(void);
-
+
/** Creates a new area of the specified size and contents.
Origin is set to all zeroes.
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);
-
+
/** Creates a new area of the specified size and contents.
Origin is set to all zeroes.
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);
-
+
/** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(int a_OriginX, int a_OriginY, int a_OriginZ);
-
+
/** Resets the origin. No other changes are made, contents are untouched. */
void SetOrigin(const Vector3i & a_Origin);
-
+
/** 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);
-
+
/** 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);
-
+
/** 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);
-
+
// 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
-
+
/** 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);
-
+
/** 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);
-
+
/** Copies this object's contents into the specified BlockArea. */
void CopyTo(cBlockArea & a_Into) const;
-
+
/** Copies the contents from the specified BlockArea into this object. */
void CopyFrom(const cBlockArea & a_From);
-
+
/** For testing purposes only, dumps the area into a file. */
void DumpToRawFile(const AString & a_FileName);
-
+
/** 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);
-
+
/** 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);
-
+
/** Merges another block area into this one, using the specified block combinating strategy
This function combines another BlockArea into the current object.
The strategy parameter specifies how individual blocks are combined together, using the table below.
@@ -125,7 +125,7 @@ public:
| A | air | air | A | A |
| air | B | B | B | B |
| A | B | B | A | B |
-
+
So to sum up:
- msOverwrite completely overwrites all blocks with the Src's blocks
- msFillAir overwrites only those blocks that were air
@@ -147,7 +147,7 @@ public:
| mycelium | stone | stone | ... and mycelium
| A | stone | A | ... but nothing else
| A | * | A | Everything else is left as it is
-
+
msSpongePrint:
Used for most generators, it allows carving out air pockets, too, and uses the Sponge as the NOP block
| area block | |
@@ -155,7 +155,7 @@ public:
+----------+--------+--------+
| A | sponge | A | Sponge is the NOP block
| * | B | B | Everything else overwrites anything
-
+
msMask:
Combines two areas, the blocks that are the same are kept, differing ones are reset to air
| 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);
-
+
/** Merges another block area into this one, using the specified block combinating strategy.
See Merge() above for details. */
void Merge(const cBlockArea & a_Src, const Vector3i & a_RelMinCoords, eMergeStrategy a_Strategy);
-
+
/** 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);
-
+
/** 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,
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. a_Cuboid must be sorted. */
void FillRelCuboid(const cCuboid & a_RelCuboid,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
-
+
/** 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,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
-
+
/** Draws a line from between two points with the specified data */
void RelLine(const Vector3i & a_Point1, const Vector3i & a_Point2,
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta = 0,
NIBBLETYPE a_BlockLight = 0, NIBBLETYPE a_BlockSkyLight = 0x0f
);
-
+
/** Rotates the entire area counter-clockwise around the Y axis */
void RotateCCW(void);
-
+
/** Rotates the entire area clockwise around the Y axis */
void RotateCW(void);
-
+
/** Mirrors the entire area around the XY plane */
void MirrorXY(void);
-
+
/** Mirrors the entire area around the XZ plane */
void MirrorXZ(void);
-
+
/** Mirrors the entire area around the YZ plane */
void MirrorYZ(void);
-
+
/** Rotates the entire area counter-clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCCWNoMeta(void);
-
+
/** Rotates the entire area clockwise around the Y axis, doesn't use blockhandlers for block meta */
void RotateCWNoMeta(void);
-
+
/** Mirrors the entire area around the XY plane, doesn't use blockhandlers for block meta */
void MirrorXYNoMeta(void);
-
+
/** Mirrors the entire area around the XZ plane, doesn't use blockhandlers for block meta */
void MirrorXZNoMeta(void);
-
+
/** Mirrors the entire area around the YZ plane, doesn't use blockhandlers for block meta */
void MirrorYZNoMeta(void);
-
+
// Setters:
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);
@@ -253,80 +253,80 @@ public:
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);
-
+
// tolua_end
-
+
// 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 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
const Vector3i & GetSize(void) const { return m_Size; }
-
+
// GetOrigin() is already exported manually to return 3 numbers, can't auto-export
const Vector3i & GetOrigin(void) const { return m_Origin; }
-
+
// tolua_begin
-
+
int GetSizeX(void) const { return m_Size.x; }
int GetSizeY(void) const { return m_Size.y; }
int GetSizeZ(void) const { return m_Size.z; }
-
+
/** 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 GetOriginX(void) const { return m_Origin.x; }
int GetOriginY(void) const { return m_Origin.y; }
int GetOriginZ(void) const { return m_Origin.z; }
-
+
/** Returns the datatypes that are stored in the object (bitmask of baXXX values) */
int GetDataTypes(void) const;
-
+
bool HasBlockTypes (void) const { return (m_BlockTypes != NULL); }
bool HasBlockMetas (void) const { return (m_BlockMetas != NULL); }
bool HasBlockLights (void) const { return (m_BlockLight != NULL); }
bool HasBlockSkyLights(void) const { return (m_BlockSkyLight != NULL); }
-
+
// tolua_end
-
+
// Clients can use these for faster access to all blocktypes. Be careful though!
/** Returns the internal pointer to the block types */
BLOCKTYPE * GetBlockTypes (void) const { return m_BlockTypes; }
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 * 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;
protected:
friend class cChunkDesc;
friend class cSchematicFileSerializer;
-
+
class cChunkReader :
public cChunkDataCallback
{
public:
cChunkReader(cBlockArea & a_Area);
-
+
protected:
cBlockArea & m_Area;
Vector3i m_Origin;
int m_CurrentChunkX;
int m_CurrentChunkZ;
-
+
void CopyNibbles(NIBBLETYPE * a_AreaDst, const NIBBLETYPE * a_ChunkSrc);
-
+
// cChunkDataCallback overrides:
virtual bool Coords(int a_ChunkX, int a_ChunkZ) override;
virtual void ChunkData(const cChunkData & a_BlockTypes) override;
} ;
-
+
typedef NIBBLETYPE * NIBBLEARRAY;
-
-
+
+
Vector3i m_Origin;
Vector3i m_Size;
-
+
/** 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. */
Vector3i m_WEOffset;
@@ -335,10 +335,10 @@ protected:
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_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 */
bool SetSize(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes);
-
+
// Basic Setters:
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);
@@ -346,11 +346,11 @@ protected:
// Basic Getters:
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;
-
+
// Crop helpers:
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);
-
+
// Expand helpers:
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);
@@ -361,13 +361,9 @@ protected:
int a_DataTypes, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta,
NIBBLETYPE a_BlockLight, NIBBLETYPE a_BlockSkyLight
);
-
+
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);
// tolua_begin
} ;
// tolua_end
-
-
-
-
diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp
index 02f45a097..fe5bcf143 100644
--- a/src/BlockEntities/BeaconEntity.cpp
+++ b/src/BlockEntities/BeaconEntity.cpp
@@ -2,6 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "BeaconEntity.h"
+#include <algorithm>
#include "../BlockArea.h"
#include "../Entities/Player.h"
@@ -227,10 +228,7 @@ void cBeaconEntity::GiveEffects(void)
virtual bool Item(cPlayer * a_Player)
{
Vector3d PlayerPosition = Vector3d(a_Player->GetPosition());
- if (PlayerPosition.y > (double)m_PosY)
- {
- PlayerPosition.y = (double)m_PosY;
- }
+ PlayerPosition.y = std::min(static_cast<double>(m_PosY), PlayerPosition.y);
// TODO: Vanilla minecraft uses an AABB check instead of a radius one
Vector3d BeaconPosition = Vector3d(m_PosX, m_PosY, m_PosZ);
@@ -255,7 +253,7 @@ void cBeaconEntity::GiveEffects(void)
, m_PrimaryEffect(a_PrimaryEffect)
, m_SecondaryEffect(a_SecondaryEffect)
, m_EffectLevel(a_EffectLevel)
- {};
+ {}
} PlayerCallback(Radius, m_PosX, m_PosY, m_PosZ, m_PrimaryEffect, SecondaryEffect, EffectLevel);
GetWorld()->ForEachPlayer(PlayerCallback);
@@ -288,7 +286,7 @@ void cBeaconEntity::UsedBy(cPlayer * a_Player)
OpenWindow(new cBeaconWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow();
}
-
+
if (Window != NULL)
{
// if (a_Player->GetWindow() != Window)
@@ -307,7 +305,3 @@ void cBeaconEntity::SendTo(cClientHandle & a_Client)
{
a_Client.SendUpdateBlockEntity(*this);
}
-
-
-
-
diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp
index aea854dc2..157862bd1 100644
--- a/src/BlockEntities/DispenserEntity.cpp
+++ b/src/BlockEntities/DispenserEntity.cpp
@@ -105,7 +105,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
{
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * 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);
}
@@ -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)
{
- 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);
return true;
}
-
-
-
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index dac951b27..e39b938a0 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -70,19 +70,19 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
SlotsCnt++;
}
} // for i - m_Contents[]
-
+
if (SlotsCnt == 0)
{
// 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);
return;
}
-
+
int RandomSlot = m_World->GetTickRandomNumber(SlotsCnt - 1);
-
+
// DropSpense the item, using the specialized behavior in the subclasses:
DropSpenseFromSlot(a_Chunk, OccupiedSlots[RandomSlot]);
-
+
// Broadcast a smoke and click effects:
NIBBLETYPE Meta = a_Chunk.GetMeta(m_RelX, m_PosY, m_RelZ);
int SmokeDir = 0;
@@ -132,7 +132,7 @@ bool cDropSpenserEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
return false;
}
-
+
m_ShouldDropSpense = false;
DropSpense(a_Chunk);
return true;
@@ -160,7 +160,7 @@ void cDropSpenserEntity::UsedBy(cPlayer * a_Player)
OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this));
Window = GetWindow();
}
-
+
if (Window != NULL)
{
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);
}
-
-
-
-
diff --git a/src/BlockEntities/FlowerPotEntity.cpp b/src/BlockEntities/FlowerPotEntity.cpp
index 01560f814..ad7b496cc 100644
--- a/src/BlockEntities/FlowerPotEntity.cpp
+++ b/src/BlockEntities/FlowerPotEntity.cpp
@@ -28,7 +28,7 @@ void cFlowerPotEntity::UsedBy(cPlayer * a_Player)
{
return;
}
-
+
cItem SelectedItem = a_Player->GetInventory().GetEquippedItem();
if (IsFlower(SelectedItem.m_ItemType, SelectedItem.m_ItemDamage))
{
@@ -63,7 +63,7 @@ void cFlowerPotEntity::Destroy(void)
cItems Pickups;
Pickups.Add(m_Item);
m_World->SpawnItemPickups(Pickups, m_PosX + 0.5, m_PosY + 0.5, m_PosZ + 0.5);
-
+
m_Item.Empty();
}
}
@@ -88,7 +88,7 @@ bool cFlowerPotEntity::IsFlower(short m_ItemType, short m_ItemData)
}
case E_BLOCK_TALL_GRASS:
{
- return (m_ItemData == (short) 2);
+ return (m_ItemData == static_cast<short>(2));
}
default:
{
@@ -96,7 +96,3 @@ bool cFlowerPotEntity::IsFlower(short m_ItemType, short m_ItemData)
}
}
}
-
-
-
-
diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp
index 284ac7de9..ac71f1541 100644
--- a/src/BlockEntities/FurnaceEntity.cpp
+++ b/src/BlockEntities/FurnaceEntity.cpp
@@ -115,16 +115,16 @@ bool cFurnaceEntity::Tick(float a_Dt, cChunk & a_Chunk)
FinishOne();
}
}
-
+
m_TimeBurned++;
if (m_TimeBurned >= m_FuelBurnTime)
{
// The current fuel has been exhausted, use another one, if possible
BurnNewFuel();
}
-
+
UpdateProgressBars();
-
+
return true;
}
@@ -185,7 +185,7 @@ void cFurnaceEntity::BurnNewFuel(void)
SetIsCooking(false);
return;
}
-
+
// Is the input and output ready for cooking?
if (!CanCookInputToOutput())
{
@@ -217,12 +217,12 @@ void cFurnaceEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
{
return;
}
-
+
ASSERT(a_ItemGrid == &m_Contents);
switch (a_SlotNum)
{
- case fsInput: UpdateInput(); break;
- case fsFuel: UpdateFuel(); break;
+ case fsInput: UpdateInput(); break;
+ case fsFuel: UpdateFuel(); break;
case fsOutput: UpdateOutput(); break;
default: ASSERT(!"Invalid furnace slot update!"); break;
}
@@ -241,7 +241,7 @@ void cFurnaceEntity::UpdateInput(void)
m_TimeCooked = 0;
}
m_LastInput = m_Contents.GetSlot(fsInput);
-
+
cFurnaceRecipe * FR = cRoot::Get()->GetFurnaceRecipe();
m_CurrentRecipe = FR->GetRecipeFrom(m_Contents.GetSlot(fsInput));
if (!CanCookInputToOutput())
@@ -254,7 +254,7 @@ void cFurnaceEntity::UpdateInput(void)
{
m_NeedCookTime = m_CurrentRecipe->CookTime;
SetIsCooking(true);
-
+
// Start burning new fuel if there's no flame now:
if (GetFuelBurnTimeLeft() <= 0)
{
@@ -274,7 +274,7 @@ void cFurnaceEntity::UpdateFuel(void)
// The current fuel is still burning, don't modify anything:
return;
}
-
+
// The current fuel is spent, try to burn some more:
BurnNewFuel();
}
@@ -292,7 +292,7 @@ void cFurnaceEntity::UpdateOutput(void)
SetIsCooking(false);
return;
}
-
+
// No need to burn new fuel, the Tick() function will take care of that
// Can cook, start cooking if not already underway:
@@ -311,7 +311,7 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
// This input cannot be cooked
return false;
}
-
+
const cItem & Slot = m_Contents.GetSlot(fsOutput);
if (Slot.IsEmpty())
{
@@ -324,13 +324,13 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
// The output slot is blocked with something that cannot be stacked with the recipe's output
return false;
}
-
+
if (Slot.IsFullStack())
{
// Cannot add any more items to the output slot
return false;
}
-
+
return true;
}
@@ -345,11 +345,11 @@ void cFurnaceEntity::UpdateProgressBars(bool a_ForceUpdate)
{
return;
}
-
+
int CurFuel = (m_FuelBurnTime > 0) ? 200 - (200 * m_TimeBurned / m_FuelBurnTime) : 0;
BroadcastProgress(PROGRESSBAR_FUEL, static_cast<short>(CurFuel));
- int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
+ int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0;
BroadcastProgress(PROGRESSBAR_SMELTING_CONFIRM, 200); // Post 1.8, Mojang requires a random packet with an ID of three and value of 200. Wat. Wat. Wat.
BroadcastProgress(PROGRESSBAR_SMELTING, static_cast<short>(CurCook));
}
@@ -373,7 +373,3 @@ void cFurnaceEntity::SetIsCooking(bool a_IsCooking)
m_World->FastSetBlock(m_PosX, m_PosY, m_PosZ, E_BLOCK_LIT_FURNACE, m_BlockMeta);
}
}
-
-
-
-
diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h
index 8e48810ba..71c2fe127 100644
--- a/src/BlockEntities/FurnaceEntity.h
+++ b/src/BlockEntities/FurnaceEntity.h
@@ -133,7 +133,7 @@ protected:
int m_FuelBurnTime;
/** Amount of ticks that the current fuel has been burning */
- int m_TimeBurned;
+ int m_TimeBurned;
/** Sends the specified progressbar value to all clients of the window */
void BroadcastProgress(short a_ProgressbarID, short a_Value);
diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp
index 103f516fc..9f64ea148 100644
--- a/src/BlockEntities/HopperEntity.cpp
+++ b/src/BlockEntities/HopperEntity.cpp
@@ -58,7 +58,7 @@ bool cHopperEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
UNUSED(a_Dt);
Int64 CurrentTick = a_Chunk.GetWorld()->GetWorldAge();
-
+
bool res = false;
res = MoveItemsIn (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
// All the actual handling is in the cWindow UI code that gets called when the hopper is rclked
-
+
UNUSED(a_Client);
}
@@ -91,7 +91,7 @@ void cHopperEntity::UsedBy(cPlayer * a_Player)
OpenNewWindow();
Window = GetWindow();
}
-
+
// Open the window for the player:
if (Window != NULL)
{
@@ -138,7 +138,7 @@ bool cHopperEntity::MoveItemsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
// Too early after the previous transfer
return false;
}
-
+
// Try moving an item in:
bool res = false;
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_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;
}
}
-
+
// If the item has been moved, reset the last tick:
if (res)
{
m_LastMoveItemsInTick = a_CurrentTick;
}
-
+
return res;
}
@@ -205,12 +205,12 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
}
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();
if (Distance < 0.5)
{
- if (TrySuckPickupIn((cPickup *)a_Entity))
+ if (TrySuckPickupIn(static_cast<cPickup *>(a_Entity)))
{
return false;
}
@@ -238,9 +238,9 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
m_bFoundPickupsAbove = true;
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
-
+
if (Item.IsEmpty())
{
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
return false;
}
-
+
// Get the coords of the block where to output items:
int OutX, OutY, OutZ;
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
return false;
}
-
+
// Convert coords to relative:
int OutRelX = OutX - a_Chunk.GetPosX() * 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
return false;
}
-
+
// Call proper moving function, based on the blocktype present at the coords:
bool res = false;
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_HOPPER:
{
- cBlockEntityWithItems * BlockEntity = (cBlockEntityWithItems *)DestChunk->GetBlockEntity(OutX, OutY, OutZ);
+ cBlockEntityWithItems * BlockEntity = static_cast<cBlockEntityWithItems *>(DestChunk->GetBlockEntity(OutX, OutY, OutZ));
if (BlockEntity == NULL)
{
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;
}
}
-
+
// If the item has been moved, reset the last tick:
if (res)
{
m_LastMoveItemsOutTick = a_CurrentTick;
}
-
+
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.
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)
{
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
return true;
}
-
+
// Check if the chest is a double-chest (chest directly above was empty), if so, try to move from there:
static const struct
{
@@ -395,7 +395,7 @@ bool cHopperEntity::MoveItemsFromChest(cChunk & a_Chunk)
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)
{
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;
}
-
+
// The chest was single and nothing could be moved
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.
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)
{
LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
return false;
}
-
+
// Try move from the output slot:
if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsOutput, true))
{
@@ -435,7 +435,7 @@ bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
Furnace->SetOutputSlot(NewOutput.AddCount(-1));
return true;
}
-
+
// No output moved, check if we can move an empty bucket out of the fuel slot:
if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
{
@@ -445,7 +445,7 @@ bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
return true;
}
}
-
+
// Nothing can be moved
return false;
}
@@ -458,7 +458,7 @@ bool cHopperEntity::MoveItemsFromGrid(cBlockEntityWithItems & a_Entity)
{
cItemGrid & Grid = a_Entity.GetContents();
int NumSlots = Grid.GetNumSlots();
-
+
// First try adding items of types already in the hopper:
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
continue;
}
-
+
m_Contents.ChangeSlotCount(i, 1);
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)
{
// 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)
{
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;
}
- 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)
{
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;
}
-
+
// The chest was single and nothing could be moved
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
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)
{
// Feed the input slot of the furnace
@@ -684,7 +684,3 @@ bool cHopperEntity::MoveItemsToSlot(cBlockEntityWithItems & a_Entity, int a_DstS
return false;
}
}
-
-
-
-
diff --git a/src/BlockEntities/JukeboxEntity.cpp b/src/BlockEntities/JukeboxEntity.cpp
index bb9b335e0..473526855 100644
--- a/src/BlockEntities/JukeboxEntity.cpp
+++ b/src/BlockEntities/JukeboxEntity.cpp
@@ -79,7 +79,7 @@ bool cJukeboxEntity::EjectRecord(void)
}
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_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);
@@ -113,7 +113,3 @@ void cJukeboxEntity::SetRecord(int a_Record)
{
m_Record = a_Record;
}
-
-
-
-
diff --git a/src/BlockEntities/SignEntity.cpp b/src/BlockEntities/SignEntity.cpp
index d048d0218..9a2695b3f 100644
--- a/src/BlockEntities/SignEntity.cpp
+++ b/src/BlockEntities/SignEntity.cpp
@@ -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)
{
- 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());
return;
@@ -59,7 +59,7 @@ void cSignEntity::SetLine(int a_Index, const AString & a_Line)
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);
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]);
}
-
-
-
-
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index f4ed66c4b..260aace58 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -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
typedef HEIGHTTYPE HeightMap[Width * Width];
-
+
/** The type used for any biomemap operations and storage inside MCServer,
using MCServer biomes (need not correspond to client representation!)
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_Z = a_Z - a_ChunkZ * Width;
}
-
-
+
+
/// Converts absolute block coords to chunk coords:
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));
a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)] = a_Type;
}
-
-
+
+
inline static void SetBlock(BLOCKTYPE * a_BlockTypes, int a_Index, BLOCKTYPE a_Type)
{
ASSERT((a_Index >= 0) && (a_Index <= NumBlocks));
a_BlockTypes[a_Index] = a_Type;
}
-
-
+
+
inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_X, int a_Y, int a_Z)
{
ASSERT((a_X >= 0) && (a_X < Width));
@@ -181,39 +181,39 @@ public:
ASSERT((a_Z >= 0) && (a_Z < Width));
return a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)];
}
-
-
+
+
inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, int a_Idx)
{
ASSERT((a_Idx >= 0) && (a_Idx < NumBlocks));
return a_BlockTypes[a_Idx];
}
-
-
+
+
inline static int GetHeight(const HeightMap & a_HeightMap, int a_X, int a_Z)
{
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width));
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)
{
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width));
a_HeightMap[a_X + Width * a_Z] = a_Height;
}
-
-
+
+
inline static EMCSBiome GetBiome(const BiomeMap & a_BiomeMap, int a_X, int a_Z)
{
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Z >= 0) && (a_Z < Width));
return a_BiomeMap[a_X + Width * a_Z];
}
-
-
+
+
inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
{
ASSERT((a_X >= 0) && (a_X < Width));
@@ -226,11 +226,11 @@ public:
{
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_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!");
return 0;
@@ -241,7 +241,7 @@ public:
{
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())
{
return (a_IsSkyLightNibble ? 0xff : 0);
@@ -258,7 +258,7 @@ public:
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
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!");
return 0;
@@ -272,11 +272,11 @@ public:
ASSERT(!"cChunkDef::SetNibble(): index out of range!");
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;
}
- 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())
{
a_Buffer.resize(((Index / 2) + 1));
@@ -336,7 +336,7 @@ public:
/// Called for clients that are in Chunk1 and not in Chunk2,
virtual void Removed(cClientHandle * a_Client) = 0;
-
+
/// Called for clients that are in Chunk2 and not in Chunk1.
virtual void Added(cClientHandle * a_Client) = 0;
} ;
@@ -373,9 +373,9 @@ class cChunkCoords
public:
int m_ChunkX;
int m_ChunkZ;
-
+
cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {}
-
+
bool operator == (const cChunkCoords & a_Other) const
{
return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ));
@@ -432,12 +432,12 @@ public:
int y;
int z;
X Data;
-
+
cCoordWithData(int a_X, int a_Y, int a_Z) :
x(a_X), y(a_Y), z(a_Z), 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)
{
@@ -478,7 +478,3 @@ public:
typedef cCoordWithDoubleData <BLOCKTYPE, bool> cCoordWithBlockAndBool;
typedef std::vector<cCoordWithBlockAndBool> cCoordWithBlockAndBoolVector;
-
-
-
-
diff --git a/src/Defines.h b/src/Defines.h
index 6355b75b4..f1ff911e7 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -39,7 +39,7 @@ enum eBlockFace
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_ZP = 3, // Interacting with the Z+ face of the block
-
+
// Synonyms using the (deprecated) world directions:
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
@@ -101,7 +101,7 @@ enum eClickAction
caDblClick,
// Add new actions here
caUnknown = 255,
-
+
// Keep this list in sync with ClickActionToString() function below!
} ;
@@ -116,14 +116,14 @@ enum eGameMode
eGameMode_Creative = 1,
eGameMode_Adventure = 2,
eGameMode_Spectator = 3,
-
+
// Easier-to-use synonyms:
gmNotSet = eGameMode_NotSet,
gmSurvival = eGameMode_Survival,
gmCreative = eGameMode_Creative,
gmAdventure = eGameMode_Adventure,
gmSpectator = eGameMode_Spectator,
-
+
// These two are used to check GameMode for validity when converting from integers.
gmMax, // Gets automatically assigned
gmMin = 0,
@@ -138,7 +138,7 @@ enum eWeather
eWeather_Sunny = 0,
eWeather_Rain = 1,
eWeather_ThunderStorm = 2,
-
+
// Easier-to-use synonyms:
wSunny = eWeather_Sunny,
wRain = eWeather_Rain,
@@ -218,7 +218,7 @@ inline const char * ClickActionToString(eClickAction a_ClickAction)
case caLeftPaintEnd: return "caLeftPaintEnd";
case caRightPaintEnd: return "caRightPaintEnd";
case caDblClick: return "caDblClick";
-
+
case caUnknown: return "caUnknown";
}
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;
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
mtJoin, // A player has joined the server
mtLeave, // A player has left the server
-
+
// Common aliases:
mtFail = mtFailure,
mtError = mtFailure,
@@ -626,9 +626,9 @@ namespace ItemCategory
|| (a_ItemID == E_ITEM_GOLD_HOE)
|| (a_ItemID == E_ITEM_DIAMOND_HOE);
}
-
-
-
+
+
+
inline bool IsShovel(short a_ItemID)
{
return (a_ItemID == E_ITEM_WOODEN_SHOVEL)
@@ -648,9 +648,9 @@ namespace ItemCategory
|| IsHoe ( a_ItemID)
|| IsShovel ( a_ItemID);
}
-
-
-
+
+
+
inline bool IsHelmet(short a_ItemType)
{
return (
@@ -700,9 +700,9 @@ namespace ItemCategory
(a_ItemType == E_ITEM_DIAMOND_BOOTS)
);
}
-
-
-
+
+
+
inline bool IsArmor(short a_ItemType)
{
return (
@@ -715,7 +715,3 @@ namespace ItemCategory
}
// tolua_end
-
-
-
-
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index 1e4d8eebb..436ec0293 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -1,6 +1,11 @@
-//
-// ArrowEntity.h
-//
+
+// ArrowEntity.h
+
+// Declares the cArrowEntity representing the arrow that has been shot by the player or by a skeleton
+
+
+
+
#pragma once
@@ -19,7 +24,7 @@ class cArrowEntity :
typedef cProjectileEntity super;
public:
- /// Determines when the arrow can be picked up (depending on player gamemode). Corresponds to the MCA file "pickup" field
+ /** Determines when the arrow can be picked up (depending on player gamemode). Corresponds to the MCA file "pickup" field */
enum ePickupState
{
psNoPickup = 0,
@@ -31,33 +36,33 @@ public:
CLASS_PROTODEF(cArrowEntity)
- /// Creates a new arrow with psNoPickup state and default damage modifier coeff
+ /** Creates a new arrow with psNoPickup state and default damage modifier coeff */
cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
- /// Creates a new arrow as shot by a player, initializes it from the player object
+ /** Creates a new arrow as shot by a player, initializes it from the player object */
cArrowEntity(cPlayer & a_Player, double a_Force);
// tolua_begin
- /// Returns whether the arrow can be picked up by players
+ /** Returns whether the arrow can be picked up by players */
ePickupState GetPickupState(void) const { return m_PickupState; }
- /// Sets a new pickup state
+ /** Sets a new pickup state */
void SetPickupState(ePickupState a_PickupState) { m_PickupState = a_PickupState; }
- /// Returns the damage modifier coeff.
+ /** Returns the damage modifier coeff. */
double GetDamageCoeff(void) const { return m_DamageCoeff; }
- /// Sets the damage modifier coeff
+ /** Sets the damage modifier coeff */
void SetDamageCoeff(double a_DamageCoeff) { m_DamageCoeff = a_DamageCoeff; }
- /// Returns true if the specified player can pick the arrow up
+ /** Returns true if the specified player can pick the arrow up */
bool CanPickup(const cPlayer & a_Player) const;
- /// Returns true if the arrow is set as critical
+ /** Returns true if the arrow is set as critical */
bool IsCritical(void) const { return m_IsCritical; }
- /// Sets the IsCritical flag
+ /** Sets the IsCritical flag */
void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
/** Gets the block arrow is in */
@@ -70,28 +75,28 @@ public:
protected:
- /// Determines when the arrow can be picked up by players
+ /** Determines when the arrow can be picked up by players */
ePickupState m_PickupState;
- /// The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow
+ /** The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow */
double m_DamageCoeff;
- /// If true, the arrow deals more damage
+ /** If true, the arrow deals more damage */
bool m_IsCritical;
- /// Timer for pickup collection animation or five minute timeout
+ /** Timer for pickup collection animation or five minute timeout */
float m_Timer;
- /// Timer for client arrow position confirmation via TeleportEntity
+ /** Timer for client arrow position confirmation via TeleportEntity */
float m_HitGroundTimer;
// Whether the arrow has already been teleported into the proper position in the ground.
bool m_HasTeleported;
- /// If true, the arrow is in the process of being collected - don't go to anyone else
+ /** If true, the arrow is in the process of being collected - don't go to anyone else */
bool m_bIsCollected;
- /// Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air
+ /** Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air */
Vector3i m_HitBlockPos;
// cProjectileEntity overrides:
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 07754791d..451ac3711 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -84,13 +84,13 @@ public:
etFloater,
etItemFrame,
etPainting,
-
+
// Common variations
etMob = etMonster, // DEPRECATED, use etMonster instead!
} ;
-
+
// tolua_end
-
+
enum eEntityStatus
{
// 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
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_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_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_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 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 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
-
+
cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
virtual ~cEntity();
@@ -151,9 +151,9 @@ public:
virtual bool Initialize(cWorld & a_World);
// tolua_begin
-
+
eEntityType GetEntityType(void) const { return m_EntityType; }
-
+
bool IsEnderCrystal(void) const { return (m_EntityType == etEnderCrystal); }
bool IsPlayer (void) const { return (m_EntityType == etPlayer); }
bool IsPickup (void) const { return (m_EntityType == etPickup); }
@@ -168,16 +168,16 @@ public:
bool IsFloater (void) const { return (m_EntityType == etFloater); }
bool IsItemFrame (void) const { return (m_EntityType == etItemFrame); }
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)
virtual bool IsA(const char * a_ClassName) const;
-
+
/** Returns the class name of this class */
static const char * GetClassStatic(void);
/** Returns the topmost class name for the object */
virtual const char * GetClass(void) const;
-
+
/** Returns the topmost class's parent class name for the object. cEntity returns an empty string (no parent). */
virtual const char * GetParentClass(void) const;
@@ -200,9 +200,9 @@ public:
double GetSpeedY (void) const { return m_Speed.y; }
double GetSpeedZ (void) const { return m_Speed.z; }
double GetWidth (void) const { return m_Width; }
-
- int GetChunkX(void) const {return (int)floor(m_Pos.x / cChunkDef::Width); }
- int GetChunkZ(void) const {return (int)floor(m_Pos.z / cChunkDef::Width); }
+
+ int GetChunkX(void) const {return static_cast<int>(floor(m_Pos.x / cChunkDef::Width)); }
+ int GetChunkZ(void) const {return static_cast<int>(floor(m_Pos.z / cChunkDef::Width)); }
void SetHeadYaw (double a_HeadYaw);
void SetHeight (double a_Height);
@@ -219,21 +219,21 @@ public:
/** Sets the speed of the entity, measured in m / sec */
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
-
+
/** 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); }
-
+
/** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedX(double a_SpeedX);
-
+
/** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedY(double a_SpeedY);
-
+
/** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */
void SetSpeedZ(double a_SpeedZ);
-
+
void SetWidth (double a_Width);
-
+
void AddPosX (double a_AddPosX);
void AddPosY (double a_AddPosY);
void AddPosZ (double a_AddPosZ);
@@ -244,7 +244,7 @@ public:
void AddSpeedX (double a_AddSpeedX);
void AddSpeedY (double a_AddSpeedY);
void AddSpeedZ (double a_AddSpeedZ);
-
+
virtual void HandleSpeedFromAttachee(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
void TakeDamage(cEntity & a_Attacker);
-
+
/// 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);
/// 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);
-
+
float GetGravity(void) const { return m_Gravity; }
-
+
void SetGravity(float a_Gravity) { m_Gravity = a_Gravity; }
-
+
/// Sets the rotation to match the speed vector (entity goes "face-forward")
void SetYawFromSpeed(void);
-
+
/// Sets the pitch to match the speed vector (entity gies "face-forward")
void SetPitchFromSpeed(void);
-
+
// tolua_end
-
+
/** Makes this entity take damage specified in the a_TDI.
The TDI is sent through plugins first, then applied.
If it returns false, the entity hasn't receive any damage. */
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI);
-
+
// tolua_begin
/// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items
virtual int GetRawDamageAgainst(const cEntity & a_Receiver);
-
+
/** Returns whether armor will protect against the passed damage type **/
virtual bool ArmorCoversAgainst(eDamageType a_DamageType);
-
+
/// 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);
-
+
/// Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit
virtual double GetKnockbackAmountAgainst(const cEntity & a_Receiver);
-
+
/// Returns the curently equipped weapon; empty item if none
virtual cItem GetEquippedWeapon(void) const { return cItem(); }
-
+
/// Returns the currently equipped helmet; empty item if none
virtual cItem GetEquippedHelmet(void) const { return cItem(); }
-
+
/// Returns the currently equipped chestplate; empty item if none
virtual cItem GetEquippedChestplate(void) const { return cItem(); }
/// Returns the currently equipped leggings; empty item if none
virtual cItem GetEquippedLeggings(void) const { return cItem(); }
-
+
/// Returns the currently equipped boots; empty item if none
virtual cItem GetEquippedBoots(void) const { return cItem(); }
@@ -317,20 +317,20 @@ public:
/// Heals the specified amount of HPs
virtual void Heal(int a_HitPoints);
-
+
/// Returns the health of this entity
int GetHealth(void) const { return m_Health; }
-
+
/// Sets the health of this entity; doesn't broadcast any hurt animation
void SetHealth(int a_Health);
-
+
// tolua_end
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
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk);
-
+
/// Updates the state related to this entity being on fire
virtual void TickBurning(cChunk & a_Chunk);
@@ -341,34 +341,34 @@ public:
Returns true if MoveToWorld() was called, false if not
*/
virtual bool DetectPortal(void);
-
+
/// Handles when the entity is in the void
virtual void TickInVoid(cChunk & a_Chunk);
/// Called when the entity starts burning
virtual void OnStartedBurning(void);
-
+
/// Called when the entity finishes burning
virtual void OnFinishedBurning(void);
-
+
// tolua_begin
-
+
/// Sets the maximum value for the health
void SetMaxHealth(int a_MaxHealth);
int GetMaxHealth(void) const { return m_MaxHealth; }
-
+
/// Sets whether the entity is fireproof
void SetIsFireproof(bool a_IsFireproof);
-
+
bool IsFireproof(void) const { return m_IsFireproof; }
-
+
/// Puts the entity on fire for the specified amount of ticks
void StartBurning(int a_TicksLeftBurning);
-
+
/// Stops the entity from burning, resets all burning timers
void StopBurning(void);
-
+
// tolua_end
/** 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;
// tolua_begin
-
+
/// Teleports to the entity specified
virtual void TeleportToEntity(cEntity & a_Entity);
-
+
/// Teleports to the coordinates specified
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 */
bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true);
-
+
// tolua_end
virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn);
@@ -399,16 +399,16 @@ public:
/** Sets the world the entity will be leaving */
void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; }
-
+
/// Updates clients of changes in the entity.
virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL);
-
+
/// Attaches to the specified entity; detaches from any previous one first
void AttachTo(cEntity * a_AttachTo);
-
+
/// Detaches from the currently attached entity, if any
virtual void Detach(void);
-
+
/// Makes sure head yaw is not over the specified range.
void WrapHeadYaw();
@@ -417,9 +417,9 @@ public:
/// Makes speed is not over 20. Max speed is 20 blocks / second
void WrapSpeed();
-
+
// tolua_begin
-
+
// COMMON metadata flags; descendants may override the defaults:
virtual bool IsOnFire (void) const {return (m_TicksLeftBurning > 0); }
virtual bool IsCrouched (void) const {return false; }
@@ -437,15 +437,15 @@ public:
/** Gets number of ticks this entity has existed for */
long int GetTicksAlive(void) const { return m_TicksAlive; }
-
+
/** Gets the invulnerable ticks from the entity */
int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
/** Set the invulnerable ticks from the entity */
void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; }
-
+
// tolua_end
-
+
/// Called when the specified player right-clicks this entity
virtual void OnRightClicked(cPlayer & a_Player) {}
@@ -462,38 +462,38 @@ public:
protected:
static cCriticalSection m_CSCount;
static int m_EntityCount;
-
+
/** Measured in meter/second (m/s) */
Vector3d m_Speed;
int m_UniqueID;
-
+
int m_Health;
int m_MaxHealth;
-
+
/// The entity to which this entity is attached (vehicle), NULL if none
cEntity * m_AttachedTo;
-
+
/// The entity which is attached to this entity (rider), NULL if none
cEntity * m_Attachee;
/** Stores whether head yaw has been set manually */
bool m_bDirtyHead;
-
+
/** Stores whether our yaw/pitch/roll (body orientation) has been set manually */
bool m_bDirtyOrientation;
-
+
/** 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 */
bool m_bHasSentNoSpeed;
/** Stores if the entity is on the ground */
bool m_bOnGround;
-
+
/** 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 */
float m_Gravity;
-
+
/** Last position sent to client via the Relative Move or Teleport packets (not Velocity)
Only updated if cEntity::BroadcastMovementUpdate() is called! */
Vector3d m_LastPos;
@@ -508,31 +508,31 @@ protected:
cWorld * m_WorldTravellingFrom;
eEntityType m_EntityType;
-
+
cWorld * m_World;
-
+
/// Whether the entity is capable of taking fire or lava damage.
bool m_IsFireproof;
/// Time, in ticks, since the last damage dealt by being on fire. Valid only if on fire (IsOnFire())
int m_TicksSinceLastBurnDamage;
-
+
/// Time, in ticks, since the last damage dealt by standing in lava. Reset to zero when moving out of lava.
int m_TicksSinceLastLavaDamage;
-
+
/// Time, in ticks, since the last damage dealt by standing in fire. Reset to zero when moving out of fire.
int m_TicksSinceLastFireDamage;
-
+
/// Time, in ticks, until the entity extinguishes its fire
int m_TicksLeftBurning;
-
+
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
int m_TicksSinceLastVoidDamage;
-
+
/** 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. */
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
-
+
virtual void Destroyed(void) {} // Called after the entity has been destroyed
/** Applies friction to an entity
@@ -543,7 +543,7 @@ protected:
/** Called in each tick to handle air-related processing i.e. drowning */
virtual void HandleAir(void);
-
+
/** Called once per tick to set IsSwimming and IsSubmerged */
virtual void SetSwimState(cChunk & a_Chunk);
@@ -568,29 +568,29 @@ protected:
/** Portal delay timer and cooldown boolean data */
sPortalCooldownData m_PortalCooldownData;
-
+
/** The number of ticks this entity has been alive for */
long int m_TicksAlive;
-
+
private:
/** Measured in degrees, [-180, +180) */
double m_HeadYaw;
-
+
/** Measured in degrees, [-180, +180) */
Vector3d m_Rot;
-
+
/** Position of the entity's XZ center and Y bottom */
Vector3d m_Pos;
-
+
/** Measured in meter / second */
Vector3d m_WaterSpeed;
-
+
/** Measured in Kilograms (Kg) */
double m_Mass;
-
+
/** Width of the entity, in the XZ plane. Since entities are represented as cylinders, this is more of a diameter. */
double m_Width;
-
+
/** Height of the entity (Y axis) */
double m_Height;
@@ -600,7 +600,3 @@ private:
} ; // tolua_export
typedef std::list<cEntity *> cEntityList;
-
-
-
-
diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h
index d36110f97..715b9947e 100644
--- a/src/Entities/ExpBottleEntity.h
+++ b/src/Entities/ExpBottleEntity.h
@@ -1,6 +1,11 @@
-//
-// ExpBottleEntity.h
-//
+
+// ExpBottleEntity.h
+
+// Declares the cExpBottleEntity class representing the thrown exp bottle
+
+
+
+
#pragma once
@@ -33,6 +38,10 @@ protected:
/** Breaks the bottle, fires its particle effects and sounds
@param a_HitPos The position where the bottle will break */
- void Break(const Vector3d &a_HitPos);
+ void Break(const Vector3d & a_HitPos);
}; // tolua_export
+
+
+
+
diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h
index 5df55bec4..eb08f5324 100644
--- a/src/Entities/FireChargeEntity.h
+++ b/src/Entities/FireChargeEntity.h
@@ -1,6 +1,11 @@
-//
-// FireChargeEntity.h
-//
+
+// FireChargeEntity.h
+
+// Declares the cFireChargeEntity representing the fire charge shot by the blaze
+
+
+
+
#pragma once
@@ -34,3 +39,7 @@ protected:
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/FireworkEntity.cpp b/src/Entities/FireworkEntity.cpp
index 403a53c84..68d02640a 100644
--- a/src/Entities/FireworkEntity.cpp
+++ b/src/Entities/FireworkEntity.cpp
@@ -10,7 +10,7 @@
cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item) :
super(pkFirework, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
- m_ExplodeTimer(0),
+ m_TicksToExplosion(a_Item.m_FireworkItem.m_FlightTimeInTicks),
m_FireworkItem(a_Item)
{
}
@@ -27,7 +27,9 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((PosY < 0) || (PosY >= cChunkDef::Height))
{
- goto setspeed;
+ AddSpeedY(1);
+ AddPosition(GetSpeed() * (a_Dt / 1000));
+ return;
}
if (m_IsInGround)
@@ -50,7 +52,6 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
}
}
-setspeed:
AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000));
}
@@ -63,11 +64,13 @@ void cFireworkEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (m_ExplodeTimer == m_FireworkItem.m_FireworkItem.m_FlightTimeInTicks)
+ if (m_TicksToExplosion <= 0)
{
+ // TODO: Notify the plugins
m_World->BroadcastEntityStatus(*this, esFireworkExploding);
Destroy();
+ return;
}
- m_ExplodeTimer++;
+ m_TicksToExplosion -= 1;
}
diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h
index 20f18b6dc..300ec571e 100644
--- a/src/Entities/FireworkEntity.h
+++ b/src/Entities/FireworkEntity.h
@@ -1,6 +1,11 @@
-//
-// FireworkEntity.h
-//
+
+// FireworkEntity.h
+
+// Declares the cFireworkEntity class representing the flying firework rocket
+
+
+
+
#pragma once
@@ -24,7 +29,22 @@ public:
CLASS_PROTODEF(cFireworkEntity)
cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item);
+
+ // tolua_begin
+
+ /** Returns the item used to create the rocket (has all the firework effects on it) */
const cItem & GetItem(void) const { return m_FireworkItem; }
+
+ /** Sets the item that is used to create the rocket (has all the firework effects on it) */
+ void SetItem(const cItem & a_Item) { m_FireworkItem = a_Item; }
+
+ /** Returns the number of ticks left until the firework explosion. */
+ int GetTicksToExplosion(void) const { return m_TicksToExplosion; }
+
+ /** Sets the number of ticks left until the firework explosion. */
+ void SetTicksToExplosion(int a_TicksToExplosion) { m_TicksToExplosion = a_TicksToExplosion; }
+
+ // tolua_end
protected:
@@ -34,7 +54,11 @@ protected:
private:
- int m_ExplodeTimer;
+ int m_TicksToExplosion;
cItem m_FireworkItem;
}; // tolua_export
+
+
+
+
diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h
index 3ed72d9ef..bbce89d31 100644
--- a/src/Entities/GhastFireballEntity.h
+++ b/src/Entities/GhastFireballEntity.h
@@ -1,6 +1,11 @@
-//
-// GhastFireballEntity.h
-//
+
+// GhastFireballEntity.h
+
+// Declares the cGhastFireballEntity class representing the ghast fireball in flight.
+
+
+
+
#pragma once
@@ -36,3 +41,7 @@ protected:
// TODO: Deflecting the fireballs by arrow- or sword- hits
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp
index 3276bc4a0..a6b9c40c8 100644
--- a/src/Entities/HangingEntity.cpp
+++ b/src/Entities/HangingEntity.cpp
@@ -9,9 +9,9 @@
-cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
- : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8)
- , m_BlockFace(a_BlockFace)
+cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_Facing, double a_X, double a_Y, double a_Z) :
+ cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8),
+ m_Facing(a_Facing)
{
SetMaxHealth(1);
SetHealth(1);
@@ -21,15 +21,23 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace,
-void cHangingEntity::SetDirection(eBlockFace a_BlockFace)
+void cHangingEntity::SetFacing(eBlockFace a_Facing)
{
- if ((a_BlockFace < 2) || (a_BlockFace > 5))
+ // Y-based faces are not allowed:
+ switch (a_Facing)
{
- ASSERT(!"Tried to set a bad direction!");
- return;
+ case BLOCK_FACE_NONE:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
+ {
+ LOGWARNING("%s: Invalid facing: %d. Ignoring.", __FUNCTION__, a_Facing);
+ ASSERT(!"Tried to set a bad facing!");
+ return;
+ }
+ default: break;
}
- m_BlockFace = a_BlockFace;
+ m_Facing = a_Facing;
}
@@ -41,7 +49,7 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
int Dir = 0;
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
- switch (m_BlockFace)
+ switch (m_Facing)
{
case BLOCK_FACE_ZP: Dir = 0; break;
case BLOCK_FACE_ZM: Dir = 2; break;
@@ -49,8 +57,8 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
case BLOCK_FACE_XP: Dir = 3; break;
default:
{
- LOGINFO("Invalid face (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.",
- m_BlockFace, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ()
+ LOGINFO("Invalid facing (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.",
+ m_Facing, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ()
);
Dir = 3;
}
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 1cc0034e1..67146a20b 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -11,36 +11,41 @@
class cHangingEntity :
public cEntity
{
- // tolua_end
typedef cEntity super;
public:
+ // tolua_end
+
CLASS_PROTODEF(cHangingEntity)
cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
- /** Returns the orientation from the hanging entity */
- eBlockFace GetDirection() const { return m_BlockFace; } // tolua_export
+ // tolua_begin
+
+ /** Returns the direction in which the entity is facing. */
+ eBlockFace GetFacing() const { return m_Facing; }
- /** Set the orientation from the hanging entity */
- void SetDirection(eBlockFace a_BlockFace); // tolua_export
+ /** Set the direction in which the entity is facing. */
+ void SetFacing(eBlockFace a_Facing);
- /** Returns the X coord. */
- int GetTileX() const { return POSX_TOINT; } // tolua_export
+ /** Returns the X coord of the block in which the entity resides. */
+ int GetBlockX() const { return POSX_TOINT; }
- /** Returns the Y coord. */
- int GetTileY() const { return POSY_TOINT; } // tolua_export
+ /** Returns the Y coord of the block in which the entity resides. */
+ int GetBlockY() const { return POSY_TOINT; }
- /** Returns the Z coord. */
- int GetTileZ() const { return POSZ_TOINT; } // tolua_export
+ /** Returns the Z coord of the block in which the entity resides. */
+ int GetBlockZ() const { return POSZ_TOINT; }
+
+ // tolua_end
private:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
- eBlockFace m_BlockFace;
+ eBlockFace m_Facing;
}; // tolua_export
diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp
index f512324eb..6704c05b4 100644
--- a/src/Entities/ItemFrame.cpp
+++ b/src/Entities/ItemFrame.cpp
@@ -9,10 +9,10 @@
-cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
- : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z)
- , m_Item(E_BLOCK_AIR)
- , m_Rotation(0)
+cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z) :
+ cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z),
+ m_Item(E_BLOCK_AIR),
+ m_ItemRotation(0)
{
}
@@ -27,10 +27,10 @@ void cItemFrame::OnRightClicked(cPlayer & a_Player)
if (!m_Item.IsEmpty())
{
// Item not empty, rotate, clipping values to zero to three inclusive
- m_Rotation++;
- if (m_Rotation >= 8)
+ m_ItemRotation++;
+ if (m_ItemRotation >= 8)
{
- m_Rotation = 0;
+ m_ItemRotation = 0;
}
}
else if (!a_Player.GetEquippedItem().IsEmpty())
@@ -72,7 +72,7 @@ void cItemFrame::KilledBy(TakeDamageInfo & a_TDI)
SetHealth(GetMaxHealth());
m_Item.Empty();
- m_Rotation = 0;
+ m_ItemRotation = 0;
SetInvulnerableTicks(0);
GetWorld()->BroadcastEntityMetadata(*this);
}
diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h
index a63b78b70..3642662f9 100644
--- a/src/Entities/ItemFrame.h
+++ b/src/Entities/ItemFrame.h
@@ -11,26 +11,31 @@
class cItemFrame :
public cHangingEntity
{
- // tolua_end
typedef cHangingEntity super;
public:
+ // tolua_end
+
CLASS_PROTODEF(cItemFrame)
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
+ // tolua_begin
+
/** Returns the item in the frame */
- const cItem & GetItem(void) { return m_Item; } // tolua_export
+ const cItem & GetItem(void) { return m_Item; }
/** Set the item in the frame */
- void SetItem(cItem & a_Item) { m_Item = a_Item; } // tolua_export
+ void SetItem(cItem & a_Item) { m_Item = a_Item; }
/** Returns the rotation from the item in the frame */
- Byte GetRotation(void) const { return m_Rotation; } // tolua_export
+ Byte GetItemRotation(void) const { return m_ItemRotation; }
/** Set the rotation from the item in the frame */
- void SetRotation(Byte a_Rotation) { m_Rotation = a_Rotation; } // tolua_export
+ void SetRotation(Byte a_ItemRotation) { m_ItemRotation = a_ItemRotation; }
+
+ // tolua_end
private:
@@ -39,7 +44,7 @@ private:
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
cItem m_Item;
- Byte m_Rotation;
+ Byte m_ItemRotation;
}; // tolua_export
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index 9877c95c5..078270b42 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -11,15 +11,22 @@
class cPainting :
public cEntity
{
- // tolua_end
typedef cEntity super;
public:
+
+ // tolua_end
+
CLASS_PROTODEF(cPainting)
cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z);
- const AString & GetName(void) const { return m_Name; } // tolua_export
- int GetDirection(void) const { return m_Direction; } // tolua_export
+
+ // tolua_begin
+
+ const AString & GetName(void) const { return m_Name; }
+ int GetDirection(void) const { return m_Direction; }
+
+ // tolua_end
private:
diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h
index b3cbeee0b..d1176a7cf 100644
--- a/src/Entities/Pickup.h
+++ b/src/Entities/Pickup.h
@@ -19,7 +19,7 @@ class cPickup :
public cEntity
{
typedef cEntity super;
-
+
public:
// tolua_end
@@ -37,10 +37,10 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
/** 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 */
- 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 */
bool IsCollected(void) const { return m_bCollected; } // tolua_export
@@ -59,7 +59,3 @@ private:
bool m_bIsPlayerCreated;
}; // tolua_export
-
-
-
-
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index 03eda9739..b9d2dfa63 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -1,7 +1,7 @@
// ProjectileEntity.h
-// Declares the cProjectileEntity class representing the common base class for projectiles, as well as individual projectile types
+// Declares the cProjectileEntity class representing the common base class for projectiles
@@ -23,7 +23,7 @@ class cProjectileEntity :
typedef cEntity super;
public:
- /// The kind of the projectile. The numbers correspond to the network type ID used for spawning via the 0x17 packet.
+ /** The kind of the projectile. The numbers correspond to the network type ID used for spawning them in the protocol. */
enum eKind
{
pkArrow = 60,
@@ -48,22 +48,22 @@ public:
static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL);
- /// Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given
+ /** Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given */
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
- /// Called by the physics blocktracer when the entity hits another entity
+ /** Called by the physics blocktracer when the entity hits another entity */
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{
UNUSED(a_EntityHit);
UNUSED(a_HitPos);
}
- /// Called by Chunk when the projectile is eligible for player collection
+ /** Called by Chunk when the projectile is eligible for player collection */
virtual void CollectedBy(cPlayer & a_Dest);
// tolua_begin
- /// Returns the kind of the projectile (fast class identification)
+ /** Returns the kind of the projectile (fast class identification) */
eKind GetProjectileKind(void) const { return m_ProjectileKind; }
/** Returns the unique ID of the entity who created this projectile
@@ -76,15 +76,15 @@ public:
*/
AString GetCreatorName(void) const { return m_CreatorData.m_Name; }
- /// Returns the string that is used as the entity type (class name) in MCA files
+ /** Returns the string that is used as the entity type (class name) in MCA files */
AString GetMCAClassName(void) const;
- /// Returns true if the projectile has hit the ground and is stuck there
+ /** Returns true if the projectile has hit the ground and is stuck there */
bool IsInGround(void) const { return m_IsInGround; }
// tolua_end
- /// Sets the internal InGround flag. To be used by MCA loader only!
+ /** Sets the internal InGround flag. To be used by MCA loader only! */
void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; }
protected:
@@ -114,7 +114,7 @@ protected:
*/
CreatorData m_CreatorData;
- /// True if the projectile has hit the ground and is stuck there
+ /** True if the projectile has hit the ground and is stuck there */
bool m_IsInGround;
// cEntity overrides:
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 4afc5f204..9302d8292 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -1,6 +1,11 @@
-//
-// SplashPotionEntity.h
-//
+
+// SplashPotionEntity.h
+
+// Declares the cSplashPotionEntity class representing a splash potion that has been thrown
+
+
+
+
#pragma once
@@ -32,6 +37,7 @@ public:
const cItem & a_Item
);
+ // tolua_begin
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
int GetPotionColor(void) const { return m_PotionColor; }
@@ -39,6 +45,8 @@ public:
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
+
+ // tolua_end
protected:
@@ -77,3 +85,7 @@ private:
/** Time in ticks to wait for the hit animation to begin before destroying */
int m_DestroyTimer;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp
index 5ae85bee8..24c946a9c 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -44,6 +44,27 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
+void cThrownEggEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+}
+
+
+
+
+
void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
{
if (m_World->GetTickRandomNumber(7) == 1)
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index a0b7d5340..6ffedf5b5 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -1,6 +1,11 @@
-//
-// ThrownEggEntity.h
-//
+
+// ThrownEggEntity.h
+
+// Declares the cThrownEggEntity class representing a regular thrown egg
+
+
+
+
#pragma once
@@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override
- {
- if (m_DestroyTimer > 0)
- {
- m_DestroyTimer--;
- if (m_DestroyTimer == 0)
- {
- Destroy();
- return;
- }
- }
- else
- {
- super::Tick(a_Dt, a_Chunk);
- }
- }
+ virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
// Randomly decides whether to spawn a chicken where the egg lands.
void TrySpawnChicken(const Vector3d & a_HitPos);
@@ -56,3 +46,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index c7407e6ae..8f1b62934 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -1,3 +1,4 @@
+
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "ThrownEnderPearlEntity.h"
@@ -45,6 +46,27 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
+void cThrownEnderPearlEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+}
+
+
+
+
+
void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
{
if (m_CreatorData.m_Name.empty())
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index 436450013..475ebde87 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -1,6 +1,11 @@
-//
-// ThrownEnderPearlEntity.h
-//
+
+// ThrownEnderPearlEntity.h
+
+// Declares the cThrownEnderPeralEntity class representing an ender pearl being thrown
+
+
+
+
#pragma once
@@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override
- {
- if (m_DestroyTimer > 0)
- {
- m_DestroyTimer--;
- if (m_DestroyTimer == 0)
- {
- Destroy();
- return;
- }
- }
- else
- {
- super::Tick(a_Dt, a_Chunk);
- }
- }
+ virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
/** Teleports the creator where the ender pearl lands */
void TeleportCreator(const Vector3d & a_HitPos);
@@ -56,3 +46,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index 496397100..88e39d22e 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -43,3 +43,28 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
m_DestroyTimer = 5;
}
+
+
+
+
+
+void cThrownSnowballEntity::Tick(float a_Dt, cChunk & a_Chunk)
+{
+ if (m_DestroyTimer > 0)
+ {
+ m_DestroyTimer--;
+ if (m_DestroyTimer == 0)
+ {
+ Destroy();
+ return;
+ }
+ }
+ else
+ {
+ super::Tick(a_Dt, a_Chunk);
+ }
+}
+
+
+
+
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index 8d195ced1..f806996cc 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -1,6 +1,11 @@
-//
-// ThrownSnowballEntity.h
-//
+
+// ThrownSnowballEntity.h
+
+// Declares the cThrownSnowballEntity representing a snowball that has been thrown
+
+
+
+
#pragma once
@@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
- virtual void Tick (float a_Dt, cChunk & a_Chunk) override
- {
- if (m_DestroyTimer > 0)
- {
- m_DestroyTimer--;
- if (m_DestroyTimer == 0)
- {
- Destroy();
- return;
- }
- }
- else
- {
- super::Tick(a_Dt, a_Chunk);
- }
- }
+ virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
private:
@@ -53,3 +43,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export
+
+
+
+
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
index c59acd807..43a520388 100644
--- a/src/Entities/WitherSkullEntity.h
+++ b/src/Entities/WitherSkullEntity.h
@@ -1,8 +1,12 @@
-// WitherSkullEntity.h
+// WitherSkullEntity.h
// Declares the cWitherSkullEntity class representing the entity used by both blue and black wither skulls
+
+
+
+
#pragma once
#include "ProjectileEntity.h"
@@ -30,6 +34,10 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
- virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
+ virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // tolua_export
+
+
+
+
diff --git a/src/MersenneTwister.h b/src/MersenneTwister.h
index 759b8a1ae..e83a470e2 100644
--- a/src/MersenneTwister.h
+++ b/src/MersenneTwister.h
@@ -19,11 +19,11 @@
// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
// Copyright (C) 2000 - 2009, Richard J. Wagner
// All rights reserved.
-//
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
-//
+//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
@@ -31,10 +31,10 @@
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
-// 3. The names of its contributors may not be used to endorse or promote
-// products derived from this software without specific prior written
+// 3. The names of its contributors may not be used to endorse or promote
+// products derived from this software without specific prior written
// permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -63,13 +63,13 @@ class MTRand {
// Data
public:
typedef UInt32 uint32; // unsigned integer type, at least 32 bits
-
+
enum { N = 624 }; // length of state vector
enum { SAVE = N + 1 }; // length of array for save()
protected:
enum { M = 397 }; // period parameter
-
+
uint32 state[N]; // internal state
uint32 *pNext; // next value to get from state
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(); // auto-initialize with /dev/urandom or time() and clock()
MTRand( const MTRand& o ); // copy
-
+
// Do NOT use for CRYPTOGRAPHY without securely hashing several returned
// values together, otherwise the generator state can be learned after
// reading 624 consecutive values.
-
+
// Access to 32-bit random numbers
uint32 randInt(); // integer in [0,2^32-1]
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( const double n ); // real number in (0,n)
double operator()(); // same as rand()
-
+
// Access to 53-bit random numbers (capacity of IEEE double precision)
double rand53(); // real number in [0,1)
-
+
// Access to nonuniform random number distributions
double randNorm( const double mean = 0.0, const double stddev = 1.0 );
-
+
// Re-seeding functions with same behavior as initializers
void seed( const uint32 oneSeed );
void seed( uint32 *const bigSeed, const uint32 seedLength = N );
void seed();
-
+
// Saving and loading generator state
void save( uint32* saveArray ) const; // to array of size SAVE
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
// Better than uint32(x) in case x is floating point in [0,1]
// Based on code by Lawrence Kirby (fred@genesis.demon.co.uk)
-
+
static uint32 differ = 0; // guarantee time-based seeds will change
-
+
uint32 h1 = 0;
unsigned char *p = (unsigned char *) &t;
for( size_t i = 0; i < sizeof(t); ++i )
@@ -185,7 +185,7 @@ inline void MTRand::reload()
for( i = M; --i; ++p )
*p = twist( p[MmN], p[0], p[1] );
*p = twist( p[MmN], p[0], state[0] );
-
+
left = N, pNext = state;
}
@@ -207,7 +207,7 @@ inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength )
initialize(19650218UL);
uint32 i = 1;
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 )
{
state[i] =
@@ -235,7 +235,7 @@ inline void MTRand::seed()
{
// Seed the generator with an array from /dev/urandom if available
// Otherwise use a hash of time() and clock() values
-
+
// First try getting an array from /dev/urandom
/* // 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; }
}
*/
-
+
// Was not successful, so use time() and clock() instead
seed( hash( time(NULL), clock() ) );
}
@@ -280,10 +280,10 @@ inline MTRand::uint32 MTRand::randInt()
{
// Pull a 32-bit integer from the generator state
// Every other access function simply transforms the numbers extracted here
-
+
if( left == 0 ) reload();
--left;
-
+
uint32 s1;
s1 = *pNext++;
s1 ^= (s1 >> 11);
@@ -302,7 +302,7 @@ inline MTRand::uint32 MTRand::randInt( const uint32 n )
used |= used >> 4;
used |= used >> 8;
used |= used >> 16;
-
+
// Draw numbers until one is found in [0,n]
uint32 i;
do
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index 9fd67d67c..f5ae2cb4d 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -35,12 +35,12 @@ public:
mfNoSpawn,
mfUnhandled, // Nothing. Be sure this is the last and the others are in order
} ;
-
+
// tolua_end
-
+
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
enum MPersonality{PASSIVE, AGGRESSIVE, COWARDLY} m_EMPersonality;
-
+
/** Creates the mob object.
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))
@@ -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);
CLASS_PROTODEF(cMonster)
-
+
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
-
+
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void MoveToPosition(const Vector3d & a_Position); // tolua_export
virtual bool ReachedDestination(void);
-
+
// tolua_begin
eMonsterType GetMobType(void) const {return m_MobType; }
eFamily GetMobFamily(void) const;
// tolua_end
-
+
virtual void CheckEventSeePlayer(void);
virtual void EventSeePlayer(cEntity * a_Player);
-
+
/// Reads the monster configuration for the specified monster name and assigns it to this object.
void GetMonsterConfig(const AString & a_Name);
-
+
/** Returns whether this mob is undead (skeleton, zombie, etc.) */
virtual bool IsUndead(void);
-
+
virtual void EventLosePlayer(void);
virtual void CheckEventLostPlayer(void);
-
+
virtual void InStateIdle (float a_Dt);
virtual void InStateChasing (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 SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; }
void SetAttackDamage(int a_AttackDamage) { m_AttackDamage = a_AttackDamage; }
void SetSightDistance(int a_SightDistance) { m_SightDistance = a_SightDistance; }
-
+
float GetDropChanceWeapon() { return m_DropChanceWeapon; }
float GetDropChanceHelmet() { return m_DropChanceHelmet; }
float GetDropChanceChestplate() { return m_DropChanceChestplate; }
@@ -102,7 +102,7 @@ public:
void SetDropChanceLeggings(float a_DropChanceLeggings) { m_DropChanceLeggings = a_DropChanceLeggings; }
void SetDropChanceBoots(float a_DropChanceBoots) { m_DropChanceBoots = a_DropChanceBoots; }
void SetCanPickUpLoot(bool a_CanPickUpLoot) { m_CanPickUpLoot = a_CanPickUpLoot; }
-
+
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
@@ -113,7 +113,7 @@ public:
virtual bool IsBaby (void) const { return false; }
virtual bool IsTame (void) const { return false; }
virtual bool IsSitting (void) const { return false; }
-
+
// tolua_begin
/** Returns true if the monster has a custom name. */
@@ -135,10 +135,10 @@ public:
/// Translates MobType enum to a string, empty string if unknown
static AString MobTypeToString(eMonsterType a_MobType);
-
+
/// Translates MobType string to the enum, mtInvalidType if not recognized
static eMonsterType StringToMobType(const AString & a_MobTypeName);
-
+
/// Returns the mob family based on the type
static eFamily FamilyFromType(eMonsterType a_MobType);
@@ -146,7 +146,7 @@ public:
static int GetSpawnDelay(cMonster::eFamily a_MobFamily);
// tolua_end
-
+
/** Creates a new object of the specified mob.
a_MobType is the type of the mob to be created
Asserts and returns null if mob type is not specified
@@ -154,7 +154,7 @@ public:
static cMonster * NewMonsterFromType(eMonsterType a_MobType);
protected:
-
+
/* ======= PATHFINDING ======= */
/** 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 */
bool m_bMovingToDestination;
-
+
/** 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 solid, goes up to find first nonsolid block, and returns that */
@@ -227,14 +227,14 @@ protected:
int m_AttackRange;
float m_AttackInterval;
int m_SightDistance;
-
+
float m_DropChanceWeapon;
float m_DropChanceHelmet;
float m_DropChanceChestplate;
float m_DropChanceLeggings;
float m_DropChanceBoots;
bool m_CanPickUpLoot;
-
+
void HandleDaylightBurning(cChunk & a_Chunk);
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*/
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*/
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*/
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*/
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*/
void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel);
-
-
-} ; // tolua_export
-
-
+} ; // tolua_export
diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h
index 5de5f31c4..5c8d28d2d 100644
--- a/src/OSSupport/IsThread.h
+++ b/src/OSSupport/IsThread.h
@@ -31,20 +31,20 @@ protected:
/// The overriden Execute() method should check this value periodically and terminate if this is true
volatile bool m_ShouldTerminate;
-
+
public:
cIsThread(const AString & iThreadName);
virtual ~cIsThread();
-
+
/// Starts the thread; returns without waiting for the actual start
bool Start(void);
-
+
/// Signals the thread to terminate and waits until it's finished
void Stop(void);
-
+
/// Waits for the thread to finish. Doesn't signalize the ShouldTerminate flag
bool Wait(void);
-
+
/// Returns the OS-dependent thread ID for the caller's thread
static unsigned long GetCurrentID(void);
@@ -53,7 +53,7 @@ public:
protected:
AString m_ThreadName;
-
+
// Value used for "no handle":
#ifdef _WIN32
#define NULL_HANDLE NULL
@@ -62,34 +62,34 @@ protected:
#endif
#ifdef _WIN32
-
+
DWORD m_ThreadID;
HANDLE m_Handle;
-
+
static DWORD __stdcall thrExecute(LPVOID a_Param)
{
// 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);
-
+
// Run the thread:
((cIsThread *)a_Param)->Execute();
-
+
// Destroy the identification window:
DestroyWindow(IdentificationWnd);
-
+
return 0;
}
-
+
#else // _WIN32
-
+
pthread_t m_Handle;
-
+
static void * thrExecute(void * a_Param)
{
- ((cIsThread *)a_Param)->Execute();
+ (static_cast<cIsThread *>(a_Param))->Execute();
return NULL;
}
-
+
#endif // else _WIN32
} ;
@@ -98,7 +98,3 @@ protected:
#endif // CISTHREAD_H_INCLUDED
-
-
-
-
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 204691ede..f4779d83b 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -2803,7 +2803,7 @@ void cProtocol172::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity)
WriteByte(0xA2);
WriteItem(Frame.GetItem());
WriteByte(0x3);
- WriteByte(Frame.GetRotation() / 2);
+ WriteByte(Frame.GetItemRotation() / 2);
break;
}
default: break;
diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp
index c9118c239..39046e2ed 100644
--- a/src/Protocol/Protocol18x.cpp
+++ b/src/Protocol/Protocol18x.cpp
@@ -3109,7 +3109,7 @@ void cProtocol180::cPacketizer::WriteEntityMetadata(const cEntity & a_Entity)
WriteByte(0xA8);
WriteItem(Frame.GetItem());
WriteByte(0x09);
- WriteByte(Frame.GetRotation());
+ WriteByte(Frame.GetItemRotation());
break;
}
default: break;
diff --git a/src/World.h b/src/World.h
index bb43d7fba..0ced90562 100644
--- a/src/World.h
+++ b/src/World.h
@@ -84,7 +84,7 @@ class cWorld :
public:
// tolua_end
-
+
/** A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the destructor */
class cLock :
public cCSLock
@@ -94,7 +94,7 @@ public:
cLock(cWorld & a_World);
} ;
-
+
/** A common ancestor for all tasks queued onto the tick thread */
class cTask
{
@@ -102,10 +102,10 @@ public:
virtual ~cTask() {}
virtual void Run(cWorld & a_World) = 0;
} ;
-
+
typedef std::vector<std::unique_ptr<cTask>> cTasks;
-
+
class cTaskSaveAllChunks :
public cTask
{
@@ -113,7 +113,7 @@ public:
// cTask overrides:
virtual void Run(cWorld & a_World) override;
} ;
-
+
class cTaskUnloadUnusedChunks :
public cTask
@@ -142,7 +142,7 @@ public:
{
return "cWorld";
}
-
+
// tolua_begin
int GetTicksUntilWeatherChange(void) const { return m_WeatherInterval; }
@@ -159,7 +159,7 @@ public:
virtual Int64 GetWorldAge (void) const override { return m_WorldAge; }
virtual int GetTimeOfDay(void) const override { return m_TimeOfDay; }
-
+
void SetTicksUntilWeatherChange(int a_WeatherInterval)
{
m_WeatherInterval = a_WeatherInterval;
@@ -168,42 +168,42 @@ public:
virtual void SetTimeOfDay(int a_TimeOfDay) override
{
m_TimeOfDay = a_TimeOfDay;
- m_TimeOfDaySecs = (double)a_TimeOfDay / 20.0;
+ m_TimeOfDaySecs = static_cast<double>(a_TimeOfDay) / 20.0;
UpdateSkyDarkness();
BroadcastTimeUpdate();
}
-
+
/** Returns the default weather interval for the specific weather type.
Returns -1 for any unknown weather. */
int GetDefaultWeatherInterval(eWeather a_Weather);
-
+
/** Returns the current game mode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable */
eGameMode GetGameMode(void) const { return m_GameMode; }
/** Returns true if the world is in Creative mode */
bool IsGameModeCreative(void) const { return (m_GameMode == gmCreative); }
-
+
/** Returns true if the world is in Survival mode */
bool IsGameModeSurvival(void) const { return (m_GameMode == gmSurvival); }
-
+
/** Returns true if the world is in Adventure mode */
bool IsGameModeAdventure(void) const { return (m_GameMode == gmAdventure); }
-
+
/** Returns true if the world is in Spectator mode */
bool IsGameModeSpectator(void) const { return (m_GameMode == gmSpectator); }
-
+
bool IsPVPEnabled(void) const { return m_bEnabledPVP; }
bool IsDeepSnowEnabled(void) const { return m_IsDeepSnowEnabled; }
-
+
bool ShouldLavaSpawnFire(void) const { return m_ShouldLavaSpawnFire; }
-
+
bool VillagersShouldHarvestCrops(void) const { return m_VillagersShouldHarvestCrops; }
virtual eDimension GetDimension(void) const { return m_Dimension; }
/** 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);
-
+
// tolua_end
/** 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);
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);
-
+
virtual cBroadcastInterface & GetBroadcastManager(void) override
{
return *this;
}
-
+
/** 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 MarkRedstoneDirty(int a_ChunkX, int a_ChunkZ);
void MarkChunkDirty (int a_ChunkX, int a_ChunkZ, bool a_MarkRedstoneDirty = false);
void MarkChunkSaving(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.
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 ChunkLighted(
int a_ChunkX, int a_ChunkZ,
const cChunkDef::BlockNibbles & a_BlockLight,
const cChunkDef::BlockNibbles & a_SkyLight
);
-
+
bool GetChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataCallback & a_Callback);
-
+
/** Gets the chunk's blocks, only the block types */
bool GetChunkBlockTypes(int a_ChunkX, int a_ChunkZ, BLOCKTYPE * a_BlockTypes);
-
+
/** Returns true iff the chunk is in the loader / generator queue. */
bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const;
@@ -294,10 +294,10 @@ public:
bool IsChunkValid(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*/
void QueueUnloadUnusedChunks(void); // tolua_export
-
+
void CollectPickupsByPlayer(cPlayer & a_Player);
/** 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 */
bool FindAndDoWithPlayer(const AString & a_PlayerNameHint, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
-
+
// TODO: This interface is dangerous - rewrite to DoWithClosestPlayer(pos, sight, action)
cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true);
-
+
void SendPlayerList(cPlayer * a_DestPlayer); // Sends playerlist to the player
/** 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. */
void AddEntity(cEntity * a_Entity);
-
+
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 */
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 */
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 */
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 */
bool AddChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
-
+
/** Removes client from the chunk specified */
void RemoveChunkClient(int a_ChunkX, int a_ChunkZ, cClientHandle * a_Client);
-
+
/** Removes the client from all chunks it is present in */
void RemoveClientFromChunks(cClientHandle * a_Client);
-
+
/** 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). */
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.
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);
-
+
/** Removes client from ChunkSender's queue of chunks to be sent */
void RemoveClientFromChunkSender(cClientHandle * a_Client);
-
+
/** Touches the chunk, causing it to be loaded or generated */
void TouchChunk(int a_ChunkX, int a_ChunkZ);
-
+
/** Marks the chunk as failed-to-load: */
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() */
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() */
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: */
void RegenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
-
+
/** Generates the given chunk */
void GenerateChunk(int a_ChunkX, int a_ChunkZ); // tolua_export
-
+
/** 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);
-
+
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 */
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override;
// tolua_begin
-
+
/** Sets the block at the specified coords to the specified value.
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);
-
+
/** Sets the block at the specified coords to the specified value.
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)
@@ -418,7 +418,7 @@ public:
{
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.
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);
}
-
+
BLOCKTYPE GetBlock (int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
}
-
+
NIBBLETYPE GetBlockMeta (int a_BlockX, int a_BlockY, int 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);
NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ);
NIBBLETYPE GetBlockBlockLight(int a_BlockX, int a_BlockY, int a_BlockZ);
-
+
// 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 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);
// tolua_begin
-
+
// 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); }
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); }
void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData); }
// tolua_end
-
+
/** Writes the block area into the specified coords.
Returns true if all chunks have been processed.
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.
*/
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override;
-
+
// tolua_begin
/** 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;
-
+
/** 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;
-
+
/** 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);
@@ -486,10 +486,10 @@ public:
/** Replaces world blocks with a_Blocks, if they are of type 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. */
bool GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure);
-
+
// tolua_begin
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;
@@ -500,21 +500,21 @@ public:
/** Wakes up the simulators for the specified block */
virtual void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) override;
-
+
/** 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);
// tolua_end
inline cSimulatorManager * GetSimulatorManager(void) { return m_SimulatorManager.get(); }
-
+
inline cFluidSimulator * GetWaterSimulator(void) { return m_WaterSimulator; }
inline cFluidSimulator * GetLavaSimulator (void) { return m_LavaSimulator; }
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 */
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 */
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 */
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
a_SourceData exact type depends on the a_Source:
| 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 */
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: */
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 */
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback);
void GrowTreeImage(const sSetBlockVector & a_Blocks);
-
+
// tolua_begin
/** 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);
-
+
/** 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);
-
+
/** 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);
-
+
/** 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);
-
+
/** 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);
@@ -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 */
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 */
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).
Doesn't resend the chunk to clients, use ForceSendChunkTo() for that. */
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).
(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);
-
+
/** 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.
The cuboid needn't be sorted. */
@@ -630,7 +630,7 @@ public:
/** Returns the name of the world */
const AString & GetName(void) const { return m_WorldName; }
-
+
/** Returns the name of the world.ini file used by this world */
const AString & GetIniFileName(void) const {return m_IniFileName; }
@@ -661,18 +661,18 @@ public:
AString GetLinkedOverworldName(void) const { return m_OverworldName; }
void SetLinkedOverworldName(const AString & a_Name) { m_OverworldName = a_Name; }
-
+
// tolua_end
-
+
/** Saves all chunks immediately. Dangerous interface, may deadlock, use QueueSaveAllChunks() instead */
void SaveAllChunks(void);
-
+
/** 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
-
+
/** Queues a task onto the tick thread. The task object will be deleted once the task is finished */
void QueueTask(std::unique_ptr<cTask> a_Task); // Exported in ManualBindings.cpp
-
+
/** Queues a task onto the tick thread, with the specified delay.
The task object will be deleted once the task is finished */
void ScheduleTask(int a_DelayTicks, cTask * a_Task);
@@ -690,13 +690,13 @@ public:
inline size_t GetStorageSaveQueueLength(void) { return m_Storage.GetSaveQueueLength(); } // tolua_export
void InitializeSpawn(void);
-
+
/** Starts threads that belong to this world */
void Start(void);
-
+
/** Stops threads that belong to this world (part of deinit) */
void Stop(void);
-
+
/** Processes the blocks queued for ticking with a delay (m_BlockTickQueue[]) */
void TickQueuedBlocks(void);
@@ -714,34 +714,34 @@ public:
// tolua_begin
/** Casts a thunderbolt at the specified coords */
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 */
void SetWeather(eWeather a_NewWeather);
-
+
/** Forces a weather change in the next game tick */
void ChangeWeather(void);
-
+
/** 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; }
-
+
/** Returns true if the current weather is sun */
bool IsWeatherSunny(void) const { return (m_Weather == wSunny); }
-
+
/** Returns true if it is sunny at the specified location. This takes into account biomes. */
bool IsWeatherSunnyAt(int a_BlockX, int a_BlockZ)
{
return (IsWeatherSunny() || IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
}
-
+
/** Returns true if the current weather is rain */
bool IsWeatherRain(void) const { return (m_Weather == wRain); }
-
+
/** Returns true if it is raining at the specified location. This takes into account biomes. */
bool IsWeatherRainAt(int a_BlockX, int a_BlockZ)
{
return (IsWeatherRain() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
}
-
+
/** Returns true if the current weather is stormy */
bool IsWeatherStorm(void) const { return (m_Weather == wStorm); }
@@ -750,10 +750,10 @@ public:
{
return (IsWeatherStorm() && !IsBiomeNoDownfall(GetBiomeAt(a_BlockX, a_BlockZ)));
}
-
+
/** Returns true if the current weather has any precipitation - rain, storm or snow */
bool IsWeatherWet(void) const { return !IsWeatherSunny(); }
-
+
/** 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)
{
@@ -765,33 +765,33 @@ public:
cChunkGenerator & GetGenerator(void) { return m_Generator; }
cWorldStorage & GetStorage (void) { return m_Storage; }
cChunkMap * GetChunkMap (void) { return m_ChunkMap.get(); }
-
+
/** 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
-
+
int GetMaxSugarcaneHeight(void) const { return m_MaxSugarcaneHeight; } // tolua_export
int GetMaxCactusHeight (void) const { return m_MaxCactusHeight; } // 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 */
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) override; // tolua_export
int SpawnMobFinalize(cMonster* a_Monster);
-
+
/** 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
*/
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! */
- 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 */
void TabCompleteUserName(const AString & a_Text, AStringVector & a_Results);
/** Get the current darkness level based on the time */
NIBBLETYPE GetSkyDarkness() { return m_SkyDarkness; }
-
+
/** 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
whether it has any clients or not.
@@ -802,43 +802,43 @@ public:
private:
friend class cRoot;
-
+
class cTickThread :
public cIsThread
{
typedef cIsThread super;
public:
cTickThread(cWorld & a_World);
-
+
protected:
cWorld & m_World;
-
+
// cIsThread overrides:
virtual void Execute(void) override;
} ;
-
-
+
+
/** Implementation of the callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
class cChunkGeneratorCallbacks :
public cChunkGenerator::cChunkSink,
public cChunkGenerator::cPluginInterface
{
cWorld * m_World;
-
+
// cChunkSink overrides:
virtual void OnChunkGenerated (cChunkDesc & a_ChunkDesc) override;
virtual bool IsChunkValid (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;
-
+
// cPluginInterface overrides:
virtual void CallHookChunkGenerating(cChunkDesc & a_ChunkDesc) override;
virtual void CallHookChunkGenerated (cChunkDesc & a_ChunkDesc) override;
-
+
public:
cChunkGeneratorCallbacks(cWorld & a_World);
} ;
-
+
/** A container for tasks that have been scheduled for a specific game tick */
class cScheduledTask
@@ -846,14 +846,14 @@ private:
public:
Int64 m_TargetTick;
cTask * m_Task;
-
+
/** Creates a new scheduled task; takes ownership of the task object passed to it. */
cScheduledTask(Int64 a_TargetTick, cTask * a_Task) :
m_TargetTick(a_TargetTick),
m_Task(a_Task)
{
}
-
+
virtual ~cScheduledTask()
{
delete m_Task;
@@ -873,15 +873,15 @@ private:
AString m_OverworldName;
AString m_IniFileName;
-
+
/** Name of the storage schema used to load and save chunks */
AString m_StorageSchema;
-
+
int m_StorageCompressionFactor;
-
+
/** The dimension of the world, used by the client to provide correct lighting scheme */
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) */
MTRand m_TickRand;
@@ -910,7 +910,7 @@ private:
bool m_IsDeepSnowEnabled;
bool m_ShouldLavaSpawnFire;
bool m_VillagersShouldHarvestCrops;
-
+
std::vector<BlockTickQueueItem *> m_BlockTickQueue;
std::vector<BlockTickQueueItem *> m_BlockTickQueueCopy; // Second is for safely removing the objects from the queue
@@ -920,12 +920,12 @@ private:
cFluidSimulator * m_LavaSimulator;
std::unique_ptr<cFireSimulator> m_FireSimulator;
cRedstoneSimulator<cChunk, cWorld> * m_RedstoneSimulator;
-
+
cCriticalSection m_CSPlayers;
cPlayerList m_Players;
cWorldStorage m_Storage;
-
+
unsigned int m_MaxPlayers;
std::unique_ptr<cChunkMap> m_ChunkMap;
@@ -935,7 +935,7 @@ private:
eWeather m_Weather;
int m_WeatherInterval;
-
+
int m_MaxCactusHeight;
int m_MaxSugarcaneHeight;
bool m_IsCactusBonemealable;
@@ -952,7 +952,7 @@ private:
/** Whether command blocks are enabled or not */
bool m_bCommandBlocksEnabled;
-
+
/** Whether prefixes such as [INFO] are prepended to SendMessageXXX() / BroadcastChatXXX() functions */
bool m_bUseChatPrefixes;
@@ -966,43 +966,43 @@ private:
/** Name of the end world */
AString m_EndWorldName;
-
+
cChunkGenerator m_Generator;
cScoreboard m_Scoreboard;
cMapManager m_MapManager;
-
+
/** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */
cChunkGeneratorCallbacks m_GeneratorCallbacks;
-
+
cChunkSender m_ChunkSender;
cLightingThread m_Lighting;
cTickThread m_TickThread;
-
+
/** Guards the m_Tasks */
cCriticalSection m_CSTasks;
-
+
/** Tasks that have been queued onto the tick thread; guarded by m_CSTasks */
cTasks m_Tasks;
-
+
/** Guards the m_ScheduledTasks */
cCriticalSection m_CSScheduledTasks;
-
+
/** Tasks that have been queued to be executed on the tick thread at target tick in the future.
Ordered by increasing m_TargetTick.
Guarded by m_CSScheduledTasks */
cScheduledTasks m_ScheduledTasks;
-
+
/** Guards m_Clients */
cCriticalSection m_CSClients;
-
+
/** List of clients in this world, these will be ticked by this world */
cClientHandleList m_Clients;
-
+
/** Clients that are scheduled for removal (ticked in another world), waiting for TickClients() to remove them */
cClientHandleList m_ClientsToRemove;
-
+
/** Clients that are scheduled for adding, waiting for TickClients to add them */
cClientHandleList m_ClientsToAdd;
@@ -1017,10 +1017,10 @@ private:
/** List of players that are scheduled for adding, waiting for the Tick thread to add them. */
cPlayerList m_PlayersToAdd;
-
+
/** CS protecting m_SetChunkDataQueue. */
cCriticalSection m_CSSetChunkDataQueue;
-
+
/** Queue for the chunk data to be set into m_ChunkMap by the tick thread. Protected by m_CSSetChunkDataQueue */
cSetChunkDataPtrs m_SetChunkDataQueue;
@@ -1032,16 +1032,16 @@ private:
/** Handles the weather in each tick */
void TickWeather(float a_Dt);
-
+
/** Handles the mob spawning/moving/destroying each tick */
void TickMobs(float a_Dt);
-
+
/** Executes all tasks queued onto the tick thread */
void TickQueuedTasks(void);
-
+
/** Executes all tasks queued onto the tick thread */
void TickScheduledTasks(void);
-
+
/** Ticks all clients that are in this world */
void TickClients(float a_Dt);
@@ -1077,7 +1077,3 @@ private:
void SetChunkData(cSetChunkData & a_SetChunkData);
}; // tolua_export
-
-
-
-
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 28b9dd042..80d9ab6d2 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -685,21 +685,21 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
void cNBTChunkSerializer::AddHangingEntity(cHangingEntity * a_Hanging)
{
- m_Writer.AddByte("Direction", (unsigned char)a_Hanging->GetDirection());
- m_Writer.AddInt("TileX", a_Hanging->GetTileX());
- m_Writer.AddInt("TileY", a_Hanging->GetTileY());
- m_Writer.AddInt("TileZ", a_Hanging->GetTileZ());
- switch (a_Hanging->GetDirection())
+ m_Writer.AddInt("TileX", a_Hanging->GetBlockX());
+ m_Writer.AddInt("TileY", a_Hanging->GetBlockY());
+ m_Writer.AddInt("TileZ", a_Hanging->GetBlockZ());
+ switch (a_Hanging->GetFacing())
{
- case BLOCK_FACE_YM: m_Writer.AddByte("Dir", (unsigned char)2); break;
- case BLOCK_FACE_YP: m_Writer.AddByte("Dir", (unsigned char)1); break;
- case BLOCK_FACE_ZM: m_Writer.AddByte("Dir", (unsigned char)0); break;
- case BLOCK_FACE_ZP: m_Writer.AddByte("Dir", (unsigned char)3); break;
+ case BLOCK_FACE_XM: m_Writer.AddByte("Facing", 1); break;
+ case BLOCK_FACE_XP: m_Writer.AddByte("Facing", 3); break;
+ case BLOCK_FACE_ZM: m_Writer.AddByte("Facing", 2); break;
+ case BLOCK_FACE_ZP: m_Writer.AddByte("Facing", 0); break;
- case BLOCK_FACE_XM:
- case BLOCK_FACE_XP:
+ case BLOCK_FACE_YM:
+ case BLOCK_FACE_YP:
case BLOCK_FACE_NONE:
{
+ // These directions are invalid, but they may have been previously loaded, so keep them.
break;
}
}
@@ -740,7 +740,7 @@ void cNBTChunkSerializer::AddItemFrameEntity(cItemFrame * a_ItemFrame)
AddBasicEntity(a_ItemFrame, "ItemFrame");
AddHangingEntity(a_ItemFrame);
AddItem(a_ItemFrame->GetItem(), -1, "Item");
- m_Writer.AddByte("ItemRotation", (unsigned char)a_ItemFrame->GetRotation());
+ m_Writer.AddByte("ItemRotation", (unsigned char)a_ItemFrame->GetItemRotation());
m_Writer.AddFloat("ItemDropChance", 1.0F);
m_Writer.EndCompound();
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 092b9514c..eba21c659 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1660,30 +1660,41 @@ void cWSSAnvil::LoadExpOrbFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadHangingFromNBT(cHangingEntity & a_Hanging, const cParsedNBT & a_NBT, int a_TagIdx)
{
- int Direction = a_NBT.FindChildByName(a_TagIdx, "Direction");
- if (Direction > 0)
+ // "Facing" tag is the prime source of the Facing; if not available, translate from older "Direction" or "Dir"
+ int Facing = a_NBT.FindChildByName(a_TagIdx, "Facing");
+ if (Facing > 0)
{
- Direction = (int)a_NBT.GetByte(Direction);
- if ((Direction < 2) || (Direction > 5))
+ Facing = (int)a_NBT.GetByte(Facing);
+ if ((Facing >= 2) && (Facing <= 5))
{
- a_Hanging.SetDirection(BLOCK_FACE_NORTH);
- }
- else
- {
- a_Hanging.SetDirection(static_cast<eBlockFace>(Direction));
+ a_Hanging.SetFacing(static_cast<eBlockFace>(Facing));
}
}
else
{
- Direction = a_NBT.FindChildByName(a_TagIdx, "Dir");
- if (Direction > 0)
+ Facing = a_NBT.FindChildByName(a_TagIdx, "Direction");
+ if (Facing > 0)
+ {
+ switch ((int)a_NBT.GetByte(Facing))
+ {
+ case 0: a_Hanging.SetFacing(BLOCK_FACE_ZM); break;
+ case 1: a_Hanging.SetFacing(BLOCK_FACE_XM); break;
+ case 2: a_Hanging.SetFacing(BLOCK_FACE_ZP); break;
+ case 3: a_Hanging.SetFacing(BLOCK_FACE_XP); break;
+ }
+ }
+ else
{
- switch ((int)a_NBT.GetByte(Direction))
+ Facing = a_NBT.FindChildByName(a_TagIdx, "Dir"); // Has values 0 and 2 swapped
+ if (Facing > 0)
{
- case 0: a_Hanging.SetDirection(BLOCK_FACE_NORTH); break;
- case 1: a_Hanging.SetDirection(BLOCK_FACE_TOP); break;
- case 2: a_Hanging.SetDirection(BLOCK_FACE_BOTTOM); break;
- case 3: a_Hanging.SetDirection(BLOCK_FACE_SOUTH); break;
+ switch ((int)a_NBT.GetByte(Facing))
+ {
+ case 0: a_Hanging.SetFacing(BLOCK_FACE_ZP); break;
+ case 1: a_Hanging.SetFacing(BLOCK_FACE_XM); break;
+ case 2: a_Hanging.SetFacing(BLOCK_FACE_ZM); break;
+ case 3: a_Hanging.SetFacing(BLOCK_FACE_XP); break;
+ }
}
}
}