Example #1
0
def OnLogin():
    global _savePeriod
    global _displaySeconds
    global _watchSpan
    global _allowedTime
    global _schedule
    if boot.region != 'optic' or not AmIUnderage():
        return
    if prefs.GetValue('aaTestTimes', 0):
        _watchSpan = _testWatchSpan
        _allowedTime = _testAllowedTime
        _schedule = _testSchedule
        _savePeriod = _testSavePeriod
        _displaySeconds = True
    else:
        _watchSpan = _liveWatchSpan
        _allowedTime = _liveAllowedTime
        _schedule = _liveSchedule
        _savePeriod = _liveSavePeriod
        _displaySeconds = False
    sessionID = StartSession()
    uthread.worker('antiaddiction::EndSession', lambda : EndSessionWorker(sessionID))

    def ActionWrap(action, time):
        return lambda : action(time)

    t = TimeLeft()
    for time, action in _schedule:
        if t <= time:
            action(t)
            break
        else:
            Schedule(t - time, ActionWrap(action, time))
Example #2
0
 def _PerformUICallback(self, callbackKey):
     callback = self.uiCallbackDict.get(callbackKey, None)
     if callback is not None:
         uthread.worker('_PerformUICallback_%s' % callbackKey, self._PerformUICallbackTasklet, callbackKey, callback)
         return True
     self.LogError('ActionObject.PerformUICallback: Unknown callbackKey', callbackKey)
     return False
Example #3
0
    def OnObjectPublicAttributesUpdated(self, uuid, pa, args, keywords):
        for sess in base.GetSessions():
            try:
                if sess.machoObjectConnectionsByObjectID.get(uuid, 0):
                    for conn in sess.machoObjectConnectionsByObjectID[uuid][1].itervalues():
                        k = keywords.get('partial', [])
                        if k:
                            old = {}
                            for each in k:
                                old[each] = conn.__publicattributes__[each]
                                conn.__publicattributes__[each] = pa[each]

                        else:
                            old = conn.__publicattributes__
                            conn.__publicattributes__ = pa
                        for each in conn.objectChangeHandlers.iterkeys():
                            try:
                                func = getattr(each, 'OnObjectChanged')
                            except StandardError:
                                log.LogException()
                                sys.exc_clear()
                                continue

                            theArgs = [conn, old, conn.__publicattributes__] + list(args)
                            uthread.worker('machoNet::OnObjectChanged', func, *theArgs, **keywords)

            except Exception:
                log.LogException('Exception during OnObjectPublicAttributesUpdated')
                sys.exc_clear()
Example #4
0
 def LoadHintFromItem(self, item, force):
     if item is None or uicore.uilib.leftbtn:
         self.FadeOpacity(0.0)
         self._lastHintInfo = None
         return
     hint = None
     if getattr(item, 'GetHint', None) is not None:
         hint = item.GetHint()
     hint = hint or getattr(item, 'hint', None)
     if hint is None and getattr(item, 'sr', None):
         hint = item.sr.Get('hint', None)
     if item.auxiliaryHint:
         if hint:
             hint += '<br>' + item.auxiliaryHint
         else:
             hint = item.auxiliaryHint
     if not hint:
         self.FadeOpacity(0.0)
         self._lastHintInfo = None
         return
     lastHint = getattr(self, '_lastHintInfo', None)
     if not lastHint or lastHint != (id(item), hint):
         self._lastHintInfo = (id(item), hint)
         uthread.worker('UICoreHint::LoadHintFromItem',
                        self._LoadHintFromItemThread, item, hint)
Example #5
0
def OnLogin():
    global _savePeriod
    global _displaySeconds
    global _watchSpan
    global _allowedTime
    global _schedule
    if boot.region != 'optic' or not AmIUnderage():
        return
    if prefs.GetValue('aaTestTimes', 0):
        _watchSpan = _testWatchSpan
        _allowedTime = _testAllowedTime
        _schedule = _testSchedule
        _savePeriod = _testSavePeriod
        _displaySeconds = True
    else:
        _watchSpan = _liveWatchSpan
        _allowedTime = _liveAllowedTime
        _schedule = _liveSchedule
        _savePeriod = _liveSavePeriod
        _displaySeconds = False
    sessionID = StartSession()
    uthread.worker('antiaddiction::EndSession',
                   lambda: EndSessionWorker(sessionID))

    def ActionWrap(action, time):
        return lambda: action(time)

    t = TimeLeft()
    for time, action in _schedule:
        if t <= time:
            action(t)
            break
        else:
            Schedule(t - time, ActionWrap(action, time))
Example #6
0
 def Start(self, duration):
     if not settings.user.ui.Get('turretsEnabled', 1):
         return
     shipID = self.ballIDs[0]
     shipBall = self.fxSequencer.GetBall(shipID)
     targetID = self.ballIDs[1]
     targetBall = self.fxSequencer.GetBall(targetID)
     if targetBall is None:
         return
     if shipBall is None:
         return
     if not hasattr(shipBall, 'fitted'):
         self.fxSequencer.LogError(
             self.__guid__ + str(shipBall.id) +
             ' Turrets: Error! can not fit turrets. No fitted attribute ')
         return
     if not shipBall.fitted:
         shipBall.FitHardpoints(blocking=True)
     if shipBall.modules is None:
         return
     self.turret = shipBall.modules.get(self.moduleID)
     if getattr(self, 'turret', None) is None:
         self.fxSequencer.LogError('Turret not fitted on shipID', shipID)
         return
     if hasattr(self.turret, 'SetAmmoColor'):
         self.SetAmmoColor()
     uthread.worker('FxSequencer::ShootTurrets', self.Shoot, shipID,
                    targetID)
Example #7
0
 def FadeOpacity(self, toOpacity):
     if toOpacity == getattr(self, '_settingOpacity', None):
         return
     self._newOpacity = toOpacity
     self._settingOpacity = toOpacity
     uthread.worker('UICoreHint::FadeOpacity', self.FadeOpacityThread,
                    toOpacity)
