From ec0c49a3aefe5ca4b8af494366bb0b8141d34a32 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 18 二月 2025 15:18:36 +0800
Subject: [PATCH] 10393 2月11-14版本更新(商店限购改DWORD)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py |   49 ++++++++++------
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini                              |    6 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py                      |   56 ++++++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py                  |    2 
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py                                           |   56 ++++++++++++++++++
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py                                       |    2 
 6 files changed, 150 insertions(+), 21 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
index 43f9ef3..2163321 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
@@ -8189,6 +8189,62 @@
 
 
 #------------------------------------------------------
+# A3 10 购买商城物品 #tagCMBuyItem
+
+class  tagCMBuyItem(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ("BuyItemIndex", c_ushort),    #购买的物品索引
+                  ("BuyCount", c_int),    #购买数量
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xA3
+        self.SubCmd = 0x10
+        return
+
+    def ReadData(self, stringData, _pos=0, _len=0):
+        self.Clear()
+        memmove(addressof(self), stringData[_pos:], self.GetLength())
+        return _pos + self.GetLength()
+
+    def Clear(self):
+        self.Cmd = 0xA3
+        self.SubCmd = 0x10
+        self.BuyItemIndex = 0
+        self.BuyCount = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagCMBuyItem)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// A3 10 购买商城物品 //tagCMBuyItem:
+                                Cmd:%s,
+                                SubCmd:%s,
+                                BuyItemIndex:%d,
+                                BuyCount:%d
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd,
+                                self.BuyItemIndex,
+                                self.BuyCount
+                                )
+        return DumpString
+
+
+m_NAtagCMBuyItem=tagCMBuyItem()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMBuyItem.Cmd,m_NAtagCMBuyItem.SubCmd))] = m_NAtagCMBuyItem
+
+
+#------------------------------------------------------
 # A3 07 过期物品续费 #tagCMItemRenew
 
 class  tagCMItemRenew(Structure):
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index c22dd73..7e4aa29 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -34126,7 +34126,7 @@
     _pack_ = 1
     _fields_ = [
                   ("ItemIndex", c_int),    
-                  ("BuyCnt", c_ushort),    # 今日已购买次数
+                  ("BuyCnt", c_int),    # 今日已购买次数
                   ("IsReset", c_ubyte),    #是否重置
                   ]
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
index 044f571..e0d8210 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
@@ -108,7 +108,7 @@
 Writer = wdb
 Releaser = wdb
 RegType = 0
-RegisterPackCount = 3
+RegisterPackCount = 4
 
 PacketCMD_1=0xA2
 PacketSubCMD_1=0x01
@@ -122,6 +122,10 @@
 PacketSubCMD_3=0x32
 PacketCallFunc_3=OnMysticalShopRefresh
 
+PacketCMD_4=0xA3
+PacketSubCMD_4=0x10
+PacketCallFunc_4=PyBuyItem
+
 ;物品管理
 [ItemControler]
 ScriptName = Item\ItemControler.py
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
index 43f9ef3..2163321 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
@@ -8189,6 +8189,62 @@
 
 
 #------------------------------------------------------
