|  |  | 
 |  |  | 
 | 
 |  |  | import GameWorld
 | 
 |  |  | import PlayerSocial
 | 
 |  |  | import CrossBillboard
 | 
 |  |  | import PlayerFamilyStore
 | 
 |  |  | import PlayerCompensation
 | 
 |  |  | import PlayerBourse
 | 
 |  |  | import GameWorldBoss
 | 
 |  |  | import PlayerSealDemon
 | 
 |  |  | 
 |  |  | import PyGameData
 | 
 |  |  | import CrossRealmPK
 | 
 |  |  | import AuctionHouse
 | 
 |  |  | import PlayerAssist
 | 
 |  |  | import PyGameDataStruct
 | 
 |  |  | import IpyGameDataPY
 | 
 |  |  | import PlayerCharm
 | 
 |  |  | import PlayerLove
 | 
 |  |  | import CommFunc
 | 
 |  |  | import time
 | 
 |  |  | 
 | 
 |  |  | def GetSavePyData():
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     result = pyGameDataMgr.GetSaveData()
 | 
 |  |  |     GameWorld.DebugLog("GetSavePyData!! id = %s-%s"%(id(pyGameDataMgr), len(result)))
 | 
 |  |  |     GameWorld.Log("GetSavePyData!! id = %s-%s"%(id(pyGameDataMgr), len(result)))
 | 
 |  |  |     result = binascii.b2a_hex(result)
 | 
 |  |  |     #GameWorld.DebugLog("GetSavePyData!! result = %s-%s"%(result, len(result)))
 | 
 |  |  |     # 字节码在C++转化会发生错误must be string without null bytes, not str,但是可以正常保存,错误会在下次调用便宜接口才会触发
 | 
 |  |  | 
 |  |  |     GameWorld.Log("LoadPyGameData!!id = %s %s"%(id(pyGameDataMgr), len(gameBuffer)))
 | 
 |  |  |     return pyGameDataMgr.LoadGameData(gameBuffer, pos)
 | 
 |  |  | 
 | 
 |  |  | #协助感谢表
 | 
 |  |  | class PlayerAssistThanksPyManager(object):
 | 
 |  |  |      | 
 |  |  |     def __init__(self):
 | 
 |  |  |         self.allAssistThanksList = [] # 所有感谢 [tagDBAssistThanks, ...]
 | 
 |  |  |         self.playerThanksDict = {} # 玩家未感谢的 {playerID:[tagDBAssistThanks, ...], ...}
 | 
 |  |  |         self.assistPlayerThanksDict = {} # 协助玩家未接受感谢的协助 {assistPlayerID:[tagDBAssistThanks, ...], ...}
 | 
 |  |  |         return
 | 
 |  |  |      | 
 |  |  |     # 保存数据 存数据库和realtimebackup
 | 
 |  |  |     def GetSaveData(self):
 | 
 |  |  |         savaData = ""
 | 
 |  |  |         cntData = ""
 | 
 |  |  |         cnt = 0
 | 
 |  |  |          | 
 |  |  |         for dbData in self.allAssistThanksList:
 | 
 |  |  |             cnt += 1
 | 
 |  |  |             PlayerAssist.OnSaveAssistThanksData(dbData)
 | 
 |  |  |             savaData += dbData.getBuffer()
 | 
 |  |  |              | 
 |  |  |         GameWorld.Log("Save DBAssistThanks count :%s len=%s" % (cnt, len(savaData)))
 | 
 |  |  |         return CommFunc.WriteDWORD(cntData, cnt) + savaData
 | 
 |  |  |      | 
 |  |  |     # 从数据库载入数据
 | 
 |  |  |     def LoadPyGameData(self, datas, pos, dataslen):
 | 
 |  |  |         cnt, pos = CommFunc.ReadDWORD(datas, pos)
 | 
 |  |  |         GameWorld.Log("Load DBAssistThanks count :%s" % cnt)
 | 
 |  |  |          | 
 |  |  |         for _ in xrange(cnt):
 | 
 |  |  |             dbData = PyGameDataStruct.tagDBAssistThanks()
 | 
 |  |  |             dbData.clear()
 | 
 |  |  |             pos += dbData.readData(datas, pos, dataslen)
 | 
 |  |  |             PlayerAssist.OnInitAssistThanksData(self, dbData)
 | 
 |  |  |              | 
 |  |  |         return pos
 | 
 |  |  |      | 
 |  |  | #协助表
 | 
 |  |  | class PlayerAssistPyManager(object):
 | 
 |  |  |      | 
 |  |  |     def __init__(self):
 | 
 |  |  |         self.allAssistDict = {} # 所有协助 {GUID:tagDBAssist, ...}
 | 
 |  |  |         self.familyAssistDict = {} # 仙盟协助缓存 {familyID:[tagDBAssist, ...], ...}
 | 
 |  |  |          | 
 |  |  |         self.playerNoSaveDBAssistDict = {} # 玩家发布的不存库协助 {playerID:[tagDBAssist, ...], ...}
 | 
 |  |  |         self.playerAssistingDict = {} # 玩家正在协助中的协助,只能存在一条 {playerID:tagDBAssist, ...}
 | 
 |  |  |         return
 | 
 |  |  |      | 
 |  |  |     # 保存数据 存数据库和realtimebackup
 | 
 |  |  |     def GetSaveData(self):
 | 
 |  |  |         savaData = ""
 | 
 |  |  |         cntData = ""
 | 
 |  |  |         cnt = 0
 | 
 |  |  |          | 
 |  |  |         for dbData in self.allAssistDict.values():
 | 
 |  |  |             if not dbData.IsSaveDB:
 | 
 |  |  |                 continue
 | 
 |  |  |             cnt += 1
 | 
 |  |  |             savaData += dbData.getBuffer()
 | 
 |  |  |              | 
 |  |  |         GameWorld.Log("Save DBAssist count :%s len=%s" % (cnt, len(savaData)))
 | 
 |  |  |         return CommFunc.WriteDWORD(cntData, cnt) + savaData
 | 
 |  |  |      | 
 |  |  |     # 从数据库载入数据
 | 
 |  |  |     def LoadPyGameData(self, datas, pos, dataslen):
 | 
 |  |  |         cnt, pos = CommFunc.ReadDWORD(datas, pos)
 | 
 |  |  |         GameWorld.Log("Load DBAssist count :%s" % cnt)
 | 
 |  |  |          | 
 |  |  |         for _ in xrange(cnt):
 | 
 |  |  |             dbData = PyGameDataStruct.tagDBAssist()
 | 
 |  |  |             dbData.clear()
 | 
 |  |  |             pos += dbData.readData(datas, pos, dataslen)
 | 
 |  |  |              | 
 |  |  |             PlayerAssist.OnInitAssistData(dbData, 1)
 | 
 |  |  |              | 
 |  |  |             self.allAssistDict[dbData.GUID] = dbData
 | 
 |  |  |             familyID = dbData.FamilyID
 | 
 |  |  |             if familyID not in self.familyAssistDict:
 | 
 |  |  |                 self.familyAssistDict[familyID] = []
 | 
 |  |  |             familyAssistList = self.familyAssistDict[familyID]
 | 
 |  |  |             familyAssistList.append(dbData)
 | 
 |  |  |              | 
 |  |  |         return pos
 | 
 |  |  |      | 
 |  |  | #玩家缓存管理,该类只做数据缓存存取,不写功能逻辑,防止重读脚本时功能逻辑脚本不生效
 | 
 |  |  | class PlayerViewCachePyManager(object):
 | 
 |  |  |     
 | 
 |  |  | 
 |  |  |             cnt += 1
 | 
 |  |  |             savaData += dbData.getBuffer()
 | 
 |  |  |             
 | 
 |  |  |         GameWorld.Log("Save PlayerViewCachePy count :%s" % cnt)
 | 
 |  |  |         GameWorld.Log("Save PlayerViewCachePy count :%s len=%s" % (cnt, len(savaData)))
 | 
 |  |  |         return CommFunc.WriteDWORD(cntData, cnt) + savaData
 | 
 |  |  |     
 | 
 |  |  |     # 从数据库载入数据
 | 
 |  |  | 
 |  |  |         cntData = ""
 | 
 |  |  |         cnt = 0
 | 
 |  |  |         
 | 
 |  |  |         unSaveCnt = 0
 | 
 |  |  |         curTime = int(time.time())
 | 
 |  |  |         vaildSeconds = IpyGameDataPY.GetFuncCfg("AuctionHouse", 1) * 3600 * 24
 | 
 |  |  |         for recordDict in [self.myAuctionItemRecordDict, self.myBidItemRecordDict, self.familyAuctionItemRecordDict]:
 | 
 |  |  |             for recordList in recordDict.values():
 | 
 |  |  |                 for dbData in recordList:
 | 
 |  |  |                     if vaildSeconds:
 | 
 |  |  |                         recordTime = GameWorld.ChangeTimeStrToNum(dbData.RecordTime)
 | 
 |  |  |                         if curTime - recordTime > vaildSeconds:
 | 
 |  |  |                             unSaveCnt += 1
 | 
 |  |  |                             continue
 | 
 |  |  |                     cnt += 1
 | 
 |  |  |                     savaData += dbData.getBuffer()
 | 
 |  |  |                     
 | 
 |  |  |         GameWorld.Log("Save AuctionRecord count :%s" % cnt)
 | 
 |  |  |         GameWorld.Log("Save AuctionRecord count :%s len=%s unSaveCnt=%s" % (cnt, len(savaData), unSaveCnt))
 | 
 |  |  |         return CommFunc.WriteDWORD(cntData, cnt) + savaData
 | 
 |  |  |     
 | 
 |  |  |     # 从数据库载入数据
 | 
 |  |  | 
 |  |  |             cnt += 1
 | 
 |  |  |             savaData += dbData.getBuffer()
 | 
 |  |  |             
 | 
 |  |  |         GameWorld.Log("Save AuctionAttention count :%s" % cnt)
 | 
 |  |  |         GameWorld.Log("Save AuctionAttention count :%s len=%s" % (cnt, len(savaData)))
 | 
 |  |  |         return CommFunc.WriteDWORD(cntData, cnt) + savaData
 | 
 |  |  |     
 | 
 |  |  |     # 从数据库载入数据
 | 
 |  |  | 
 |  |  |     
 | 
 |  |  |     def __InitAuctionAttentionAttrEx(self, attentionData):
 | 
 |  |  |         ## 初始化拍卖关注实例附加属性
 | 
 |  |  |         setattr(attentionData, "AttentionItemIDList", [] if not attentionData.AttentionInfo else eval(attentionData.AttentionInfo))
 | 
 |  |  |         setattr(attentionData, "AttentionItemIDList", [])
 | 
 |  |  |         if attentionData.AttentionInfo.startswith("[") and attentionData.AttentionInfo.endswith("]"):
 | 
 |  |  |             attentionData.AttentionItemIDList = eval(attentionData.AttentionInfo)
 | 
 |  |  |         return
 | 
 |  |  |     
 | 
 |  |  | #拍卖物品数据缓存,该类只做数据缓存存取,不写功能逻辑,防止重读脚本时功能逻辑脚本不生效
 | 
 |  |  | 
 |  |  |         self.worldAuctionItemList = [] # 全服拍品列表缓存 [tagDBAuctionItem, ...]
 | 
 |  |  |         self.worldAuctionItemQueryDict = {} # 全服拍品过滤查询缓存,添加拍品时重置 {(job, (itemType, ...), itemClassLV, (itemID, ...)):[tagDBAuctionItem, ...], ...}
 | 
 |  |  |         self.familyAuctionItemDict = {} # 仙盟拍品列表缓存,包含转移到全服的仙盟拍品 {familyID:[tagDBAuctionItem, ...], ...}
 | 
 |  |  |         self.sysBuyoutItemByTimeList = [] # 系统一口价拍品按时间排序缓存 [tagDBAuctionItem, ...]
 | 
 |  |  |         
 | 
 |  |  |         self.nowBiddingAuctionItemDict = {} # 玩家当前是最高竞价的拍品,含所有拍品 {playerID:[tagDBAuctionItem, ...], ...}
 | 
 |  |  |         self.hisBiddingAuctionItemDict = {} # 玩家曾经参与过竞价的拍品,含所有拍品 {playerID:[tagDBAuctionItem, ...], ...}
 | 
 |  |  |         self.myAuctionItemDict = {} # 玩家拍卖中的物品 ,不包含仙盟拍品,由前端界面自行整合数据 {playerID:[tagDBAuctionItem, ...], ...}
 | 
 |  |  |         self.myAttentionItemDict = {} # 玩家关注中的物品 ,不包含仙盟拍品,由前端界面自行整合数据,只保存在线的玩家,离线清除,上线不同步,由前端查询 {playerID:[tagDBAuctionItem, ...], ...}
 | 
 |  |  |          | 
 |  |  |         self.worldAuctionItemCountDict = {} # 全服拍品物品ID对应件数统计 {itemID:件数, ...}
 | 
 |  |  |         self.worldAuctionJobEquipCountDict = {} # 全服拍品职业装备对应件数统计 {(职业,阶,颜色,是否套装):件数, ...}
 | 
 |  |  |         self.worldAuctionReplenishTimeDict = {} # 全服拍品动态上架历史处理时间 {cfgID:time, ...}
 | 
 |  |  |         return
 | 
 |  |  |     
 | 
 |  |  |     # 保存数据 存数据库和realtimebackup
 | 
 |  |  | 
 |  |  |             cnt += 1
 | 
 |  |  |             savaData += dbData.getBuffer()
 | 
 |  |  |             
 | 
 |  |  |         GameWorld.Log("Save AuctionItem count :%s" % cnt)
 | 
 |  |  |         GameWorld.Log("Save AuctionItem count :%s len=%s" % (cnt, len(savaData)))
 | 
 |  |  |         return CommFunc.WriteDWORD(cntData, cnt) + savaData
 | 
 |  |  |     
 | 
 |  |  |     # 从数据库载入数据
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  | class PyGameDataManager(object):
 | 
 |  |  |     def __init__(self):
 | 
 |  |  |         self.DBPyCoupleManager = PlayerLove.DBPyCoupleManager()
 | 
 |  |  |         self.DBPyUnNotifyLoveGiftRecManager = PlayerLove.DBPyUnNotifyLoveGiftRecManager()
 | 
 |  |  |         self.DBPyCharmValueRecManager = PlayerCharm.DBPyCharmValueRecManager()
 | 
 |  |  |         self.IntimacyManager = PlayerSocial.IntimacyManager()
 | 
 |  |  |         self.CrossPersonalCompensationManager = PlayerCompensation.CrossPersonalCompensationManager()
 | 
 |  |  |         self.CrossBillboardManager = CrossBillboard.CrossBillboardManager()
 | 
 |  |  |         self.PlayerAssistThanksPyManager = PlayerAssistThanksPyManager()
 | 
 |  |  |         self.PlayerAssistPyManager = PlayerAssistPyManager()
 | 
 |  |  |         self.PlayerViewCachePyManager = PlayerViewCachePyManager()
 | 
 |  |  |         self.AuctionAttentionManager = AuctionAttentionManager()
 | 
 |  |  |         self.AuctionRecordManager = AuctionRecordManager()
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  |     def GetSaveData(self):
 | 
 |  |  |         buff = ""
 | 
 |  |  |         buff += self.DBPyCoupleManager.GetSaveData()
 | 
 |  |  |         buff += self.DBPyUnNotifyLoveGiftRecManager.GetSaveData()
 | 
 |  |  |         buff += self.DBPyCharmValueRecManager.GetSaveData()
 | 
 |  |  |         buff += self.IntimacyManager.GetSaveData()
 | 
 |  |  |         buff += self.CrossPersonalCompensationManager.GetSaveData()
 | 
 |  |  |         buff += self.CrossBillboardManager.GetSaveData()
 | 
 |  |  |         buff += self.PlayerAssistThanksPyManager.GetSaveData()
 | 
 |  |  |         buff += self.PlayerAssistPyManager.GetSaveData()
 | 
 |  |  |         buff += self.PlayerViewCachePyManager.GetSaveData()
 | 
 |  |  |         buff += self.AuctionAttentionManager.GetSaveData()
 | 
 |  |  |         buff += self.AuctionRecordManager.GetSaveData()
 | 
 |  |  | 
 |  |  |         return buff
 | 
 |  |  |     
 | 
 |  |  |     def LoadGameData(self, gameBuffer, pos):
 | 
 |  |  |         pos = self.DBPyCoupleManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.DBPyUnNotifyLoveGiftRecManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.DBPyCharmValueRecManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.IntimacyManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.CrossPersonalCompensationManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.CrossBillboardManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.PlayerAssistThanksPyManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.PlayerAssistPyManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.PlayerViewCachePyManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.AuctionAttentionManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  |         pos = self.AuctionRecordManager.LoadPyGameData(gameBuffer, pos, len(gameBuffer))
 | 
 |  |  | 
 |  |  |         pyGameDataMgr = PyGameDataManager()
 | 
 |  |  |         PyGameData.g_pyGameDataManager = pyGameDataMgr
 | 
 |  |  |     return pyGameDataMgr
 | 
 |  |  | 
 | 
 |  |  | def GetCrossPersonalCompensationManager():
 | 
 |  |  |     # 跨服个人补偿邮件管理
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.CrossPersonalCompensationManager
 | 
 |  |  | 
 | 
 |  |  | def GetCrossBillboardManager():
 | 
 |  |  |     # 跨服排行榜管理
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.CrossBillboardManager
 | 
 |  |  | 
 | 
 |  |  | def GetPlayerAssistThanksPyManager():
 | 
 |  |  |     # 协助感谢表
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.PlayerAssistThanksPyManager
 | 
 |  |  | 
 | 
 |  |  | def GetPlayerAssistPyManager():
 | 
 |  |  |     # 协助表
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.PlayerAssistPyManager
 | 
 |  |  | 
 | 
 |  |  | def GetPlayerViewCachePyManager():
 | 
 |  |  |     # 拍卖记录表
 | 
 |  |  | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.familyStoreItemManager
 | 
 |  |  | 
 | 
 |  |  | def GetDBPyCoupleManager():
 | 
 |  |  |     # 伴侣管理
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.DBPyCoupleManager
 | 
 |  |  | 
 | 
 |  |  | def GetDBPyUnNotifyLoveGiftRecManager():
 | 
 |  |  |     # 未通知的赠送礼物记录
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.DBPyUnNotifyLoveGiftRecManager
 | 
 |  |  | 
 | 
 |  |  | def GetDBPyCharmValueRecManager():
 | 
 |  |  |     # 魅力管理
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.DBPyCharmValueRecManager
 | 
 |  |  | 
 | 
 |  |  | def GetIntimacyManager():
 | 
 |  |  |     # 亲密管理
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 | 
 |  |  |     return pyGameDataMgr.IntimacyManager
 | 
 |  |  | 
 | 
 |  |  | # 好友系统
 | 
 |  |  | def GetFriendManager():
 | 
 |  |  |     pyGameDataMgr = GetPyGameDataManager()
 |