summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-03-09 19:02:30 +0100
committerTycho <work.tycho+git@gmail.com>2014-03-09 19:02:30 +0100
commitb5e33c5424c0b148a7076bb0f3019cfb0ef9c824 (patch)
treedabb3041abd9b8513570111310903992254d8063 /src/ClientHandle.cpp
parentFix IsThread destructor (diff)
parentFixed #778 - stack overflow.com (diff)
downloadcuberite-b5e33c5424c0b148a7076bb0f3019cfb0ef9c824.tar
cuberite-b5e33c5424c0b148a7076bb0f3019cfb0ef9c824.tar.gz
cuberite-b5e33c5424c0b148a7076bb0f3019cfb0ef9c824.tar.bz2
cuberite-b5e33c5424c0b148a7076bb0f3019cfb0ef9c824.tar.lz
cuberite-b5e33c5424c0b148a7076bb0f3019cfb0ef9c824.tar.xz
cuberite-b5e33c5424c0b148a7076bb0f3019cfb0ef9c824.tar.zst
cuberite-b5e33c5424c0b148a7076bb0f3019cfb0ef9c824.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r--src/ClientHandle.cpp71
1 files changed, 43 insertions, 28 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 53c859721..b08c029c0 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -555,12 +555,25 @@ void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString
}
else if (a_Channel == "REGISTER")
{
+ if (HasPluginChannel(a_Channel))
+ {
+ SendPluginMessage("UNREGISTER", a_Channel);
+ return; // Can't register again if already taken - kinda defeats the point of plugin messaging!
+ }
+
RegisterPluginChannels(BreakApartPluginChannels(a_Message));
}
else if (a_Channel == "UNREGISTER")
{
UnregisterPluginChannels(BreakApartPluginChannels(a_Message));
}
+ else if (!HasPluginChannel(a_Channel))
+ {
+ // Ignore if client sent something but didn't register the channel first
+ LOGD("Player %s sent a plugin message on channel \"%s\", but didn't REGISTER it first", GetUsername().c_str(), a_Channel.c_str());
+ SendPluginMessage("UNREGISTER", a_Channel);
+ return;
+ }
cPluginManager::Get()->CallHookPluginMessage(*this, a_Channel, a_Message);
}
@@ -1453,7 +1466,7 @@ bool cClientHandle::HandleHandshake(const AString & a_Username)
-void cClientHandle::HandleEntityAction(int a_EntityID, char a_ActionID)
+void cClientHandle::HandleEntityCrouch(int a_EntityID, bool a_IsCrouching)
{
if (a_EntityID != m_Player->GetUniqueID())
{
@@ -1461,35 +1474,37 @@ void cClientHandle::HandleEntityAction(int a_EntityID, char a_ActionID)
return;
}
- switch (a_ActionID)
+ m_Player->SetCrouch(a_IsCrouching);
+}
+
+
+
+
+
+void cClientHandle::HandleEntityLeaveBed(int a_EntityID)
+{
+ if (a_EntityID != m_Player->GetUniqueID())
{
- case 1: // Crouch
- {
- m_Player->SetCrouch(true);
- break;
- }
- case 2: // Uncrouch
- {
- m_Player->SetCrouch(false);
- break;
- }
- case 3: // Leave bed
- {
- m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, 2);
- break;
- }
- case 4: // Start sprinting
- {
- m_Player->SetSprint(true);
- break;
- }
- case 5: // Stop sprinting
- {
- m_Player->SetSprint(false);
- SendPlayerMaxSpeed();
- break;
- }
+ // We should only receive entity actions from the entity that is performing the action
+ return;
+ }
+
+ m_Player->GetWorld()->BroadcastEntityAnimation(*m_Player, 2);
+}
+
+
+
+
+
+void cClientHandle::HandleEntitySprinting(int a_EntityID, bool a_IsSprinting)
+{
+ if (a_EntityID != m_Player->GetUniqueID())
+ {
+ // We should only receive entity actions from the entity that is performing the action
+ return;
}
+
+ m_Player->SetSprint(a_IsSprinting);
}