From d8e5fed26a9e170f8a7f145428b2dd607f74e4fe Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 11 一月 2019 16:42:18 +0800
Subject: [PATCH] 2857 【BUG】【1.5】采集被打断问题 -  屏蔽无用代码

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py |  621 +++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 385 insertions(+), 236 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
index df300e4..d7dd489 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
@@ -78,6 +78,7 @@
 import GameLogic_TrialTower
 import GameLogic_FamilyWar
 import PlayerBossReborn
+import PlayerWeekParty
 import Operate_EquipWash
 import PlayerTreasure
 import GameLogic_GodArea
@@ -179,7 +180,8 @@
     #先发送所有任务, 再刷新日期, 否则会有2个相同的任务在玩家身上
     #把玩家当前的所有任务发送给客户端
     #GameWorld.Log('EventShell.NotifyAllQuestDetail')
-    EventShell.NotifyAllQuestDetail(curPlayer, True)
+    if not GameWorld.IsCrossServer():
+        EventShell.NotifyAllQuestDetail(curPlayer, True)
     
     #刷新人物日期状态
     #GameWorld.Log('PlayerEventCounter.UpdatePlayerLoginTime')
@@ -222,6 +224,128 @@
     
     return
 
+#// A1 08 刷新主服角色信息 #tagCMRefreshMainServerRole
+#
+#struct tagCMRefreshMainServerRole
+#{
+#    tagHead        Head;
+#};
+def OnRefreshMainServerRole(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    
+    Sync_DBPlayer(curPlayer)
+    
+    # 强刷一次属性,刷之前重置还没同步过所有属性
+    curPlayer.SetDict(ChConfig.Def_PlayerKey_NotifyAllAttrState, 0)
+    playerControl = PlayerControl.PlayerControl(curPlayer)
+    playerControl.ReCalcAllState()
+    
+    if PlayerControl.GetCrossMapID(curPlayer):
+        CrossRealmPlayer.DoExitCrossRealm(curPlayer)
+        
+    return
+
+def Sync_DBPlayer(curPlayer):
+    ## 同步DBPlayer信息,同0102封包
+    dbPlayer = ChPyNetSendPack.tagMCDBPlayer()
+    dbPlayer.AccID = curPlayer.GetAccID()
+    dbPlayer.PlayerID = curPlayer.GetPlayerID()
+    dbPlayer.PlayerName = curPlayer.GetPlayerName()
+    dbPlayer.AccState = curPlayer.GetAccState()
+    dbPlayer.GMLevel = curPlayer.GetGMLevel()
+    dbPlayer.Sex = curPlayer.GetSex()
+    dbPlayer.Job = curPlayer.GetJob()
+    dbPlayer.ReincarnationLv = curPlayer.GetReincarnationLv()
+    dbPlayer.LV = curPlayer.GetLV()
+    dbPlayer.LVEx = curPlayer.GetLVEx()
+    dbPlayer.LV2 = curPlayer.GetLV2()
+    dbPlayer.ExpPoint = curPlayer.GetExpPoint()
+    dbPlayer.TotalExp = curPlayer.GetTotalExp()
+    dbPlayer.Family = curPlayer.GetFamilyID()
+    dbPlayer.FamilyName = curPlayer.GetFamilyName()
+    dbPlayer.TeamHornor = curPlayer.GetTeamHornor()
+    dbPlayer.FamilyHornor = curPlayer.GetFamilyHornor()
+    dbPlayer.FamilyActiveValue = curPlayer.GetFamilyActiveValue()
+    dbPlayer.LastWeekFamilyActiveValue = curPlayer.GetLastWeekFamilyActiveValue()
+    dbPlayer.CountryHornor = curPlayer.GetCountryHornor()
+    dbPlayer.CountryLastWeekHornor = curPlayer.GetCountryLastWeekHornor()
+    dbPlayer.Mate = curPlayer.GetMate()
+    dbPlayer.Gold = curPlayer.GetGold()
+    dbPlayer.GoldPaper = curPlayer.GetGoldPaper()
+    dbPlayer.Silver = curPlayer.GetSilver()
+    dbPlayer.SilverPaper = curPlayer.GetSilverPaper()
+    dbPlayer.FightPoint = curPlayer.GetFightPoint()
+    dbPlayer.HappyPoint = curPlayer.GetHappyPoint()
+    dbPlayer.LineID = curPlayer.GetLineID()
+    dbPlayer.MapID = curPlayer.GetMapID() # 玩家身上的 GetMapID 返回的就是 GetDataMapID
+    dbPlayer.PosX = curPlayer.GetPosX()
+    dbPlayer.PosY = curPlayer.GetPosY()
+    dbPlayer.RebornMapID = curPlayer.GetRebornMapID()
+    dbPlayer.RebornPosX = curPlayer.GetRebornPosX()
+    dbPlayer.RebornPosY = curPlayer.GetRebornPosY()
+    dbPlayer.State = curPlayer.GetState()
+    dbPlayer.HP = curPlayer.GetHP()
+    dbPlayer.XP = curPlayer.GetXP()
+    dbPlayer.HPRestoreSetting = curPlayer.GetHPRestoreSetting()
+    dbPlayer.MPRestoreSetting = curPlayer.GetMPRestoreSetting()
+    dbPlayer.FreePoint = curPlayer.GetFreePoint()
+    dbPlayer.FreeSkillPoint = curPlayer.GetFreeSkillPoint()
+    dbPlayer.BaseSTR = curPlayer.GetBaseSTR()
+    dbPlayer.BasePNE = curPlayer.GetBasePNE()
+    dbPlayer.BasePHY = curPlayer.GetBasePHY()
+    dbPlayer.BaseCON = curPlayer.GetBaseCON()
+    dbPlayer.STR = curPlayer.GetSTR()
+    dbPlayer.PNE = curPlayer.GetPNE()
+    dbPlayer.PHY = curPlayer.GetPHY()
+    dbPlayer.CON = curPlayer.GetCON()
+    #dbPlayer.Setting = curPlayer.GetSetting() # 没有
+    dbPlayer.PKValue = curPlayer.GetPKValue()
+    #dbPlayer.ActiveValue = curPlayer.GetActiveValue() # 没有
+    dbPlayer.BackpackLV = curPlayer.GetBackpackLV()
+    dbPlayer.WarehouseLV = curPlayer.GetWarehouseLV()
+    dbPlayer.TeamID = curPlayer.GetTeamID()
+    dbPlayer.UseGoldType = curPlayer.GetUseGoldType()
+    dbPlayer.UseSilverType = curPlayer.GetUseSilverType()
+    dbPlayer.AttackMode = curPlayer.GetAttackMode()
+    dbPlayer.LastWeekOnlineTime = curPlayer.GetLastWeekOnlineTime()
+    dbPlayer.FBID = curPlayer.GetClientLineID()
+    dbPlayer.FamilyLV = curPlayer.GetFamilyLV()
+    dbPlayer.FriendFavor = curPlayer.GetFriendFavor()
+    dbPlayer.Energy = curPlayer.GetEnergy()
+    dbPlayer.EquipShowSwitch = curPlayer.GetEquipShowSwitch()
+    dbPlayer.LuckValue = curPlayer.GetLuckValue()
+    dbPlayer.ExAttr1 = curPlayer.GetExAttr1()
+    dbPlayer.ExAttr2 = curPlayer.GetExAttr2()
+    dbPlayer.ExAttr3 = curPlayer.GetExAttr3()
+    dbPlayer.ExAttr4 = curPlayer.GetExAttr4()
+    dbPlayer.ExAttr5 = curPlayer.GetExAttr5()
+    dbPlayer.Faction = curPlayer.GetFaction()
+    dbPlayer.InfamyValue = curPlayer.GetInfamyValue()
+    dbPlayer.OfficialRank = curPlayer.GetOfficialRank()
+    dbPlayer.ChangeCoinPointTotal = curPlayer.GetChangeCoinPointTotal()
+    dbPlayer.VIPLv = curPlayer.GetVIPLv()
+    dbPlayer.VIPLvForPhone = curPlayer.GetVIPLvForPhone()
+    dbPlayer.ExAttr6 = curPlayer.GetExAttr6()
+    dbPlayer.ExAttr7 = curPlayer.GetExAttr7()
+    dbPlayer.ExAttr8 = curPlayer.GetExAttr8()
+    dbPlayer.ExAttr9 = curPlayer.GetExAttr9()
+    dbPlayer.ExAttr10 = curPlayer.GetExAttr10()
+    dbPlayer.ModelMark = curPlayer.GetModelMark()
+    dbPlayer.ExAttr11 = curPlayer.GetExAttr11()
+    dbPlayer.ExAttr12 = curPlayer.GetExAttr12()
+    dbPlayer.ExAttr13 = curPlayer.GetExAttr13()
+    dbPlayer.ExAttr14 = curPlayer.GetExAttr14()
+    dbPlayer.OperateInfo = curPlayer.GetOperateInfo()
+    dbPlayer.Operate = curPlayer.GetOperate()
+    dbPlayer.ServerID = curPlayer.GetServerID()
+    dbPlayer.ExAttr15 = curPlayer.GetExAttr15()
+    dbPlayer.ExAttr16 = curPlayer.GetExAttr16()
+    dbPlayer.ExAttr17 = curPlayer.GetExAttr17()
+    dbPlayer.ExAttr18 = curPlayer.GetExAttr18()
+    dbPlayer.ExAttr19 = curPlayer.GetExAttr19()
+    dbPlayer.ExAttr20 = curPlayer.GetExAttr20()
+    NetPackCommon.SendFakePack(curPlayer, dbPlayer)
+    return
 
 #---------------------------------------------------------------------
 ##玩家登陆游戏逻辑处理
@@ -246,25 +370,54 @@
     if GameWorld.IsCrossServer():
         curPlayer.SetForbiddenSyncClientState(True)
     
-    SyncGuideState(curPlayer)
+    __DoPlayerLoginServer(curPlayer, tick)
     
+    # 屏蔽跨服下关闭和子服重复的数据的发送 pushsend接口, notifyall正常发送
+    # !!!必要发送的数据要注意位置
+    if GameWorld.IsCrossServer():
+        curPlayer.SetForbiddenSyncClientState(False)
+        PlayerControl.SetCrossMapID(curPlayer, curPlayer.GetMapID()) # 因为主服上传数据之前该值为0,所以登录跨服后在跨服服务器要设置为对应地图
+        
+    return
+
+def __DoPlayerLoginServer(curPlayer, tick):
+    ''' 玩家登录需要处理的内容,本服及跨服服务器分开
+    '''
+    
+    #设置上线时间
+    curPlayer.SetLoginTime(GameWorld.GetCurrentDataTimeStr())
     #初始化玩家背包
     InitPlayerPack(curPlayer)
+    #通知玩家物品信息
+    __Sync_PackDetel(curPlayer)
+    
+    if GameWorld.IsCrossServer():
+        SkillCommon.PlayerLoginMergeServerSkillLogic(curPlayer, tick)
+        # 重置所有技能CD
+        
+        DoPlayerLoginInMap(curPlayer, tick)
+        
+        DataRecordPack.DR_PlayerLogin(curPlayer)
+        EventReport.WriteEvent_login(curPlayer)
+        #---玩家上线, 宠物逻辑处理---
+        PetControl.DoLogic_PetInfo_OnLogin(curPlayer, tick)
+        
+        #通知运行成功
+        curPlayer.BalanceServer_PlayerLoginInitOK()
+        return
+    
+    SyncGuideState(curPlayer)
     
     #上线检查一次装备属性
     ItemControler.PlayerItemControler(curPlayer).CheckRolePackEquipAttr()
     #上线检查加点属性点
     PlayerControl.FixOldAddPoint(curPlayer)
-    #通知玩家物品信息
-    __Sync_PackDetel(curPlayer)
     
     #更新服务器组ID
     PlayerControl.UpdPlayerServerGroupID(curPlayer)
     
     #上线学习技能
     SkillCommon.PlayerLoginCheckLearnSkill(curPlayer)
-    
-    SkillCommon.PlayerLoginMergeServerSkillLogic(curPlayer, tick)
     
     #刷新技能CD
     SkillCommon.PlayerLoginUpdateSkillCD(curPlayer, tick)
@@ -285,12 +438,10 @@
     
     #初始化现实时间物品
     InitRealityTimeItem(curPlayer, tick)
-
+    
     #---刷新了玩家属性, 登陆只刷新一次,其他地方不用刷
     DoPlayerLoginInMap(curPlayer, tick)
     
-    #设置上线时间
-    curPlayer.SetLoginTime(GameWorld.GetCurrentDataTimeStr())
     #PlayerControl.SyncOnLineTimeTotal(curPlayer)
     #PlayerControl.SyncOnLineTimeLastOpenPack(curPlayer, IPY_GameWorld.rptItem)
     PlayerGodWeapon.OnLogin(curPlayer)
@@ -307,8 +458,8 @@
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_HighChangeLineID, 0)
         #GameWorld.DebugLog("离线超过10秒重置切线临时保存的相关记录值!leaveServerSecond=%s" % leaveServerSecond, curPlayer.GetPlayerID())
         # 离线过久恢复为非跨服状态
