general: fix a bunch of crashes

This commit is contained in:
John Cote 2019-12-30 20:21:20 -05:00
parent 9b6676ebc7
commit 5e0d895680
7 changed files with 26 additions and 25 deletions

View file

@ -3,7 +3,6 @@ from libotp import *
from direct.gui.DirectGui import *
from direct.directnotify import DirectNotifyGlobal
from direct.fsm import StateData
import string
from otp.otpbase import OTPLocalizer
from otp.otpbase import OTPGlobals
from otp.uberdog import RejectCode
@ -449,7 +448,7 @@ class FriendSecret(DirectFrame, StateData.StateData):
def __enterSecret(self, secret):
self.enterSecret.set('')
secret = string.strip(secret)
secret = secret.strip()
if not secret:
self.exit()
return

View file

@ -13,7 +13,7 @@ class DelayDeletable:
self.notify.error('cannot acquire DelayDelete "%s" on %s because it is in state %s' % (name, self.__class__.__name__, ESNum2Str[self.activeState]))
if self.getDelayDeleteCount() == 0:
self.cr._addDelayDeletedDO(self)
token = next(DelayDeletable.DelayDeleteSerialGen)
token = DelayDeletable.DelayDeleteSerialGen.next()
self._token2delayDeleteName[token] = name
return token

View file

@ -7,6 +7,7 @@ from toontown.friends import ToontownFriendSecret
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import TTLocalizer
from otp.otpbase import OTPGlobals
import functools
FLPPets = 1
FLPOnline = 2
FLPAll = 3
@ -574,13 +575,13 @@ class FriendsListPanel(DirectFrame, StateData.StateData):
friendButton.destroy()
del self.friends[friendPair]
newFriends.sort(compareFriends)
petFriends.sort(compareFriends)
freeChatOneRef.sort(compareFriends)
speedChatOneRef.sort(compareFriends)
freeChatDouble.sort(compareFriends)
speedChatDouble.sort(compareFriends)
offlineFriends.sort(compareFriends)
newFriends.sort(key=functools.cmp_to_key(compareFriends))
petFriends.sort(key=functools.cmp_to_key(compareFriends))
freeChatOneRef.sort(key=functools.cmp_to_key(compareFriends))
speedChatOneRef.sort(key=functools.cmp_to_key(compareFriends))
freeChatDouble.sort(key=functools.cmp_to_key(compareFriends))
speedChatDouble.sort(key=functools.cmp_to_key(compareFriends))
offlineFriends.sort(key=functools.cmp_to_key(compareFriends))
for friendPair in newFriends:
if friendPair not in self.friends:
friendButton = self.makeFriendButton(friendPair)

View file

@ -5,7 +5,7 @@ from toontown.battle import SuitBattleGlobals
from toontown.coghq import CogDisguiseGlobals
import random
from toontown.toon import NPCToons
import copy, string
import copy
from toontown.hood import ZoneUtil
from direct.directnotify import DirectNotifyGlobal
from toontown.toonbase import TTLocalizer
@ -18164,7 +18164,7 @@ def getNpcLocationDialog(fromNpcId, toNpcId):
def fillInQuestNames(text, avName = None, fromNpcId = None, toNpcId = None):
text = copy.deepcopy(text)
if avName != None:
text = string.replace(text, '_avName_', avName)
text = text.replace('_avName_', avName)
if toNpcId:
if toNpcId == ToonHQ:
toNpcName = TTLocalizer.QuestsHQOfficerFillin
@ -18179,10 +18179,10 @@ def fillInQuestNames(text, avName = None, fromNpcId = None, toNpcId = None):
else:
toNpcName = str(NPCToons.getNPCName(toNpcId))
where, buildingName, streetDesc = getNpcLocationDialog(fromNpcId, toNpcId)
text = string.replace(text, '_toNpcName_', toNpcName)
text = string.replace(text, '_where_', where)
text = string.replace(text, '_buildingName_', buildingName)
text = string.replace(text, '_streetDesc_', streetDesc)
text = text.replace('_toNpcName_', toNpcName)
text = text.replace('_where_', where)
text = text.replace('_buildingName_', buildingName)
text = text.replace('_streetDesc_', streetDesc)
return text

View file

