Merge branch 'master' of http://192.168.0.87:10010/r/SnxxServerCode
 
	
	
	
	
	
	
	
	
	
	
	
	
	
 |  |  | 
 |  |  |         
 | 
 |  |  |     # 跨服登录处理
 | 
 |  |  |     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):    
 | 
 |  |  | 
 |  |  |     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
 | 
 |  |  | 
 |  |  |             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" 
 | 
 |  |  | 
 |  |  |         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)
 | 
 
 |  |  | 
 |  |  | import PlayerControl
 | 
 |  |  | import PlayerViewCache
 | 
 |  |  | import ChPyNetSendPack
 | 
 |  |  | import IPY_PlayerDefine
 | 
 |  |  | import NetPackCommon
 | 
 |  |  | import PyGameData
 | 
 |  |  | 
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  |     return (nameFormat%{"opname":opName, "sid":GameWorld.GetPlayerServerID(curPlayer)}).decode('gbk').encode(GameWorld.GetCharacterEncoding()) + playerName
 | 
 |  |  | 
 | 
 |  |  | def PlayerExitCrossServer(curPlayer):
 | 
 |  |  |     ## 玩家退出跨服服务器
 | 
 |  |  |      | 
 |  |  |     # 通知子服玩家退出跨服服务器
 | 
 |  |  |     playerID = curPlayer.GetPlayerID()
 | 
 |  |  |     serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
 | 
 |  |  |     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ExitCrossServer, playerID, [serverGroupID])
 | 
 |  |  |      | 
 |  |  |     # 设置非跨服状态,踢下线
 | 
 |  |  |     PlayerControl.SetCrossRealmState(curPlayer, 0)
 | 
 |  |  |     curPlayer.Kick(0)
 | 
 |  |  |     GameWorld.Log("PlayerExitCrossServer...serverGroupID=%s" % serverGroupID, playerID)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def CrossServerMsg_ExitCrossServer(msgData):
 | 
 |  |  |     ## 收到跨服服务器同步的玩家退出跨服服务器
 | 
 |  |  |     playerID = msgData
 | 
 |  |  |     GameWorld.Log("收到跨服服务器同步的玩家退出跨服服务器: playerID=%s" % playerID)
 | 
 |  |  |     curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
 | 
 |  |  |     if not curPlayer:
 | 
 |  |  |         GameWorld.Log("    退出跨服时本服玩家不在线!", playerID)
 | 
 |  |  |         return
 | 
 |  |  |     PlayerControl.SetCrossRealmState(curPlayer, 0)
 | 
 |  |  |     return
 | 
 
 |  |  | 
 |  |  |     return 
 | 
 |  |  | def GetLeaveFamilyTime(curPlayer):return curPlayer.GetExAttr12()
 | 
 |  |  | 
 | 
 |  |  | ## 玩家所属服务器组ID
 | 
 |  |  | def GetPlayerServerGroupID(curPlayer): return curPlayer.GetExAttr13()
 | 
 |  |  | 
 | 
 |  |  | ## 是否脱机挂机状态
 | 
 |  |  | def GetIsTJG(curPlayer):
 | 
 |  |  |     if curPlayer.GetDictByKey(ChConfig.Def_OnlineType):
 | 
 
 |  |  | 
 |  |  | Def_PDict_OnDayEx = "OnDayEx" # 特殊时间点凌晨X点过天
 | 
 |  |  | Def_PDict_OnWeekEx = "OnWeekEx" # 特殊时间点凌晨X点过周
 | 
 |  |  | Def_PDict_OnMonthEx = "OnMonthEx" # 特殊时间点凌晨X点过月
 | 
 |  |  | Def_Player_Dict_ServerGroupID = "ServerGroupID"    # 合服/混服时所属游戏服务器组ID
 | 
 |  |  | Def_Player_Dict_PlayerFromPID = "PlayerFromPID"    # pid
 | 
 |  |  | Def_Player_Dict_Account_Type = "account_type"    # account_type
 | 
 |  |  | Def_Player_Dict_TencentPF = "tencentPF"    # 腾讯平台来源pf
 | 
 
 |  |  | 
 |  |  |     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
 | 
 |  |  |     
 | 
 |  |  |     if not curPlayer.GetMapLoadOK():
 | 
 |  |  |         #未读取地图成功,不让用
 | 
 |  |  |         GameWorld.DebugLog("    未读取地图成功,不让用")
 | 
 |  |  |         return
 | 
 |  |  |     
 | 
 |  |  |     #判断FB中是否可使用GM命令
 | 
 
 |  |  | 
 |  |  |             
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | ##玩家主动离开副本.
 | 
 |  |  | def DoPlayerLeaveFB(curPlayer, tick):
 | 
 |  |  |     gameFB = GameWorld.GetGameFB()
 | 
 |  |  |     fbStep = gameFB.GetFBStep()
 | 
 |  |  |      | 
 |  |  |     if fbStep <= FB_State_Waiting and fbStep >= FB_State_Leave:
 | 
 |  |  |         return
 | 
 |  |  |      | 
 |  |  |     leavePlayerID = curPlayer.GetPlayerID()
 | 
 |  |  |     roomID = GameWorld.GetGameWorld().GetPropertyID()
 | 
 |  |  |     playerIDA = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 1)
 | 
 |  |  |     playerIDB = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 2)
 | 
 |  |  |      | 
 |  |  |     loser, loserID = curPlayer, leavePlayerID
 | 
 |  |  |     winnerID = playerIDA if playerIDB == loserID else playerIDB
 | 
 |  |  |     winner = GameWorld.GetMapCopyPlayerManager().FindPlayerByID(winnerID)
 | 
 |  |  |     GameWorld.Log("玩家主动退出,直接算输! roomID=%s,leavePlayerID=%s,loserID=%s,winnerID=%s" % (roomID, leavePlayerID, loserID, winnerID))
 | 
 |  |  |     __DoFBPKAllOver(winner, winnerID, loser, loserID, Def_OverType_PlayerExit, tick)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | ## 获得副本帮助信息
 | 
 |  |  | def DoFBHelp(curPlayer, tick):
 | 
 |  |  |     return
 | 
 |  |  | 
 |  |  |                     其他情况则在线玩家获胜,如果没有玩家在线,则最迟离线的获胜
 | 
 |  |  |     '''
 | 
 |  |  |     winner, winnerID, loser, loserID = None, 0, None, 0
 | 
 |  |  |     roomID = GameWorld.GetGameWorld().GetPropertyID()
 | 
 |  |  |     gameFB = GameWorld.GetGameFB()
 | 
 |  |  |     fbStep = gameFB.GetFBStep()
 | 
 |  |  |     copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
 | 
 |  |  | 
 |  |  |         # 时间到还没分出胜负, 根据以下规则决定胜负,这里用玩家ID处理,防止结算时都掉线了导致没有结果
 | 
 |  |  |         # 伤害输出 > 优先到达时间 > 剩余HP > 最大HP > playerID
 | 
 |  |  |         
 | 
 |  |  |         GameWorld.Log("两个人都在线,根据超时规则判断胜负玩家! roomID=%s" % (roomID))
 | 
 |  |  |         playerInfoList = []
 | 
 |  |  |         for playerID in [playerIDA, playerIDB]:
 | 
 |  |  |             player = copyMapPlayerManager.FindPlayerByID(playerID)
 | 
 |  |  | 
 |  |  |             continue
 | 
 |  |  |         winner = player
 | 
 |  |  |         winnerID = player.GetPlayerID()
 | 
 |  |  |         GameWorld.Log("超时结算,玩家在线,直接获胜: roomID=%s,winnerID=%s" % (roomID, winnerID))
 | 
 |  |  |         break
 | 
 |  |  |     
 | 
 |  |  |     if not winner:
 | 
 |  |  |         playerLeaveTickA = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerIDA)
 | 
 |  |  |         playerLeaveTickB = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerIDB)
 | 
 |  |  |         GameWorld.Log("超时结算,没有玩家在线,后离线的获胜: playerLeaveTickA=%s,playerLeaveTickB=%s" % (playerLeaveTickA, playerLeaveTickB))
 | 
 |  |  |         # 离线tick较大的就是比较晚离线的
 | 
 |  |  |         if playerLeaveTickA > playerLeaveTickB:
 | 
 |  |  |             winnerID = playerIDA
 | 
 |  |  | 
 |  |  |     SkillCommon.ResetAllSkillCD(player)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | ## 跨服PK结束处理
 | 
 |  |  | ## 跨服PK结束处理,注意 winner、loser 参数可能为None
 | 
 |  |  | def __DoFBPKAllOver(winner, winnerID, loser, loserID, overType, tick):
 | 
 |  |  |     gameFB = GameWorld.GetGameFB()
 | 
 |  |  |     
 | 
 
 |  |  | 
 |  |  |     #通知玩家物品信息
 | 
 |  |  |     __Sync_PackDetel(curPlayer)
 | 
 |  |  |     
 | 
 |  |  |     #更新主服ID信息
 | 
 |  |  |     #UpdatePlayerServerGroupID(curPlayer)
 | 
 |  |  |     #更新服务器组ID
 | 
 |  |  |     PlayerControl.UpdPlayerServerGroupID(curPlayer)
 | 
 |  |  |     
 | 
 |  |  |     #上线学习技能
 | 
 |  |  |     SkillCommon.PlayerLoginCheckLearnSkill(curPlayer)
 | 
 |  |  | 
 |  |  | # #    curPlayer.Syn_OfflineTimeRefresh(int(curOfflineMinutes))
 | 
 |  |  | #    curPlayer.Syn_OfflineTimeQueryResult()
 | 
 |  |  | #===============================================================================
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def UpdatePlayerServerGroupID(curPlayer):
 | 
 |  |  |     # 更新自己的服务器组ID, 跨服服务器不处理
 | 
 |  |  |     if GameWorld.IsCrossServer():
 | 
 |  |  |         return
 | 
 |  |  |     serverGroupID = GameWorld.GetServerGroupID()
 | 
 |  |  |     if not serverGroupID:
 | 
 |  |  |         return
 | 
 |  |  |     playerServerGroupID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ServerGroupID)
 | 
 |  |  |     if playerServerGroupID != serverGroupID:
 | 
 |  |  |         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_ServerGroupID, serverGroupID)
 | 
 |  |  |         GameWorld.DebugLog("更新玩家所属服务器组ID: serverGroupID=%s" % serverGroupID)
 | 
 |  |  |          | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | #---------------------------------------------------------------------
 | 
 
 |  |  | 
 |  |  |     
 | 
 |  |  |     # 通知子服玩家退出跨服服务器
 | 
 |  |  |     playerID = curPlayer.GetPlayerID()
 | 
 |  |  |     serverGroupID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ServerGroupID)
 | 
 |  |  |     serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
 | 
 |  |  |     GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_ExitCrossServer, playerID, [serverGroupID])
 | 
 |  |  |     
 | 
 |  |  |     # 设置非跨服状态,踢下线
 | 
 
 |  |  | 
 |  |  | def GetChatBubbleBox(curPlayer): return curPlayer.GetExAttr10()
 | 
 |  |  | def SetChatBubbleBox(curPlayer, value): return curPlayer.SetExAttr10(value, False, True)
 | 
 |  |  | 
 | 
 |  |  | ## 玩家所属服务器组ID
 | 
 |  |  | def GetPlayerServerGroupID(curPlayer): return curPlayer.GetExAttr13()
 | 
 |  |  | def UpdPlayerServerGroupID(curPlayer):
 | 
 |  |  |     # 更新自己的服务器组ID, 跨服服务器不处理
 | 
 |  |  |     if GameWorld.IsCrossServer():
 | 
 |  |  |         return
 | 
 |  |  |     serverGroupID = GameWorld.GetServerGroupID()
 | 
 |  |  |     if not serverGroupID:
 | 
 |  |  |         return
 | 
 |  |  |     playerServerGroupID = curPlayer.GetExAttr13()
 | 
 |  |  |     if playerServerGroupID != serverGroupID:
 | 
 |  |  |         curPlayer.SetExAttr13(serverGroupID, False, True)
 | 
 |  |  |         GameWorld.DebugLog("更新玩家所属服务器组ID: serverGroupID=%s" % serverGroupID)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | ##获得玩家威望值
 | 
 |  |  | def GetPrestige(curPlayer): return 0
 | 
 |  |  | def SetPrestige(curPlayer, value): return
 | 
 
 |  |  | 
 |  |  | def Sycn_MagicWeaponLV(curPlayer, mwID= -1):
 | 
 |  |  |     #通知法宝等级信息
 | 
 |  |  |     if mwID == -1:
 | 
 |  |  |         isAll = True
 | 
 |  |  |         needCalList = []
 | 
 |  |  |         ipyDataMgr = IpyGameDataPY.IPY_Data()
 | 
 |  |  |         for i in xrange(ipyDataMgr.GetTreasureCount()):
 | 
 |  |  |             ipyData = ipyDataMgr.GetTreasureByIndex(i)
 | 
 |  |  |             needCalList.append(ipyData.GetID())
 | 
 |  |  |     else:
 | 
 |  |  |         isAll = False
 | 
 |  |  |         needCalList = [mwID]
 | 
 |  |  |     sendPack = ChPyNetSendPack.tagMCMagicWeaponLVInfo()
 | 
 |  |  |     sendPack.InfoList = []
 | 
 |  |  | 
 |  |  |         state = GetIsClickMagicWeapon(curPlayer, mwID)
 | 
 |  |  |         FBPassLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWFBPassLevel % mwID)
 | 
 |  |  |         isWear = GetIsWearMagicWeapon(curPlayer, mwID)
 | 
 |  |  |         if not mwLv and not curUpExp and not state and not FBPassLV and not isWear:
 | 
 |  |  |         if isAll and not mwLv and not curUpExp and not state and not FBPassLV and not isWear:
 | 
 |  |  |             continue
 | 
 |  |  |         pack = ChPyNetSendPack.tagMCMagicWeaponInfo()
 | 
 |  |  |         pack.MWID = mwID
 | 
 |  |  | 
 |  |  |                 hasWearCnt +=1
 | 
 |  |  |                 
 | 
 |  |  |     SetMagicWeaponWearState(curPlayer, mwID, isWear)
 | 
 |  |  |     CalcMagicWeaponAttr(curPlayer)
 | 
 |  |  |     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
 | 
 |  |  |     Sycn_MagicWeaponLV(curPlayer, mwID)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 
 |  |  | 
 |  |  | #-------------------------------------------------------------------------------
 | 
 |  |  | 
 | 
 |  |  | import GameWorld
 | 
 |  |  | import PlayerControl
 | 
 |  |  | import CrossRealmPlayer
 | 
 |  |  | import IPY_GameWorld
 | 
 |  |  | import ChPlayer
 | 
 |  |  | 
 |  |  |         return
 | 
 |  |  |     
 | 
 |  |  |     #跨服前更新自己所属服务器组ID
 | 
 |  |  |     ChPlayer.UpdatePlayerServerGroupID(curPlayer)
 | 
 |  |  |     PlayerControl.UpdPlayerServerGroupID(curPlayer)
 | 
 |  |  |     
 | 
 |  |  |     mapID, dataMapID, copyMapID, posX, posY = mapPosInfo
 | 
 |  |  |     #curPlayer.SendMergeRegisterPlayer(mapID, dataMapID, copyMapID, posX, posY)
 |