| | |
| | | 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 # 历史异常脱机挂个数
|
| | |
|
| | |
| | | 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() # 在登录的机器人
|
| | |
|
| | |
| | | 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()
|
| | |
| | | # 队列中清理无效的脱机挂, 一次只清理一个
|
| | | 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)
|