NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

jumpMonitor.py (8197B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\util\jumpMonitor.py
      2 import sys
      3 import blue
      4 import types
      5 import uthread
      6 from carbon.common.script.sys.service import Service
      7 from carbon.common.script.sys.serviceConst import SERVICE_RUNNING, SERVICE_STOPPED
      8 from carbon.common.script.util import timerstuff
      9 from eve.common.script.sys import idCheckers
     10 MAXALLOWEDJUMPTIMEINMS = 600000
     11 
     12 class jumpMonitor(Service):
     13     __guid__ = 'svc.jumpMonitor'
     14     __displayname__ = 'Jump Monitoring Service'
     15     __exportedcalls__ = {}
     16     __dependencies__ = []
     17     __notifyevents__ = ['OnSessionChanged',
     18      'DoBallsAdded',
     19      'OnChannelsJoined',
     20      'DoSessionChanging',
     21      'OnSessionMutated',
     22      'OnGlobalConfigChanged']
     23 
     24     def __init__(self):
     25         Service.__init__(self)
     26 
     27     def Run(self, memStream = None):
     28         Service.Run(self, memStream)
     29         self.useJumpMonitor = False
     30         self.jumping = False
     31         self.jumpStartTime = 0
     32         self.jumpType = None
     33         self.CheckJumpCompletedTimer = None
     34         self.checkBallpark = True
     35         self.ballparkLoaded = False
     36         self.state = SERVICE_RUNNING
     37 
     38     def Stop(self, stream):
     39         Service.Stop(self)
     40         self.state = SERVICE_STOPPED
     41 
     42     def OnGlobalConfigChanged(self, configVals):
     43         self.useJumpMonitor = bool(configVals.get('useClientSideJumpMonitor'))
     44 
     45     def OnSessionMutated(self, isremote, session, change):
     46         if not self.useJumpMonitor:
     47             return
     48         try:
     49             if type(session) == types.TupleType:
     50                 if len(session) == 1 and idCheckers.IsFakeItem(session[0]):
     51                     self.jumpStartTime = blue.os.GetWallclockTime()
     52                     self.jumpType = 'wormhole %s' % session[0]
     53                     self.checkBallpark = True
     54                 elif len(session) == 2 and idCheckers.IsStargate(session[0]) and idCheckers.IsStargate(session[1]):
     55                     self.jumpStartTime = blue.os.GetWallclockTime()
     56                     self.jumpType = 'stargate %d->%d' % (session[0], session[1])
     57                     self.checkBallpark = True
     58                 elif len(session) == 2 and idCheckers.IsPlayerItem(session[0]) and idCheckers.IsSolarSystem(session[1]):
     59                     self.jumpStartTime = blue.os.GetWallclockTime()
     60                     self.jumpType = 'pos cyno array:%d' % (session[0],)
     61                     self.checkBallpark = True
     62                 elif len(session) == 3 and idCheckers.IsPlayerItem(session[0]) and idCheckers.IsPlayerItem(session[1]) and idCheckers.IsSolarSystem(session[2]):
     63                     self.jumpStartTime = blue.os.GetWallclockTime()
     64                     self.jumpType = 'bridge src:%s dst:%d in:%d' % (session[0], session[1], session[2])
     65                     self.checkBallpark = True
     66                 elif len(session) == 3 and idCheckers.IsCharacter(session[0]) and idCheckers.IsSolarSystem(session[2]):
     67                     self.jumpStartTime = blue.os.GetWallclockTime()
     68                     self.jumpType = 'cyno char:%s cyno:%d' % (session[0], session[1])
     69                     self.checkBallpark = True
     70                 elif len(session) == 4 and idCheckers.IsCharacter(session[0]) and idCheckers.IsPlayerItem(session[1]) and idCheckers.IsSolarSystem(session[3]):
     71                     self.jumpStartTime = blue.os.GetWallclockTime()
     72                     self.jumpType = 'ship bridge char:%s-%s cyno:%d' % (session[0], session[1], session[2])
     73                     self.checkBallpark = True
     74         except:
     75             sys.exc_clear()
     76 
     77     def DoSessionChanging(self, isremote, session, change):
     78         if not self.useJumpMonitor:
     79             return
     80         if 'locationid' not in change or change['locationid'][0] is None:
     81             return
     82         if 'solarsystemid2' not in change:
     83             return
     84         if self.CheckJumpCompletedTimer:
     85             self.LogError('JumpMonitor: Jump detected in DoSessionChanging but last jump not completed?')
     86             reportingString = 'JumpMonitor: OVERLAPPED JUMP %s->%s type[%s] start:%d,local:%d,sess:%d,ballpark:%d ' % (self.jumpOrigin,
     87              self.jumpDestination,
     88              self.jumpType,
     89              self.jumpStartTime,
     90              self.localLoadedEnd,
     91              self.sessionChangedEnd,
     92              self.ballparkLoadedEnd)
     93             reportingString += ' new jump: %s:%s ' % change['solarsystemid2']
     94             uthread.new(sm.ProxySvc('clientStatLogger').LogString, reportingString)
     95         if 'shipid' in change and change['shipid'][0] and not change['shipid'][1]:
     96             self.jumpStartTime = blue.os.GetWallclockTime()
     97             self.jumpType = 'podkill'
     98             self.checkBallpark = False
     99         elif 'stationid' in change and change['stationid'][0] and change['stationid'][1]:
    100             self.jumpStartTime = blue.os.GetWallclockTime()
    101             self.jumpType = 'clonejump'
    102             self.checkBallpark = False
    103         if self.jumpType is None:
    104             self.jumpStartTime = blue.os.GetWallclockTime()
    105             self.jumpType = '/tr'
    106             self.checkBallpark = not ('stationid' in change and change['stationid'][1])
    107         self.jumpOrigin = session.locationid
    108         self.jumpDestination = change['locationid'][1]
    109         self.jumping = True
    110         self.sessionChanged = False
    111         self.localLoaded = False
    112         self.ballparkLoaded = False
    113         self.localLoadedEnd = 0
    114         self.sessionChangedEnd = 0
    115         self.ballparkLoadedEnd = 0
    116         self.CheckJumpCompletedTimer = timerstuff.AutoTimer(1000, self.CheckJumpCompleted)
    117 
    118     def CheckJumpCompleted(self):
    119         if self.jumping and self.sessionChanged and self.localLoaded and (self.ballparkLoaded or not self.checkBallpark):
    120             self.CheckJumpCompletedTimer = None
    121             self.jumpEndTime = blue.os.GetWallclockTime()
    122             self.jumping = False
    123             reportingString = 'JumpMonitor: %s->%s type[%s] start:%d,local:%d,sess:%d,ballpark:%d\n' % (self.jumpOrigin,
    124              self.jumpDestination,
    125              self.jumpType,
    126              self.jumpStartTime,
    127              self.localLoadedEnd,
    128              self.sessionChangedEnd,
    129              self.ballparkLoadedEnd)
    130             sm.ProxySvc('clientStatLogger').LogString(reportingString)
    131             self.jumpType = None
    132         elif self.jumping and blue.os.TimeDiffInMs(self.jumpStartTime, blue.os.GetWallclockTime()) > MAXALLOWEDJUMPTIMEINMS:
    133             reportingString = 'JumpMonitor: INCOMPLETE %s->%s type[%s] start:%d,local:%d,sess:%d,ballpark:%d\n' % (self.jumpOrigin,
    134              self.jumpDestination,
    135              self.jumpType,
    136              self.jumpStartTime,
    137              self.localLoadedEnd,
    138              self.sessionChangedEnd,
    139              self.ballparkLoadedEnd)
    140             sm.ProxySvc('clientStatLogger').LogString(reportingString)
    141             self.jumpType = None
    142             self.CheckJumpCompletedTimer = None
    143             self.jumpEndTime = blue.os.GetWallclockTime()
    144             self.jumping = False
    145 
    146     def OnSessionChanged(self, isRemote, session, change):
    147         if self.jumping and not self.sessionChanged and ('locationid' in change or 'solarsystemid' in change or 'solarsystemid2' in change):
    148             self.sessionChanged = True
    149             self.sessionChangedEnd = blue.os.GetWallclockTime()
    150             uthread.new(self.CheckJumpCompleted)
    151 
    152     def DoBallsAdded(self, *args, **kw):
    153         if not self.ballparkLoaded:
    154             self.ballparkLoaded = True
    155             self.ballparkLoadedEnd = blue.os.GetWallclockTime()
    156             if self.jumping:
    157                 uthread.new(self.CheckJumpCompleted)
    158 
    159     def OnChannelsJoined(self, channelIDs):
    160         if self.jumping and not self.localLoaded:
    161             try:
    162                 local = [ chan for chan in channelIDs if type(chan) == types.TupleType and type(chan[0]) == types.TupleType and 'solarsystemid2' == chan[0][0] ]
    163                 if local:
    164                     self.localLoaded = True
    165                     self.localLoadedEnd = blue.os.GetWallclockTime()
    166                     uthread.new(self.CheckJumpCompleted)
    167             except:
    168                 pass
    169 
    170     def IsBallparkLoaded(self):
    171         return self.ballparkLoaded