From b5e898a608cfa0b872828db842e31ec2d624e598 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 3 Feb 2014 21:12:44 +0000 Subject: Server now handles join messages also * Revised as well hook documentation --- src/Entities/Player.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 8c37fdc8d..a1c942c20 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -130,7 +130,13 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) cPlayer::~cPlayer(void) { - cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this); + if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this)) + { + AString DisconnectMessage; + AppendPrintf(DisconnectMessage, "%s[LEAVE] %s%s has left the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), GetClientHandle()->GetUsername().c_str()); + cRoot::Get()->BroadcastChat(DisconnectMessage); + LOGINFO("Player %s has left the game.", GetClientHandle()->GetUsername().c_str()); + } LOGD("Deleting cPlayer \"%s\" at %p, ID %d", m_PlayerName.c_str(), this, GetUniqueID()); -- cgit v1.2.3 From 6de8c09fe0044f310397ef94457277f7426470e0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 3 Feb 2014 22:24:22 +0000 Subject: Fixed a crash bug --- src/Entities/Player.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index d649cacf2..70c881091 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -133,12 +133,12 @@ cPlayer::~cPlayer(void) if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this)) { AString DisconnectMessage; - AppendPrintf(DisconnectMessage, "%s[LEAVE] %s%s has left the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), GetClientHandle()->GetUsername().c_str()); + AppendPrintf(DisconnectMessage, "%s[LEAVE] %s%s has left the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), GetName().c_str()); cRoot::Get()->BroadcastChat(DisconnectMessage); - LOGINFO("Player %s has left the game.", GetClientHandle()->GetUsername().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); -- cgit v1.2.3 From ea2ce1595f51c141342991378c372529f26434c6 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 4 Feb 2014 23:27:13 +0000 Subject: Fixed annoying creative on fire bug --- src/Entities/Player.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 70c881091..c0466fa66 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1760,6 +1760,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) { -- cgit v1.2.3 From aa8b46e94714f261bfe451897b7ef23934e764eb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 5 Feb 2014 23:24:16 +0000 Subject: Server internally uses new functions --- src/Entities/Player.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index c0466fa66..385e28c28 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -132,9 +132,7 @@ cPlayer::~cPlayer(void) { if (!cRoot::Get()->GetPluginManager()->CallHookPlayerDestroyed(*this)) { - AString DisconnectMessage; - AppendPrintf(DisconnectMessage, "%s[LEAVE] %s%s has left the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), GetName().c_str()); - cRoot::Get()->BroadcastChat(DisconnectMessage); + cRoot::Get()->BroadcastChatLeave(Printf("%s has left the game", GetName().c_str())); LOGINFO("Player %s has left the game.", GetName().c_str()); } @@ -847,18 +845,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 -- cgit v1.2.3 From 88a64ec40df87f21a89de43fe8bb78f10ee7eeb7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 7 Feb 2014 18:58:52 +0000 Subject: Improved chat messaging functions * Moved string manipulation into cClientHandle and therefore... + Added configuration option for prefixes. * Cleaned up code. * Updated documentation for API. --- src/Entities/Player.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 385e28c28..eef6b8e69 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" @@ -1121,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 ); -- cgit v1.2.3