From 0be2d6f2947fe9f3573841aee07dde4b9f4211b9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 19 九月 2024 16:39:21 +0800
Subject: [PATCH] 10267 【越南】【英文】【砍树】优化GivePlayerItemOrMail,防范列表元素包含None报错;

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

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 6468de1..b17ef36 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/ItemControler.py
@@ -2525,8 +2525,13 @@
     ##给物品,背包满则发邮件
     if not itemList:
         return
+    giveItemList = []
     needPackSpaceDict = {}
-    for itemID, itemCnt, isAuctionItem in itemList:
+    for itemInfo in itemList:
+        if not itemInfo:
+            continue
+        itemID, itemCnt = itemInfo[:2]
+        isAuctionItem = itemInfo[2] if len(itemInfo) > 2 else 0
         curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
         if not curItem:
             GameWorld.ErrLog('GivePlayerItemOrMail 物品ID不存在 itemID=%s'%itemID, curPlayer.GetID())
@@ -2534,6 +2539,9 @@
         packType = ChConfig.GetItemPackType(curItem)
         needSpace = GetItemNeedPackCount(packType, curItem, itemCnt, isAuctionItem)
         needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace
+        giveItemList.append([itemID, itemCnt, isAuctionItem])
+    if not giveItemList:
+        return
     isSendMail = False
     for packType, needSpace in needPackSpaceDict.items():
         if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):
@@ -2541,10 +2549,10 @@
             break
            
     if isSendMail:
-        PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], itemList)
-        GameWorld.DebugLog("GivePlayerItemOrMail背包空间不够,发送邮件: mailItemList=%s" % str(itemList), curPlayer.GetPlayerID())
+        PlayerControl.SendMailByKey(mailKey, [curPlayer.GetPlayerID()], giveItemList)
+        GameWorld.DebugLog("GivePlayerItemOrMail背包空间不够,发送邮件: mailItemList=%s" % str(giveItemList), curPlayer.GetPlayerID())
     else:
-        for itemID, itemCnt, isAuctionItem in itemList:
+        for itemID, itemCnt, isAuctionItem in giveItemList:
             GivePlayerItem(curPlayer, itemID, itemCnt, isAuctionItem, [IPY_GameWorld.rptItem], event=event)
     return
 

--
Gitblit v1.8.0