general: time for pain

This commit is contained in:
Open Toontown 2019-11-08 22:20:04 -05:00
parent 9b2834785e
commit 41cad484c4
7 changed files with 109 additions and 1 deletions

View file

@ -6,7 +6,7 @@ from direct.task.TaskManagerGlobal import *
from direct.showbase.JobManagerGlobal import * from direct.showbase.JobManagerGlobal import *
from direct.showbase.EventManagerGlobal import * from direct.showbase.EventManagerGlobal import *
from direct.showbase.PythonUtil import * from direct.showbase.PythonUtil import *
from direct.showbase import PythonUtil from otp.otpbase import PythonUtil
from direct.interval.IntervalManager import ivalMgr from direct.interval.IntervalManager import ivalMgr
from direct.task import Task from direct.task import Task
from direct.showbase import EventManager from direct.showbase import EventManager

View file

@ -0,0 +1,5 @@
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI
class DistributedDirectoryAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedDirectoryAI')

View file

@ -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)

View file

@ -25,6 +25,18 @@ def recordCreationStack(cls):
cls.printCreationStackTrace = printCreationStackTrace cls.printCreationStackTrace = printCreationStackTrace
return cls 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): def describeException(backTrace = 4):
# When called in an exception handler, returns a string describing # When called in an exception handler, returns a string describing
# the current exception. # the current exception.

View file

@ -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)

View file

@ -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')

View file

@ -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