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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GameWorship
#
# @todo:Ĥ°Ý
# @author hxp
# @date 2024-07-02
# @version 1.0
#
# ÏêϸÃèÊö: Ä¤°Ý
#
#-------------------------------------------------------------------------------
#"""Version = 2024-7-02 16:30"""
#-------------------------------------------------------------------------------
 
import ShareDefine
import PyDataManager
import NetPackCommon
import PlayerControl
import ChPyNetSendPack
import PlayerViewCache
import PlayerRecData
import CrossRealmMsg
import IpyGameDataPY
import GameWorld
import ChConfig
 
import random
import time
import json
 
# ±»Ä¤°ÝÍæ¼Ò  RecType = ShareDefine.Def_PlayerRecType_WorshipPlayer
def GetWorshipType(recData): return recData.GetValue1() # Ä¤°ÝÀàÐÍ
def SetWorshipType(recData, worshipType): recData.SetValue1(worshipType)
def GetWorshipValue(recData): return recData.GetValue2() # Ä¤°ÝÀàÐÍÏµĹ¦ÄÜÖµ£¬¼´Ä¤°Ýʲô£¬¹¦ÄÜ×Ô¶¨Ò壬ÈçÅÅÃû»òÆäËû£¬¿ÉÑ¡
def SetWorshipValue(recData, worshipValue): recData.SetValue2(worshipValue)
def GetWorshipDays(recData): return recData.GetValue3() # ³ÖÐøÌìÊý£º 0ÓÀ¾Ã£¬>0-ÌìÊý
def SetWorshipDays(recData, days): recData.SetValue3(days)
 
# Íæ¼ÒÿÈÕĤ°Ý¼Ç¼  RecType = ShareDefine.Def_PlayerRecType_WorshipDaily
# ½ñÈÕÒÑĤ°Ý¼Ç¼ {tagPlayerID:[[Ĥ°ÝÀàÐÍ, Ä¤°ÝÖµ], ...], ...}
# ½ñÈÕÊÇ·ñÒÑĤ°Ý¹ý¸ÃÍæ¼Òij¸öĤ°Ý
def HasWorshipRecordToday(recData, tagPlayerID, worshipType, worshipValue):
    worshipRecordList = recData.GetUserDataByKey(tagPlayerID, [])
    if not worshipRecordList:
        return False
    return [worshipType, worshipValue] in worshipRecordList
# ÉèÖýñÈÕÒÑĤ°Ý¹ý¸ÃÍæ¼Òij¸öĤ°Ý
def SetWorshipRecordToday(recData, tagPlayerID, worshipType, worshipValue):
    worshipRecordList = recData.GetUserDataByKey(tagPlayerID, [])
    recordInfo = [worshipType, worshipValue]
    if recordInfo not in worshipRecordList:
        worshipRecordList.append(recordInfo)
    recData.SetUserDataByKey(tagPlayerID, worshipRecordList)
    return
##--------------------------------------------------------------------------------------------------
def OnServerStart():
    return
 
def GetPlayerViewInfo(playerID):
    ## »ñȡĤ°Ý¶ÔÏóµÄÍâ¹ÛÏÔʾÐÅÏ¢ - ±¾·þ¿ç·þͨÓÃ
    return PlayerViewCache.GetShotCacheDict(playerID, "AccID", "VIPLV", "FightPower", "Model")
 
def OnPlayerLogin(curPlayer):
    
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    
    unWorshipList = [] # Î´Ä¤°ÝÁбí
    recDict = playerRecMgr.GetPlayerRecDataDict(ShareDefine.Def_PlayerRecType_WorshipPlayer)
    for recDataList in recDict.values():
        for recData in recDataList:
            if not __CheckPlayerCanWorship(curPlayer, recData):
                continue
            unWorshipList.append(recData)
            
    Sync_UnWorshipInfo(curPlayer, unWorshipList)
    return
 
