hxp
2018-12-26 1deb0b9086974c1205cddee149b88b6974d35ecd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/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