Example #8
0
 def Start(self, duration):
     if self.gfx is None:
         return
     self.gfx.display = False
     self.hasExploded = False
     self.hasWind = False
     self.hasMoreCollisions = True
     self.findNext = True
     ShipEffect.Start(self, duration)
     bp = sm.StartService('michelle').GetBallpark()
     shipID = self.GetEffectShipID()
     shipBall = bp.GetBall(shipID)
     self.shipBall = shipBall
     self.shipModel = getattr(shipBall, 'model', None)
     self.shipBall.RegisterModelChangeNotification(self.ModelChangeNotify)
     slimItem = bp.GetInvItem(shipID)
     self.warpSpeedModifier = sm.StartService('godma').GetTypeAttribute(slimItem.typeID, const.attributeWarpSpeedMultiplier)
     if self.warpSpeedModifier is None:
         self.warpSpeedModifier = 1.0
     space = sm.GetService('space')
     self.SetupTunnelBindings()
     self.nextCollision = None
     self.insideSolid = False
     self.destination = space.warpDestinationCache[3]
     self.collisions = []
     self.collisions = self.GetWarpCollisions(shipBall)
     self.ControlFlow('NextCollision')
     uthread.worker('FxSequencer::WarpEffectLoop', self.WarpLoop, shipBall)
Example #9
0
 def OnFleetBroadcast_Local(self, broadcast):
     caption = broadcast.broadcastLabel
     iconName = fleetbr.defaultIcon[1]
     t = fleetbr.types.get(broadcast.name, None)
     if t:
         iconName = t['smallIcon']
     self.sr.lastBroadcastCont.Flush()
     uicontrols.EveLabelMedium(text=caption,
                               parent=self.sr.lastBroadcastCont,
                               align=uiconst.TOALL,
                               left=25,
                               maxLines=1,
                               state=uiconst.UI_DISABLED)
     self.sr.lastBroadcastCont.GetMenu = lambda: self.GetLastBroadcastMenu(
         broadcast)
     self.sr.lastBroadcastCont.OnClick = lambda: self.OnLastBroadcastClick(
         broadcast)
     self.sr.lastBroadcastCont.hint = localization.GetByLabel(
         'UI/Fleet/FleetBroadcast/BroadcastNotificationHint',
         eventLabel=broadcast.broadcastLabel,
         time=broadcast.time,
         charID=broadcast.charID,
         range=fleetbr.GetBroadcastScopeName(broadcast.scope,
                                             broadcast.where),
         role=fleetbr.GetRankName(
             sm.GetService('fleet').GetMemberInfo(int(broadcast.charID))))
     icon = uicontrols.Icon(icon=iconName,
                            parent=self.sr.lastBroadcastCont,
                            align=uiconst.RELATIVE,
                            pos=(6, 0, 16, 16),
                            state=uiconst.UI_DISABLED)
     uthread.worker('fleet::flash', self.Flash, icon)
Example #10
0
 def Start(self, duration):
     if not gfxsettings.Get(gfxsettings.UI_TURRETS_ENABLED):
         return
     shipID = self.ballIDs[0]
     shipBall = self.fxSequencer.GetBall(shipID)
     targetID = self.ballIDs[1]
     targetBall = self.fxSequencer.GetBall(targetID)
     if targetBall is None:
         return
     if shipBall is None:
         return
     if not hasattr(shipBall, 'fitted'):
         self.fxSequencer.LogError(
             self.__guid__ + str(shipBall.id) +
             ' Turrets: Error! can not fit turrets. No fitted attribute ')
         return
     shipBall.FitHardpoints(blocking=True)
     if not shipBall.fitted:
         return
     if shipBall.modules is None:
         return
     shipBall.PrepareForFiring()
     self.turret = shipBall.modules.get(self.moduleID)
     if not self.turret:
         self.fxSequencer.LogError(
             'StandardWeapon: Turret not fitted on shipID', shipID)
         return
     if hasattr(self.turret, 'SetAmmoColor'):
         self.SetAmmoColor()
     uthread.worker('FxSequencer::ShootTurrets', self.Shoot, shipID,
                    targetID)
Example #11
0
 def Start(self, duration):
     if not gfxsettings.Get(gfxsettings.UI_TURRETS_ENABLED):
         return
     shipID = self.ballIDs[0]
     shipBall = self.fxSequencer.GetBall(shipID)
     targetID = self.ballIDs[1]
     targetBall = self.fxSequencer.GetBall(targetID)
     if targetBall is None:
         return
     if shipBall is None:
         return
     if shipBall == targetBall:
         return
     if not hasattr(shipBall, 'fitted'):
         return
     shipBall.FitHardpoints(blocking=True)
     if not shipBall.fitted:
         return
     if shipBall.modules is None:
         return
     self.turret = shipBall.modules.get(self.moduleID)
     if not self.turret:
         self.turret = shipBall.modules.get(0)
         if not self.turret:
             self.fxSequencer.LogError(
                 'MissileLaunch: Turret not fitted on shipID', shipID,
                 self.moduleID)
             return
     uthread.worker('FxSequencer::ShootTurrets', self.Shoot, shipID,
                    targetID)
Example #12
0
    def __UberMachoRemoteServiceCall(self, sess, service, method, nodes, *args, **keywords):
        retvals = []
        dude = UberDude(len(nodes), service, method)
        if not len(nodes):
            raise UnMachoDestination('No target nodes available for UberMachoRemoteServiceCall')
        uberMachoRaise = keywords.get('uberMachoRaise', False)
        if 'uberMachoRaise' in keywords:
            keywords = copy.copy(keywords)
            del keywords['uberMachoRaise']
        if 'machoTimeout' in keywords:
            keywords = copy.copy(keywords)
        else:
            keywords['machoTimeout'] = 60
        machoTimeout = keywords.get('machoTimeout', 60)
        for each in nodes:
            uthread.worker(blue.pyos.taskletTimer.GetCurrent() + '::RPC', UnterMachoRemoteServiceCall, self, dude, retvals, sess, each, service, method, args, keywords)

        if dude.Await(machoTimeout) == 2:
            log.LogTraceback('Local Timeout')
            n = copy.copy(nodes)
            for r in retvals:
                n.remove(r[1])

            for nodeID in n:
                self.machoNet.LogError('Node ', nodeID, " has not completed it's uber-macho call")
                retvals.append((1, nodeID, RuntimeError('Local Timeout')))

        if uberMachoRaise:
            for isexception, nodeID, ret in retvals:
                if isexception:
                    raise UberMachoException(retvals)

        return retvals
