summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Boat.cpp10
-rw-r--r--src/Entities/ExpOrb.h1
-rw-r--r--src/Entities/Floater.h4
-rw-r--r--src/Entities/Pickup.h7
-rw-r--r--src/Entities/Player.cpp41
-rw-r--r--src/Entities/Player.h12
6 files changed, 53 insertions, 22 deletions
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index 184aeeeeb..67df201ce 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -89,8 +89,14 @@ void cBoat::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
BroadcastMovementUpdate();
- SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed.
- if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())))
+ SetSpeed(GetSpeed() * 0.97); // Slowly decrease the speed
+
+ if ((POSY_TOINT < 0) || (POSY_TOINT > cChunkDef::Height))
+ {
+ return;
+ }
+
+ if (IsBlockWater(m_World->GetBlock(POSX_TOINT, POSY_TOINT, POSZ_TOINT)))
{
SetSpeedY(1);
}
diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h
index a062eedd3..47d86922c 100644
--- a/src/Entities/ExpOrb.h
+++ b/src/Entities/ExpOrb.h
@@ -13,6 +13,7 @@ class cExpOrb :
typedef cExpOrb super;
public:
+ 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/Floater.h b/src/Entities/Floater.h
index 162b74e75..865d6dc50 100644
--- a/src/Entities/Floater.h
+++ b/src/Entities/Floater.h
@@ -14,8 +14,10 @@ class cFloater :
typedef cFloater super;
public:
-
//tolua_end
+
+ CLASS_PROTODEF(cFloater);
+
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
virtual void SpawnOn(cClientHandle & a_Client) override;
diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h
index d39eda298..c273567d1 100644
--- a/src/Entities/Pickup.h
+++ b/src/Entities/Pickup.h
@@ -18,15 +18,16 @@ class cPlayer;
class cPickup :
public cEntity
{
- // tolua_end
typedef cEntity super;
public:
+ // tolua_end
+
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); // tolua_export
+ 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);
- cItem & GetItem(void) {return m_Item; } // tolua_export
+ cItem & GetItem(void) {return m_Item; } // tolua_export
const cItem & GetItem(void) const {return m_Item; }
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index bea8def9e..286d43cf6 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -3,7 +3,6 @@
#include "Player.h"
#include "../Server.h"
-#include "../ClientHandle.h"
#include "../UI/Window.h"
#include "../UI/WindowOwner.h"
#include "../World.h"
@@ -130,9 +129,13 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
cPlayer::~cPlayer(void)
{
- cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this);
+ if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this))
+ {
+ cRoot::Get()->BroadcastChatLeave(Printf("%s has left the game", GetName().c_str()));
+ LOGINFO("Player %s has left the game.", GetName().c_str());
+ }
- LOGD("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID());
+ LOGD("Deleting cPlayer \"%s\" at %p, ID %d", GetName().c_str(), this, GetUniqueID());
// Notify the server that the player is being destroyed
cRoot::Get()->GetServer()->PlayerDestroying(this);
@@ -841,18 +844,18 @@ void cPlayer::KilledBy(cEntity * a_Killer)
if (a_Killer == NULL)
{
- GetWorld()->BroadcastChat(Printf("%s[DEATH] %s%s was killed by environmental damage", cChatColor::Red.c_str(), cChatColor::White.c_str(), GetName().c_str()));
+ GetWorld()->BroadcastChatDeath(Printf("%s was killed by environmental damage", GetName().c_str()));
}
else if (a_Killer->IsPlayer())
{
- GetWorld()->BroadcastChat(Printf("%s[DEATH] %s%s was killed by %s", cChatColor::Red.c_str(), cChatColor::White.c_str(), GetName().c_str(), ((cPlayer *)a_Killer)->GetName().c_str()));
+ GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), ((cPlayer *)a_Killer)->GetName().c_str()));
}
else
{
AString KillerClass = a_Killer->GetClass();
KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch")
- GetWorld()->BroadcastChat(Printf("%s[DEATH] %s%s was killed by a %s", cChatColor::Red.c_str(), cChatColor::White.c_str(), GetName().c_str(), KillerClass.c_str()));
+ GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
}
class cIncrementCounterCB
@@ -1117,15 +1120,6 @@ void cPlayer::SetIP(const AString & a_IP)
-void cPlayer::SendMessage(const AString & a_Message)
-{
- m_ClientHandle->SendChat(a_Message);
-}
-
-
-
-
-
void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
{
SetPosition( a_PosX, a_PosY, a_PosZ );
@@ -1741,6 +1735,23 @@ void cPlayer::UseEquippedItem(void)
+void cPlayer::TickBurning(cChunk & a_Chunk)
+{
+ // Don't burn in creative and stop burning in creative if necessary
+ if (!IsGameModeCreative())
+ {
+ super::TickBurning(a_Chunk);
+ }
+ else if (IsOnFire())
+ {
+ m_TicksLeftBurning = 0;
+ OnFinishedBurning();
+ }
+}
+
+
+
+
void cPlayer::HandleFood(void)
{
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 5c56c927a..7db9544cb 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -5,6 +5,7 @@
#include "../Inventory.h"
#include "../Defines.h"
#include "../World.h"
+#include "../ClientHandle.h"
@@ -195,7 +196,13 @@ public:
cClientHandle * GetClientHandle(void) const { return m_ClientHandle; }
- void SendMessage(const AString & a_Message);
+ void SendMessage (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtCustom); }
+ void SendMessageInfo (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtInformation); }
+ void SendMessageFailure (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
+ void SendMessageSuccess (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtSuccess); }
+ void SendMessageWarning (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtWarning); }
+ void SendMessageFatal (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
+ void SendMessagePrivateMsg(const AString & a_Message, const AString & a_Sender) { m_ClientHandle->SendChat(a_Message, mtPrivateMessage, a_Sender); }
const AString & GetName(void) const { return m_PlayerName; }
void SetName(const AString & a_Name) { m_PlayerName = a_Name; }
@@ -467,6 +474,9 @@ protected:
/// Filters out damage for creative mode/friendly fire
virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
+
+ /** Stops players from burning in creative mode */
+ virtual void TickBurning(cChunk & a_Chunk) override;
/// Called in each tick to handle food-related processing
void HandleFood(void);