From 28da462e529d195c7c1d7791b0bed1184a905191 Mon Sep 17 00:00:00 2001 From: John Cote Date: Mon, 30 Dec 2019 19:17:24 -0500 Subject: [PATCH] general: loads to playground --- otp/chat/WhiteList.py | 2 +- otp/distributed/TelemetryLimited.py | 2 +- otp/login/AstronLoginManagerUD.py | 2 +- toontown/chat/TTWhiteList.py | 6 +++--- toontown/distributed/HoodMgr.py | 3 +-- toontown/parties/CalendarGuiDay.py | 3 ++- toontown/shtiker/DirectNewsFrame.py | 6 +++--- toontown/shtiker/TrackPage.py | 2 +- toontown/toon/DistributedToonAI.py | 2 +- toontown/toon/Toon.py | 3 ++- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/otp/chat/WhiteList.py b/otp/chat/WhiteList.py index 14f9b76..4d1f82b 100644 --- a/otp/chat/WhiteList.py +++ b/otp/chat/WhiteList.py @@ -8,7 +8,7 @@ class WhiteList: def __init__(self, wordlist): self.words = [] for line in wordlist: - self.words.append(line.strip('\n\r').lower()) + self.words.append(line.strip(b'\n\r').lower()) self.words.sort() self.numWords = len(self.words) diff --git a/otp/distributed/TelemetryLimited.py b/otp/distributed/TelemetryLimited.py index aa7918b..af65ef0 100644 --- a/otp/distributed/TelemetryLimited.py +++ b/otp/distributed/TelemetryLimited.py @@ -4,7 +4,7 @@ class TelemetryLimited: Sng = SerialNumGen() def __init__(self): - self._telemetryLimiterId = next(self.Sng) + self._telemetryLimiterId = self.Sng.next() self._limits = set() def getTelemetryLimiterId(self): diff --git a/otp/login/AstronLoginManagerUD.py b/otp/login/AstronLoginManagerUD.py index a3881df..7571034 100644 --- a/otp/login/AstronLoginManagerUD.py +++ b/otp/login/AstronLoginManagerUD.py @@ -607,7 +607,7 @@ class LoadAvatarOperation(AvatarOperation): cleanupDatagram.addUint32(self.avId) datagram = PyDatagram() datagram.addServerHeader(channel, self.loginManager.air.ourChannel, CLIENTAGENT_ADD_POST_REMOVE) - datagram.addString(cleanupDatagram.getMessage()) + datagram.appendData(cleanupDatagram.getMessage()) self.loginManager.air.send(datagram) self.loginManager.air.sendActivate(self.avId, 0, 0, self.loginManager.air.dclassesByName['DistributedToonUD']) diff --git a/toontown/chat/TTWhiteList.py b/toontown/chat/TTWhiteList.py index 8027172..df81ffe 100644 --- a/toontown/chat/TTWhiteList.py +++ b/toontown/chat/TTWhiteList.py @@ -28,7 +28,7 @@ class TTWhiteList(WhiteList, DistributedObject.DistributedObject): if not found: self.notify.info("Couldn't find whitelist data file!") data = vfs.readFile(filename, 1) - lines = data.split('\n') + lines = data.split(b'\n') WhiteList.__init__(self, lines) self.redownloadWhitelist() self.defaultWord = TTLocalizer.ChatGarblerDefault[0] @@ -145,10 +145,10 @@ class TTWhiteList(WhiteList, DistributedObject.DistributedObject): if not localFilename.exists(): return data = vfs.readFile(localFilename, 1) - lines = data.split('\n') + lines = data.split(b'\n') self.words = [] for line in lines: - self.words.append(line.strip('\n\r').lower()) + self.words.append(line.strip(b'\n\r').lower()) self.words.sort() self.numWords = len(self.words) diff --git a/toontown/distributed/HoodMgr.py b/toontown/distributed/HoodMgr.py index 985a14d..dce28f5 100644 --- a/toontown/distributed/HoodMgr.py +++ b/toontown/distributed/HoodMgr.py @@ -2,7 +2,6 @@ from pandac.PandaModules import * from direct.showbase import DirectObject from direct.directnotify import DirectNotifyGlobal from toontown.launcher import DownloadForceAcknowledge -import string import random from toontown.toonbase import ToontownGlobals from toontown.hood import ZoneUtil @@ -926,7 +925,7 @@ class HoodMgr(DirectObject.DirectObject): return tunnelOriginList def extractGroupName(self, groupFullName): - return string.split(groupFullName, ':', 1)[0] + return groupFullName.split(':', 1)[0] def makeLinkTunnelName(self, hoodId, currentZone): return '**/toph_' + self.getNameFromId(hoodId) + '_' + str(currentZone) diff --git a/toontown/parties/CalendarGuiDay.py b/toontown/parties/CalendarGuiDay.py index 5c02b6b..05dae26 100644 --- a/toontown/parties/CalendarGuiDay.py +++ b/toontown/parties/CalendarGuiDay.py @@ -1,4 +1,5 @@ import datetime +import functools import time from pandac.PandaModules import TextNode, Vec3, Vec4, PlaneNode, Plane, Point3 from direct.gui.DirectGui import DirectFrame, DirectLabel, DirectButton, DirectScrolledList, DGG @@ -287,7 +288,7 @@ class CalendarGuiDay(DirectFrame): else: return 1 - self.timedEvents.sort(cmp=timedEventCompare) + self.timedEvents.sort(key=functools.cmp_to_key(timedEventCompare)) for timedEvent in self.timedEvents: if isinstance(timedEvent[1], PartyInfo): self.addPartyToScrollList(timedEvent[1]) diff --git a/toontown/shtiker/DirectNewsFrame.py b/toontown/shtiker/DirectNewsFrame.py index 0c89a9c..1e474b7 100644 --- a/toontown/shtiker/DirectNewsFrame.py +++ b/toontown/shtiker/DirectNewsFrame.py @@ -273,7 +273,7 @@ class DirectNewsFrame(DirectObject.DirectObject): return self.downloadNextFile(task) def downloadNextFile(self, task): - while self.nextNewsFile < len(self.newsFiles) and 'aaver' in self.newsFiles[self.nextNewsFile]: + while self.nextNewsFile < len(self.newsFiles) and b'aaver' in self.newsFiles[self.nextNewsFile]: self.nextNewsFile += 1 if self.nextNewsFile >= len(self.newsFiles): @@ -294,7 +294,7 @@ class DirectNewsFrame(DirectObject.DirectObject): self.percentDownloaded = float(self.nextNewsFile) / float(len(self.newsFiles)) self.filename = self.newsFiles[self.nextNewsFile] self.nextNewsFile += 1 - self.url = self.newsUrl + self.filename + self.url = self.newsUrl + self.filename.decode('utf-8') localFilename = Filename(self.newsDir, self.filename) self.notify.info('testing for %s' % localFilename.getFullpath()) doc = DocumentSpec(self.url) @@ -322,7 +322,7 @@ class DirectNewsFrame(DirectObject.DirectObject): del self.newsCache[self.filename] self.saveNewsCache() return self.downloadNextFile(task) - self.notify.info('downloaded %s' % self.filename) + self.notify.info('downloaded %s' % self.filename.decode('utf-8')) size = self.ch.getFileSize() doc = self.ch.getDocumentSpec() date = '' diff --git a/toontown/shtiker/TrackPage.py b/toontown/shtiker/TrackPage.py index 8e05946..712de50 100644 --- a/toontown/shtiker/TrackPage.py +++ b/toontown/shtiker/TrackPage.py @@ -110,7 +110,7 @@ class TrackPage(ShtikerPage.ShtikerPage): for index in range(1, MAX_FRAMES + 1): frame = self.trackFrames[index - 1] col = (index - 1) % 6 - row = (index - 1) / 6 + row = int((index - 1) / 6) frame.setPos(colPos[col], 0, rowPos[row]) frame.setScale(0.39) diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index 5755865..14c8d8d 100644 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -2348,7 +2348,7 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo nextTime = nextGiftTime if nextGiftTime == None: nextGiftTime = nextTime - if nextGiftTime < nextTime: + if nextGiftTime is not None and nextTime is not None and nextGiftTime < nextTime: nextTime = nextGiftTime existingDuration = None checkTaskList = taskMgr.getTasksNamed(taskName) diff --git a/toontown/toon/Toon.py b/toontown/toon/Toon.py index dfb8fea..48316a0 100644 --- a/toontown/toon/Toon.py +++ b/toontown/toon/Toon.py @@ -27,6 +27,7 @@ from toontown.distributed import DelayDelete from . import AccessoryGlobals import types import importlib +import functools def teleportDebug(requestStatus, msg, onlyIfToAv = True): if teleportNotify.getDebug(): @@ -1296,7 +1297,7 @@ class Toon(Avatar.Avatar, ToonHead): nodePathList.append((node, offset)) if nodePathList: - nodePathList.sort(lambda x, y: cmp(x[0].getDistance(self), y[0].getDistance(self))) + nodePathList.sort(key=functools.cmp_to_key(lambda x, y: cmp(x[0].getDistance(self), y[0].getDistance(self)))) if len(nodePathList) >= 2: if self.randGen.random() < 0.9: chosenNodePath = nodePathList[0]