-        if PlayerControl.GetCrossRealmState(curPlayer):
-            PlayerControl.SetCrossRealmState(curPlayer, 0)
+        if PlayerControl.GetCrossMapID(curPlayer):
+            PlayerControl.SetCrossMapID(curPlayer, 0)
             
     # 合服首登处理
     __DoMixServerFirstLogin(curPlayer)
@@ -542,6 +693,8 @@
     PlayerFreeGoods.OnLogin(curPlayer)
     # BOSS复活活动
     PlayerBossReborn.OnLogin(curPlayer)
+    # 周狂欢活动
+    PlayerWeekParty.OnLogin(curPlayer)
     # 仙界盛典活动
     PlayerFairyCeremony.OnLogin(curPlayer)
     # 分支下载奖励记录通知
@@ -575,13 +728,6 @@
     # 如果被禁言的,上线同步前端
     if curPlayer.GetGMForbidenTalk():
         curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_ForbidenTalk, curPlayer.GetGMForbidenTalk(), False)
-        
-    # 屏蔽跨服下关闭和子服重复的数据的发送 pushsend接口, notifyall正常发送
-    # !!!必要发送的数据要注意位置
-    if GameWorld.IsCrossServer():
-        curPlayer.SetForbiddenSyncClientState(False)
-        PlayerControl.SetCrossRealmState(curPlayer, 1) # 因为主服上传数据之前该值为1,所以登录跨服后在跨服服务器要设置为1
-        
     return
 
 
