From 1bc4623d268c4ef18a437c71f8be663a9d044a12 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 20 五月 2025 11:16:59 +0800
Subject: [PATCH] 16 卡牌服务端(优化邮件物品,Mail命令支持发送全服邮件;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py | 4 +-
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMail.py | 1
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBMail.py | 19 +++++----
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Mail.py | 68 +++++++++++++++++++++++-----------
4 files changed, 59 insertions(+), 33 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBMail.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBMail.py
index 5a65c35..561d085 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBMail.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/DB/StructData/DBMail.py
@@ -156,7 +156,7 @@
itemRankList.append(key)
itemDict[key] = itemDict[key] + itemCount
- mailItemCount = 0
+ giveItemList = []
for itemInfo in itemRankList:
if len(itemInfo) == 4:
itemID, itemCount, isBind, userData = itemInfo
@@ -164,7 +164,14 @@
userData = ""
itemID, isBind = itemInfo
itemCount = itemDict.get(itemInfo, 0)
-
+ giveItemList.append([itemID, itemCount, isBind, userData])
+
+ Max_MailItem = 20
+ if len(giveItemList) > Max_MailItem:
+ GameWorld.SendGameErrorEx("MailItemMultiError", "%s|%s|%s|%s" % (guid, len(giveItemList), itemList, giveItemList))
+ #giveItemList = giveItemList[:Max_MailItem] 暂时还是让发,先做下后台邮件警告即可
+
+ for itemID, itemCount, isBind, userData in giveItemList:
dbData = DBStruct.tagDBMailItem()
dbData.GUID = guid
dbData.ItemID = itemID
@@ -173,12 +180,6 @@
dbData.UserData = userData
dbData.UserDataLen = len(dbData.UserData)
self.__InitMailItemInstance(dbData)
-
- mailItemCount += 1
- if mailItemCount >= 20:
- #防范某些异常情况,内置单封邮件物品上限,做下限制,并做后台邮件警告
- GameWorld.SendGameErrorEx("MailItemMultiError", "%s|%s" % (guid, itemList))
- break
return
@@ -402,7 +403,7 @@
for _ in xrange(cnt):
dbData.clear()
pos += dbData.readData(datas, pos, dataslen)
- self.SetServerMailPlayerState(dbData.GUID, dbData.PlayerID, dbData.MailState)
+ self.SetPlayerMailState(dbData.GUID, dbData.PlayerID, dbData.MailState)
# 个人邮件
cnt, pos = CommFunc.ReadDWORD(datas, pos)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Mail.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Mail.py
index ab5ab3f..78412de 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Mail.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Mail.py
@@ -32,6 +32,7 @@
GameWorld.DebugAnswer(curPlayer, "清空邮件: Mail 0")
GameWorld.DebugAnswer(curPlayer, "发送邮件: Mail 几封 物品数 [模板key 参数1 ...]")
GameWorld.DebugAnswer(curPlayer, "输出邮件: Mail p")
+ GameWorld.DebugAnswer(curPlayer, "发送全服: Mail s 物品数 [天数]")
return
value = gmList[0]
@@ -42,6 +43,10 @@
if value == "p":
PrintPlayerMail(curPlayer)
+ return
+
+ if value == "s":
+ SendServerMail(curPlayer, gmList)
return
if value > 0:
@@ -57,37 +62,56 @@
mailTypeKey = gmList[2] if len(gmList) > 2 else ""
paramList = gmList[3:]
- itemIDList = range(3501, 3530 + 1)
- moneyIDList = [20, 30]
-
mailMgr = DBDataMgr.GetMailMgr()
mailCntBef = mailMgr.GetPersonalMailCount(playerID)
-
- isBind = 0
for _ in range(sendCnt):
-
- itemList = []
- if mailItemCnt:
- for moneyID in moneyIDList:
- itemCount = random.choice([100, 1000, 10000, 20000, 50000, 100000, 200000, 300000, 500000])
- itemList.append([moneyID, itemCount, isBind])
- if len(itemList) >= mailItemCnt:
- break
-
- random.shuffle(itemIDList)
- for i in range(mailItemCnt):
- itemID = itemIDList[i]
- itemCount = random.randint(1, 100000)
- itemList.append([itemID, itemCount, isBind])
- if len(itemList) >= mailItemCnt:
- break
-
+ itemList = __randMailItem(mailItemCnt)
PlayerMail.SendMailByKey(mailTypeKey, playerID, itemList, paramList)
mailCntAft = mailMgr.GetPersonalMailCount(playerID)
GameWorld.DebugAnswer(curPlayer, "发送个人邮件OK:%s, %s~%s" % (sendCnt, mailCntBef, mailCntAft))
return
+def SendServerMail(curPlayer, gmList):
+ mailItemCnt = gmList[1] if len(gmList) > 1 else 5
+ limitDays = gmList[2] if len(gmList) > 2 else 7
+
+ randValue = random.randint(1, 1000)
+ title = GameWorld.GbkToCode("全服邮件标题%s" % randValue)
+ text = GameWorld.GbkToCode(
+ '''全服邮件内容全服邮件内容全服邮件内容全服邮件内容全服邮件内容
+ 全服邮件内容全服邮件内容全服邮件内容全服邮件内容全服邮件内容%s
+ ''' % randValue
+ )
+ itemList = __randMailItem(mailItemCnt)
+
+ PlayerMail.SendSeverMail("", title, text, itemList, limitDays)
+ GameWorld.DebugAnswer(curPlayer, "发送全服邮件OK!")
+ return
+
+def __randMailItem(mailItemCnt):
+ itemIDList = range(3501, 3530 + 1)
+ moneyIDList = [20, 30]
+
+ isBind = 0
+ itemList = []
+ if mailItemCnt:
+ for moneyID in moneyIDList:
+ itemCount = random.choice([100, 1000, 10000, 20000, 50000, 100000, 200000, 300000, 500000])
+ itemList.append([moneyID, itemCount, isBind])
+ if len(itemList) >= mailItemCnt:
+ break
+
+ random.shuffle(itemIDList)
+ for i in range(mailItemCnt):
+ itemID = itemIDList[i%len(itemIDList)]
+ itemCount = random.randint(1, 100000)
+ itemList.append([itemID, itemCount, isBind])
+ if len(itemList) >= mailItemCnt:
+ break
+
+ return itemList
+
def ClearMail(curPlayer):
notifyGUIDState = {}
playerID = curPlayer.GetPlayerID()
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
index 090cf01..19d0ca4 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py
@@ -2391,8 +2391,8 @@
def SendGameErrorEx(errType, msgInfo="", playerID=0):
ErrLog("SendGameErrorEx: %s -> %s" % (errType, msgInfo), playerID)
SendGameError(errType, msgInfo)
- if GetGameWorld().GetDebugLevel():
- raise Exception("%s -> %s" % (errType, msgInfo))
+ #if GetGameWorld().GetDebugLevel():
+ # raise Exception("%s -> %s" % (errType, msgInfo))
return
def SendGameError(errType, msgInfo=""):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMail.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMail.py
index eb1cf85..0d938da 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMail.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMail.py
@@ -412,6 +412,7 @@
return
clientPack = ChPyNetSendPack.tagMCMailList()
+ clientPack.IsServerMail = 1
clientPack.MailList = mailList
clientPack.Count = len(clientPack.MailList)
NetPackCommon.SendFakePack(curPlayer, clientPack)
--
Gitblit v1.8.0