summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-08-11 11:39:43 +0200
committerpeterbell10 <peterbell10@live.co.uk>2019-08-11 11:39:43 +0200
commite0ca4d83991d80865781c1dbbbfa1f92259a366a (patch)
tree7a1ee18692772befe2c60bd304474fae99d51e1b /src/Entities
parentWake up redstone simulator on slot changes for blockentities (#4348) (diff)
downloadcuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.gz
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.bz2
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.lz
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.xz
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.tar.zst
cuberite-e0ca4d83991d80865781c1dbbbfa1f92259a366a.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Entity.cpp12
-rw-r--r--src/Entities/Entity.h10
-rw-r--r--src/Entities/Pickup.cpp2
-rw-r--r--src/Entities/Player.cpp4
4 files changed, 15 insertions, 13 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 7546cc402..55f5ba144 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -414,7 +414,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if ((a_TDI.DamageType == dtAttack) || (a_TDI.DamageType == dtArrowAttack))
{
- a_TDI.FinalDamage *= 1.5; // 150% damage
+ a_TDI.FinalDamage *= 1.5f; // 150% damage
m_World->BroadcastEntityAnimation(*this, 4); // Critical hit
}
}
@@ -427,7 +427,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if (SharpnessLevel > 0)
{
- a_TDI.FinalDamage += 1.25 * SharpnessLevel;
+ a_TDI.FinalDamage += 1.25f * SharpnessLevel;
}
else if (SmiteLevel > 0)
{
@@ -441,7 +441,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
case mtWither:
case mtZombiePigman:
{
- a_TDI.FinalDamage += 2.5 * SmiteLevel;
+ a_TDI.FinalDamage += 2.5f * SmiteLevel;
break;
}
default: break;
@@ -459,7 +459,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
case mtCaveSpider:
case mtSilverfish:
{
- a_TDI.FinalDamage += 2.5 * BaneOfArthropodsLevel;
+ a_TDI.FinalDamage += 2.5f * BaneOfArthropodsLevel;
// The duration of the effect is a random value between 1 and 1.5 seconds at level I,
// increasing the max duration by 0.5 seconds each level
// Ref: https://minecraft.gamepedia.com/Enchanting#Bane_of_Arthropods
@@ -868,7 +868,7 @@ void cEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
}
// Position changed -> super::Tick() called:
- GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, POSX_TOINT, POSZ_TOINT)
+ GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, POSX_TOINT, POSZ_TOINT);
// Set swim states (water, lava, and fire):
SetSwimState(*NextChunk);
@@ -920,7 +920,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
int BlockZ = POSZ_TOINT;
// Position changed -> super::HandlePhysics() called
- GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, BlockX, BlockZ)
+ GET_AND_VERIFY_CURRENT_CHUNK(NextChunk, BlockX, BlockZ);
// TODO Add collision detection with entities.
auto DtSec = std::chrono::duration_cast<std::chrono::duration<double>>(a_Dt);
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 282e8368a..594acdd89 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -33,10 +33,12 @@
#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) \
cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); \
- if ((ChunkVarName == nullptr) || !ChunkVarName->IsValid()) \
- { \
- return; \
- }
+ do { \
+ if ((ChunkVarName == nullptr) || !ChunkVarName->IsValid()) \
+ { \
+ return; \
+ } \
+ } while (false)
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 4b983588c..c63c720c0 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -143,7 +143,7 @@ void cPickup::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
if ((BlockY >= 0) && (BlockY < cChunkDef::Height)) // Don't do anything except for falling when outside the world
{
// Position might have changed due to physics. So we have to make sure we have the correct chunk.
- GET_AND_VERIFY_CURRENT_CHUNK(CurrentChunk, BlockX, BlockZ)
+ GET_AND_VERIFY_CURRENT_CHUNK(CurrentChunk, BlockX, BlockZ);
// Destroy the pickup if it is on fire:
if (IsOnFire())
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 07962fec8..ef6afbff3 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2689,8 +2689,8 @@ void cPlayer::SendBlocksAround(int a_BlockX, int a_BlockY, int a_BlockZ, int a_R
for (int x = a_BlockX - a_Range + 1; x < a_BlockX + a_Range; x++)
{
blks.emplace_back(x, y, z, E_BLOCK_AIR, 0); // Use fake blocktype, it will get set later on.
- };
- };
+ }
+ }
} // for y
// Get the values of all the blocks: