From f617d71ec6795493a67b0042ffbecd126e47b9fb Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 18 二月 2025 15:16:34 +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 6a0e5ab..ec0e7d4 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
@@ -8193,6 +8193,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 1fdc316..89affc0 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -34174,7 +34174,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 40f70c7..32db37c 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
@@ -120,7 +120,7 @@
Writer = wdb
Releaser = wdb
RegType = 0
-RegisterPackCount = 3
+RegisterPackCount = 4
PacketCMD_1=0xA2
PacketSubCMD_1=0x01
@@ -134,6 +134,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 6a0e5ab..ec0e7d4 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
@@ -8193,6 +8193,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 1fdc316..89affc0 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -34174,7 +34174,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 373e88d..5af1bcb 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