| | |
| | |
|
| | | return DumpString
|
| | | #------------------------------------------------------
|
| | | # 05 03 玩家离开队伍 #tagGMPlayerLeaveTeam
|
| | |
|
| | | class tagGMPlayerLeaveTeam(Structure):
|
| | | _pack_ = 1
|
| | | _fields_ = [
|
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("PlayerID", c_int), |
| | | ("CopyMapID", c_int), |
| | | ("TeamID", c_int), |
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | self.Cmd = 0x05
|
| | | self.SubCmd = 0x03
|
| | | 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 = 0x05
|
| | | self.SubCmd = 0x03
|
| | | self.PlayerID = 0
|
| | | self.CopyMapID = 0
|
| | | self.TeamID = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | return sizeof(tagGMPlayerLeaveTeam)
|
| | |
|
| | | def GetBuffer(self):
|
| | | return string_at(addressof(self), self.GetLength())
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''// 05 03 玩家离开队伍 //tagGMPlayerLeaveTeam:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | PlayerID:%d,
|
| | | CopyMapID:%d,
|
| | | TeamID:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.PlayerID,
|
| | | self.CopyMapID,
|
| | | self.TeamID
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | m_NAtagGMPlayerLeaveTeam=tagGMPlayerLeaveTeam()
|
| | | ChNetPackDict[eval("0x%02x%02x"%(m_NAtagGMPlayerLeaveTeam.Cmd,m_NAtagGMPlayerLeaveTeam.SubCmd))] = m_NAtagGMPlayerLeaveTeam
|
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # 05 02 队伍信息刷新 #tagGMTeamInfo
|
| | |
|
| | | class tagGMTeamMemInfo(Structure):
|
| | |
| | | DR_Team(eventName, teamID, drDict)
|
| | | return
|
| | |
|
| | | def SyncMapServerPlayerNoTeam(curPlayer):
|
| | | ## 同步地图玩家没有队伍,切图时调用
|
| | | teamInfo = ChGameToMapPyPack.tagGMTeamInfo()
|
| | | teamInfo.PlayerID = curPlayer.GetPlayerID()
|
| | | teamInfo.TeamID = 0
|
| | | teamInfo.TeamLV = 0
|
| | | teamInfo.MemInfoList = []
|
| | | teamInfo.MemCnt = len(teamInfo.MemInfoList)
|
| | | NetPackCommon.SendPyPackToMapServer(curPlayer.GetLineNO(), curPlayer.GetRealMapID(), teamInfo)
|
| | | return
|
| | |
|
| | | def SyncMapServerPlayerLeaveTeam(curPlayer, teamID):
|
| | | ## 同步地图玩家离开队伍
|
| | | leavePack = ChGameToMapPyPack.tagGMPlayerLeaveTeam()
|
| | | leavePack.PlayerID = curPlayer.GetPlayerID()
|
| | | leavePack.CopyMapID = curPlayer.GetFBID()
|
| | | leavePack.TeamID = teamID
|
| | | NetPackCommon.SendPyPackToMapServer(curPlayer.GetLineNO(), curPlayer.GetRealMapID(), leavePack)
|
| | | return
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
|
| | | #// B9 03 修改队伍信息 #tagCGChangeTeamInfo
|
| | |
| | | #GameServer清除玩家队伍ID为空
|
| | | delPlayer.SetTeam(None)
|
| | | #通知MapServerd队伍变更, 在mapserver构建目前队伍
|
| | | delPlayer.MapServer_Sync_Team(0)
|
| | | #delPlayer.MapServer_Sync_Team(0)
|
| | | SyncMapServerPlayerLeaveTeam(delPlayer, curTeam.GetTeamID())
|
| | | #玩家离开副本
|
| | | delPlayer.MapServer_LeaveFB()
|
| | | if IsTeamMatchingPlayer(curTeam.GetTeamID()):
|
| | |
| | | #GameServer玩家队伍为空
|
| | | curPlayer.SetTeam(None)
|
| | | #通知MapServerd队伍变更
|
| | | curPlayer.MapServer_Sync_Team(0)
|
| | | #curPlayer.MapServer_Sync_Team(0)
|
| | | SyncMapServerPlayerLeaveTeam(curPlayer, curTeam.GetTeamID())
|
| | | __DoLogic_PlayerTeamChange(curPlayer)
|
| | |
|
| | | if curMember.GetTeamLV() != IPY_GameServer.tmlLeader:
|
| | |
| | | if curTeam == None:
|
| | | return
|
| | |
|
| | | if curTeam.GetTeamPlayerCount() <= 1:
|
| | | #补救完毕, 队伍中只有一个人, 删除这个队伍
|
| | | GameWorld.Log('玩家(%s)仍然有队伍(%s), 补救完毕, 队伍中只有一个人, 删除这个队伍' % (playerID, curTeamID))
|
| | | DeleteTeam(curTeam, tick)
|
| | | return
|
| | | #允许存在单人队伍,暂屏蔽该逻辑
|
| | | # if curTeam.GetTeamPlayerCount() <= 1:
|
| | | # #补救完毕, 队伍中只有一个人, 删除这个队伍
|
| | | # GameWorld.Log('玩家(%s)仍然有队伍(%s), 补救完毕, 队伍中只有一个人, 删除这个队伍' % (playerID, curTeamID))
|
| | | # DeleteTeam(curTeam, tick)
|
| | | # return
|
| | |
|
| | | GameWorld.Log('玩家(%s)仍然有队伍(%s), 补救' % (playerID, curTeamID))
|
| | | curPlayer.SetTeamID(curTeamID)
|
| | |
| | | curPlayer.SetTeam(None)
|
| | | curPlayer.Sync_LeaveTeam(1)
|
| | | #通知MapServer, 玩家已经队伍了, 刷新玩家的TeamID
|
| | | curPlayer.MapServer_Sync_Team(0)
|
| | | #curPlayer.MapServer_Sync_Team(0)
|
| | | SyncMapServerPlayerLeaveTeam(curPlayer, curTeamID)
|
| | | gameMap = GameWorld.GetMap(curPlayer.GetMapID())
|
| | | if gameMap and gameMap.GetMapFBType() == ChConfig.fbtTeam:
|
| | | curPlayer.MapServer_LeaveFB()
|
| | |
| | | # 玩家进入组队副本,则停止匹配
|
| | | if gameMap.GetMapFBType() == ChConfig.fbtTeam:
|
| | | DelPlayerIDFromMatchingList(curPlayer)
|
| | | |
| | | SyncMapServerPlayerNoTeam(curPlayer) # 没有队伍的时候切图也通知地图
|
| | | |
| | | return
|
| | |
|
| | | def PlayerTeamMemberRefresh(curPlayer, refreshType, value, tick):
|
| | |
| | | Writer = hxp
|
| | | Releaser = hxp
|
| | | RegType = 0
|
| | | RegisterPackCount = 1
|
| | | RegisterPackCount = 2
|
| | |
|
| | | PacketCMD_1=0x05
|
| | | PacketSubCMD_1=0x02
|
| | | PacketCallFunc_1=GameServer_TeamInfo
|
| | |
|
| | | PacketCMD_2=0x05
|
| | | PacketSubCMD_2=0x03
|
| | | PacketCallFunc_2=GameServer_PlayerLeaveTeam
|
| | |
|
| | |
| | |
|
| | | return DumpString
|
| | | #------------------------------------------------------
|
| | | # 05 03 玩家离开队伍 #tagGMPlayerLeaveTeam
|
| | |
|
| | | class tagGMPlayerLeaveTeam(Structure):
|
| | | _pack_ = 1
|
| | | _fields_ = [
|
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("PlayerID", c_int), |
| | | ("CopyMapID", c_int), |
| | | ("TeamID", c_int), |
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | | self.Clear()
|
| | | self.Cmd = 0x05
|
| | | self.SubCmd = 0x03
|
| | | 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 = 0x05
|
| | | self.SubCmd = 0x03
|
| | | self.PlayerID = 0
|
| | | self.CopyMapID = 0
|
| | | self.TeamID = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | | return sizeof(tagGMPlayerLeaveTeam)
|
| | |
|
| | | def GetBuffer(self):
|
| | | return string_at(addressof(self), self.GetLength())
|
| | |
|
| | | def OutputString(self):
|
| | | DumpString = '''// 05 03 玩家离开队伍 //tagGMPlayerLeaveTeam:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | PlayerID:%d,
|
| | | CopyMapID:%d,
|
| | | TeamID:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.PlayerID,
|
| | | self.CopyMapID,
|
| | | self.TeamID
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
|
| | | m_NAtagGMPlayerLeaveTeam=tagGMPlayerLeaveTeam()
|
| | | ChNetPackDict[eval("0x%02x%02x"%(m_NAtagGMPlayerLeaveTeam.Cmd,m_NAtagGMPlayerLeaveTeam.SubCmd))] = m_NAtagGMPlayerLeaveTeam
|
| | |
|
| | |
|
| | | #------------------------------------------------------
|
| | | # 05 02 队伍信息刷新 #tagGMTeamInfo
|
| | |
|
| | | class tagGMTeamMemInfo(Structure):
|
| | |
| | | # @return None or True
|
| | | # @remarks 函数详细说明.
|
| | | def GameServer_OnTeam(index, tick):
|
| | | GameWorld.GetPsycoFunc(__Func_GameServer_OnTeam)(index, tick)
|
| | | '''废弃该逻辑,由0502、0503封包结合处理
|
| | | 废弃原因:
|
| | | 因为当玩家有队伍时,加入别人的队伍,此时该玩家需要先退出队伍(OnTeam同步),再加入队伍(0502同步)
|
| | | 而地图会先收到0502包,导致地图队伍管理出现异常,所以暂时废弃OnTeam
|
| | | '''
|
| | | return
|
| | |
|
| | | ## 游戏服务器刷新队伍(封包参数)
|
| | | # @param index 玩家索引
|
| | | # @param tick 当前时间 |
| | | # @return None or True
|
| | | # @remarks 函数详细说明.
|
| | | def __Func_GameServer_OnTeam(index, tick):
|
| | | recvPack = IPY_GameWorld.IPY_MTeamRefresh()
|
| | | packPlayerID = recvPack.GetPlayerID()
|
| | | teamID = recvPack.GetTeamID()
|
| | | teamLV = recvPack.GetTeamLV()
|
| | | dataDict = {"packPlayerID":packPlayerID, "teamLV":teamLV, "index":index}
|
| | | |
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | if curPlayer == None:
|
| | | GameWorld.Log("地图服务器寻找组队玩家失败index = "+str(index))
|
| | | DR_Team("OnTeamError", teamID, dataDict, "curPlayer is None")
|
| | | return
|
| | | |
| | | if curPlayer.IsEmpty():
|
| | | GameWorld.Log("地图服务器寻找组队玩家失败index = %d, 玩家为空"%index)
|
| | | DR_Team("OnTeamError", teamID, dataDict, "curPlayer IsEmpty")
|
| | | return
|
| | | |
| | | if packPlayerID != curPlayer.GetID():
|
| | | #不是给自己的封包
|
| | | GameWorld.DebugLog("不是给自己的封包! packPlayerID=%s" % packPlayerID, curPlayer.GetPlayerID())
|
| | | DR_Team("OnTeam", teamID, dataDict, "packPlayerID != curPlayerID(%s)" % curPlayer.GetID())
|
| | | return
|
| | | |
| | | # 这个封包只处理teamID为0的情况, teamID不为0的情况在py包 GameServer_TeamInfo 处理
|
| | | if teamID:
|
| | | #GameWorld.DebugLog("OnTeam teamID=%s, 大于0不处理!" % teamID, curPlayer.GetPlayerID())
|
| | | return
|
| | | |
| | | GameWorld.DebugLog("OnTeam teamID=%s, 玩家无队伍更新!" % teamID, curPlayer.GetPlayerID())
|
| | | RefreshPlayerTeamID(curPlayer, teamID, teamLV, tick)
|
| | | return True
|
| | | #// 05 03 玩家离开队伍 #tagGMPlayerLeaveTeam
|
| | | #
|
| | | #struct tagGMPlayerLeaveTeam
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD PlayerID;
|
| | | # DWORD CopyMapID;
|
| | | # DWORD TeamID;
|
| | | #};
|
| | | def GameServer_PlayerLeaveTeam(curPackData, tick):
|
| | | playerID = curPackData.PlayerID
|
| | | copyMapID = curPackData.CopyMapID # 这里不依赖玩家来取copyMapID,防止找不到玩家导致无法正常管理分线队伍
|
| | | leaveTeamID = curPackData.TeamID
|
| | | GameWorld.DebugLog("GameServer_PlayerLeaveTeam playerID=%s,copyMapID=%s,leaveTeamID=%s" |
| | | % (playerID, copyMapID, leaveTeamID), playerID)
|
| | | __OnPlayerLeaveTeam(copyMapID, playerID, leaveTeamID, tick)
|
| | | return
|
| | |
|
| | | #// 05 02 队伍信息刷新 #tagGMTeamInfo
|
| | | #
|
| | |
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if not curPlayer or curPlayer.IsEmpty():
|
| | | DR_Team("TeamInfo", teamID, dataDict, "curPlayer is None or empty")
|
| | | return
|
| | | |
| | | playerTeamID = curPlayer.GetTeamID()
|
| | | # 切图时GameServer玩家无队伍时会同步teamID为0,这里进一步处理,防止地图玩家在某些异常情况下teamID与GameServer不同步
|
| | | if teamID == 0 and playerTeamID:
|
| | | __OnPlayerLeaveTeam(curPlayer.GetCopyMapID(), playerID, playerTeamID, tick)
|
| | | return
|
| | |
|
| | | RefreshPlayerTeamID(curPlayer, teamID, teamLV, tick)
|
| | |
| | | "playerTeamLV":playerTeamLV, "teamLV":teamLV}
|
| | | #--------------世界服务器组队表中无队伍
|
| | | if not teamID:
|
| | | if not playerTeamID and not curTeam:
|
| | | DR_Team("RefreshPlayerTeamID_Leave", teamID, dataDict, "not playerTeamID and not curTeam")
|
| | | #GameWorld.DebugLog(" 玩家无队伍,无需处理!", playerID)
|
| | | pass
|
| | | else:
|
| | | #GameWorld.DebugLog(" 玩家有队伍,处理玩家离队!", playerID)
|
| | | DR_Team("RefreshPlayerTeamID_Leave", teamID, dataDict)
|
| | | __OnLeaveTeam(curPlayer, tick)
|
| | | |
| | | RefreshTeamVIPBuff_OnNoTeam(curPlayer, tick)
|
| | | # 这里不再处理离开队伍
|
| | | return
|
| | |
|
| | | #--------------世界服务器组队表中有队伍
|
| | |
| | | else:
|
| | | dataDict["MemberCount"] = 0 if not curMapTeam else curMapTeam.GetMemberCount()
|
| | | DR_Team("RefreshPlayerTeamID_Update", teamID, dataDict)
|
| | | |
| | | return
|
| | |
|
| | |
|
| | | ## 玩家退出队伍
|
| | | # @param curPlayer 当前玩家
|
| | | # @param tick 当前时间
|
| | | # @return None
|
| | | # @remarks 函数详细说明.
|
| | | def __OnLeaveTeam(curPlayer, tick):
|
| | | curTeam = curPlayer.GetTeam()
|
| | | if curTeam:
|
| | | #玩家脱离队伍
|
| | | curTeam.DeleteMember(curPlayer.GetID())
|
| | | |
| | | #旧队伍无人,删除旧队伍
|
| | | if curTeam.GetMemberCount() == 0:
|
| | | GameWorld.GetTeamManager().DeleteTeam(curTeam.GetTeamID())
|
| | | |
| | | curPlayer.SetTeam(None)
|
| | | curPlayer.SetTeamID(0)
|
| | | curPlayer.SetTeamLV(0)
|
| | | __DelPlayerIDFromTeamPlayer(curPlayer.GetPlayerID(), False)
|
| | | |
| | | #改变镖车身上记录的主人信息
|
| | | #PlayerTruck.ChangeTruckNoteInfo(curPlayer)
|
| | | |
| | | #自己离开队伍, 删除自己的buff
|
| | | __CleanTeamEffect(curPlayer, tick)
|
| | | |
| | | #副本中,如果只有一个玩家,这个玩家离开组队,设置副本ID为0
|
| | | if GameWorld.GetMapCopyPlayerManager().GetPlayerCount() == 1 and GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.tmtTeam:
|
| | | curPlayer.SetCurrentFBProperty(0)
|
| | |
|
| | | return
|
| | |
|
| | |
| | | return
|
| | | return
|
| | |
|
| | | def __OnPlayerLeaveTeam(copyMapID, playerID, leaveTeamID, tick):
|
| | | GameWorld.DebugLog("__OnPlayerLeaveTeam copyMapID=%s, playerID=%s, leaveTeamID=%s" % (copyMapID, playerID, leaveTeamID))
|
| | | |
| | | # !!!队伍管理器在分线内的 需要获取分线的队伍管理器
|
| | | curGameWorld = IPY_GameWorld.IPY_GameWorld(copyMapID)
|
| | | curMapTeam = curGameWorld.GetTeamManager().FindTeam(leaveTeamID)
|
| | | if curMapTeam:
|
| | | #玩家脱离队伍
|
| | | curMapTeam.DeleteMember(playerID)
|
| | | #旧队伍无人,删除旧队伍
|
| | | if curMapTeam.GetMemberCount() == 0:
|
| | | curGameWorld.GetTeamManager().DeleteTeam(leaveTeamID)
|
| | | |
| | | __DelPlayerIDFromTeamPlayer(playerID, False)
|
| | | |
| | | dataDict = {"playerID":playerID, "copyMapID":copyMapID}
|
| | | ### =========================== 以下逻辑是玩家存在时才需要处理的 =================================
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if not curPlayer or curPlayer.IsEmpty():
|
| | | DR_Team("PlayerLeaveTeam", leaveTeamID, dataDict, "curPlayer is None or empty")
|
| | | return
|
| | | |
| | | playerTeamID = curPlayer.GetTeamID()
|
| | | playerCopyMapID = curPlayer.GetCopyMapID()
|
| | | curGameWorld = IPY_GameWorld.IPY_GameWorld(playerCopyMapID)
|
| | | |
| | | dataDict.update({"playerTeamID":playerTeamID, "playerCopyMapID":playerCopyMapID})
|
| | | DR_Team("PlayerLeaveTeam", leaveTeamID, dataDict)
|
| | | |
| | | # 处理玩家离队
|
| | | if playerTeamID == leaveTeamID:
|
| | | curPlayer.SetTeam(None)
|
| | | curPlayer.SetTeamID(0)
|
| | | curPlayer.SetTeamLV(0)
|
| | | |
| | | #自己离开队伍, 删除自己的buff
|
| | | __CleanTeamEffect(curPlayer, tick)
|
| | | |
| | | #副本中,如果只有一个玩家,这个玩家离开组队,设置副本ID为0
|
| | | if curGameWorld.GetMapCopyPlayerManager().GetPlayerCount() == 1 and GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.tmtTeam:
|
| | | curPlayer.SetCurrentFBProperty(0)
|
| | | |
| | | RefreshTeamVIPBuff_OnNoTeam(curPlayer, tick)
|
| | | return
|
| | |
|
| | | ## 清除组队buff
|
| | | # @param
|
| | | # @return None
|