From 7311a1f98dccf5b66e30faafd9ef9b6b0b661e23 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 14 八月 2018 17:01:21 +0800
Subject: [PATCH] Fix: 1536 【BUG】娲皇遗迹层数进入错误;               瞬间同时退出时可能导致该bug,修改为按最后一个退出的方式判断;

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ExitFB.py              |   12 +++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py                      |    1 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py |   42 +++++++++++++++-----
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py            |    6 ++
 4 files changed, 48 insertions(+), 13 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ExitFB.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ExitFB.py
index 5f2ec53..3789b02 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ExitFB.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ExitFB.py
@@ -24,6 +24,16 @@
 #  @return None
 #  @remarks 函数详细说明.
 def OnExec(curPlayer, paramList):
-    ChPlayer.__Func_ExitFB(curPlayer, GameWorld.GetGameWorld().GetTick())
+    tick = GameWorld.GetGameWorld().GetTick()
+    isAll = paramList[0] if paramList else 0
+    if isAll:
+        copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
+        for i in xrange(copyMapPlayerManager.GetPlayerCount()):
+            player = copyMapPlayerManager.GetPlayerByIndex(i)
+            if player == None or player.IsEmpty():
+                continue
+            ChPlayer.__Func_ExitFB(player, tick)
+        return
+    ChPlayer.__Func_ExitFB(curPlayer, tick)
     return
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py
index e31eba8..b399c4a 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/GameWorldProcess.py
@@ -311,15 +311,35 @@
         return
     
     gameFB = GameWorld.GetGameFB()
-    logOffTick = gameFB.GetPlayerLogoffTick()
+    fbIndex = gameWorld.GetCurGameWorldIndex()
+    if fbIndex in PyGameData.g_lastExitFBType:
+        '''老模式根据 GetPlayerLogoffTick()、GetIsSafeClose()判断的话在某些情况下会有隐藏bug
+                            因为当副本中玩家同时退出时可能出现  GameWorld.GetMapCopyPlayerManager().GetPlayerCount() != 1 的情况
+                            所以老逻辑存在副本无法关闭的bug,这里只使用新模式,老模式暂不做修改,仅做兼容后备处理
+        '''
+        exitFBType, exitTick = PyGameData.g_lastExitFBType[fbIndex]
+        if exitFBType == 1:
+            passTick = tick - exitTick
+            if passTick < ChConfig.Def_EmptyFBKeepTime:
+                #GameWorld.DebugLog("最后一个玩家离线退出的,副本保护中!tick=%s,exitTick=%s,passTick=%s" 
+                #                   % (tick, exitTick, passTick), fbIndex)
+                return
+            #GameWorld.DebugLog("最后一个玩家离线退出的,副本保护超时,关闭副本!tick=%s,exitTick=%s,passTick=%s" 
+            #                   % (tick, exitTick, passTick), fbIndex)
+        #else:
+        #    GameWorld.DebugLog("最后一个玩家主动退出的,直接关闭副本!", fbIndex)
+        PyGameData.g_lastExitFBType.pop(fbIndex)
+        #GameWorld.DebugLog("PyGameData.g_lastExitFBType=%s" % PyGameData.g_lastExitFBType, fbIndex)
+    else:
+        logOffTick = gameFB.GetPlayerLogoffTick()
 
-    if logOffTick == 0:
-        return
-
-    if (not gameFB.GetIsSafeClose()) and tick - logOffTick < ChConfig.Def_EmptyFBKeepTime:
-        #GameWorld.Log(str(tick - logOffTick))
-        #不是安全断线的情况下, 返回
-        return
+        if logOffTick == 0:
+            return
+    
+        if (not gameFB.GetIsSafeClose()) and tick - logOffTick < ChConfig.Def_EmptyFBKeepTime:
+            #GameWorld.Log(str(tick - logOffTick))
+            #不是安全断线的情况下, 返回
+            return
 
     #输出调试信息
     GameWorld.Log('__ProcessClose! LineID = %s, openState = %s, isSafeClose = %s'%(
@@ -452,11 +472,11 @@
     
     __ProcessOpen(gameWorld, tick)
     
-    __ProcessTimeKickPlayer(gameWorld, tick)
+    __ProcessTimeKickPlayer(gameWorld, tick) # 处理副本生存周期强关副本
     
-    __ProcessFBDelayKickPlayer(gameWorld, tick)
+    __ProcessFBDelayKickPlayer(gameWorld, tick) # 关闭副本延迟踢出玩家
     
-    __ProcessClose(gameWorld, tick)
+    __ProcessClose(gameWorld, tick) # 自伸缩副本关闭逻辑
     
     __ProcessMapServerAcPlayer(tick)
     
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
index 6c82da8..d8a9525 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
@@ -1160,8 +1160,12 @@
 #    3. 如果没有玩家存在, 副本回收
     if GameWorld.GetMap().GetMapFBType() != 0:
         #离开副本
+        fbIndex = GameWorld.GetGameWorld().GetCurGameWorldIndex()
+        exitFBType = 1 if isDisconnect else 2
+        PyGameData.g_lastExitFBType[fbIndex] = [exitFBType, tick]
+        #GameWorld.DebugLog("玩家离开副本:fbIndex=%s,exitFBType=%s, %s" % (fbIndex, exitFBType, PyGameData.g_lastExitFBType), curPlayer.GetPlayerID())
         FBLogic.DoExitFBLogic(curPlayer, tick)
-
+        
     GameLogic_ManorWar.DoExitFB(curPlayer, tick)
     
     #清空所有不属于自己的光环
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
index ac11085..37e353b 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameData.py
@@ -29,6 +29,7 @@
 g_teamPlayerDict = {} # 地图队伍对应玩家ID列表,含离线玩家 {teamID:[playerID, ...], ...}
 
 g_disconnectPlayer = {} # 在本地图离线的玩家信息 {playerID:[tick, posX, posY], ...}
+g_lastExitFBType = {} # 最后一个离开副本信息 {fbIndex:[exitType, tick], ...} exitType: 1-掉线,2-主动退出
 
 g_sgzztopPlayerName = '' #上古战场积分王名字
 

--
Gitblit v1.8.0