@@ -862,7 +1008,10 @@
     SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, ChConfig.Def_SkillID_LimitSuperBuff, tick)
             
     #刷新玩家的视野
-    PlayerState.ChangePlayerSigh(curPlayer, tick)
+    if not GameWorld.IsCrossServer() and PlayerControl.GetCrossMapID(curPlayer):
+        GameWorld.DebugLog("===登录本服地图时,处于跨服状态,不刷新视野!", curPlayer.GetPlayerID())
+    else:
+        PlayerState.ChangePlayerSigh(curPlayer, tick)
     
     if GameWorld.IsCrossServer():
         curPlayer.SetForbiddenSyncClientState(False)
@@ -1213,8 +1362,11 @@
     firstMission = QuestCommon.GetCommonMission(curPlayer)
     if not (firstMission and firstMission.GetProperty(QuestCommon.Def_NewGuyNoSight) == 1):
         #刷新自己的视野
-        curPlayer.RefreshView()
-        curPlayer.SetVisible(True)
+        if not GameWorld.IsCrossServer() and PlayerControl.GetCrossMapID(curPlayer):
+            GameWorld.DebugLog("===本服LoadMapOK时玩家处于跨服状态,不设置可见!", curPlayer.GetPlayerID())
+        else:
+            curPlayer.RefreshView()
+            curPlayer.SetVisible(True)
     
     #如果玩家hp为0,设置玩家为死亡状态
     if curPlayer.GetHP() <= 0:
