summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-07-26 13:27:27 +0200
committerHowaner <franzi.moos@googlemail.com>2014-07-26 13:27:27 +0200
commitef4d68adfd70488df0887f3a5fba1c9aad7a0108 (patch)
tree1ea3acb0e6b16e8badf7d1d56301bf3dd3a5d99e /src/Entities
parentAdd armor items directly to the armor slots. (diff)
parentGit: Ignore AllFiles.lst (generated by cmake) (diff)
downloadcuberite-ef4d68adfd70488df0887f3a5fba1c9aad7a0108.tar
cuberite-ef4d68adfd70488df0887f3a5fba1c9aad7a0108.tar.gz
cuberite-ef4d68adfd70488df0887f3a5fba1c9aad7a0108.tar.bz2
cuberite-ef4d68adfd70488df0887f3a5fba1c9aad7a0108.tar.lz
cuberite-ef4d68adfd70488df0887f3a5fba1c9aad7a0108.tar.xz
cuberite-ef4d68adfd70488df0887f3a5fba1c9aad7a0108.tar.zst
cuberite-ef4d68adfd70488df0887f3a5fba1c9aad7a0108.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/ArrowEntity.h2
-rw-r--r--src/Entities/Boat.h2
-rw-r--r--src/Entities/CMakeLists.txt65
-rw-r--r--src/Entities/EnderCrystal.h2
-rw-r--r--src/Entities/Entity.cpp17
-rw-r--r--src/Entities/Entity.h8
-rw-r--r--src/Entities/EntityEffect.h2
-rw-r--r--src/Entities/ExpBottleEntity.h2
-rw-r--r--src/Entities/ExpOrb.cpp6
-rw-r--r--src/Entities/ExpOrb.h2
-rw-r--r--src/Entities/FallingBlock.h2
-rw-r--r--src/Entities/FireChargeEntity.h2
-rw-r--r--src/Entities/FireworkEntity.h2
-rw-r--r--src/Entities/Floater.h2
-rw-r--r--src/Entities/GhastFireballEntity.h2
-rw-r--r--src/Entities/HangingEntity.h4
-rw-r--r--src/Entities/ItemFrame.h4
-rw-r--r--src/Entities/Minecart.cpp16
-rw-r--r--src/Entities/Minecart.h23
-rw-r--r--src/Entities/Painting.h2
-rw-r--r--src/Entities/Pawn.h2
-rw-r--r--src/Entities/Pickup.h2
-rw-r--r--src/Entities/Player.cpp129
-rw-r--r--src/Entities/Player.h16
-rw-r--r--src/Entities/ProjectileEntity.cpp8
-rw-r--r--src/Entities/ProjectileEntity.h2
-rw-r--r--src/Entities/SplashPotionEntity.cpp41
-rw-r--r--src/Entities/SplashPotionEntity.h36
-rw-r--r--src/Entities/TNTEntity.cpp2
-rw-r--r--src/Entities/TNTEntity.h2
-rw-r--r--src/Entities/ThrownEggEntity.h2
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h2
-rw-r--r--src/Entities/ThrownSnowballEntity.h2
-rw-r--r--src/Entities/WitherSkullEntity.h2
34 files changed, 247 insertions, 168 deletions
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index ad93dba6c..4bfcb1f6d 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -28,7 +28,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cArrowEntity);
+ CLASS_PROTODEF(cArrowEntity)
/// 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);
diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h
index 0fcfbd602..8de88d165 100644
--- a/src/Entities/Boat.h
+++ b/src/Entities/Boat.h
@@ -21,7 +21,7 @@ class cBoat :
typedef cEntity super;
public:
- CLASS_PROTODEF(cBoat);
+ CLASS_PROTODEF(cBoat)
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt
index 205cb2cca..5d10e1680 100644
--- a/src/Entities/CMakeLists.txt
+++ b/src/Entities/CMakeLists.txt
@@ -4,11 +4,64 @@ project (MCServer)
include_directories ("${PROJECT_SOURCE_DIR}/../")
-file(GLOB SOURCE
- "*.cpp"
- "*.h"
-)
+SET (SRCS
+ ArrowEntity.cpp
+ Boat.cpp
+ EnderCrystal.cpp
+ Entity.cpp
+ EntityEffect.cpp
+ ExpBottleEntity.cpp
+ ExpOrb.cpp
+ FallingBlock.cpp
+ FireChargeEntity.cpp
+ FireworkEntity.cpp
+ Floater.cpp
+ GhastFireballEntity.cpp
+ HangingEntity.cpp
+ ItemFrame.cpp
+ Minecart.cpp
+ Painting.cpp
+ Pawn.cpp
+ Pickup.cpp
+ Player.cpp
+ ProjectileEntity.cpp
+ SplashPotionEntity.cpp
+ TNTEntity.cpp
+ ThrownEggEntity.cpp
+ ThrownEnderPearlEntity.cpp
+ ThrownSnowballEntity.cpp
+ WitherSkullEntity.cpp)
-add_library(Entities ${SOURCE})
+SET (HDRS
+ ArrowEntity.h
+ Boat.h
+ EnderCrystal.h
+ Entity.h
+ EntityEffect.h
+ ExpBottleEntity.h
+ ExpOrb.h
+ FallingBlock.h
+ FireChargeEntity.h
+ FireworkEntity.h
+ Floater.h
+ GhastFireballEntity.h
+ HangingEntity.h
+ ItemFrame.h
+ Minecart.h
+ Painting.h
+ Pawn.h
+ Pickup.h
+ Player.h
+ ProjectileEntity.h
+ SplashPotionEntity.h
+ TNTEntity.h
+ ThrownEggEntity.h
+ ThrownEnderPearlEntity.h
+ ThrownSnowballEntity.h
+ WitherSkullEntity.h)
-target_link_libraries(Entities WorldStorage)
+if(NOT MSVC)
+ add_library(Entities ${SRCS} ${HDRS})
+
+ target_link_libraries(Entities WorldStorage)
+endif()
diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h
index 30211de13..c98c3b681 100644
--- a/src/Entities/EnderCrystal.h
+++ b/src/Entities/EnderCrystal.h
@@ -15,7 +15,7 @@ class cEnderCrystal :
typedef cEntity super;
public:
- CLASS_PROTODEF(cEnderCrystal);
+ CLASS_PROTODEF(cEnderCrystal)
cEnderCrystal(double a_X, double a_Y, double a_Z);
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 28817428f..db0fd0fd6 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -49,6 +49,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_IsSubmerged(false)
, m_AirLevel(0)
, m_AirTickTimer(0)
+ , m_TicksAlive(0)
, m_HeadYaw(0.0)
, m_Rot(0.0, 0.0, 0.0)
, m_Pos(a_X, a_Y, a_Z)
@@ -327,10 +328,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
// TODO: Apply damage to armor
- if (m_Health < 0)
- {
- m_Health = 0;
- }
+ m_Health = std::max(m_Health, 0);
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
{
@@ -562,6 +560,8 @@ void cEntity::SetHealth(int a_Health)
void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
+ m_TicksAlive++;
+
if (m_InvulnerableTicks > 0)
{
m_InvulnerableTicks--;
@@ -648,7 +648,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
int RelBlockX = BlockX - (NextChunk->GetPosX() * cChunkDef::Width);
int RelBlockZ = BlockZ - (NextChunk->GetPosZ() * cChunkDef::Width);
- BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ );
+ BLOCKTYPE BlockIn = NextChunk->GetBlock( RelBlockX, BlockY, RelBlockZ);
BLOCKTYPE BlockBelow = (BlockY > 0) ? NextChunk->GetBlock(RelBlockX, BlockY - 1, RelBlockZ) : E_BLOCK_AIR;
if (!cBlockInfo::IsSolid(BlockIn)) // Making sure we are not inside a solid block
{
@@ -758,7 +758,7 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
m_WaterSpeed *= 0.9f; // Reduce speed each tick
- switch(WaterDir)
+ switch (WaterDir)
{
case X_PLUS:
m_WaterSpeed.x = 0.2f;
@@ -1146,10 +1146,7 @@ void cEntity::SetMaxHealth(int a_MaxHealth)
m_MaxHealth = a_MaxHealth;
// Reset health, if too high:
- if (m_Health > a_MaxHealth)
- {
- m_Health = a_MaxHealth;
- }
+ m_Health = std::min(m_Health, a_MaxHealth);
}
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 88f8528e9..efca60a6c 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -416,6 +416,9 @@ public:
/** Gets remaining air of a monster */
int GetAirLevel(void) const { return m_AirLevel; }
+ /** 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; }
@@ -425,7 +428,7 @@ public:
// tolua_end
/// Called when the specified player right-clicks this entity
- virtual void OnRightClicked(cPlayer &) {};
+ virtual void OnRightClicked(cPlayer &) {}
/// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy().
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL)
@@ -521,6 +524,9 @@ protected:
int m_AirLevel;
int m_AirTickTimer;
+ /** The number of ticks this entity has been alive for */
+ long int m_TicksAlive;
+
private:
/** Measured in degrees, [-180, +180) */
double m_HeadYaw;
diff --git a/src/Entities/EntityEffect.h b/src/Entities/EntityEffect.h
index ebd611ff0..396a9bbe0 100644
--- a/src/Entities/EntityEffect.h
+++ b/src/Entities/EntityEffect.h
@@ -55,7 +55,7 @@ public:
@param a_OtherEffect The other effect to copy */
cEntityEffect & operator=(cEntityEffect a_OtherEffect);
- virtual ~cEntityEffect(void) {};
+ virtual ~cEntityEffect(void) {}
/** Creates a pointer to the proper entity effect from the effect type
@warning This function creates raw pointers that must be manually managed.
diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h
index e9536452c..d62a84469 100644
--- a/src/Entities/ExpBottleEntity.h
+++ b/src/Entities/ExpBottleEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cExpBottleEntity);
+ CLASS_PROTODEF(cExpBottleEntity)
cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index ed225b8e6..73d5cbfed 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -62,9 +62,9 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
}
a_Distance.Normalize();
a_Distance *= ((float) (5.5 - Distance));
- SetSpeedX( a_Distance.x );
- SetSpeedY( a_Distance.y );
- SetSpeedZ( a_Distance.z );
+ SetSpeedX( a_Distance.x);
+ SetSpeedY( a_Distance.y);
+ SetSpeedZ( a_Distance.z);
BroadcastMovementUpdate();
}
HandlePhysics(a_Dt, a_Chunk);
diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h
index 2cd4ef31f..bdb9a5b19 100644
--- a/src/Entities/ExpOrb.h
+++ b/src/Entities/ExpOrb.h
@@ -16,7 +16,7 @@ class cExpOrb :
public:
// tolua_end
- CLASS_PROTODEF(cExpOrb);
+ CLASS_PROTODEF(cExpOrb)
cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward);
cExpOrb(const Vector3d & a_Pos, int a_Reward);
diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h
index 5ba9909bb..c20fe8eb9 100644
--- a/src/Entities/FallingBlock.h
+++ b/src/Entities/FallingBlock.h
@@ -20,7 +20,7 @@ class cFallingBlock :
typedef cEntity super;
public:
- CLASS_PROTODEF(cFallingBlock);
+ CLASS_PROTODEF(cFallingBlock)
/// Creates a new falling block. a_BlockPosition is expected in world coords
cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h
index 42ecc7d74..5df55bec4 100644
--- a/src/Entities/FireChargeEntity.h
+++ b/src/Entities/FireChargeEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cFireChargeEntity);
+ CLASS_PROTODEF(cFireChargeEntity)
cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/FireworkEntity.h b/src/Entities/FireworkEntity.h
index 7dbdc49e1..20f18b6dc 100644
--- a/src/Entities/FireworkEntity.h
+++ b/src/Entities/FireworkEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cFireworkEntity);
+ CLASS_PROTODEF(cFireworkEntity)
cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item);
const cItem & GetItem(void) const { return m_FireworkItem; }
diff --git a/src/Entities/Floater.h b/src/Entities/Floater.h
index 5d2720b6a..96d77ac82 100644
--- a/src/Entities/Floater.h
+++ b/src/Entities/Floater.h
@@ -16,7 +16,7 @@ class cFloater :
public:
// tolua_end
- CLASS_PROTODEF(cFloater);
+ CLASS_PROTODEF(cFloater)
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h
index fa59fa642..3ed72d9ef 100644
--- a/src/Entities/GhastFireballEntity.h
+++ b/src/Entities/GhastFireballEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cGhastFireballEntity);
+ CLASS_PROTODEF(cGhastFireballEntity)
cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 6498e4b5b..3593f9ede 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -16,7 +16,7 @@ class cHangingEntity :
public:
- CLASS_PROTODEF(cHangingEntity);
+ CLASS_PROTODEF(cHangingEntity)
cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
@@ -38,7 +38,7 @@ public:
private:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(float a_Dt, cChunk & a_Chunk) override {};
+ virtual void Tick(float a_Dt, cChunk & a_Chunk) override {}
eBlockFace m_BlockFace;
diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h
index 9261e52cc..a63b78b70 100644
--- a/src/Entities/ItemFrame.h
+++ b/src/Entities/ItemFrame.h
@@ -16,7 +16,7 @@ class cItemFrame :
public:
- CLASS_PROTODEF(cItemFrame);
+ CLASS_PROTODEF(cItemFrame)
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
@@ -24,7 +24,7 @@ public:
const cItem & GetItem(void) { return m_Item; } // tolua_export
/** 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; } // tolua_export
/** Returns the rotation from the item in the frame */
Byte GetRotation(void) const { return m_Rotation; } // tolua_export
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index 03850c8a7..d4eadc5d5 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -103,21 +103,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
void cMinecart::SpawnOn(cClientHandle & a_ClientHandle)
{
- char SubType = 0;
- switch (m_Payload)
- {
- case mpNone: SubType = 0; break;
- case mpChest: SubType = 1; break;
- case mpFurnace: SubType = 2; break;
- case mpTNT: SubType = 3; break;
- case mpHopper: SubType = 5; break;
- default:
- {
- ASSERT(!"Unknown payload, cannot spawn on client");
- return;
- }
- }
- a_ClientHandle.SendSpawnVehicle(*this, 10, SubType); // 10 = Minecarts, SubType = What type of Minecart
+ a_ClientHandle.SendSpawnVehicle(*this, 10, (char)m_Payload); // 10 = Minecarts
a_ClientHandle.SendEntityMetadata(*this);
}
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index 798f844ce..410d3c77d 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -21,15 +21,16 @@ class cMinecart :
typedef cEntity super;
public:
- CLASS_PROTODEF(cMinecart);
+ CLASS_PROTODEF(cMinecart)
+ /** Minecart payload, values correspond to packet subtype */
enum ePayload
{
- mpNone, // Empty minecart, ridable by player or mobs
- mpChest, // Minecart-with-chest, can store a grid of 3*8 items
- mpFurnace, // Minecart-with-furnace, can be powered
- mpTNT, // Minecart-with-TNT, can be blown up with activator rail
- mpHopper, // Minecart-with-hopper, can be hopper
+ mpNone = 0, // Empty minecart, ridable by player or mobs
+ mpChest = 1, // Minecart-with-chest, can store a grid of 3*8 items
+ mpFurnace = 2, // Minecart-with-furnace, can be powered
+ mpTNT = 3, // Minecart-with-TNT, can be blown up with activator rail
+ mpHopper = 5, // Minecart-with-hopper, can be hopper
// TODO: Spawner minecarts, (and possibly any block in a minecart with NBT editing)
} ;
@@ -88,7 +89,7 @@ class cRideableMinecart :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cRideableMinecart);
+ CLASS_PROTODEF(cRideableMinecart)
cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height);
@@ -112,7 +113,7 @@ class cMinecartWithChest :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithChest);
+ CLASS_PROTODEF(cMinecartWithChest)
/// Number of item slots in the chest
static const int NumSlots = 9 * 3;
@@ -143,7 +144,7 @@ class cMinecartWithFurnace :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithFurnace);
+ CLASS_PROTODEF(cMinecartWithFurnace)
cMinecartWithFurnace(double a_X, double a_Y, double a_Z);
@@ -175,7 +176,7 @@ class cMinecartWithTNT :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithTNT);
+ CLASS_PROTODEF(cMinecartWithTNT)
cMinecartWithTNT(double a_X, double a_Y, double a_Z);
} ;
@@ -190,7 +191,7 @@ class cMinecartWithHopper :
typedef cMinecart super;
public:
- CLASS_PROTODEF(cMinecartWithHopper);
+ CLASS_PROTODEF(cMinecartWithHopper)
cMinecartWithHopper(double a_X, double a_Y, double a_Z);
} ;
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index ce7c6f3de..9877c95c5 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -15,7 +15,7 @@ class cPainting :
typedef cEntity super;
public:
- CLASS_PROTODEF(cPainting);
+ 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
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index 63c7cfbb6..d50bcd8af 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -16,7 +16,7 @@ class cPawn :
typedef cEntity super;
public:
- CLASS_PROTODEF(cPawn);
+ CLASS_PROTODEF(cPawn)
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h
index d7c5d2b26..4d5250819 100644
--- a/src/Entities/Pickup.h
+++ b/src/Entities/Pickup.h
@@ -23,7 +23,7 @@ class cPickup :
public:
// tolua_end
- CLASS_PROTODEF(cPickup);
+ CLASS_PROTODEF(cPickup)
cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f);
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 5c3303cb2..fcc8eb9a0 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2,6 +2,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Player.h"
+#include "../ChatColor.h"
#include "../Server.h"
#include "../UI/Window.h"
#include "../UI/WindowOwner.h"
@@ -139,7 +140,7 @@ cPlayer::~cPlayer(void)
SaveToDisk();
- m_World->RemovePlayer( this );
+ m_World->RemovePlayer( this);
m_ClientHandle = NULL;
@@ -172,11 +173,11 @@ void cPlayer::SpawnOn(cClientHandle & a_Client)
}
a_Client.SendPlayerSpawn(*this);
a_Client.SendEntityHeadLook(*this);
- a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem() );
- a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots() );
- a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings() );
- a_Client.SendEntityEquipment(*this, 3, m_Inventory.GetEquippedChestplate() );
- a_Client.SendEntityEquipment(*this, 4, m_Inventory.GetEquippedHelmet() );
+ a_Client.SendEntityEquipment(*this, 0, m_Inventory.GetEquippedItem());
+ a_Client.SendEntityEquipment(*this, 1, m_Inventory.GetEquippedBoots());
+ a_Client.SendEntityEquipment(*this, 2, m_Inventory.GetEquippedLeggings());
+ a_Client.SendEntityEquipment(*this, 3, m_Inventory.GetEquippedChestplate());
+ a_Client.SendEntityEquipment(*this, 4, m_Inventory.GetEquippedHelmet());
}
@@ -285,19 +286,19 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
short cPlayer::CalcLevelFromXp(short a_XpTotal)
{
// level 0 to 15
- if(a_XpTotal <= XP_TO_LEVEL15)
+ if (a_XpTotal <= XP_TO_LEVEL15)
{
return a_XpTotal / XP_PER_LEVEL_TO15;
}
// level 30+
- if(a_XpTotal > XP_TO_LEVEL30)
+ if (a_XpTotal > XP_TO_LEVEL30)
{
return (short) (151.5 + sqrt( 22952.25 - (14 * (2220 - a_XpTotal)))) / 7;
}
// level 16 to 30
- return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal )))) / 3;
+ return (short) ( 29.5 + sqrt( 870.25 - (6 * ( 360 - a_XpTotal)))) / 3;
}
@@ -307,19 +308,19 @@ short cPlayer::CalcLevelFromXp(short a_XpTotal)
short cPlayer::XpForLevel(short a_Level)
{
// level 0 to 15
- if(a_Level <= 15)
+ if (a_Level <= 15)
{
return a_Level * XP_PER_LEVEL_TO15;
}
// level 30+
- if(a_Level >= 31)
+ if (a_Level >= 31)
{
- return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220 );
+ return (short) ( (3.5 * a_Level * a_Level) - (151.5 * a_Level) + 2220);
}
// level 16 to 30
- return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360 );
+ return (short) ( (1.5 * a_Level * a_Level) - (29.5 * a_Level) + 360);
}
@@ -350,7 +351,7 @@ float cPlayer::GetXpPercentage()
bool cPlayer::SetCurrentExperience(short int a_CurrentXp)
{
- if(!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp)))
+ if (!(a_CurrentXp >= 0) || (a_CurrentXp > (SHRT_MAX - m_LifetimeTotalXp)))
{
LOGWARNING("Tried to update experiece with an invalid Xp value: %d", a_CurrentXp);
return false; // oops, they gave us a dodgey number
@@ -381,10 +382,7 @@ short cPlayer::DeltaExperience(short a_Xp_delta)
m_CurrentXp += a_Xp_delta;
// Make sure they didn't subtract too much
- if (m_CurrentXp < 0)
- {
- m_CurrentXp = 0;
- }
+ m_CurrentXp = std::max<short int>(m_CurrentXp, 0);
// Update total for score calculation
if (a_Xp_delta > 0)
@@ -624,7 +622,8 @@ void cPlayer::FinishEating(void)
GetInventory().RemoveOneEquippedItem();
// if the food is mushroom soup, return a bowl to the inventory
- if( Item.m_ItemType == E_ITEM_MUSHROOM_SOUP ) {
+ if (Item.m_ItemType == E_ITEM_MUSHROOM_SOUP)
+ {
cItem emptyBowl(E_ITEM_BOWL, 1, 0, "");
GetInventory().AddItem(emptyBowl, true, true);
}
@@ -1008,7 +1007,7 @@ double cPlayer::GetEyeHeight(void) const
Vector3d cPlayer::GetEyePosition(void) const
{
- return Vector3d( GetPosX(), m_Stance, GetPosZ() );
+ return Vector3d( GetPosX(), m_Stance, GetPosZ());
}
@@ -1170,7 +1169,7 @@ void cPlayer::SetGameMode(eGameMode a_GameMode)
-void cPlayer::LoginSetGameMode( eGameMode a_GameMode )
+void cPlayer::LoginSetGameMode( eGameMode a_GameMode)
{
m_GameMode = a_GameMode;
}
@@ -1306,7 +1305,7 @@ void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
-void cPlayer::MoveTo( const Vector3d & a_NewPos )
+void cPlayer::MoveTo( const Vector3d & a_NewPos)
{
if ((a_NewPos.y < -990) && (GetPosY() > -100))
{
@@ -1329,7 +1328,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos )
Vector3d DeltaPos = a_NewPos - GetPosition();
UpdateMovementStats(DeltaPos);
- SetPosition( a_NewPos );
+ SetPosition( a_NewPos);
SetStance(a_NewPos.y + 1.62);
}
@@ -1355,11 +1354,11 @@ void cPlayer::SetVisible(bool a_bVisible)
-void cPlayer::AddToGroup( const AString & a_GroupName )
+void cPlayer::AddToGroup( const AString & a_GroupName)
{
- cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName );
- m_Groups.push_back( Group );
- LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str() );
+ cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName);
+ m_Groups.push_back( Group);
+ LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str());
ResolveGroups();
ResolvePermissions();
}
@@ -1368,28 +1367,28 @@ void cPlayer::AddToGroup( const AString & a_GroupName )
-void cPlayer::RemoveFromGroup( const AString & a_GroupName )
+void cPlayer::RemoveFromGroup( const AString & a_GroupName)
{
bool bRemoved = false;
- for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
+ for (GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr)
{
- if( (*itr)->GetName().compare(a_GroupName ) == 0 )
+ if ((*itr)->GetName().compare(a_GroupName) == 0)
{
- m_Groups.erase( itr );
+ m_Groups.erase( itr);
bRemoved = true;
break;
}
}
- if( bRemoved )
+ if (bRemoved)
{
- LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() );
+ LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str());
ResolveGroups();
ResolvePermissions();
}
else
{
- LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str() );
+ LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str());
}
}
@@ -1405,30 +1404,30 @@ bool cPlayer::HasPermission(const AString & a_Permission)
return true;
}
- AStringVector Split = StringSplit( a_Permission, "." );
+ AStringVector Split = StringSplit( a_Permission, ".");
PermissionMap Possibilities = m_ResolvedPermissions;
// Now search the namespaces
- while( Possibilities.begin() != Possibilities.end() )
+ while (Possibilities.begin() != Possibilities.end())
{
PermissionMap::iterator itr = Possibilities.begin();
- if( itr->second )
+ if (itr->second)
{
- AStringVector OtherSplit = StringSplit( itr->first, "." );
- if( OtherSplit.size() <= Split.size() )
+ AStringVector OtherSplit = StringSplit( itr->first, ".");
+ if (OtherSplit.size() <= Split.size())
{
unsigned int i;
- for( i = 0; i < OtherSplit.size(); ++i )
+ for (i = 0; i < OtherSplit.size(); ++i)
{
- if( OtherSplit[i].compare( Split[i] ) != 0 )
+ if (OtherSplit[i].compare( Split[i]) != 0)
{
- if( OtherSplit[i].compare("*") == 0 ) return true; // WildCard man!! WildCard!
+ if (OtherSplit[i].compare("*") == 0) return true; // WildCard man!! WildCard!
break;
}
}
- if( i == Split.size() ) return true;
+ if (i == Split.size()) return true;
}
}
- Possibilities.erase( itr );
+ Possibilities.erase( itr);
}
// Nothing that matched :(
@@ -1439,11 +1438,11 @@ bool cPlayer::HasPermission(const AString & a_Permission)
-bool cPlayer::IsInGroup( const AString & a_Group )
+bool cPlayer::IsInGroup( const AString & a_Group)
{
- for( GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr )
+ for (GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr)
{
- if( a_Group.compare( (*itr)->GetName().c_str() ) == 0 )
+ if (a_Group.compare( (*itr)->GetName().c_str()) == 0)
return true;
}
return false;
@@ -1458,15 +1457,15 @@ void cPlayer::ResolvePermissions()
m_ResolvedPermissions.clear(); // Start with an empty map
// Copy all player specific permissions into the resolved permissions map
- for( PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr )
+ for (PermissionMap::iterator itr = m_Permissions.begin(); itr != m_Permissions.end(); ++itr)
{
m_ResolvedPermissions[ itr->first ] = itr->second;
}
- for( GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr )
+ for (GroupList::iterator GroupItr = m_ResolvedGroups.begin(); GroupItr != m_ResolvedGroups.end(); ++GroupItr)
{
const cGroup::PermissionMap & Permissions = (*GroupItr)->GetPermissions();
- for( cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr )
+ for (cGroup::PermissionMap::const_iterator itr = Permissions.begin(); itr != Permissions.end(); ++itr)
{
m_ResolvedPermissions[ itr->first ] = itr->second;
}
@@ -1485,14 +1484,14 @@ void cPlayer::ResolveGroups()
// Get a complete resolved list of all groups the player is in
std::map< cGroup*, bool > AllGroups; // Use a map, because it's faster than iterating through a list to find duplicates
GroupList ToIterate;
- for( GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr )
+ for (GroupList::iterator GroupItr = m_Groups.begin(); GroupItr != m_Groups.end(); ++GroupItr)
{
- ToIterate.push_back( *GroupItr );
+ ToIterate.push_back( *GroupItr);
}
- while( ToIterate.begin() != ToIterate.end() )
+ while (ToIterate.begin() != ToIterate.end())
{
cGroup* CurrentGroup = *ToIterate.begin();
- if( AllGroups.find( CurrentGroup ) != AllGroups.end() )
+ if (AllGroups.find( CurrentGroup) != AllGroups.end())
{
LOGWARNING("ERROR: Player \"%s\" is in the group multiple times (\"%s\"). Please fix your settings in users.ini!",
GetName().c_str(), CurrentGroup->GetName().c_str()
@@ -1501,19 +1500,19 @@ void cPlayer::ResolveGroups()
else
{
AllGroups[ CurrentGroup ] = true;
- m_ResolvedGroups.push_back( CurrentGroup ); // Add group to resolved list
+ m_ResolvedGroups.push_back( CurrentGroup); // Add group to resolved list
const cGroup::GroupList & Inherits = CurrentGroup->GetInherits();
- for( cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr )
+ for (cGroup::GroupList::const_iterator itr = Inherits.begin(); itr != Inherits.end(); ++itr)
{
- if( AllGroups.find( *itr ) != AllGroups.end() )
+ if (AllGroups.find( *itr) != AllGroups.end())
{
- LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str() );
+ LOGERROR("ERROR: Player %s is in the same group multiple times due to inheritance (%s). FIX IT!", GetName().c_str(), (*itr)->GetName().c_str());
continue;
}
- ToIterate.push_back( *itr );
+ ToIterate.push_back( *itr);
}
}
- ToIterate.erase( ToIterate.begin() );
+ ToIterate.erase( ToIterate.begin());
}
}
@@ -1523,12 +1522,12 @@ void cPlayer::ResolveGroups()
AString cPlayer::GetColor(void) const
{
- if ( m_Color != '-' )
+ if (m_Color != '-')
{
- return cChatColor::Color + m_Color;
+ return cChatColor::Delimiter + m_Color;
}
- if ( m_Groups.size() < 1 )
+ if (m_Groups.size() < 1)
{
return cChatColor::White;
}
@@ -1915,11 +1914,11 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
StringList Permissions;
const PermissionMap& ResolvedPermissions = m_ResolvedPermissions;
- for( PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr )
+ for (PermissionMap::const_iterator itr = ResolvedPermissions.begin(); itr != ResolvedPermissions.end(); ++itr)
{
if (itr->second)
{
- Permissions.push_back( itr->first );
+ Permissions.push_back( itr->first);
}
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 7c287d41b..488884602 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -48,7 +48,7 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); };
+ virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }
/** Returns the curently equipped weapon; empty item if none */
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
@@ -117,8 +117,8 @@ public:
/** Returns true if the player is currently charging the bow */
bool IsChargingBow(void) const { return m_IsChargingBow; }
- void SetTouchGround( bool a_bTouchGround );
- inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; }
+ void SetTouchGround( bool a_bTouchGround);
+ inline void SetStance( const double a_Stance) { m_Stance = a_Stance; }
double GetEyeHeight(void) const; // tolua_export
Vector3d GetEyePosition(void) const; // tolua_export
inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export
@@ -239,15 +239,15 @@ public:
typedef std::list< std::string > StringList;
/** Adds a player to existing group or creates a new group when it doesn't exist */
- void AddToGroup( const AString & a_GroupName ); // tolua_export
+ void AddToGroup( const AString & a_GroupName); // tolua_export
/** Removes a player from the group, resolves permissions and group inheritance (case sensitive) */
- void RemoveFromGroup( const AString & a_GroupName ); // tolua_export
+ void RemoveFromGroup( const AString & a_GroupName); // tolua_export
- bool HasPermission( const AString & a_Permission ); // tolua_export
+ bool HasPermission( const AString & a_Permission); // tolua_export
const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS <<
StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS <<
- bool IsInGroup( const AString & a_Group ); // tolua_export
+ bool IsInGroup( const AString & a_Group); // tolua_export
// tolua_begin
@@ -328,7 +328,7 @@ public:
void Respawn(void); // tolua_export
- void SetVisible( bool a_bVisible ); // tolua_export
+ void SetVisible( bool a_bVisible); // tolua_export
bool IsVisible(void) const { return m_bVisible; } // tolua_export
/** Moves the player to the specified world.
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index a55c9b895..b5e81bc0c 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -146,9 +146,11 @@ public:
(a_Entity->GetUniqueID() == m_Projectile->GetCreatorUniqueID()) // Do not check whoever shot the projectile
)
{
- // TODO: Don't check creator only for the first 5 ticks
- // so that arrows stuck in ground and dug up can hurt the player
- return false;
+ // Don't check creator only for the first 5 ticks so that projectiles can collide with the creator
+ if (m_Projectile->GetTicksAlive() <= 5)
+ {
+ return false;
+ }
}
cBoundingBox EntBox(a_Entity->GetPosition(), a_Entity->GetWidth() / 2, a_Entity->GetHeight());
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index e6b05714e..0ebc32f36 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -41,7 +41,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cProjectileEntity);
+ CLASS_PROTODEF(cProjectileEntity)
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height);
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 3efb1f25d..6d874e957 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -2,11 +2,15 @@
#include "SplashPotionEntity.h"
#include "Pawn.h"
+#include "../ClientHandle.h"
+/// Converts an angle in radians into a byte representation used by the network protocol
+#define ANGLE_TO_PROTO(X) (Byte)(X * 255 / 360)
+
////////////////////////////////////////////////////////////////////////////////
// cSplashPotionEntityCallback:
@@ -29,25 +33,23 @@ public:
/** Called by cWorld::ForEachEntity(), adds the stored entity effect to the entity, if it is close enough. */
virtual bool Item(cEntity * a_Entity) override
{
- double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
- if (SplashDistance >= 20)
+ if (!a_Entity->IsPawn())
{
- // Too far away
+ // Not an entity that can take effects
return false;
}
- if (!a_Entity->IsPawn())
+
+ double SplashDistance = (a_Entity->GetPosition() - m_HitPos).Length();
+ if (SplashDistance >= 20)
{
- // Not an entity that can take effects
+ // Too far away
return false;
}
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
// TODO: better equation
double Reduction = -0.25 * SplashDistance + 1.0;
- if (Reduction < 0)
- {
- Reduction = 0;
- }
+ Reduction = std::max(Reduction, 0.0);
((cPawn *) a_Entity)->AddEntityEffect(m_EntityEffectType, m_EntityEffect.GetDuration(), m_EntityEffect.GetIntensity(), Reduction);
return false;
@@ -72,12 +74,13 @@ cSplashPotionEntity::cSplashPotionEntity(
const Vector3d & a_Speed,
cEntityEffect::eType a_EntityEffectType,
cEntityEffect a_EntityEffect,
- int a_PotionParticleType
+ int a_PotionColor
) :
super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
m_EntityEffectType(a_EntityEffectType),
m_EntityEffect(a_EntityEffect),
- m_PotionParticleType(a_PotionParticleType)
+ m_PotionColor(a_PotionColor),
+ m_DestroyTimer(-1)
{
SetSpeed(a_Speed);
}
@@ -89,7 +92,7 @@ cSplashPotionEntity::cSplashPotionEntity(
void cSplashPotionEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
Splash(a_HitPos);
- Destroy();
+ m_DestroyTimer = 2;
}
@@ -100,7 +103,7 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_
{
a_EntityHit.TakeDamage(dtRangedAttack, this, 0, 1);
Splash(a_HitPos);
- Destroy(true);
+ m_DestroyTimer = 5;
}
@@ -112,7 +115,17 @@ void cSplashPotionEntity::Splash(const Vector3d & a_HitPos)
cSplashPotionCallback Callback(a_HitPos, m_EntityEffectType, m_EntityEffect);
m_World->ForEachEntity(Callback);
- m_World->BroadcastSoundParticleEffect(2002, (int)a_HitPos.x, (int)a_HitPos.y, (int)a_HitPos.z, m_PotionParticleType);
+ m_World->BroadcastSoundParticleEffect(2002, (int)floor(a_HitPos.x), (int)floor(a_HitPos.y), (int)floor(a_HitPos.z), m_PotionColor);
+}
+
+
+
+
+
+void cSplashPotionEntity::SpawnOn(cClientHandle & a_Client)
+{
+ a_Client.SendSpawnObject(*this, 73, m_PotionColor, ANGLE_TO_PROTO(GetYaw()), ANGLE_TO_PROTO(GetPitch()));
+ a_Client.SendEntityMetadata(*this);
}
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 2c78b55d2..dd14ea82f 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -23,7 +23,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cSplashPotionEntity);
+ CLASS_PROTODEF(cSplashPotionEntity)
cSplashPotionEntity(
cEntity * a_Creator,
@@ -31,29 +31,51 @@ public:
const Vector3d & a_Speed,
cEntityEffect::eType a_EntityEffectType,
cEntityEffect a_EntityEffect,
- int a_PotionParticleType
+ int a_PotionColor
);
- cEntityEffect::eType GetEntityEffectType (void) const { return m_EntityEffectType; }
- cEntityEffect GetEntityEffect (void) const { return m_EntityEffect; }
- int GetPotionParticleType(void) const { return m_PotionParticleType; }
+ cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
+ cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
+ int GetPotionColor(void) const { return m_PotionColor; }
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
- void SetPotionParticleType(int a_PotionParticleType) { m_PotionParticleType = a_PotionParticleType; }
+ void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
protected:
cEntityEffect::eType m_EntityEffectType;
cEntityEffect m_EntityEffect;
- int m_PotionParticleType;
+ int m_PotionColor;
// 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);
+ }
+ }
/** Splashes the potion, fires its particle effects and sounds
@param a_HitPos The position where the potion will splash */
void Splash(const Vector3d & a_HitPos);
+
+ virtual void SpawnOn(cClientHandle & a_Client) override;
+
+private:
+ /** Time in ticks to wait for the hit animation to begin before destroying */
+ int m_DestroyTimer;
} ; // tolua_export
diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp
index fd9a4e7ac..53af446cc 100644
--- a/src/Entities/TNTEntity.cpp
+++ b/src/Entities/TNTEntity.cpp
@@ -42,7 +42,7 @@ void cTNTEntity::Explode(void)
{
m_FuseTicks = 0;
Destroy(true);
- LOGD("BOOM at {%f,%f,%f}", GetPosX(), GetPosY(), GetPosZ());
+ LOGD("BOOM at {%f, %f, %f}", GetPosX(), GetPosY(), GetPosZ());
m_World->DoExplosionAt(4.0, GetPosX() + 0.49, GetPosY() + 0.49, GetPosZ() + 0.49, true, esPrimedTNT, this);
}
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index df61b14f5..48503cf76 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -14,7 +14,7 @@ class cTNTEntity :
public:
// tolua_end
- CLASS_PROTODEF(cTNTEntity);
+ CLASS_PROTODEF(cTNTEntity)
cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80);
cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80);
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index f93731256..a0b7d5340 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownEggEntity);
+ CLASS_PROTODEF(cThrownEggEntity)
cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index 549d8a3eb..436450013 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownEnderPearlEntity);
+ CLASS_PROTODEF(cThrownEnderPearlEntity)
cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index 6f3efdd7e..8d195ced1 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -21,7 +21,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cThrownSnowballEntity);
+ CLASS_PROTODEF(cThrownSnowballEntity)
cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
index ebc1550e3..c59acd807 100644
--- a/src/Entities/WitherSkullEntity.h
+++ b/src/Entities/WitherSkullEntity.h
@@ -22,7 +22,7 @@ public:
// tolua_end
- CLASS_PROTODEF(cWitherSkullEntity);
+ CLASS_PROTODEF(cWitherSkullEntity)
cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);