diff --git a/dependencies/config/release/dev.prc b/dependencies/config/release/dev.prc index d4c572e3..129cb96e 100644 --- a/dependencies/config/release/dev.prc +++ b/dependencies/config/release/dev.prc @@ -31,7 +31,7 @@ want-checkers #t want-house-types #t # Chat: -want-whitelist #f +want-whitelist #t # Optional: want-jor-el-cam #f diff --git a/otp/avatar/DistributedPlayer.py b/otp/avatar/DistributedPlayer.py index bf8a5099..c1ef6b57 100755 --- a/otp/avatar/DistributedPlayer.py +++ b/otp/avatar/DistributedPlayer.py @@ -5,21 +5,18 @@ import string import time from otp.ai.MagicWordGlobal import * -from otp.avatar import Avatar, PlayerBase -from otp.avatar import DistributedAvatar +from otp.avatar import Avatar, PlayerBase, DistributedAvatar from otp.avatar.Avatar import teleportNotify -from otp.chat import ChatGarbler -from otp.chat import TalkAssistant +from otp.chat import ChatGarbler, TalkAssistant from otp.distributed.TelemetryLimited import TelemetryLimited -from otp.otpbase import OTPGlobals -from otp.otpbase import OTPLocalizer +from otp.otpbase import OTPGlobals, OTPLocalizer from otp.speedchat import SCDecoders from toontown.chat.ChatGlobals import * from toontown.chat.WhisperPopup import WhisperPopup class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBase, TelemetryLimited): TeleportFailureTimeout = 60.0 - chatGarbler = ChatGarbler.ChatGarbler() + chatGarbler = ChatGarbler.ChatGarbler({'default': OTPLocalizer.ChatGarblerDefault}) def __init__(self, cr): try: diff --git a/otp/avatar/LocalAvatar.py b/otp/avatar/LocalAvatar.py index 3dbfaa4b..4dc06c91 100755 --- a/otp/avatar/LocalAvatar.py +++ b/otp/avatar/LocalAvatar.py @@ -54,7 +54,6 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis self.customMessages = [] self.chatMgr = chatMgr base.talkAssistant = talkAssistant - self.garbleChat = 1 self.teleportAllowed = 1 self.lockedDown = 0 self.isPageUp = 0 diff --git a/otp/chat/ChatGarbler.py b/otp/chat/ChatGarbler.py index fe380857..608217aa 100755 --- a/otp/chat/ChatGarbler.py +++ b/otp/chat/ChatGarbler.py @@ -1,29 +1,24 @@ -import string import random -from otp.otpbase import OTPLocalizer class ChatGarbler: + + def __init__(self, messages): + self.messages = messages - def garble(self, avatar, message): + def garble(self, avatar, message, isRandom=False): newMessage = '' - numWords = random.randint(1, 7) - wordlist = OTPLocalizer.ChatGarblerDefault + + if avatar.style: + avatarType = avatar.style.getType() + wordList = self.messages[avatarType if avatarType in self.messages else 'default'] + + numWords = random.randint(1, 7) if isRandom else 1 + for i in xrange(1, numWords + 1): - wordIndex = random.randint(0, len(wordlist) - 1) - newMessage = newMessage + wordlist[wordIndex] + wordIndex = random.randint(0, len(wordList) - 1) + newMessage = newMessage + wordList[wordIndex] + if i < numWords: newMessage = newMessage + ' ' - return newMessage - - def garbleSingle(self, avatar, message): - newMessage = '' - numWords = 1 - wordlist = OTPLocalizer.ChatGarblerDefault - for i in xrange(1, numWords + 1): - wordIndex = random.randint(0, len(wordlist) - 1) - newMessage = newMessage + wordlist[wordIndex] - if i < numWords: - newMessage = newMessage + ' ' - - return newMessage + return newMessage \ No newline at end of file diff --git a/toontown/chat/ToonChatGarbler.py b/toontown/chat/ToonChatGarbler.py index 8f7b163b..c47806ca 100755 --- a/toontown/chat/ToonChatGarbler.py +++ b/toontown/chat/ToonChatGarbler.py @@ -1,49 +1,16 @@ -import string -import random -from toontown.toonbase import TTLocalizer -from otp.otpbase import OTPLocalizer from otp.chat import ChatGarbler +from toontown.toonbase import TTLocalizer class ToonChatGarbler(ChatGarbler.ChatGarbler): - animalSounds = {'dog': TTLocalizer.ChatGarblerDog, - 'cat': TTLocalizer.ChatGarblerCat, - 'mouse': TTLocalizer.ChatGarblerMouse, - 'horse': TTLocalizer.ChatGarblerHorse, - 'rabbit': TTLocalizer.ChatGarblerRabbit, - 'duck': TTLocalizer.ChatGarblerDuck, - 'monkey': TTLocalizer.ChatGarblerMonkey, - 'bear': TTLocalizer.ChatGarblerBear, - 'pig': TTLocalizer.ChatGarblerPig, - 'default': OTPLocalizer.ChatGarblerDefault} - def garble(self, toon, message): - newMessage = '' - animalType = toon.getStyle().getType() - if animalType in ToonChatGarbler.animalSounds: - wordlist = ToonChatGarbler.animalSounds[animalType] - else: - wordlist = ToonChatGarbler.animalSounds['default'] - numWords = random.randint(1, 7) - for i in xrange(1, numWords + 1): - wordIndex = random.randint(0, len(wordlist) - 1) - newMessage = newMessage + wordlist[wordIndex] - if i < numWords: - newMessage = newMessage + ' ' - - return newMessage - - def garbleSingle(self, toon, message): - newMessage = '' - animalType = toon.getStyle().getType() - if animalType in ToonChatGarbler.animalSounds: - wordlist = ToonChatGarbler.animalSounds[animalType] - else: - wordlist = ToonChatGarbler.animalSounds['default'] - numWords = 1 - for i in xrange(1, numWords + 1): - wordIndex = random.randint(0, len(wordlist) - 1) - newMessage = newMessage + wordlist[wordIndex] - if i < numWords: - newMessage = newMessage + ' ' - - return newMessage + def __init__(self): + self.messages = {'dog': TTLocalizer.ChatGarblerDog, + 'cat': TTLocalizer.ChatGarblerCat, + 'mouse': TTLocalizer.ChatGarblerMouse, + 'horse': TTLocalizer.ChatGarblerHorse, + 'rabbit': TTLocalizer.ChatGarblerRabbit, + 'duck': TTLocalizer.ChatGarblerDuck, + 'monkey': TTLocalizer.ChatGarblerMonkey, + 'bear': TTLocalizer.ChatGarblerBear, + 'pig': TTLocalizer.ChatGarblerPig, + 'default': TTLocalizer.ChatGarblerDefault} \ No newline at end of file diff --git a/toontown/friends/FriendHandle.py b/toontown/friends/FriendHandle.py index a92abe1f..6dfa2ac4 100755 --- a/toontown/friends/FriendHandle.py +++ b/toontown/friends/FriendHandle.py @@ -81,7 +81,7 @@ class FriendHandle: if word == '': newwords.append(word) elif word[0] == '\x07': - newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garbleSingle(self, word) + '\x02') + newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garble(self, word) + '\x02') scrubbed = 1 elif base.whiteList.isWord(word): newwords.append(word) @@ -99,7 +99,7 @@ class FriendHandle: if word == '': newwords.append(word) elif word[0] == '\x07': - newwords.append('\x01WLRed\x01' + self.chatGarbler.garbleSingle(self, word) + '\x02') + newwords.append('\x01WLRed\x01' + self.chatGarbler.garble(self, word) + '\x02') elif base.whiteList.isWord(word): newwords.append(word) else: diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index a5f6d3a1..c98a4dc5 100755 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -2402,7 +2402,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute if word == '': newwords.append(word) elif word[0] == '\x07' or len(word) > 1 and word[0] == '.' and word[1] == '\x07': - newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garbleSingle(self, word) + '\x02') + newwords.append('\x01WLDisplay\x01' + self.chatGarbler.garble(self, word) + '\x02') scrubbed = 1 elif not self.whiteListEnabled or base.whiteList.isWord(word): newwords.append(word) @@ -2428,7 +2428,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute if word == '': newwords.append(word) elif word[0] == '\x07': - newwords.append('\x01WLRed\x01' + self.chatGarbler.garbleSingle(self, word) + '\x02') + newwords.append('\x01WLRed\x01' + self.chatGarbler.garble(self, word) + '\x02') elif not self.whiteListEnabled or base.whiteList.isWord(word): newwords.append(word) else: