10229 【越南】【主干】【港台】【砍树】古神战场修改(功能队伍增加队员在线状态同步;相关玩家在线状态管理,支持跨服;优化查找玩家相关联队伍同步玩家所在队伍及已申请的队伍;修复队伍成员找不到缓存时报错;优化玩家缓存判断是否保存统一逻辑,防止过天可能被删除;)
| | |
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # B3 15 相关玩家在线状态变更同步 #tagGCRelatedPlayerOnlineState
|
| | |
|
| | | class tagGCRelatedPlayerOnlineState(Structure):
|
| | | _pack_ = 1
|
| | | _fields_ = [
|
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("PlayerID", c_int), # 相关玩家ID
|
| | | ("OfflineValue", c_int), # 离线值:0-在线;1-离线;>1-上次离线时间戳,可用于计算离线多久了;当取不到玩家信息时用1代表已离线;
|
| | | ("IsCross", c_ubyte), # 是否跨服同步的,如果是跨服则离线时间计算时要取跨服服务器时间
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | self.Cmd = 0xB3
|
| | | self.SubCmd = 0x15
|
| | | return
|
| | |
|
| | | def ReadData(self, stringData, _pos=0, _len=0):
|
| | | self.Clear()
|
| | | memmove(addressof(self), stringData[_pos:], self.GetLength())
|
| | | return _pos + self.GetLength()
|
| | |
|
| | | def Clear(self):
|
| | | self.Cmd = 0xB3
|
| | | self.SubCmd = 0x15
|
| | | self.PlayerID = 0
|
| | | self.OfflineValue = 0
|
| | | self.IsCross = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | return sizeof(tagGCRelatedPlayerOnlineState)
|
| | |
|
| | | def GetBuffer(self):
|
| | | return string_at(addressof(self), self.GetLength())
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''// B3 15 相关玩家在线状态变更同步 //tagGCRelatedPlayerOnlineState:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | PlayerID:%d,
|
| | | OfflineValue:%d,
|
| | | IsCross:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.PlayerID,
|
| | | self.OfflineValue,
|
| | | self.IsCross
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | m_NAtagGCRelatedPlayerOnlineState=tagGCRelatedPlayerOnlineState()
|
| | | ChNetPackDict[eval("0x%02x%02x"%(m_NAtagGCRelatedPlayerOnlineState.Cmd,m_NAtagGCRelatedPlayerOnlineState.SubCmd))] = m_NAtagGCRelatedPlayerOnlineState
|
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # B3 20 送礼物成功通知 #tagGCSendGiftsOKList
|
| | |
|
| | | class tagGCSendGiftsOK(Structure):
|
| | |
| | | RealmLV = 0 #(WORD RealmLV)// 玩家境界
|
| | | FightPower = 0 #(DWORD FightPower)// 战力,求余亿
|
| | | FightPowerEx = 0 #(DWORD FightPowerEx)// 战力,整除亿
|
| | | OfflineValue = 0 #(DWORD OfflineValue)// 离线值:0-在线;1-离线;>1-上次离线时间戳,可用于计算离线多久了;当取不到玩家信息时用1代表已离线;
|
| | | Value1 = 0 #(DWORD Value1)//ֵ1
|
| | | Value2 = 0 #(DWORD Value2)//ֵ2
|
| | | data = None
|
| | |
| | | self.RealmLV,_pos = CommFunc.ReadWORD(_lpData, _pos)
|
| | | self.FightPower,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.FightPowerEx,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.OfflineValue,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.Value1,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.Value2,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | return _pos
|
| | |
| | | self.RealmLV = 0
|
| | | self.FightPower = 0
|
| | | self.FightPowerEx = 0
|
| | | self.OfflineValue = 0
|
| | | self.Value1 = 0
|
| | | self.Value2 = 0
|
| | | return
|
| | |
| | | length += 2
|
| | | length += 1
|
| | | length += 2
|
| | | length += 4
|
| | | length += 4
|
| | | length += 4
|
| | | length += 4
|
| | |
| | | data = CommFunc.WriteWORD(data, self.RealmLV)
|
| | | data = CommFunc.WriteDWORD(data, self.FightPower)
|
| | | data = CommFunc.WriteDWORD(data, self.FightPowerEx)
|
| | | data = CommFunc.WriteDWORD(data, self.OfflineValue)
|
| | | data = CommFunc.WriteDWORD(data, self.Value1)
|
| | | data = CommFunc.WriteDWORD(data, self.Value2)
|
| | | return data
|
| | |
| | | RealmLV:%d,
|
| | | FightPower:%d,
|
| | | FightPowerEx:%d,
|
| | | OfflineValue:%d,
|
| | | Value1:%d,
|
| | | Value2:%d
|
| | | '''\
|
| | |
| | | self.RealmLV,
|
| | | self.FightPower,
|
| | | self.FightPowerEx,
|
| | | self.OfflineValue,
|
| | | self.Value1,
|
| | | self.Value2
|
| | | )
|
| | |
| | | import PyGameData
|
| | | import CrossBoss
|
| | | import ChConfig
|
| | | import ChPlayer
|
| | | import PlayerFB
|
| | | import GMShell
|
| | |
|
| | |
| | |
|
| | | elif msgType == ShareDefine.ClientServerMsg_ChatCrossWorld:
|
| | | PlayerTalk.ClientServerMsg_ChatCrossWorld(serverGroupID, msgData, tick)
|
| | | |
| | | |
| | | elif msgType == ShareDefine.ClientServerMsg_PlayerLoginout:
|
| | | ChPlayer.ClientServerMsg_PlayerLoginout(serverGroupID, msgData)
|
| | | |
| | | elif msgType == ShareDefine.ClientServerMsg_GMCMD:
|
| | | GMShell.ClientServerMsg_GMCMD(msgData, tick)
|
| | |
|
| | |
| | | elif msgType == ShareDefine.CrossServerMsg_Notify:
|
| | | PlayerControl.CrossServerMsg_Notify(msgData)
|
| | |
|
| | | elif msgType == ShareDefine.CrossServerMsg_PlayerLoginout:
|
| | | ChPlayer.CrossServerMsg_PlayerLoginout(msgData)
|
| | | |
| | | elif msgType == ShareDefine.CrossServerMsg_ChatCrossWorld:
|
| | | PlayerTalk.CrossServerMsg_ChatCrossWorld(msgData)
|
| | |
|
| | |
| | | DataRecordPack.SendEventPack("CrossPK_%s" % eventName, drDataDict)
|
| | | return
|
| | |
|
| | | def IsCrossRealmPKPlayer(playerID, checkPreSeason=False, checkAllSeason=False):
|
| | | ## 仅跨服服务器判断用
|
| | | # @param checkPreSeason: 检查上一赛季
|
| | | # @param checkAllSeason: 检查所有赛季
|
| | | |
| | | # 默认取分区1的赛季作为当前赛季,所有分区赛季ID相同,且递增
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | nowSeasonID = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % 1)
|
| | | preSeasonID = nowSeasonID - 1
|
| | | crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
|
| | | crossZoneName = GameWorld.GetCrossZoneName()
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetCrossRealmPKSeasonCount()):
|
| | | seasonIpyData = ipyDataMgr.GetCrossRealmPKSeasonByIndex(index)
|
| | | if crossZoneName != seasonIpyData.GetCrossZoneName():
|
| | | continue
|
| | | zoneID = seasonIpyData.GetZoneID()
|
| | | seasonID = seasonIpyData.GetSeasonID()
|
| | | if checkAllSeason or seasonID == nowSeasonID or (checkPreSeason and seasonID == preSeasonID):
|
| | | pass
|
| | | else:
|
| | | continue
|
| | | _, orderDict = crossPKBillboardMgr.GetCrossPKBillboardInfo(zoneID, seasonID)
|
| | | if orderDict and playerID in orderDict:
|
| | | return True
|
| | | |
| | | return False
|
| | |
| | | if pID not in SkyTowerPassPlayerIDList:
|
| | | SkyTowerPassPlayerIDList.append(pID)
|
| | | IpyGameDataPY.SetConfigEx(ConfigExKey_SkyTowerPassPlayerIDList, SkyTowerPassPlayerIDList)
|
| | | GameWorld.DebugLog("IsSkyTowerPassPlayer SkyTowerPassPlayerIDList=%s" % SkyTowerPassPlayerIDList)
|
| | | #GameWorld.DebugLog("IsSkyTowerPassPlayer SkyTowerPassPlayerIDList=%s" % SkyTowerPassPlayerIDList)
|
| | | return playerID in SkyTowerPassPlayerIDList
|
| | |
|
| | | def __OnServerChallengePass(curPlayer, msgData):
|
| | |
| | | import CrossBattlefield
|
| | | import CrossActAllRecharge
|
| | | import CrossYaomoBoss
|
| | | import CrossRealmMsg
|
| | | import PlayerViewCache
|
| | | import PlayerFuncTeam
|
| | | import PyDataManager
|
| | | import GameWorldMineArea
|
| | | import PlayerRecData
|
| | | import GameWorship
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | class OnlinePlayerMgr():
|
| | | ''' 在线玩家管理,子服跨服通用
|
| | | 注:跨服服务器时,玩家不一定在跨服服务器,只是表示有同步到跨服服务器的在线玩家,且不是所有玩家都有同步
|
| | | '''
|
| | | |
| | | def __init__(self):
|
| | | self.onlinePlayerDict = {} # 在线玩家 {playerID:serverGroupID, ...}
|
| | | return
|
| | | |
| | | def IsOnline(self, playerID): return playerID in self.onlinePlayerDict
|
| | | |
| | | def __SetOnline(self, playerID, serverGroupID):
|
| | | self.onlinePlayerDict[playerID] = serverGroupID
|
| | | return
|
| | | |
| | | def __SetOffline(self, playerID, serverGroupID):
|
| | | self.onlinePlayerDict.pop(playerID, None)
|
| | | return
|
| | | |
| | | def SetOnlineState(self, playerID, isOnline, serverGroupID=0):
|
| | | if isOnline:
|
| | | self.__SetOnline(playerID, serverGroupID)
|
| | | else:
|
| | | self.__SetOffline(playerID, serverGroupID)
|
| | | return
|
| | | |
| | | def GetOfflineValue(self, playerID, viewCache=None):
|
| | | ## 离线值:0-在线;1-离线;>1-上次离线时间戳,可用于计算离线多久了;当取不到玩家信息时用1代表已离线;
|
| | | if playerID in self.onlinePlayerDict:
|
| | | return 0
|
| | | offlineValue = 1
|
| | | if viewCache and viewCache.OffTime:
|
| | | offlineValue = viewCache.OffTime
|
| | | return offlineValue
|
| | | |
| | | def GetOnlinePlayerMgr():
|
| | | mgr = PyGameData.g_onlinePlayerMgr
|
| | | if mgr == None:
|
| | | mgr = OnlinePlayerMgr()
|
| | | PyGameData.g_onlinePlayerMgr = mgr
|
| | | return mgr
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | |
| | | CrossYaomoBoss.OnPlayerLogin(curPlayer)
|
| | | #玩家记录
|
| | | PlayerRecData.OnPlayerLogin(curPlayer)
|
| | | |
| | | #在线状态变更,放最后
|
| | | __OnPlayerOnlineStateChange(curPlayer, True)
|
| | |
|
| | | if isMixServerFirstLogin:
|
| | | PlayerCharm.OnMixServerFirstLogin(curPlayer)
|
| | |
| | |
|
| | | if GameWorld.IsCrossServer():
|
| | | PlayerFB.OnPlayerDisconnectCrossServer(curPlayer)
|
| | | |
| | | return
|
| | | |
| | | #跨服匹配PK
|
| | | CrossRealmPK.OnLeaveServer(curPlayer)
|
| | |
|
| | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | PyGameData.g_unTJLogoffTime[playerID] = int(time.time())
|
| | |
|
| | | #在线状态变更,放最后
|
| | | __OnPlayerOnlineStateChange(curPlayer, False)
|
| | | return
|
| | |
|
| | | def __OnPlayerOnlineStateChange(curPlayer, isOnline):
|
| | | ## 在线状态变更
|
| | | if PlayerControl.GetIsTJG(curPlayer):
|
| | | return
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | olMgr = GetOnlinePlayerMgr()
|
| | | olMgr.SetOnlineState(playerID, isOnline)
|
| | | |
| | | #relatedPlayerIDList = [] # 本服相关玩家
|
| | | #offlineValue = olMgr.GetOfflineValue(playerID, PlayerViewCache.FindViewCache(playerID))
|
| | | #SyncRelatedPlayerOnlineState(playerID, offlineValue, relatedPlayerIDList)
|
| | | |
| | | if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_CrossRealmPK) \
|
| | | and not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_CrossBattlefield):
|
| | | GameWorld.DebugLog("跨服相关功能未开启,不同步在线状态到跨服服务器! LV=%s" % curPlayer.GetLV(), curPlayer.GetPlayerID())
|
| | | return
|
| | | |
| | | cacheBase = PlayerViewCache.GetSyncCrossCacheBase(curPlayer)
|
| | | dataMsg = {"playerID":playerID, "isOnline":isOnline, "cacheBase":cacheBase}
|
| | | CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PlayerLoginout, dataMsg)
|
| | | return
|
| | |
|
| | | def ClientServerMsg_PlayerLoginout(serverGroupID, msgData):
|
| | | ## 收到子服玩家上下线
|
| | | |
| | | playerID = msgData["playerID"]
|
| | | isOnline = msgData["isOnline"]
|
| | | cacheBase = msgData["cacheBase"]
|
| | | |
| | | isLogout = not isOnline
|
| | | PlayerViewCache.UpdCrossCacheBase(playerID, cacheBase, isLogout)
|
| | | |
| | | SyncCrossPlayerOnlineStateToRelatedPlayer(playerID)
|
| | | return
|
| | |
|
| | | def SyncCrossPlayerOnlineStateToRelatedPlayer(playerID):
|
| | | ## 同步跨服玩家在线状态给相关玩家
|
| | | |
| | | relatedPlayerIDList = []
|
| | | |
| | | # 功能队伍
|
| | | funcTeamMgr = PyDataManager.GetDBPyFuncTeamManager()
|
| | | playerTeamIDDict = funcTeamMgr.GetPlayerTeamIDDict(playerID)
|
| | | for _, teamID in playerTeamIDDict.items():
|
| | | funcTeam = funcTeamMgr.GetFuncTeam(teamID)
|
| | | if not funcTeam:
|
| | | continue
|
| | | relatedPlayerIDList += funcTeam.GetMemberIDList()
|
| | | |
| | | # 其他...
|
| | | |
| | | # 去重汇总
|
| | | relatedPlayerIDList = list(set(relatedPlayerIDList)) |
| | | if playerID in relatedPlayerIDList:
|
| | | relatedPlayerIDList.remove(playerID)
|
| | | if not relatedPlayerIDList:
|
| | | return
|
| | | |
| | | offlineValue = GetOnlinePlayerMgr().GetOfflineValue(playerID, PlayerViewCache.FindViewCache(playerID))
|
| | | dataMsg = {"loginoutPlayerID":playerID, "offlineValue":offlineValue, "relatedPlayerIDList":relatedPlayerIDList}
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PlayerLoginout, dataMsg)
|
| | | return
|
| | |
|
| | | def CrossServerMsg_PlayerLoginout(msgData):
|
| | | ## 收到跨服服务器信息 - 玩家上下线状态变更
|
| | | loginoutPlayerID = msgData["loginoutPlayerID"]
|
| | | offlineValue = msgData["offlineValue"]
|
| | | relatedPlayerIDList = msgData["relatedPlayerIDList"]
|
| | | SyncRelatedPlayerOnlineState(loginoutPlayerID, offlineValue, relatedPlayerIDList, 1)
|
| | | return
|
| | |
|
| | | def SyncRelatedPlayerOnlineState(loginoutPlayerID, offlineValue, relatedPlayerIDList, isCross=0):
|
| | | clientPack = None
|
| | | playerMgr = GameWorld.GetPlayerManager()
|
| | | for playerID in relatedPlayerIDList:
|
| | | if not PlayerControl.GetDBPlayerAccIDByID(playerID):
|
| | | continue
|
| | | curPlayer = playerMgr.FindPlayerByID(playerID)
|
| | | if not curPlayer or not curPlayer.GetInitOK():
|
| | | continue
|
| | | |
| | | if not clientPack:
|
| | | clientPack = ChPyNetSendPack.tagGCRelatedPlayerOnlineState()
|
| | | clientPack.PlayerID = loginoutPlayerID
|
| | | clientPack.OfflineValue = offlineValue
|
| | | clientPack.IsCross = isCross
|
| | | |
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | ## 设置玩家离线时间
|
| | |
| | | return 0
|
| | | teamIDDict = self.playerFuncTeamIDDict[playerID]
|
| | | return teamIDDict.get(funcMapID, 0)
|
| | | def GetPlayerTeamIDDict(self, playerID): return self.playerFuncTeamIDDict.get(playerID, {})
|
| | |
|
| | | def IsTeamPlayer(self, playerID):
|
| | | if playerID in self.playerFuncTeamIDDict:
|
| | |
| | | memberList = []
|
| | | for memberInfo in teamInfo["MemberList"]:
|
| | | mem = ChPyNetSendPack.tagGCFuncTeamMem()
|
| | | mem.ServerID = memberInfo["ServerID"]
|
| | | mem.ServerID = memberInfo.get("ServerID", 0)
|
| | | mem.PlayerID = memberInfo["PlayerID"]
|
| | | mem.Name = memberInfo["Name"]
|
| | | mem.Name = memberInfo.get("Name", "")
|
| | | mem.NameLen = len(mem.Name)
|
| | | mem.LV = memberInfo["LV"]
|
| | | mem.Job = memberInfo["Job"]
|
| | | mem.RealmLV = memberInfo["RealmLV"]
|
| | | mem.FightPower = memberInfo["FightPower"] % ChConfig.Def_PerPointValue
|
| | | mem.FightPowerEx = memberInfo["FightPower"] / ChConfig.Def_PerPointValue
|
| | | mem.LV = memberInfo.get("LV", 0)
|
| | | mem.Job = memberInfo.get("Job", 0)
|
| | | mem.RealmLV = memberInfo.get("RealmLV", 0)
|
| | | mem.FightPower = memberInfo.get("FightPower", 0) % ChConfig.Def_PerPointValue
|
| | | mem.FightPowerEx = memberInfo.get("FightPower", 0) / ChConfig.Def_PerPointValue
|
| | | mem.Value1 = memberInfo["Value1"]
|
| | | mem.Value2 = memberInfo["Value2"]
|
| | | memberList.append(mem)
|
| | |
| | | memberList = []
|
| | | for memberInfo in memberInfoList:
|
| | | mem = ChPyNetSendPack.tagGCFuncTeamRefreshMem()
|
| | | mem.ServerID = memberInfo["ServerID"]
|
| | | mem.ServerID = memberInfo.get("ServerID", 0)
|
| | | mem.PlayerID = memberInfo["PlayerID"]
|
| | | mem.Name = memberInfo["Name"]
|
| | | mem.Name = memberInfo.get("Name", "")
|
| | | mem.NameLen = len(mem.Name)
|
| | | mem.LV = memberInfo["LV"]
|
| | | mem.Job = memberInfo["Job"]
|
| | | mem.RealmLV = memberInfo["RealmLV"]
|
| | | mem.FightPower = memberInfo["FightPower"] % ChConfig.Def_PerPointValue
|
| | | mem.FightPowerEx = memberInfo["FightPower"] / ChConfig.Def_PerPointValue
|
| | | mem.LV = memberInfo.get("LV", 0)
|
| | | mem.Job = memberInfo.get("Job", 0)
|
| | | mem.RealmLV = memberInfo.get("RealmLV", 0)
|
| | | mem.FightPower = memberInfo.get("FightPower", 0) % ChConfig.Def_PerPointValue
|
| | | mem.FightPowerEx = memberInfo.get("FightPower", 0) / ChConfig.Def_PerPointValue
|
| | | mem.OfflineValue = memberInfo.get("OfflineValue", 0)
|
| | | mem.Value1 = memberInfo["Value1"]
|
| | | mem.Value2 = memberInfo["Value2"]
|
| | | memberList.append(mem)
|
| | |
| | |
|
| | | # 非列表查询,返回玩家相关队伍
|
| | | if "startIndex" not in msgData:
|
| | | syncPlayerIDList = [playerID]
|
| | | serverGroupList = [serverGroupID]
|
| | | |
| | | funcTeamMgr = PyDataManager.GetDBPyFuncTeamManager()
|
| | | # 申请的队伍
|
| | | funcTeamList = funcTeamMgr.GetFuncTeamList(zoneID, funcMapID)
|
| | | for funcTeam in funcTeamList:
|
| | | if playerID not in funcTeam.GetApplyIDList():
|
| | | continue
|
| | | teamID = funcTeam.GetTeamID()
|
| | | teamInfo = funcTeam.GetSyncDict(False)
|
| | | sendMsg = {"infoType":"QueryPlayerFuncTeam", "zoneID":zoneID, "playerID":playerID, "funcMapID":funcMapID, |
| | | "teamInfo":teamInfo, "teamID":teamID, "syncPlayerIDList":syncPlayerIDList}
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_FuncTeamInfo, sendMsg, serverGroupList)
|
| | | |
| | | # 玩家所属队伍
|
| | | teamID = funcTeamMgr.GetPlayerTeamID(playerID, funcMapID)
|
| | | funcTeam = funcTeamMgr.GetFuncTeam(teamID)
|
| | | teamInfo = funcTeam.GetSyncDict(True) if funcTeam else {}
|
| | | syncPlayerIDList = [playerID]
|
| | | serverGroupList = [serverGroupID]
|
| | | sendMsg = {"infoType":"QueryPlayerFuncTeam", "zoneID":zoneID, "playerID":playerID, "funcMapID":funcMapID,
|
| | | "teamInfo":teamInfo, "teamID":teamID, "syncPlayerIDList":syncPlayerIDList}
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_FuncTeamInfo, sendMsg, serverGroupList)
|
| | |
| | | import PyGameDataStruct
|
| | | import IpyGameDataPY
|
| | | import PyDataManager
|
| | | import CrossRealmPK
|
| | | import ShareDefine
|
| | | import ChPlayer
|
| | | import ChConfig
|
| | |
|
| | | import json
|
| | |
| | | DelOutofTimeViewCacheData()
|
| | | return
|
| | |
|
| | | def IsSaveDBViewCache(playerID, playerLV):
|
| | | ## 是否保存基本的缓存数据
|
| | | def IsSaveDBViewCache(viewCache):
|
| | | ## 缓存数据是否入库
|
| | | if not viewCache:
|
| | | return False
|
| | | |
| | | playerID = viewCache.PlayerID
|
| | | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID):
|
| | | return True
|
| | |
|
| | |
| | | if GameWorldSkyTower.IsSkyTowerPassPlayer(playerID):
|
| | | return True
|
| | |
|
| | | SaveDBLimitLV = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 1)
|
| | | #校验玩家等级
|
| | | if playerLV < SaveDBLimitLV:
|
| | | return False
|
| | | |
| | | return True
|
| | |
|
| | | def IsSaveAllViewCache(playerID):
|
| | | ## 是否保存所有缓存数据
|
| | | |
| | | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID):
|
| | | return True
|
| | | |
| | | if GameWorldArena.IsArenaBattlePlayer(playerID):
|
| | | return True
|
| | | |
| | | if CrossBattlefield.IsBattlefieldCallPlayer(playerID):
|
| | | return True
|
| | | |
| | | if CrossChampionship.IsChampionshipPlayer(playerID):
|
| | | return True
|
| | | |
| | | NeedCheckBillBoardType = IpyGameDataPY.GetFuncEvalCfg("PlayerViewCache", 2)
|
| | | #校验玩家是否上排行榜
|
| | | billboardMgr = GameWorld.GetBillboard()
|
| | | for BillBoardType in NeedCheckBillBoardType:
|
| | | curBillboard = billboardMgr.FindBillboard(BillBoardType)
|
| | | if not curBillboard:
|
| | | continue
|
| | | if curBillboard.FindByID(playerID):
|
| | | return True
|
| | | |
| | | #跨服榜单上的默认保留
|
| | | if GameWorld.IsCrossServer():
|
| | | billboardMgr = PyDataManager.GetCrossBillboardManager()
|
| | |
| | | if billboardObj.FindByID(playerID):
|
| | | return True
|
| | |
|
| | | if CrossRealmPK.IsCrossRealmPKPlayer(playerID, checkPreSeason=True):
|
| | | return True
|
| | | else:
|
| | | NeedCheckBillBoardType = IpyGameDataPY.GetFuncEvalCfg("PlayerViewCache", 2)
|
| | | #校验玩家是否上排行榜
|
| | | billboardMgr = GameWorld.GetBillboard()
|
| | | for BillBoardType in NeedCheckBillBoardType:
|
| | | curBillboard = billboardMgr.FindBillboard(BillBoardType)
|
| | | if not curBillboard:
|
| | | continue
|
| | | if curBillboard.FindByID(playerID):
|
| | | return True
|
| | | |
| | | # 以上是相关功能需要用到的数据,必定不能删除的
|
| | | |
| | | # 以下是保留近期活跃玩家,等级限制
|
| | | playerLV = viewCache.LV
|
| | | offTime = viewCache.OffTime
|
| | | if not playerLV and not offTime:
|
| | | # 跨服服务器之前某些情况没有存储LV及OffTime,防止误删,做旧数据兼容用
|
| | | return True
|
| | | |
| | | SaveDBLimitLV = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 1)
|
| | | if playerLV >= SaveDBLimitLV:
|
| | | maxDays = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 3)
|
| | | if not maxDays:
|
| | | maxDays = 7 # 默认7天
|
| | | MaxTime = maxDays * 3600 * 24
|
| | | curTime = int(time.time())
|
| | | passTime = curTime - viewCache.OffTime
|
| | | if passTime < MaxTime:
|
| | | return True
|
| | | |
| | | return False
|
| | |
|
| | | def DelOutofTimeViewCacheData():
|
| | | ## 删除过期的查看缓存数据
|
| | |
|
| | | curTime = int(time.time())
|
| | | MaxTime = IpyGameDataPY.GetFuncCfg("PlayerViewCache", 3) * 3600 * 24
|
| | | |
| | | pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
|
| | | playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict
|
| | | for playerID, viewCache in playerViewCachePyDict.items():
|
| | | |
| | | passTime = curTime - viewCache.OffTime
|
| | | if passTime < MaxTime:
|
| | | continue
|
| | | if IsSaveAllViewCache(playerID):
|
| | | if IsSaveDBViewCache(viewCache):
|
| | | continue
|
| | | playerViewCachePyDict.pop(playerID)
|
| | |
|
| | |
| | | # 内网测试假玩家
|
| | | if playerID < 10000 and not newPropData:
|
| | | openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1)
|
| | | fakeName = "匿名玩家".decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())
|
| | | fakeName = "神秘道友".decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())
|
| | | fakeName = "%s%s" % (fakeName, playerID)
|
| | | serverID = random.randint(9900, 9950)
|
| | | serverID = playerID % 200 + 1 # 1 ~ 200 服
|
| | | serverGroupID = serverID
|
| | | if serverID < 50:
|
| | | serverGroupID = serverGroupID / 10 + 1 # 前50服每10服1主服
|
| | | isOnline = True if playerID % 2 == 0 else False
|
| | | olMgr = ChPlayer.GetOnlinePlayerMgr()
|
| | | olMgr.SetOnlineState(playerID, isOnline, serverGroupID)
|
| | | accID = "fake%s@test@s%s" % (playerID, serverID)
|
| | | newPropData = {
|
| | | "AccID":accID,
|
| | |
| | | "LV":random.randint(100, 200),
|
| | | "RealmLV":random.randint(5, 15),
|
| | | "FightPower":random.randint(1000000, 100000000),
|
| | | "ServerGroupID":serverID,
|
| | | "ServerGroupID":serverGroupID,
|
| | | }
|
| | | curCache = PyGameDataStruct.tagPlayerViewCachePy()
|
| | | curCache.PlayerID = playerID
|
| | | curCache.OffTime = int(time.time())
|
| | | if newPropData:
|
| | | curCache.PropData = json.dumps(newPropData, ensure_ascii=False).replace(" ", "")
|
| | | curCache.PropDataSize = len(curCache.PropData)
|
| | |
| | |
|
| | | def GetShotCahceDict(playerID, withEquip=False):
|
| | | ## 获取玩家简短的缓存信息字典
|
| | | cacheDict = GetCachePropDataDict(FindViewCache(playerID))
|
| | | viewCache = FindViewCache(playerID)
|
| | | cacheDict = GetCachePropDataDict(viewCache)
|
| | | if not cacheDict:
|
| | | return {}
|
| | | olMgr = ChPlayer.GetOnlinePlayerMgr()
|
| | | shotCacheDict = {
|
| | | "PlayerID":playerID,
|
| | | "Name":cacheDict["Name"],
|
| | |
| | | "RealmLV":cacheDict["RealmLV"],
|
| | | "FightPower":cacheDict["FightPower"],
|
| | | "ServerID":GameWorld.GetAccIDServerID(cacheDict["AccID"]),
|
| | | "OfflineValue":olMgr.GetOfflineValue(playerID, viewCache)
|
| | | }
|
| | | if withEquip:
|
| | | shotCacheDict.update({
|
| | |
| | | }
|
| | | return cacheBase
|
| | |
|
| | | def UpdCrossCacheBase(playerID, cacheBase):
|
| | | def UpdCrossCacheBase(playerID, cacheBase, isLogout=False):
|
| | | ## 更新同步跨服基础查看缓存
|
| | | cacheDict = GetCachePropDataDict(FindViewCache(playerID, True))
|
| | | #更新跨服在线状态,只要有同步即视为在线,除了指定是Logout的
|
| | | olMgr = ChPlayer.GetOnlinePlayerMgr()
|
| | | olMgr.SetOnlineState(playerID, not isLogout, cacheBase.get("ServerGroupID", 0))
|
| | | curCache = FindViewCache(playerID, True)
|
| | | if not curCache:
|
| | | return {}
|
| | | curCache.LV = cacheBase.get("LV", 0)
|
| | | curCache.OffTime = int(time.time()) # 每次都更新,最后一次可视为跨服玩家的最近一次离线时间
|
| | | cacheDict = GetCachePropDataDict(curCache)
|
| | | if not cacheBase:
|
| | | return cacheDict
|
| | | for k, v in cacheBase.items():
|
| | | cacheDict[k] = v
|
| | | if isLogout:
|
| | | if not IsSaveDBViewCache(curCache):
|
| | | DeleteViewCache(playerID)
|
| | | return {}
|
| | | return cacheDict
|
| | |
|
| | | #//04 01 地图同步玩家缓存数据到GameServer#tagMGUpdatePlayerCache
|
| | |
| | | #};
|
| | | def OnMGUpdatePlayerCache(routeIndex, mapID, curPackData, tick):
|
| | | playerID = curPackData.PlayerID
|
| | | playerLV = curPackData.PlayerLV
|
| | | #playerLV = curPackData.PlayerLV
|
| | | isLogout = curPackData.IsLogouting
|
| | | GameWorld.DebugLog('ViewCache### OnMGUpdatePlayerCache isLogout=%s' % isLogout, playerID)
|
| | | isSaveAll = True # 是否保存所有数据
|
| | | if isLogout:
|
| | | #不需要保存离线数据的,直接删除缓存数据
|
| | | if not IsSaveDBViewCache(playerID, playerLV):
|
| | | DeleteViewCache(playerID)
|
| | | return
|
| | | isSaveAll = IsSaveAllViewCache(playerID)
|
| | | GameWorld.DebugLog(" isSaveAll=%s" % isSaveAll, playerID)
|
| | |
|
| | | curCache = FindViewCache(playerID, True)
|
| | | if not curCache:
|
| | | return
|
| | | curCache.LV = curPackData.PlayerLV
|
| | | curCache.OffTime = curPackData.OffTime
|
| | | if isLogout:
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if curPlayer:
|
| | | curCache.GeTuiID = curPlayer.GetGeTuiClientID()
|
| | | curCache.GeTuiIDSize = len(curCache.GeTuiID)
|
| | | |
| | | curCache.PropDataDict = {} # 每次更新数据时,重置字典缓存,下次获取时重新eval缓存
|
| | | curCache.PropData = curPackData.PropData
|
| | | curCache.PropDataSize = curPackData.PropDataSize
|
| | |
| | | setattr(curCache, "ItemDataSize%s" % classLV, itemDataSize)
|
| | | #GameWorld.DebugLog(" 更新Item数据: classLV=%s,size=%s, %s" % (classLV, itemDataSize, itemData), playerID)
|
| | |
|
| | | if isLogout:
|
| | | #不需要保存离线数据的,直接删除缓存数据
|
| | | if not IsSaveDBViewCache(curCache):
|
| | | DeleteViewCache(playerID)
|
| | | return
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if curPlayer:
|
| | | curCache.GeTuiID = curPlayer.GetGeTuiClientID()
|
| | | curCache.GeTuiIDSize = len(curCache.GeTuiID)
|
| | | |
| | | #GameWorld.DebugLog(" %s" % curCache.outputString())
|
| | | # 同步更新助战信息
|
| | | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID):
|
| | |
| | | cnt = 0
|
| | |
|
| | | for dbData in self.playerViewCachePyDict.values():
|
| | | if dbData.PlayerID < 10000:
|
| | | # 假人玩家不存储
|
| | | continue
|
| | | cnt += 1
|
| | | savaData += dbData.getBuffer()
|
| | |
|
| | |
| | |
|
| | | g_pyGameDataManager = None
|
| | |
|
| | | g_onlinePlayerMgr = None # 玩家在线管理
|
| | |
|
| | | g_commMapLineInfo = {} # 地图线路真实地图虚拟线信息 {(dataMapID, lineID):(realMapID, copyMapID), ...}
|
| | | g_commMapLineRouteDict = {} # 地图线路路由服务索引信息 {(dataMapID, lineID):routeServerIndex, ...}
|
| | | g_commMapLinePlayerCountDict = {} # 常规地图分线人数 {dataMapID:{lineID:人数, ...}}
|
| | |
| | | GameFuncID_LittleHelper = 146 # 小助手
|
| | | GameFuncID_TJG = 147 # 脱机挂
|
| | | GameFuncID_SuperGift = 150 # 超值礼包
|
| | | GameFuncID_CrossRealmPK = 157 # 跨服天梯
|
| | | GameFuncID_PenglaiBoss = 162 # 蓬莱仙境
|
| | | GameFuncID_ZhuXianBoss = 163 # 诛仙BOSS
|
| | | GameFuncID_Arena = 195 # 竞技场
|
| | | GameFuncID_FaQi = 199 # 法器
|
| | | GameFuncID_LianTi = 207 # 炼体
|
| | | GameFuncID_CrossBattlefield = 208 # 跨服古神战场
|
| | | GameFuncID_Championship = 210 # 排位
|
| | | GameFuncID_MineArea = 227 # 福地
|
| | | GameFuncID_Guaji = 228 # 挂机
|
| | |
| | |
|
| | | # 跨服服务器发送子服信息定义
|
| | | CrossServerMsg_CrossServerState = "CrossServerState" # 跨服服务器状态变更
|
| | | CrossServerMsg_PlayerLoginout = "PlayerLoginout" # 玩家上下线状态同步
|
| | | CrossServerMsg_ExitCrossServer = "ExitCrossServer" # 退出跨服服务器
|
| | | CrossServerMsg_Notify = "Notify" # 提示信息
|
| | | CrossServerMsg_ChatCrossWorld = "ChatCrossWorld" # 跨服世界聊天
|
| | |
| | |
|
| | | # 子服发送跨服信息定义
|
| | | ClientServerMsg_ServerInitOK = "ServerInitOK" # 子服启动成功
|
| | | ClientServerMsg_PlayerLoginout = "PlayerLoginout" # 玩家上下线状态同步
|
| | | ClientServerMsg_ChatCrossWorld = "ChatCrossWorld" # 跨服世界聊天
|
| | | ClientServerMsg_GMCMD = "GMCMD" # GM命令
|
| | | ClientServerMsg_ViewPlayerCache = "ViewPlayerCache" # 查看跨服玩家信息
|
| | |
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # B3 15 相关玩家在线状态变更同步 #tagGCRelatedPlayerOnlineState
|
| | |
|
| | | class tagGCRelatedPlayerOnlineState(Structure):
|
| | | _pack_ = 1
|
| | | _fields_ = [
|
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("PlayerID", c_int), # 相关玩家ID
|
| | | ("OfflineValue", c_int), # 离线值:0-在线;1-离线;>1-上次离线时间戳,可用于计算离线多久了;当取不到玩家信息时用1代表已离线;
|
| | | ("IsCross", c_ubyte), # 是否跨服同步的,如果是跨服则离线时间计算时要取跨服服务器时间
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | self.Cmd = 0xB3
|
| | | self.SubCmd = 0x15
|
| | | return
|
| | |
|
| | | def ReadData(self, stringData, _pos=0, _len=0):
|
| | | self.Clear()
|
| | | memmove(addressof(self), stringData[_pos:], self.GetLength())
|
| | | return _pos + self.GetLength()
|
| | |
|
| | | def Clear(self):
|
| | | self.Cmd = 0xB3
|
| | | self.SubCmd = 0x15
|
| | | self.PlayerID = 0
|
| | | self.OfflineValue = 0
|
| | | self.IsCross = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | return sizeof(tagGCRelatedPlayerOnlineState)
|
| | |
|
| | | def GetBuffer(self):
|
| | | return string_at(addressof(self), self.GetLength())
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''// B3 15 相关玩家在线状态变更同步 //tagGCRelatedPlayerOnlineState:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | PlayerID:%d,
|
| | | OfflineValue:%d,
|
| | | IsCross:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.PlayerID,
|
| | | self.OfflineValue,
|
| | | self.IsCross
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | m_NAtagGCRelatedPlayerOnlineState=tagGCRelatedPlayerOnlineState()
|
| | | ChNetPackDict[eval("0x%02x%02x"%(m_NAtagGCRelatedPlayerOnlineState.Cmd,m_NAtagGCRelatedPlayerOnlineState.SubCmd))] = m_NAtagGCRelatedPlayerOnlineState
|
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # B3 20 送礼物成功通知 #tagGCSendGiftsOKList
|
| | |
|
| | | class tagGCSendGiftsOK(Structure):
|
| | |
| | | RealmLV = 0 #(WORD RealmLV)// 玩家境界
|
| | | FightPower = 0 #(DWORD FightPower)// 战力,求余亿
|
| | | FightPowerEx = 0 #(DWORD FightPowerEx)// 战力,整除亿
|
| | | OfflineValue = 0 #(DWORD OfflineValue)// 离线值:0-在线;1-离线;>1-上次离线时间戳,可用于计算离线多久了;当取不到玩家信息时用1代表已离线;
|
| | | Value1 = 0 #(DWORD Value1)//ֵ1
|
| | | Value2 = 0 #(DWORD Value2)//ֵ2
|
| | | data = None
|
| | |
| | | self.RealmLV,_pos = CommFunc.ReadWORD(_lpData, _pos)
|
| | | self.FightPower,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.FightPowerEx,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.OfflineValue,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.Value1,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | self.Value2,_pos = CommFunc.ReadDWORD(_lpData, _pos)
|
| | | return _pos
|
| | |
| | | self.RealmLV = 0
|
| | | self.FightPower = 0
|
| | | self.FightPowerEx = 0
|
| | | self.OfflineValue = 0
|
| | | self.Value1 = 0
|
| | | self.Value2 = 0
|
| | | return
|
| | |
| | | length += 2
|
| | | length += 1
|
| | | length += 2
|
| | | length += 4
|
| | | length += 4
|
| | | length += 4
|
| | | length += 4
|
| | |
| | | data = CommFunc.WriteWORD(data, self.RealmLV)
|
| | | data = CommFunc.WriteDWORD(data, self.FightPower)
|
| | | data = CommFunc.WriteDWORD(data, self.FightPowerEx)
|
| | | data = CommFunc.WriteDWORD(data, self.OfflineValue)
|
| | | data = CommFunc.WriteDWORD(data, self.Value1)
|
| | | data = CommFunc.WriteDWORD(data, self.Value2)
|
| | | return data
|
| | |
| | | RealmLV:%d,
|
| | | FightPower:%d,
|
| | | FightPowerEx:%d,
|
| | | OfflineValue:%d,
|
| | | Value1:%d,
|
| | | Value2:%d
|
| | | '''\
|
| | |
| | | self.RealmLV,
|
| | | self.FightPower,
|
| | | self.FightPowerEx,
|
| | | self.OfflineValue,
|
| | | self.Value1,
|
| | | self.Value2
|
| | | )
|
| | |
| | | GameFuncID_LittleHelper = 146 # 小助手
|
| | | GameFuncID_TJG = 147 # 脱机挂
|
| | | GameFuncID_SuperGift = 150 # 超值礼包
|
| | | GameFuncID_CrossRealmPK = 157 # 跨服天梯
|
| | | GameFuncID_PenglaiBoss = 162 # 蓬莱仙境
|
| | | GameFuncID_ZhuXianBoss = 163 # 诛仙BOSS
|
| | | GameFuncID_Arena = 195 # 竞技场
|
| | | GameFuncID_FaQi = 199 # 法器
|
| | | GameFuncID_LianTi = 207 # 炼体
|
| | | GameFuncID_CrossBattlefield = 208 # 跨服古神战场
|
| | | GameFuncID_Championship = 210 # 排位
|
| | | GameFuncID_MineArea = 227 # 福地
|
| | | GameFuncID_Guaji = 228 # 挂机
|
| | |
| | |
|
| | | # 跨服服务器发送子服信息定义
|
| | | CrossServerMsg_CrossServerState = "CrossServerState" # 跨服服务器状态变更
|
| | | CrossServerMsg_PlayerLoginout = "PlayerLoginout" # 玩家上下线状态同步
|
| | | CrossServerMsg_ExitCrossServer = "ExitCrossServer" # 退出跨服服务器
|
| | | CrossServerMsg_Notify = "Notify" # 提示信息
|
| | | CrossServerMsg_ChatCrossWorld = "ChatCrossWorld" # 跨服世界聊天
|
| | |
| | |
|
| | | # 子服发送跨服信息定义
|
| | | ClientServerMsg_ServerInitOK = "ServerInitOK" # 子服启动成功
|
| | | ClientServerMsg_PlayerLoginout = "PlayerLoginout" # 玩家上下线状态同步
|
| | | ClientServerMsg_ChatCrossWorld = "ChatCrossWorld" # 跨服世界聊天
|
| | | ClientServerMsg_GMCMD = "GMCMD" # GM命令
|
| | | ClientServerMsg_ViewPlayerCache = "ViewPlayerCache" # 查看跨服玩家信息
|