@@ -1367,9 +1519,6 @@
     
     PassiveBuffEffMng.OnLoadMapGFPassive(curPlayer)
     ItemControler.PlayerItemControler(curPlayer).RefreshStartEquipCount()   # 刷新装备珍品星级
-    
-    #最后处理下跨服
-    CrossRealmPlayer.OnLoadMapOK(curPlayer)
     
     #EndLoadMap需放在最后
     curPlayer.EndLoadMap()
@@ -2174,31 +2323,76 @@
     #根据玩家选择重生选项重生
     sendPack = IPY_GameWorld.IPY_CCliectReborn()
     #复活类型
-    playerRebornType = sendPack.GetType()
+    rebornType = sendPack.GetType()
+    GameWorld.DebugLog("玩家点击复活: rebornType=%s" % rebornType, curPlayer.GetPlayerID())
     
-    if curPlayer.GetHP() > 0:
-        # 当血量大于0收到复活请求包时,一般是前后端复活状态不一致的情况下导致的
-        # 由于前端需要根据复活状态判断复活界面相关逻辑,所以这里需要做一些特殊处理,防止某些情况下前后端复活状态不一致导致的一些异常问题
-        
-        # 后端非死亡状态的情况,补同步一次复活包给前端
-        if curPlayer.GetPlayerAction() != IPY_GameWorld.paDie:
-            SyncPlayerReborn(curPlayer, playerRebornType)
-        # 后端也是死亡状态的情况,直接重新触发一次复活
-        else:
-            PlayerRebornByType(curPlayer, playerRebornType, tick)
-        #生命值不为0 , 不能重生
-#        GameWorld.Log("玩家点击: 重生失败,生命值不为0 , 不能重生" , curPlayer.GetPlayerID())
+    if GameWorld.IsCrossServer():
+        GameWorld.DebugLog("跨服服务器不接受复活请求!")
+        return
+    
+    if PlayerControl.GetCrossMapID(curPlayer):
+        OnReqCrossServerReborn(curPlayer, rebornType)
         return
     
     #FB中禁止复活
-    if FBLogic.DoFBForbidReborn(curPlayer, playerRebornType):
+    if FBLogic.DoFBForbidReborn(curPlayer, rebornType):
         PlayerControl.NotifyCode(curPlayer, "Reborn_lhs_31379")
         return
     
     #玩家复活
-    if PlayerRebornByType(curPlayer, playerRebornType, tick):
+    if PlayerRebornByType(curPlayer, rebornType, tick):
         #玩家复活成功,判断是否在副本中复活
-        PlayerReborn_InFB(curPlayer, playerRebornType, tick)
+        PlayerReborn_InFB(curPlayer, rebornType, tick)
+        
+    return
+
+def OnReqCrossServerReborn(curPlayer, rebornType):
+    ## 请求跨服服务器复活玩家
+    
+    crossMapID = PlayerControl.GetCrossMapID(curPlayer)
+    if not crossMapID:
+        GameWorld.DebugLog("当前无跨服地图!")
+        return
+    
+    if not __CheckCanReborn(curPlayer, rebornType):
+        return
+    
+    msgDict = {"PlayerID":curPlayer.GetPlayerID(), "RebornType":rebornType}
+    GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_Reborn, msgDict)
+    GameWorld.DebugLog("跨服中请求复活, crossMapID=%s,msgDict=%s" % (crossMapID, msgDict), curPlayer.GetPlayerID())
+    return
+
+def ClientServerMsg_Reborn(curPlayer, msgData, serverGroupID, tick):
+    ## 收到子服请求复活信息
+    
+    rebornType = msgData["RebornType"]
+    gameMap = GameWorld.GetMap()
+    if not __CheckCanReborn(curPlayer, rebornType, gameMap):
+        return
+    
+    isAddReviveTired = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IsAddReviveTired)
+    # 跨服服务器不执行消耗,复活后同步消息回主服扣除消耗
+    __DoPlayerReborn(curPlayer, rebornType, tick)
+    
+    # 发送回本服复活结果
+    msgInfo = {"Result":1, "ReviveTired":isAddReviveTired}
+    msgInfo.update(msgData)
+    GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_RebornRet, msgInfo, [serverGroupID])
+    return
+
+def CrossServerMsg_RebornRet(curPlayer, msgData, tick):
+    ## 收到跨服服务器复活结果
+    
+    result = msgData["Result"]
+    if result != 1:
+        return
+    
+    rebornType = msgData["RebornType"]
+    isAddReviveTired = msgData["ReviveTired"]
+    __RebornCost(curPlayer, rebornType, True)
+    
+    if isAddReviveTired:
+        __AddReviveTired(curPlayer, tick)
         
     return
 