def DoOnDay():
    '''
        ±¾·þÏȹýÌì
                ÒѹýÆÚµÄ¿ç·þĤ°ÝÒ²»á±»ÏÈɾ³ý£¬Ï൱ÓÚÌύɾ³ý¹ýÆÚµÄ¿ç·þĤ°Ý
                Î´¹ýÆÚµÄ¿ç·þĤ°Ýµ±¿ç·þ·þÎñÆ÷¹ýÌìʱͬÑùÒ²ÊÇδ¹ýÆÚ£¬¹ÊÒ²¿ÉÕý³£Ä¤°Ý£¬Ã¿ÌìµÄĤ°Ý¼Ç¼ÊÇ´æÔÚ±¾·þÍæ¼Ò£¬Ï൱ÓÚÌáǰĤ°Ý
                
        ¿ç·þÏȹýÌì
                ÒѹýÆÚµÄ¿ç·þĤ°Ý»á±»É¾³ý£¬È»ºóͬ²½¸ø×Ó·þÏÈͬ²½É¾³ýµô¼´¿É
                Î´¹ýÆÚµÄ¿ç·þĤ°Ý²»´¦Àí¼´¿É
                
        ËùÒÔ£¬¹ýÌìʱ£¬±¾·þ¼°¿ç·þ¸÷×Ô´¦Àí¸÷×ÔµÄÂß¼­¼´¿É
    '''
    
    isCrossServer = GameWorld.IsCrossServer()
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    
    worshipList = []
    curTime = int(time.time())
    recDict = playerRecMgr.GetPlayerRecDataDict(ShareDefine.Def_PlayerRecType_WorshipPlayer)
    for recDataList in recDict.values():
        for recData in recDataList[::-1]: # µ¹Ðò´¦Àíɾ³ýµ½ÆÚµÄĤ°Ý¶ÔÏó
            recTime = recData.GetTime()
            tagPlayerID = recData.GetPlayerID()
            worshipType = GetWorshipType(recData)
            worshipValue = GetWorshipValue(recData)
            worshipDays = GetWorshipDays(recData)
            if not worshipDays: # ÓÀ¾ÃĤ°Ý²»´¦Àí£¬Ö±µ½±»Ìæ»»
                GameWorld.DebugLog("ÓÀ¾ÃĤ°Ý²»´¦Àí: worshipType=%s,worshipValue=%s,tagPlayerID=%s" % (worshipType, worshipValue, tagPlayerID))
                __UpdWorshipByDay(isCrossServer, worshipList, recData)
                continue
            
            diffDays = GameWorld.GetDiff_Day(curTime, recTime)
            if diffDays < worshipDays:
                GameWorld.DebugLog("Ĥ°Ýδµ½ÆÚ: worshipType=%s,worshipValue=%s,tagPlayerID=%s,diffDays=%s < %s" 
                                   % (worshipType, worshipValue, tagPlayerID, diffDays, worshipDays))
                __UpdWorshipByDay(isCrossServer, worshipList, recData)
                continue
            
            GameWorld.DebugLog("ɾ³ýĤ°Ý: worshipType=%s,worshipValue=%s,tagPlayerID=%s" % (worshipType, worshipValue, tagPlayerID))
            playerRecMgr.DelRecData(recData)
            
    if isCrossServer:
        # Í¬²½¸ø×Ó·þ
        dataMsg = {"msgType":"AllCrossWorship", "worshipDataList":worshipList}
        CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Worship, dataMsg)
        return
    
    # ±¾·þ´¦Àí
    playerRecMgr.DelRecDataByType(ShareDefine.Def_PlayerRecType_WorshipDaily) # É¾³ý±¾·þËùÓÐÍæ¼ÒµÄÿÈÕĤ°Ý¼Ç¼
    Sync_UnWorshipInfo(None, worshipList)
    return
 