@ -1,6 +1,7 @@
import os
import time
import datetime
import functools
from pandac.PandaModules import Filename, DSearchPath, TextNode
from pandac.PandaModules import HTTPClient, Ramfile, DocumentSpec
from direct.showbase import DirectObject
@ -123,7 +124,7 @@ class DirectNewsFrame(DirectObject.DirectObject):
return fileA.getFilename().compareTo(fileB.getFilename())
homeFileNames = list(homeFileNames)
homeFileNames.sort(cmp=fileCmp)
homeFileNames.sort(key=functools.cmp_to_key(fileCmp))
self.notify.debug('returned homeFileNames=%s' % homeFileNames)
return homeFileNames
@ -391,8 +392,8 @@ class DirectNewsFrame(DirectObject.DirectObject):
majorVer = 1
minorVer = 0
for entry in self.newsIndexEntries:
if 'aaver' in entry and dateStr in entry:
parts = entry.split('_')
if b'aaver' in entry and dateStr.encode('utf-8') in entry:
parts = entry.split(b'_')
if len(parts) > 5:
try:
majorVer = int(parts[5])

View file

@ -132,7 +132,7 @@ class DistributedNPCSpecialQuestGiver(DistributedNPCToonBase):
return
if mode == NPCToons.QUEST_MOVIE_REJECT:
rejectString = Quests.chooseQuestDialogReject()
rejectString = Quests.fillInQuestNames(rejectString, avName=av.name)
rejectString = Quests.fillInQuestNames(rejectString, avName=av._name)
self.setChatAbsolute(rejectString, CFSpeech | CFTimeout)
if isLocalToon:
base.localAvatar.posCamera(0, 0)
@ -140,7 +140,7 @@ class DistributedNPCSpecialQuestGiver(DistributedNPCToonBase):
return
if mode == NPCToons.QUEST_MOVIE_TIER_NOT_DONE:
rejectString = Quests.chooseQuestDialogTierNotDone()
rejectString = Quests.fillInQuestNames(rejectString, avName=av.name)
rejectString = Quests.fillInQuestNames(rejectString, avName=av._name)
self.setChatAbsolute(rejectString, CFSpeech | CFTimeout)
if isLocalToon:
base.localAvatar.posCamera(0, 0)
@ -226,7 +226,7 @@ class DistributedNPCSpecialQuestGiver(DistributedNPCToonBase):
self.acceptOnce('chooseTrack', self.sendChooseTrack)
self.trackChoiceGui = TrackChoiceGui.TrackChoiceGui(tracks, ChoiceTimeout)
return
fullString = Quests.fillInQuestNames(fullString, avName=av.name, fromNpcId=npcId, toNpcId=toNpcId)
fullString = Quests.fillInQuestNames(fullString, avName=av._name, fromNpcId=npcId, toNpcId=toNpcId)
self.acceptOnce(self.uniqueName('doneChatPage'), self.finishMovie, extraArgs=[av, isLocalToon])
self.clearChat()
self.setPageChat(avId, 0, fullString, 1)

View file

@ -121,7 +121,7 @@ class DistributedNPCToon(DistributedNPCToonBase):
return
if mode == NPCToons.QUEST_MOVIE_REJECT:
rejectString = Quests.chooseQuestDialogReject()
rejectString = Quests.fillInQuestNames(rejectString, avName=av.name)
rejectString = Quests.fillInQuestNames(rejectString, avName=av._name)
self.setChatAbsolute(rejectString, CFSpeech | CFTimeout)
if isLocalToon:
base.localAvatar.posCamera(0, 0)
@ -129,7 +129,7 @@ class DistributedNPCToon(DistributedNPCToonBase):
return
if mode == NPCToons.QUEST_MOVIE_TIER_NOT_DONE:
rejectString = Quests.chooseQuestDialogTierNotDone()
rejectString = Quests.fillInQuestNames(rejectString, avName=av.name)
rejectString = Quests.fillInQuestNames(rejectString, avName=av._name)
self.setChatAbsolute(rejectString, CFSpeech | CFTimeout)
if isLocalToon:
base.localAvatar.posCamera(0, 0)
@ -215,7 +215,7 @@ class DistributedNPCToon(DistributedNPCToonBase):
self.acceptOnce('chooseTrack', self.sendChooseTrack)
self.trackChoiceGui = TrackChoiceGui.TrackChoiceGui(tracks, ChoiceTimeout)
return
fullString = Quests.fillInQuestNames(fullString, avName=av.name, fromNpcId=npcId, toNpcId=toNpcId)
fullString = Quests.fillInQuestNames(fullString, avName=av._name, fromNpcId=npcId, toNpcId=toNpcId)
self.acceptOnce(self.uniqueName('doneChatPage'), self.finishMovie, extraArgs=[av, isLocalToon])
self.clearChat()
self.setPageChat(avId, 0, fullString, 1)