From c513032a4928a5365f67151ab8289ffba91bcb3f Mon Sep 17 00:00:00 2001 From: John Date: Sat, 30 May 2015 22:02:08 +0300 Subject: [PATCH] Speedchat Plus toggle! --- otp/avatar/Avatar.py | 2 +- otp/avatar/DistributedPlayer.py | 4 +++- otp/chat/ChatGarbler.py | 11 +++-------- otp/chat/WhiteList.py | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/otp/avatar/Avatar.py b/otp/avatar/Avatar.py index 1cfaea32..ba22c2b7 100755 --- a/otp/avatar/Avatar.py +++ b/otp/avatar/Avatar.py @@ -148,7 +148,7 @@ class Avatar(Actor, ShadowCaster): self.understandable = 1 self.setPlayerType(NametagGlobals.CCNormal) elif settings['trueFriends'] and base.cr.getFriendFlags(self.doId) & OTPGlobals.FriendChat: - self.understandable = 1 + self.understandable = 2 self.setPlayerType(NametagGlobals.CCNormal) elif settings['speedchatPlus']: self.understandable = 1 diff --git a/otp/avatar/DistributedPlayer.py b/otp/avatar/DistributedPlayer.py index ec764059..8f1a5635 100755 --- a/otp/avatar/DistributedPlayer.py +++ b/otp/avatar/DistributedPlayer.py @@ -186,7 +186,9 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa return if base.localAvatar.isIgnored(self.doId): return - if base.whiteList: + if not self.understandable: + chat = self.chatGarbler.garble(self, chat) + elif base.whiteList and self.understandable < 2: chat = base.whiteList.processThroughAll(chat, self, self.chatGarbler) self.displayTalk(chat) diff --git a/otp/chat/ChatGarbler.py b/otp/chat/ChatGarbler.py index 6cfdf370..1e4ebf7b 100755 --- a/otp/chat/ChatGarbler.py +++ b/otp/chat/ChatGarbler.py @@ -5,19 +5,14 @@ class ChatGarbler: def __init__(self, messages): self.messages = messages - def garble(self, avatar, message, type=0): + def garble(self, avatar, message): newMessage = '' if avatar.style: avatarType = avatar.style.getType() wordList = self.messages[avatarType if avatarType in self.messages else 'default'] - if type == 0: - numWords = 1 - elif type == 1: - numWords = random.randint(1, 7) - elif type == 2: - numWords = len(message.split(' ')) + numWords = len(message.split(' ')) for i in xrange(1, numWords + 1): wordIndex = random.randint(0, len(wordList) - 1) @@ -26,4 +21,4 @@ class ChatGarbler: if i < numWords: newMessage = newMessage + ' ' - return newMessage \ No newline at end of file + return '\x01WLDisplay\x01%s\x02' % newMessage \ No newline at end of file diff --git a/otp/chat/WhiteList.py b/otp/chat/WhiteList.py index 4cdc337f..f1b57e73 100755 --- a/otp/chat/WhiteList.py +++ b/otp/chat/WhiteList.py @@ -19,7 +19,7 @@ class WhiteList: return i != self.numWords and self.words[i].startswith(text) def getReplacement(self, text, av=None, garbler=None): - return '\x01%s\x01%s\x02' % ('WLDisplay' if garbler else 'WLRed', text if not garbler else garbler.garble(av, text, 2)) + return '\x01WLRed\x01%s\x02' % text if not garbler else garbler.garble(av, text) def processText(self, text, av=None, garbler=None): if (not self.words) or text.startswith('~'):