hxp
2025-06-12 edc3910a9d090e5df4deb2dbc37709a740375938
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Player.PlayerOfflineSupport
#
# @todo:Íæ¼ÒÀëÏßÖ§³ÖÄÜÁ¦
# @author hxp
# @date 2025-06-03
# @version 1.0
#
# ÏêϸÃèÊö: Ö÷ÒªÓÃÓÚ´¦ÀíÀëÏßÍæ¼ÒÏà¹ØÖ§³ÖµÄÄÜÁ¦
# µäÐÍÓ¦Óãº
#     1. ºǫ́GM¹¤¾ßÃüÁî£¬Íæ¼Ò²»ÔÚÏßÖ§³Ö£¬¹æ±Üºǫ́²Ù×÷Ò»¶¨ÒªÍæ¼ÒÔÚÏßµÄÏÞÖÆ£»
#     2. ¿ç·þ֪ͨµÄÍæ¼ÒÏà¹Ø²Ù×÷ÐÅÏ¢
#            ÓÉÓÚ×Ó·þ¿ç·þͨѶÓÐÒ»¶¨µÄÑÓ³Ù£¬ËùÒÔÈ·±£Ä³Ð©Í¨¹ý¿ç·þÐÞ¸ÄÍæ¼ÒÏà¹ØÐÅÏ¢ÃüÁîÔÚ×Ó·þÍæ¼ÒÀëÏßʱÄÜÔÚÉÏÏߺóÖ´ÐÐ
#            Èç¿ÛÎïÆ·¡¢»õ±Ò»òÕ߸ø½±ÀøµÈ£¬·ÀÖ¹ÓÉÍæ¼ÒÀëÏߺó²ÅÊÕµ½ÏûÏ¢ÒýÆðµÄÉÙ¿Û»òÉÙ¸ø
#     3. ÆäËû
#
#-------------------------------------------------------------------------------
#"""Version = 2025-06-03 14:00"""
#-------------------------------------------------------------------------------
 
import DBDataMgr
import GameWorld
import ShareDefine
import traceback
import time
 
def AddOfflineUnprocessed(playerID, eventName, eventData, outtimeDays=7):
    '''Ìí¼ÓÍæ¼ÒÀëÏßδ´¦ÀíµÄʼþ
    @param eventName: Ê¼þÃû
    @param eventData: Ê¼þÊý¾Ý£¬Óɹ¦ÄÜ×Ô¶¨¶¨Ò壬ÈÎÒâ¸ñʽ
    @param outtimeDays: ¹ýÆÚÌìÊý£¬0-ÓÀ¾Ã, >0-Ö¸¶¨ÌìÊý, Ä¬ÈÏ30Ìì
    '''
    gameRecMgr = DBDataMgr.GetGameRecMgr()
    recIDMgr = gameRecMgr.GetRecTypeIDMgr(ShareDefine.Def_GameRecType_PlayerOfflineUnprocessed, playerID)
    recData = recIDMgr.AddRecData()
    recData.SetValue1(outtimeDays)
    recData.GetUserDict().update({"eventName":eventName, "eventData":eventData})
    GameWorld.Log("Ìí¼ÓÍæ¼ÒÀëÏßδ´¦ÀíµÄʼþ: %s, %s, %s" % (eventName, outtimeDays, eventData), playerID)
    return
 
def DoOfflineUnprocessed(curPlayer, eventName, dofunc):
    '''Ö´Ðд¦ÀíÍæ¼ÒÀëÏßδ´¦ÀíµÄʼþ
    @param dofunc: Ö´Ðк¯Êý£¬²ÎÊý[curPlayer, recData, eventName, eventData]
    '''
    if not dofunc:
        return
    playerID = curPlayer.GetPlayerID()
    recIDMgr = DBDataMgr.GetGameRecMgr().GetRecTypeIDMgr(ShareDefine.Def_GameRecType_PlayerOfflineUnprocessed, playerID)
    # ±ØÐë°´Ìí¼Ó˳ÐòÖ´ÐУ¬²»È»¿ÉÄܵ¼ÖÂÒì³££¬È磬ÏȼÓ1000½ð±Ò£¬ÔÙ¿Û³ý500£¬Èç¹û²»°´Ë³ÐòÖ´ÐпÉÄܵ¼ÖÂ×îºó½ð±ÒÓëÔ¤ÆÚ²»·ûºÏ
    
    delRecDataList = []
    try:
        for index in range(recIDMgr.GetCount()):
            recData = recIDMgr.At(index)
            recDict = recData.GetUserDict()
            if recDict.get("eventName") != eventName:
                continue
            eventData = recDict.get("eventData")
            GameWorld.Log("Ö´ÐÐÍæ¼ÒÉÏ´ÎÀëÏßǰδ´¦Àíʼþ: %s, %s" % (eventName, eventData), playerID)
            dofunc(curPlayer, recData, eventName, eventData)
            delRecDataList.append(recData)
    except:
        accID = curPlayer.GetAccID()
        msgInfo = "eventName=%s,accID=%s, %s" % (eventName, accID, traceback.format_exc())
        GameWorld.SendGameErrorEx("DoOfflineUnprocessed", msgInfo, playerID)
        
    # Ö´ÐÐÍêºóÔÙͳһɾ³ý
    for recData in delRecDataList:
        recIDMgr.DelRecData(recData)
        
    return
 
def DelOfflineUnprocessed(eventName):
    ## É¾³ýËùÓÐÍæ¼ÒijÖÖÀëÏßδ´¦ÀíµÄʼþ
    # @param eventName: Ê¼þÃû
    
    delCnt = 0
    recTypeMgr = DBDataMgr.GetGameRecMgr().GetRecTypeMgr(ShareDefine.Def_GameRecType_PlayerOfflineUnprocessed)
    for recID in recTypeMgr.GetRecIDList():
        recIDMgr = recTypeMgr.GetRecIDMgr(recID)
        for index in range(recIDMgr.GetCount())[::-1]:
            recData = recIDMgr.At(index)
            if recData.GetUserDict().get("eventName") != eventName:
                continue
            recIDMgr.DelRecData(recData)
            delCnt += 1
            
    GameWorld.DebugLog("ɾ³ýÍæ¼ÒÀëÏßδ´¦ÀíµÄʼþ: %s, delCnt=%s" % (eventName, delCnt))
    return
 
def DelOuttimeOfflineUnprocessed():
    ## É¾³ý¹ýÆÚÍæ¼ÒÀëÏßδ´¦ÀíµÄʼþ
    curTime = int(time.time())
    recTypeMgr = DBDataMgr.GetGameRecMgr().GetRecTypeMgr(ShareDefine.Def_GameRecType_PlayerOfflineUnprocessed)
    for recID in recTypeMgr.GetRecIDList():
        recIDMgr = recTypeMgr.GetRecIDMgr(recID)
        for index in range(recIDMgr.GetCount())[::-1]:
            recData = recIDMgr.At(index)
            recTime = recData.GetTime()
            outtimeDays = recData.GetValue1()
            if not outtimeDays:
                continue
            diffDays = GameWorld.GetDiff_Day(curTime, recTime) + 1
            if diffDays <= outtimeDays:
                continue
            recIDMgr.DelRecData(recData)
            GameWorld.DebugLog("ɾ³ýÍæ¼ÒÀëÏßδ´¦ÀíµÄ¹ýÆÚʼþ: %s, %s" % (outtimeDays, recData.GetUserData()), recID)
    return
 
def OnDay():
    DelOuttimeOfflineUnprocessed()
    return