def __UpdWorshipByDay(isCrossServer, worshipList, recData):
    ## ¹ýÌì¸üÐÂδ¹ýÆÚĤ°ÝÐÅÏ¢
    playerID = recData.GetPlayerID()
    playerInfo = GetPlayerViewInfo(playerID)
    if playerInfo:
        recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, playerInfo)
        
    if isCrossServer:
        worshipList.append(recData.GetString())
    else:
        worshipList.append(recData)
    return
 
def IsWorshipPlayer(playerID):
    ## ÊÇ·ñĤ°ÝÍæ¼Ò
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    if playerRecMgr.GetPlayerRecDataList(ShareDefine.Def_PlayerRecType_WorshipPlayer, playerID):
        return True
    return False
 
def AddWorshipPlayer(worshipType, worshipValue, playerID, serverIDList, syncList=None, days=None):
    ## Ìí¼ÓĤ°ÝÍæ¼Ò£¬±¾·þ¿ç·þͨÓÃ
    
    if worshipType in ShareDefine.Def_WorshipTypeCross:
        if not GameWorld.IsCrossServer():
            GameWorld.ErrLog("·Ç¿ç·þ·þÎñÆ÷²»ÔÊÐíÌí¼Ó¿ç·þĤ°Ý! worshipType=%s" % (worshipType))
            return
    else:
        if GameWorld.IsCrossServer():
            GameWorld.ErrLog("¿ç·þ·þÎñÆ÷²»ÔÊÐíÌí¼Ó·Ç¿ç·þĤ°Ý! worshipType=%s" % (worshipType))
            return
        
    ipyData = IpyGameDataPY.GetIpyGameDataNotLog("Worship", worshipType, worshipValue)
    if not ipyData:
        return
    
    if days == None:
        days = ipyData.GetWorshipDays() # Ã»ÓÐÖ¸¶¨ÌìÊýµÄ»°È¡Åä±í
        
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    recData = playerRecMgr.GetPlayerRecData(ShareDefine.Def_PlayerRecType_WorshipPlayer, playerID, [worshipType, worshipValue])
    if not recData:
        GameWorld.Log("Ìí¼ÓĤ°ÝÊý¾Ý: playerID=%s,worshipType=%s,worshipValue=%s,days=%s,%s" % (playerID, worshipType, worshipValue, days, serverIDList))
        recData = playerRecMgr.AddPlayerRecData(ShareDefine.Def_PlayerRecType_WorshipPlayer, playerID)
    else:
        GameWorld.Log("¸üÐÂĤ°ÝÊý¾Ý: playerID=%s,worshipType=%s,worshipValue=%s,days=%s,%s" % (playerID, worshipType, worshipValue, days, serverIDList))
        recData.SetTime(int(time.time()))
    SetWorshipType(recData, worshipType)
    SetWorshipValue(recData, worshipValue)
    SetWorshipDays(recData, days)
    
    playerInfo = GetPlayerViewInfo(playerID)
    serverID = GameWorld.GetAccIDServerID(playerInfo.get("AccID", ""))
    saveServerIDList = [] + serverIDList # ÖØÐ´´½¨Ò»·Ý´æ´¢£¬²»¸Ä±ä´«ÈëÖµ
    # È·±£Íæ¼Ò×ÔÉíÒ»¶¨ÄÜ¿´µ½×Ô¼º£¬¿ç·þÅÅλÈüÀúÊ··ÖÇøÎÊÌâ
    if saveServerIDList and serverID and not GameWorld.CheckServerIDInList(serverID, saveServerIDList):
        saveServerIDList.append(serverID)
    recData.SetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList, saveServerIDList) # ±£´æµ±ÏµÄÇø·þID·¶Î§        
    recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, playerInfo) # ±£´æµ±ÏµÄÍæ¼Ò»ù±¾ÐÅÏ¢
    
    if isinstance(syncList, list):
        syncList.append(recData)
    else:
        SendNewWorshipPlayer([recData])
        
    return recData
 
