From 9f5616195512e69c145dee25f10673696d44d681 Mon Sep 17 00:00:00 2001 From: John Cote Date: Thu, 28 Nov 2019 00:17:22 -0500 Subject: [PATCH] general: some cleanup --- otp/distributed/AccountAI.py | 1 + otp/distributed/AccountUD.py | 1 + otp/distributed/AstronAccount.py | 1 + otp/distributed/AstronAccountAI.py | 1 + otp/distributed/AstronAccountUD.py | 1 + otp/distributed/CentralLoggerAI.py | 1 + otp/distributed/CentralLoggerUD.py | 1 + otp/distributed/DistributedDirectoryAI.py | 1 + otp/distributed/DistributedDistrictAI.py | 1 + otp/distributed/DistributedDistrictUD.py | 1 + otp/distributed/DistributedTestObjectAI.py | 1 + otp/distributed/OTPInternalRepository.py | 4 +- otp/distributed/ObjectServerAI.py | 1 + otp/distributed/ObjectServerUD.py | 1 + otp/login/AstronLoginManager.py | 2 + otp/login/AstronLoginManagerUD.py | 72 ++++++++++++++-------- otp/login/AstronLoginScreen.py | 5 +- toontown/uberdog/ToontownUDRepository.py | 5 +- toontown/uberdog/UDStart.py | 2 + 19 files changed, 76 insertions(+), 27 deletions(-) diff --git a/otp/distributed/AccountAI.py b/otp/distributed/AccountAI.py index 1e31caf..ae85c98 100644 --- a/otp/distributed/AccountAI.py +++ b/otp/distributed/AccountAI.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class AccountAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('AccountAI') diff --git a/otp/distributed/AccountUD.py b/otp/distributed/AccountUD.py index d7de24e..7bdb0ea 100644 --- a/otp/distributed/AccountUD.py +++ b/otp/distributed/AccountUD.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectUD import DistributedObjectUD + class AccountUD(DistributedObjectUD): notify = DirectNotifyGlobal.directNotify.newCategory('AccountUD') diff --git a/otp/distributed/AstronAccount.py b/otp/distributed/AstronAccount.py index d984fec..de66e16 100644 --- a/otp/distributed/AstronAccount.py +++ b/otp/distributed/AstronAccount.py @@ -1,5 +1,6 @@ from direct.distributed import DistributedObject + class AstronAccount(DistributedObject.DistributedObject): def __init__(self, cr): diff --git a/otp/distributed/AstronAccountAI.py b/otp/distributed/AstronAccountAI.py index e5dc069..0248634 100644 --- a/otp/distributed/AstronAccountAI.py +++ b/otp/distributed/AstronAccountAI.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class AstronAccountAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('AstronAccountAI') diff --git a/otp/distributed/AstronAccountUD.py b/otp/distributed/AstronAccountUD.py index 94e8539..598ee93 100644 --- a/otp/distributed/AstronAccountUD.py +++ b/otp/distributed/AstronAccountUD.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectUD import DistributedObjectUD + class AstronAccountUD(DistributedObjectUD): notify = DirectNotifyGlobal.directNotify.newCategory('AstronAccountUD') diff --git a/otp/distributed/CentralLoggerAI.py b/otp/distributed/CentralLoggerAI.py index f37d0aa..5e0cc10 100644 --- a/otp/distributed/CentralLoggerAI.py +++ b/otp/distributed/CentralLoggerAI.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class CentralLoggerAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('CentralLoggerAI') diff --git a/otp/distributed/CentralLoggerUD.py b/otp/distributed/CentralLoggerUD.py index 088a917..a80076d 100644 --- a/otp/distributed/CentralLoggerUD.py +++ b/otp/distributed/CentralLoggerUD.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectUD import DistributedObjectUD + class CentralLoggerUD(DistributedObjectUD): notify = DirectNotifyGlobal.directNotify.newCategory('CentralLoggerUD') diff --git a/otp/distributed/DistributedDirectoryAI.py b/otp/distributed/DistributedDirectoryAI.py index 0150be9..22b3563 100644 --- a/otp/distributed/DistributedDirectoryAI.py +++ b/otp/distributed/DistributedDirectoryAI.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class DistributedDirectoryAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedDirectoryAI') diff --git a/otp/distributed/DistributedDistrictAI.py b/otp/distributed/DistributedDistrictAI.py index d3a50ad..faedb7f 100644 --- a/otp/distributed/DistributedDistrictAI.py +++ b/otp/distributed/DistributedDistrictAI.py @@ -1,6 +1,7 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class DistributedDistrictAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedDistrictAI') diff --git a/otp/distributed/DistributedDistrictUD.py b/otp/distributed/DistributedDistrictUD.py index fac1fdb..0d2dca7 100644 --- a/otp/distributed/DistributedDistrictUD.py +++ b/otp/distributed/DistributedDistrictUD.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectUD import DistributedObjectUD + class DistributedDistrictUD(DistributedObjectUD): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedDistrictUD') diff --git a/otp/distributed/DistributedTestObjectAI.py b/otp/distributed/DistributedTestObjectAI.py index caf0577..a009fbc 100644 --- a/otp/distributed/DistributedTestObjectAI.py +++ b/otp/distributed/DistributedTestObjectAI.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class DistributedTestObjectAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedTestObjectAI') diff --git a/otp/distributed/OTPInternalRepository.py b/otp/distributed/OTPInternalRepository.py index 1f1b574..3dd121d 100644 --- a/otp/distributed/OTPInternalRepository.py +++ b/otp/distributed/OTPInternalRepository.py @@ -1,6 +1,7 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.AstronInternalRepository import AstronInternalRepository + # TODO: Remove Astron dependence. class OTPInternalRepository(AstronInternalRepository): @@ -8,7 +9,8 @@ class OTPInternalRepository(AstronInternalRepository): dbId = 4003 def __init__(self, baseChannel, serverId, dcFileNames, dcSuffix, connectMethod, threadedNet): - AstronInternalRepository.__init__(self, baseChannel, serverId=serverId, dcFileNames=dcFileNames, dcSuffix=dcSuffix, connectMethod=connectMethod, threadedNet=threadedNet) + AstronInternalRepository.__init__(self, baseChannel, serverId=serverId, dcFileNames=dcFileNames, + dcSuffix=dcSuffix, connectMethod=connectMethod, threadedNet=threadedNet) def handleConnected(self): AstronInternalRepository.handleConnected(self) diff --git a/otp/distributed/ObjectServerAI.py b/otp/distributed/ObjectServerAI.py index bbd9ce1..84c8dea 100644 --- a/otp/distributed/ObjectServerAI.py +++ b/otp/distributed/ObjectServerAI.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class ObjectServerAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('ObjectServerAI') diff --git a/otp/distributed/ObjectServerUD.py b/otp/distributed/ObjectServerUD.py index ae8fb9f..43aa61c 100644 --- a/otp/distributed/ObjectServerUD.py +++ b/otp/distributed/ObjectServerUD.py @@ -1,5 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectUD import DistributedObjectUD + class ObjectServerUD(DistributedObjectUD): notify = DirectNotifyGlobal.directNotify.newCategory('ObjectServerUD') diff --git a/otp/login/AstronLoginManager.py b/otp/login/AstronLoginManager.py index fb06589..1a71fb3 100644 --- a/otp/login/AstronLoginManager.py +++ b/otp/login/AstronLoginManager.py @@ -4,8 +4,10 @@ from datetime import datetime from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectGlobal import DistributedObjectGlobal + from otp.uberdog.AccountDetailRecord import AccountDetailRecord + class AstronLoginManager(DistributedObjectGlobal): notify = DirectNotifyGlobal.directNotify.newCategory('AstronLoginManager') diff --git a/otp/login/AstronLoginManagerUD.py b/otp/login/AstronLoginManagerUD.py index 202307a..5f5133f 100644 --- a/otp/login/AstronLoginManagerUD.py +++ b/otp/login/AstronLoginManagerUD.py @@ -2,15 +2,17 @@ import anydbm import dumbdbm import json import sys -from datetime import datetime import time +from datetime import datetime from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD from direct.distributed.PyDatagram import * + +from toontown.makeatoon.NameGenerator import NameGenerator from toontown.toon.ToonDNA import ToonDNA from toontown.toonbase import TTLocalizer -from toontown.makeatoon.NameGenerator import NameGenerator + class AccountDB: """ @@ -89,7 +91,8 @@ class LoginOperation: self.__handleCreateAccount() def __handleRetrieveAccount(self): - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.accountId, self.__handleAccountRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.accountId, + self.__handleAccountRetrieved) def __handleAccountRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']: @@ -107,7 +110,9 @@ class LoginOperation: 'LAST_LOGIN': time.ctime(), 'ACCOUNT_ID': str(self.databaseId)} - self.loginManager.air.dbInterface.createObject(self.loginManager.air.dbId, self.loginManager.air.dclassesByName['AstronAccountUD'], self.account, self.__handleAccountCreated) + self.loginManager.air.dbInterface.createObject(self.loginManager.air.dbId, + self.loginManager.air.dclassesByName['AstronAccountUD'], + self.account, self.__handleAccountCreated) def __handleAccountCreated(self, accountId): if not accountId: @@ -130,7 +135,8 @@ class LoginOperation: def __handleSetAccount(self): # if somebody's already logged into this account, disconnect them datagram = PyDatagram() - datagram.addServerHeader(self.loginManager.GetAccountConnectionChannel(self.accountId), self.loginManager.air.ourChannel, CLIENTAGENT_EJECT) + datagram.addServerHeader(self.loginManager.GetAccountConnectionChannel(self.accountId), + self.loginManager.air.ourChannel, CLIENTAGENT_EJECT) datagram.addUint16(100) datagram.addString('This account has been logged in elsewhere.') self.loginManager.air.send(datagram) @@ -144,7 +150,7 @@ class LoginOperation: # set sender channel to represent account affiliation datagram = PyDatagram() datagram.addServerHeader(self.sender, self.loginManager.air.ourChannel, CLIENTAGENT_SET_CLIENT_ID) - datagram.addChannel(self.accountId << 32) # accountId is in high 32 bits, 0 in low (no avatar). + datagram.addChannel(self.accountId << 32) # accountId is in high 32 bits, 0 in low (no avatar). self.loginManager.air.send(datagram) # set client state to established, thus un-sandboxing the sender @@ -202,7 +208,8 @@ class GetAvatarsOperation: self.avatarFields = None def start(self): - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, self.__handleAccountRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, + self.__handleAccountRetrieved) def __handleAccountRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']: @@ -221,6 +228,7 @@ class GetAvatarsOperation: for avId in self.avList: if avId: self.pendingAvatars.add(avId) + def response(dclass, fields, avId=avId): if dclass != self.loginManager.air.dclassesByName['DistributedToonUD']: # mayonnaise @@ -289,7 +297,8 @@ class CreateAvatarOperation: self.__handleRetrieveAccount() def __handleRetrieveAccount(self): - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, self.__handleAccountRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, + self.__handleAccountRetrieved) def __handleAccountRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']: @@ -318,7 +327,9 @@ class CreateAvatarOperation: 'setDNAString': (self.avDNA,), 'setDISLid': (self.sender,)} - self.loginManager.air.dbInterface.createObject(self.loginManager.air.dbId, self.loginManager.air.dclassesByName['DistributedToonUD'], toonFields, self.__handleToonCreated) + self.loginManager.air.dbInterface.createObject(self.loginManager.air.dbId, + self.loginManager.air.dclassesByName['DistributedToonUD'], + toonFields, self.__handleToonCreated) def __handleToonCreated(self, avId): if not avId: @@ -330,10 +341,11 @@ class CreateAvatarOperation: def __handleStoreAvatar(self): self.avList[self.avPosition] = self.avId - self.loginManager.air.dbInterface.updateObject(self.loginManager.air.dbId, self.sender, self.loginManager.air.dclassesByName['AstronAccountUD'], - {'ACCOUNT_AV_SET': self.avList}, - {'ACCOUNT_AV_SET': self.account['ACCOUNT_AV_SET']}, - self.__handleAvatarStored) + self.loginManager.air.dbInterface.updateObject(self.loginManager.air.dbId, self.sender, + self.loginManager.air.dclassesByName['AstronAccountUD'], + {'ACCOUNT_AV_SET': self.avList}, + {'ACCOUNT_AV_SET': self.account['ACCOUNT_AV_SET']}, + self.__handleAvatarStored) def __handleAvatarStored(self, fields): if fields: @@ -362,7 +374,8 @@ class SetNamePatternOperation: self.__handleRetrieveAccount() def __handleRetrieveAccount(self): - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, self.__handleAccountRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, + self.__handleAccountRetrieved) def __handleAccountRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']: @@ -381,7 +394,8 @@ class SetNamePatternOperation: # It's you! return - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.avId, self.__handleAvatarRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.avId, + self.__handleAvatarRetrieved) def __handleAvatarRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['DistributedToonUD']: @@ -413,7 +427,8 @@ class SetNamePatternOperation: name = ' '.join(parts) - self.loginManager.air.dbInterface.updateObject(self.loginManager.air.dbId, self.avId, self.loginManager.air.dclassesByName['DistributedToonUD'], + self.loginManager.air.dbInterface.updateObject(self.loginManager.air.dbId, self.avId, + self.loginManager.air.dclassesByName['DistributedToonUD'], {'WishNameState': ('LOCKED',), 'WishName': ('',), 'setName': (name,)}) @@ -441,7 +456,8 @@ class SetNameTypedOperation: self.__handleJudgeName() def __handleRetrieveAccount(self): - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, self.__handleAccountRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, + self.__handleAccountRetrieved) def __handleAccountRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']: @@ -460,7 +476,8 @@ class SetNameTypedOperation: # Hahaha return - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.avId, self.__handleAvatarRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.avId, + self.__handleAvatarRetrieved) def __handleAvatarRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['DistributedToonUD']: @@ -500,7 +517,8 @@ class AcknowledgeNameOperation: self.__handleRetrieveAccount() def __handleRetrieveAccount(self): - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, self.__handleAccountRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, + self.__handleAccountRetrieved) def __handleAccountRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']: @@ -518,7 +536,8 @@ class AcknowledgeNameOperation: # welp return - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.avId, self.__handleAvatarRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.avId, + self.__handleAvatarRetrieved) def __handleAvatarRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['DistributedToonUD']: @@ -564,7 +583,8 @@ class RemoveAvatarOperation: def start(self, avId): self.avId = avId - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, self.__handleAccountRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, + self.__handleAccountRetrieved) def __handleAccountRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']: @@ -593,7 +613,8 @@ class RemoveAvatarOperation: {'setSlot%sToonId' % index: [0], 'setSlot%sItems' % index: [[]]}) - self.loginManager.air.dbInterface.updateObject(self.loginManager.air.dbId, self.sender, self.loginManager.air.dclassesByName['AstronAccountUD'], + self.loginManager.air.dbInterface.updateObject(self.loginManager.air.dbId, self.sender, + self.loginManager.air.dclassesByName['AstronAccountUD'], {'ACCOUNT_AV_SET': self.avList, 'ACCOUNT_AV_SET_DEL': avatarsRemoved}, {'ACCOUNT_AV_SET': self.account['ACCOUNT_AV_SET'], @@ -613,6 +634,7 @@ class RemoveAvatarOperation: for avId in self.avList: if avId: self.pendingAvatars.add(avId) + def response(dclass, fields, avId=avId): if dclass != self.loginManager.air.dclassesByName['DistributedToonUD']: # mayonnaise @@ -669,7 +691,8 @@ class LoadAvatarOperation: self.__handleRetrieveAccount() def __handleRetrieveAccount(self): - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, self.__handleAccountRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.sender, + self.__handleAccountRetrieved) def __handleAccountRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['AstronAccountUD']: @@ -686,7 +709,8 @@ class LoadAvatarOperation: if self.avId not in self.avList: return - self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.avId, self.__handleAvatarRetrieved) + self.loginManager.air.dbInterface.queryObject(self.loginManager.air.dbId, self.avId, + self.__handleAvatarRetrieved) def __handleAvatarRetrieved(self, dclass, fields): if dclass != self.loginManager.air.dclassesByName['DistributedToonUD']: diff --git a/otp/login/AstronLoginScreen.py b/otp/login/AstronLoginScreen.py index f663f43..0eaa95a 100644 --- a/otp/login/AstronLoginScreen.py +++ b/otp/login/AstronLoginScreen.py @@ -1,8 +1,11 @@ from direct.directnotify import DirectNotifyGlobal -from otp.login.LoginScreen import LoginScreen from direct.distributed.MsgTypes import * +from otp.login.LoginScreen import LoginScreen + + class AstronLoginScreen(LoginScreen): + notify = DirectNotifyGlobal.directNotify.newCategory('AstronLoginScreen') def handleWaitForLoginResponse(self, msgType, di): if msgType == CLIENT_HELLO_RESP: diff --git a/toontown/uberdog/ToontownUDRepository.py b/toontown/uberdog/ToontownUDRepository.py index fdfa746..fddb242 100644 --- a/toontown/uberdog/ToontownUDRepository.py +++ b/toontown/uberdog/ToontownUDRepository.py @@ -1,11 +1,14 @@ from direct.directnotify import DirectNotifyGlobal -from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository + from otp.distributed.DistributedDirectoryAI import DistributedDirectoryAI from otp.distributed.OtpDoGlobals import * +from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository + # TODO: Remove Astron dependence. class ToontownUDRepository(ToontownInternalRepository): + notify = DirectNotifyGlobal.directNotify.newCategory('ToontownUDRepository') def __init__(self, baseChannel, serverId): ToontownInternalRepository.__init__(self, baseChannel, serverId, dcSuffix='UD') diff --git a/toontown/uberdog/UDStart.py b/toontown/uberdog/UDStart.py index e2a4ea4..7f3a86e 100644 --- a/toontown/uberdog/UDStart.py +++ b/toontown/uberdog/UDStart.py @@ -1,9 +1,11 @@ import __builtin__ + class game: name = 'uberDog' process = 'server' + __builtin__.game = game from panda3d.core import *