@@ -2513,7 +2707,8 @@
     #取消自动运镖状态
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_AutoTruck, 0)
     
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_RoomID, 0)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_CrossRegisterMap, 0)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_IsCrossPKMatching, 0)
     
     #下线召回宠物
     PetControl.ReCallFightPet(curPlayer)
@@ -3637,6 +3832,10 @@
         GameWorld.ErrLog("ChangeLine -> 封包错误, 无此线路 = %s" % (changLineID), curPlayer.GetID())
         return
     
+    if GameWorld.IsCrossServer():
+        # 跨服服务器无法切线
+        return
+    
     mapID = curPlayer.GetMapID()
     
     activityLineID = 0 # 活动线, 默认1线
@@ -3742,20 +3941,23 @@
 #    curPlayer.GameServer_LineState()
     return
 
-
-
-##获取死亡冷却时间
-#@param curPlayer 玩家实例
-#@param playerRebornType 复活类型
-#@return 死亡冷却时间
-def GetRebronTime(curPlayer, playerRebornType):
-    mapType = GameWorld.GetMap().GetMapFBType()
+def GetRebronTime(curPlayer, rebornType):
+    ''' 死亡状态才验证时间,本服跨服通用
+            跨服服务器死亡的复活也是先发到本服,正常情况下本服是活着的,无法验证
+            所以可否复活由跨服服务器死亡状态下的玩家实例判断,简单讲就是哪个服务器死亡的哪个服务器判断
+            所以该函数可以直接使用玩家所在的地图判断
+    '''
     
-    if playerRebornType in [ChConfig.rebornType_Health, ChConfig.rebornType_UseItem]:
-        #原地复活、道具复活不用CD
+    # 非死亡状态下,也就是哪个服务器角色死亡由哪个服务器判断
+    if curPlayer.GetHP() > 0 and curPlayer.GetPlayerAction() != IPY_GameWorld.paDie:
+        return 0
+    
+    # 回城复活的才需要CD
+    if rebornType not in [ChConfig.rebornType_City, ChConfig.rebornType_MainCity]:
         return 0
     
     # 副本地图CD
+    mapType = GameWorld.GetMap().GetMapFBType()
     if mapType != IPY_GameWorld.fbtNull:
         fbRebornTimeDict = IpyGameDataPY.GetFuncEvalCfg('DuplicatesRebornTime', 1)
         curMapID = GameWorld.GetMap().GetMapID()
@@ -3769,30 +3971,6 @@
             if findBuff.GetSkill().GetSkillLV() == findBuff.GetSkill().GetSkillMaxLV():
                 return IpyGameDataPY.GetFuncEvalCfg('RebornArguments', 1)[1]
     return 0
-    
-#    playerRebornTimeDict = ReadChConfig.GetEvalChConfig('PlayerRebornTime')
-#    
-#    curMapID = GameWorld.GetMap().GetMapID()
-#    
-#    #不在配表的地图ID中取默认的
-#    if curMapID not in playerRebornTimeDict.keys():
-#        curMapID = 0
-#    
-#    rebronTimeByTypeDict = playerRebornTimeDict.get(curMapID, {})
-#    
-#    if not rebronTimeByTypeDict:
-#        GameWorld.ErrLog("GetRebronTime rebronTimeByTypeDict=%s,,curMapID=%s" % 
-#                              (rebronTimeByTypeDict, curMapID))
-#        return 0
-#    
-#    #公式参数
-#    playerLV = curPlayer.GetLV()
-#    playerDeadCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_PlayerDeadCnt)
-#    
-#    rebornTime = int(eval(rebronTimeByTypeDict.get(playerRebornType, "0")))
-#    
-#    return rebornTime
-
 
 ## 死亡冷却时间是否完了
 #@param curPlayer 玩家实例
@@ -3808,116 +3986,90 @@
     
 
 #---------------------------------------------------------------------
-##自定义函数, 玩家复活
-#@param curPlayer 玩家实例
-#@param playerRebornType 复活类型
-#@param tick 时间戳
-#@param mapBornPlace 复活位置,默认0为原地
-#@return 返回值无意义
-#@remarks 自定义函数, 玩家复活
-def PlayerRebornByType(curPlayer, playerRebornType, tick, mapBornPlace=0, isAddSuperBuff=True):
-    curPlayerID = curPlayer.GetID()
-    curVipLv = curPlayer.GetVIPLv()
+
+def __CheckCanReborn(curPlayer, rebornType, gameMap=None):
+    ''' 检查可否复活,为了逻辑统一,这里不适用玩家所在的地图,支持跨服状态下判断跨服地图
+                本函数不验证玩家死亡状态等,因为有可能前后端复活状态不一致,如果这里拦住可能导致前端躺尸复活不了
+    '''
     
-    gameMap = GameWorld.GetMap()
+    if rebornType not in ChConfig.Def_RebornTypeList:
+        return
     
-    #需要支付的银子数量 
-    moneyPrice = 0
-    #复活恢复血量、魔的万分比
-    resetHpPercent = ChConfig.Def_MaxRateValue
-    resetMpPercent = ChConfig.Def_MaxRateValue
+    ## 由于本服及跨服地图数据不互通,所以这里根据是否有地图数据进行判断处理
+    if gameMap:
+        playerID = curPlayer.GetPlayerID()
+        if rebornType in [ChConfig.rebornType_Health, ChConfig.rebornType_UseItem] and not gameMap.GetLocalReborn():
+            GameWorld.ErrLog("该地图不可原地复活! mapID=%s,rebornType=%s" % (gameMap.GetMapID(), rebornType), curPlayer.GetPlayerID())
+            return
         
