hch
2019-04-19 519a8605a41e9e4cb72da4d58f55a52c3b83263d
860312 优化脱机挂登录
5个文件已修改
103 ■■■■■ 已修改文件
ServerPython/CoreServerGroup/GameServer/Script/EventReport.py 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/EventReport.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tool/Robot/AI/AIFile/AILoginIn.py 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tool/Robot/Robot/RobotBase.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tool/Robot/Robot/RobotMgr.py 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/EventReport.py
@@ -116,7 +116,10 @@
            return
        RegionName = 's%s'%sid
        
    getUrl = "%s?ProductID=%s&OperatorID=%s&RegionName=%s&EventID=%s%s&Time=%s&DeviceFlag=%s&%s"%(\
    if eventParam:
        eventParam = "&%s"%eventParam
    getUrl = "%s?ProductID=%s&OperatorID=%s&RegionName=%s&EventID=%s%s&Time=%s&DeviceFlag=%s%s"%(\
             ReportUrl, ProductID, OperatorID, RegionName, eventActionID, playerInfo,
             str(datetime.datetime.today()).split('.')[0], curPlayer.GetDeviceFlag(), eventParam)
    GameWorld.DebugLog("EventReport: %s"%getUrl)
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/EventReport.py
@@ -139,7 +139,7 @@
        eventParam = "&%s"%eventParam
    
    
    getUrl = "%s?ProductID=%s&OperatorID=%s&RegionName=%s&EventID=%s&%s&Time=%s&DeviceFlag=%s&%s"%(\
    getUrl = "%s?ProductID=%s&OperatorID=%s&RegionName=%s&EventID=%s&%s&Time=%s&DeviceFlag=%s%s"%(\
             ReportUrl, ProductID, OperatorID, RegionName, eventActionID, playerInfo,
             str(datetime.datetime.today()).split('.')[0], curPlayer.GetAccountData().GetDeviceFlag(), eventParam)
    GameWorld.DebugLog("EventReport: %s"%getUrl)
Tool/Robot/AI/AIFile/AILoginIn.py
@@ -73,21 +73,7 @@
    #  @remarks
    def _Process(self):
        return
        #self.IsKillSelf()
#===============================================================================
#        playerId = self.robot.GetPlayerInfo().GetPlayerID()
#        curPosX, curPosY = self.robot.GetPlayerInfo().GetPos()
#
#
#        curTime = self.GetTick()
#
#        if self.playerDieTime > 0 and curTime - self.playerDieTime > ReBornTime:
#            if self.robot.GetIsLoginOK():
#                #发包复活
#                self.PlayerReborn()
#
#            self.playerDieTime = 0
#===============================================================================
        
@@ -96,32 +82,10 @@
    #  @return None
    #  @remarks
    def ReConnect(self, curTime):
        if self.robot.IsConnected():
            curPosX, curPosY = self.robot.GetPlayerInfo().GetPos()
            if self.__IsCorrectPos(curPosX, curPosY):
                return
            self.SendGMRoleDead()
#            self.robot.DestroyRobot()
#            self.playerDisconnectTime = curTime
            logging.info('坐标错误,断开')
        else:
            if self.robot.GetIsLoginOK():
                self.robot.DestroyRobot()
            if  self.playerDisconnectTime == 0:
                self.playerDisconnectTime = curTime
            if self.playerDisconnectTime > 0 and curTime - self.playerDisconnectTime > ReConnectTime:
                self.robot.ReCreateRobot()
                if self.robot.IsConnected():
                    self.playerDisconnectTime = 0
                    logging.info('重新连接了')
        self.robot.SetIsLoginOK(False)
        self.robot.SetLastDisconnectReason(1)
        from Robot import RobotMgr
        RobotMgr.GetRobotMgr().DisconnectServer(self.robot)
                
        return
        
Tool/Robot/Robot/RobotBase.py
@@ -235,7 +235,7 @@
        port = GetConfig().GetServerPort()
        logging.debug( "Connect to %s:%d", ip, port )
        self.__peer = self.__mgr.CreatePeer()
        logging.debug( "create __peer:0x%08X",  self.GetPeerValue() )
        logging.info( "create %s __peer:0x%08X",  self.__params[1], self.GetPeerValue() )
        
        #注册回调
        logging.debug( "register callback function for 0x%08X" % self.GetPeerValue() )
Tool/Robot/Robot/RobotMgr.py
@@ -19,12 +19,13 @@
        self.robotMgr = robotMgr
        self.AIList = []
        config =  ConfigurationReader.ConfigIniReader.GetConfig()
        self.tjgLimitCnt = config.GetTJGLimitCnt()
        self.lastTime = 0
        self.tjgLimitCnt = config.GetTJGLimitCnt()  # 限制脱机数量
        self.offTime = config.GetPlayerOffTime()    # 获取下线多久的玩家时间
        self.lastTime = 0   # 控制日志输出频率
        self.badRobotCnt = 0 # 历史异常脱机挂个数
        
        self.ProcessFindTJGTime = 5
        self.lastLoginTime = 0
        self.lastLoginTime = 0  # 处理机器人登录的频率
        
    def runThread(self):   
        logging.info( "thread %s start" % self.getName() )
@@ -47,9 +48,14 @@
                    robotList = []
                    for i in xrange(len(tokenList)):
                        tokenInfo = tokenList.pop()
                        if tokenInfo[1] in logoningList:
                            print "正在登录中------", tokenInfo[1]
                        accID = tokenInfo[1]
                        if accID in logoningList:
                            print "正在登录中------", accID
                            continue
                        lastTime = self.robotMgr.GetNoteLastTimeByAccID(accID)   # 上一次加入队列的时间
                        if lastTime != 0 and nowTime - lastTime < self.offTime:
                            # 登录有问题则进入排队
                            continue
                        robot = self.robotMgr.AddRobot(tokenInfo)
                        robotList.append(robot)
@@ -63,7 +69,7 @@
                            continue
                        
                        # 连接-登录-运行AI
                        if not robot.IsConnected():
                        if not robot.IsConnected() and robot.GetReconnectCount() < 2:
                            robot.ReCreateRobot()
                            
                    
@@ -135,12 +141,22 @@
        self.dbRobot = dbRobot
        self.TeamMgr = {}
        
        self.LoginHistory = {}  # 记录历史添加时间 {账号:时间} 登录失败需3分钟后方可尝试
        #启动AI线程    
        #config =  ConfigurationReader.ConfigIniReader.GetConfig()
        #AI_THREAD_NUM = config.GetAIThreadNum()
        th = AIThread(self, 0)
        th.start()
    def NoteHistory(self, accID):
        self.LoginHistory[accID] = time.time()
    def GetNoteLastTimeByAccID(self, accID):
        return self.LoginHistory.get(accID, 0)
    def GetRobotAccIDList(self):
        self.__robotAccIDs = []
@@ -149,7 +165,9 @@
        return self.__robotAccIDs
    def AddRobot(self, tokenInfo):
        self.LoginHistory[tokenInfo[1]] = time.time()   # 账号记录
        #创建Robot实例,具体项目实现相应的RobotBase的子类,在这里创建子类的实例
        logging.debug( "Create Robot index:%s....." % (tokenInfo,)  )
        robot = ProjectRobot( self.__asioMgr, tokenInfo )
@@ -180,19 +198,6 @@
        return n     
        
        
#===============================================================================
#    def ConnectServer(self, index ):
#
#        robot = self.GetRobot(index)
#        if not robot:
#            return False
#
#        logging.debug( "ConnectServer for %d" % index )
#        #创建了实例了,这时只需要再次连接即可
#        robot.ReCreateRobot()
#        return True
#===============================================================================
    def GetRobot(self, index ):
        #logging.debug( "GetRobot for %d" % index )
        
@@ -200,6 +205,7 @@
        
    def Remove(self, robot):
        self.__robots.remove(robot)
        logging.info( "Remove robot 剩余: %s"%len(self.__robots) )
        
        
    def DisconnectServer(self, robot ):