#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package CrossRealmPlayer
|
#
|
# @todo:¿ç·þÍæ¼Ò
|
# @author hxp
|
# @date 2018-12-21
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ¿ç·þÍæ¼Ò
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2018-12-21 18:00"""
|
#-------------------------------------------------------------------------------
|
|
import GameWorld
|
import ShareDefine
|
import CrossRealmMsg
|
import ReadChConfig
|
import ChConfig
|
import PlayerControl
|
|
# »ñÈ¡Íæ¼Ò¿ç·þ·þÎñÆ÷ÉϵÄÃû×Ö
|
def GetCrossPlayerName(curPlayer):
|
# ͨ¹ýÓÎÏ·Õ˺ÅÖÐµÄÆ½Ì¨±êÖ¾»ñÈ¡Ãû³Æ£¬Ä¿Ç°Îªspid
|
playerName = curPlayer.GetPlayerName()
|
nameFormat = ReadChConfig.GetPyMongoConfig("Merge", "NameFormat", True)
|
if not nameFormat:
|
return playerName
|
|
opName = ReadChConfig.GetPyMongoConfig("Merge", "OpName_%s" % GameWorld.GetPlayerPlatform(curPlayer))
|
|
return (nameFormat%{"opname":opName, "sid":GameWorld.GetPlayerServerID(curPlayer)}).decode('gbk').encode(GameWorld.GetCharacterEncoding()) + playerName
|
|
def CrossServerMsg_ExitCrossServer(msgData):
|
## ÊÕµ½¿ç·þ·þÎñÆ÷ͬ²½µÄÍæ¼ÒÍ˳ö¿ç·þ·þÎñÆ÷
|
playerID = msgData
|
curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
if not curPlayer:
|
return
|
PlayerControl.SetCrossRealmState(curPlayer, 0)
|
return
|
|
def SendCrossRealmReg(curPlayer, actionType, mapID=0, dataMapID=0, copyMapID=0, posX=0, posY=0):
|
# ·¢ËÍ¿ç·þÕ˺Å×¢²áÉÏ´«Êý¾Ý
|
|
# ÉèÖÃÉÏ´«Êý¾ÝµÄ»î¶¯ÀàÐÍ
|
curPlayer.SetDict(ChConfig.Def_PlayerKey_MergeRegisterType, actionType)
|
sysMsg = str([actionType, mapID, dataMapID, copyMapID, posX, posY])
|
curPlayer.MapServer_QueryPlayerResult(0, 0, "CrossRealmReg", sysMsg, len(sysMsg))
|
GameWorld.Log("SendCrossRealmReg actionType=%s,mapID=%s,dataMapID=%s,copyMapID=%s,posX=%s,posY=%s"
|
% (actionType, mapID, dataMapID, copyMapID, posX, posY), curPlayer.GetPlayerID())
|
return
|
|
def OnCrossRealmRegOK(playerID, msgList, tick):
|
## ¿ç·þ±¨Ãû½á¹û
|
|
curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
if not curPlayer:
|
return
|
|
#newAccount, newName = msgList
|
|
actionType = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MergeRegisterType)
|
GameWorld.Log("¿ç·þ±¨Ãû³É¹¦ , actionType=%s" % (actionType), playerID)
|
|
# ¿ç·þPKÉÏ´«Êý¾ÝÍê±Ï£¬Í¨Öª¿ç·þ·þÎñÆ÷£¬×¼±¸Íê±Ï
|
if actionType == ShareDefine.Def_CrossAction_PK:
|
regVSRoomID = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MergeRegisterRoomID)
|
vsRoomID = curPlayer.GetVsRoomId()
|
|
if regVSRoomID != vsRoomID:
|
GameWorld.Log("ÉÏ´«¿ç·þ·þÎñÆ÷µÄ regVSRoomID=%s ÓëÍæ¼Òµ±Ç°µÄ roomID=%s ²»Í¬!²»·¢ËÍ×¼±¸Íê±Ï£¡"
|
% (regVSRoomID, vsRoomID), playerID)
|
return
|
|
dataMsg = {
|
"accID":curPlayer.GetAccID(), # ½ÇÉ«Õ˺ÅID
|
"playerID":playerID, # ½ÇÉ«ID
|
"vsRoomID":vsRoomID, # ËùÊô¶ÔÕ½·¿¼äID
|
}
|
CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKPrepareOK, dataMsg)
|
GameWorld.Log("֪ͨ¿ç·þ·þÎñÆ÷, Íæ¼ÒÆ¥ÅäPK×¼±¸Íê±Ï£¡%s" % str(dataMsg), playerID)
|
|
# ÆäËûµÄ£¬ÔÚÉÏ´«Êý¾ÝÍê±Ïºó£¬Ê¹ÓÃͨÓõÄ֪ͨ¿É½øÈë¿ç·þ
|
else:
|
NotifyCanEnterMergeServer(curPlayer, actionType)
|
|
# hxp 2015.09.10 ¿ç·þboss£¬ºóÃæµÄÔÝʱ²»ÐèÒª
|
return
|
|
|
def NotifyCanEnterMergeServer(curPlayer, actionType):
|
# ͨÓðü£¬Í¨Öª¿Í»§¶Ë¿É½øÈë¿ç·þ·þÎñÆ÷
|
return
|
|
#// C0 02 ²é¿´¿ç·þÍæ¼ÒÐÅÏ¢ #tagCGViewCrossPlayerInfo
|
#
|
#struct tagCGViewCrossPlayerInfo
|
#{
|
# tagHead Head;
|
# DWORD PlayerID; // ¿ç·þÍæ¼ÒID
|
#};
|
def OnViewCrossPlayerInfo(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
return
|
|
|
|