Example #13
0
 def Start(self, duration):
     if not gfxsettings.Get(gfxsettings.UI_TURRETS_ENABLED):
         return
     shipID = self.ballIDs[0]
     shipBall = self.fxSequencer.GetBall(shipID)
     targetID = self.ballIDs[1]
     targetBall = self.fxSequencer.GetBall(targetID)
     if targetBall is None:
         return
     if shipBall is None:
         return
     if not hasattr(shipBall, 'fitted'):
         self.fxSequencer.LogError(self.__guid__ + str(shipBall.id) + ' Turrets: Error! can not fit turrets. No fitted attribute ')
         return
     shipBall.FitHardpoints(blocking=True)
     if not shipBall.fitted:
         return
     if shipBall.modules is None:
         return
     self.turret = shipBall.modules.get(self.moduleID)
     if not self.turret:
         self.fxSequencer.LogError('StandardWeapon: Turret not fitted on shipID', shipID)
         return
     if hasattr(self.turret, 'SetAmmoColor'):
         self.SetAmmoColor()
     uthread.worker('FxSequencer::ShootTurrets', self.Shoot, shipID, targetID)
Example #14
0
 def Start(self, duration):
     if not gfxsettings.Get(gfxsettings.UI_TURRETS_ENABLED):
         return
     shipID = self.ballIDs[0]
     shipBall = self.fxSequencer.GetBall(shipID)
     targetID = self.ballIDs[1]
     targetBall = self.fxSequencer.GetBall(targetID)
     if targetBall is None:
         return
     if shipBall is None:
         return
     if shipBall == targetBall:
         return
     if not hasattr(shipBall, 'fitted'):
         return
     shipBall.FitHardpoints(blocking=True)
     if not shipBall.fitted:
         return
     if shipBall.modules is None:
         return
     self.turret = shipBall.modules.get(self.moduleID)
     if not self.turret:
         self.turret = shipBall.modules.get(0)
         if not self.turret:
             self.fxSequencer.LogError('MissileLaunch: Turret not fitted on shipID', shipID, self.moduleID)
             return
     uthread.worker('FxSequencer::ShootTurrets', self.Shoot, shipID, targetID)
Example #15
0
    def RemoveSessionsFromServer(self, nodeID, sessionIDs):
        """
        On proxy: remove the sessions 'sessionIDs' from server node 'nodeID',
        by faking TransportClosed messages. This call comes from server 'nodeID', it having detected
        that the sessions are no longer relevant to the server. Note that the sessions are _not_ removed
        from the proxy and that "race conditions" are OK: in the worst-case a removed relevant session
        will be re-JITed to the server again, ahead of a notification or call.
        """
        if machobase.mode != 'proxy':
            raise RuntimeError(
                'RemoveSessionsFromServer should only be called on a proxy')
        log.LogInfo('CTXSESS: RemoveSessionsFromServer(nodeID=', nodeID,
                    '), with ', len(sessionIDs), ' session IDs')
        mn = sm.services['machoNet']
        serverTID = mn.transportIDbySolNodeID.get(nodeID, None)
        if serverTID is not None:
            serverTransport = mn.transportsByID[serverTID]
            for sid in sessionIDs:
                sess = sessionsBySID.get(sid, None)
                if sess is not None:
                    uthread.worker('SessionMgr::RemoveSesssionsFromServer',
                                   serverTransport.RemoveSessionFromServer,
                                   sess)

        else:
            log.LogWarning(
                'RemoveSessionsFromServer() called with unknown or non-server nodeID ',
                nodeID)
Example #16
0
 def Start(self, duration):
     if self.gfx is None:
         return
     self.gfx.display = False
     self.hasExploded = False
     self.hasWind = False
     self.hasMoreCollisions = True
     self.findNext = True
     ShipEffect.Start(self, duration)
     bp = sm.StartService('michelle').GetBallpark()
     shipID = self.GetEffectShipID()
     shipBall = bp.GetBall(shipID)
     self.shipBall = shipBall
     self.shipModel = getattr(shipBall, 'model', None)
     self.shipBall.RegisterModelChangeNotification(self.ModelChangeNotify)
     slimItem = bp.GetInvItem(shipID)
     self.warpSpeedModifier = sm.StartService('godma').GetTypeAttribute(
         slimItem.typeID, const.attributeWarpSpeedMultiplier)
     if self.warpSpeedModifier is None:
         self.warpSpeedModifier = 1.0
     space = sm.GetService('space')
     self.SetupTunnelBindings()
     self.nextCollision = None
     self.insideSolid = False
     self.destination = space.warpDestinationCache[3]
     self.collisions = []
     self.collisions = self.GetWarpCollisions(shipBall)
     self.ControlFlow('NextCollision')
     uthread.worker('FxSequencer::WarpEffectLoop', self.WarpLoop, shipBall)
Example #17
0
 def QueuedcastWithoutTheStars(self, idtype, ids, method, args):
     if ids:
         self.queue.append((idtype, tuple(ids), method, args))
         if not self.busrunning:
             self.busrunning = 1
             uthread.worker('MachoNet::BroadcastStuff::BusDriver',
                            self.__BusDriver)