-    #复活冷却时间(秒)
-    rebornTime = GetRebronTime(curPlayer, playerRebornType)    
-    #冷却时间到了
-    if playerRebornType != ChConfig.rebornType_System and not CanRebornByTimeOver(curPlayer, rebornTime):
-        PlayerControl.NotifyCode(curPlayer, 'RebornCD')
-        return False
+    # 验证复活CD
+    rebornCD = GetRebronTime(curPlayer, rebornType)
+    if rebornCD:
+        curTime = int(time.time())
+        deadTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_DeadTime)
+        if curTime - deadTime < rebornCD:
+            PlayerControl.NotifyCode(curPlayer, "RebornCD")
+            GameWorld.Log("复活冷却时间中,无法复活! curTime(%s) - deadTime(%s) < rebornCD(%s)" % (curTime, deadTime, rebornCD), playerID)
+            return
+        
+    # 验证复活消耗,在本服验证,跨服服务器只验证状态
+    if not GameWorld.IsCrossServer():
+        if not __RebornCost(curPlayer, rebornType, False):
+            return
+        
+    return True
+
+def __RebornCost(curPlayer, rebornType, isDoCost):
+    ## 扣除复活消耗
+    # @param isDoCost: 是否执行消耗
+    playerID = curPlayer.GetPlayerID()
+    if rebornType == ChConfig.rebornType_Health:
+        rebornCfg = IpyGameDataPY.GetFuncEvalCfg('RebornArguments', 1)
+        moneyPrice = rebornCfg[2]
+        costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, moneyPrice)
+        if not costMoneyList:
+            GameWorld.ErrLog("货币不足,无法原地复活! moneyPrice=%s" % (moneyPrice), playerID)
+            return
+        
+        if isDoCost:
+            for moneyType, moneyCnt in costMoneyList:
+                if not PlayerControl.PayMoney(curPlayer, moneyType, moneyCnt, ChConfig.Def_Cost_Revive):
+                    return
+                
+    elif rebornType == ChConfig.rebornType_UseItem:
+        rebornItem = ItemCommon.FindItemInPackByEffectEx(curPlayer, ChConfig.Def_Effect_Reborn)
+        if not rebornItem:
+            GameWorld.ErrLog("复活道具不足,无法原地复活! ", playerID)                
+            return
+        
+        if isDoCost:
+            ItemCommon.DelItem(curPlayer, rebornItem, 1, True, "Reborn")
+            
+    return True
+
+def __DoPlayerReborn(curPlayer, rebornType, tick, mapBornPlace=0, isAddSuperBuff=True):
+    ## 执行玩家复活逻辑,该函数没有执行验证是否可复活等,不可直接调用
     
+    if curPlayer.GetHP() > 0 and curPlayer.GetPlayerAction() != IPY_GameWorld.paDie:
+        # 当血量大于0收到复活请求时,一般是前后端复活状态不一致的情况下导致的
+        # 由于前端需要根据复活状态判断复活界面相关逻辑,所以这里需要做一些特殊处理,防止某些情况下前后端复活状态不一致导致的一些异常问题
+        # 后端非死亡状态的情况,补同步一次复活包给前端
+        SyncPlayerReborn(curPlayer, rebornType)
+        return
+    
+    resetHpPercent = ChConfig.Def_MaxRateValue
     isFBReborn = False
-    #-----------------------------------------回城复活(切换地图)-----------------------------------
-    if playerRebornType == ChConfig.rebornType_City:
+    if rebornType == ChConfig.rebornType_City:
         if FBLogic.OnPlayerReborn():
             isFBReborn = True
         else:
             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IsReBorn, 1)
-        
-#===============================================================================
-#        #不在特殊的地图中,玩家副本中复活相关
-#        if not FBLogic.OnPlayerReborn():
-#            #输出系统提示
-#            __NotifyReBornToPlace( curPlayer )
-#===============================================================================
-
-    
-    #----------------------------------------------其他复活(不切换地图)------------------------------------
-    #技能复活
-    elif playerRebornType == ChConfig.rebornType_Skill:
-
-        if not gameMap.GetSkillReborn():
-            return False
-        
-        reBornSkill =  GameWorld.GetGameData().GetSkillBySkillID(ChConfig.Def_SkillID_SkillReBorn)
-        #恢复血量万分比
-        resetHpPercent = reBornSkill.GetEffect(1).GetEffectValue(0)
-        #恢复魔万分比
-        resetMpPercent = reBornSkill.GetEffect(2).GetEffectValue(0)
-        
-        BuffSkill.DelBuffBySkillID(curPlayer, ChConfig.Def_SkillID_SkillReBorn, tick)
-    
-    #原地健康复活
-    elif playerRebornType == ChConfig.rebornType_Health:
-        #if not PlayerVip.GetVipCanOriginalReborn(curVipLv):
-        #    #vip等级限制
-        #    return
-        if not gameMap.GetLocalReborn():
-            GameWorld.DebugLog('    地图配置不能原地复活')
-            return False
-        
-        if not __HealthRebornPayMoney(curPlayer):
-            return False
-        
-    #使用道具(还阳咒)复活
-    elif playerRebornType == ChConfig.rebornType_UseItem:
-
-        if not gameMap.GetLocalReborn():
-            return False
-        
-        if not __RebornDelItem(curPlayer):
-            return False
-    
-    # 副本复活
-    elif playerRebornType in [ChConfig.rebornType_FBGold, ChConfig.rebornType_FBUseItem]:
-        isFBReborn = True
-        freeBorn = FBLogic.DecFreeRebornCount(curPlayer)
-        if not freeBorn:
-            if not gameMap.GetLocalReborn():
-                return False
             