def SendNewWorshipPlayer(syncList):
    ## Í¬²½ÐÂĤ°ÝÊý¾Ý
    if not syncList:
        return
    if GameWorld.IsCrossServer():
        SyncAddCrossWorship(syncList)
    else:
        Sync_UnWorshipInfo(None, syncList)
    return
 
 
def DelWorshipPlayer(worshipType, worshipValue=None, delPlayerID=None):
    ## É¾³ýĤ°ÝÍæ¼Ò£¬±¾·þ¿ç·þͨÓÃ
    valueList = [worshipType]
    if worshipValue != None:
        valueList.append(worshipValue)
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    playerRecMgr.DelRecDataByTypeValue(ShareDefine.Def_PlayerRecType_WorshipPlayer, valueList, delPlayerID)
    
    if GameWorld.IsCrossServer():
        dataMsg = {"msgType":"DelCrossWorship", "worshipType":worshipType, "worshipValue":worshipValue, "delPlayerID":delPlayerID}
        CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Worship, dataMsg)
    return
 
#// B0 20 ÇëÇóĤ°ÝÍæ¼Ò #tagCGWorship
#
#struct    tagCGWorship
#{
#    tagHead        Head;
#    DWORD        PlayerID;        // Ä¿±êÍæ¼ÒID
#    BYTE        WorshipType;    // Ä¤°ÝÀàÐÍ
#    DWORD        WorshipValue;    // Ä¤°ÝÀàÐͶÔÓ¦µÄ¹¦ÄÜÖµ£¬ÈçÃû´Î»òÆäËû£¬ÓɾßÌåĤ°ÝÀàÐͶ¨Òå¶ÔÓ¦Öµº¬Òå
#};
def OnWorship(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    tagPlayerID = clientData.PlayerID
    worshipType = clientData.WorshipType
    worshipValue = clientData.WorshipValue
    
    ipyData = IpyGameDataPY.GetIpyGameData("Worship", worshipType, worshipValue)
    if not ipyData:
        __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, 1)
        return
    
    findWorshipData = None
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    recDataList = playerRecMgr.GetPlayerRecDataList(ShareDefine.Def_PlayerRecType_WorshipPlayer, tagPlayerID)
    for recData in recDataList:
        if worshipType == GetWorshipType(recData) and worshipValue == GetWorshipValue(recData):
            findWorshipData = recData
            break
        
    if not findWorshipData:
        __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, 2)
        GameWorld.DebugLog("²»´æÔÚ¸ÃÄ¿±êÍæ¼ÒµÄĤ°Ý! tagPlayerID=%s,worshipType=%s,worshipValue=%s" 
                           % (tagPlayerID, worshipType, worshipValue), playerID)
        return
    
    if not __CheckPlayerCanWorship(curPlayer, recData):
        __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, 3)
        return
    
    moneyType = ipyData.GetMoneyType()
    moneyRange = ipyData.GetMoneyRange()
    if len(moneyRange) != 2:
        return
    moneyValue = random.randint(moneyRange[0], moneyRange[1])
    
    GameWorld.DebugLog("Ĥ°Ý: tagPlayerID=%s,worshipType=%s,worshipValue=%s,moneyType=%s,moneyValue=%s" 
                       % (tagPlayerID, worshipType, worshipValue, moneyType, moneyValue), playerID)
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    worshipRecData = playerRecMgr.GetPlayerRecDataFirst(ShareDefine.Def_PlayerRecType_WorshipDaily, playerID)
    SetWorshipRecordToday(worshipRecData, tagPlayerID, worshipType, worshipValue)
    
    __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, 0, moneyType, moneyValue)
    # Í¬²½µØÍ¼·¢·Å»õ±Ò
    PlayerControl.MapServerGiveAward(curPlayer, "Worship", {moneyType:moneyValue})
    return
 
