|  |  |  | 
|---|
|  |  |  | import PyGameData | 
|---|
|  |  |  | import CrossRealmPK | 
|---|
|  |  |  | import AuctionHouse | 
|---|
|  |  |  | import PlayerAssist | 
|---|
|  |  |  | import PyGameDataStruct | 
|---|
|  |  |  | import CommFunc | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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" % cnt) | 
|---|
|  |  |  | 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" % cnt) | 
|---|
|  |  |  | 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): | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | class PyGameDataManager(object): | 
|---|
|  |  |  | def __init__(self): | 
|---|
|  |  |  | self.PlayerAssistThanksPyManager = PlayerAssistThanksPyManager() | 
|---|
|  |  |  | self.PlayerAssistPyManager = PlayerAssistPyManager() | 
|---|
|  |  |  | self.PlayerViewCachePyManager = PlayerViewCachePyManager() | 
|---|
|  |  |  | self.AuctionAttentionManager = AuctionAttentionManager() | 
|---|
|  |  |  | self.AuctionRecordManager = AuctionRecordManager() | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def GetSaveData(self): | 
|---|
|  |  |  | buff = "" | 
|---|
|  |  |  | 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.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)) | 
|---|
|  |  |  | 
|---|
|  |  |  | PyGameData.g_pyGameDataManager = pyGameDataMgr | 
|---|
|  |  |  | return pyGameDataMgr | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def GetPlayerAssistThanksPyManager(): | 
|---|
|  |  |  | # 协助感谢表 | 
|---|
|  |  |  | pyGameDataMgr = GetPyGameDataManager() | 
|---|
|  |  |  | return pyGameDataMgr.PlayerAssistThanksPyManager | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def GetPlayerAssistPyManager(): | 
|---|
|  |  |  | # 协助表 | 
|---|
|  |  |  | pyGameDataMgr = GetPyGameDataManager() | 
|---|
|  |  |  | return pyGameDataMgr.PlayerAssistPyManager | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def GetPlayerViewCachePyManager(): | 
|---|
|  |  |  | # 拍卖记录表 | 
|---|
|  |  |  | pyGameDataMgr = GetPyGameDataManager() | 
|---|