From 2941a7635bb04ca59afa820b51a23aca9dc70eb9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 29 十月 2019 11:59:23 +0800
Subject: [PATCH] 4610 【恺英】【bug】脱机上线报错

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerStore.py |   78 +++++++++++++++++++++++++++++----------
 1 files changed, 58 insertions(+), 20 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerStore.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerStore.py
index c425e21..547c164 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerStore.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerStore.py
@@ -18,10 +18,11 @@
 """Version = 2018-10-09 17:00"""
 
 import GameWorld
-import PlayerUniversalGameRec
 import ShareDefine
 import PlayerControl
 import IpyGameDataPY
+import ChPyNetSendPack
+import NetPackCommon
 
 RecType = ShareDefine.Def_UniversalGameRecType_StoreServerCntRecord
 
@@ -29,7 +30,7 @@
 #  @param None
 #  @return None
 def OnPlayerLogin(curPlayer):
-    PlayerUniversalGameRec.SendUniversalGameRecInfo(curPlayer, RecType)
+    SyncStoreServerBuyInfo(curPlayer)
     return
 
 
@@ -61,17 +62,10 @@
     if not findRecData:
         findRecData = recTypeListData.AddRec()
         findRecData.SetValue1(goodsID)
-    findRecData.SetValue2(curGotCnt+buyCount)
+    newBuyCnt = curGotCnt+buyCount
+    findRecData.SetValue2(newBuyCnt)
     #通知
-    playerManager = GameWorld.GetPlayerManager()
-    for i in xrange(playerManager.GetActivePlayerCount()):
-        curPlayer = playerManager.GetActivePlayerAt(i)
-        if curPlayer == None or not curPlayer.GetInitOK():
-            continue
-        if PlayerControl.GetIsTJG(curPlayer):
-            continue
-        PlayerUniversalGameRec.SendUniversalGameRecSingle(curPlayer, findRecData)
-    
+    SyncStoreServerBuyInfo(None, {goodsID:newBuyCnt})
     return msgList
 
 def DoResetStoreServerBuyCnt(shopTypeList):
@@ -80,6 +74,7 @@
     recTypeListData = universalRecMgr.GetTypeList(RecType)
     
     delCnt = 0
+    syncDict = {}
     for index in xrange(recTypeListData.Count()):
         dataIndex = index - delCnt
         recData = recTypeListData.At(dataIndex)
@@ -89,20 +84,63 @@
             continue
         if ipyData.GetShopType() not in shopTypeList:
             continue
+        syncDict[curGoodsID] = 0
         recTypeListData.Delete(dataIndex)
         delCnt +=1
+        
     GameWorld.DebugLog('    根据商店类型重置全服购买次数 shopTypeList=%s'%shopTypeList)
     if delCnt:
-        PlayerUniversalGameRec.SendUniversalGameRecInfo(None, RecType)
+        SyncStoreServerBuyInfo(None, syncDict)
+        
     return
 
 
-def ResetFlashSaleBuyCnt(ipyData, dayIndex, state):
+def ResetFlashSaleBuyCnt(ipyData):
     #重置限时抢购商店全服购买次数
-    if state == 0:
-        return
-    shopTypeList = ipyData.GetShopTypeList()
-    dayShopList = shopTypeList[dayIndex] if dayIndex < len(shopTypeList) else shopTypeList[-1]
-    shopType = dayShopList[state-1] if state-1 < len(dayShopList) else dayShopList[-1]
-    DoResetStoreServerBuyCnt([shopType])
+    dayShopRangeDict = ipyData.GetShopTypeList()
+    
+    resetTypeList = []
+    for shopTypeList in dayShopRangeDict.values():
+        for dayShopList in shopTypeList:
+            for shopType in dayShopList:
+                if shopType not in resetTypeList:
+                    resetTypeList.append(shopType)
+    if resetTypeList:
+        DoResetStoreServerBuyCnt(resetTypeList)
+    return
+
+def SyncStoreServerBuyInfo(curPlayer, syncCntDict={}):
+    #通知商品全服购买次数
+    sendPack = ChPyNetSendPack.tagGCStoreServerBuyCntInfo()
+    sendPack.Clear()
+    sendPack.InfoList = []
+    if syncCntDict:
+        for goodsID, buyCnt in syncCntDict.items():
+            buyInfo = ChPyNetSendPack.tagGCStoreServerBuyCnt()
+            buyInfo.GoodsID = goodsID
+            buyInfo.BuyCnt = buyCnt
+            sendPack.InfoList.append(buyInfo)
+    else:
+        universalRecMgr = GameWorld.GetUniversalRecMgr()
+        recTypeListData = universalRecMgr.GetTypeList(RecType)
+        for index in xrange(recTypeListData.Count()):
+            recData = recTypeListData.At(index)
+            buyInfo = ChPyNetSendPack.tagGCStoreServerBuyCnt()
+            buyInfo.GoodsID = recData.GetValue1()
+            buyInfo.BuyCnt = recData.GetValue2()
+            sendPack.InfoList.append(buyInfo)
+    sendPack.Count = len(sendPack.InfoList)
+    if not curPlayer:
+        playerManager = GameWorld.GetPlayerManager()
+        for i in xrange(playerManager.GetActivePlayerCount()):
+            curPlayer = playerManager.GetActivePlayerAt(i)
+            if curPlayer == None or not curPlayer.GetInitOK():
+                continue
+            if PlayerControl.GetIsTJG(curPlayer):
+                continue
+            NetPackCommon.SendFakePack(curPlayer, sendPack)
+    else:
+        if PlayerControl.GetIsTJG(curPlayer):
+            return
+        NetPackCommon.SendFakePack(curPlayer, sendPack)
     return
\ No newline at end of file

--
Gitblit v1.8.0