Example #18
0
    def Network(self):
        if self.machoNet.GetNodeID() > const.maxNodeID:
            solPackets = float(self.packetsP2S) / self.netTasklets
            proxyPackets = 0
        else:
            proxyPackets = float(self.packetsS2P) / self.netTasklets
            solPackets = float(self.packetsS2S) / self.netTasklets
        if solPackets:
            nodes = self.machoNet.GetConnectedSolNodes()
            nodes = [ (node, self.session.ConnectToRemoteService('loadService', node)) for node in nodes ]
            randomNodes = self.NodeRandomizer(nodes)

            def func():
                self.NetworkSendPacket(randomNodes)

            interval = 1.0 / solPackets if solPackets > 0.0 else 0.0
            uthread.worker('loadServiceService::NetworkTraffic::ToSolServers', self.TaskletWrap(self.IntervalDispatcher), interval, self.netStats, func)
        if proxyPackets:
            nodes = self.machoNet.GetConnectedProxyNodes()
            nodes = [ (node, self.session.ConnectToRemoteService('loadService', node)) for node in nodes ]
            randomNodes = self.NodeRandomizer(nodes)

            def func():
                self.NetworkSendPacket(randomNodes)

            interval = 1.0 / proxyPackets if proxyPackets > 0.0 else 0.0
            uthread.worker('loadServiceService::NetworkTraffic::ToProxyServers', self.TaskletWrap(self.IntervalDispatcher), interval, self.netStats, func)
Example #19
0
 def Explode(self):
     if self.exploded:
         return False
     self.exploded = True
     if self.model is None:
         return False
     uthread.worker('wormhole:PlayDeath', self.PlayDeath)
     return 2000
Example #20
0
    def ImportCharacter(factory, scene, resPath, **kwargs):
        blocking = kwargs.get('blocking')
        callBack = kwargs.get('callBack')
        rotation = kwargs.get('rotation')
        position = kwargs.get('point')
        pdc = PaperDollCharacter(factory)
        pdc.scene = scene
        pdc.avatar = trinity.Load(resPath + '/unique.red')
        if pdc.avatar is None:
            log.LogInfo('Import failed on ' + resPath + '/unique.red')
            return
        pdc.visualModel = pdc.avatar.visualModel
        slash = resPath.rfind('/')
        pdc.avatar.name = str(resPath[slash + 1:] + ' (import)')
        if position:
            pdc.avatar.translation = position
        if rotation:
            pdc.avatar.rotation = rotation
        rf = blue.ResFile()
        bsPath = resPath + '/blendshapes.yaml'
        meshes = None
        morphTargets = None
        if rf.FileExists(bsPath):
            f = rf.open(bsPath)
            morphTargets = yaml.load(f, Loader=yaml.CLoader)
            f.close()
            if morphTargets:
                meshes = pdc.visualModel.meshes

        def fun():
            if meshes:
                factory.ApplyMorphTargetsToMeshes(meshes, morphTargets)
                if trinity.GetShaderModel() == 'SM_2_0_LO':
                    PD.PortraitTools.RebindDXT5ShadersForSM2(meshes)
            if callBack:
                callBack()

        if blocking:
            fun()
        else:
            uthread.worker('paperDoll::PaperDollCharacter::ImportCharacter', fun)
        scene.AddDynamic(pdc.avatar)
        rf = blue.ResFile()
        aoPath = resPath + '/animationOffsets.yaml'
        if rf.FileExists(aoPath):
            f = rf.open(aoPath)
            animationOffsets = yaml.load(f, Loader=yaml.CLoader)
            f.close()
            if animationOffsets:
                pdc.ApplyAnimationOffsets(animationOffsets)
        pdc.avatar.explicitMinBounds = (-5, -5, -5)
        pdc.avatar.explicitMaxBounds = (5, 5, 5)
        pdc.avatar.useExplicitBounds = True
        if PD.SkinSpotLightShadows.instance is not None:
            for mesh in pdc.visualModel.meshes:
                PD.SkinSpotLightShadows.instance.CreateEffectParamsForMesh(mesh)

        return pdc
Example #21
0
def DoMethodLater(waitDuration, launchFunction, *args, **kwargs):
    """
    Launches a new thread. On the new thread, it sleeps for 'waitTime' and then calls 'launchFunction' with the specified arguments.
    waitDuration is in blue time!
    """
    launchTime = blue.os.GetWallclockTime() + waitDuration
    uthread.worker(('doMethodLater-' + launchFunction.__name__),
                   SleepAndCallAtTime, launchTime, launchFunction, *args,
                   **kwargs)
Example #22
0
 def _Close(self, s, noSend):
     flag = log.LGWARN
     if self.closeReason and self.closeReason.get('exception', None) is None:
         flag = log.LGINFO
     mylog.Log('Closing connection to ' + self.address + ': ' + repr(self.closeReason), flag)
     if noSend:
         SocketTransport._Close(self, s, noSend)
     else:
         uthread.worker('Socket::DelayedClose', self._DelayedClose, s)
Example #23
0
 def QueuedcastWithoutTheStars(self, idtype, ids, method, args):
     if ids:
         self.queue.append((idtype,
          tuple(ids),
          method,
          args))
         if not self.busrunning:
             self.busrunning = 1
             uthread.worker('MachoNet::BroadcastStuff::BusDriver', self.__BusDriver)
 def __CacheIsDirty(self, what, key):
     if macho.mode == 'client':
         ret = blue.os.GetWallclockTime()
         shouldFlush = len(self.lastChange) == 0
         self.lastChange[what, key] = ret
         filename = self.cachePath + what + '/%s.cache' % self.KeyToFileName(key)
         self.downloadedCachedObjects[key] = filename
         if shouldFlush:
             uthread.worker('objectCaching::FlushCache', self.__FlushCache, True)
         return ret
Example #25
0
 def __init__(self):
     self._InitializeInternalVariables()
     self._InitializeTextData()
     self._importantNameSetting = None
     self._languageTooltipSetting = None
     self._qaTooltipOverride = None
     self._highlightImportantSetting = None
     uthread.worker('localization::_SetHardcodedStringDetection', self._SetHardcodedStringDetection)
     message = 'Cerberus localization module loaded on ' + boot.role
     LogInfo(message)
     print message
