| | |
| | | import PlayerControl
|
| | | import FamilyRobBoss
|
| | | import NPCCustomRefresh
|
| | | import EventShell
|
| | | import FBLogic
|
| | | import FBCommon
|
| | | import ShareDefine
|
| | | import EventReport
|
| | | import ItemCommon
|
| | | import PyGameData
|
| | | import PlayerTeam
|
| | | import GameMap
|
| | | import NPCRealmRefresh
|
| | | import IpyGameDataPY
|
| | | import DBDataMgr
|
| | | import GameWorldEvent
|
| | | #---------------------------------------------------------------------
|
| | | ## 副本开启
|
| | | # @param gameWorld IPY_GameWorld
|
| | |
| | | GameWorld.Log("发送未拾取的物品给玩家: %s" % mailItemList, ownerID)
|
| | | if isCrossServer:
|
| | | serverGroupID = playerServerGroupIDDict.get(ownerID, 0)
|
| | | PlayerControl.SendCrossMail(serverGroupID, "ItemNoPickUp", [ownerID], mailItemList, [gameWorld.GetMapID()])
|
| | | # 删除旧版发送邮件,如果功能还有需要,可使用新版本发送邮件 PlayerMail
|
| | | else:
|
| | | PlayerControl.SendMailByKey("ItemNoPickUp", [ownerID], mailItemList, [gameWorld.GetMapID()])
|
| | |
|
| | |
| | | if playerExistTime < existTime / 2:
|
| | | #这个玩家存在时间过短, 不能触发副本结束的事件
|
| | | continue
|
| | |
|
| | | #副本时间到了, 调用时间到响应
|
| | | EventShell.EventResponse_OnFBTimeOut(curPlayer)
|
| | | |
| | | |
| | | #输出调试信息
|
| | | GameWorld.Log('__ProcessTimeKickPlayer! LineID = %s, openState = %s'%(gameWorld.GetLineID(), gameWorld.GetOpenState()))
|
| | |
|
| | |
| | | if not gameWorld.GetInitOK() :
|
| | | return
|
| | |
|
| | | GameWorldEvent.OnHighProcess(tick)
|
| | | |
| | | __ProcessOpen(gameWorld, tick)
|
| | |
|
| | | __ProcessTimeKickPlayer(gameWorld, tick) # 处理副本生存周期强关副本
|
| | |
| | | #通知RouteServer 消息
|
| | | __ProcessRouteServer(gameWorld, tick)
|
| | |
|
| | | #每分钟触发
|
| | | curTime = GameWorld.GetCurrentTime()
|
| | | __OnMapMinute(curTime, tick)
|
| | | __RefreshOnMinute(curTime, tick)
|
| | | #五分钟触发
|
| | | __RefreshOnFiveMinute(tick)
|
| | | #定时检测关闭超时文件
|
| | | EventReport.OnTimeCloseScribeTxt()
|
| | |
|
| | |
| | | ## 初始化gameWorld
|
| | | # @param tick 当前时间
|
| | | # @return None
|
| | | # @remarks 函数详细说明.
|
| | | # @remarks 函数详细说明 每条分线都会触发该函数
|
| | | def InitGameWorld(tick):
|
| | | if not PyGameData.g_initGame:
|
| | | PyGameData.g_initGame = True
|
| | | DBDataMgr.OnServerStart()
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | ItemCommon.InitPyItem()
|
| | | EventShell.DoReloadRefresh()
|
| | | #处理副本逻辑
|
| | | FBLogic.OnInit(tick)
|
| | | #初始化地图时钟
|
| | |
| | | #初始化事件报告
|
| | | EventReport.InitDllAppID()
|
| | | #向GameServer注册普通地图启动成功信息
|
| | | GameServer_CommMapServerInitOK(gameWorld)
|
| | | #GameServer_CommMapServerInitOK(gameWorld)
|
| | | #初始化游戏世界的最后一步
|
| | | gameWorld.SetInitOK(True)
|
| | | #通知BalanceServer自己初始化好了
|
| | | gameWorld.BalanceServer_MapServerInitOK()
|
| | | return
|
| | |
|
| | |
|
| | |
|
| | | def GameServer_CommMapServerInitOK(gameWorld):
|
| | | '''
|
| | |
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | ## 五分钟刷新
|
| | | # @param tick
|
| | | # @return None
|
| | | def __RefreshOnFiveMinute(tick):
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | lastTick = gameWorld.GetTickByType(ChConfig.TYPE_Map_Tick_ProcessFiveMinute)
|
| | | tickInterval = ChConfig.TYPE_Map_Tick_Time[ChConfig.TYPE_Map_Tick_ProcessFiveMinute]
|
| | | if tick - lastTick < tickInterval:
|
| | | return
|
| | | gameWorld.SetTickByType(ChConfig.TYPE_Map_Tick_ProcessFiveMinute, tick)
|
| | | |
| | | # playerManager = GameWorld.GetMapCopyPlayerManager()
|
| | | # for index in xrange(playerManager.GetPlayerCount()):
|
| | | # curPlayer = playerManager.GetPlayerByIndex(index)
|
| | | # if not curPlayer:
|
| | | # continue
|
| | |
|
| | | ## 初始化共享表(原c++表)
|
| | | # @param tick 当前时间
|
| | | # @return None
|
| | | def ReadShareData(tick):
|
| | | #读取静态表,与数据库无关 不要调用UserCtrlDB
|
| | | from PyMongoDB.Collections import DataServerGameData
|
| | | from PyMongoDB.DBCommon import (GlobalFunctions, CommonDefine, error)
|
| | | from PyMongoDB.Common import (CommFunc, )
|
| | | import NetPackCommon
|
| | | import os
|
| | | import zlib
|
| | | sysData = DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinNPC,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagChinNPC.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagNPCRefresh,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagNPCRefresh.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinSkill,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagChinSkill.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinExp,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagChinExp.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinItem,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagChinItem.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagTransportRefresh,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagTransportRefresh.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinShopItem,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagChinShopItem.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagBornRefresh,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagBornRefresh.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinMixItem,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagChinMixItem.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagBuildEquip,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagBuildEquip.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagSuiteActivation,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagSuiteActivation.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagSuiteEffect,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagSuiteEffect.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagRepeatEvent,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagRepeatEvent.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagEffectRefresh,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagEffectRefresh.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagChinMap,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagChinMap.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagDBStoreItem,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagDBStoreItem.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagOnMissionDelete,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagOnMissionDelete.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagPet,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagPet.txt')) |
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagPetGrade,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagPetGrade.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagPetFriendliness,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagPetFriendliness.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagPetExp,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagPetExp.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagNPC_Item_Pet,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagNPC_Item_Pet.txt'))
|
| | | sysData += DataServerGameData.sysDBLoadFromFile(DataServerGameData.tagFlyObjBaseInfo,
|
| | | os.path.join(GlobalFunctions.getServerConfigPath(),
|
| | | CommonDefine.SYSDB_PATH,
|
| | | 'tagFlyObjBaseInfo.txt'))
|
| | |
|
| | |
|
| | | #压缩
|
| | | try:
|
| | | compressSysData = zlib.compress(sysData, 9) #最大压缩
|
| | | |
| | | #回发地图
|
| | | data = ''
|
| | | data = CommFunc.WriteBYTE(data, CommonDefine.dgGameData) #1
|
| | | data = CommFunc.WriteString(data, len(compressSysData), compressSysData)
|
| | |
|
| | | return
|
| | |
|
| | | ## 按分钟刷新
|
| | | # @param tick
|
| | | # @return None
|
| | | def __RefreshOnMinute(curTime, tick):
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | lastTick = gameWorld.GetTickByType(ChConfig.TYPE_Map_Tick_ProcessMinute)
|
| | | tickInterval = ChConfig.TYPE_Map_Tick_Time[ChConfig.TYPE_Map_Tick_ProcessMinute]
|
| | | if tick - lastTick < tickInterval:
|
| | | return
|
| | | gameWorld.SetTickByType(ChConfig.TYPE_Map_Tick_ProcessMinute, tick)
|
| | | |
| | | playerManager = GameWorld.GetMapCopyPlayerManager()
|
| | | for index in xrange(playerManager.GetPlayerCount()):
|
| | | curPlayer = playerManager.GetPlayerByIndex(index)
|
| | | if not curPlayer:
|
| | | continue
|
| | | |
| | | __ProcessHalfHour(curPlayer, curTime, tick)
|
| | | return
|
| | |
|
| | | def __OnMapMinute(curTime, tick):
|
| | | ## 地图层级每分钟处理, 每分钟最多只会处理一次, 无视虚拟分线
|
| | | curMinute = curTime.minute
|
| | | if curMinute == PyGameData.g_mapLastProcess_Minute:
|
| | | return
|
| | | if PyGameData.g_initGame:
|
| | | DBDataMgr.OnMinute(curMinute)
|
| | | PyGameData.g_mapLastProcess_Minute = curMinute
|
| | | PlayerTeam.OnCheckTeamPlayerDisconnectTimeout(tick)
|
| | | |
| | | __CheckIpyDataRecycle(curTime)
|
| | | return
|
| | |
|
| | | def __CheckIpyDataRecycle(timeNow):
|
| | | ## 检查IpyData数据回收
|
| | | playerCount = GameWorld.GetPlayerManager().OnlineCount()
|
| | | if playerCount:
|
| | | PyGameData.g_ipyDataRecycleCheckTime = 0
|
| | | #GameWorld.DebugLog("地图还有玩家在线! playerCount=%s" % playerCount)
|
| | | return
|
| | | |
| | | curTime = GameWorld.ChangeDatetimeToNum(timeNow)
|
| | | if not PyGameData.g_ipyDataRecycleCheckTime:
|
| | | PyGameData.g_ipyDataRecycleCheckTime = curTime
|
| | | #GameWorld.DebugLog("地图没有玩家在线")
|
| | | return
|
| | | |
| | | if PyGameData.g_ipyDataRecycleCheckTime == 1:
|
| | | # 已经回收了
|
| | | #GameWorld.DebugLog("本次已经回收过了")
|
| | | return
|
| | | |
| | | if curTime - PyGameData.g_ipyDataRecycleCheckTime < 24 * 3600:
|
| | | #GameWorld.DebugLog("还未到达回收时间, passSeconds=%s" % (curTime - PyGameData.g_ipyDataRecycleCheckTime))
|
| | | return
|
| | | PyGameData.g_ipyDataRecycleCheckTime = 1 |
| | | IpyGameDataPY.IPYData.Recycle()
|
| | | return
|
| | |
|
| | | ## 整半小时触发 <00和30分钟时触发>
|
| | | # @param curPlayer
|
| | | # @param curTime 当前时间对象
|
| | | # @param tick
|
| | | # @return None
|
| | | def __ProcessHalfHour(curPlayer, curTime, tick):
|
| | | if curTime.minute not in [0, 30]:
|
| | | return
|
| | | |
| | | EventShell.EventResponse_OnHalfHour(curPlayer)
|
| | | return
|
| | | GameWorld.Log('Load game sys data for len = %s - %s ok!'%(len(compressSysData), len(data)))
|
| | | NetPackCommon.SendPyPackToMapServerSelf(data, len(data))
|
| | | except:
|
| | | msg = error.formatMsg('fatal', error.ERROR_NO_53, 'Compress game sys data failed!error = \n%s'%traceback.format_exc())
|
| | | GameWorld.ErrLog(msg)
|
| | | return |