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

eveMoniker.py (7083B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\common\script\net\eveMoniker.py
      2 import eve.common.lib.appConst as const
      3 from carbon.common.script.net import machoNet
      4 from carbon.common.script.net.moniker import Moniker
      5 from cluster import SERVICE_STATION, SERVICE_AGENTMGR
      6 from eve.common.script.sys.idCheckers import IsStation
      7 
      8 def GetLocationBindParams():
      9     if session.solarsystemid:
     10         return (session.solarsystemid, const.groupSolarSystem)
     11     if session.stationid:
     12         return (session.stationid, const.groupStation)
     13     raise RuntimeError('You have no place to go')
     14 
     15 
     16 def GetLocationSessionCheck():
     17     if session.solarsystemid:
     18         return {'solarsystemid': session.solarsystemid}
     19     if session.stationid:
     20         return {'stationid': session.stationid}
     21     raise RuntimeError('You have no location to check on')
     22 
     23 
     24 def CharGetDogmaLocation():
     25     moniker = Moniker('dogmaIM', GetLocationBindParams())
     26     moniker.SetSessionCheck(GetLocationSessionCheck())
     27     return moniker
     28 
     29 
     30 def GetStationDogmaLocation():
     31     moniker = Moniker('dogmaIM', (session.stationid, const.groupStation))
     32     moniker.SetSessionCheck({'stationid': session.stationid})
     33     return moniker
     34 
     35 
     36 def GetShipAccess():
     37     if session.solarsystemid:
     38         moniker = Moniker('ship', (session.solarsystemid, const.groupSolarSystem))
     39         moniker.SetSessionCheck({'solarsystemid': session.solarsystemid})
     40     elif session.stationid:
     41         moniker = Moniker('ship', (session.stationid, const.groupStation))
     42         moniker.SetSessionCheck({'stationid': session.stationid})
     43     return moniker
     44 
     45 
     46 def GetStationShipAccess():
     47     moniker = Moniker('ship', (session.stationid, const.groupStation))
     48     moniker.SetSessionCheck({'stationid': session.stationid})
     49     return moniker
     50 
     51 
     52 def GetEntityAccess():
     53     if session.solarsystemid is not None:
     54         moniker = Moniker('entity', session.solarsystemid2)
     55         moniker.SetSessionCheck({'solarsystemid': session.solarsystemid})
     56         return moniker
     57     raise RuntimeError('EntityAccess only available in-flight but session is %s' % (session,))
     58 
     59 
     60 def GetEntityLocation():
     61     if session.solarsystemid2 is not None:
     62         moniker = Moniker('entity', session.solarsystemid2)
     63         moniker.SetSessionCheck({'solarsystemid2': session.solarsystemid2})
     64         return moniker
     65     raise RuntimeError('EntityLocation only available with in a valid solarsystem %s' % (session,))
     66 
     67 
     68 def GetPOSMgr():
     69     if session.solarsystemid is not None:
     70         moniker = Moniker('posMgr', session.solarsystemid)
     71         moniker.SetSessionCheck({'solarsystemid': session.solarsystemid})
     72         return moniker
     73     raise RuntimeError('POSMgr only available in-flight but session is %s' % (session,))
     74 
     75 
     76 def GetReprocessingManager():
     77     if session.structureid:
     78         moniker = GetReprocessingManagerEx(session.structureid)
     79         moniker.SetSessionCheck({'structureid': session.structureid})
     80     elif session.stationid:
     81         moniker = GetReprocessingManagerEx(session.stationid)
     82         moniker.SetSessionCheck({'stationid': session.stationid})
     83     else:
     84         raise RuntimeError('asked for reprocessing manager in a weird place')
     85     return moniker
     86 
     87 
     88 def GetReprocessingManagerEx(stationID):
     89     return Moniker('reprocessingSvc', stationID)
     90 
     91 
     92 def GetCorpStationManager():
     93     moniker = GetCorpStationManagerEx(session.stationid)
     94     moniker.SetSessionCheck({'stationid': session.stationid})
     95     return moniker
     96 
     97 
     98 def GetCorpStationManagerEx(stationID):
     99     return Moniker('corpStationMgr', stationID)
    100 
    101 
    102 def GetSolarSystemInventoryMgr(solarsystemID):
    103     return Moniker('invbroker', (solarsystemID, const.groupSolarSystem))
    104 
    105 
    106 def GetStationInventoryMgr(stationID):
    107     return Moniker('invbroker', (stationID, const.groupStation))
    108 
    109 
    110 def GetInventoryMgr():
    111     if session.solarsystemid:
    112         moniker = GetSolarSystemInventoryMgr(session.solarsystemid)
    113         moniker.SetSessionCheck({'solarsystemid': session.solarsystemid})
    114         return moniker
    115     if session.stationid:
    116         moniker = GetStationInventoryMgr(session.stationid)
    117         moniker.SetSessionCheck({'stationid': session.stationid})
    118         return moniker
    119     raise RuntimeError('Caller not in solsys nor station, session is %s' % (session,))
    120 
    121 
    122 def CharGetCrimewatchLocation():
    123     moniker = Moniker('crimewatch', GetLocationBindParams())
    124     moniker.SetSessionCheck(GetLocationSessionCheck())
    125     return moniker
    126 
    127 
    128 def GetBallPark(solarsystemID):
    129     moniker = Moniker('beyonce', solarsystemID)
    130     moniker.SetSessionCheck({'solarsystemid': solarsystemID})
    131     return moniker
    132 
    133 
    134 def GetCourierMissionCreator(stationID):
    135     return Moniker('missionMgr', ('courier', stationID))
    136 
    137 
    138 def GetAgent(agentID, stationID = None):
    139     if stationID is not None:
    140         macho = sm.GetService('machoNet')
    141         nodeID = macho.CheckAddressCache(SERVICE_STATION, stationID)
    142         if nodeID is not None:
    143             macho.SetNodeOfAddress(SERVICE_AGENTMGR, agentID, nodeID)
    144     return Moniker('agentMgr', agentID)
    145 
    146 
    147 def GetCorpRegistry():
    148     moniker = GetCorpRegistryEx(session.corpid)
    149     moniker.SetSessionCheck({'corpid': session.corpid})
    150     return moniker
    151 
    152 
    153 def GetCorpRegistryEx(corpID):
    154     return Moniker('corpRegistry', corpID)
    155 
    156 
    157 def GetAlliance():
    158     if session.allianceid is None:
    159         raise RuntimeError('YouAreNotInAnAllianceAtTheMoment')
    160     moniker = GetAllianceEx(session.allianceid, 1)
    161     moniker.SetSessionCheck({'allianceid': session.allianceid})
    162     return moniker
    163 
    164 
    165 def GetAllianceEx(allianceID, isMaster = 0):
    166     if machoNet.mode == 'server':
    167         isMaster = isMaster or sm.StartServiceAndWaitForRunningState('allianceRegistry').IsAllianceLocal(allianceID)
    168     return Moniker('allianceRegistry', (allianceID, isMaster))
    169 
    170 
    171 def GetWar():
    172     ownerID = session.corpid
    173     ownerType = 'corpid'
    174     if session.allianceid:
    175         ownerID = session.allianceid
    176         ownerType = 'allianceid'
    177     moniker = GetWarEx(ownerID, 1)
    178     moniker.SetSessionCheck({ownerType: ownerID})
    179     return moniker
    180 
    181 
    182 def GetWarEx(allianceOrCorpID, isMaster = 0):
    183     if machoNet.mode == 'server':
    184         isMaster = isMaster or sm.GetService('warRegistry').IsAllianceOrCorpLocal(allianceOrCorpID)
    185     return Moniker('warRegistry', (allianceOrCorpID, isMaster))
    186 
    187 
    188 def GetWarStatistic(warID):
    189     return Moniker('warStatisticMgr', warID)
    190 
    191 
    192 def GetFleet(fleetID = None):
    193     fleetID = fleetID or session.fleetid
    194     moniker = Moniker('fleetObjectHandler', fleetID)
    195     return moniker
    196 
    197 
    198 def GetPlanet(planetID):
    199     return Moniker('planetMgr', planetID)
    200 
    201 
    202 def GetPlanetBaseManager(planetID):
    203     return Moniker('planetBaseBroker', planetID)
    204 
    205 
    206 def GetPlanetOrbitalRegistry(solarSystemID):
    207     return Moniker('planetOrbitalRegistryBroker', solarSystemID)
    208 
    209 
    210 def GetRepairManager(locationID, solarSystemID):
    211     isStation = IsStation(locationID)
    212     parentLocationID = locationID if isStation else solarSystemID
    213     locationGroup = const.groupStation if isStation else const.groupSolarSystem
    214     return Moniker('repairSvc', (locationID, parentLocationID, locationGroup))