Example #26
0
    def ScatterEventWithoutTheStars(self, eventid, args, keywords=None):
        if keywords is None:
            keywords = {}
        if not eventid.startswith('On'):
            self.LogError(
                'ScatterEvent called with event ', eventid,
                ".  All events sent via ScatterEvent should start with 'On'.")
            self.LogError(
                "Not only is the programmer responsible for this a 10z3r, but he wears his mother's underwear as well"
            )
            log.LogTraceback()
        shouldLogMethodCalls = self.ShouldLogMethodCalls()
        if shouldLogMethodCalls:
            if IsFullLogging():
                self.LogMethodCall('ScatterEvent(', eventid, ',*args=', args,
                                   ',**kw=', keywords, ')')
            else:
                self.LogMethodCall('ScatterEvent(', eventid, ')')
        prefix = blue.pyos.taskletTimer.GetCurrent(
        ) + '::ScatterEvent_' + eventid + '::'
        for srv in self.notify.get(eventid, []):
            try:
                logname = prefix + self.GetLogName(srv)
                if ObjectShouldReceiveMessages(srv):
                    if shouldLogMethodCalls:
                        self.LogMethodCall('Calling ', logname)
                    srvGuid = getattr(srv, '__guid__', logname)
                    uthread.worker(prefix + srvGuid,
                                   self.MollycoddledUthread, srvGuid, eventid,
                                   getattr(srv, eventid), args, keywords)
                elif shouldLogMethodCalls:
                    self.LogMethodCall('Skipping ', logname,
                                       ' (service not running)')
            except Exception:
                log.LogException()

        notifiedToRemove = []
        for weakObj in self.notifyObs.get(eventid, []):
            try:
                obj = weakObj()
                func = getattr(obj, eventid, None)
                if obj is None or func is None:
                    notifiedToRemove.append(weakObj)
                else:
                    if shouldLogMethodCalls:
                        logname = prefix + str(obj)
                        self.LogMethodCall('Calling ', logname)
                    uthread.workerWithoutTheStars('', func, args, keywords)
            except Exception:
                log.LogException()

        for toRemove in notifiedToRemove:
            if toRemove in self.notifyObs[eventid]:
                self.notifyObs[eventid].remove(toRemove)
Example #27
0
 def __CacheIsDirty(self, what, key):
     if macho.mode == 'client':
         ret = blue.os.GetWallclockTime()
         shouldFlush = len(self.lastChange) == 0
         self.lastChange[what, key] = ret
         filename = self.cachePath + what + '/%s.cache' % self.KeyToFileName(
             key)
         self.downloadedCachedObjects[key] = filename
         if shouldFlush:
             uthread.worker('objectCaching::FlushCache', self.__FlushCache,
                            True)
         return ret
Example #28
0
 def __init__(self):
     self._InitializeInternalVariables()
     self._InitializeTextData()
     self._importantNameSetting = None
     self._languageTooltipSetting = None
     self._qaTooltipOverride = None
     self._highlightImportantSetting = None
     uthread.worker('localization::_SetHardcodedStringDetection',
                    self._SetHardcodedStringDetection)
     message = 'Cerberus localization module loaded on ' + boot.role
     LogInfo(message)
     print message
Example #29
0
 def LoadDollFromDNA(self, dollDNA, dollName = None, lodEnabled = True, compressionSettings = None):
     name = dollName if dollName is not None else PaperDollCharacter.__DEFAULT_NAME
     self.doll = PD.Doll(name)
     self.doll.LoadDNA(dollDNA, self.factory)
     if compressionSettings:
         self.doll.compressionSettings = compressionSettings
     if self.avatar:
         gender = PD.GENDER.MALE if self.doll.gender else PD.GENDER.FEMALE
         networkToLoad = const.FEMALE_MORPHEME_PATH if gender == PD.GENDER.FEMALE else const.MALE_MORPHEME_PATH
         if lodEnabled:
             uthread.worker('^PaperDollCharacter::LoadFromDNA', PD.SetupLODFromPaperdoll, self.avatar, self.doll, self.factory, networkToLoad)
         else:
             uthread.worker('^PaperDollCharacter::LoadFromDNA', self.doll.Update, self.factory, self.avatar)
Example #30
0
 def UberMachoRemoteServiceCall(self, nodeGroup, batchInterval, sess, service, method, *args, **keywords):
     if batchInterval:
         queue = sess.GetSessionVariable(('batchedCallQueue', batchInterval), ({}, {}))
         if not queue[0]:
             uthread.worker('GPCS::BroadcastStuff::BatchedUberMachoRemoteServiceCall', self.__BatchedUberMachoRemoteServiceCall, nodeGroup, sess, batchInterval)
         i = len(queue[0])
         queue[0][i] = (service,
          method,
          args,
          keywords)
         queue[1][i] = uthread.Channel()
         return queue[1][i].receive()
     else:
         return self.__UberMachoRemoteServiceCall(sess, service, method, self.__GetNodeGroup(nodeGroup), *args, **keywords)
 def OnFleetBroadcast_Local(self, broadcast):
     caption = broadcast.broadcastLabel
     iconName = fleetbr.defaultIcon[1]
     t = fleetbr.types.get(broadcast.name, None)
     if t:
         iconName = t['smallIcon']
     roleIcon = fleetbr.GetRoleIconFromCharID(broadcast.charID)
     self.sr.lastBroadcastCont.Flush()
     t = uicontrols.EveLabelMedium(text=caption, parent=self.sr.lastBroadcastCont, align=uiconst.TOALL, left=25, maxLines=1, state=uiconst.UI_DISABLED)
     self.sr.lastBroadcastCont.GetMenu = lambda : self.GetLastBroadcastMenu(broadcast)
     self.sr.lastBroadcastCont.OnClick = lambda : self.OnLastBroadcastClick(broadcast)
     self.sr.lastBroadcastCont.hint = localization.GetByLabel('UI/Fleet/FleetBroadcast/BroadcastNotificationHint', eventLabel=broadcast.broadcastLabel, time=broadcast.time, charID=broadcast.charID, range=fleetbr.GetBroadcastScopeName(broadcast.scope, broadcast.where), role=fleetbr.GetRankName(sm.GetService('fleet').GetMemberInfo(int(broadcast.charID))))
     icon = uicontrols.Icon(icon=iconName, parent=self.sr.lastBroadcastCont, align=uiconst.RELATIVE, pos=(6, 0, 16, 16), state=uiconst.UI_DISABLED)
     uthread.worker('fleet::flash', self.Flash, icon)
