diff --git a/otp/ai/AIBase.py b/otp/ai/AIBase.py index 8b471c0..ead9bbe 100644 --- a/otp/ai/AIBase.py +++ b/otp/ai/AIBase.py @@ -6,7 +6,7 @@ from direct.task.TaskManagerGlobal import * from direct.showbase.JobManagerGlobal import * from direct.showbase.EventManagerGlobal import * from direct.showbase.PythonUtil import * -from direct.showbase import PythonUtil +from otp.otpbase import PythonUtil from direct.interval.IntervalManager import ivalMgr from direct.task import Task from direct.showbase import EventManager diff --git a/otp/distributed/DistributedDirectoryAI.py b/otp/distributed/DistributedDirectoryAI.py new file mode 100644 index 0000000..0150be9 --- /dev/null +++ b/otp/distributed/DistributedDirectoryAI.py @@ -0,0 +1,5 @@ +from direct.directnotify import DirectNotifyGlobal +from direct.distributed.DistributedObjectAI import DistributedObjectAI + +class DistributedDirectoryAI(DistributedObjectAI): + notify = DirectNotifyGlobal.directNotify.newCategory('DistributedDirectoryAI') diff --git a/otp/distributed/OTPInternalRepository.py b/otp/distributed/OTPInternalRepository.py new file mode 100644 index 0000000..8f64971 --- /dev/null +++ b/otp/distributed/OTPInternalRepository.py @@ -0,0 +1,14 @@ +from direct.directnotify import DirectNotifyGlobal +from direct.distributed.AstronInternalRepository import AstronInternalRepository + +# TODO: Remove Astron dependence. + +class OTPInternalRepository(AstronInternalRepository): + notify = DirectNotifyGlobal.directNotify.newCategory('OTPInternalRepository') + 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) + + def handleConnected(self): + AstronInternalRepository.handleConnected(self) diff --git a/otp/otpbase/PythonUtil.py b/otp/otpbase/PythonUtil.py index c15e413..acf7a63 100644 --- a/otp/otpbase/PythonUtil.py +++ b/otp/otpbase/PythonUtil.py @@ -25,6 +25,18 @@ def recordCreationStack(cls): cls.printCreationStackTrace = printCreationStackTrace return cls +# __dev__ is not defined at import time, call this after it's defined +def recordFunctorCreationStacks(): + global Functor + from pandac.PandaModules import getConfigShowbase + config = getConfigShowbase() + # off by default, very slow + if __dev__ and config.GetBool('record-functor-creation-stacks', 0): + if not hasattr(Functor, '_functorCreationStacksRecorded'): + Functor = recordCreationStackStr(Functor) + Functor._functorCreationStacksRecorded = True + Functor.__call__ = Functor._exceptionLoggedCreationStack__call__ + def describeException(backTrace = 4): # When called in an exception handler, returns a string describing # the current exception. diff --git a/toontown/distributed/ToontownInternalRepository.py b/toontown/distributed/ToontownInternalRepository.py new file mode 100644 index 0000000..83644e0 --- /dev/null +++ b/toontown/distributed/ToontownInternalRepository.py @@ -0,0 +1,8 @@ +from direct.directnotify import DirectNotifyGlobal +from otp.distributed.OTPInternalRepository import OTPInternalRepository + +class ToontownInternalRepository(OTPInternalRepository): + notify = DirectNotifyGlobal.directNotify.newCategory('ToontownInternalRepository') + + def __init__(self, baseChannel, serverId=None, dcFileNames=None, dcSuffix='AI', connectMethod=None, threadedNet=None): + OTPInternalRepository.__init__(self, baseChannel, serverId, dcFileNames, dcSuffix, connectMethod, threadedNet) diff --git a/toontown/uberdog/ToontownUDRepository.py b/toontown/uberdog/ToontownUDRepository.py new file mode 100644 index 0000000..cafae5c --- /dev/null +++ b/toontown/uberdog/ToontownUDRepository.py @@ -0,0 +1,29 @@ +from direct.directnotify import DirectNotifyGlobal +from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository +from otp.distributed.DistributedDirectoryAI import DistributedDirectoryAI + +# TODO: Remove Astron dependence. + +class ToontownUDRepository(ToontownInternalRepository): + + def __init__(self, baseChannel, serverId): + ToontownInternalRepository.__init__(self, baseChannel, serverId, dcSuffix='UD') + self.astronLoginManager = None + + def handleConnected(self): + ToontownInternalRepository.handleConnected(self) + + # Create our root object. + self.notify.info('Creating root object (%d)...' % self.getGameDoId()) + rootObj = DistributedDirectoryAI(self) + rootObj.generateWithRequiredAndId(self.getGameDoId(), 0, 0) + + # Create our global objects. + self.notify.info('Creating global objects...') + self.createGlobals() + + self.notify.info('UberDOG server is ready.') + + def createGlobals(self): + # Create our Astron login manager... + self.astronLoginManager = self.generateGlobalObject(OTP_DO_ID_ASTRON_LOGIN_MANAGER, 'AstronLoginManager') diff --git a/toontown/uberdog/UDStart.py b/toontown/uberdog/UDStart.py new file mode 100644 index 0000000..9340246 --- /dev/null +++ b/toontown/uberdog/UDStart.py @@ -0,0 +1,40 @@ +import __builtin__ + +class game: + name = 'uberDog' + process = 'server' + +__builtin__.game = game + +from panda3d.core import * + +loadPrcFile('etc/Configrc.prc') + +from otp.ai.AIBaseGlobal import * +from toontown.uberdog.ToontownUDRepository import ToontownUDRepository + +udConfig = '' +udConfig += 'air-base-channel %s\n' % 1000000 +udConfig += 'air-channel-allocation %s\n' % 999999 +udConfig += 'air-stateserver %s\n' % 4002 +udConfig += 'air-connect %s\n' % '127.0.0.1:7199' +udConfig += 'eventlog-host %s\n' % '127.0.0.1:7197' + +simbase.air = ToontownUDRepository(config.GetInt('air-base-channel', 1000000), config.GetInt('air-stateserver', 4002)) + +host = config.GetString('air-connect', '127.0.0.1:7199') +port = 7199 +if ':' in host: + host, port = host.split(':', 1) + port = int(port) + +simbase.air.connect(host, port) + +try: + run() +except SystemExit: + raise +except Exception: + from otp.otpbase import PythonUtil + print PythonUtil.describeException() + raise