def __CheckPlayerCanWorship(curPlayer, recData):
    ## ¼ì²éÍæ¼ÒÊÇ·ñ¿ÉĤ°Ý¸Ã¶ÔÏó
    playerID = curPlayer.GetPlayerID()
    recPlayerID = recData.GetPlayerID()
    playerInfo = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, {})
    if not playerInfo:
        GameWorld.DebugLog("ûÓÐÍâ¹ÛչʾµÄ²»Í¬²½! recPlayerID=%s" % recPlayerID, playerID)
        return
    accID = playerInfo.get("AccID", "")
    if not accID:
        return
    serverID = GameWorld.GetAccIDServerID(accID)
    playerServerID = GameWorld.GetPlayerServerID(curPlayer)
    
    worshipType = GetWorshipType(recData)
    worshipValue = GetWorshipValue(recData)
    if worshipType == ShareDefine.Def_WorshipType_ServerNaming:
        #ֻͬ²½¸øÍ¬ServerIDµÄ
        if serverID != playerServerID:
            GameWorld.DebugLog("ֻͬ²½¸øÍ¬ServerIDµÄ! recPlayerID=%s,accID=%s,serverID=%s != playerServerID=%s" 
                               % (recPlayerID, accID, serverID, playerServerID), playerID)
            return
    else:
        serverIDList = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList)
        if not GameWorld.CheckServerIDInList(playerServerID, serverIDList):
            GameWorld.DebugLog("¸ÃÍæ¼Ò²»ÄÜĤ°ÝÄ¿±êÍæ¼Ò! playerServerID=%s not in %s" % (playerServerID, serverIDList), playerID)
            return
        
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    worshipRecData = playerRecMgr.GetPlayerRecDataFirst(ShareDefine.Def_PlayerRecType_WorshipDaily, playerID)
    if HasWorshipRecordToday(worshipRecData, recPlayerID, worshipType, worshipValue):
        GameWorld.DebugLog("½ñÈÕÒÑĤ°Ý¹ý! recPlayerID=%s,worshipType=%s, worshipValue=%s" % (recPlayerID, worshipType, worshipValue), playerID)
        return
    
    return True
 
def __SyncWorshipResult(curPlayer, tagPlayerID, worshipType, worshipValue, result, moneyType=0, moneyValue=0):
    ## Í¬²½Ä¤°Ý½á¹û
    # @param result: Ä¤°Ý½á¹û£º0-³É¹¦£»1-²»´æÔÚ¸ÃĤ°Ý£»2-²»ÄÜĤ°ÝÄ¿±ê
    clientPack = ChPyNetSendPack.tagGCWorshipResult()
    clientPack.PlayerID = tagPlayerID
    clientPack.WorshipType = worshipType
    clientPack.WorshipValue = worshipValue
    clientPack.Result = result
    clientPack.MoneyType = moneyType
    clientPack.MoneyValue = moneyValue
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
 
def CrossServerMsg_Worship(msgData):
    ## ×Ó·þÊÕµ½¿ç·þÐÅÏ¢
    
    msgType = msgData["msgType"]
    
    if msgType == "AddCrossWorship":
        __Client_AddCrossWorship(msgData)
    
    elif msgType == "AllCrossWorship":
        __Client_AllCrossWorship(msgData)
        
    elif msgType == "DelCrossWorship":
        __Client_DelCrossWorship(msgData)
        
    return
 
