From 5e0d895680d69976a4ade0f49e93c0747e3b730c Mon Sep 17 00:00:00 2001 From: John Cote Date: Mon, 30 Dec 2019 20:21:20 -0500 Subject: [PATCH] general: fix a bunch of crashes --- otp/friends/FriendSecret.py | 3 +-- toontown/distributed/DelayDeletable.py | 2 +- toontown/friends/FriendsListPanel.py | 15 ++++++++------- toontown/quest/Quests.py | 12 ++++++------ toontown/shtiker/DirectNewsFrame.py | 7 ++++--- toontown/toon/DistributedNPCSpecialQuestGiver.py | 6 +++--- toontown/toon/DistributedNPCToon.py | 6 +++--- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/otp/friends/FriendSecret.py b/otp/friends/FriendSecret.py index ffb4917..295f906 100644 --- a/otp/friends/FriendSecret.py +++ b/otp/friends/FriendSecret.py @@ -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 diff --git a/toontown/distributed/DelayDeletable.py b/toontown/distributed/DelayDeletable.py index b4aca0e..bd52769 100644 --- a/toontown/distributed/DelayDeletable.py +++ b/toontown/distributed/DelayDeletable.py @@ -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 diff --git a/toontown/friends/FriendsListPanel.py b/toontown/friends/FriendsListPanel.py index 1f34dd1..c90ab66 100644 --- a/toontown/friends/FriendsListPanel.py +++ b/toontown/friends/FriendsListPanel.py @@ -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) diff --git a/toontown/quest/Quests.py b/toontown/quest/Quests.py index 7a842bb..749b025 100644 --- a/toontown/quest/Quests.py +++ b/toontown/quest/Quests.py @@ -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 diff --git a/toontown/shtiker/DirectNewsFrame.py b/toontown/shtiker/DirectNewsFrame.py index 1e474b7..83349f2 100644 --- a/toontown/shtiker/DirectNewsFrame.py +++ b/toontown/shtiker/DirectNewsFrame.py @@ -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]) diff --git a/toontown/toon/DistributedNPCSpecialQuestGiver.py b/toontown/toon/DistributedNPCSpecialQuestGiver.py index 35e3a53..d7d78d5 100644 --- a/toontown/toon/DistributedNPCSpecialQuestGiver.py +++ b/toontown/toon/DistributedNPCSpecialQuestGiver.py @@ -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) diff --git a/toontown/toon/DistributedNPCToon.py b/toontown/toon/DistributedNPCToon.py index 848ff4a..89fb23d 100644 --- a/toontown/toon/DistributedNPCToon.py +++ b/toontown/toon/DistributedNPCToon.py @@ -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)