From 10a2b69436a1ebb09fa49a339655e150bfda70a8 Mon Sep 17 00:00:00 2001 From: xdh <xiefantasy@qq.com> Date: 星期六, 13 四月 2019 17:16:54 +0800 Subject: [PATCH] 6457 新增GM命令 AddFairyEvent 事件ID 事件ID。。 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTeam.py | 218 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 132 insertions(+), 86 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTeam.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTeam.py index 3b60019..ccd03a4 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTeam.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTeam.py @@ -25,6 +25,7 @@ import ChConfig import SkillCommon import IPY_GameWorld +import DataRecordPack #import PlayerTruck import ShareDefine import SkillShell @@ -67,13 +68,13 @@ #玩家刚登录, 什么也不做, 等待GameServer刷新自己 return -## 游戏服务器刷新队伍(封包参数) -# @param index 玩家索引 -# @param tick 当前时间 -# @return None or True -# @remarks 函数详细说明. -def GameServer_OnTeam(index, tick): - GameWorld.GetPsycoFunc(__Func_GameServer_OnTeam)(index, tick) +def OnPlayerLoginCrossServer(curPlayer): + ## 登录跨服服务器处理 + + if curPlayer.GetTeamID(): + curPlayer.SetTeamID(0) + GameWorld.DebugLog("登录跨服服务器重置队伍ID!") + return ## 游戏服务器刷新队伍(封包参数) @@ -81,32 +82,31 @@ # @param tick 当前时间 # @return None or True # @remarks 函数详细说明. -def __Func_GameServer_OnTeam(index, tick): - curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) - if curPlayer == None: - GameWorld.Log("地图服务器寻找组队玩家失败index = "+str(index)) - return - - if curPlayer.IsEmpty(): - GameWorld.Log("地图服务器寻找组队玩家失败index = %d, 玩家为空"%index) - return - - recvPack = IPY_GameWorld.IPY_MTeamRefresh() - - if recvPack.GetPlayerID() != curPlayer.GetID(): - #不是给自己的封包 - GameWorld.DebugLog("不是给自己的封包! packPlayerID=%s" % recvPack.GetPlayerID(), curPlayer.GetPlayerID()) - return - - teamID = recvPack.GetTeamID() - # 这个封包只处理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, recvPack.GetTeamLV(), tick) - return True +def GameServer_OnTeam(index, tick): + '''废弃该逻辑,由0502、0503封包结合处理 + 废弃原因: + 因为当玩家有队伍时,加入别人的队伍,此时该玩家需要先退出队伍(OnTeam同步),再加入队伍(0502同步) + 而地图会先收到0502包,导致地图队伍管理出现异常,所以暂时废弃OnTeam + ''' + return + +#// 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 # @@ -130,13 +130,25 @@ playerID = curPackData.PlayerID teamID = curPackData.TeamID teamLV = curPackData.TeamLV + memCnt = curPackData.MemCnt + dataDict = {"playerID":playerID, "teamLV":teamLV} - GameWorld.DebugLog("GameServer_TeamInfo playerID=%s,teamID=%s,teamLV=%s" % (playerID, teamID, teamLV), playerID) + GameWorld.DebugLog("GameServer_TeamInfo playerID=%s,teamID=%s,teamLV=%s,memCnt=%s" % (playerID, teamID, teamLV, memCnt), playerID) 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: + if playerTeamID: + __OnPlayerLeaveTeam(curPlayer.GetCopyMapID(), playerID, playerTeamID, tick) return RefreshPlayerTeamID(curPlayer, teamID, teamLV, tick) + + curPlayer.SetDict(ChConfig.Def_PlayerKey_TeamMemCount, memCnt) sameMapMemCount = 0 # 同地图队员数 sameMapVIPLV = 0 # 同地图VIP加成等级 @@ -188,6 +200,17 @@ GameWorld.DebugLog("__AddTeamVIPBuff sameMapVIPLV=%s,isOK=%s" % (sameMapVIPLV, isOK), playerID) return +def RefreshTeamVIPBuff_OnNoTeam(curPlayer, tick): + ## 刷新队伍VIPbuff,注意该函数只能无队伍时触发 + sameMapVIPLV = 0 + playerVIPLV = curPlayer.GetVIPLv() + teamVIPBuffIpyData = PlayerVip.GetVipPrivilegeData(ChConfig.VIPPrivilege_TeamVIPBuff) + if teamVIPBuffIpyData and hasattr(teamVIPBuffIpyData, "GetVIP%d" % playerVIPLV) \ + and getattr(teamVIPBuffIpyData, "GetVIP%d" % playerVIPLV)(): + sameMapVIPLV += 1 + __RefreshTeamVIPBuff(curPlayer, sameMapVIPLV, tick) + return + ## 刷新玩家队伍ID # @param curPlayer 当前玩家 # @param teamID 队伍ID @@ -195,34 +218,27 @@ # @return None # @remarks 函数详细说明. def RefreshPlayerTeamID(curPlayer, teamID, teamLV, tick): - #playerID = curPlayer.GetPlayerID() + playerID = curPlayer.GetPlayerID() playerTeamID = curPlayer.GetTeamID() - #GameWorld.DebugLog("刷新玩家队伍信息: teamID=%s,playerTeamID=%s,teamLV=%s" % (teamID, playerTeamID, teamLV), playerID) + playerCopyMapID = curPlayer.GetCopyMapID() + playerTeamLV = curPlayer.GetTeamLV() + GameWorld.DebugLog("刷新玩家队伍信息: playerTeamID=%s,playerCopyMapID=%s,teamID=%s,teamLV=%s" + % (playerTeamID, playerCopyMapID, teamID, teamLV), playerID) curTeam = curPlayer.GetTeam() curPlayer.SetTeamID(teamID) curPlayer.SetTeamLV(teamLV) + + dataDict = {"playerID":playerID, "playerTeamID":playerTeamID, "playerCopyMapID":playerCopyMapID, + "playerTeamLV":playerTeamLV, "teamLV":teamLV} #--------------世界服务器组队表中无队伍 if not teamID: - if not playerTeamID and not curTeam: - #GameWorld.DebugLog(" 玩家无队伍,无需处理!", playerID) - pass - else: - #GameWorld.DebugLog(" 玩家有队伍,处理玩家离队!", playerID) - __OnLeaveTeam(curPlayer, tick) - - sameMapVIPLV = 0 - playerVIPLV = curPlayer.GetVIPLv() - teamVIPBuffIpyData = PlayerVip.GetVipPrivilegeData(ChConfig.VIPPrivilege_TeamVIPBuff) - if teamVIPBuffIpyData and hasattr(teamVIPBuffIpyData, "GetVIP%d" % playerVIPLV) \ - and getattr(teamVIPBuffIpyData, "GetVIP%d" % playerVIPLV)(): - sameMapVIPLV += 1 - __RefreshTeamVIPBuff(curPlayer, sameMapVIPLV, tick) + # 这里不再处理离开队伍 return #--------------世界服务器组队表中有队伍 # !!!队伍管理器在分线内的 需要获取分线的队伍管理器,不然队伍都是在1线创建 - curGameWorld = IPY_GameWorld.IPY_GameWorld(curPlayer.GetCopyMapID()) + curGameWorld = IPY_GameWorld.IPY_GameWorld(playerCopyMapID) curMapTeam = curGameWorld.GetTeamManager().FindTeam(teamID) if curMapTeam == None: @@ -231,44 +247,15 @@ if GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.fbtTeam: curPlayer.SetCurrentFBProperty(teamID) #curMapTeam.SetTeamType(recvPack.GetTeamType()) + DR_Team("RefreshPlayerTeamID_Create", teamID, dataDict) if playerTeamID != teamID or not curTeam: isNewTeam = playerTeamID != teamID # 切地图/上线时teamID可能不变,但是team为None #GameWorld.DebugLog(" 玩家当前无队伍,处理玩家进队!isNewTeam=%s" % isNewTeam, playerID) - __OnEnterTeam(curPlayer, curMapTeam, isNewTeam, tick) - - 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) + __OnEnterTeam(curPlayer, curMapTeam, isNewTeam, tick, dataDict) + else: + dataDict["MemberCount"] = 0 if not curMapTeam else curMapTeam.GetMemberCount() + DR_Team("RefreshPlayerTeamID_Update", teamID, dataDict) return @@ -277,11 +264,12 @@ # @param tick 当前时间 # @return None # @remarks 函数详细说明. -def __OnEnterTeam(curPlayer, curMapTeam, isNewTeam, tick): +def __OnEnterTeam(curPlayer, curMapTeam, isNewTeam, tick, dataDict): teamID = curMapTeam.GetTeamID() memCount = curMapTeam.GetMemberCount() if memCount >= ShareDefine.Def_Team_MaxPlayerCount: GameWorld.ErrLog("队伍人数已满,玩家入队失败!teamID=%s,memCount=%s" % (teamID, memCount), curPlayer.GetPlayerID()) + DR_Team("RefreshPlayerTeamID_EnterError", teamID, dataDict, "memCount(%s) >= %s" % (memCount, ShareDefine.Def_Team_MaxPlayerCount)) return #告诉GameServer自己的副本状态 @@ -291,6 +279,8 @@ curPlayer.SetTeam(curMapTeam) curPlayer.SetTeamID(teamID) curMapTeam.AddMember(curPlayer) + dataDict["MemberCount"] = curMapTeam.GetMemberCount() + DR_Team("RefreshPlayerTeamID_Enter", teamID, dataDict) playerID = curPlayer.GetPlayerID() teamPlayerIDList = PyGameData.g_teamPlayerDict.get(teamID, []) if playerID not in teamPlayerIDList: @@ -306,6 +296,51 @@ 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 @@ -343,6 +378,7 @@ #无队伍玩家,不处理 return + GameWorld.DebugLog("队伍成员离开地图: temaID=%s,isDisconnect=%s,copyMapID=%s" % (curTeam.GetTeamID(), isDisconnect, curPlayer.GetCopyMapID()), curPlayer.GetPlayerID()) __CleanTeamEffect(curPlayer, tick) #设定当前玩家队伍为None, 否则在玩家状态刷新的时候, 可能取到乱指针 curPlayer.SetTeam(None) @@ -351,13 +387,18 @@ teamID = curTeam.GetTeamID() playerID = curPlayer.GetPlayerID() + dataDict = {"playerID":playerID, "isDisconnect":isDisconnect, "playerCopyMapID":curPlayer.GetCopyMapID()} #如果队伍无人,MapServer中删除队伍 if curTeam.GetMemberCount() <= 1: GameWorld.GetTeamManager().DeleteTeam(teamID) + dataDict["MemberCount"] = 0 + dataDict["DeleteTeam"] = 1 else: #如果队伍还有其他人,离开队伍 curTeam.DeleteMember(playerID) + dataDict["MemberCount"] = curTeam.GetMemberCount() #GameWorld.Log("玩家下线 %d, 从队伍 %d 中删除玩家"%(curPlayer.GetPlayerID(), curTeam.GetTeamID())) + DR_Team("PlayerLeaveMap", teamID, dataDict) if not isDisconnect: __DelPlayerIDFromTeamPlayer(playerID, True) @@ -417,4 +458,9 @@ FBLogic.GameServer_LeaveFB(curPlayer, tick) return +def DR_Team(eventName, teamID, dataDict, info=""): + drDict = {"EventName":eventName, "TeamID":teamID, "Info":info} + drDict.update(dataDict) + DataRecordPack.SendEventPack("Team_%s" % GameWorld.GetMap().GetMapID(), drDict) + return -- Gitblit v1.8.0