def __Client_AllCrossWorship(msgData):
    ## ×Ó·þ¸üÐÂËùÓпç·þĤ°Ý
    worshipDataList = msgData["worshipDataList"]
    
    GameWorld.Log("×Ó·þ¸üÐÂËùÓпç·þĤ°Ý: count=%s" % len(worshipDataList))
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    for crossWorshipType in ShareDefine.Def_WorshipTypeCross:
        playerRecMgr.DelRecDataByTypeValue(ShareDefine.Def_PlayerRecType_WorshipPlayer, [crossWorshipType])
        
    sysnList = []
    for attrDict in worshipDataList:
        recData = playerRecMgr.AddPlayerRecDataByDict(attrDict)
        playerID = recData.GetPlayerID()
        
        # Èç¹û´æÔÚ±¾·þµÄ×îÐÂÍâ¹ÛÊý¾ÝÔòÒѱ¾·þµÄΪ׼
        playerInfo = GetPlayerViewInfo(playerID)
        if playerInfo:
            recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, playerInfo)
            
        sysnList.append(recData)
        
        serverIDList = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList)
        GameWorld.Log("    ¸üпç·þĤ°Ý: worshipType=%s,worshipValue=%s,playerID=%s,days=%s,%s" 
                      % (GetWorshipType(recData), GetWorshipValue(recData), playerID, GetWorshipDays(recData), serverIDList))
        
    #¸üÐÂÊý¾ÝµÄ¿É²»Í¬²½£¬Ã¿¸öÈ˵ÄĤ°Ý¼Ç¼¶¼²»Ò»Ñù£¬ÓɵǼ´¥·¢¼°Ìí¼ÓÐÂĤ°Ý´¥·¢¼´¿É
    #Sync_UnWorshipInfo(None, sysnList)
    return
 
def __Client_AddCrossWorship(msgData):
    ## ×Ó·þÌí¼Ó¿ç·þĤ°Ý
    worshipDataList = msgData["worshipDataList"]
    
    GameWorld.Log("×Ó·þÌí¼Ó¿ç·þĤ°Ý: addCount=%s" % len(worshipDataList))
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    
    tempData = PlayerRecData.PlayerRecDataTemp
    sysnList = []
    for attrDict in worshipDataList:
        tempData.SetAttr(attrDict, True)
        playerID = tempData.GetPlayerID()
        worshipType = GetWorshipType(tempData)
        worshipValue = GetWorshipValue(tempData)
        if not playerID or not worshipType:
            continue
        
        # Èç¹ûÒѾ­´æÔÚ¸ÃĤ°ÝÔòÖ±½Ó¸üÐÂÊý¾Ý£¬·ñÔòÌí¼ÓÐÂÊý¾Ý
        recData = playerRecMgr.GetPlayerRecData(ShareDefine.Def_PlayerRecType_WorshipPlayer, playerID, [worshipType, worshipValue])
        if recData:
            recData.SetAttr(attrDict, True)
        else:
            recData = playerRecMgr.AddPlayerRecDataByDict(attrDict)
            
        sysnList.append(recData)
        
        serverIDList = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_ServerIDList)
        GameWorld.Log("    Ìí¼Ó¿ç·þĤ°Ý: worshipType=%s,worshipValue=%s,playerID=%s,days=%s,%s" 
                      % (GetWorshipType(recData), GetWorshipValue(recData), playerID, GetWorshipDays(recData), serverIDList))
        
    Sync_UnWorshipInfo(None, sysnList)
    return
 
def __Client_DelCrossWorship(msgData):
    ## ×Ó·þɾ³ý¿ç·þĤ°Ý
    worshipType = msgData["worshipType"]
    worshipValue = msgData["worshipValue"]
    delPlayerID = msgData["delPlayerID"]
    GameWorld.Log("×Ó·þɾ³ý¿ç·þĤ°Ý: worshipType=%s,worshipValue=%s,delPlayerID=%s" % (worshipType, worshipValue, delPlayerID))
    DelWorshipPlayer(worshipType, worshipValue, delPlayerID)
    return
 
