class Heartbeat(): def __init__(self): self.http = HTTPClient() self.SendHeartbeat() #taskMgr.doMethodLater(10, self.SendHeartbeat, 'SendHeartbeat') def SendHeartbeat(self, task = None): baseUrl = 'http://modifire.net/heartbeat.php?' values = {'name' : Settings.SERVER_NAME, 'currentPlayers' : Globals.CURRENT_PLAYERS, 'maxPlayers' : Globals.MAX_PLAYERS, 'public' : Settings.SERVER_PUBLIC, 'port' : Globals.PORT_SERVER_LISTENER, 'version' : Globals.VERSION} for key, value in values.iteritems(): values[key] = urllib.quote(str(value)) params = [ baseUrl, 'name=%s' % (values['name']), 'currentPlayers=%s' % (values['currentPlayers']), 'maxPlayers=%s' % (values['maxPlayers']), 'public=%s' % (values['public']), 'port=%s' % (values['port']), 'version=%s' % (values['version']) ] req = '&'.join(params) self.channel = self.http.makeChannel(True) self.channel.beginGetDocument(DocumentSpec(req)) self.rf = Ramfile() self.channel.downloadToRam(self.rf) taskMgr.add(self.downloadTask, 'download') if(task): return task.again def downloadTask(self, task): if self.channel.run(): return task.cont if not self.channel.isDownloadComplete(): return task.done data = self.rf.getData() return task.done
class UserFunnel: def __init__(self): self.hitboxAcct = 'DM53030620EW' self.language = 'en-us' self.cgRoot = 'ToonTown_Online' self.cgBeta = 'Beta' self.cgRelease = 'Release' self.cgLocation = 'US' self.campaignID = '' self.cfCookieFile = 'cf.txt' self.dynamicVRFunnel = 'http://download.toontown.com/' self.hostDict = {0: 'Internal Disney PHP Collector Site', 1: 'ehg-dig.hitbox.com/HG?', 2: 'ehg-dig.hitbox.com/HG?', 3: 'build64.online.disney.com:5020/index.php?'} self.CurrentHost = '' self.URLtoSend = '' self.gameName = 'ToonTown' self.browserName = 'Panda3D%20(' + self.gameName + ';%20' + sys.platform + ')' self.HTTPUserHeader = [('User-agent', 'Panda3D')] self.osMajorver = '' self.osMinorver = '' self.osRevver = '' self.osBuild = '' self.osType = '' self.osComments = '' self.msWinTypeDict = {0: 'Win32s on Windows 3.1', 1: 'Windows 95/98/ME', 2: 'Windows NT/2000/XP', 3: 'Windows CE'} self.milestoneDict = {0: 'New User', 1: 'Create Account', 2: 'View EULA', 3: 'Accept EULA', 4: 'Download Start', 5: 'Download End', 6: 'Installer Run', 7: 'Launcher Start', 8: 'Launcher Login', 9: 'Client Opens', 10: 'Create Pirate Loads', 11: 'Create Pirate Exit', 12: 'Cutscene One Start', 13: 'Cutscene One Ends', 14: 'Cutscene Two Start', 15: 'Cutscene Thee Start', 16: 'Cutscene Three Ends', 17: 'Access Cannon', 18: 'Cutscene Four Starts', 19: 'Cutscene Four Ends', 20: 'Dock - Start Game'} self.macTypeDict = {2: 'Jaguar', 1: 'Puma', 3: 'Panther', 4: 'Tiger', 5: 'Lepard'} self.milestone = '' self.pandaHTTPClientVarWSS = [] self.pandaHTTPClientVarCTG = [] self.pandaHTTPClientVarDM = [] self.checkForCFfile() self.httpSession = HTTPClient() self.whatOSver() def checkForCFfile(self): if firstRun() == True: pass elif os.path.isfile(self.cfCookieFile) == False: firstRun('write', True) def whatOSver(self): if sys.platform == 'win32': self.osMajorver = str(sys.getwindowsversion()[0]) self.osMinorver = str(sys.getwindowsversion()[1]) self.osBuild = str(sys.getwindowsversion()[2]) self.osType = str(sys.getwindowsversion()[3]) self.osComments = str(sys.getwindowsversion()[4]) return if sys.platform == 'darwin': self.osMajorver = '10' osxcmd = '/usr/sbin/system_profiler SPSoftwareDataType |/usr/bin/grep "System Version"' infopipe = os.popen(osxcmd, 'r') parseLine = infopipe.read() infopipe.close() del infopipe notify.info('parseLine = %s' % str(parseLine)) versionStringStart = parseLine.find('10.') notify.info('versionStringStart = %s' % str(versionStringStart)) testPlist = False try: self.osMinorver = parseLine[versionStringStart + 3] self.osRevver = parseLine[versionStringStart + 5:versionStringStart + 7].strip(' ') self.osBuild = parseLine[int(parseLine.find('(')) + 1:parseLine.find(')')] except: notify.info("couldn't parse the system_profiler output, using zeros") self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' testPlist = True del versionStringStart del parseLine del osxcmd if testPlist: try: import plistlib pl = plistlib.readPlist('/System/Library/CoreServices/SystemVersion.plist') notify.info('pl=%s' % str(pl)) parseLine = pl['ProductVersion'] numbers = parseLine.split('.') notify.info('parseline =%s numbers =%s' % (parseLine, numbers)) self.osMinorver = numbers[1] self.osRevver = numbers[2] self.osBuild = pl['ProductBuildVersion'] except: notify.info('tried plist but still got exception') self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' return def setmilestone(self, ms): if firstRun() == False: self.milestone = ms else: self.milestone = '%s_INITIAL' % ms def setgamename(self, gamename): self.gameName = gamename def printosComments(self): return self.osComments def setHost(self, hostID): self.CurrentHost = hostID 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 isVarSet(self, varInQuestion): try: tempvar = type(varInQuestion) return 1 except NameError: return 0 def buildURL(self): if sys.platform == 'win32': hitboxOSType = 'c3' else: hitboxOSType = 'c4' if self.CurrentHost == 1: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str(self.hitboxAcct) + '&n=' + str(self.milestone) + '&ln=' + self.language + '&gp=STARTGAME&fnl=TOONTOWN_FUNNEL&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str(vconGroup()) + '&c1=' + str(sys.platform) + '&' + str(hitboxOSType) + '=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) if self.CurrentHost == 2: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str(self.hitboxAcct) + '&n=' + str(self.milestone) + '&ln=' + self.language + '&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str(vconGroup()) + '&c1=' + str(sys.platform) + '&' + str(hitboxOSType) + '=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) if self.CurrentHost == 0: localMAC = str(getMAC()) self.URLtoSend = str(self.dynamicVRFunnel) + '?funnel=' + str(self.milestone) + '&platform=' + str(sys.platform) + '&sysver=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) + '&mac=' + localMAC + '&username='******'&id=' + str(loggingAvID()) def readInPandaCookie(self): thefile = open(self.cfCookieFile, 'r') thedata = thefile.read().split('\n') thefile.close() del thefile if thedata[0].find('Netscape HTTP Cookie File') != -1: return thedata.pop() try: while thedata: temp = thedata.pop() temp = temp.split('\t') domain = temp[0] loc = temp[1] variable = temp[2] value = temp[3] if variable == 'CTG': self.pandaHTTPClientVarCTG = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarCTG) if variable == self.hitboxAcct + 'V6': self.pandaHTTPClientVarDM = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarDM) if variable == 'WSS_GW': self.pandaHTTPClientVarWSS = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarWSS) except IndexError: print 'UserFunnel(Warning): Cookie Data file bad' del thedata def updateInstanceCookieValues(self): a = self.httpSession.getCookie(HTTPCookie('WSS_GW', '/', '.hitbox.com')) if a.getName(): self.pandaHTTPClientVarWSS = ['.hitbox.com', '/', 'WSS_GW', a.getValue()] b = self.httpSession.getCookie(HTTPCookie('CTG', '/', '.hitbox.com')) if b.getName(): self.pandaHTTPClientVarCTG = ['.hitbox.com', '/', 'CTG', b.getValue()] c = self.httpSession.getCookie(HTTPCookie(self.hitboxAcct + 'V6', '/', 'ehg-dig.hitbox.com')) if c.getName(): self.pandaHTTPClientVarDM = ['ehg-dig.hitbox.com', '/', self.hitboxAcct + 'V6', c.getValue()] del a del b del c def setTheHTTPCookie(self, cookieParams): c = HTTPCookie(cookieParams[2], cookieParams[1], cookieParams[0]) c.setValue(cookieParams[3]) self.httpSession.setCookie(c) def writeOutPandaCookie(self): try: thefile = open(self.cfCookieFile, 'w') if len(self.pandaHTTPClientVarWSS) == 4: thefile.write(self.pandaHTTPClientVarWSS[0] + '\t' + self.pandaHTTPClientVarWSS[1] + '\t' + self.pandaHTTPClientVarWSS[2] + '\t' + self.pandaHTTPClientVarWSS[3] + '\n') if len(self.pandaHTTPClientVarCTG) == 4: thefile.write(self.pandaHTTPClientVarCTG[0] + '\t' + self.pandaHTTPClientVarCTG[1] + '\t' + self.pandaHTTPClientVarCTG[2] + '\t' + self.pandaHTTPClientVarCTG[3] + '\n') if len(self.pandaHTTPClientVarDM) == 4: thefile.write(self.pandaHTTPClientVarDM[0] + '\t' + self.pandaHTTPClientVarDM[1] + '\t' + self.pandaHTTPClientVarDM[2] + '\t' + self.pandaHTTPClientVarDM[3] + '\n') thefile.close() except IOError: return def prerun(self): self.getFunnelURL() self.buildURL() if os.path.isfile(self.cfCookieFile) == True: if self.CurrentHost == 1 or self.CurrentHost == 2: self.readInPandaCookie() def run(self): if self.CurrentHost == 0 and patcherVer() == ['OFFLINE']: return self.nonBlock = self.httpSession.makeChannel(False) self.nonBlock.beginGetDocument(DocumentSpec(self.URLtoSend)) instanceMarker = str(random.randint(1, 1000)) instanceMarker = 'FunnelLoggingRequest-%s' % instanceMarker self.startCheckingAsyncRequest(instanceMarker) def startCheckingAsyncRequest(self, name): taskMgr.remove(name) taskMgr.doMethodLater(0.5, self.pollFunnelTask, name) def stopCheckingFunnelTask(self, name): taskMgr.remove('pollFunnelTask') def pollFunnelTask(self, task): result = self.nonBlock.run() if result == 0: self.stopCheckingFunnelTask(task) if self.CurrentHost == 1 or self.CurrentHost == 2: self.updateInstanceCookieValues() self.writeOutPandaCookie() else: return Task.again
class FancyLoadingScreen(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('LoadingScreen') def __init__(self, parent): DirectObject.DirectObject.__init__(self) self.debugMode = config.GetInt('loading-screen') == 2 self.parent = parent self.state = False self.currScreenshot = None self.snapshot = None self.snapshotFrame = None self.snapshotFrameBasic = None self.currentTime = 0 self.analyzeMode = False self.loadScale = 1.0 self.unmappedTicks = [] self.stepInfo = {} self.accept(base.win.getWindowEvent(), self.adjustSize) self.accept('tick', self.tick) self.currStage = 'unmapped' self.stagePercent = 0 self.numObjects = 0 self.currPercent = 0.0 self.line = LineSegs() self.line.setColor((0, 0, 0, 1)) self.line.setThickness(1) self.stageLabel = None self.currNum = 0 self.overallPercent = 0 self.lastPercent = 0 self.topLock = aspect2dp.attachNewNode('topShift') self.root = self.topLock.attachNewNode('loadingScreenRoot') self.root.setZ(-1) self.root.stash() self.model = loader.loadModel( 'models/gui/pir_m_gui_gen_loadScreen.bam') self.model.setP(90) self.model.reparentTo(self.root) cm = CardMaker('backdrop') cm.setFrame(-10, 10, -10, 10) if self.debugMode: self.backdrop = self.root.attachNewNode(cm.generate()) self.backdrop.setX(-1.5) self.backdrop.setZ(-1) self.backdrop.setScale(4) self.backdrop.setColor(0.5, 0.5, 0.5, 1) cm = CardMaker('loadingBarBase') cm.setFrame(-0.90000000000000002, 0.90000000000000002, 0.10000000000000001, 0.5) self.loadingBarBacking = self.root.attachNewNode(cm.generate()) self.loadingBarRoot = self.root.attachNewNode('loadingBarRoot') cm.setName('analysisBarBase') cm.setFrame(-0.90000000000000002, 0.90000000000000002, -0.5, -0.10000000000000001) self.analysisBar = self.root.attachNewNode(cm.generate()) self.analysisBarRoot = self.root.attachNewNode('analysisBarRoot') self.analysisBar.hide() self.analysisButtons = [] self.enterToContinue = DirectLabel(parent=self.root, text='Press Shift To Continue', relief=None, text_scale=0.10000000000000001, pos=(0, 0, -0.90000000000000002), text_align=TextNode.ACenter) self.enterToContinue.hide() self.stageLabel = DirectLabel(parent=self.root, text='', relief=None, text_scale=0.10000000000000001, pos=(-1.25, 0, 0.75), text_align=TextNode.ALeft, textMayChange=1) self.tickLabel = DirectLabel(parent=self.root, text='', relief=None, text_scale=0.10000000000000001, pos=(0.75, 0, 0.75), textMayChange=1) self.overallLabel = DirectLabel(parent=self.root, text='', relief=None, text_scale=0.10000000000000001, pos=(0, 0, -0.75), textMayChange=1) else: self.backdrop = loader.loadModel( 'models/gui/pir_m_gui_gen_loadScreen') self.backdrop.reparentTo(self.root) bg = self.backdrop.find('**/expandable_bg') bg.setScale(1000, 1, 1000) bg.flattenStrong() self.backdrop.find('**/loadbar_grey').setColorScale( 0.14999999999999999, 0.14999999999999999, 0.14999999999999999, 0.10000000000000001) self.loadingBar = self.backdrop.find('**/loadbar') self.loadingBar.setColorScale(0.20000000000000001, 0.59999999999999998, 0.5, 1) self.loadingPlank = NodePathCollection() self.loadingPlank.addPath( self.backdrop.find('**/plank_loading_bar')) self.loadingPlank.addPath(self.backdrop.find('**/loadbar')) self.loadingPlank.addPath(self.backdrop.find('**/loadbar_frame')) self.loadingPlank.addPath(self.backdrop.find('**/loadbar_grey')) self.titlePlank = self.backdrop.find('**/plank_title') self.percentLabel = DirectLabel( text='0%', parent=self.root, relief=None, text_font=PiratesGlobals.getPirateFont(), text_fg=PiratesGuiGlobals.TextFG2, text_shadow=PiratesGuiGlobals.TextShadow, text_scale=0.031, pos=(0, 0, -0.44450000000000001), textMayChange=1) self.loadingPlank.addPath(self.percentLabel) self.screenshot = self.backdrop.find('**/screenshot') copyGeom = self.loadingBar.find('**/+GeomNode').node().getGeom(0) format = copyGeom.getVertexData().getFormat() primitive = copyGeom.getPrimitive(0) data = GeomVertexData( self.screenshot.node().getGeom(0).getVertexData()) data.setFormat(format) writer = GeomVertexWriter(data, 'texcoord') writer.setData2f(0, 0) writer.setData2f(1, 0) writer.setData2f(1, 1) writer.setData2f(0, 1) geom = Geom(data) geom.addPrimitive(primitive) self.screenshot.node().removeGeom(0) self.screenshot.node().addGeom(geom) self.titlePlankMiddle = self.backdrop.find( '**/plank_title_middle_box') self.titlePlankLeft = self.backdrop.find('**/plank_title_left') self.titlePlankRight = self.backdrop.find('**/plank_title_right') self.loadingBarColors = [(((i % 10) / 10.0 + 0.5) / 2.0, ((i % 100) / 10 / 10.0 + 0.5) / 2.0, (i / 100 / 10.0 + 0.5) / 2.0, 1) for i in range(1000)] random.shuffle(self.loadingBarColors) self.lastUpdateTime = globalClock.getRealTime() self.locationLabel = DirectLabel( parent=self.root, relief=None, text='', text_font=PiratesGlobals.getPirateOutlineFont(), text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, text_scale=PiratesGuiGlobals.TextScaleTitleJumbo * 0.69999999999999996, text_align=TextNode.ACenter, pos=(0.0, 0.0, 0.51500000000000001), textMayChange=1) self.locationText = None self.hintLabel = DirectLabel( parent=self.root, relief=None, text='', text_font=PiratesGlobals.getPirateOutlineFont(), text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, text_scale=PiratesGuiGlobals.TextScaleTitleJumbo * 0.5, text_align=TextNode.ACenter, pos=(0.0, 0.0, -0.62), text_wordwrap=30, textMayChange=1) self.hintText = None self.adImage = None self.allowLiveFlatten = ConfigVariableBool('allow-live-flatten') self.title_art = [] self.tempVolume = [] self.adjustSize(base.win) gsg = base.win.getGsg() if gsg: self.root.prepareScene(gsg) def startLoading(self, expectedLoadScale): if not self.debugMode: self.loadingBar.setSx(0) self.loadScale = float(expectedLoadScale) self.currStage = 'unmapped' self.stagePercent = 0 self.numObjects = 0 self.currPercent = 0.0 self.loadingStart = globalClock.getRealTime() self.currNum = 0 self.overallPercent = 0 self.lastPercent = 0 self.stepNum = 0 if self.debugMode: self.overallLabel['text'] = '0.0' self.stageLabel['text'] = self.currStage self.update() def beginStep(self, stageName, amt=0, percent=0.001): if not self.state: return None if self.currStage != 'unmapped' and stageName != self.currStage: if __dev__ and self.debugMode: self.notify.error( 'step %s not finished when step %s was started!' % (self.currStage, stageName)) else: self.notify.warning( 'step %s not finished when step %s was started!' % (self.currStage, stageName)) return None self.stepNum += 1 if self.debugMode: stageColor = self.loadingBarColors[self.stepNum] self.stepInfo[stageName] = [ globalClock.getRealTime() - self.loadingStart, 0.0, stageColor, [], self.lastPercent + self.stagePercent, percent, amt ] self.stepCard = CardMaker('step-%s' % stageName) self.stepCard.setColor(stageColor) self.currPoly = NodePath('empty') self.stageLabel['text'] = stageName self.tickLabel['text'] = '0.0' self.currPercent = 0.0 self.overallPercent = min(100.0 * self.loadScale, self.lastPercent + self.stagePercent) self.lastPercent = self.overallPercent self.currStage = stageName self.stagePercent = percent self.numObjects = amt self.currNum = 0 base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() def endStep(self, stageName): if self.currStage == 'unmapped': self.notify.warning( 'step %s was started before loading screen was enabled' % stageName) return None if stageName != self.currStage: if __dev__ and self.debugMode: self.notify.error( 'step %s was active while step %s was trying to end!' % (self.currStage, stageName)) else: return None self.tick() if self.debugMode: stageInfo = self.stepInfo[self.currStage] stageInfo[1] = globalClock.getRealTime( ) - self.loadingStart - stageInfo[0] self.currPoly.detachNode() self.stepCard.setFrame( (self.lastPercent / self.loadScale) * 0.017999999999999999 - 0.90000000000000002, ((self.lastPercent + self.stagePercent) / self.loadScale) * 0.017999999999999999 - 0.90000000000000002, 0.10000000000000001, 0.5) self.loadingBarRoot.attachNewNode(self.stepCard.generate()) self.stageLabel['text'] = 'unmapped' self.currStage = 'unmapped' self.currPercent = 0.0 def tick(self): if self.state == False or self.analyzeMode: return None if self.debugMode: if self.currStage == 'unmapped': self.unmappedTicks.append(globalClock.getRealTime() - self.loadingStart) else: self.stepInfo[self.currStage][3].append( globalClock.getRealTime() - self.loadingStart) self.currNum += 1 self.currPercent = min(1.0, self.currNum / float(self.numObjects + 1)) self.overallPercent = min( 100.0 * self.loadScale, self.lastPercent + self.currPercent * self.stagePercent) self.update() def destroy(self): taskMgr.remove('updateLoadingScreen') for part in (self.model, self.snapshot): if part is not None: tex = part.findTexture('*') if tex: tex.releaseAll() part.removeNode() continue self.model = None self.snapshot = None if self.snapshotFrame: self.snapshotFrame.destroy() if self.snapshotFrameBasic: self.snapshotFrameBasic.destroy() if self.locationLabel: self.locationLabel.destroy() if self.hintLabel: self.hintLabel.destroy() if self.debugMode: self.stageLabel.destroy() self.tickLabel.destroy() self.overallLabel.destroy() self.enterToContinue.destroy() self.stageLabel = None self.tickLabel = None self.overallLabel = None self.enterToContinue = None self.ignoreAll() def showTitleFrame(self): if base.config.GetBool('no-loading-screen', 0): return None for part in self.title_art: part.show() def hideTitleFrame(self): for part in self.title_art: part.hide() def show(self, waitForLocation=False, disableSfx=True, expectedLoadScale=1.0): if self.state and base.config.GetBool('no-loading-screen', 0) or not (self.locationLabel): return None render.hide() render2d.hide() render2dp.hide() if not self.debugMode: self.loadingPlank.hide() self.root.unstash() self.root.showThrough() self.state = True gsg = base.win.getGsg() if gsg: gsg.setIncompleteRender(False) base.setTaskChainNetNonthreaded() self.allowLiveFlatten.setValue(1) self.startLoading(expectedLoadScale) base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() base.refreshAds() taskMgr.add(self.update, 'updateLoadingScreen', priority=-100) if base.sfxManagerList and disableSfx: index = 0 while index < len(base.sfxManagerList): sfx_manager = base.sfxManagerList[index] sfx_manager.setVolume(0.0) index += 1 if base.appRunner: base.appRunner.notifyRequest('onLoadingMessagesStart') self._FancyLoadingScreen__setLocationText(self.locationText) self._FancyLoadingScreen__setHintText(self.hintText) if not waitForLocation: screenshot = random.choice(tutorialShots_MoveAim) self._FancyLoadingScreen__setLoadingArt(screenshot) def showHint(self, destId=None, ocean=False): if base.config.GetBool('no-loading-screen', 0) or not (self.locationLabel): return None if ocean: hint = getOceanHint() elif hasattr(base, 'localAvatar'): totalReputation = 0 level = base.localAvatar.getLevel() if totalReputation: hint = getHint(destId, level) else: hint = getHint(destId) else: hint = getHint() shipPVPIslands = ['1196970035.53sdnaik', '1196970080.56sdnaik'] if (destId in shipPVPIslands or ocean ) and base.localAvatar.getCurrentIsland() in shipPVPIslands: hint = getPrivateeringHint() if self.parent and base.localAvatar.style.getTutorial( ) == PiratesGlobals.TUT_MET_JOLLY_ROGER: hint = '%s: %s' % (PLocalizer.LoadingScreen_Hint, PLocalizer.GeneralTip7) self._FancyLoadingScreen__setHintText(hint) def update(self, task=None): if not (self.state) or self.analyzeMode: return Task.cont realTime = globalClock.getRealTime() if realTime - self.lastUpdateTime < 0.10000000000000001: return Task.cont self.currentTime += min(10, (realTime - self.lastUpdateTime) * 250) self.lastUpdateTime = realTime if self.debugMode: self.overallLabel[ 'text'] = '%3.1f' % self.overallPercent / self.loadScale self.tickLabel['text'] = '%3.1f' % self.currPercent * 100.0 else: self.percentLabel[ 'text'] = '%d%%' % self.overallPercent / self.loadScale if self.currStage != 'unmapped': if self.debugMode: self.currPoly.detachNode() self.stepCard.setFrame( (self.lastPercent / self.loadScale) * 0.017999999999999999 - 0.90000000000000002, (self.overallPercent / self.loadScale) * 0.017999999999999999 - 0.90000000000000002, 0.20000000000000001, 0.40000000000000002) self.currPoly = self.loadingBarRoot.attachNewNode( self.stepCard.generate()) if not self.debugMode: self.loadingBar.setSx( (self.overallPercent / self.loadScale) * 3.3999999999999999) if self.overallPercent > 0: self.loadingPlank.show() base.eventMgr.doEvents() base.graphicsEngine.renderFrame() return Task.cont def hide(self, reallyHide=not (config.GetInt('loading-screen', 0) == 2)): if not self.state: return None if not reallyHide: if not self.analyzeMode: self.loadingEnd = globalClock.getRealTime() self.accept('shift', self.hide, extraArgs=[1]) self.enterToContinue.show() self.generateAnalysis() return None self.cleanupLoadingScreen() if self.debugMode: self.enterToContinue.hide() self.ignore('shift') self.root.hide() self.root.stash() render2d.show() render2dp.show() render.show() base.graphicsEngine.renderFrame() self.state = False self.currentTime = 0 self.locationText = None self.hintText = None self.currScreenshot = None gsg = base.win.getGsg() if gsg: gsg.setIncompleteRender(True) render.prepareScene(gsg) render2d.prepareScene(gsg) taskMgr.remove('updateLoadingScreen') self.allowLiveFlatten.clearValue() base.setTaskChainNetThreaded() if base.sfxManagerList: index = 0 while index < len(base.sfxManagerList): sfx_manager = base.sfxManagerList[index] sfx_manager.setVolume(base.options.sound_volume) index += 1 messenger.send('texture_state_changed') if base.appRunner: base.appRunner.notifyRequest('onLoadingMessagesStop') def showTarget(self, targetId=None, ocean=False, jail=False, pickapirate=False, exit=False, potionCrafting=False, benchRepair=False, shipRepair=False, cannonDefense=False, fishing=False): if base.config.GetBool('no-loading-screen', 0): return None if pickapirate: screenshot = screenShot_EnterGame elif exit: screenshot = screenShot_ExitGame elif ocean: screenshot = screenShot_Dinghy elif jail: screenshot = screenShot_Jail elif potionCrafting: screenshot = screenShot_Potions elif benchRepair: screenshot = screenShot_BenchRepair elif shipRepair: screenshot = screenShot_ShipRepair elif cannonDefense: screenshot = screenShot_CannonDefense elif fishing: screenshot = screenShot_Fishing elif base.localAvatar.style.getTutorial( ) < PiratesGlobals.TUT_GOT_CUTLASS: screenshot = screenShot_Weapon elif base.localAvatar.style.getTutorial( ) < PiratesGlobals.TUT_MET_JOLLY_ROGER: screenshot = screenShot_Cutlass elif base.cr.newsManager and base.cr.newsManager.getHoliday(21): screenshot = screenShots_WinterHolidayLocations.get(targetId) if not screenshot: screenshot = screenShots_Locations.get(targetId) else: screenshot = screenShots_Locations.get(targetId) if not screenshot: if areaType_Jungles.has_key(targetId): screenshot = random.choice(screenShots_Jungles) elif areaType_Swamps.has_key(targetId): screenshot = random.choice(screenShots_Swamps) elif areaType_Caves.has_key(targetId): screenshot = random.choice(screenShots_Caves) else: island = getParentIsland(targetId) screenshot = screenShots_Locations.get( island, [random.choice(screenShots)])[0] elif len(screenshot) > 1: screenshot = random.choice(screenshot) else: screenshot = screenshot[0] self._FancyLoadingScreen__setLoadingArt(screenshot) if pickapirate: targetName = PLocalizer.LoadingScreen_PickAPirate elif exit: targetName = None elif ocean: targetName = PLocalizer.LoadingScreen_Ocean elif jail: targetName = PLocalizer.LoadingScreen_Jail else: targetName = PLocalizer.LocationNames.get(targetId) base.setLocationCode('Loading: %s' % targetName) if targetName is None: return None if len(targetName): self._FancyLoadingScreen__setLocationText(targetName) def _FancyLoadingScreen__setLoadingArt(self, screenshot): if self.currScreenshot: return None if self.parent and hasattr( base, 'localAvatar' ) and base.localAvatar.style.getTutorial( ) < PiratesGlobals.TUT_MET_JOLLY_ROGER and screenshot not in tutorialShots: screenshot = random.choice(tutorialShots) self.currScreenshot = loader.loadModel(screenshot).findAllTextures()[0] if not self.debugMode: self.screenshot.setTexture(self.currScreenshot) def _FancyLoadingScreen__setLocationText(self, locationText): if self.debugMode: return None self.locationText = locationText if not self.locationText: self.locationText = '' self.titlePlank.hide() if len(self.locationText) > 12: scaleFactor = len(self.locationText) / 12.0 self.titlePlankMiddle.setSx(scaleFactor) self.titlePlankRight.setX(0.215 * scaleFactor - 0.215) self.titlePlankLeft.setX(-1 * (0.215 * scaleFactor - 0.215)) else: self.titlePlankMiddle.setSx(1) self.titlePlankRight.setX(0) self.titlePlankLeft.setX(0) self.locationLabel['text'] = self.locationText if self._FancyLoadingScreen__isVisible() and len(self.locationText): self.locationLabel.show() self.titlePlank.show() else: self.locationLabel.hide() self.titlePlank.hide() launcher.setValue('gameLocation', self.locationText) def _FancyLoadingScreen__setHintText(self, hintText): self.hintText = hintText if not self.hintText: self.hintText = '' self.hintLabel['text'] = self.hintText if self._FancyLoadingScreen__isVisible(): self.hintLabel.show() def _FancyLoadingScreen__isVisible(self): return self.state def scheduleHide(self, function): base.cr.queueAllInterestsCompleteEvent() self.acceptOnce(function, self.interestComplete) def interestComplete(self): self.endStep('scheduleHide') self.hide() def _FancyLoadingScreen__setAdArt(self): return None imageFrame = self.model.find('**/frame') randomImageNumber = random.randint(0, len(screenShots) - 1) imageFileName = screenShots[randomImageNumber] self.adImage = loader.loadModel(imageFileName) self.adImage.reparentTo(imageFrame) self.adImage.setScale(2.1499999999999999 * 5, 1, 1.2 * 5) self.adImage.setPos(0, 0, 2.2999999999999998) self.adImage.setBin('fixed', 1) if randomImageNumber == 0: urlToGet = 'http://log.go.com/log?srvc=dis&guid=951C36F8-3ACD-4EB2-9F02-8E8A0A217AF5&drop=0&addata=3232:64675:408091:64675&a=0' self.httpSession = HTTPClient() self.nonBlockHTTP = self.httpSession.makeChannel(False) self.nonBlockHTTP.beginGetDocument(DocumentSpec(urlToGet)) instanceMarker = 'FunnelLoggingRequest-%s' % str( random.randint(1, 1000)) self.startCheckingAsyncRequest(instanceMarker) def startCheckingAsyncRequest(self, name): taskMgr.remove(name) taskMgr.doMethodLater(0.5, self.pollAdTask, name) def pollAdTask(self, task): result = self.nonBlockHTTP.run() if result == 0: self.stopCheckingAdTask(task) else: return Task.again def stopCheckingAdTask(self, name): taskMgr.remove(name) def cleanupLoadingScreen(self): if self.debugMode: self.loadingBarRoot.removeChildren() self.cleanupAnalysis() self.stepInfo = {} self.unmappedTicks = [] def showInfo(self, stepName, pos): self.stageLabel['text'] = stepName info = self.stepInfo[stepName] self.tickLabel['text'] = '%s ticks(%s)' % (len(info[3]), info[6]) self.overallLabel['text'] = '%3.2f seconds (%d%%)' % ( info[1], 100 * info[1] / (self.loadingEnd - self.loadingStart)) def generateAnalysis(self): if self.analyzeMode: self.cleanupAnalysis() self.analyzeMode = True cm = CardMaker('cm') self.analysisBar.show() loadingTime = self.loadingEnd - self.loadingStart for stepName in self.stepInfo: (startTime, duration, color, ticks, startPercent, percent, expectedTicks) = self.stepInfo[stepName] cm.setName(stepName) cm.setColor(color) cm.setFrame((startTime / loadingTime) * 1.8 - 0.90000000000000002, ((startTime + duration) / loadingTime) * 1.8 - 0.90000000000000002, -0.5, -0.10000000000000001) self.analysisBarRoot.attachNewNode(cm.generate()) button = DirectFrame( parent=self.analysisBarRoot, geom=NodePath('empty'), image=NodePath('empty'), state=DGG.NORMAL, relief=None, frameSize=((startTime / loadingTime) * 1.8 - 0.90000000000000002, ((startTime + duration) / loadingTime) * 1.8 - 0.90000000000000002, -0.5, -0.10000000000000001)) button.bind(DGG.ENTER, self.showInfo, extraArgs=[stepName]) self.analysisButtons.append(button) button = DirectFrame( parent=self.analysisBarRoot, geom=NodePath('empty'), image=NodePath('empty'), state=DGG.NORMAL, relief=None, frameSize=( (startPercent / self.loadScale / 100.0) * 1.8 - 0.90000000000000002, ((startPercent + percent) / self.loadScale / 100.0) * 1.8 - 0.90000000000000002, 0.10000000000000001, 0.5)) button.bind(DGG.ENTER, self.showInfo, extraArgs=[stepName]) self.analysisButtons.append(button) for tick in ticks: self.line.moveTo( VBase3((tick / loadingTime) * 1.8 - 0.90000000000000002, 0, -0.5)) self.line.drawTo( VBase3((tick / loadingTime) * 1.8 - 0.90000000000000002, 0, -0.55000000000000004)) for tick in self.unmappedTicks: self.line.moveTo( VBase3((tick / loadingTime) * 1.8 - 0.90000000000000002, 0, -0.5)) self.line.drawTo( VBase3((tick / loadingTime) * 1.8 - 0.90000000000000002, 0, -0.55000000000000004)) self.analysisSegs = self.analysisBarRoot.attachNewNode( self.line.create()) def cleanupAnalysis(self): for button in self.analysisButtons: button.destroy() self.analysisButtons = [] self.analysisBarRoot.removeChildren() self.analysisBar.hide() self.analyzeMode = False self.analysisSegs = None def adjustSize(self, window): x = max(1, window.getXSize()) y = max(1, window.getYSize()) minSz = min(x, y) aspect = float(x) / y if x > y: self.topLock.setZ(1) else: self.topLock.setZ(float(y) / x) if minSz > IDEALX: self.topLock.setScale(IDEALX / float(x)) elif minSz > IDEALY: self.topLock.setScale(IDEALY / float(y)) else: self.topLock.setScale(1.0)
class LoadingScreen(DirectObject.DirectObject): def __init__(self, parent): DirectObject.DirectObject.__init__(self) self.parent = parent self.state = False self.model = None self.wheel = None self.snapshot = None self.snapshotFrame = None self.snapshotFrameBasic = None self.currentTime = 0 self.lastUpdateTime = globalClock.getRealTime() self.locationLabel = None self.locationText = None self.hintLabel = None self.hintText = None self.adImage = None self.allowLiveFlatten = ConfigVariableBool('allow-live-flatten') self.title_art = [] self.tempVolume = [] def startLoading(self): pass def beginStep(self, stageName, amt=0, percent=0): self.update() def endStep(self, stageName): self.update() def tick(self): self.update() def destroy(self): for part in (self.model, self.snapshot): if part is not None: tex = part.findTexture('*') if tex: tex.releaseAll() part.removeNode() self.model = None self.snapshot = None if self.snapshotFrame: self.snapshotFrame.destroy() if self.snapshotFrameBasic: self.snapshotFrameBasic.destroy() if self.locationLabel: self.locationLabel.destroy() if self.hintLabel: self.hintLabel.destroy() taskMgr.remove('updateLoadingScreen') self.ignoreAll() return def showTitleFrame(self): if base.config.GetBool('no-loading-screen', 0): return for part in self.title_art: part.show() def hideTitleFrame(self): for part in self.title_art: part.hide() def show(self, waitForLocation=False, disableSfx=True, expectedLoadScale=1.0): if self.state or base.config.GetBool('no-loading-screen', 0): return self.startLoading() render.hide() self.state = True gsg = base.win.getGsg() if gsg: gsg.setIncompleteRender(False) base.setTaskChainNetNonthreaded() self.allowLiveFlatten.setValue(1) if base.config.GetBool('loading-screen-interstitial', 0): self.model = loader.loadModel('models/gui/loading_screen_interstitial') if self.model is not None: loadimage = self.model.find('**/loadimage') if loadimage is not None: loadimage.hide() else: self.model = loader.loadModel('models/gui/loading_screen') self.locationLabel = DirectLabel(parent=aspect2dp, relief=None, text='', text_font=PiratesGlobals.getPirateOutlineFont(), text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, text_scale=PiratesGuiGlobals.TextScaleTitleJumbo * 0.7, text_align=TextNode.ACenter, pos=(0.0, 0.0, -0.52), textMayChange=1) self.hintLabel = DirectLabel(parent=aspect2dp, relief=None, text='', text_font=PiratesGlobals.getPirateOutlineFont(), text_fg=PiratesGuiGlobals.TextFG1, text_shadow=PiratesGuiGlobals.TextShadow, text_scale=PiratesGuiGlobals.TextScaleTitleJumbo * 0.5, text_align=TextNode.ACenter, pos=(0.0, 0.0, -0.8), text_wordwrap=30, textMayChange=1) self.wheel = self.model.find('**/red_wheel') title_bg = self.model.find('**/title_bg') title_frame = self.model.find('**/title_frame') if base.config.GetBool('loading-screen-interstitial', 0): self.hintLabel.setPos(0.69, 0, -0.63) self.hintLabel['text_wordwrap'] = 12 self.locationLabel.setPos(-0.11, 0.0, -0.65) root = self.model.find('**/loading_screen_top') timer = self.model.find('**/timer') gear = self.model.find('**/gear') shell = self.model.find('**/shell') frame_little = self.model.find('**/frame_little') self.wheel.reparentTo(timer, 0) gear.reparentTo(timer, 1) shell.reparentTo(timer, 2) title_bg.reparentTo(root) title_frame.reparentTo(root) self.snapshotFrameBasic = DirectFrame(parent=aspect2dp, relief=DGG.FLAT, frameColor=(0.0, 0.0, 0.0, 1.0), frameSize=(-4.95, -2.5, -1.1, -2.6)) self.snapshotFrameBasic.reparentTo(root) frame_little.reparentTo(root) self.title_art.append(title_bg) self.title_art.append(title_frame) self.hideTitleFrame() if waitForLocation or self.snapshot is None: screenshot = random.choice(tutorialShots_MoveAim) self.__setLoadingArt(screenshot) if self.snapshot: self.snapshot.show() elif self.snapshot: self.snapshot.show() if self.snapshot and base.config.GetBool('loading-screen-interstitial', 0): root = self.model.find('**/loading_screen_top') frame_little = self.model.find('**/frame_little') self.snapshot.reparentTo(root, 0) frame_little.reparentTo(root, 1) self.snapshotFrame = DirectFrame(parent=aspect2dp, relief=DGG.FLAT, frameColor=(0.0, 0.0, 0.0, 1.0), frameSize=(-2.0, 2.0, 2.0, -2.0)) self.snapshotFrame.setBin('fixed', 0) self.model.reparentTo(aspect2dp, DGG.NO_FADE_SORT_INDEX) self.locationLabel.reparentTo(aspect2dp, DGG.NO_FADE_SORT_INDEX) self.hintLabel.reparentTo(aspect2dp, DGG.NO_FADE_SORT_INDEX) if base.config.GetBool('loading-screen-interstitial', 0): self.model.setScale(0.22, 0.22, 0.22) self.model.setPos(0.0, 0.0, -0.3) else: self.model.setScale(0.25, 0.25, 0.25) self.model.setPos(0.0, 0.0, -0.15) if self.locationText and len(self.locationText): self.__setLocationText(self.locationText) if self.hintText is not None: if len(self.hintText): self.__setHintText(self.hintText) if base.config.GetBool('want-ad-reporting', 0) and base.config.GetBool('loading-screen-interstitial', 0): self.__setAdArt() base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() base.refreshAds() taskMgr.add(self.update, 'updateLoadingScreen', priority=-100) if base.sfxManagerList and disableSfx: index = 0 while index < len(base.sfxManagerList): sfx_manager = base.sfxManagerList[index] sfx_manager.setVolume(0.0) index += 1 if base.appRunner: base.appRunner.notifyRequest('onLoadingMessagesStart') return def showHint(self, destId=None, ocean=False): if base.config.GetBool('no-loading-screen', 0): return if ocean: hint = getOceanHint() else: if hasattr(base, 'localAvatar'): totalReputation = 0 level = base.localAvatar.getLevel() if totalReputation: hint = getHint(destId, level) else: hint = getHint(destId) else: hint = getHint() shipPVPIslands = [ '1196970035.53sdnaik', '1196970080.56sdnaik'] if destId in shipPVPIslands or ocean and base.localAvatar.getCurrentIsland() in shipPVPIslands: hint = getPrivateeringHint() if base.localAvatar.style.getTutorial() == PiratesGlobals.TUT_MET_JOLLY_ROGER: hint = '%s: %s' % (PLocalizer.LoadingScreen_Hint, PLocalizer.GeneralTip7) self.__setHintText(hint) def update(self, task=None): if not self.state: return Task.cont realTime = globalClock.getRealTime() if realTime - self.lastUpdateTime < 0.1: return Task.cont self.currentTime += min(10, (realTime - self.lastUpdateTime) * 250) self.lastUpdateTime = realTime self.wheel.setR(-self.currentTime) base.graphicsEngine.renderFrame() return Task.cont def hide(self): if not self.state: return render.show() base.graphicsEngine.renderFrame() self.state = False self.currentTime = 0 self.locationText = None self.hintText = None gsg = base.win.getGsg() if gsg: gsg.setIncompleteRender(True) render.prepareScene(gsg) render2d.prepareScene(gsg) for part in (self.model, self.snapshot): if part: tex = part.findTexture('*') if tex: tex.releaseAll() part.removeNode() self.model = None self.snapshot = None if self.adImage: self.adImage = None if self.snapshotFrame: self.snapshotFrame.destroy() if self.locationLabel: self.locationLabel.destroy() if self.hintLabel: self.hintLabel.destroy() taskMgr.remove('updateLoadingScreen') self.allowLiveFlatten.clearValue() base.setTaskChainNetThreaded() if base.sfxManagerList: index = 0 while index < len(base.sfxManagerList): sfx_manager = base.sfxManagerList[index] sfx_manager.setVolume(base.options.sound_volume) index += 1 messenger.send('texture_state_changed') if base.appRunner: base.appRunner.notifyRequest('onLoadingMessagesStop') return def showTarget(self, targetId=None, ocean=False, jail=False, pickapirate=False, exit=False, potionCrafting=False, benchRepair=False, shipRepair=False, cannonDefense=False, fishing=False): if base.config.GetBool('no-loading-screen', 0): return if pickapirate: screenshot = screenShot_EnterGame elif exit: screenshot = screenShot_ExitGame elif ocean: screenshot = screenShot_Dinghy elif jail: screenshot = screenShot_Jail elif potionCrafting: screenshot = screenShot_Potions elif benchRepair: screenshot = screenShot_BenchRepair elif shipRepair: screenshot = screenShot_ShipRepair elif cannonDefense: screenshot = screenShot_CannonDefense elif fishing: screenshot = screenShot_Fishing elif base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_GOT_CUTLASS: screenshot = screenShot_Weapon elif base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_MET_JOLLY_ROGER: screenshot = screenShot_Cutlass elif base.cr.newsManager: if base.cr.newsManager.getHoliday(21): screenshot = screenShots_WinterHolidayLocations.get(targetId) if not screenshot: screenshot = screenShots_Locations.get(targetId) else: screenshot = screenShots_Locations.get(targetId) if not screenshot: if areaType_Jungles.has_key(targetId): screenshot = random.choice(screenShots_Jungles) elif areaType_Swamps.has_key(targetId): screenshot = random.choice(screenShots_Swamps) elif areaType_Caves.has_key(targetId): screenshot = random.choice(screenShots_Caves) else: island = getParentIsland(targetId) screenshot = screenShots_Locations.get(island, [random.choice(screenShots)])[0] if isinstance(screenshot, list): screenshot = random.choice(screenshot) self.__setLoadingArt(screenshot) if pickapirate: targetName = PLocalizer.LoadingScreen_PickAPirate elif exit: targetName = None elif ocean: targetName = PLocalizer.LoadingScreen_Ocean elif jail: targetName = PLocalizer.LoadingScreen_Jail else: targetName = PLocalizer.LocationNames.get(targetId) base.setLocationCode('Loading: %s' % targetName) if targetName is None: return if len(targetName): self.__setLocationText(targetName) def __setLoadingArt(self, screenshot): if self.snapshot: return if hasattr(base, 'localAvatar') and base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_MET_JOLLY_ROGER and screenshot not in tutorialShots: screenshot = random.choice(tutorialShots) self.snapshot = loader.loadModel(screenshot) if self.snapshot: if base.config.GetBool('loading-screen-interstitial', 0): self.snapshot.setScale(2.35, 1.0, 1.3) self.snapshot.setPos(-3.74, 0, -1.83) if self.model is not None: root = self.model.find('**/loading_screen_top') frame_little = self.model.find('**/frame_little') self.snapshot.reparentTo(root, 0) frame_little.reparentTo(root, 1) else: self.snapshot.reparentTo(aspect2dp, DGG.NO_FADE_SORT_INDEX) self.snapshot.setScale(2.15, 1, 1.2) self.snapshot.setPos(0.0, 0.0, 0.09) self.snapshot.setBin('fixed', 1) self.__isVisible() or self.snapshot.hide() def __setLocationText(self, locationText): self.locationText = locationText if self.__isVisible(): self.locationLabel['text'] = locationText self.locationLabel.show() self.showTitleFrame() launcher.setValue('gameLocation', self.locationText) def __setHintText(self, hintText): self.hintText = hintText if self.__isVisible(): self.hintLabel['text'] = hintText self.hintLabel.show() def __isVisible(self): return self.state def scheduleHide(self, function): base.cr.queueAllInterestsCompleteEvent() self.acceptOnce(function, self.hide) def __setAdArt(self): imageFrame = self.model.find('**/frame') randomImageNumber = random.randint(0, len(screenShots) - 1) imageFileName = screenShots[randomImageNumber] self.adImage = loader.loadModel(imageFileName) self.adImage.reparentTo(imageFrame) self.adImage.setScale(2.15 * 5, 1, 1.2 * 5) self.adImage.setPos(0, 0, 2.3) self.adImage.setBin('fixed', 1) if randomImageNumber == 0: urlToGet = 'http://log.go.com/log?srvc=dis&guid=951C36F8-3ACD-4EB2-9F02-8E8A0A217AF5&drop=0&addata=3232:64675:408091:64675&a=0' self.httpSession = HTTPClient() self.nonBlockHTTP = self.httpSession.makeChannel(False) self.nonBlockHTTP.beginGetDocument(DocumentSpec(urlToGet)) instanceMarker = 'FunnelLoggingRequest-%s' % str(random.randint(1, 1000)) self.startCheckingAsyncRequest(instanceMarker) def startCheckingAsyncRequest(self, name): taskMgr.remove(name) taskMgr.doMethodLater(0.5, self.pollAdTask, name) def pollAdTask(self, task): result = self.nonBlockHTTP.run() if result == 0: self.stopCheckingAdTask(task) else: return Task.again def stopCheckingAdTask(self, name): taskMgr.remove(name)
class LoadingScreen(DirectObject.DirectObject): def __init__(self, parent): DirectObject.DirectObject.__init__(self) self.parent = parent self.state = False self.model = None self.wheel = None self.snapshot = None self.snapshotFrame = None self.snapshotFrameBasic = None self.currentTime = 0 self.lastUpdateTime = globalClock.getRealTime() self.locationLabel = None self.locationText = None self.hintLabel = None self.hintText = None self.adImage = None self.allowLiveFlatten = ConfigVariableBool('allow-live-flatten') self.title_art = [] self.tempVolume = [] def startLoading(self): pass def beginStep(self, stageName, amt = 0, percent = 0): self.update() def endStep(self, stageName): self.update() def tick(self): self.update() def destroy(self): for part in (self.model, self.snapshot): if part is not None: tex = part.findTexture('*') if tex: tex.releaseAll() part.removeNode() continue self.model = None self.snapshot = None if self.snapshotFrame: self.snapshotFrame.destroy() if self.snapshotFrameBasic: self.snapshotFrameBasic.destroy() if self.locationLabel: self.locationLabel.destroy() if self.hintLabel: self.hintLabel.destroy() taskMgr.remove('updateLoadingScreen') self.ignoreAll() def showTitleFrame(self): if base.config.GetBool('no-loading-screen', 0): return None for part in self.title_art: part.show() def hideTitleFrame(self): for part in self.title_art: part.hide() def show(self, waitForLocation = False, disableSfx = True, expectedLoadScale = 1.0): if self.state or base.config.GetBool('no-loading-screen', 0): return None self.startLoading() render.hide() self.state = True gsg = base.win.getGsg() if gsg: gsg.setIncompleteRender(False) base.setTaskChainNetNonthreaded() self.allowLiveFlatten.setValue(1) if self.parent and base.cr.isPaid() == OTPGlobals.AccessVelvetRope and base.config.GetBool('loading-screen-interstitial', 0): self.model = loader.loadModel('models/gui/loading_screen_interstitial') if self.model is not None: loadimage = self.model.find('**/loadimage') if loadimage is not None: loadimage.hide() else: self.model = loader.loadModel('models/gui/loading_screen') self.locationLabel = DirectLabel(parent = aspect2dp, relief = None, text = '', text_font = PiratesGlobals.getPirateOutlineFont(), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_scale = PiratesGuiGlobals.TextScaleTitleJumbo * 0.69999999999999996, text_align = TextNode.ACenter, pos = (0.0, 0.0, -0.52000000000000002), textMayChange = 1) self.hintLabel = DirectLabel(parent = aspect2dp, relief = None, text = '', text_font = PiratesGlobals.getPirateOutlineFont(), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_scale = PiratesGuiGlobals.TextScaleTitleJumbo * 0.5, text_align = TextNode.ACenter, pos = (0.0, 0.0, -0.80000000000000004), text_wordwrap = 30, textMayChange = 1) self.wheel = self.model.find('**/red_wheel') title_bg = self.model.find('**/title_bg') title_frame = self.model.find('**/title_frame') if self.parent and base.cr.isPaid() == OTPGlobals.AccessVelvetRope and base.config.GetBool('loading-screen-interstitial', 0): self.hintLabel.setPos(0.68999999999999995, 0, -0.63) self.hintLabel['text_wordwrap'] = 12 self.locationLabel.setPos(-0.11, 0.0, -0.65000000000000002) root = self.model.find('**/loading_screen_top') timer = self.model.find('**/timer') gear = self.model.find('**/gear') shell = self.model.find('**/shell') frame_little = self.model.find('**/frame_little') self.wheel.reparentTo(timer, 0) gear.reparentTo(timer, 1) shell.reparentTo(timer, 2) title_bg.reparentTo(root) title_frame.reparentTo(root) self.snapshotFrameBasic = DirectFrame(parent = aspect2dp, relief = DGG.FLAT, frameColor = (0.0, 0.0, 0.0, 1.0), frameSize = (-4.9500000000000002, -2.5, -1.1000000000000001, -2.6000000000000001)) self.snapshotFrameBasic.reparentTo(root) frame_little.reparentTo(root) self.title_art.append(title_bg) self.title_art.append(title_frame) self.hideTitleFrame() if not waitForLocation: if self.snapshot is None: screenshot = random.choice(tutorialShots_MoveAim) self._LoadingScreen__setLoadingArt(screenshot) if self.snapshot: self.snapshot.show() elif self.snapshot: self.snapshot.show() if self.parent and self.snapshot and base.cr.isPaid() == OTPGlobals.AccessVelvetRope and base.config.GetBool('loading-screen-interstitial', 0): root = self.model.find('**/loading_screen_top') frame_little = self.model.find('**/frame_little') self.snapshot.reparentTo(root, 0) frame_little.reparentTo(root, 1) self.snapshotFrame = DirectFrame(parent = aspect2dp, relief = DGG.FLAT, frameColor = (0.0, 0.0, 0.0, 1.0), frameSize = (-2.0, 2.0, 2.0, -2.0)) self.snapshotFrame.setBin('fixed', 0) self.model.reparentTo(aspect2dp, NO_FADE_SORT_INDEX) self.locationLabel.reparentTo(aspect2dp, NO_FADE_SORT_INDEX) self.hintLabel.reparentTo(aspect2dp, NO_FADE_SORT_INDEX) if self.parent and base.cr.isPaid() == OTPGlobals.AccessVelvetRope and base.config.GetBool('loading-screen-interstitial', 0): self.model.setScale(0.22, 0.22, 0.22) self.model.setPos(0.0, 0.0, -0.29999999999999999) else: self.model.setScale(0.25, 0.25, 0.25) self.model.setPos(0.0, 0.0, -0.14999999999999999) if self.locationText and len(self.locationText): self._LoadingScreen__setLocationText(self.locationText) if self.hintText is not None: if len(self.hintText): self._LoadingScreen__setHintText(self.hintText) if self.parent and base.cr.isPaid() == OTPGlobals.AccessVelvetRope and base.config.GetBool('want-ad-reporting', 0) and base.config.GetBool('loading-screen-interstitial', 0): self._LoadingScreen__setAdArt() base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() base.refreshAds() taskMgr.add(self.update, 'updateLoadingScreen', priority = -100) if base.sfxManagerList and disableSfx: index = 0 while index < len(base.sfxManagerList): sfx_manager = base.sfxManagerList[index] sfx_manager.setVolume(0.0) index += 1 if base.appRunner: base.appRunner.notifyRequest('onLoadingMessagesStart') def showHint(self, destId = None, ocean = False): if base.config.GetBool('no-loading-screen', 0): return None if ocean: hint = getOceanHint() elif hasattr(base, 'localAvatar'): totalReputation = 0 level = base.localAvatar.getLevel() if totalReputation: hint = getHint(destId, level) else: hint = getHint(destId) else: hint = getHint() shipPVPIslands = [ '1196970035.53sdnaik', '1196970080.56sdnaik'] if (destId in shipPVPIslands or ocean) and base.localAvatar.getCurrentIsland() in shipPVPIslands: hint = getPrivateeringHint() if self.parent and base.localAvatar.style.getTutorial() == PiratesGlobals.TUT_MET_JOLLY_ROGER: hint = '%s: %s' % (PLocalizer.LoadingScreen_Hint, PLocalizer.GeneralTip7) self._LoadingScreen__setHintText(hint) def update(self, task = None): if not self.state: return Task.cont realTime = globalClock.getRealTime() if realTime - self.lastUpdateTime < 0.10000000000000001: return Task.cont self.currentTime += min(10, (realTime - self.lastUpdateTime) * 250) self.lastUpdateTime = realTime self.wheel.setR(-(self.currentTime)) base.graphicsEngine.renderFrame() return Task.cont def hide(self): if not self.state: return None render.show() base.graphicsEngine.renderFrame() self.state = False self.currentTime = 0 self.locationText = None self.hintText = None gsg = base.win.getGsg() if gsg: gsg.setIncompleteRender(True) render.prepareScene(gsg) render2d.prepareScene(gsg) for part in (self.model, self.snapshot): if part: tex = part.findTexture('*') if tex: tex.releaseAll() part.removeNode() continue self.model = None self.snapshot = None if self.adImage: self.adImage = None if self.snapshotFrame: self.snapshotFrame.destroy() if self.locationLabel: self.locationLabel.destroy() if self.hintLabel: self.hintLabel.destroy() taskMgr.remove('updateLoadingScreen') self.allowLiveFlatten.clearValue() base.setTaskChainNetThreaded() if base.sfxManagerList: index = 0 while index < len(base.sfxManagerList): sfx_manager = base.sfxManagerList[index] sfx_manager.setVolume(base.options.sound_volume) index += 1 messenger.send('texture_state_changed') if base.appRunner: base.appRunner.notifyRequest('onLoadingMessagesStop') def showTarget(self, targetId = None, ocean = False, jail = False, pickapirate = False, exit = False, potionCrafting = False, benchRepair = False, shipRepair = False, cannonDefense = False): if base.config.GetBool('no-loading-screen', 0): return None if pickapirate: screenshot = screenShot_EnterGame self.setLoadingScreenShot(screenshot) elif exit: screenshot = screenShot_ExitGame self.setLoadingScreenShot(screenshot) elif ocean: screenshot = screenShot_Dinghy self.setLoadingScreenShot(screenshot) elif jail: screenshot = screenShot_Jail self.setLoadingScreenShot(screenshot) elif potionCrafting: screenshot = screenShot_Potions self.setLoadingScreenShot(screenshot) elif benchRepair: screenshot = screenShot_BenchRepair self.setLoadingScreenShot(screenshot) elif shipRepair: screenshot = screenShot_ShipRepair self.setLoadingScreenShot(screenshot) elif cannonDefense: screenshot = screenShot_CannonDefense self.setLoadingScreenShot(screenshot) elif base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_GOT_CUTLASS: screenshot = screenShot_Weapon self.setLoadingScreenShot(screenshot) elif base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_MET_JOLLY_ROGER: screenshot = screenShot_Cutlass self.setLoadingScreenShot(screenshot) elif base.cr.newsManager and base.cr.newsManager.getHoliday(21): screenshot = screenShots_WinterHolidayLocations.get(targetId) self.setLoadingScreenShot(screenshot) if not screenshot: screenshot = screenShots_Locations.get(targetId) self.setLoadingScreenShot(screenshot) else: screenshot = screenShots_Locations.get(targetId) self.setLoadingScreenShot(screenshot) if not screenshot: if areaType_Jungles.has_key(targetId): screenshot = random.choice(screenShots_Jungles) self.setLoadingScreenShot(screenshot) elif areaType_Swamps.has_key(targetId): screenshot = random.choice(screenShots_Swamps) self.setLoadingScreenShot(screenshot) elif areaType_Caves.has_key(targetId): screenshot = random.choice(screenShots_Caves) self.setLoadingScreenShot(screenshot) else: island = getParentIsland(targetId) screenshot = screenShots_Locations.get(island, [ random.choice(screenShots)])[0] self.setLoadingScreenShot(screenshot) elif len(screenshot) > 1: screenshot = random.choice(screenshot) self.setLoadingScreenShot(screenshot) else: screenshot = screenshot[0] self.setLoadingScreenShot(screenshot) if pickapirate: targetName = PLocalizer.LoadingScreen_PickAPirate elif exit: targetName = None elif ocean: targetName = PLocalizer.LoadingScreen_Ocean elif jail: targetName = PLocalizer.LoadingScreen_Jail else: targetName = PLocalizer.LocationNames.get(targetId) base.setLocationCode('Loading: %s' % targetName) if targetName is None: return None if len(targetName): self._LoadingScreen__setLocationText(targetName) def setLoadingScreenShot(self, screenshot): if not screenshot: return self._LoadingScreen__setLoadingArt(screenshot) def _LoadingScreen__setLoadingArt(self, screenshot): if self.snapshot: return None if self.parent and hasattr(base, 'localAvatar') and base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_MET_JOLLY_ROGER and screenshot not in tutorialShots: screenshot = random.choice(tutorialShots) self.snapshot = loader.loadModel(screenshot) if self.snapshot: if self.parent and base.cr.isPaid() == OTPGlobals.AccessVelvetRope and base.config.GetBool('loading-screen-interstitial', 0): self.snapshot.setScale(2.3500000000000001, 1.0, 1.3) self.snapshot.setPos(-3.7400000000000002, 0, -1.8300000000000001) if self.model is not None: root = self.model.find('**/loading_screen_top') frame_little = self.model.find('**/frame_little') self.snapshot.reparentTo(root, 0) frame_little.reparentTo(root, 1) else: self.snapshot.reparentTo(aspect2dp, NO_FADE_SORT_INDEX) self.snapshot.setScale(2.1499999999999999, 1, 1.2) self.snapshot.setPos(0.0, 0.0, 0.089999999999999997) self.snapshot.setBin('fixed', 1) if not self._LoadingScreen__isVisible(): self.snapshot.hide() def _LoadingScreen__setLocationText(self, locationText): self.locationText = locationText if self._LoadingScreen__isVisible(): self.locationLabel['text'] = locationText self.locationLabel.show() self.showTitleFrame() launcher.setValue('gameLocation', self.locationText) def _LoadingScreen__setHintText(self, hintText): self.hintText = hintText if self._LoadingScreen__isVisible(): self.hintLabel['text'] = hintText self.hintLabel.show() def _LoadingScreen__isVisible(self): return self.state def scheduleHide(self, function): base.cr.queueAllInterestsCompleteEvent() self.acceptOnce(function, self.hide) def _LoadingScreen__setAdArt(self): imageFrame = self.model.find('**/frame') randomImageNumber = random.randint(0, len(screenShots) - 1) imageFileName = screenShots[randomImageNumber] self.adImage = loader.loadModel(imageFileName) self.adImage.reparentTo(imageFrame) self.adImage.setScale(2.1499999999999999 * 5, 1, 1.2 * 5) self.adImage.setPos(0, 0, 2.2999999999999998) self.adImage.setBin('fixed', 1) if randomImageNumber == 0: urlToGet = 'http://log.go.com/log?srvc=dis&guid=951C36F8-3ACD-4EB2-9F02-8E8A0A217AF5&drop=0&addata=3232:64675:408091:64675&a=0' self.httpSession = HTTPClient() self.nonBlockHTTP = self.httpSession.makeChannel(False) self.nonBlockHTTP.beginGetDocument(DocumentSpec(urlToGet)) instanceMarker = 'FunnelLoggingRequest-%s' % str(random.randint(1, 1000)) self.startCheckingAsyncRequest(instanceMarker) def startCheckingAsyncRequest(self, name): taskMgr.remove(name) taskMgr.doMethodLater(0.5, self.pollAdTask, name) def pollAdTask(self, task): result = self.nonBlockHTTP.run() if result == 0: self.stopCheckingAdTask(task) else: return Task.again def stopCheckingAdTask(self, name): taskMgr.remove(name)
class UserFunnel: def __init__(self): self.hitboxAcct = 'DM53030620EW' self.language = 'en-us' self.cgRoot = 'ToonTown_Online' self.cgBeta = 'Beta' self.cgRelease = 'Release' self.cgLocation = 'US' self.campaignID = '' self.cfCookieFile = 'cf.txt' self.dynamicVRFunnel = 'http://download.toontown.com/' self.hostDict = {0: 'Internal Disney PHP Collector Site', 1: 'ehg-dig.hitbox.com/HG?', 2: 'ehg-dig.hitbox.com/HG?', 3: 'build64.online.disney.com:5020/index.php?'} self.CurrentHost = '' self.URLtoSend = '' self.gameName = 'ToonTown' self.browserName = 'Panda3D%20(' + self.gameName + ';%20' + sys.platform + ')' self.HTTPUserHeader = [('User-agent', 'Panda3D')] self.osMajorver = '' self.osMinorver = '' self.osRevver = '' self.osBuild = '' self.osType = '' self.osComments = '' self.msWinTypeDict = {0: 'Win32s on Windows 3.1', 1: 'Windows 95/98/ME', 2: 'Windows NT/2000/XP', 3: 'Windows CE'} self.milestoneDict = {0: 'New User', 1: 'Create Account', 2: 'View EULA', 3: 'Accept EULA', 4: 'Download Start', 5: 'Download End', 6: 'Installer Run', 7: 'Launcher Start', 8: 'Launcher Login', 9: 'Client Opens', 10: 'Create Pirate Loads', 11: 'Create Pirate Exit', 12: 'Cutscene One Start', 13: 'Cutscene One Ends', 14: 'Cutscene Two Start', 15: 'Cutscene Thee Start', 16: 'Cutscene Three Ends', 17: 'Access Cannon', 18: 'Cutscene Four Starts', 19: 'Cutscene Four Ends', 20: 'Dock - Start Game'} self.macTypeDict = {2: 'Jaguar', 1: 'Puma', 3: 'Panther', 4: 'Tiger', 5: 'Lepard'} self.milestone = '' self.pandaHTTPClientVarWSS = [] self.pandaHTTPClientVarCTG = [] self.pandaHTTPClientVarDM = [] self.checkForCFfile() self.httpSession = HTTPClient() self.whatOSver() def checkForCFfile(self): if firstRun(): pass elif not os.path.isfile(self.cfCookieFile): firstRun('write', True) def whatOSver(self): if sys.platform == 'win32': self.osMajorver = str(sys.getwindowsversion()[0]) self.osMinorver = str(sys.getwindowsversion()[1]) self.osBuild = str(sys.getwindowsversion()[2]) self.osType = str(sys.getwindowsversion()[3]) self.osComments = str(sys.getwindowsversion()[4]) return if sys.platform == 'darwin': self.osMajorver = '10' osxcmd = '/usr/sbin/system_profiler SPSoftwareDataType |/usr/bin/grep "System Version"' infopipe = os.popen(osxcmd, 'r') parseLine = infopipe.read() infopipe.close() del infopipe notify.info('parseLine = %s' % str(parseLine)) versionStringStart = parseLine.find('10.') notify.info('versionStringStart = %s' % str(versionStringStart)) testPlist = False try: self.osMinorver = parseLine[versionStringStart + 3] self.osRevver = parseLine[versionStringStart + 5:versionStringStart + 7].strip(' ') self.osBuild = parseLine[int(parseLine.find('(')) + 1:parseLine.find(')')] except: notify.info("couldn't parse the system_profiler output, using zeros") self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' testPlist = True del versionStringStart del parseLine del osxcmd if testPlist: try: import plistlib pl = plistlib.readPlist('/System/Library/CoreServices/SystemVersion.plist') notify.info('pl=%s' % str(pl)) parseLine = pl['ProductVersion'] numbers = parseLine.split('.') notify.info('parseline =%s numbers =%s' % (parseLine, numbers)) self.osMinorver = numbers[1] self.osRevver = numbers[2] self.osBuild = pl['ProductBuildVersion'] except: notify.info('tried plist but still got exception') self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' return def setmilestone(self, ms): if not firstRun(): self.milestone = ms else: self.milestone = '%s_INITIAL' % ms def setgamename(self, gamename): self.gameName = gamename def printosComments(self): return self.osComments def setHost(self, hostID): self.CurrentHost = hostID def getFunnelURL(self): if patcherVer() == ['OFFLINE']: return if not 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 isVarSet(self, varInQuestion): try: tempvar = type(varInQuestion) return 1 except NameError: return 0 def buildURL(self): if sys.platform == 'win32': hitboxOSType = 'c3' else: hitboxOSType = 'c4' if self.CurrentHost == 1: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str(self.hitboxAcct) + '&n=' + str(self.milestone) + '&ln=' + self.language + '&gp=STARTGAME&fnl=TOONTOWN_FUNNEL&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str(vconGroup()) + '&c1=' + str(sys.platform) + '&' + str(hitboxOSType) + '=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) if self.CurrentHost == 2: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str(self.hitboxAcct) + '&n=' + str(self.milestone) + '&ln=' + self.language + '&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str(vconGroup()) + '&c1=' + str(sys.platform) + '&' + str(hitboxOSType) + '=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) if self.CurrentHost == 0: localMAC = str(getMAC()) self.URLtoSend = str(self.dynamicVRFunnel) + '?funnel=' + str(self.milestone) + '&platform=' + str(sys.platform) + '&sysver=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) + '&mac=' + localMAC + '&username='******'&id=' + str(loggingAvID()) def readInPandaCookie(self): thefile = open(self.cfCookieFile, 'r') thedata = thefile.read().split('\n') thefile.close() del thefile if thedata[0].find('Netscape HTTP Cookie File') != -1: return thedata.pop() try: while thedata: temp = thedata.pop() temp = temp.split('\t') domain = temp[0] loc = temp[1] variable = temp[2] value = temp[3] if variable == 'CTG': self.pandaHTTPClientVarCTG = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarCTG) if variable == self.hitboxAcct + 'V6': self.pandaHTTPClientVarDM = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarDM) if variable == 'WSS_GW': self.pandaHTTPClientVarWSS = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarWSS) except IndexError: print 'UserFunnel(Warning): Cookie Data file bad' del thedata def updateInstanceCookieValues(self): a = self.httpSession.getCookie(HTTPCookie('WSS_GW', '/', '.hitbox.com')) if a.getName(): self.pandaHTTPClientVarWSS = ['.hitbox.com', '/', 'WSS_GW', a.getValue()] b = self.httpSession.getCookie(HTTPCookie('CTG', '/', '.hitbox.com')) if b.getName(): self.pandaHTTPClientVarCTG = ['.hitbox.com', '/', 'CTG', b.getValue()] c = self.httpSession.getCookie(HTTPCookie(self.hitboxAcct + 'V6', '/', 'ehg-dig.hitbox.com')) if c.getName(): self.pandaHTTPClientVarDM = ['ehg-dig.hitbox.com', '/', self.hitboxAcct + 'V6', c.getValue()] del a del b del c def setTheHTTPCookie(self, cookieParams): c = HTTPCookie(cookieParams[2], cookieParams[1], cookieParams[0]) c.setValue(cookieParams[3]) self.httpSession.setCookie(c) def writeOutPandaCookie(self): try: thefile = open(self.cfCookieFile, 'w') if len(self.pandaHTTPClientVarWSS) == 4: thefile.write(self.pandaHTTPClientVarWSS[0] + '\t' + self.pandaHTTPClientVarWSS[1] + '\t' + self.pandaHTTPClientVarWSS[2] + '\t' + self.pandaHTTPClientVarWSS[3] + '\n') if len(self.pandaHTTPClientVarCTG) == 4: thefile.write(self.pandaHTTPClientVarCTG[0] + '\t' + self.pandaHTTPClientVarCTG[1] + '\t' + self.pandaHTTPClientVarCTG[2] + '\t' + self.pandaHTTPClientVarCTG[3] + '\n') if len(self.pandaHTTPClientVarDM) == 4: thefile.write(self.pandaHTTPClientVarDM[0] + '\t' + self.pandaHTTPClientVarDM[1] + '\t' + self.pandaHTTPClientVarDM[2] + '\t' + self.pandaHTTPClientVarDM[3] + '\n') thefile.close() except IOError: return def prerun(self): self.getFunnelURL() self.buildURL() if os.path.isfile(self.cfCookieFile): if self.CurrentHost == 1 or self.CurrentHost == 2: self.readInPandaCookie() def run(self): if self.CurrentHost == 0 and patcherVer() == ['OFFLINE']: return self.nonBlock = self.httpSession.makeChannel(False) self.nonBlock.beginGetDocument(DocumentSpec(self.URLtoSend)) instanceMarker = str(random.randint(1, 1000)) instanceMarker = 'FunnelLoggingRequest-%s' % instanceMarker self.startCheckingAsyncRequest(instanceMarker) def startCheckingAsyncRequest(self, name): taskMgr.remove(name) taskMgr.doMethodLater(0.5, self.pollFunnelTask, name) def stopCheckingFunnelTask(self, name): taskMgr.remove('pollFunnelTask') def pollFunnelTask(self, task): result = self.nonBlock.run() if result == 0: self.stopCheckingFunnelTask(task) if self.CurrentHost == 1 or self.CurrentHost == 2: self.updateInstanceCookieValues() self.writeOutPandaCookie() else: return Task.again
class UserFunnel: def __init__(self): self.hitboxAcct = 'DM560804E8WD' self.omniAccount = 'wdgdolpironl,wdgdsec' self.language = 'en-us' self.cgRoot = 'Pirates_Online' self.cgBeta = 'Beta' self.cgRelease = 'Release' self.cgLocation = 'US' self.ogBeta = 'pir_onl_beta' self.ogRelease = 'pir_onl' self.ogLocation = 'us' self.campaignID = '' self.cfCookieFile = 'cf.txt' self.cfCookieFileOmniture = 'cf2.txt' self.dynamicVRFunnel = 'http://download.pirates.com/' self.hostDict = { 0: 'Internal Disney PHP Collector Site', 1: 'ehg-dig.hitbox.com/HG?', 2: 'ehg-dig.hitbox.com/HG?', 3: 'w88.go.com/b/ss/' } self.CurrentHost = '' self.URLtoSend = '' self.gameName = 'Pirates' self.browserName = 'Panda3D%20(' + self.gameName + ';%20' + sys.platform + ')' self.HTTPUserHeader = [('User-agent', 'Panda3D')] self.osMajorver = '' self.osMinorver = '' self.osRevver = '' self.osBuild = '' self.osType = '' self.osComments = '' self.msWinTypeDict = { 0: 'Win32s on Windows 3.1', 1: 'Windows 95/98/ME', 2: 'Windows NT/2000/XP', 3: 'Windows CE' } self.milestoneDict = { 0: 'New User', 1: 'Create Account', 2: 'View EULA', 3: 'Accept EULA', 4: 'Download Start', 5: 'Download End', 6: 'Installer Run', 7: 'Launcher Start', 8: 'Launcher Login', 9: 'Client Opens', 10: 'Create Pirate Loads', 11: 'Create Pirate Exit', 12: 'Cutscene One Start', 13: 'Cutscene One Ends', 14: 'Cutscene Two Start', 15: 'Cutscene Thee Start', 16: 'Cutscene Three Ends', 17: 'Access Cannon', 18: 'Cutscene Four Starts', 19: 'Cutscene Four Ends', 20: 'Dock - Start Game' } self.macTypeDict = { 2: 'Jaguar', 1: 'Puma', 3: 'Panther', 4: 'Tiger', 5: 'Lepard' } self.milestone = '' self.pandaHTTPClientVarWSS = [] self.pandaHTTPClientVarCTG = [] self.pandaHTTPClientVarDM = [] self.pandaHTTPClientVarSVI = [] self.checkForCFfile() self.httpSession = HTTPClient() self.whatOSver() def checkForCFfile(self): if firstRun() == True: pass 1 if os.path.isfile(self.cfCookieFile) == False: firstRun('write', True) def whatOSver(self): if sys.platform == 'win32': self.osMajorver = str(sys.getwindowsversion()[0]) self.osMinorver = str(sys.getwindowsversion()[1]) self.osBuild = str(sys.getwindowsversion()[2]) self.osType = str(sys.getwindowsversion()[3]) self.osComments = str(sys.getwindowsversion()[4]) elif sys.platform == 'darwin': self.osMajorver = '10' osxcmd = '/usr/sbin/system_profiler SPSoftwareDataType |/usr/bin/grep "System Version"' infopipe = os.popen(osxcmd, 'r') parseLine = infopipe.read() infopipe.close() del infopipe versionStringStart = parseLine.find('10.') try: self.osMinorver = parseLine[versionStringStart + 3] self.osRevver = parseLine[versionStringStart + 5:versionStringStart + 7].strip(' ') self.osBuild = parseLine[int(parseLine.find('(')) + 1:parseLine.find(')')] except: self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' del versionStringStart del parseLine del osxcmd elif sys.platform == 'linux2': self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' def setmilestone(self, ms): if firstRun() == False: self.milestone = ms else: self.milestone = '%s_INITIAL' % ms def setgamename(self, gamename): self.gameName = gamename def printosComments(self): return self.osComments def setHost(self, hostID): self.CurrentHost = hostID def getFunnelURL(self): if patcherVer() == ['OFFLINE']: return None if patcherVer() == []: patcherHTTP = HTTPClient() if checkParamFile() == None: patcherDoc = patcherHTTP.getDocument( URLSpec( 'http://download.piratesonline.com/english/currentVersion/content/patcher.ver' )) vconGroup('w', self.cgRelease) oconGroup('w', self.ogRelease) else: patcherDoc = patcherHTTP.getDocument(URLSpec(checkParamFile())) vconGroup('w', self.cgBeta) oconGroup('w', self.ogBeta) rf = Ramfile() patcherDoc.downloadToRam(rf) self.patcherURL = rf.getData() if self.patcherURL.find('FUNNEL_LOG') == -1: patcherVer('w', 'OFFLINE') return None 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')) continue else: self.dynamicVRFunnel = patcherVer()[0] def isVarSet(self, varInQuestion): try: tempvar = type(varInQuestion) return 1 except NameError: return 0 def buildURL(self): if sys.platform == 'win32': hitboxOSType = 'c3' elif sys.platform == 'darwin': hitboxOSType = 'c4' elif sys.platform == 'linux2': hitboxOSType = 'c4' if self.CurrentHost == 1: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str( self.hitboxAcct ) + '&n=' + str( self.milestone ) + '&ln=' + self.language + '&gp=STARTGAME_DOCK&fnl=PIRATES_FUNNEL&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str( vconGroup()) + '&c1=' + str( sys.platform) + '&' + str(hitboxOSType) + '=' + str( self.osMajorver) + '_' + str( self.osMinorver) + '_' + str( self.osRevver) + '_' + str(self.osBuild) if self.CurrentHost == 2: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str( self.hitboxAcct ) + '&n=' + str( self.milestone ) + '&ln=' + self.language + '&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str( vconGroup()) + '&c1=' + str( sys.platform) + '&' + str(hitboxOSType) + '=' + str( self.osMajorver) + '_' + str( self.osMinorver) + '_' + str( self.osRevver) + '_' + str(self.osBuild) if self.CurrentHost == 3: self.URLtoSend = 'http://' + self.hostDict[ self. CurrentHost] + self.omniAccount + '/1/H.15.1/' + self.cacheBuster( ) + '?[AQB]&ns=dol&pageName=dgame%3Apir_onl%3Ammog%3A' + str( self.milestone ).lower() + '&c1=' + str( oconGroup() ) + '&c14=dgame&h1=mmog&c11=pir&c4=in_game&c25=' + self.ogLocation + '&v25=' + self.ogLocation + '[AQE]' if self.CurrentHost == 0: localMAC = str(getMAC()) self.URLtoSend = str(self.dynamicVRFunnel) + '?funnel=' + str( self.milestone ) + '&platform=' + str(sys.platform) + '&sysver=' + str( self.osMajorver) + '_' + str(self.osMinorver) + '_' + str( self.osRevver) + '_' + str( self.osBuild ) + '&mac=' + localMAC + '&username='******'&id=' + str(loggingAvID()) def readInPandaCookie(self): thefile = open(self.cfCookieFile, 'r') thedata = thefile.read().split('\n') thefile.close() del thefile if thedata[0].find('Netscape HTTP Cookie File') != -1: return None thedata.pop() try: while thedata: temp = thedata.pop() temp = temp.split('\t') domain = temp[0] loc = temp[1] variable = temp[2] value = temp[3] if variable == 'CTG': self.pandaHTTPClientVarCTG = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarCTG) if variable == self.hitboxAcct + 'V6': self.pandaHTTPClientVarDM = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarDM) if variable == 'WSS_GW': self.pandaHTTPClientVarWSS = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarWSS) continue except IndexError: print 'UserFunnel(Warning): Cookie Data file bad' del thedata def readInPandaCookieOmniture(self): thefile = open(self.cfCookieFileOmniture, 'r') thedata = thefile.read().split('\n') thefile.close() del thefile if thedata[0].find('Netscape HTTP Cookie File') != -1: return None thedata.pop() try: while thedata: temp = thedata.pop() temp = temp.split('\t') domain = temp[0] loc = temp[1] variable = temp[2] value = temp[3] if variable == 's_vi': self.pandaHTTPClientVarSVI = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarSVI) continue except IndexError: print 'UserFunnel(Warning): Omniture Cookie Data file bad' del thedata def updateInstanceCookieValues(self): a = self.httpSession.getCookie(HTTPCookie('WSS_GW', '/', '.hitbox.com')) if a.getName(): self.pandaHTTPClientVarWSS = [ '.hitbox.com', '/', 'WSS_GW', a.getValue() ] b = self.httpSession.getCookie(HTTPCookie('CTG', '/', '.hitbox.com')) if b.getName(): self.pandaHTTPClientVarCTG = [ '.hitbox.com', '/', 'CTG', b.getValue() ] c = self.httpSession.getCookie( HTTPCookie(self.hitboxAcct + 'V6', '/', '.ehg-dig.hitbox.com')) if c.getName(): self.pandaHTTPClientVarDM = [ '.ehg-dig.hitbox.com', '/', self.hitboxAcct + 'V6', c.getValue() ] del a del b del c def updateInstanceCookieValuesOmniture(self): a = self.httpSession.getCookie(HTTPCookie('s_vi', '/', '.go.com')) if a.getName(): self.pandaHTTPClientVarSVI = ['.go.com', '/', 's_vi', a.getValue()] del a def setTheHTTPCookie(self, cookieParams): c = HTTPCookie(cookieParams[2], cookieParams[1], cookieParams[0]) c.setValue(cookieParams[3]) self.httpSession.setCookie(c) def writeOutPandaCookie(self): try: thefile = open(self.cfCookieFile, 'w') if len(self.pandaHTTPClientVarWSS) == 4: thefile.write(self.pandaHTTPClientVarWSS[0] + '\t' + self.pandaHTTPClientVarWSS[1] + '\t' + self.pandaHTTPClientVarWSS[2] + '\t' + self.pandaHTTPClientVarWSS[3] + '\n') if len(self.pandaHTTPClientVarCTG) == 4: thefile.write(self.pandaHTTPClientVarCTG[0] + '\t' + self.pandaHTTPClientVarCTG[1] + '\t' + self.pandaHTTPClientVarCTG[2] + '\t' + self.pandaHTTPClientVarCTG[3] + '\n') if len(self.pandaHTTPClientVarDM) == 4: thefile.write(self.pandaHTTPClientVarDM[0] + '\t' + self.pandaHTTPClientVarDM[1] + '\t' + self.pandaHTTPClientVarDM[2] + '\t' + self.pandaHTTPClientVarDM[3] + '\n') thefile.close() except IOError: return None def writeOutPandaCookieOmniture(self): try: thefile = open(self.cfCookieFileOmniture, 'w') if len(self.pandaHTTPClientVarSVI) == 4: thefile.write(self.pandaHTTPClientVarSVI[0] + '\t' + self.pandaHTTPClientVarSVI[1] + '\t' + self.pandaHTTPClientVarSVI[2] + '\t' + self.pandaHTTPClientVarSVI[3] + '\n') thefile.close() except IOError: return None def prerun(self): self.getFunnelURL() self.buildURL() if os.path.isfile(self.cfCookieFile) == True: if self.CurrentHost == 1 or self.CurrentHost == 2: self.readInPandaCookie() if os.path.isfile( self.cfCookieFileOmniture) == True and self.CurrentHost == 3: self.readInPandaCookieOmniture() def run(self): if self.CurrentHost == 0 and patcherVer() == ['OFFLINE']: return None self.nonBlock = self.httpSession.makeChannel(False) self.nonBlock.beginGetDocument(DocumentSpec(self.URLtoSend)) instanceMarker = str(random.randint(1, 1000)) instanceMarker = 'FunnelLoggingRequest-%s' % instanceMarker self.startCheckingAsyncRequest(instanceMarker) def startCheckingAsyncRequest(self, name): taskMgr.remove(name) taskMgr.doMethodLater(0.5, self.pollFunnelTask, name) def stopCheckingFunnelTask(self, name): taskMgr.remove('pollFunnelTask') def pollFunnelTask(self, task): result = self.nonBlock.run() if result == 0: self.stopCheckingFunnelTask(task) if self.CurrentHost == 1 or self.CurrentHost == 2: self.updateInstanceCookieValues() self.writeOutPandaCookie() if self.CurrentHost == 3: self.updateInstanceCookieValuesOmniture() self.writeOutPandaCookieOmniture() else: return Task.again def cacheBuster(self): return str(time.time())
class UserFunnel: def __init__(self): # Variables required for acct service access # HitBox Account Number. # DOL test account = DM510925KJWE # Pirates Account = DM560804E8WD # ToonTown Account = DM53030620EW self.hitboxAcct = 'DM53030620EW' # self.hitboxAcct = 'DM510925KJWE' # Language Used; example: English (US) = en-us self.language = 'en-us' # Content Group self.cgRoot = 'ToonTown_Online' # Content Sub-Groups # For now, I've hardcoded the cgLocation to US. In the future # we'll need to change this by hand or via a function, to reflect # the geolocation that this is being built for. self.cgBeta = 'Beta' self.cgRelease = 'Release' self.cgLocation = 'US' # Campaign ID for hitbox # Again, this ID has yet to be provided self.campaignID = '' # Cookie CallBack for HBX, but can be used for others if needed # self.cfCookie = cookielib.MozillaCookieJar('cf.txt') self.cfCookieFile = 'cf.txt' # Host Listing. Access hostnames and paths will be listed here # Each item has an int that goes along with it. self.dynamicVRFunnel = 'http://download.toontown.com/' # self.dynamicVRFunnel = 'http://build64:3120/logging/collector.php' self.hostDict = { 0: 'Internal Disney PHP Collector Site', 1: 'ehg-dig.hitbox.com/HG?', 2: 'ehg-dig.hitbox.com/HG?', 3: 'build64.online.disney.com:5020/index.php?' } # The current host variable will be an int value that points to an # entry in the hostDict. It is used at URL generation time to insert # the correct hostname and path into the URL self.CurrentHost = '' # URLtoSend is the actual URL that will be accessed when run() is called self.URLtoSend = '' # System Variables to report on. Currently, they are not all being used. # Some variables have been put in place for future use. # GameName is the name of the game being reported on self.gameName = 'ToonTown' # BrowserName for ID self.browserName = 'Panda3D%20(' + self.gameName + ';%20' + sys.platform + ')' # HTTPUserHeader to be transmitted once the http connection is established. This is not part of the URL that is sent. It is part of the header. self.HTTPUserHeader = [('User-agent', 'Panda3D')] # OS Major Version: Example MS-WinXP = 5, MacOSX Tiger = 10 self.osMajorver = '' # OS Minor Version: Example MS-WinXP = 1, OSX Tiger = 4 self.osMinorver = '' # OS Rev Version: Example OSX Tiger = 1...9 self.osRevver = '' # OS Build Number: Example MS-WinXP = 2600 self.osBuild = '' # OS Type. Example: int value that goes along with the msWinTypeDict self.osType = '' # The getwindowsversion command returns comments. An example would the a comment about the currently installed service pack self.osComments = '' # Dict of int to string pairs for self.osType self.msWinTypeDict = { 0: 'Win32s on Windows 3.1', 1: 'Windows 95/98/ME', 2: 'Windows NT/2000/XP', 3: 'Windows CE' } self.milestoneDict = { 0: 'New User', 1: 'Create Account', 2: 'View EULA', 3: 'Accept EULA', 4: 'Download Start', 5: 'Download End', 6: 'Installer Run', 7: 'Launcher Start', 8: 'Launcher Login', 9: 'Client Opens', 10: 'Create Pirate Loads', 11: 'Create Pirate Exit', 12: 'Cutscene One Start', 13: 'Cutscene One Ends', 14: 'Cutscene Two Start', 15: 'Cutscene Thee Start', 16: 'Cutscene Three Ends', 17: 'Access Cannon', 18: 'Cutscene Four Starts', 19: 'Cutscene Four Ends', 20: 'Dock - Start Game' } self.macTypeDict = { 2: 'Jaguar', 1: 'Puma', 3: 'Panther', 4: 'Tiger', 5: 'Lepard' } # Milestone string var. Used to hold the funnel location string. This used to be an int (as per the dict above), but later is was decided that it would be a string value; ie. START_GAME or BUILD_PIRATE_START. I have left the milestoneDict in place for reference purposes. self.milestone = '' # The next three lists hold the cookie vars for the three hitbox based # variable / value pairs requred for hitbox. # [DOMAIN, /, VARIABLE, VALUE] self.pandaHTTPClientVarWSS = [] self.pandaHTTPClientVarCTG = [] self.pandaHTTPClientVarDM = [] # In an effort to determine if this is the first time the client has # been executed on the system, we will check for the existance of the # cf.txt file. If the file does not exist, we will set the firstRun() # to True. self.checkForCFfile() # Instance an HTTPClient session self.httpSession = HTTPClient() # Run the whatOSver command at the end of the constructor. self.whatOSver() def checkForCFfile(self): # Check for the existance of the cf.txt file. If it does not exist, # then set the firstRun() to True. If it does exist, do nothing. if firstRun() == True: pass else: if (os.path.isfile(self.cfCookieFile) == False): firstRun('write', True) # Populate the osMajor, osMinor, osBuild, osType, osComments, and osRevver vars def whatOSver(self): if (sys.platform == 'win32'): self.osMajorver = str(sys.getwindowsversion()[0]) self.osMinorver = str(sys.getwindowsversion()[1]) self.osBuild = str(sys.getwindowsversion()[2]) self.osType = str(sys.getwindowsversion()[3]) self.osComments = str(sys.getwindowsversion()[4]) return if (sys.platform == 'darwin'): self.osMajorver = '10' osxcmd = '/usr/sbin/system_profiler SPSoftwareDataType |/usr/bin/grep "System Version"' infopipe = os.popen(osxcmd, 'r') parseLine = infopipe.read() infopipe.close() del infopipe notify.info("parseLine = %s" % str(parseLine)) versionStringStart = parseLine.find('10.') notify.info("versionStringStart = %s" % str(versionStringStart)) testPlist = False try: # I placed this segment into the try/except pair due to an # exception that pops up at most once a day, where these # assignments return an out of range error # RAU exception always happen in 10.6 self.osMinorver = parseLine[versionStringStart + 3] self.osRevver = parseLine[versionStringStart + 5:versionStringStart + 7].strip(' ') self.osBuild = parseLine[int(parseLine.find('(')) + 1:parseLine.find(')')] except: # This should catch this rare case. It's probably happening # due to a corrupt OS install on the client. # In this case, we'll just manually assign values # RAU so 10.6 will always report as 10.0 notify.info( "couldn't parse the system_profiler output, using zeros") self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' testPlist = True del versionStringStart del parseLine del osxcmd if testPlist: try: import plistlib pl = plistlib.readPlist( "/System/Library/CoreServices/SystemVersion.plist") notify.info("pl=%s" % str(pl)) parseLine = pl['ProductVersion'] numbers = parseLine.split('.') notify.info("parseline =%s numbers =%s" % (parseLine, numbers)) self.osMinorver = numbers[1] self.osRevver = numbers[2] self.osBuild = pl["ProductBuildVersion"] except: notify.info("tried plist but still got exception") self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' return def setmilestone(self, ms): if firstRun() == False: self.milestone = ms else: self.milestone = '%s_INITIAL' % (ms) def setgamename(self, gamename): self.gameName = gamename def printosComments(self): return self.osComments def setHost(self, hostID): assert hostID < len( self.hostDict ), "Error: hostID passed in UserTracker.setHost not valid, value to high" assert hostID > -1, "Error: hostID must be 0 or positive int" self.CurrentHost = hostID # This will go out to the download server and get the current Disney Funnel logging URL def getFunnelURL(self): # print 'VRS URL: ' + self.dynamicVRFunnel if (patcherVer() == ['OFFLINE']): # print "Funnel System Offline" return if (patcherVer() == []): # print "Funnel URL not set. Setting now" patcherHTTP = HTTPClient() if checkParamFile() == None: patcherDoc = patcherHTTP.getDocument( URLSpec( 'http://download.toontown.com/english/currentVersion/content/patcher.ver' )) # Now set vcon (Content Group) to the Release string vconGroup('w', self.cgRelease) else: patcherDoc = patcherHTTP.getDocument(URLSpec(checkParamFile())) # Set vcon (Content Group) to the Beta string vconGroup('w', self.cgBeta) # patcherDoc = patcherHTTP.getDocument(URLSpec('http://build64:3120/english/currentVersion/dev/content/patcher.ver')) rf = Ramfile() patcherDoc.downloadToRam(rf) self.patcherURL = rf.getData() if self.patcherURL.find('FUNNEL_LOG') == -1: # The file did not download, need to set # the patcherVer to offline patcherVer('w', 'OFFLINE') # print 'Patcher system could not be reached' return self.patcherURL = self.patcherURL.split('\n') del rf, patcherDoc, 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] def isVarSet(self, varInQuestion): try: tempvar = type(varInQuestion) return 1 except NameError: return 0 def buildURL(self): # A recent Hitbox Addition. We need to generate a variable/value pair. # The variable name depends on the OS. If the OS is win32, then the # variable name is c3. If the OS is darwin, then the variable name # is c4. The value to be passed to c3 and c4 is the same: # str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) if sys.platform == 'win32': hitboxOSType = 'c3' else: hitboxOSType = 'c4' # This will take all of the required variables and generate # A URL to be transmitted to the currently selected service # Host 1 is the hitbox URL config if (self.CurrentHost == 1): self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str( self.hitboxAcct ) + '&n=' + str( self.milestone ) + '&ln=' + self.language + '&gp=STARTGAME&fnl=TOONTOWN_FUNNEL&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str( vconGroup()) + '&c1=' + str( sys.platform) + '&' + str(hitboxOSType) + '=' + str( self.osMajorver) + '_' + str( self.osMinorver) + '_' + str( self.osRevver) + '_' + str(self.osBuild) # print self.URLtoSend # Host 2 is for the Hitbox, with no funnel if (self.CurrentHost == 2): self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str( self.hitboxAcct ) + '&n=' + str( self.milestone ) + '&ln=' + self.language + '&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str( vconGroup()) + '&c1=' + str( sys.platform) + '&' + str(hitboxOSType) + '=' + str( self.osMajorver) + '_' + str( self.osMinorver) + '_' + str( self.osRevver) + '_' + str(self.osBuild) # Host 3 is the disney logging server config. # if (self.CurrentHost == 3): # self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'some_var_name=' + self.gameName #Need to add a bunch more. Just not sure of the variable names yet # This host is for the internal server if (self.CurrentHost == 0): localMAC = str(getMAC()) self.URLtoSend = str(self.dynamicVRFunnel) + '?funnel=' + str( self.milestone ) + '&platform=' + str(sys.platform) + '&sysver=' + str( self.osMajorver) + '_' + str(self.osMinorver) + '_' + str( self.osRevver) + '_' + str( self.osBuild ) + '&mac=' + localMAC + '&username='******'&id=' + str(loggingAvID()) def readInPandaCookie(self): # This function is designed to read in the cookie format that # the panda HTTPClient uses. # The format is as follows: # DOMAINAME<TAB>/<TAB>VARIABLE<TAB>VALUE<\n> # EXAMPLE: # .hitbox.com / CTG 1181271609 thefile = open(self.cfCookieFile, 'r') thedata = thefile.read().split('\n') thefile.close() del thefile # Before we go any further, lets check to see if the file is using # the old Netscape HTTP format the python's MozillaCookie Jar # supports. If so, lets delete the file and re-populate with # a new cookie from the server if (thedata[0].find('Netscape HTTP Cookie File') != -1): return # Pop off last element; it's blank thedata.pop() try: while thedata: temp = thedata.pop() # if temp.find('.hitbox.com') != -1 or temp.find('ehg-dig.hitbox.com') != -1: temp = temp.split('\t') domain = temp[0] loc = temp[1] variable = temp[2] value = temp[3] if (variable == 'CTG'): self.pandaHTTPClientVarCTG = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarCTG) if (variable == self.hitboxAcct + 'V6'): self.pandaHTTPClientVarDM = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarDM) if (variable == 'WSS_GW'): self.pandaHTTPClientVarWSS = [domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarWSS) except IndexError: print "UserFunnel(Warning): Cookie Data file bad" del thedata def updateInstanceCookieValues(self): a = self.httpSession.getCookie(HTTPCookie('WSS_GW', '/', '.hitbox.com')) if a.getName(): self.pandaHTTPClientVarWSS = [ '.hitbox.com', '/', 'WSS_GW', a.getValue() ] else: # print 'WSS_GW Cookie Value not set' pass b = self.httpSession.getCookie(HTTPCookie('CTG', '/', '.hitbox.com')) if b.getName(): self.pandaHTTPClientVarCTG = [ '.hitbox.com', '/', 'CTG', b.getValue() ] else: # print 'CTG Cookie Value not set' pass c = self.httpSession.getCookie( HTTPCookie(self.hitboxAcct + 'V6', '/', 'ehg-dig.hitbox.com')) if c.getName(): self.pandaHTTPClientVarDM = [ 'ehg-dig.hitbox.com', '/', self.hitboxAcct + 'V6', c.getValue() ] else: #print self.hitboxAcct + 'V6 Cookie Value not set' pass del a, b, c def setTheHTTPCookie(self, cookieParams): c = HTTPCookie(cookieParams[2], cookieParams[1], cookieParams[0]) c.setValue(cookieParams[3]) self.httpSession.setCookie(c) def writeOutPandaCookie(self): # This is designed to write out a cookie file in the format that # the panda HTTPClient uses. # Please see the readInPandaCookie comments for format. try: thefile = open(self.cfCookieFile, 'w') if len(self.pandaHTTPClientVarWSS) == 4: thefile.write(self.pandaHTTPClientVarWSS[0] + '\t' + self.pandaHTTPClientVarWSS[1] + '\t' + self.pandaHTTPClientVarWSS[2] + '\t' + self.pandaHTTPClientVarWSS[3] + '\n') if len(self.pandaHTTPClientVarCTG) == 4: thefile.write(self.pandaHTTPClientVarCTG[0] + '\t' + self.pandaHTTPClientVarCTG[1] + '\t' + self.pandaHTTPClientVarCTG[2] + '\t' + self.pandaHTTPClientVarCTG[3] + '\n') if len(self.pandaHTTPClientVarDM) == 4: thefile.write(self.pandaHTTPClientVarDM[0] + '\t' + self.pandaHTTPClientVarDM[1] + '\t' + self.pandaHTTPClientVarDM[2] + '\t' + self.pandaHTTPClientVarDM[3] + '\n') thefile.close() except IOError: return # The next function spawns another thread and executed the network # transaction; i.e. host resolve, open connection, send, close, etc. # Update, the threading has been disbaled for the time being. def prerun(self): # print "Begin Hitbox Thread" # Use start() method to execute this run() function in second thread # Commented out the next line (if statement) on 9-10-07, # and moved the indent on self.getFunnelURL to the left. # It looks like due to changes in the function that gets the # patcher.ver, it is no longer necessary to only check the FunnelURL # status when the CurrentHost is 0. The getFunnelURL() should be # called no mater what the CurrentHost is set to. I think that it was # only checking when CurrentHost == 0, due to some URLs being # hardcoded in previous versions of the logging module. But that # is no longer the case for the VRS collector. # if (self.CurrentHost == 0): self.getFunnelURL() # print "build url" self.buildURL() if (os.path.isfile(self.cfCookieFile) == True): # print "load preexisting cookie" # self.cfCookie.load() if self.CurrentHost == 1 or self.CurrentHost == 2: self.readInPandaCookie() # print "Cookies before transaction" # self.httpSession.writeCookies(ostream) # print "Cookie Header Line" # self.httpSession.sendCookies(ostream, URLSpec(self.URLtoSend)) def run(self): # Here is where the new Panda based HTTP code starts # But before we hit the URL, let make sure we need to. # Lets check to see if the VRS Collector is OFFLINE and # host type 0 was selected. If that is the case, we can just # return here; nothing needs to be done. if self.CurrentHost == 0 and patcherVer() == ['OFFLINE']: return # Hit the URL # The next line uses the Panda HTTP lib (blocking) # doc = self.httpSession.getDocument(URLSpec(self.URLtoSend)) # Next line uses non-blocking self.nonBlock = self.httpSession.makeChannel(False) # nonBlock.setHttpTimeout(1) # nonBlock.setConnectTimeout(.5) # nonBlock.setBlockingConnect(False) # doc = nonBlock.getDocument(DocumentSpec(self.URLtoSend)) self.nonBlock.beginGetDocument(DocumentSpec(self.URLtoSend)) instanceMarker = str(random.randint(1, 1000)) instanceMarker = 'FunnelLoggingRequest-%s' % instanceMarker self.startCheckingAsyncRequest(instanceMarker) # That's it. The server should have recorded the hit # delete the object # del doc # print "The Funnel URL could not be accessed" # if (self.CurrentHost == 0): # patcherVer('w','OFFLINE') # For testing, write out all cookies in memory # print "Cookies after Transaction" # self.httpSession.writeCookies(ostream) # Commented out the following, moved it to the taskMgr call # if self.CurrentHost == 1 or self.CurrentHost == 2: # self.updateInstanceCookieValues() # self.writeOutPandaCookie() # Now lets do a check to see if the string LEAK is in the milestone # If LEAK is present, then we will also call the memory leak report # function to submit a report. # if self.milestone.find('LEAK') != -1: # reportMemoryLeaks() def startCheckingAsyncRequest(self, name): taskMgr.remove(name) # print "Starting Checking Async Request" taskMgr.doMethodLater(0.5, self.pollFunnelTask, name) def stopCheckingFunnelTask(self, name): taskMgr.remove('pollFunnelTask') def pollFunnelTask(self, task): # print "Polling....." result = self.nonBlock.run() if result == 0: # print "Result = 0, Done" # Funnel request complete self.stopCheckingFunnelTask(task) if self.CurrentHost == 1 or self.CurrentHost == 2: self.updateInstanceCookieValues() self.writeOutPandaCookie() else: return Task.again
class UserFunnel: def __init__(self): self.hitboxAcct = 'DM560804E8WD' self.omniAccount = 'wdgdolpironl,wdgdsec' self.language = 'en-us' self.cgRoot = 'Pirates_Online' self.cgBeta = 'Beta' self.cgRelease = 'Release' self.cgLocation = 'US' self.ogBeta = 'pir_onl_beta' self.ogRelease = 'pir_onl' self.ogLocation = 'us' self.campaignID = '' self.cfCookieFile = 'cf.txt' self.cfCookieFileOmniture = 'cf2.txt' self.dynamicVRFunnel = 'http://download.pirates.com/' self.hostDict = { 0: 'Internal Disney PHP Collector Site', 1: 'ehg-dig.hitbox.com/HG?', 2: 'ehg-dig.hitbox.com/HG?', 3: 'w88.go.com/b/ss/' } self.CurrentHost = '' self.URLtoSend = '' self.gameName = 'Pirates' self.browserName = 'Panda3D%20(' + self.gameName + ';%20' + sys.platform + ')' self.HTTPUserHeader = [ ('User-agent', 'Panda3D')] self.osMajorver = '' self.osMinorver = '' self.osRevver = '' self.osBuild = '' self.osType = '' self.osComments = '' self.msWinTypeDict = { 0: 'Win32s on Windows 3.1', 1: 'Windows 95/98/ME', 2: 'Windows NT/2000/XP', 3: 'Windows CE' } self.milestoneDict = { 0: 'New User', 1: 'Create Account', 2: 'View EULA', 3: 'Accept EULA', 4: 'Download Start', 5: 'Download End', 6: 'Installer Run', 7: 'Launcher Start', 8: 'Launcher Login', 9: 'Client Opens', 10: 'Create Pirate Loads', 11: 'Create Pirate Exit', 12: 'Cutscene One Start', 13: 'Cutscene One Ends', 14: 'Cutscene Two Start', 15: 'Cutscene Thee Start', 16: 'Cutscene Three Ends', 17: 'Access Cannon', 18: 'Cutscene Four Starts', 19: 'Cutscene Four Ends', 20: 'Dock - Start Game' } self.macTypeDict = { 2: 'Jaguar', 1: 'Puma', 3: 'Panther', 4: 'Tiger', 5: 'Lepard' } self.milestone = '' self.pandaHTTPClientVarWSS = [] self.pandaHTTPClientVarCTG = [] self.pandaHTTPClientVarDM = [] self.pandaHTTPClientVarSVI = [] self.checkForCFfile() self.httpSession = HTTPClient() self.whatOSver() def checkForCFfile(self): if firstRun() == True: pass 1 if os.path.isfile(self.cfCookieFile) == False: firstRun('write', True) def whatOSver(self): if sys.platform == 'win32': self.osMajorver = str(sys.getwindowsversion()[0]) self.osMinorver = str(sys.getwindowsversion()[1]) self.osBuild = str(sys.getwindowsversion()[2]) self.osType = str(sys.getwindowsversion()[3]) self.osComments = str(sys.getwindowsversion()[4]) elif sys.platform == 'darwin': self.osMajorver = '10' osxcmd = '/usr/sbin/system_profiler SPSoftwareDataType |/usr/bin/grep "System Version"' infopipe = os.popen(osxcmd, 'r') parseLine = infopipe.read() infopipe.close() del infopipe versionStringStart = parseLine.find('10.') try: self.osMinorver = parseLine[versionStringStart + 3] self.osRevver = parseLine[versionStringStart + 5:versionStringStart + 7].strip(' ') self.osBuild = parseLine[int(parseLine.find('(')) + 1:parseLine.find(')')] except: self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' del versionStringStart del parseLine del osxcmd elif sys.platform == 'linux2': self.osMinorver = '0' self.osRevver = '0' self.osBuild = '0000' def setmilestone(self, ms): if firstRun() == False: self.milestone = ms else: self.milestone = '%s_INITIAL' % ms def setgamename(self, gamename): self.gameName = gamename def printosComments(self): return self.osComments def setHost(self, hostID): self.CurrentHost = hostID def getFunnelURL(self): if patcherVer() == [ 'OFFLINE']: return None if patcherVer() == []: patcherHTTP = HTTPClient() if checkParamFile() == None: patcherDoc = patcherHTTP.getDocument(URLSpec('http://download.piratesonline.com/english/currentVersion/content/patcher.ver')) vconGroup('w', self.cgRelease) oconGroup('w', self.ogRelease) else: patcherDoc = patcherHTTP.getDocument(URLSpec(checkParamFile())) vconGroup('w', self.cgBeta) oconGroup('w', self.ogBeta) rf = Ramfile() patcherDoc.downloadToRam(rf) self.patcherURL = rf.getData() if self.patcherURL.find('FUNNEL_LOG') == -1: patcherVer('w', 'OFFLINE') return None 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')) continue else: self.dynamicVRFunnel = patcherVer()[0] def isVarSet(self, varInQuestion): try: tempvar = type(varInQuestion) return 1 except NameError: return 0 def buildURL(self): if sys.platform == 'win32': hitboxOSType = 'c3' elif sys.platform == 'darwin': hitboxOSType = 'c4' elif sys.platform == 'linux2': hitboxOSType = 'c4' if self.CurrentHost == 1: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str(self.hitboxAcct) + '&n=' + str(self.milestone) + '&ln=' + self.language + '&gp=STARTGAME_DOCK&fnl=PIRATES_FUNNEL&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str(vconGroup()) + '&c1=' + str(sys.platform) + '&' + str(hitboxOSType) + '=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) if self.CurrentHost == 2: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + 'hb=' + str(self.hitboxAcct) + '&n=' + str(self.milestone) + '&ln=' + self.language + '&vcon=/' + self.cgRoot + '/' + self.cgLocation + '/' + str(vconGroup()) + '&c1=' + str(sys.platform) + '&' + str(hitboxOSType) + '=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) if self.CurrentHost == 3: self.URLtoSend = 'http://' + self.hostDict[self.CurrentHost] + self.omniAccount + '/1/H.15.1/' + self.cacheBuster() + '?[AQB]&ns=dol&pageName=dgame%3Apir_onl%3Ammog%3A' + str(self.milestone).lower() + '&c1=' + str(oconGroup()) + '&c14=dgame&h1=mmog&c11=pir&c4=in_game&c25=' + self.ogLocation + '&v25=' + self.ogLocation + '[AQE]' if self.CurrentHost == 0: localMAC = str(getMAC()) self.URLtoSend = str(self.dynamicVRFunnel) + '?funnel=' + str(self.milestone) + '&platform=' + str(sys.platform) + '&sysver=' + str(self.osMajorver) + '_' + str(self.osMinorver) + '_' + str(self.osRevver) + '_' + str(self.osBuild) + '&mac=' + localMAC + '&username='******'&id=' + str(loggingAvID()) def readInPandaCookie(self): thefile = open(self.cfCookieFile, 'r') thedata = thefile.read().split('\n') thefile.close() del thefile if thedata[0].find('Netscape HTTP Cookie File') != -1: return None thedata.pop() try: while thedata: temp = thedata.pop() temp = temp.split('\t') domain = temp[0] loc = temp[1] variable = temp[2] value = temp[3] if variable == 'CTG': self.pandaHTTPClientVarCTG = [ domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarCTG) if variable == self.hitboxAcct + 'V6': self.pandaHTTPClientVarDM = [ domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarDM) if variable == 'WSS_GW': self.pandaHTTPClientVarWSS = [ domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarWSS) continue except IndexError: print 'UserFunnel(Warning): Cookie Data file bad' del thedata def readInPandaCookieOmniture(self): thefile = open(self.cfCookieFileOmniture, 'r') thedata = thefile.read().split('\n') thefile.close() del thefile if thedata[0].find('Netscape HTTP Cookie File') != -1: return None thedata.pop() try: while thedata: temp = thedata.pop() temp = temp.split('\t') domain = temp[0] loc = temp[1] variable = temp[2] value = temp[3] if variable == 's_vi': self.pandaHTTPClientVarSVI = [ domain, loc, variable, value] self.setTheHTTPCookie(self.pandaHTTPClientVarSVI) continue except IndexError: print 'UserFunnel(Warning): Omniture Cookie Data file bad' del thedata def updateInstanceCookieValues(self): a = self.httpSession.getCookie(HTTPCookie('WSS_GW', '/', '.hitbox.com')) if a.getName(): self.pandaHTTPClientVarWSS = [ '.hitbox.com', '/', 'WSS_GW', a.getValue()] b = self.httpSession.getCookie(HTTPCookie('CTG', '/', '.hitbox.com')) if b.getName(): self.pandaHTTPClientVarCTG = [ '.hitbox.com', '/', 'CTG', b.getValue()] c = self.httpSession.getCookie(HTTPCookie(self.hitboxAcct + 'V6', '/', '.ehg-dig.hitbox.com')) if c.getName(): self.pandaHTTPClientVarDM = [ '.ehg-dig.hitbox.com', '/', self.hitboxAcct + 'V6', c.getValue()] del a del b del c def updateInstanceCookieValuesOmniture(self): a = self.httpSession.getCookie(HTTPCookie('s_vi', '/', '.go.com')) if a.getName(): self.pandaHTTPClientVarSVI = [ '.go.com', '/', 's_vi', a.getValue()] del a def setTheHTTPCookie(self, cookieParams): c = HTTPCookie(cookieParams[2], cookieParams[1], cookieParams[0]) c.setValue(cookieParams[3]) self.httpSession.setCookie(c) def writeOutPandaCookie(self): try: thefile = open(self.cfCookieFile, 'w') if len(self.pandaHTTPClientVarWSS) == 4: thefile.write(self.pandaHTTPClientVarWSS[0] + '\t' + self.pandaHTTPClientVarWSS[1] + '\t' + self.pandaHTTPClientVarWSS[2] + '\t' + self.pandaHTTPClientVarWSS[3] + '\n') if len(self.pandaHTTPClientVarCTG) == 4: thefile.write(self.pandaHTTPClientVarCTG[0] + '\t' + self.pandaHTTPClientVarCTG[1] + '\t' + self.pandaHTTPClientVarCTG[2] + '\t' + self.pandaHTTPClientVarCTG[3] + '\n') if len(self.pandaHTTPClientVarDM) == 4: thefile.write(self.pandaHTTPClientVarDM[0] + '\t' + self.pandaHTTPClientVarDM[1] + '\t' + self.pandaHTTPClientVarDM[2] + '\t' + self.pandaHTTPClientVarDM[3] + '\n') thefile.close() except IOError: return None def writeOutPandaCookieOmniture(self): try: thefile = open(self.cfCookieFileOmniture, 'w') if len(self.pandaHTTPClientVarSVI) == 4: thefile.write(self.pandaHTTPClientVarSVI[0] + '\t' + self.pandaHTTPClientVarSVI[1] + '\t' + self.pandaHTTPClientVarSVI[2] + '\t' + self.pandaHTTPClientVarSVI[3] + '\n') thefile.close() except IOError: return None def prerun(self): self.getFunnelURL() self.buildURL() if os.path.isfile(self.cfCookieFile) == True: if self.CurrentHost == 1 or self.CurrentHost == 2: self.readInPandaCookie() if os.path.isfile(self.cfCookieFileOmniture) == True and self.CurrentHost == 3: self.readInPandaCookieOmniture() def run(self): if self.CurrentHost == 0 and patcherVer() == [ 'OFFLINE']: return None self.nonBlock = self.httpSession.makeChannel(False) self.nonBlock.beginGetDocument(DocumentSpec(self.URLtoSend)) instanceMarker = str(random.randint(1, 1000)) instanceMarker = 'FunnelLoggingRequest-%s' % instanceMarker self.startCheckingAsyncRequest(instanceMarker) def startCheckingAsyncRequest(self, name): taskMgr.remove(name) taskMgr.doMethodLater(0.5, self.pollFunnelTask, name) def stopCheckingFunnelTask(self, name): taskMgr.remove('pollFunnelTask') def pollFunnelTask(self, task): result = self.nonBlock.run() if result == 0: self.stopCheckingFunnelTask(task) if self.CurrentHost == 1 or self.CurrentHost == 2: self.updateInstanceCookieValues() self.writeOutPandaCookie() if self.CurrentHost == 3: self.updateInstanceCookieValuesOmniture() self.writeOutPandaCookieOmniture() else: return Task.again def cacheBuster(self): return str(time.time())
class FancyLoadingScreen(DirectObject.DirectObject): notify = DirectNotifyGlobal.directNotify.newCategory('LoadingScreen') def __init__(self, parent): DirectObject.DirectObject.__init__(self) self.debugMode = config.GetInt('loading-screen') == 2 self.parent = parent self.state = False self.currScreenshot = None self.snapshot = None self.snapshotFrame = None self.snapshotFrameBasic = None self.currentTime = 0 self.analyzeMode = False self.loadScale = 1.0 self.unmappedTicks = [] self.stepInfo = { } self.accept(base.win.getWindowEvent(), self.adjustSize) self.accept('tick', self.tick) self.currStage = 'unmapped' self.stagePercent = 0 self.numObjects = 0 self.currPercent = 0.0 self.line = LineSegs() self.line.setColor((0, 0, 0, 1)) self.line.setThickness(1) self.stageLabel = None self.currNum = 0 self.overallPercent = 0 self.lastPercent = 0 self.topLock = aspect2dp.attachNewNode('topShift') self.root = self.topLock.attachNewNode('loadingScreenRoot') self.root.setZ(-1) self.root.stash() self.model = loader.loadModel('models/gui/pir_m_gui_gen_loadScreen.bam') self.model.setP(90) self.model.reparentTo(self.root) cm = CardMaker('backdrop') cm.setFrame(-10, 10, -10, 10) if self.debugMode: self.backdrop = self.root.attachNewNode(cm.generate()) self.backdrop.setX(-1.5) self.backdrop.setZ(-1) self.backdrop.setScale(4) self.backdrop.setColor(0.5, 0.5, 0.5, 1) cm = CardMaker('loadingBarBase') cm.setFrame(-0.90000000000000002, 0.90000000000000002, 0.10000000000000001, 0.5) self.loadingBarBacking = self.root.attachNewNode(cm.generate()) self.loadingBarRoot = self.root.attachNewNode('loadingBarRoot') cm.setName('analysisBarBase') cm.setFrame(-0.90000000000000002, 0.90000000000000002, -0.5, -0.10000000000000001) self.analysisBar = self.root.attachNewNode(cm.generate()) self.analysisBarRoot = self.root.attachNewNode('analysisBarRoot') self.analysisBar.hide() self.analysisButtons = [] self.enterToContinue = DirectLabel(parent = self.root, text = 'Press Shift To Continue', relief = None, text_scale = 0.10000000000000001, pos = (0, 0, -0.90000000000000002), text_align = TextNode.ACenter) self.enterToContinue.hide() self.stageLabel = DirectLabel(parent = self.root, text = '', relief = None, text_scale = 0.10000000000000001, pos = (-1.25, 0, 0.75), text_align = TextNode.ALeft, textMayChange = 1) self.tickLabel = DirectLabel(parent = self.root, text = '', relief = None, text_scale = 0.10000000000000001, pos = (0.75, 0, 0.75), textMayChange = 1) self.overallLabel = DirectLabel(parent = self.root, text = '', relief = None, text_scale = 0.10000000000000001, pos = (0, 0, -0.75), textMayChange = 1) else: self.backdrop = loader.loadModel('models/gui/pir_m_gui_gen_loadScreen') self.backdrop.reparentTo(self.root) bg = self.backdrop.find('**/expandable_bg') bg.setScale(1000, 1, 1000) bg.flattenStrong() self.backdrop.find('**/loadbar_grey').setColorScale(0.14999999999999999, 0.14999999999999999, 0.14999999999999999, 0.10000000000000001) self.loadingBar = self.backdrop.find('**/loadbar') self.loadingBar.setColorScale(0.20000000000000001, 0.59999999999999998, 0.5, 1) self.loadingPlank = NodePathCollection() self.loadingPlank.addPath(self.backdrop.find('**/plank_loading_bar')) self.loadingPlank.addPath(self.backdrop.find('**/loadbar')) self.loadingPlank.addPath(self.backdrop.find('**/loadbar_frame')) self.loadingPlank.addPath(self.backdrop.find('**/loadbar_grey')) self.titlePlank = self.backdrop.find('**/plank_title') self.percentLabel = DirectLabel(text = '0%', parent = self.root, relief = None, text_font = PiratesGlobals.getPirateFont(), text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_scale = 0.031, pos = (0, 0, -0.44450000000000001), textMayChange = 1) self.loadingPlank.addPath(self.percentLabel) self.screenshot = self.backdrop.find('**/screenshot') copyGeom = self.loadingBar.find('**/+GeomNode').node().getGeom(0) format = copyGeom.getVertexData().getFormat() primitive = copyGeom.getPrimitive(0) data = GeomVertexData(self.screenshot.node().getGeom(0).getVertexData()) data.setFormat(format) writer = GeomVertexWriter(data, 'texcoord') writer.setData2f(0, 0) writer.setData2f(1, 0) writer.setData2f(1, 1) writer.setData2f(0, 1) geom = Geom(data) geom.addPrimitive(primitive) self.screenshot.node().removeGeom(0) self.screenshot.node().addGeom(geom) self.titlePlankMiddle = self.backdrop.find('**/plank_title_middle_box') self.titlePlankLeft = self.backdrop.find('**/plank_title_left') self.titlePlankRight = self.backdrop.find('**/plank_title_right') self.loadingBarColors = [ (((i % 10) / 10.0 + 0.5) / 2.0, ((i % 100) / 10 / 10.0 + 0.5) / 2.0, (i / 100 / 10.0 + 0.5) / 2.0, 1) for i in range(1000) ] random.shuffle(self.loadingBarColors) self.lastUpdateTime = globalClock.getRealTime() self.locationLabel = DirectLabel(parent = self.root, relief = None, text = '', text_font = PiratesGlobals.getPirateOutlineFont(), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_scale = PiratesGuiGlobals.TextScaleTitleJumbo * 0.69999999999999996, text_align = TextNode.ACenter, pos = (0.0, 0.0, 0.51500000000000001), textMayChange = 1) self.locationText = None self.hintLabel = DirectLabel(parent = self.root, relief = None, text = '', text_font = PiratesGlobals.getPirateOutlineFont(), text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_scale = PiratesGuiGlobals.TextScaleTitleJumbo * 0.5, text_align = TextNode.ACenter, pos = (0.0, 0.0, -0.62), text_wordwrap = 30, textMayChange = 1) self.hintText = None self.adImage = None self.allowLiveFlatten = ConfigVariableBool('allow-live-flatten') self.title_art = [] self.tempVolume = [] self.adjustSize(base.win) gsg = base.win.getGsg() if gsg: self.root.prepareScene(gsg) def startLoading(self, expectedLoadScale): if not self.debugMode: self.loadingBar.setSx(0) self.loadScale = float(expectedLoadScale) self.currStage = 'unmapped' self.stagePercent = 0 self.numObjects = 0 self.currPercent = 0.0 self.loadingStart = globalClock.getRealTime() self.currNum = 0 self.overallPercent = 0 self.lastPercent = 0 self.stepNum = 0 if self.debugMode: self.overallLabel['text'] = '0.0' self.stageLabel['text'] = self.currStage self.update() def beginStep(self, stageName, amt = 0, percent = 0.001): if not self.state: return None if self.currStage != 'unmapped' and stageName != self.currStage: if __dev__ and self.debugMode: self.notify.error('step %s not finished when step %s was started!' % (self.currStage, stageName)) else: self.notify.warning('step %s not finished when step %s was started!' % (self.currStage, stageName)) return None self.stepNum += 1 if self.debugMode: stageColor = self.loadingBarColors[self.stepNum] self.stepInfo[stageName] = [ globalClock.getRealTime() - self.loadingStart, 0.0, stageColor, [], self.lastPercent + self.stagePercent, percent, amt] self.stepCard = CardMaker('step-%s' % stageName) self.stepCard.setColor(stageColor) self.currPoly = NodePath('empty') self.stageLabel['text'] = stageName self.tickLabel['text'] = '0.0' self.currPercent = 0.0 self.overallPercent = min(100.0 * self.loadScale, self.lastPercent + self.stagePercent) self.lastPercent = self.overallPercent self.currStage = stageName self.stagePercent = percent self.numObjects = amt self.currNum = 0 base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() def endStep(self, stageName): if self.currStage == 'unmapped': self.notify.warning('step %s was started before loading screen was enabled' % stageName) return None if stageName != self.currStage: if __dev__ and self.debugMode: self.notify.error('step %s was active while step %s was trying to end!' % (self.currStage, stageName)) else: return None self.tick() if self.debugMode: stageInfo = self.stepInfo[self.currStage] stageInfo[1] = globalClock.getRealTime() - self.loadingStart - stageInfo[0] self.currPoly.detachNode() self.stepCard.setFrame((self.lastPercent / self.loadScale) * 0.017999999999999999 - 0.90000000000000002, ((self.lastPercent + self.stagePercent) / self.loadScale) * 0.017999999999999999 - 0.90000000000000002, 0.10000000000000001, 0.5) self.loadingBarRoot.attachNewNode(self.stepCard.generate()) self.stageLabel['text'] = 'unmapped' self.currStage = 'unmapped' self.currPercent = 0.0 def tick(self): if self.state == False or self.analyzeMode: return None if self.debugMode: if self.currStage == 'unmapped': self.unmappedTicks.append(globalClock.getRealTime() - self.loadingStart) else: self.stepInfo[self.currStage][3].append(globalClock.getRealTime() - self.loadingStart) self.currNum += 1 self.currPercent = min(1.0, self.currNum / float(self.numObjects + 1)) self.overallPercent = min(100.0 * self.loadScale, self.lastPercent + self.currPercent * self.stagePercent) self.update() def destroy(self): taskMgr.remove('updateLoadingScreen') for part in (self.model, self.snapshot): if part is not None: tex = part.findTexture('*') if tex: tex.releaseAll() part.removeNode() continue self.model = None self.snapshot = None if self.snapshotFrame: self.snapshotFrame.destroy() if self.snapshotFrameBasic: self.snapshotFrameBasic.destroy() if self.locationLabel: self.locationLabel.destroy() if self.hintLabel: self.hintLabel.destroy() if self.debugMode: self.stageLabel.destroy() self.tickLabel.destroy() self.overallLabel.destroy() self.enterToContinue.destroy() self.stageLabel = None self.tickLabel = None self.overallLabel = None self.enterToContinue = None self.ignoreAll() def showTitleFrame(self): if base.config.GetBool('no-loading-screen', 0): return None for part in self.title_art: part.show() def hideTitleFrame(self): for part in self.title_art: part.hide() def show(self, waitForLocation = False, disableSfx = True, expectedLoadScale = 1.0): if self.state and base.config.GetBool('no-loading-screen', 0) or not (self.locationLabel): return None render.hide() render2d.hide() render2dp.hide() if not self.debugMode: self.loadingPlank.hide() self.root.unstash() self.root.showThrough() self.state = True gsg = base.win.getGsg() if gsg: gsg.setIncompleteRender(False) base.setTaskChainNetNonthreaded() self.allowLiveFlatten.setValue(1) self.startLoading(expectedLoadScale) base.graphicsEngine.renderFrame() base.graphicsEngine.renderFrame() base.refreshAds() taskMgr.add(self.update, 'updateLoadingScreen', priority = -100) if base.sfxManagerList and disableSfx: index = 0 while index < len(base.sfxManagerList): sfx_manager = base.sfxManagerList[index] sfx_manager.setVolume(0.0) index += 1 if base.appRunner: base.appRunner.notifyRequest('onLoadingMessagesStart') self._FancyLoadingScreen__setLocationText(self.locationText) self._FancyLoadingScreen__setHintText(self.hintText) if not waitForLocation: screenshot = random.choice(tutorialShots_MoveAim) self._FancyLoadingScreen__setLoadingArt(screenshot) def showHint(self, destId = None, ocean = False): if base.config.GetBool('no-loading-screen', 0) or not (self.locationLabel): return None if ocean: hint = getOceanHint() elif hasattr(base, 'localAvatar'): totalReputation = 0 level = base.localAvatar.getLevel() if totalReputation: hint = getHint(destId, level) else: hint = getHint(destId) else: hint = getHint() shipPVPIslands = [ '1196970035.53sdnaik', '1196970080.56sdnaik'] if (destId in shipPVPIslands or ocean) and base.localAvatar.getCurrentIsland() in shipPVPIslands: hint = getPrivateeringHint() if self.parent and base.localAvatar.style.getTutorial() == PiratesGlobals.TUT_MET_JOLLY_ROGER: hint = '%s: %s' % (PLocalizer.LoadingScreen_Hint, PLocalizer.GeneralTip7) self._FancyLoadingScreen__setHintText(hint) def update(self, task = None): if not (self.state) or self.analyzeMode: return Task.cont realTime = globalClock.getRealTime() if realTime - self.lastUpdateTime < 0.10000000000000001: return Task.cont self.currentTime += min(10, (realTime - self.lastUpdateTime) * 250) self.lastUpdateTime = realTime if self.debugMode: self.overallLabel['text'] = '%3.1f' % self.overallPercent / self.loadScale self.tickLabel['text'] = '%3.1f' % self.currPercent * 100.0 else: self.percentLabel['text'] = '%d%%' % self.overallPercent / self.loadScale if self.currStage != 'unmapped': if self.debugMode: self.currPoly.detachNode() self.stepCard.setFrame((self.lastPercent / self.loadScale) * 0.017999999999999999 - 0.90000000000000002, (self.overallPercent / self.loadScale) * 0.017999999999999999 - 0.90000000000000002, 0.20000000000000001, 0.40000000000000002) self.currPoly = self.loadingBarRoot.attachNewNode(self.stepCard.generate()) if not self.debugMode: self.loadingBar.setSx((self.overallPercent / self.loadScale) * 3.3999999999999999) if self.overallPercent > 0: self.loadingPlank.show() base.eventMgr.doEvents() base.graphicsEngine.renderFrame() return Task.cont def hide(self, reallyHide = not (config.GetInt('loading-screen', 0) == 2)): if not self.state: return None if not reallyHide: if not self.analyzeMode: self.loadingEnd = globalClock.getRealTime() self.accept('shift', self.hide, extraArgs = [ 1]) self.enterToContinue.show() self.generateAnalysis() return None self.cleanupLoadingScreen() if self.debugMode: self.enterToContinue.hide() self.ignore('shift') self.root.hide() self.root.stash() render2d.show() render2dp.show() render.show() base.graphicsEngine.renderFrame() self.state = False self.currentTime = 0 self.locationText = None self.hintText = None self.currScreenshot = None gsg = base.win.getGsg() if gsg: gsg.setIncompleteRender(True) render.prepareScene(gsg) render2d.prepareScene(gsg) taskMgr.remove('updateLoadingScreen') self.allowLiveFlatten.clearValue() base.setTaskChainNetThreaded() if base.sfxManagerList: index = 0 while index < len(base.sfxManagerList): sfx_manager = base.sfxManagerList[index] sfx_manager.setVolume(base.options.sound_volume) index += 1 messenger.send('texture_state_changed') if base.appRunner: base.appRunner.notifyRequest('onLoadingMessagesStop') def showTarget(self, targetId = None, ocean = False, jail = False, pickapirate = False, exit = False, potionCrafting = False, benchRepair = False, shipRepair = False, cannonDefense = False, fishing = False): if base.config.GetBool('no-loading-screen', 0): return None if pickapirate: screenshot = screenShot_EnterGame elif exit: screenshot = screenShot_ExitGame elif ocean: screenshot = screenShot_Dinghy elif jail: screenshot = screenShot_Jail elif potionCrafting: screenshot = screenShot_Potions elif benchRepair: screenshot = screenShot_BenchRepair elif shipRepair: screenshot = screenShot_ShipRepair elif cannonDefense: screenshot = screenShot_CannonDefense elif fishing: screenshot = screenShot_Fishing elif base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_GOT_CUTLASS: screenshot = screenShot_Weapon elif base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_MET_JOLLY_ROGER: screenshot = screenShot_Cutlass elif base.cr.newsManager and base.cr.newsManager.getHoliday(21): screenshot = screenShots_WinterHolidayLocations.get(targetId) if not screenshot: screenshot = screenShots_Locations.get(targetId) else: screenshot = screenShots_Locations.get(targetId) if not screenshot: if areaType_Jungles.has_key(targetId): screenshot = random.choice(screenShots_Jungles) elif areaType_Swamps.has_key(targetId): screenshot = random.choice(screenShots_Swamps) elif areaType_Caves.has_key(targetId): screenshot = random.choice(screenShots_Caves) else: island = getParentIsland(targetId) screenshot = screenShots_Locations.get(island, [ random.choice(screenShots)])[0] elif len(screenshot) > 1: screenshot = random.choice(screenshot) else: screenshot = screenshot[0] self._FancyLoadingScreen__setLoadingArt(screenshot) if pickapirate: targetName = PLocalizer.LoadingScreen_PickAPirate elif exit: targetName = None elif ocean: targetName = PLocalizer.LoadingScreen_Ocean elif jail: targetName = PLocalizer.LoadingScreen_Jail else: targetName = PLocalizer.LocationNames.get(targetId) base.setLocationCode('Loading: %s' % targetName) if targetName is None: return None if len(targetName): self._FancyLoadingScreen__setLocationText(targetName) def _FancyLoadingScreen__setLoadingArt(self, screenshot): if self.currScreenshot: return None if self.parent and hasattr(base, 'localAvatar') and base.localAvatar.style.getTutorial() < PiratesGlobals.TUT_MET_JOLLY_ROGER and screenshot not in tutorialShots: screenshot = random.choice(tutorialShots) self.currScreenshot = loader.loadModel(screenshot).findAllTextures()[0] if not self.debugMode: self.screenshot.setTexture(self.currScreenshot) def _FancyLoadingScreen__setLocationText(self, locationText): if self.debugMode: return None self.locationText = locationText if not self.locationText: self.locationText = '' self.titlePlank.hide() if len(self.locationText) > 12: scaleFactor = len(self.locationText) / 12.0 self.titlePlankMiddle.setSx(scaleFactor) self.titlePlankRight.setX(0.215 * scaleFactor - 0.215) self.titlePlankLeft.setX(-1 * (0.215 * scaleFactor - 0.215)) else: self.titlePlankMiddle.setSx(1) self.titlePlankRight.setX(0) self.titlePlankLeft.setX(0) self.locationLabel['text'] = self.locationText if self._FancyLoadingScreen__isVisible() and len(self.locationText): self.locationLabel.show() self.titlePlank.show() else: self.locationLabel.hide() self.titlePlank.hide() launcher.setValue('gameLocation', self.locationText) def _FancyLoadingScreen__setHintText(self, hintText): self.hintText = hintText if not self.hintText: self.hintText = '' self.hintLabel['text'] = self.hintText if self._FancyLoadingScreen__isVisible(): self.hintLabel.show() def _FancyLoadingScreen__isVisible(self): return self.state def scheduleHide(self, function): base.cr.queueAllInterestsCompleteEvent() self.acceptOnce(function, self.interestComplete) def interestComplete(self): self.endStep('scheduleHide') self.hide() def _FancyLoadingScreen__setAdArt(self): return None imageFrame = self.model.find('**/frame') randomImageNumber = random.randint(0, len(screenShots) - 1) imageFileName = screenShots[randomImageNumber] self.adImage = loader.loadModel(imageFileName) self.adImage.reparentTo(imageFrame) self.adImage.setScale(2.1499999999999999 * 5, 1, 1.2 * 5) self.adImage.setPos(0, 0, 2.2999999999999998) self.adImage.setBin('fixed', 1) if randomImageNumber == 0: urlToGet = 'http://log.go.com/log?srvc=dis&guid=951C36F8-3ACD-4EB2-9F02-8E8A0A217AF5&drop=0&addata=3232:64675:408091:64675&a=0' self.httpSession = HTTPClient() self.nonBlockHTTP = self.httpSession.makeChannel(False) self.nonBlockHTTP.beginGetDocument(DocumentSpec(urlToGet)) instanceMarker = 'FunnelLoggingRequest-%s' % str(random.randint(1, 1000)) self.startCheckingAsyncRequest(instanceMarker) def startCheckingAsyncRequest(self, name): taskMgr.remove(name) taskMgr.doMethodLater(0.5, self.pollAdTask, name) def pollAdTask(self, task): result = self.nonBlockHTTP.run() if result == 0: self.stopCheckingAdTask(task) else: return Task.again def stopCheckingAdTask(self, name): taskMgr.remove(name) def cleanupLoadingScreen(self): if self.debugMode: self.loadingBarRoot.removeChildren() self.cleanupAnalysis() self.stepInfo = { } self.unmappedTicks = [] def showInfo(self, stepName, pos): self.stageLabel['text'] = stepName info = self.stepInfo[stepName] self.tickLabel['text'] = '%s ticks(%s)' % (len(info[3]), info[6]) self.overallLabel['text'] = '%3.2f seconds (%d%%)' % (info[1], 100 * info[1] / (self.loadingEnd - self.loadingStart)) def generateAnalysis(self): if self.analyzeMode: self.cleanupAnalysis() self.analyzeMode = True cm = CardMaker('cm') self.analysisBar.show() loadingTime = self.loadingEnd - self.loadingStart for stepName in self.stepInfo: (startTime, duration, color, ticks, startPercent, percent, expectedTicks) = self.stepInfo[stepName] cm.setName(stepName) cm.setColor(color) cm.setFrame((startTime / loadingTime) * 1.8 - 0.90000000000000002, ((startTime + duration) / loadingTime) * 1.8 - 0.90000000000000002, -0.5, -0.10000000000000001) self.analysisBarRoot.attachNewNode(cm.generate()) button = DirectFrame(parent = self.analysisBarRoot, geom = NodePath('empty'), image = NodePath('empty'), state = DGG.NORMAL, relief = None, frameSize = ((startTime / loadingTime) * 1.8 - 0.90000000000000002, ((startTime + duration) / loadingTime) * 1.8 - 0.90000000000000002, -0.5, -0.10000000000000001)) button.bind(DGG.ENTER, self.showInfo, extraArgs = [ stepName]) self.analysisButtons.append(button) button = DirectFrame(parent = self.analysisBarRoot, geom = NodePath('empty'), image = NodePath('empty'), state = DGG.NORMAL, relief = None, frameSize = ((startPercent / self.loadScale / 100.0) * 1.8 - 0.90000000000000002, ((startPercent + percent) / self.loadScale / 100.0) * 1.8 - 0.90000000000000002, 0.10000000000000001, 0.5)) button.bind(DGG.ENTER, self.showInfo, extraArgs = [ stepName]) self.analysisButtons.append(button) for tick in ticks: self.line.moveTo(VBase3((tick / loadingTime) * 1.8 - 0.90000000000000002, 0, -0.5)) self.line.drawTo(VBase3((tick / loadingTime) * 1.8 - 0.90000000000000002, 0, -0.55000000000000004)) for tick in self.unmappedTicks: self.line.moveTo(VBase3((tick / loadingTime) * 1.8 - 0.90000000000000002, 0, -0.5)) self.line.drawTo(VBase3((tick / loadingTime) * 1.8 - 0.90000000000000002, 0, -0.55000000000000004)) self.analysisSegs = self.analysisBarRoot.attachNewNode(self.line.create()) def cleanupAnalysis(self): for button in self.analysisButtons: button.destroy() self.analysisButtons = [] self.analysisBarRoot.removeChildren() self.analysisBar.hide() self.analyzeMode = False self.analysisSegs = None def adjustSize(self, window): x = max(1, window.getXSize()) y = max(1, window.getYSize()) minSz = min(x, y) aspect = float(x) / y if x > y: self.topLock.setZ(1) else: self.topLock.setZ(float(y) / x) if minSz > IDEALX: self.topLock.setScale(IDEALX / float(x)) elif minSz > IDEALY: self.topLock.setScale(IDEALY / float(y)) else: self.topLock.setScale(1.0)