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
|
import sys
|
||||||
from direct.showbase import DirectObject
|
from direct.showbase import DirectObject
|
||||||
from otp.otpbase import OTPLocalizer
|
from otp.otpbase import OTPLocalizer
|
||||||
|
@ -209,7 +208,7 @@ class TalkAssistant(DirectObject.DirectObject):
|
||||||
return 0
|
return 0
|
||||||
elif len(message) == 0:
|
elif len(message) == 0:
|
||||||
return 0
|
return 0
|
||||||
elif string.find(message, ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
|
elif message.find(ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -14,8 +14,8 @@ class WhiteList:
|
||||||
self.numWords = len(self.words)
|
self.numWords = len(self.words)
|
||||||
|
|
||||||
def cleanText(self, text):
|
def cleanText(self, text):
|
||||||
text = text.strip('.,?!')
|
text = text.decode('utf-8').strip('.,?!')
|
||||||
text = text.lower()
|
text = text.lower().encode('utf-8')
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def isWord(self, text):
|
def isWord(self, text):
|
||||||
|
|
|
@ -187,7 +187,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
flag = 1
|
flag = 1
|
||||||
|
|
||||||
for word in words:
|
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)
|
newwords.append(word)
|
||||||
else:
|
else:
|
||||||
if self.checkBeforeSend:
|
if self.checkBeforeSend:
|
||||||
|
@ -201,7 +201,7 @@ class TTChatInputWhiteList(ChatInputWhiteListFrame):
|
||||||
|
|
||||||
if not strict:
|
if not strict:
|
||||||
lastword = words[-1]
|
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
|
newwords[-1] = lastword
|
||||||
elif flag:
|
elif flag:
|
||||||
newwords[-1] = '\x01WLDisplay\x01' + lastword + '\x02'
|
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 toontown.effects import DustCloud
|
||||||
from . import CCharChatter
|
from . import CCharChatter
|
||||||
from . import CCharPaths
|
from . import CCharPaths
|
||||||
import string
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
class DistributedCCharBase(DistributedChar.DistributedChar):
|
class DistributedCCharBase(DistributedChar.DistributedChar):
|
||||||
|
@ -180,7 +179,7 @@ class DistributedCCharBase(DistributedChar.DistributedChar):
|
||||||
if '%' in str:
|
if '%' in str:
|
||||||
str = copy.deepcopy(str)
|
str = copy.deepcopy(str)
|
||||||
avName = avatar.getName()
|
avName = avatar.getName()
|
||||||
str = string.replace(str, '%', avName)
|
str = str.replace('%', avName)
|
||||||
track = Sequence()
|
track = Sequence()
|
||||||
if category != CCharChatter.GOODBYE:
|
if category != CCharChatter.GOODBYE:
|
||||||
curHpr = self.getHpr()
|
curHpr = self.getHpr()
|
||||||
|
|
|
@ -5,6 +5,7 @@ from otp.avatar.DistributedPlayerAI import DistributedPlayerAI
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
import random
|
import random
|
||||||
|
import functools
|
||||||
|
|
||||||
class DistributedCCharBaseAI(DistributedAvatarAI.DistributedAvatarAI):
|
class DistributedCCharBaseAI(DistributedAvatarAI.DistributedAvatarAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedCCharBaseAI')
|
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedCCharBaseAI')
|
||||||
|
@ -149,7 +150,7 @@ class DistributedCCharBaseAI(DistributedAvatarAI.DistributedAvatarAI):
|
||||||
else:
|
else:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
self.nearbyAvatars.sort(nAv_compare)
|
self.nearbyAvatars.sort(key=functools.cmp_to_key(nAv_compare))
|
||||||
|
|
||||||
def getNearbyAvatars(self):
|
def getNearbyAvatars(self):
|
||||||
return self.nearbyAvatars
|
return self.nearbyAvatars
|
||||||
|
|
Loading…
Reference in a new issue