-            if playerRebornType == ChConfig.rebornType_FBGold:
-                #if not PlayerVip.GetVipCanOriginalReborn(curVipLv):
-                #    #vip等级限制
-                #    return False
-                
-                if not __HealthRebornPayMoney(curPlayer):
-                    return False
-                
-            elif playerRebornType == ChConfig.rebornType_FBUseItem:
-                if not __RebornDelItem(curPlayer):
-                    return False
-    elif playerRebornType == ChConfig.rebornType_MainCity:
+    elif rebornType == ChConfig.rebornType_MainCity:
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IsReBorn, 2)
-
-    elif playerRebornType == ChConfig.rebornType_System:
-        pass
-    
-    else:
-        #封包错误
-#        GameWorld.Log("重生封包类型 = %s错误"%(playerRebornType), curPlayerID )
-        return False
-    
+        
     #通知客户端玩家复活成功
-    curPlayer.Reborn(playerRebornType)
+    curPlayer.Reborn(rebornType)
     
     #执行玩家副本复活
     if isFBReborn:
@@ -3928,16 +4080,8 @@
         SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer , ChConfig.Def_SkillID_LimitSuperBuff, tick)
     #复活疲劳BUff
     if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_IsAddReviveTired):
-        findBuff = SkillCommon.FindBuffByID(curPlayer, ChConfig.Def_SkillID_ReviveTired)[0]
-        if findBuff:
-            buffSkillLV = findBuff.GetSkill().GetSkillLV()
-            if findBuff.GetSkill().GetSkillMaxLV() != buffSkillLV:
-                buffSkillLV = buffSkillLV + 1
-        else:
-            buffSkillLV = 1
-        SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer , ChConfig.Def_SkillID_ReviveTired, tick, buffSkillLV)
-        GameWorld.DebugLog('    复活疲劳BUff buffSkillLV=%s'%(buffSkillLV))
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IsAddReviveTired,0)
+        __AddReviveTired(curPlayer, tick)
+        
     #复活后清除角色身上的打BOSS和PK状态
     validTime = IpyGameDataPY.GetFuncCfg("PKConfig", 4) * 1000
     if PlayerState.IsInPKState(curPlayer):
@@ -3956,15 +4100,16 @@
     PlayerControl.SetProDef(curPlayer, PlayerControl.GetMaxProDef(curPlayer))
     
     #玩家复活后副本处理
-    FBLogic.OnPlayerRebornOver(curPlayer, playerRebornType)
-        
+    FBLogic.OnPlayerRebornOver(curPlayer, rebornType)
+    
+    gameMap = GameWorld.GetMap()
     #障碍点中原地复活, 打回重生点
-    if (playerRebornType == ChConfig.rebornType_City and not isFBReborn)\
-    or not GameWorld.GetMap().CanMove(curPlayer.GetPosX(), curPlayer.GetPosY()) \
-    or (playerRebornType == ChConfig.rebornType_MainCity and gameMap.GetRebornMapID() == curPlayer.GetMapID()):
+    if (rebornType == ChConfig.rebornType_City and not isFBReborn) \
+        or not GameWorld.GetMap().CanMove(curPlayer.GetPosX(), curPlayer.GetPosY()) \
+        or (rebornType == ChConfig.rebornType_MainCity and gameMap.GetRebornMapID() == curPlayer.GetMapID()):
         #玩家切换到重生点
         playerControl.SetToBornPlace()        
-    elif playerRebornType == ChConfig.rebornType_MainCity:
+    elif rebornType == ChConfig.rebornType_MainCity:
         #直接取db中配置的复活点
         PlayerControl.PlayerResetWorldPos(curPlayer, gameMap.GetRebornMapID(), gameMap.GetRebornMapX(), gameMap.GetRebornMapY(), False)
     #重新召唤宠物
@@ -3972,57 +4117,38 @@
     
     #复活成功,重置状态
     PlayerControl.ChangePlayerAction(curPlayer, IPY_GameWorld.paNull)
-    return True
+    return
 