Example #32
0
    def RemoveSessionsFromServer(self, nodeID, sessionIDs):
        if machobase.mode != 'proxy':
            raise RuntimeError('RemoveSessionsFromServer should only be called on a proxy')
        log.LogInfo('CTXSESS: RemoveSessionsFromServer(nodeID=', nodeID, '), with ', len(sessionIDs), ' session IDs')
        mn = sm.services['machoNet']
        serverTID = mn.transportIDbySolNodeID.get(nodeID, None)
        if serverTID is not None:
            serverTransport = mn.transportsByID[serverTID]
            for sid in sessionIDs:
                sess = sessionsBySID.get(sid, None)
                if sess is not None:
                    uthread.worker('SessionMgr::RemoveSesssionsFromServer', serverTransport.RemoveSessionFromServer, sess)

        else:
            log.LogWarning('RemoveSessionsFromServer() called with unknown or non-server nodeID ', nodeID)
 def RemoveWnd(self, wnd, grab, correctpos=1, idx=0, dragging=0, check=1):
     if wnd.parent != self.sr.content:
         return
     if hasattr(wnd, 'OnTabSelect'):
         uthread.worker('WindowStack::RemoveWnd', wnd.OnTabSelect)
     wnd._detaching = True
     uiutil.Transplant(wnd, self.parent, idx)
     if hasattr(wnd, '_stack_cacheContents'):
         wnd.cacheContents = wnd._stack_cacheContents
     self.RemovePreferredIdx(self.windowID, wnd.windowID)
     wnd.sr.stack = None
     wnd.sr.tab = None
     wnd.align = uiconst.RELATIVE
     wnd.state = uiconst.UI_NORMAL
     wnd.grab = grab
     wnd.dragMousePosition = (uicore.uilib.x, uicore.uilib.y)
     wnd.width = wnd._fixedWidth or self.width
     wnd.height = wnd._fixedHeight or self.height
     wnd.RefreshHeaderButtonsIfVisible()
     if dragging:
         uicore.uilib.SetMouseCapture(wnd)
         uthread.new(wnd._BeginDrag)
         if wnd.height < wnd.GetMinHeight():
             wnd.height = wnd.GetMinHeight()
         if wnd.width < wnd.GetMinWidth():
             wnd.width = wnd.GetMinWidth()
     wnd.ShowHeader()
     wnd.ShowBackground()
     if correctpos:
         wnd.left = uicore.uilib.x - grab[0]
         wnd.top = uicore.uilib.y - grab[1]
     if check:
         self.Check()
     wnd.RegisterStackID()
     wnd._detaching = False
     wnd._dragging = dragging
     myWindows = self.GetWindows()
     if len(myWindows) == 1 and not self.IsCollapsed():
         w = myWindows[0]
         aL, aT, aW, aH = self.GetAbsolute()
         x, y = aL, aT
         self.RemoveWnd(w, (0, 0), 1, 1, check=0)
         self.RemovePreferredIdx(self.windowID, w)
         w.left, w.top = x, y
         return
     if len(self.GetWindows()) == 0:
         self.sr.tabs.Close()
         self.Close()
 def RemoveWnd(self, wnd, grab, correctpos = 1, idx = 0, dragging = 0, check = 1):
     if wnd.parent != self.sr.content:
         return
     if hasattr(wnd, 'OnTabSelect'):
         uthread.worker('WindowStack::RemoveWnd', wnd.OnTabSelect)
     wnd._detaching = True
     uiutil.Transplant(wnd, self.parent, idx)
     if hasattr(wnd, '_stack_cacheContents'):
         wnd.cacheContents = wnd._stack_cacheContents
     self.RemovePreferredIdx(self.windowID, wnd.windowID)
     wnd.sr.stack = None
     wnd.sr.tab = None
     wnd.align = uiconst.RELATIVE
     wnd.state = uiconst.UI_NORMAL
     wnd.grab = grab
     wnd.dragMousePosition = (uicore.uilib.x, uicore.uilib.y)
     wnd.width = wnd._fixedWidth or self.width
     wnd.height = wnd._fixedHeight or self.height
     wnd.RefreshHeaderButtonsIfVisible()
     if dragging:
         uicore.uilib.SetMouseCapture(wnd)
         uthread.new(wnd._BeginDrag)
         if wnd.height < wnd.GetMinHeight():
             wnd.height = wnd.GetMinHeight()
         if wnd.width < wnd.GetMinWidth():
             wnd.width = wnd.GetMinWidth()
     wnd.ShowHeader()
     wnd.ShowBackground()
     if correctpos:
         wnd.left = uicore.uilib.x - grab[0]
         wnd.top = uicore.uilib.y - grab[1]
     if check:
         self.Check()
     wnd.RegisterStackID()
     wnd._detaching = False
     wnd._dragging = dragging
     myWindows = self.GetWindows()
     if len(myWindows) == 1 and not self.IsCollapsed():
         w = myWindows[0]
         aL, aT, aW, aH = self.GetAbsolute()
         x, y = aL, aT
         self.RemoveWnd(w, (0, 0), 1, 1, check=0)
         self.RemovePreferredIdx(self.windowID, w)
         w.left, w.top = x, y
         return
     if len(self.GetWindows()) == 0:
         self.sr.tabs.Close()
         self.Close()
Example #35
0
 def OnOpenView(self):
     memorySnapshot.AutoMemorySnapshotIfEnabled('Login_OnOpenView')
     self.Reset()
     uthread.worker('login::StatusTextWorker', self.__StatusTextWorker)
     blue.resMan.Wait()
     self.serverName = utillib.GetServerName()
     self.serverIP = GetServerIP(self.serverName)
     self.serverName = GetServerName(self.serverIP)
     self.serverPort = utillib.GetServerPort()
     self.firstCheck = True
     self.isShowingUpdateDialog = False
     self.Layout()
     sm.ScatterEvent('OnClientReady', 'login')
     self.isopen = 1
     uthread.new(self.UpdateServerStatus)
     sm.ScatterEvent('OnClientStageChanged', 'login')
