def getFunnelURL(self): if patcherVer() == ['OFFLINE']: return if patcherVer() == []: patcherHTTP = HTTPClient() if checkParamFile() == None: patcherDoc = patcherHTTP.getDocument(URLSpec('http://download.toontown.com/english/currentVersion/content/patcher.ver')) vconGroup('w', self.cgRelease) else: patcherDoc = patcherHTTP.getDocument(URLSpec(checkParamFile())) vconGroup('w', self.cgBeta) rf = Ramfile() patcherDoc.downloadToRam(rf) self.patcherURL = rf.getData() if self.patcherURL.find('FUNNEL_LOG') == -1: patcherVer('w', 'OFFLINE') return self.patcherURL = self.patcherURL.split('\n') del rf del patcherDoc del patcherHTTP while self.patcherURL: self.confLine = self.patcherURL.pop() if self.confLine.find('FUNNEL_LOG=') != -1 and self.confLine.find('#FUNNEL_LOG=') == -1: self.dynamicVRFunnel = self.confLine[11:].strip('\n') patcherVer('w', self.confLine[11:].strip('\n')) else: self.dynamicVRFunnel = patcherVer()[0] return
def connect(self, url): self.notify.info("Attemping to connect to %s" % (url)) urlSpec = URLSpec(url) addr = NetAddress() addr.setHost(urlSpec.getServer(), urlSpec.getPort()) self.serverAddress = addr self.connectionHandle = self.netSys.connectByIPAddress(addr) if not self.connectionHandle: messenger.send('connectFailure', [self.serverAddress]) self.serverAddress = None self.connectionHandle = None else: self.startClientLoop()
def __init__(self): """ The AI Repository usually lives on a server and is responsible for server side logic that will handle game objects """ # List of all dc files that are of interest to this AI Repository dcFileNames = ['../direct.dc', 'sample.dc'] # Initialize the repository. We pass it the dc files and as this is an # AI repository the dcSuffix AI. This will make sure any later calls to # createDistributedObject will use the correct version. # The connectMethod ClientRepository.__init__(self, dcFileNames=dcFileNames, dcSuffix='AI', threadedNet=True) # Set the same port as configured on the server to be able to connect # to it tcpPort = ConfigVariableInt('server-port', 4400).getValue() # Set the IP or hostname of the server we want to connect to hostname = ConfigVariableString('server-host', '127.0.0.1').getValue() # Build the URL from the server hostname and port. If your server # doesn't use http you should change it accordingly. Make sure to pass # the connectMethod to the ClientRepository.__init__ call too. # Available connection methods are: # self.CM_HTTP, self.CM_NET and self.CM_NATIVE url = URLSpec('http://{}:{}'.format(hostname, tcpPort)) # Attempt a connection to the server self.connect([url], successCallback=self.connectSuccess, failureCallback=self.connectFailure)
def __init__(self): dcFileNames = ['../direct.dc'] # a distributed object of our game. self.distributedObject = None self.aiDGameObect = None ClientRepository.__init__( self, dcFileNames = dcFileNames, threadedNet = True) # Set the same port as configured on the server to be able to connect # to it tcpPort = ConfigVariableInt('server-port', 4400).getValue() # Set the IP or hostname of the server we want to connect to hostname = ConfigVariableString('server-host', '127.0.0.1').getValue() # Build the URL from the server hostname and port. If your server # uses another protocol then http you should change it accordingly. # Make sure to pass the connectMethod to the ClientRepository.__init__ # call too. Available connection methods are: # self.CM_HTTP, self.CM_NET and self.CM_NATIVE self.url = URLSpec('http://{}:{}'.format(hostname, tcpPort)) # Attempt a connection to the server self.connect([self.url], successCallback = self.connectSuccess, failureCallback = self.connectFailure)
def reportMemoryLeaks(): if printUnreachableNum() == 0: return import bz2, gc gc.set_debug(gc.DEBUG_SAVEALL) gc.collect() uncompressedReport = '' for s in gc.garbage: try: uncompressedReport += str(s) + '&' except TypeError: pass reportdata = bz2.compress(uncompressedReport, 9) headers = {'Content-type': 'application/x-bzip2', 'Accept': 'text/plain'} try: baseURL = patcherVer()[0].split('/lo')[0] except IndexError: print 'Base URL not available for leak submit' return basePort = 80 if baseURL.count(':') == 2: basePort = baseURL[-4:] baseURL = baseURL[:-5] baseURL = baseURL[7:] if basePort != 80: finalURL = 'http://' + baseURL + ':' + str(basePort) + '/logging/memory_leak.php?leakcount=' + str(printUnreachableNum()) else: finalURL = 'http://' + baseURL + '/logging/memory_leak.php?leakcount=' + str(printUnreachableNum()) reporthttp = HTTPClient() reporthttp.postForm(URLSpec(finalURL), reportdata)
def __init__(self): # Basics ShowBase.__init__(self) base.disableMouse() self.accept("escape", self.disconnect) base.camera.set_pos(0, 0, 60) base.camera.look_at(0, 0, 0) # Game-relevant attributes self.has_avatar = False self.avatar_owner_view = False # Avatar controls # FIXME: These values will be off the kilter if keys are pressed when the client starts. self.movement_heading = 0 self.movement_speed = 0 self.accept("avatar", self.get_avatar) self.accept("distributed_avatar", self.get_distributed_avatar) self.accept("arrow_up", self.indicate_movement, [0, 1]) self.accept("arrow_up-up", self.indicate_movement, [0, -1]) self.accept("arrow_down", self.indicate_movement, [0, -1]) self.accept("arrow_down-up", self.indicate_movement, [0, 1]) self.accept("arrow_left", self.indicate_movement, [1, 0]) self.accept("arrow_left-up", self.indicate_movement, [-1, 0]) self.accept("arrow_right", self.indicate_movement, [-1, 0]) self.accept("arrow_right-up", self.indicate_movement, [1, 0]) # Create repository # FIXME: For some freaky reason, using the default method # (CM_HTTP) won't result in further callbacks being called # back. Does connection() fail? self.repo = AstronClientRepository(dcFileNames = ["simple_example.dc"], connectMethod = AstronClientRepository.CM_NET) # Callback events. These names are "magic" (defined in AstronClientRepository) self.accept("CLIENT_HELLO_RESP", self.client_is_handshaked) self.accept("CLIENT_EJECT", self.ejected) self.accept("CLIENT_OBJECT_LEAVING", self.avatar_leaves) self.accept("CLIENT_OBJECT_LEAVING_OWNER", self.avatar_leaves_owner) self.accept("LOST_CONNECTION", self.lost_connection) # Connecting url = URLSpec() url.setServer("127.0.0.1") url.setPort(6667) # FIXME: No idea why this doesn't work instead... # url = URLSpec("127.0.0.1", 6667) self.notify.debug("Connecting...") self.repo.connect([url], successCallback = self.connection_success, failureCallback = self.connection_failure)
def __init__(self, endpoint): self.url = URLSpec(endpoint) self.http = HTTPClient() self.http.setVerifySsl(0) self.channels = {} # Start polling: taskName = self.getUniqueName() + '-pollTask' taskMgr.add(self.pollTask, taskName)
def __init__(self, host, dirnode): self.host = host self.pathname = dirnode.pathname self.totalSize = dirnode.getTotalSize() self.packages = [] if self.host: self.hostUrl = self.host.hostUrl self.descriptiveName = self.host.descriptiveName if not self.descriptiveName: self.descriptiveName = URLSpec(self.hostUrl).getServer() else: self.hostUrl = 'unknown' self.descriptiveName = 'unknown'
def __init__(self): print("SETUP AI REPOSITORY") dcFileNames = ["interfaces/direct.dc", "interfaces/gameRoom.dc", "interfaces/chat.dc"] ClientRepository.__init__( self, dcFileNames = dcFileNames, dcSuffix = 'AI', threadedNet = True) hostname = base.serverHost.getValue() print("CONNECT TO:", hostname) url = URLSpec('http://{}'.format(hostname)) self.connect([url], successCallback = self.connectSuccess, failureCallback = self.connectFailure)
def __init__(self, readyCommand, readyCommandArgs, failedCommand, failedCommandArgs): dcFileNames = [ "interfaces/direct.dc", "interfaces/gameRoom.dc", "interfaces/chat.dc" ] ClientRepository.__init__(self, dcFileNames=dcFileNames, threadedNet=True) self.roomManager = None self.readyCommand = readyCommand self.readyCommandArgs = readyCommandArgs self.failedCommand = failedCommand self.failedCommandArgs = failedCommandArgs hostname = base.serverHost.getValue() self.url = URLSpec('http://{}'.format(hostname)) self.connect([self.url], successCallback=self.connectSuccess, failureCallback=self.connectFailure)
def __init__(self): # Basics ShowBase.__init__(self) base.disableMouse() self.accept("escape", self.disconnect) base.camera.set_pos(0, 0, 60) base.camera.look_at(0, 0, 0) # Game-relevant attributes self.has_avatar = False self.avatar_owner_view = False # Avatar controls # FIXME: These values will be off the kilter if keys are pressed when the client starts. self.movement_heading = 0 self.movement_speed = 0 self.accept("avatar", self.get_avatar) self.accept("distributed_avatar", self.get_distributed_avatar) self.accept("arrow_up", self.indicate_movement, [0, 1]) self.accept("arrow_up-up", self.indicate_movement, [0, -1]) self.accept("arrow_down", self.indicate_movement, [0, -1]) self.accept("arrow_down-up", self.indicate_movement, [0, 1]) self.accept("arrow_left", self.indicate_movement, [1, 0]) self.accept("arrow_left-up", self.indicate_movement, [-1, 0]) self.accept("arrow_right", self.indicate_movement, [-1, 0]) self.accept("arrow_right-up", self.indicate_movement, [1, 0]) # Create repository # FIXME: For some freaky reason, using the default method # (CM_HTTP) won't result in further callbacks being called # back. Does connection() fail? self.repo = AstronClientRepository( dcFileNames=["simple_example.dc"], connectMethod=AstronClientRepository.CM_NET) # Callback events. These names are "magic" (defined in AstronClientRepository) self.accept("CLIENT_HELLO_RESP", self.client_is_handshaked) self.accept("CLIENT_EJECT", self.ejected) self.accept("CLIENT_OBJECT_LEAVING", self.avatar_leaves) self.accept("CLIENT_OBJECT_LEAVING_OWNER", self.avatar_leaves_owner) self.accept("LOST_CONNECTION", self.lost_connection) # Connecting url = URLSpec() url.setServer("127.0.0.1") url.setPort(6667) # FIXME: No idea why this doesn't work instead... # url = URLSpec("127.0.0.1", 6667) self.notify.debug("Connecting...") self.repo.connect([url], successCallback=self.connection_success, failureCallback=self.connection_failure)
def __init__(self, serverVersion): self.serverVersion = serverVersion AstronClientRepository.__init__( self, ['phase_3/etc/direct.dc', 'phase_3/etc/toon.dc']) self.loginFSM = ClassicFSM('login', [ State('off', self.enterOff, self.exitOff), State('connect', self.enterConnect, self.exitConnect), State('disconnect', self.enterDisconnect, self.exitDisconnect), State('avChoose', self.enterAvChoose, self.exitAvChoose), State('playingGame', self.enterPlayingGame, self.exitPlayingGame), State('serverUnavailable', self.enterServerUnavailable, self.exitServerUnavailable), State('makeAToon', self.enterMakeAToon, self.exitMakeAToon), State('submitNewToon', self.enterSubmitNewToon, self.exitSubmitNewToon), State('noShards', self.enterNoShards, self.exitNoShards), State('waitForSetAvatarResponse', self.enterWaitForSetAvatarResponse, self.exitWaitForSetAvatarResponse), State('waitForShardList', self.enterWaitForShardList, self.exitWaitForShardList), State('ejected', self.enterEjected, self.exitEjected), State('districtReset', self.enterDistrictReset, self.exitDistrictReset), State('died', self.enterDied, self.exitDied), State('betaInform', self.enterBetaInform, self.exitBetaInform) ], 'off', 'off') self.loginFSM.enterInitialState() self.gameFSM = ClassicFSM('game', [ State('off', self.enterGameOff, self.exitGameOff), State('waitForGameEnterResponse', self.enterWaitForGameEnterResponse, self.exitWaitForGameEnterResponse), State('playGame', self.enterPlayGame, self.exitPlayGame), State('closeShard', self.enterCloseShard, self.exitCloseShard), State('switchShards', self.enterSwitchShards, self.exitSwitchShards) ], 'off', 'off') self.gameFSM.enterInitialState() #self.taskNameAllocator = UniqueIdAllocator(0, 1000000000) self.avChooser = AvChooser(self.loginFSM) self.playGame = PlayGame(self.gameFSM, "playGameDone") self.hoodMgr = HoodMgr() self.makeAToon = MakeAToon() self.loginToken = os.environ.get("LOGIN_TOKEN") self.serverAddress = os.environ.get("GAME_SERVER") self.serverURL = URLSpec("http://%s" % self.serverAddress) self.parentMgr.registerParent(CIGlobals.SPRender, render) self.parentMgr.registerParent(CIGlobals.SPHidden, hidden) self.adminAccess = False self.localAvChoice = None self.SuitsActive = 0 self.BossActive = 0 self.accServerTimesNA = 0 self.maxAccServerTimesNA = 10 self.setZonesEmulated = 0 self.old_setzone_interest_handle = None self.setZoneQueue = Queue() self.accept(self.SetZoneDoneEvent, self._handleEmuSetZoneDone) self.handler = None self.__currentAvId = 0 self.myDistrict = None self.activeDistricts = {} self.shardListHandle = None self.uberZoneInterest = None self.isShowingPlayerIds = False self.doBetaInform = False self.dTutorial = None self.requestedName = None self.whisperNoise = base.loadSfx( 'phase_3.5/audio/sfx/GUI_whisper_3.ogg') self.checkHttp() #self.http.addPreapprovedServerCertificateFilename(self.serverURL, Filename('phase_3/etc/gameserver.crt')) #self.tournamentMusicChunks = {} #self.threadedTaskChain = taskMgr.setupTaskChain("threadedTaskChainForSoundIntervals", numThreads = 2) self.attackMgr = base.cl_attackMgr base.minigame = None self.newToonSlot = None base.finalExitCallbacks.insert(0, self.__handleExit) self.accountName = os.environ.get('ACCOUNT_NAME', '') self.csm = self.generateGlobalObject(DO_ID_CLIENT_SERVICES_MANAGER, 'ClientServicesManager') self.friendsManager = self.generateGlobalObject( DO_ID_FRIENDS_MANAGER, 'FriendsManager') self.uin = self.generateGlobalObject(DO_ID_UNIQUE_INTEREST_NOTIFIER, 'UniqueInterestNotifier') self.statsManager = self.generateGlobalObject(DO_ID_STATS_MANAGER, 'StatsManager') self.pingToggle = False self.currentPing = None self.pingText = OnscreenText("", align=TextNode.ALeft, parent=base.a2dBottomLeft, fg=(1, 1, 1, 1), shadow=(0, 0, 0, 0.5), pos=(0.3, 0.09)) self.pingText.setBin('gsg-popup', 1000) self.pingText.hide() SpeedHackChecker.startChecking() self.loginFSM.request('connect') return
def __init__(self, music, serverVersion): self.music = music self.serverVersion = serverVersion AstronClientRepository.__init__(self, ['phase_3/etc/direct.dc', 'phase_3/etc/toon.dc']) self.loginFSM = ClassicFSM('login', [State('off', self.enterOff, self.exitOff), State('connect', self.enterConnect, self.exitConnect), State('disconnect', self.enterDisconnect, self.exitDisconnect), State('avChoose', self.enterAvChoose, self.exitAvChoose), State('playingGame', self.enterPlayingGame, self.exitPlayingGame), State('serverUnavailable', self.enterServerUnavailable, self.exitServerUnavailable), State('makeAToon', self.enterMakeAToon, self.exitMakeAToon), State('submitNewToon', self.enterSubmitNewToon, self.exitSubmitNewToon), State('noShards', self.enterNoShards, self.exitNoShards), State('waitForSetAvatarResponse', self.enterWaitForSetAvatarResponse, self.exitWaitForSetAvatarResponse), State('waitForShardList', self.enterWaitForShardList, self.exitWaitForShardList), State('ejected', self.enterEjected, self.exitEjected), State('districtReset', self.enterDistrictReset, self.exitDistrictReset), State('died', self.enterDied, self.exitDied), State('betaInform', self.enterBetaInform, self.exitBetaInform)], 'off', 'off') self.loginFSM.enterInitialState() self.gameFSM = ClassicFSM('game', [State('off', self.enterGameOff, self.exitGameOff), State('waitForGameEnterResponse', self.enterWaitForGameEnterResponse, self.exitWaitForGameEnterResponse), State('playGame', self.enterPlayGame, self.exitPlayGame), State('closeShard', self.enterCloseShard, self.exitCloseShard), State('switchShards', self.enterSwitchShards, self.exitSwitchShards)], 'off', 'off') self.gameFSM.enterInitialState() self.avChooser = AvChooser(self.loginFSM) self.playGame = PlayGame(self.gameFSM, 'playGameDone') self.hoodMgr = HoodMgr() self.makeAToon = MakeAToon() self.loginToken = os.environ.get('LOGIN_TOKEN') self.serverAddress = os.environ.get('GAME_SERVER') self.serverURL = URLSpec('http://%s' % self.serverAddress) self.parentMgr.registerParent(CIGlobals.SPRender, render) self.parentMgr.registerParent(CIGlobals.SPHidden, hidden) self.adminAccess = False self.localAvChoice = None self.SuitsActive = 0 self.BossActive = 0 self.accServerTimesNA = 0 self.maxAccServerTimesNA = 10 self.setZonesEmulated = 0 self.old_setzone_interest_handle = None self.setZoneQueue = Queue() self.accept(self.SetZoneDoneEvent, self._handleEmuSetZoneDone) self.handler = None self.__currentAvId = 0 self.myDistrict = None self.activeDistricts = {} self.shardListHandle = None self.uberZoneInterest = None self.isShowingPlayerIds = False self.doBetaInform = True self.dTutorial = None self.requestedName = None self.whisperNoise = base.loadSfx('phase_3.5/audio/sfx/GUI_whisper_3.ogg') self.checkHttp() base.audio3d = Audio3DManager(base.sfxManagerList[0], camera) base.audio3d.setDropOffFactor(0) base.audio3d.setDopplerFactor(3.0) base.lifter = CollisionHandlerFloor() base.pusher = CollisionHandlerPusher() base.queue = CollisionHandlerQueue() base.minigame = None base.finalExitCallbacks.insert(0, self.__handleExit) self.csm = self.generateGlobalObject(DO_ID_CLIENT_SERVICES_MANAGER, 'ClientServicesManager') self.friendsManager = self.generateGlobalObject(DO_ID_FRIENDS_MANAGER, 'FriendsManager') SpeedHackChecker.startChecking() self.loginFSM.request('connect') return