-##复活扣除元宝
-#@param curPlayer 玩家实例
-#@return 是否扣除成功
-def __HealthRebornPayMoney(curPlayer):
-    rebornCfg = IpyGameDataPY.GetFuncEvalCfg('RebornArguments', 1)
-    moneyPrice = rebornCfg[2]
-    #异常
-    if not moneyPrice:
-        return True
-    costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, moneyPrice)
-    if not costMoneyList:
-        return False
-    infoDict = {}
-    for moneyType, moneyCnt in costMoneyList:
-        if not PlayerControl.PayMoney(curPlayer, moneyType, moneyCnt, ChConfig.Def_Cost_Revive, infoDict):
-            return False
+def __AddReviveTired(curPlayer, tick):
+    ## 增加复活疲劳
+    findBuff = SkillCommon.FindBuffByID(curPlayer, ChConfig.Def_SkillID_ReviveTired)[0]
+    if findBuff:
+        buffSkillLV = findBuff.GetSkill().GetSkillLV()
+        if findBuff.GetSkill().GetSkillMaxLV() != buffSkillLV:
+            buffSkillLV = buffSkillLV + 1
+    else:
+        buffSkillLV = 1
+    SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer , ChConfig.Def_SkillID_ReviveTired, tick, buffSkillLV)
+    GameWorld.DebugLog('    复活疲劳BUff buffSkillLV=%s'%(buffSkillLV))
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_IsAddReviveTired,0)    
+    return
+
+def PlayerRebornByType(curPlayer, rebornType, tick, mapBornPlace=0, isAddSuperBuff=True):
+    ''' 玩家复活
+    '''
+    gameMap = GameWorld.GetMap()
+    if not __CheckCanReborn(curPlayer, rebornType, gameMap):
+        return
     
-    GameWorld.Login_Interface_GoldRec(curPlayer , 0 , 0 , 'HealthReborn' , moneyType , moneyPrice)
+    if not GameWorld.IsCrossServer():
+        if not __RebornCost(curPlayer, rebornType, True):
+            return
+        
+    __DoPlayerReborn(curPlayer, rebornType, tick, mapBornPlace, isAddSuperBuff)
     return True
-
-##复活扣除道具
-#@param curPlayer 玩家实例
-#@return 是否扣除成功
-def __RebornDelItem(curPlayer):
-    rebornItem = ItemCommon.FindItemInPackByEffectEx(curPlayer, ChConfig.Def_Effect_Reborn)
-    if not rebornItem:
-        #GeRen_chenxin_143504 对不起,您没有XXX!
-        #PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_143504", [ChConfig.Def_ItemID_Reborn])
-        return False
-            
-    #调用通用接口删除道具
-    ItemCommon.DelItem(curPlayer, rebornItem, 1, True, "Reborn")
-    return True
-
 
 #---------------------------------------------------------------------
-#===============================================================================
-# def __NotifyReBornToPlace( curPlayer ):
-#    #普通地图
-#    if GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.fbtNull:
-#        #Revival_Home   <n color="0,255,0">提示:您可以在各大主城的杂货店消除身上携带的虚弱状态!</n>  256 -
-#        PlayerControl.NotifyCode( curPlayer, "Revival_Home" )
-#    #副本中
-#    elif not FBLogic.DoNotifyReBorn( curPlayer ):
-#        #输出默认提示
-#        PlayerControl.NotifyCode( curPlayer, "Revival_Home" )
-#    
-#    return
-#===============================================================================
+
 ##副本接口:玩家复活
 #@param curPlayer 玩家实例
 #@param tick 时间戳
@@ -4275,6 +4401,18 @@
 #---------------------------------------------------------------------
 
 #---------------------------------------------------------------------
+#// C1 05 进入跨服地图 #tagCMEnterCrossServer
+#
+#struct    tagCMEnterCrossServer
+#{
+#    tagHead        Head;
+#    DWORD        DataMapID;
+#};
+def OnEnterCrossServer(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    PlayerControl.PlayerEnterCrossServer(curPlayer, clientData.DataMapID)
+    return
+    
 #===============================================================================
 # //03 21 进入副本活动#tagCEnterFbGameEvent
 # tagCEnterFbGameEvent       *   GettagCEnterFbGameEvent();
@@ -4527,6 +4665,11 @@
     GameWorld.DebugLog("WorldTransPort packTransportType=%s,mapID=%s,lineID=%s,exData1=%s" 
                        % (packTransportType, mapID, lineID, exData1), playerID)
     lineID = -1 if lineID == 255 else lineID
+    if GameWorld.IsCrossServer():
+        if curPlayer.GetMapID() != mapID:
+            return
+        lineID = -1 # 跨服默认只能本线
+        
     #世界传送封包允许类型(世界,大地图,任务)
     if packTransportType not in ChConfig.Def_PackType_TransportType.keys():
         GameWorld.ErrLog('WorldTransPort packTransportType = %s, NoFind' % (packTransportType), playerID)
@@ -5154,7 +5297,13 @@
     # 冰晶矿脉星级奖励
     elif rewardType == ChConfig.Def_RewardType_IceLodeStar:
         GameLogic_IceLode.GetIceLodeStarAward(curPlayer, dataEx)
-        
+    # 领取周狂欢活动奖励
+    elif rewardType == ChConfig.Def_RewardType_WeekPartyAct:
+        PlayerWeekParty.GetWeekPartyActionAward(curPlayer, dataEx, dataExStr)
+    # 领取周狂欢积分奖励
+    elif rewardType == ChConfig.Def_RewardType_WeekPartyPoint:
+        PlayerWeekParty.GetWeekPartyPointAward(curPlayer, dataEx, dataExStr)
+    
     return
     
     

--
Gitblit v1.8.0