Example #36
0
 def OnOpenView(self):
     memorySnapshot.AutoMemorySnapshotIfEnabled('Login_OnOpenView')
     self.Reset()
     uthread.worker('login::StatusTextWorker', self.__StatusTextWorker)
     blue.resMan.Wait()
     self.serverName = utillib.GetServerName()
     self.serverIP = GetServerIP(self.serverName)
     self.serverName = GetServerName(self.serverIP)
     self.serverPort = utillib.GetServerPort()
     self.firstCheck = True
     self.isShowingUpdateDialog = False
     self.Layout()
     sm.ScatterEvent('OnClientReady', 'login')
     self.isopen = 1
     uthread.new(self.UpdateServerStatus)
     sm.ScatterEvent('OnClientStageChanged', 'login')
Example #37
0
 def Repeat(self, duration):
     if getattr(self, 'turret', None) is None:
         return
     shipID = self.ballIDs[0]
     shipBall = self.fxSequencer.GetBall(shipID)
     targetID = self.ballIDs[1]
     targetBall = self.fxSequencer.GetBall(targetID)
     if targetBall is None:
         self.turret.Rest()
         self.turret.shooting = 0
         return
     if shipBall is None:
         self.turret.Rest()
         self.turret.shooting = 0
         return
     uthread.worker('FxSequencer::ShootTurrets', self.Shoot, shipID, targetID)
Example #38
0
 def StartGfxSwipeThread(self, viewAngleInPlane=None):
     if viewAngleInPlane is None:
         viewAngleInPlane = self.GetViewAngleInPlane()
     if self.gfxSwipeThread is not None:
         return
     self.gfxSwipeThread = uthread.worker('sensorSuite::_GfxSwipeThread',
                                          self._GfxSwipeThread,
                                          viewAngleInPlane)
Example #39
0
 def Repeat(self, duration):
     if getattr(self, 'turret', None) is None:
         return
     shipID = self.ballIDs[0]
     shipBall = self.fxSequencer.GetBall(shipID)
     targetID = self.ballIDs[1]
     targetBall = self.fxSequencer.GetBall(targetID)
     if targetBall is None:
         self.turret.Rest()
         self.turret.shooting = 0
         return
     if shipBall is None:
         self.turret.Rest()
         self.turret.shooting = 0
         return
     uthread.worker('FxSequencer::ShootTurrets', self.Shoot, shipID,
                    targetID)
Example #40
0
 def OnOpenView(self):
     memorySnapshot.AutoMemorySnapshotIfEnabled('Login_OnOpenView')
     self.Reset()
     uthread.worker('login::StatusTextWorker', self.__StatusTextWorker)
     blue.resMan.Wait()
     self.serverName = util.GetServerName()
     self.serverIP = GetServerIP(self.serverName)
     self.serverName = GetServerName(self.serverIP)
     self.serverPort = util.GetServerPort()
     self.firstCheck = True
     self.Layout()
     sm.ScatterEvent('OnClientReady', 'login')
     self.isopen = 1
     uthread.new(self.UpdateServerStatus)
     if bluepy.IsRunningStartupTest():
         uthread.new(self.TerminateStartupTestLater_t)
     sm.ScatterEvent('OnClientStageChanged', 'login')
    def ScatterEventWithoutTheStars(self, eventid, args, keywords = None):
        if keywords is None:
            keywords = {}
        if not eventid.startswith('On'):
            self.LogError('ScatterEvent called with event ', eventid, ".  All events sent via ScatterEvent should start with 'On'.")
            self.LogError("Not only is the programmer responsible for this a 10z3r, but he wears his mother's underwear as well")
            log.LogTraceback()
        shouldLogMethodCalls = self.ShouldLogMethodCalls()
        if shouldLogMethodCalls:
            if IsFullLogging():
                self.LogMethodCall('ScatterEvent(', eventid, ',*args=', args, ',**kw=', keywords, ')')
            else:
                self.LogMethodCall('ScatterEvent(', eventid, ')')
        prefix = blue.pyos.taskletTimer.GetCurrent() + '::ScatterEvent_' + eventid + '::'
        for srv in self.notify.get(eventid, []):
            try:
                logname = prefix + self.GetLogName(srv)
                if ObjectShouldReceiveMessages(srv):
                    if shouldLogMethodCalls:
                        self.LogMethodCall('Calling ', logname)
                    srvGuid = getattr(srv, '__guid__', logname)
                    uthread.worker(prefix + srvGuid, self.MollycoddledUthread, srvGuid, eventid, getattr(srv, eventid), args, keywords)
                elif shouldLogMethodCalls:
                    self.LogMethodCall('Skipping ', logname, ' (service not running)')
            except Exception:
                log.LogException()

        notifiedToRemove = []
        for weakObj in self.notifyObs.get(eventid, []):
            try:
                obj = weakObj()
                func = getattr(obj, eventid, None)
                if obj is None or func is None:
                    notifiedToRemove.append(weakObj)
                else:
                    if shouldLogMethodCalls:
                        logname = prefix + str(obj)
                        self.LogMethodCall('Calling ', logname)
                    uthread.workerWithoutTheStars('', func, args, keywords)
            except Exception:
                log.LogException()

        for toRemove in notifiedToRemove:
            if toRemove in self.notifyObs[eventid]:
                self.notifyObs[eventid].remove(toRemove)
Example #42
0
 def Load_(self, node):
     self.sr.node = node
     self.sr.label.text = node.label
     icon = node.Get('icon', None)
     if icon is None:
         self.sr.icon.state = uiconst.UI_HIDDEN
     else:
         self.sr.icon.state = uiconst.UI_DISABLED
         self.sr.icon.LoadIcon(icon)
     self.sr.icon.color.a = 0.0
     iconRole = node.Get('iconRole', None)
     if iconRole is None:
         self.sr.iconRole.parent.state = uiconst.UI_HIDDEN
     else:
         self.sr.iconRole.parent.state = uiconst.UI_DISABLED
         self.sr.iconRole.LoadIcon(iconRole)
     uthread.worker('BroadcastEntryMixin::Flash', self.Flash)
     self.height = self.sr.label.height = self.sr.icon.height + 4
