general: fix chat & classic char crashes
This commit is contained in:
parent
86191622cf
commit
9b6676ebc7
5 changed files with 8 additions and 9 deletions
|
@ -1,4 +1,3 @@
|
|||
import string
|
||||
import sys
|
||||
from direct.showbase import DirectObject
|
||||
from otp.otpbase import OTPLocalizer
|
||||
|
@ -209,7 +208,7 @@ class TalkAssistant(DirectObject.DirectObject):
|
|||
return 0
|
||||
elif len(message) == 0:
|
||||
return 0
|
||||
elif string.find(message, ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
|
||||
elif message.find(ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
|
|
@ -14,8 +14,8 @@ class WhiteList:
|
|||
self.numWords = len(self.words)
|
||||
|
||||
def cleanText(self, text):
|
||||
text = text.strip('.,?!')
|
||||
text = text.lower()
|
||||
text = text.decode('utf-8').strip('.,?!')
|
||||
text = text.lower().encode('utf-8')
|
||||
return text
|
||||
|
||||
def isWord(self, text):
|
||||
|
|
|
@ -187,7 +187,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
|||
flag = 1
|
||||
|
||||
for word in words:
|
||||
if word == '' or self.whiteList.isWord(word) or not base.cr.whiteListChatEnabled:
|
||||
if word == '' or self.whiteList.isWord(word.encode('utf-8')) or not base.cr.whiteListChatEnabled:
|
||||
newwords.append(word)
|
||||
else:
|
||||
if self.checkBeforeSend:
|
||||
|
@ -201,7 +201,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
|||
|
||||
if not strict:
|
||||
lastword = words[-1]
|
||||
if lastword == '' or self.whiteList.isPrefix(lastword) or not base.cr.whiteListChatEnabled:
|
||||
if lastword == '' or self.whiteList.isPrefix(lastword.encode('utf-8')) or not base.cr.whiteListChatEnabled:
|
||||
newwords[-1] = lastword
|
||||
elif flag:
|
||||
newwords[-1] = '\x01WLDisplay\x01' + lastword + '\x02'
|
||||
|
|
|
@ -14,7 +14,6 @@ from toontown.toonbase.TTLocalizer import Donald, DonaldDock, WesternPluto, Plut
|
|||
from toontown.effects import DustCloud
|
||||
from . import CCharChatter
|
||||
from . import CCharPaths
|
||||
import string
|
||||
import copy
|
||||
|
||||
class DistributedCCharBase(DistributedChar.DistributedChar):
|
||||
|
@ -180,7 +179,7 @@ class DistributedCCharBase(DistributedChar.DistributedChar):
|
|||
if '%' in str:
|
||||
str = copy.deepcopy(str)
|
||||
avName = avatar.getName()
|
||||
str = string.replace(str, '%', avName)
|
||||
str = str.replace('%', avName)
|
||||
track = Sequence()
|
||||
if category != CCharChatter.GOODBYE:
|
||||
curHpr = self.getHpr()
|
||||
|
|
|
@ -5,6 +5,7 @@ from otp.avatar.DistributedPlayerAI import DistributedPlayerAI
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
import random
|
||||
import functools
|
||||
|
||||
class DistributedCCharBaseAI(DistributedAvatarAI.DistributedAvatarAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedCCharBaseAI')
|
||||
|
@ -149,7 +150,7 @@ class DistributedCCharBaseAI(DistributedAvatarAI.DistributedAvatarAI):
|
|||
else:
|
||||
return 1
|
||||
|
||||
self.nearbyAvatars.sort(nAv_compare)
|
||||
self.nearbyAvatars.sort(key=functools.cmp_to_key(nAv_compare))
|
||||
|
||||
def getNearbyAvatars(self):
|
||||
return self.nearbyAvatars
|
||||
|
|
Loading…
Reference in a new issue