From 2ef7331900344b29d633c4170a8b272b96d0a872 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期五, 19 四月 2019 21:25:20 +0800 Subject: [PATCH] 6459 【后端】【2.0】缥缈仙域开发单(优化跨服boss状态同步) --- ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py | 206 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 170 insertions(+), 36 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py b/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py index 5141fb0..3b6241c 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py @@ -15,15 +15,78 @@ from ctypes import (Structure, memset, memmove, sizeof, addressof, create_string_buffer, string_at) import CommFunc +# 拍卖关注表 #tagDBAuctionAttention +class tagDBAuctionAttention(Structure): + _pack_ = 1 + _fields_ = [ + ('PlayerID', ctypes.c_ulong), + ('AttentionLen', ctypes.c_ubyte), + ('AttentionInfo', ctypes.c_char_p), + ('ADOResult', ctypes.c_ulong), + ] + + def __init__(self): + Structure.__init__(self) + self.clear() + + def clear(self): + self.PlayerID = 0 + self.AttentionLen = 0 + self.AttentionInfo = '' + + def readData(self, buf, pos = 0, length = 0): + if not pos <= length: + return -1 + if len(buf) < pos + self.getLength(): + return -1 + self.clear() + self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) + self.AttentionLen, pos = CommFunc.ReadBYTE(buf, pos) + tmp, pos = CommFunc.ReadString(buf, pos, self.AttentionLen) + self.AttentionInfo = ctypes.c_char_p(tmp) + return self.getLength() + + def getBuffer(self): + buf = '' + buf = CommFunc.WriteDWORD(buf, self.PlayerID) + buf = CommFunc.WriteBYTE(buf, self.AttentionLen) + buf = CommFunc.WriteString(buf, self.AttentionLen, self.AttentionInfo) + return buf + + def getLength(self): + length = 0 + length += sizeof(ctypes.c_ulong) + length += sizeof(ctypes.c_ubyte) + length += self.AttentionLen + return length + + def outputString(self): + output = '''// 拍卖关注表 #tagDBAuctionAttention: + PlayerID = %s, + AttentionLen = %s, + AttentionInfo = %s, + ADOResult = %s, + '''%( + self.PlayerID, + self.AttentionLen, + self.AttentionInfo, + self.ADOResult, + ) + return output + + # 拍卖记录表 #tagDBAuctionRecord class tagDBAuctionRecord(Structure): _pack_ = 1 _fields_ = [ + ('ItemGUID', ctypes.c_char * 40), ('PlayerID', ctypes.c_ulong), ('FamilyID', ctypes.c_ulong), ('RecordType', ctypes.c_ubyte), + ('RecordResult', ctypes.c_ubyte), ('RecordTime', ctypes.c_char * 19), - ('RecordPrice', ctypes.c_ulong), + ('BidderPrice', ctypes.c_ulong), + ('BidderName', ctypes.c_char * 33), ('ItemID', ctypes.c_ulong), ('Count', ctypes.c_ushort), ('UserDataLen', ctypes.c_ushort), @@ -36,11 +99,14 @@ self.clear() def clear(self): + self.ItemGUID = '' self.PlayerID = 0 self.FamilyID = 0 self.RecordType = 0 + self.RecordResult = 0 self.RecordTime = '' - self.RecordPrice = 0 + self.BidderPrice = 0 + self.BidderName = '' self.ItemID = 0 self.Count = 0 self.UserDataLen = 0 @@ -52,11 +118,14 @@ if len(buf) < pos + self.getLength(): return -1 self.clear() + self.ItemGUID, pos = CommFunc.ReadString(buf, pos, 40) self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) self.FamilyID, pos = CommFunc.ReadDWORD(buf, pos) self.RecordType, pos = CommFunc.ReadBYTE(buf, pos) + self.RecordResult, pos = CommFunc.ReadBYTE(buf, pos) self.RecordTime, pos = CommFunc.ReadString(buf, pos, 19) - self.RecordPrice, pos = CommFunc.ReadDWORD(buf, pos) + self.BidderPrice, pos = CommFunc.ReadDWORD(buf, pos) + self.BidderName, pos = CommFunc.ReadString(buf, pos, 33) self.ItemID, pos = CommFunc.ReadDWORD(buf, pos) self.Count, pos = CommFunc.ReadWORD(buf, pos) self.UserDataLen, pos = CommFunc.ReadWORD(buf, pos) @@ -66,11 +135,14 @@ def getBuffer(self): buf = '' + buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 40, self.ItemGUID) buf = CommFunc.WriteDWORD(buf, self.PlayerID) buf = CommFunc.WriteDWORD(buf, self.FamilyID) buf = CommFunc.WriteBYTE(buf, self.RecordType) + buf = CommFunc.WriteBYTE(buf, self.RecordResult) buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 19, self.RecordTime) - buf = CommFunc.WriteDWORD(buf, self.RecordPrice) + buf = CommFunc.WriteDWORD(buf, self.BidderPrice) + buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.BidderName) buf = CommFunc.WriteDWORD(buf, self.ItemID) buf = CommFunc.WriteWORD(buf, self.Count) buf = CommFunc.WriteWORD(buf, self.UserDataLen) @@ -79,11 +151,14 @@ def getLength(self): length = 0 + length += sizeof(ctypes.c_char) * 40 length += sizeof(ctypes.c_ulong) length += sizeof(ctypes.c_ulong) length += sizeof(ctypes.c_ubyte) + length += sizeof(ctypes.c_ubyte) length += sizeof(ctypes.c_char) * 19 length += sizeof(ctypes.c_ulong) + length += sizeof(ctypes.c_char) * 33 length += sizeof(ctypes.c_ulong) length += sizeof(ctypes.c_ushort) length += sizeof(ctypes.c_ushort) @@ -92,22 +167,28 @@ def outputString(self): output = '''// 拍卖记录表 #tagDBAuctionRecord: + ItemGUID = %s, PlayerID = %s, FamilyID = %s, RecordType = %s, + RecordResult = %s, RecordTime = %s, - RecordPrice = %s, + BidderPrice = %s, + BidderName = %s, ItemID = %s, Count = %s, UserDataLen = %s, UserData = %s, ADOResult = %s, '''%( + self.ItemGUID, self.PlayerID, self.FamilyID, self.RecordType, + self.RecordResult, self.RecordTime, - self.RecordPrice, + self.BidderPrice, + self.BidderName, self.ItemID, self.Count, self.UserDataLen, @@ -117,11 +198,23 @@ return output #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错 + def SetItemGUID(self,Str): + if len(Str)<=40: + self.ItemGUID = Str + else: + self.ItemGUID = Str[:40] + def SetRecordTime(self,Str): if len(Str)<=19: self.RecordTime = Str else: self.RecordTime = Str[:19] + + def SetBidderName(self,Str): + if len(Str)<=33: + self.BidderName = Str + else: + self.BidderName = Str[:33] # 拍卖物品表 #tagDBAuctionItem @@ -133,17 +226,21 @@ ('FamilyID', ctypes.c_ulong), ('ItemID', ctypes.c_ulong), ('Count', ctypes.c_ushort), + ('AuctionType', ctypes.c_ubyte), ('AddTime', ctypes.c_char * 19), ('BiddingTime', ctypes.c_char * 19), ('BidderID', ctypes.c_ulong), ('BidderName', ctypes.c_char * 33), ('BidderPrice', ctypes.c_ulong), - ('ItemType', ctypes.c_ulong), - ('ItemJobLimit', ctypes.c_ulong), + ('ItemType', ctypes.c_ubyte), + ('ItemJobLimit', ctypes.c_ubyte), + ('ItemClassLV', ctypes.c_ubyte), ('UserDataLen', ctypes.c_ushort), ('UserData', ctypes.c_char_p), ('FamilyPlayerIDLen', ctypes.c_ushort), ('FamilyPlayerIDInfo', ctypes.c_char_p), + ('BidderIDLen', ctypes.c_ubyte), + ('BidderIDInfo', ctypes.c_char_p), ('ADOResult', ctypes.c_ulong), ] @@ -157,6 +254,7 @@ self.FamilyID = 0 self.ItemID = 0 self.Count = 0 + self.AuctionType = 0 self.AddTime = '' self.BiddingTime = '' self.BidderID = 0 @@ -164,10 +262,13 @@ self.BidderPrice = 0 self.ItemType = 0 self.ItemJobLimit = 0 + self.ItemClassLV = 0 self.UserDataLen = 0 self.UserData = '' self.FamilyPlayerIDLen = 0 self.FamilyPlayerIDInfo = '' + self.BidderIDLen = 0 + self.BidderIDInfo = '' def readData(self, buf, pos = 0, length = 0): if not pos <= length: @@ -180,19 +281,24 @@ self.FamilyID, pos = CommFunc.ReadDWORD(buf, pos) self.ItemID, pos = CommFunc.ReadDWORD(buf, pos) self.Count, pos = CommFunc.ReadWORD(buf, pos) + self.AuctionType, pos = CommFunc.ReadBYTE(buf, pos) self.AddTime, pos = CommFunc.ReadString(buf, pos, 19) self.BiddingTime, pos = CommFunc.ReadString(buf, pos, 19) self.BidderID, pos = CommFunc.ReadDWORD(buf, pos) self.BidderName, pos = CommFunc.ReadString(buf, pos, 33) self.BidderPrice, pos = CommFunc.ReadDWORD(buf, pos) - self.ItemType, pos = CommFunc.ReadDWORD(buf, pos) - self.ItemJobLimit, pos = CommFunc.ReadDWORD(buf, pos) + self.ItemType, pos = CommFunc.ReadBYTE(buf, pos) + self.ItemJobLimit, pos = CommFunc.ReadBYTE(buf, pos) + self.ItemClassLV, pos = CommFunc.ReadBYTE(buf, pos) self.UserDataLen, pos = CommFunc.ReadWORD(buf, pos) tmp, pos = CommFunc.ReadString(buf, pos, self.UserDataLen) self.UserData = ctypes.c_char_p(tmp) self.FamilyPlayerIDLen, pos = CommFunc.ReadWORD(buf, pos) tmp, pos = CommFunc.ReadString(buf, pos, self.FamilyPlayerIDLen) self.FamilyPlayerIDInfo = ctypes.c_char_p(tmp) + self.BidderIDLen, pos = CommFunc.ReadBYTE(buf, pos) + tmp, pos = CommFunc.ReadString(buf, pos, self.BidderIDLen) + self.BidderIDInfo = ctypes.c_char_p(tmp) return self.getLength() def getBuffer(self): @@ -202,17 +308,21 @@ buf = CommFunc.WriteDWORD(buf, self.FamilyID) buf = CommFunc.WriteDWORD(buf, self.ItemID) buf = CommFunc.WriteWORD(buf, self.Count) + buf = CommFunc.WriteBYTE(buf, self.AuctionType) buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 19, self.AddTime) buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 19, self.BiddingTime) buf = CommFunc.WriteDWORD(buf, self.BidderID) buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.BidderName) buf = CommFunc.WriteDWORD(buf, self.BidderPrice) - buf = CommFunc.WriteDWORD(buf, self.ItemType) - buf = CommFunc.WriteDWORD(buf, self.ItemJobLimit) + buf = CommFunc.WriteBYTE(buf, self.ItemType) + buf = CommFunc.WriteBYTE(buf, self.ItemJobLimit) + buf = CommFunc.WriteBYTE(buf, self.ItemClassLV) buf = CommFunc.WriteWORD(buf, self.UserDataLen) buf = CommFunc.WriteString(buf, self.UserDataLen, self.UserData) buf = CommFunc.WriteWORD(buf, self.FamilyPlayerIDLen) buf = CommFunc.WriteString(buf, self.FamilyPlayerIDLen, self.FamilyPlayerIDInfo) + buf = CommFunc.WriteBYTE(buf, self.BidderIDLen) + buf = CommFunc.WriteString(buf, self.BidderIDLen, self.BidderIDInfo) return buf def getLength(self): @@ -222,17 +332,21 @@ length += sizeof(ctypes.c_ulong) length += sizeof(ctypes.c_ulong) length += sizeof(ctypes.c_ushort) + length += sizeof(ctypes.c_ubyte) length += sizeof(ctypes.c_char) * 19 length += sizeof(ctypes.c_char) * 19 length += sizeof(ctypes.c_ulong) length += sizeof(ctypes.c_char) * 33 length += sizeof(ctypes.c_ulong) - length += sizeof(ctypes.c_ulong) - length += sizeof(ctypes.c_ulong) + length += sizeof(ctypes.c_ubyte) + length += sizeof(ctypes.c_ubyte) + length += sizeof(ctypes.c_ubyte) length += sizeof(ctypes.c_ushort) length += self.UserDataLen length += sizeof(ctypes.c_ushort) length += self.FamilyPlayerIDLen + length += sizeof(ctypes.c_ubyte) + length += self.BidderIDLen return length def outputString(self): @@ -242,6 +356,7 @@ FamilyID = %s, ItemID = %s, Count = %s, + AuctionType = %s, AddTime = %s, BiddingTime = %s, BidderID = %s, @@ -249,10 +364,13 @@ BidderPrice = %s, ItemType = %s, ItemJobLimit = %s, + ItemClassLV = %s, UserDataLen = %s, UserData = %s, FamilyPlayerIDLen = %s, FamilyPlayerIDInfo = %s, + BidderIDLen = %s, + BidderIDInfo = %s, ADOResult = %s, '''%( self.ItemGUID, @@ -260,6 +378,7 @@ self.FamilyID, self.ItemID, self.Count, + self.AuctionType, self.AddTime, self.BiddingTime, self.BidderID, @@ -267,10 +386,13 @@ self.BidderPrice, self.ItemType, self.ItemJobLimit, + self.ItemClassLV, self.UserDataLen, self.UserData, self.FamilyPlayerIDLen, self.FamilyPlayerIDInfo, + self.BidderIDLen, + self.BidderIDInfo, self.ADOResult, ) return output @@ -483,14 +605,22 @@ def clear(self): memset(addressof(self), 0, self.getLength()) - def readData(self, buf, pos = 0, length = 0): if not pos <= length: return -1 if len(buf) < pos + self.getLength(): return -1 self.clear() - memmove(addressof(self), buf[pos:], self.getLength()) + self.ZoneID, pos = CommFunc.ReadBYTE(buf, pos) + self.SeasonID, pos = CommFunc.ReadBYTE(buf, pos) + self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) + self.PlayerName, pos = CommFunc.ReadString(buf, pos, 33) + self.Job, pos = CommFunc.ReadBYTE(buf, pos) + self.FightPower, pos = CommFunc.ReadDWORD(buf, pos) + self.RealmLV, pos = CommFunc.ReadWORD(buf, pos) + self.PKScore, pos = CommFunc.ReadDWORD(buf, pos) + self.DanLV, pos = CommFunc.ReadBYTE(buf, pos) + self.Time, pos = CommFunc.ReadDWORD(buf, pos) return self.getLength() @@ -536,7 +666,7 @@ self.PlayerName = Str else: self.PlayerName = Str[:33] - + #仙魔之争记录表#tagDBPyXMZZ class tagDBPyXMZZ(Structure): @@ -673,14 +803,15 @@ def clear(self): memset(addressof(self), 0, self.getLength()) - def readData(self, buf, pos = 0, length = 0): if not pos <= length: return -1 if len(buf) < pos + self.getLength(): return -1 self.clear() - memmove(addressof(self), buf[pos:], self.getLength()) + self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) + self.LineID, pos = CommFunc.ReadBYTE(buf, pos) + self.Rank, pos = CommFunc.ReadWORD(buf, pos) return self.getLength() @@ -705,7 +836,6 @@ self.ADOResult, ) return output - #Boss关注记录表#tagDBPyBossAttention @@ -768,7 +898,6 @@ return output - #交易所物品最近成交单价表#tagDBPyBourseItemLastPrice class tagDBPyBourseItemLastPrice(Structure): _pack_ = 1 @@ -786,14 +915,14 @@ def clear(self): memset(addressof(self), 0, self.getLength()) - def readData(self, buf, pos = 0, length = 0): if not pos <= length: return -1 if len(buf) < pos + self.getLength(): return -1 self.clear() - memmove(addressof(self), buf[pos:], self.getLength()) + self.ItemID, pos = CommFunc.ReadDWORD(buf, pos) + self.LastPrice, pos = CommFunc.ReadDWORD(buf, pos) return self.getLength() @@ -979,7 +1108,6 @@ ) return output - #玩家黑名单 #tagDBPyPlayerBlack class tagDBPyPlayerBlack(Structure): _pack_ = 1 @@ -997,14 +1125,14 @@ def clear(self): memset(addressof(self), 0, self.getLength()) - def readData(self, buf, pos = 0, length = 0): if not pos <= length: return -1 if len(buf) < pos + self.getLength(): return -1 self.clear() - memmove(addressof(self), buf[pos:], self.getLength()) + self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) + self.TagID, pos = CommFunc.ReadDWORD(buf, pos) return self.getLength() @@ -1046,14 +1174,15 @@ def clear(self): memset(addressof(self), 0, self.getLength()) - def readData(self, buf, pos = 0, length = 0): if not pos <= length: return -1 if len(buf) < pos + self.getLength(): return -1 self.clear() - memmove(addressof(self), buf[pos:], self.getLength()) + self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) + self.TagID, pos = CommFunc.ReadDWORD(buf, pos) + self.Timestamp, pos = CommFunc.ReadDWORD(buf, pos) return self.getLength() @@ -1096,14 +1225,14 @@ def clear(self): memset(addressof(self), 0, self.getLength()) - def readData(self, buf, pos = 0, length = 0): if not pos <= length: return -1 if len(buf) < pos + self.getLength(): return -1 self.clear() - memmove(addressof(self), buf[pos:], self.getLength()) + self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) + self.TagID, pos = CommFunc.ReadDWORD(buf, pos) return self.getLength() @@ -1127,6 +1256,7 @@ ) return output + #玩家仇人表#tagPlayerEnemy class tagPlayerEnemy(Structure): _pack_ = 1 @@ -1145,14 +1275,15 @@ def clear(self): memset(addressof(self), 0, self.getLength()) - def readData(self, buf, pos = 0, length = 0): if not pos <= length: return -1 if len(buf) < pos + self.getLength(): return -1 self.clear() - memmove(addressof(self), buf[pos:], self.getLength()) + self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) + self.TagID, pos = CommFunc.ReadDWORD(buf, pos) + self.Timestamp, pos = CommFunc.ReadDWORD(buf, pos) return self.getLength() @@ -1179,7 +1310,6 @@ return output - #个人社交总表 #tagPersonalSocial class tagPersonalSocial(Structure): _pack_ = 1 @@ -1202,14 +1332,19 @@ def clear(self): memset(addressof(self), 0, self.getLength()) - def readData(self, buf, pos = 0, length = 0): if not pos <= length: return -1 if len(buf) < pos + self.getLength(): return -1 self.clear() - memmove(addressof(self), buf[pos:], self.getLength()) + self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos) + self.PlayerName, pos = CommFunc.ReadString(buf, pos, 33) + self.Job, pos = CommFunc.ReadBYTE(buf, pos) + self.LV, pos = CommFunc.ReadWORD(buf, pos) + self.RealmLV, pos = CommFunc.ReadWORD(buf, pos) + self.OnlineType, pos = CommFunc.ReadBYTE(buf, pos) + self.RefCount, pos = CommFunc.ReadDWORD(buf, pos) return self.getLength() @@ -1250,5 +1385,4 @@ else: self.PlayerName = Str[:33] - -- Gitblit v1.8.0