def Sync_UnWorshipInfo(curPlayer, unWorshipList):
    ## curPlayer ¿ÉÄÜΪNone
    if not unWorshipList:
        return
    
    infoList = []
    for recData in unWorshipList:
        recPlayerID = recData.GetPlayerID()
        playerInfo = GetPlayerViewInfo(recPlayerID)
        if playerInfo:
            # ¸üб¾·þ×îеÄÍâ¹ÛÏÔʾ£¬¿ç·þÍæ¼ÒÓÉ¿ç·þÿÈÕͬ²½¸üР__UpdWorshipByDay
            recData.SetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo, playerInfo)
        else:
            playerInfo = recData.GetUserDataByKey(ChConfig.Def_RecDataKey_PlayerInfo)
        if not playerInfo:
            # Ã»ÓÐÍâ¹ÛչʾµÄ²»Í¬²½
            continue
        
        if curPlayer:
            if not __CheckPlayerCanWorship(curPlayer, recData):
                continue
            
        infoPack = ChPyNetSendPack.tagGCWorshipInfo()
        infoPack.PlayerID = recPlayerID
        infoPack.WorshipType = GetWorshipType(recData)
        infoPack.WorshipValue = GetWorshipValue(recData)
        infoPack.PlayerInfo = json.dumps(playerInfo, ensure_ascii=False).replace(" ", "")
        infoPack.InfoLen = len(infoPack.PlayerInfo)
        
        if curPlayer:
            infoList.append(infoPack)
        else:
            infoList.append([recData, infoPack])
            
    if not infoList:
        return
    
    clientPack = ChPyNetSendPack.tagGCWorshipInfoList()
    if not curPlayer:
        # È«·þ¹ã²¥ÔÚÏßÍæ¼Ò£¬Ã¿¸öÈËͬ²½µÄ¿ÉÄܲ»Ò»Ñù
        playerManager = GameWorld.GetPlayerManager()
        for i in range(0, playerManager.GetPlayerCount()):
            curPlayer = playerManager.GetPlayerByIndex(i)
            if curPlayer == None or not curPlayer.GetInitOK():
                continue
            clientPack.WorshipInfoList = []
            for info in infoList:
                recData, infoPack = info
                if not __CheckPlayerCanWorship(curPlayer, recData):
                    continue
                clientPack.WorshipInfoList.append(infoPack)
            if not clientPack.WorshipInfoList:
                continue
            clientPack.WorshipCount = len(clientPack.WorshipInfoList)
            NetPackCommon.SendFakePack(curPlayer, clientPack)
    else:
        clientPack.WorshipInfoList = infoList
        clientPack.WorshipCount = len(clientPack.WorshipInfoList)
        NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
 
##--------------------------------------------------------------------------------------------------
 
def Sync_CrossWorshipToClientServer(serverGroupID=0):
    ''' Í¬²½¿ç·þĤ°ÝÊý¾Ýµ½×Ó·þÎñÆ÷
    @param serverGroupID: Îª0ʱͬ²½ËùÓÐ×Ó·þ
    '''
    GameWorld.Log("ͬ²½¸ø×Ó·þĤ°ÝÊý¾Ý: syncServerGroupID=%s" % (serverGroupID))
 
    playerRecMgr = PyDataManager.GetDBPlayerRecDataManager()
    recDataDict = playerRecMgr.GetPlayerRecDataDict(ShareDefine.Def_PlayerRecType_WorshipPlayer)
    
    worshipDataList = []
    for recDataList in recDataDict.values():
        for recData in recDataList:
            if not recData:
                continue
            if GetWorshipType(recData) not in ShareDefine.Def_WorshipTypeCross:
                continue
            worshipDataList.append(recData.GetString())
            
    dataMsg = {"msgType":"AllCrossWorship", "worshipDataList":worshipDataList}
    CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Worship, dataMsg)
    return
 
def SyncAddCrossWorship(addRecDataList):
    # Í¬²½×Ó·þ
    worshipDataList = []
    for recData in addRecDataList:
        if not recData:
            continue
        worshipDataList.append(recData.GetString())
    if not worshipDataList:
        return
    dataMsg = {"msgType":"AddCrossWorship", "worshipDataList":worshipDataList}
    CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Worship, dataMsg)
    return