From 090d09182710271a2b55ccdb14a7576db09ec912 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 27 十二月 2018 15:43:19 +0800
Subject: [PATCH] 5424 【后端】【1.4】跨服竞技场开发 上次匹配战斗未结算时,不能再发起匹配; 跨服增加验证登录玩家PK房间号合法性; 支持主动退出对战副本直接结算;

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py |   52 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
index 58401ad..f560d96 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
@@ -733,10 +733,38 @@
         
     # 跨服登录处理
     else:
-        # 比如验证房间ID是否合法
-        pass
-    
+        mapID = curPlayer.GetMapID()
+        mapIDList = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch", 4)
+        if mapID not in mapIDList:
+            return
+        
+        GameWorld.Log("玩家登录跨服PK地图, mapID=%s" % mapID, curPlayer.GetPlayerID())
+        if not __CheckCanLoginCrossServerPKMap(curPlayer):
+            CrossRealmPlayer.PlayerExitCrossServer(curPlayer)
+            return
+        
     return
+
+def __CheckCanLoginCrossServerPKMap(curPlayer):
+    # 检查玩家可否登录跨服PK房间
+    
+    playerID = curPlayer.GetPlayerID()
+    vsRoomID = curPlayer.GetVsRoomId()
+    if not vsRoomID:
+        GameWorld.ErrLog("玩家没有对战房间ID,不可进入对战地图! 强制踢出跨服服务器!", playerID)
+        return False
+    
+    if vsRoomID not in PyGameData.g_crossPKRoomDict:
+        GameWorld.ErrLog("玩家对战房间ID已经不存在,不可进入对战地图! 强制踢出跨服服务器!vsRoomID=%s" % vsRoomID, playerID)
+        return False
+    
+    vsRoom = PyGameData.g_crossPKRoomDict[vsRoomID]
+    if playerID not in vsRoom.roomPlayerIDList:
+        GameWorld.ErrLog("玩家对战房间ID不存在该玩家ID,不可进入对战地图! 强制踢出跨服服务器!vsRoomID=%s,roomPlayerIDList=%s" 
+                         % (vsRoomID, vsRoom.roomPlayerIDList), playerID)
+        return False
+    
+    return True
 
 ## 玩家离线处理
 def OnLeaveServer(curPlayer):    
@@ -810,14 +838,14 @@
     ondayScore = playerInfoDict["ondayScore"] # 过天时的积分
     
     zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(pkZoneID, [])
-#    if playerID in zoneMatchPlayerList:
-#        GameWorld.Log("玩家正在匹配中,无法重复发起匹配!playerID=%s,accID=%s" % (playerID, accID))
-#        CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 1], [serverGroupID])
-#        return
-#    if playerID in PyGameData.g_crossPKPlayerDict:
-#        GameWorld.Log("玩家正在战斗中,无法重复发起匹配!playerID=%s,accID=%s" % (playerID, accID))
-#        CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, -2], [serverGroupID])
-#        return
+    if playerID in zoneMatchPlayerList:
+        GameWorld.Log("玩家正在匹配中,无法重复发起匹配!playerID=%s,accID=%s" % (playerID, accID))
+        CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 1], [serverGroupID])
+        return
+    if playerID in PyGameData.g_crossPKPlayerDict:
+        GameWorld.Log("玩家正在战斗中,无法重复发起匹配!playerID=%s,accID=%s" % (playerID, accID))
+        CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, -2], [serverGroupID])
+        return
     
     pkPlayer = CrossPKPlayer()
     pkPlayer.accID = accID
@@ -1624,6 +1652,7 @@
             PyGameData.g_crossPKUnNotifyOverInfo[playerID] = sendMapOverInfo
             continue
         
+        PlayerControl.SetVsRoomId(player, 0)
         sysMsg = str(sendMapOverInfo)
         player.MapServer_QueryPlayerResult(0, 0, "CrossPKOverInfo", sysMsg, len(sysMsg))
         GameWorld.Log("通知地图跨服PK结算: roomID=%s,zoneID=%s,seasonID=%s,timeStr=%s,overType=%s,winnerID=%s,roundWinnerIDList=%s, pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s,notifyState=%s,mapID=%s" 
@@ -1636,6 +1665,7 @@
         return
     overInfo = PyGameData.g_crossPKUnNotifyOverInfo.pop(playerID)
     PlayerControl.SetCrossRealmState(curPlayer, 0)
+    PlayerControl.SetVsRoomId(curPlayer, 0)
     sysMsg = str(overInfo)
     curPlayer.MapServer_QueryPlayerResult(0, 0, "CrossPKOverInfo", sysMsg, len(sysMsg))
     GameWorld.Log("玩家上线通知地图未结算的跨服PK结算: mapID=%s,overInfo=%s" % (curPlayer.GetMapID(), overInfo), playerID)

--
Gitblit v1.8.0