+# A3 10 购买商城物品 #tagCMBuyItem
+
+class  tagCMBuyItem(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ("BuyItemIndex", c_ushort),    #购买的物品索引
+                  ("BuyCount", c_int),    #购买数量
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xA3
+        self.SubCmd = 0x10
+        return
+
+    def ReadData(self, stringData, _pos=0, _len=0):
+        self.Clear()
+        memmove(addressof(self), stringData[_pos:], self.GetLength())
+        return _pos + self.GetLength()
+
+    def Clear(self):
+        self.Cmd = 0xA3
+        self.SubCmd = 0x10
+        self.BuyItemIndex = 0
+        self.BuyCount = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagCMBuyItem)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// A3 10 购买商城物品 //tagCMBuyItem:
+                                Cmd:%s,
+                                SubCmd:%s,
+                                BuyItemIndex:%d,
+                                BuyCount:%d
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd,
+                                self.BuyItemIndex,
+                                self.BuyCount
+                                )
+        return DumpString
+
+
+m_NAtagCMBuyItem=tagCMBuyItem()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMBuyItem.Cmd,m_NAtagCMBuyItem.SubCmd))] = m_NAtagCMBuyItem
+
+
+#------------------------------------------------------
 # A3 07 过期物品续费 #tagCMItemRenew
 
 class  tagCMItemRenew(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index c22dd73..7e4aa29 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -34126,7 +34126,7 @@
     _pack_ = 1
     _fields_ = [
                   ("ItemIndex", c_int),    
-                  ("BuyCnt", c_ushort),    # 今日已购买次数
+                  ("BuyCnt", c_int),    # 今日已购买次数
                   ("IsReset", c_ubyte),    #是否重置
                   ]
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
index c55c792..7b0ba44 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
@@ -604,24 +604,38 @@
         
     return True
 
+#// A3 10 购买商城物品 #tagCMBuyItem
+#
+#struct    tagCMBuyItem
+#{
+#    tagHead        Head;
+#    WORD        BuyItemIndex;        //购买的物品索引
+#    DWORD        BuyCount;        //购买数量
+#};
+def PyBuyItem(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    itemIndex = clientData.BuyItemIndex
+    buyCount = clientData.BuyCount
+    OnBuyItem(curPlayer, itemIndex, buyCount)
+    return
+
 ##购买物品
 # @param curPlayer 玩家实例
 # @param tick 时间戳
 # @return 返回值真, 逻辑运行成功
 def BuyItem(curPlayer, tick):
-    
-    if GameWorld.IsCrossServer():
-        return
-    
     buyItemList = IPY_GameWorld.IPY_CBuyItemList()    
     itemIndex = buyItemList.GetBuyItemIndex()
-    if itemIndex < 0:
-        return
-    
     clientBuyCount = buyItemList.GetBuyCount()
-    if not clientBuyCount:
+    OnBuyItem(curPlayer, itemIndex, clientBuyCount)
+    return
+
+def OnBuyItem(curPlayer, itemIndex, clientBuyCount):
+    GameWorld.DebugLog("购买商城物品: itemIndex=%s,clientBuyCount=%s" % (itemIndex, clientBuyCount), curPlayer.GetPlayerID())
+    if GameWorld.IsCrossServer():
         return
-    
+    if itemIndex < 0 or clientBuyCount <= 0:
+        return
     ipyData = IpyGameDataPY.GetIpyGameData("Store", itemIndex)
     if not ipyData:
         return
@@ -775,27 +789,26 @@
     if limitBuyCnt > 0:
         dayBuyCntKey = ChConfig.Def_PDict_ShopItemDayBuyCnt % itemIndex
         curDayBuyCnt = curPlayer.NomalDictGetProperty(dayBuyCntKey)
-        PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, curDayBuyCnt + clientBuyCount)
+        updDayBuyCnt = min(curDayBuyCnt + clientBuyCount, ChConfig.Def_UpperLimit_DWord)
+        PlayerControl.NomalDictSetProperty(curPlayer, dayBuyCntKey, updDayBuyCnt)
+        GameWorld.DebugLog("更新商城物品限购次数: itemIndex=%s,curDayBuyCnt=%s,clientBuyCount=%s,updDayBuyCnt=%s/%s" 
+                           % (itemIndex, curDayBuyCnt, clientBuyCount, updDayBuyCnt, limitBuyCnt), curPlayer.GetPlayerID())
         SyncShopItemTodayBuyCount(curPlayer, [itemIndex])
         
     dataDict = {"ShopType":shopType, "ShopItemIndex":itemIndex, "ClientBuyCount":clientBuyCount, 
                 "ItemPrice":itemPrice, "MoneyType":priceType, 
                 "BeforeMoney":beforeMoney, "AfterMoney":afterMoney}
     isForceEvent = priceType not in [IPY_GameWorld.TYPE_Price_Silver_Money]
-
-    itemControl = ItemControler.PlayerItemControler(curPlayer)
+    
     for itemID, itemCount, isBind in totalItemList:
         curItemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, False, curPlayer=curPlayer)
         if not curItemObj:
             continue
         userData = curItemObj.GetUserData()
+        curItemObj.Clear()
         if not sendMailKey:
-            packType = ChConfig.GetItemPackType(curItemObj)
-            if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
-                curItemObj.Clear()
-                continue
-        else:
-            curItemObj.Clear()
+            if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
+                GameWorld.ErrLog("购买商城物品放入背包失败! itemID=%s, itemCount=%s" % (itemID, itemCount), curPlayer.GetPlayerID())
         EventShell.EventRespons_BuyItem(curPlayer, itemID, itemCount)
         
         if ipyData.GetNotifyMark() and itemID == mainItemID:

--
Gitblit v1.8.0