def OnLogin():
    """
    Check playing time limits for underage players in the Chinese server, to 
    comply with anti-addiction laws.  
    
    Called after successful login, but before char selection is entered.  
    
    If a player is eligible for anti-addiction control, game exit and related
    warnings are executed immediately or scheduled, depending on how longer
    the law allows her to play.
    """
    global _savePeriod
    global _displaySeconds
    global _watchSpan
    global _allowedTime
    global _schedule
    if boot.region != 'optic' or not AmIUnderage():
        return
    if prefs.GetValue('aaTestTimes', 0):
        _watchSpan = _testWatchSpan
        _allowedTime = _testAllowedTime
        _schedule = _testSchedule
        _savePeriod = _testSavePeriod
        _displaySeconds = True
    else:
        _watchSpan = _liveWatchSpan
        _allowedTime = _liveAllowedTime
        _schedule = _liveSchedule
        _savePeriod = _liveSavePeriod
        _displaySeconds = False
    sessionID = StartSession()
    uthread.worker('antiaddiction::EndSession', lambda : EndSessionWorker(sessionID))

    def ActionWrap(action, time):
        return lambda : action(time)

    t = TimeLeft()
    for time, action in _schedule:
        if t <= time:
            action(t)
            break
        else:
            Schedule(t - time, ActionWrap(action, time))
Example #44
0
    def ApplyWithTimeout(self, func, args, timeout = 120, message = None):
        rts = [0]
        t = uthread.worker('machoNet::TimeoutWorker', self.TimeoutWorker, self, timeout, rts, message)
        try:
            ret = apply(func, args)
        finally:
            rts[0] = 1
            t.kill()

        return ret
Example #45
0
    def ApplyWithTimeout(self, func, args, timeout=120, message=None):
        rts = [0]
        t = uthread.worker('machoNet::TimeoutWorker', self.TimeoutWorker, self,
                           timeout, rts, message)
        try:
            ret = apply(func, args)
        finally:
            rts[0] = 1
            t.kill()

        return ret
Example #46
0
 def TurnOnPositionTrace(self):
     self.CreateDebugRenderer()
     if self.positionTrace is not None:
         self.TurnOffPositionTrace()
     entity = self.debugSelectionClient.GetSelectedEntity()
     if entity is None:
         return
     playerEnt = self.entityClient.GetPlayerEntity()
     if entity is playerEnt:
         self.registered = True
         self.RegisterPositionTraceKeyEvents()
     self.lastPos = entity.position.position
     self.positionTrace = uthread.worker('animationDebugClient.PositionTrace', self._DrawPositionTrace)
Example #47
0
 def TurnOnVelocityTrace(self):
     self.CreateDebugRenderer()
     if self.velocityTrace is not None:
         self.TurnOffVelocityTrace()
     entity = self.debugSelectionClient.GetSelectedEntity()
     if entity is None:
         return
     if not entity.HasComponent('movement'):
         return
     pos = entity.position.position
     self.lastVelPos = pos
     self.lastVelRulePos = pos
     self.velocityTrace = uthread.worker('animationDebugClient.VelocityTrace', self._DrawVelocityTrace)
Example #48
0
 def TurnOnRotationalTrace(self):
     self.CreateDebugRenderer()
     if self.rotationalTrace is not None:
         self.TurnOffRotationalTrace()
     entity = self.debugSelectionClient.GetSelectedEntity()
     if entity is None:
         return
     pos = entity.position.position
     rot = entity.position.rotation
     self.lastRotPos = pos
     self.lastRot = rot
     self.lastRotTime = time.time()
     self.lastRotVel = 0
     self.rotationalTrace = uthread.worker('animationDebugClient.RotationalTrace', self._DrawRotationalTrace)
Example #49
0
 def RemoveWnd(self, wnd, grab, correctpos = 1, idx = 0, dragging = 0, check = 1):
     if wnd.parent != self.sr.content:
         return
     if hasattr(wnd, 'OnTabSelect'):
         uthread.worker('WindowStack::RemoveWnd', wnd.OnTabSelect)
     wnd._detaching = True
     uiutil.Transplant(wnd, self.parent, idx)
     wnd.sr.stack = None
     wnd.sr.tab = None
     wnd.align = uiconst.TOPLEFT
     wnd.state = uiconst.UI_NORMAL
     wnd.grab = grab
     wnd.width = wnd._fixedWidth or self.width
     wnd.height = wnd._fixedHeight or self.height
     if dragging:
         uicore.uilib.SetMouseCapture(wnd)
         uthread.new(wnd._BeginDrag)
     wnd.ShowHeader()
     wnd.ShowBackground()
     if correctpos:
         wnd.left = uicore.uilib.x - grab[0]
         wnd.top = uicore.uilib.y - grab[1]
     if check:
         self.Check()
     wnd.RegisterStackID()
     wnd._detaching = False
     wnd._dragging = dragging
     myWindows = self.GetWindows()
     if len(myWindows) == 1 and not self.IsCollapsed():
         w = myWindows[0]
         aL, aT, aW, aH = self.GetAbsolute()
         x, y = aL, aT
         self.RemoveWnd(w, (0, 0), 1, 1, check=0)
         w.left, w.top = x, y
         return
     if len(self.GetWindows()) == 0:
         self.Close()
Example #50
0
 def LoadHintFromItem(self, item, force):
     if item is None or uicore.uilib.leftbtn:
         self.FadeOpacity(0.0)
         self._lastHintInfo = None
         return
     hint = None
     if getattr(item, 'GetHint', None) is not None:
         hint = item.GetHint()
     hint = hint or getattr(item, 'hint', None)
     if hint is None and getattr(item, 'sr', None):
         hint = item.sr.Get('hint', None)
     if item.auxiliaryHint:
         if hint:
             hint += '<br>' + item.auxiliaryHint
         else:
             hint = item.auxiliaryHint
     if not hint:
         self.FadeOpacity(0.0)
         self._lastHintInfo = None
         return
     lastHint = getattr(self, '_lastHintInfo', None)
     if not lastHint or lastHint != (id(item), hint):
         self._lastHintInfo = (id(item), hint)
         uthread.worker('UICoreHint::LoadHintFromItem', self._LoadHintFromItemThread, item, hint)