From 875d928db2370eaaa6a43bf01d0761d7939dab5f Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期六, 13 十月 2018 17:14:42 +0800
Subject: [PATCH] 4064 【后端】【主干】直接给玩家的货币类物品优化处理; 2094 邮件发放神兽装备,神兽背包空间不足逻辑错误;
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py | 6 +-
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py | 67 +++++++++++++++++++++++----------
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCompensationTube.py | 28 +++++---------
3 files changed, 59 insertions(+), 42 deletions(-)
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 6774b4b..11882e1 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
@@ -440,8 +440,8 @@
if not curItem:
GameWorld.ErrLog("Store shop item error! shopType=%s,itemID=%s" % (shopType, itemID))
return
- packType = ShareDefine.rptRune if curItem.GetType() == ChConfig.Def_ItemType_Rune else IPY_GameWorld.rptItem
- needSpace = int(math.ceil(float(itemCnt) / curItem.GetPackCount()))
+ packType = ChConfig.GetItemPackType(curItem.GetType())
+ needSpace = ItemControler.GetItemNeedPackCount(packType, curItem, itemCnt)
needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
if i == 0:
@@ -515,7 +515,7 @@
if not curItemObj:
continue
userData = curItemObj.GetUserData()
- packType = ShareDefine.rptRune if curItemObj.GetType() == ChConfig.Def_ItemType_Rune else IPY_GameWorld.rptItem
+ packType = ChConfig.GetItemPackType(curItemObj.GetType())
if not itemControl.PutInItem(packType, curItemObj, event=[ChConfig.ItemGive_BuyItem, isForceEvent, dataDict]):
curItemObj.Clear()
continue
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
index 39200a5..7f1b375 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
@@ -35,6 +35,7 @@
import IpyGameDataPY
import EventShell
+import math
#---------------------------------------------------------------------
## 放不下主角背包放入万能背包的逻辑, curGiveItem 要先 SetCount
# @param curPlayer 当前玩家
@@ -1087,10 +1088,6 @@
def PutInItem(self, packIndex, tagItem, defaultPile=True, event=["", False, {}]):
curPlayer = self.__Player
- if packIndex != ShareDefine.rptTreasure and self.DoTransformItem(curPlayer, tagItem):
- tagItem.Clear() # 需清除,不然会导致内存泄露 寻宝仓库可暂存直接转化数值的物品
- return True
-
isEquip = ItemCommon.CheckItemIsEquip(tagItem)
if isEquip:
defaultPile = False # 装备默认不判断堆叠
@@ -1101,11 +1098,23 @@
packIndex = ChConfig.GetItemPackType(curItemData.GetType(), packIndex)
- if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), tagItem.GetCount(), tagItem.GetIsBind(), defaultPile):
- GameWorld.DebugLog("背包满,不能放入物品 count = %d"%tagItem.GetCount())
+ if not self.CanPutInItem(packIndex, tagItem.GetItemTypeID(), GetItemCount(tagItem), tagItem.GetIsBind(), defaultPile):
+ GameWorld.DebugLog("背包满,不能放入物品 count = %d"%GetItemCount(tagItem))
tagItem.Clear()
return False
+ itemID = tagItem.GetItemTypeID()
+ if itemID in ChConfig.Def_TransformItemIDList:
+ # 直接转化为对应货币的物品仅在放入背包时直接转化,否则还是以真实物品的形式存在,但堆叠上限需要做特殊处理
+ if packIndex == IPY_GameWorld.rptItem:
+ self.DoTransformItem(curPlayer, tagItem)
+ tagItem.Clear() # 需清除,不然会导致内存泄露
+ return True
+ defaultPile = True
+ maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
+ else:
+ maxPackCount = curItemData.GetPackCount()
+
# 虚拟背包, 默认不做叠加
if packIndex in ShareDefine.Def_VPack_TypeList:
return self.PutItemInVPack(packIndex, tagItem, event)
@@ -1141,9 +1150,9 @@
if item.GetIsLocked() == True:
continue
- packItemCount = item.GetCount()
- curItemCount = tagItem.GetCount()
- canPutinCount = tagItem.GetPackCount() - packItemCount
+ packItemCount = GetItemCount(item)
+ curItemCount = GetItemCount(tagItem)
+ canPutinCount = maxPackCount - packItemCount
if canPutinCount <= 0:
continue
#可以摆放
@@ -1179,9 +1188,9 @@
if item.IsEmpty() != True:
continue
- packItemCount = item.GetCount() # 为0
- curItemCount = tagItem.GetCount()
- canPutinCount = tagItem.GetPackCount() - packItemCount
+ packItemCount = GetItemCount(item) # 为0
+ curItemCount = GetItemCount(tagItem)
+ canPutinCount = maxPackCount - packItemCount
if canPutinCount <= 0:
continue
#可以摆放
@@ -1213,7 +1222,7 @@
putResult = True
if isNeedRecord:
- itemNoteDict = ItemCommon.GetItemNoteDict(item, curItemCount, packItemCount, item.GetCount())
+ itemNoteDict = ItemCommon.GetItemNoteDict(item, curItemCount, packItemCount, GetItemCount(item))
ItemCommon.DR_GetItem(curPlayer, packIndex, eventName, itemNoteDict, addDict)
break
@@ -1294,11 +1303,13 @@
return False, 0
if curItemID in ChConfig.Def_TransformItemIDList:
- #特殊物品无需判断数量
- return True, 0
-
- maxPackCount = curItemData.GetPackCount()
-
+ # 货币直接转换的物品如果是放入背包的则直接转化,无需暂用格子
+ if packIndex == IPY_GameWorld.rptItem:
+ return True, 0
+ maxPackCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的, 暂定堆叠上限20亿
+ else:
+ maxPackCount = curItemData.GetPackCount()
+
if maxPackCount == 0:
GameWorld.Log("策划填表错误 %s -> maxPackCount = %s" % (curItemID , maxPackCount))
return False, 0
@@ -1322,7 +1333,7 @@
itemIndex = -1
curPack = self.__PlayerItemManager.GetPack(packIndex)
- for i in range(0, curPack.GetCount()):
+ for i in xrange(curPack.GetCount()):
item = curPack.GetAt(i)
if item.IsEmpty():
@@ -1336,10 +1347,10 @@
continue
if (CanPackItemByItemType(item.GetItemTypeID(), item.GetIsBind(), curItemID, isBind) and
- maxPackCount > item.GetCount()):
+ maxPackCount > GetItemCount(item)):
#该物品锁定不执行==============================================
#可堆叠
- maxCanPutItem += maxPackCount - item.GetCount()
+ maxCanPutItem += maxPackCount - GetItemCount(item)
if itemIndex == -1:
itemIndex = i
@@ -2208,7 +2219,21 @@
errorInfo = "%s %s %s -- ItemControler->SetItemCount::" % (playerID, accID, playerName)
GameWorld.ErrLog(errorInfo + str(traceback.extract_stack()) + "\n" + traceback.format_exc())
raise
+
+def GetItemCount(item):
+ if item.GetItemTypeID() in ChConfig.Def_TransformItemIDList:
+ return item.GetUserAttr(ShareDefine.Def_IudetItemCount)
+ return item.GetCount()
+def GetItemNeedPackCount(packType, itemData, itemCount):
+ if itemData.GetItemTypeID() in ChConfig.Def_TransformItemIDList:
+ # 货币直接转换的物品如果是放入背包的则不需要暂用格子,放入其他的背包的则按物品叠加上限算
+ if packType == IPY_GameWorld.rptItem:
+ return 0
+ packCount = ChConfig.Def_UpperLimit_DWord # 转化物品叠加上限不取物品表的
+ else:
+ packCount = itemData.GetPackCount()
+ return int(math.ceil(itemCount / float(packCount)))
## 双手武器,需要两只手才拿得动
# @param curEquip
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCompensationTube.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCompensationTube.py
index 3d9dc44..3a508cc 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCompensationTube.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCompensationTube.py
@@ -68,9 +68,8 @@
GameWorld.DebugLog(" PlayerID %s no found "%curPackData.PlayerID)
return
+ needPackSpaceDict = {}
isPackSpaceEnough = True
- commPackItemCount = 0 # 常规背包物品个数
- RuneItemCount = 0 # 符印物品个数
# 先汇总物品所属背包
for i in xrange(curPackData.Count):
curPackItem = curPackData.Items[i]
@@ -78,24 +77,17 @@
curItemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
if not curItemData:
continue
- if curItemData.GetType() in [ChConfig.Def_ItemType_Rune, ChConfig.Def_ItemType_RuneExp]:
- RuneItemCount += curPackItem.Count
- else:
- commPackItemCount += 1
+
+ packType = ChConfig.GetItemPackType(curItemData.GetType())
+ needSpace = ItemControler.GetItemNeedPackCount(packType, curItemData, curPackItem.Count)
+ needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
- if isPackSpaceEnough and RuneItemCount > 0:
- packSpace = ItemCommon.GetItemPackSpace(curPlayer, ShareDefine.rptRune, RuneItemCount)
- if packSpace < RuneItemCount:
+ GameWorld.DebugLog(" needPackSpaceDict=%s" % str(needPackSpaceDict))
+ for packType, needSpace in needPackSpaceDict.items():
+ if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):
+ PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
isPackSpaceEnough = False
- GameWorld.DebugLog(" 符印背包空间不足, RuneItemCount=%s > packSpace=%s" % (RuneItemCount, packSpace))
- PlayerControl.NotifyCode(curPlayer, "RuneBagFull")
-
- if isPackSpaceEnough and commPackItemCount > 0:
- itemPackSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, commPackItemCount)
- if itemPackSpace < commPackItemCount:
- isPackSpaceEnough = False
- GameWorld.DebugLog(" 背包空间不足, commPackItemCount=%s > itemPackSpace=%s" % (commPackItemCount, itemPackSpace))
- PlayerControl.NotifyCode(curPlayer, "BagFull")
+ break
#背包空间不足
if not isPackSpaceEnough:
--
Gitblit v1.8.0