hch
2018-11-02 f089bf39d557fc228f7bd3b2eb8c85c7b402e7dc
Tool/Robot/Robot/RobotMgr.py
@@ -18,8 +18,8 @@
        Thread.__init__(self, None, None, "AIThreadPy_%s"%index)
        self.robotMgr = robotMgr
        self.AIList = []
        #config =  ConfigurationReader.ConfigIniReader.GetConfig()
        config =  ConfigurationReader.ConfigIniReader.GetConfig()
        self.tjgLimitCnt = config.GetTJGLimitCnt()
        self.lastTime = 0
        self.badRobotCnt = 0 # 历史异常脱机挂个数
        
@@ -35,6 +35,11 @@
                nowTime = time.time()
                if self.lastLoginTime and nowTime - self.lastLoginTime > self.ProcessFindTJGTime:
                    logging.debug( "self.tjgLimitCnt %s " % self.tjgLimitCnt )
                    # 限制脱机挂登录数量, 没有实时的玩家上线后会补收益
                    if self.robotMgr.GetRobotCount() > self.tjgLimitCnt:
                        self.robotMgr.dbRobot.ClearToken()
                    self.lastLoginTime = nowTime
                    logoningList = self.robotMgr.GetRobotAccIDList()    # 在登录的机器人
                    
@@ -67,7 +72,11 @@
                    if index >= self.robotMgr.GetRobotCount():
                        # ProcessAI可能会清除了robot
                        break
                    robot = self.robotMgr.GetRobot( index )
                    try:
                        robot = self.robotMgr.GetRobot( index )
                    except:
                        # 判断index防范不到,可能多线程引起,此处报错结束循环
                        break
                    if not robot:
                        continue
                    robot.GetAIMgr().ProcessAI()
@@ -79,7 +88,11 @@
                # 队列中清理无效的脱机挂, 一次只清理一个
                for index in xrange(self.robotMgr.GetRobotCount()):
                    #logging.debug( "Run AI for Index:%d", index )
                    robot = self.robotMgr.GetRobot( index )
                    try:
                        robot = self.robotMgr.GetRobot( index )
                    except:
                        # 判断index防范不到,可能多线程引起,此处报错结束循环
                        break
                    if not robot:
                        print "====没有机器人"
                        self.robotMgr.Remove(robot)