From 8d2ebf8e19e1556d256f75678d2272bb6739030f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 6 Mar 2014 20:06:53 +0000 Subject: [PATCH] Slight plugin messaging changes - Clients are not allowed to register duplicate channels - Clients are not allowed to use channels that were not registered --- src/ClientHandle.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 870568cdf..c677862eb 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); }