ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py
@@ -15,6 +15,257 @@
from ctypes import (Structure, memset, memmove, sizeof, addressof, create_string_buffer, string_at)
import CommFunc
# 跨服补偿个人领取表 #tagDBCrossPersonalCompensation
class tagDBCrossPersonalCompensation(Structure):
    _pack_ = 1
    _fields_ = [
        ('PlayerID', ctypes.c_ulong),
        ('GUID', ctypes.c_char * 40),
        ('LimitTime', ctypes.c_char * 30),
        ('TextLen', ctypes.c_ulong),
        ('Text', ctypes.c_char_p),
        ('Gold', ctypes.c_ulong),
        ('GoldPaper', ctypes.c_ulong),
        ('Silver', ctypes.c_ulong),
        ('ItemLen', ctypes.c_ushort),
        ('ItemInfo', ctypes.c_char_p),
        ('DetailLen', ctypes.c_ushort),
        ('Detail', ctypes.c_char_p),
        ('MoneySource', ctypes.c_ushort),
        ('ADOResult', ctypes.c_ulong),
    ]
    def __init__(self):
        Structure.__init__(self)
        self.clear()
    def clear(self):
        self.PlayerID = 0
        self.GUID = ''
        self.LimitTime = ''
        self.TextLen = 0
        self.Text = ''
        self.Gold = 0
        self.GoldPaper = 0
        self.Silver = 0
        self.ItemLen = 0
        self.ItemInfo = ''
        self.DetailLen = 0
        self.Detail = ''
        self.MoneySource = 0
    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.GUID, pos = CommFunc.ReadString(buf, pos, 40)
        self.LimitTime, pos = CommFunc.ReadString(buf, pos, 30)
        self.TextLen, pos = CommFunc.ReadDWORD(buf, pos)
        tmp, pos = CommFunc.ReadString(buf, pos, self.TextLen)
        self.Text = ctypes.c_char_p(tmp)
        self.Gold, pos = CommFunc.ReadDWORD(buf, pos)
        self.GoldPaper, pos = CommFunc.ReadDWORD(buf, pos)
        self.Silver, pos = CommFunc.ReadDWORD(buf, pos)
        self.ItemLen, pos = CommFunc.ReadWORD(buf, pos)
        tmp, pos = CommFunc.ReadString(buf, pos, self.ItemLen)
        self.ItemInfo = ctypes.c_char_p(tmp)
        self.DetailLen, pos = CommFunc.ReadWORD(buf, pos)
        tmp, pos = CommFunc.ReadString(buf, pos, self.DetailLen)
        self.Detail = ctypes.c_char_p(tmp)
        self.MoneySource, pos = CommFunc.ReadWORD(buf, pos)
        return self.getLength()
    def getBuffer(self):
        buf = ''
        buf = CommFunc.WriteDWORD(buf, self.PlayerID)
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 40, self.GUID)
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 30, self.LimitTime)
        buf = CommFunc.WriteDWORD(buf, self.TextLen)
        buf = CommFunc.WriteString(buf, self.TextLen, self.Text)
        buf = CommFunc.WriteDWORD(buf, self.Gold)
        buf = CommFunc.WriteDWORD(buf, self.GoldPaper)
        buf = CommFunc.WriteDWORD(buf, self.Silver)
        buf = CommFunc.WriteWORD(buf, self.ItemLen)
        buf = CommFunc.WriteString(buf, self.ItemLen, self.ItemInfo)
        buf = CommFunc.WriteWORD(buf, self.DetailLen)
        buf = CommFunc.WriteString(buf, self.DetailLen, self.Detail)
        buf = CommFunc.WriteWORD(buf, self.MoneySource)
        return buf
    def getLength(self):
        length = 0
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_char) * 40
        length += sizeof(ctypes.c_char) * 30
        length += sizeof(ctypes.c_ulong)
        length += self.TextLen
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ushort)
        length += self.ItemLen
        length += sizeof(ctypes.c_ushort)
        length += self.DetailLen
        length += sizeof(ctypes.c_ushort)
        return length
    def outputString(self):
        output = '''// 跨服补偿个人领取表 #tagDBCrossPersonalCompensation:
            PlayerID = %s,
            GUID = %s,
            LimitTime = %s,
            TextLen = %s,
            Text = %s,
            Gold = %s,
            GoldPaper = %s,
            Silver = %s,
            ItemLen = %s,
            ItemInfo = %s,
            DetailLen = %s,
            Detail = %s,
            MoneySource = %s,
            ADOResult = %s,
            '''%(
                self.PlayerID,
                self.GUID,
                self.LimitTime,
                self.TextLen,
                self.Text,
                self.Gold,
                self.GoldPaper,
                self.Silver,
                self.ItemLen,
                self.ItemInfo,
                self.DetailLen,
                self.Detail,
                self.MoneySource,
                self.ADOResult,
            )
        return output
    #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
    def SetGUID(self,Str):
        if len(Str)<=40:
            self.GUID = Str
        else:
            self.GUID = Str[:40]
    def SetLimitTime(self,Str):
        if len(Str)<=30:
            self.LimitTime = Str
        else:
            self.LimitTime = Str[:30]
# 跨服排行榜 #tagDBCrossBillboard
class tagDBCrossBillboard(Structure):
    _pack_ = 1
    _fields_ = [
        ('GroupValue1', ctypes.c_ubyte),
        ('GroupValue2', ctypes.c_ubyte),
        ('BillboardType', ctypes.c_ubyte),
        ('ID', ctypes.c_ulong),
        ('ID2', ctypes.c_ulong),
        ('Name1', ctypes.c_char * 33),
        ('Name2', ctypes.c_char * 33),
        ('Type2', ctypes.c_ubyte),
        ('Value1', ctypes.c_ulong),
        ('Value2', ctypes.c_ulong),
        ('CmpValue', ctypes.c_ulong),
        ('CmpValue2', ctypes.c_ulong),
        ('CmpValue3', ctypes.c_ulong),
        ('ADOResult', ctypes.c_ulong),
    ]
    def __init__(self):
        Structure.__init__(self)
        self.clear()
    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()
        self.GroupValue1, pos = CommFunc.ReadBYTE(buf, pos)
        self.GroupValue2, pos = CommFunc.ReadBYTE(buf, pos)
        self.BillboardType, pos = CommFunc.ReadBYTE(buf, pos)
        self.ID, pos = CommFunc.ReadDWORD(buf, pos)
        self.ID2, pos = CommFunc.ReadDWORD(buf, pos)
        self.Name1, pos = CommFunc.ReadString(buf, pos, 33)
        self.Name2, pos = CommFunc.ReadString(buf, pos, 33)
        self.Type2, pos = CommFunc.ReadBYTE(buf, pos)
        self.Value1, pos = CommFunc.ReadDWORD(buf, pos)
        self.Value2, pos = CommFunc.ReadDWORD(buf, pos)
        self.CmpValue, pos = CommFunc.ReadDWORD(buf, pos)
        self.CmpValue2, pos = CommFunc.ReadDWORD(buf, pos)
        self.CmpValue3, pos = CommFunc.ReadDWORD(buf, pos)
        return self.getLength()
    def getBuffer(self):
        buf = create_string_buffer(self.getLength())
        memmove(addressof(buf), addressof(self), self.getLength())
        return string_at(addressof(buf), self.getLength())
    def getLength(self):
        return sizeof(tagDBCrossBillboard)
    def outputString(self):
        output = '''// 跨服排行榜 #tagDBCrossBillboard:
            GroupValue1 = %s,
            GroupValue2 = %s,
            BillboardType = %s,
            ID = %s,
            ID2 = %s,
            Name1 = %s,
            Name2 = %s,
            Type2 = %s,
            Value1 = %s,
            Value2 = %s,
            CmpValue = %s,
            CmpValue2 = %s,
            CmpValue3 = %s,
            ADOResult = %s,
            '''%(
                self.GroupValue1,
                self.GroupValue2,
                self.BillboardType,
                self.ID,
                self.ID2,
                self.Name1,
                self.Name2,
                self.Type2,
                self.Value1,
                self.Value2,
                self.CmpValue,
                self.CmpValue2,
                self.CmpValue3,
                self.ADOResult,
            )
        return output
    #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
    def SetName1(self,Str):
        if len(Str)<=33:
            self.Name1 = Str
        else:
            self.Name1 = Str[:33]
    def SetName2(self,Str):
        if len(Str)<=33:
            self.Name2 = Str
        else:
            self.Name2 = Str[:33]
# 协助感谢表 #tagDBAssistThanks
class tagDBAssistThanks(Structure):
    _pack_ = 1
@@ -32,6 +283,7 @@
        ('NPCID', ctypes.c_ulong),
        ('ExDataLen', ctypes.c_ushort),
        ('ExData', ctypes.c_char_p),
        ('DailyDateStr', ctypes.c_char * 10),
        ('TimeStr', ctypes.c_char * 19),
        ('ThanksState', ctypes.c_ubyte),
        ('AssistPlayerLen', ctypes.c_ushort),
@@ -57,6 +309,7 @@
        self.NPCID = 0
        self.ExDataLen = 0
        self.ExData = ''
        self.DailyDateStr = ''
        self.TimeStr = ''
        self.ThanksState = 0
        self.AssistPlayerLen = 0
@@ -82,6 +335,7 @@
        self.ExDataLen, pos = CommFunc.ReadWORD(buf, pos)
        tmp, pos = CommFunc.ReadString(buf, pos, self.ExDataLen)
        self.ExData = ctypes.c_char_p(tmp)
        self.DailyDateStr, pos = CommFunc.ReadString(buf, pos, 10)
        self.TimeStr, pos = CommFunc.ReadString(buf, pos, 19)
        self.ThanksState, pos = CommFunc.ReadBYTE(buf, pos)
        self.AssistPlayerLen, pos = CommFunc.ReadWORD(buf, pos)
@@ -104,6 +358,7 @@
        buf = CommFunc.WriteDWORD(buf, self.NPCID)
        buf = CommFunc.WriteWORD(buf, self.ExDataLen)
        buf = CommFunc.WriteString(buf, self.ExDataLen, self.ExData)
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 10, self.DailyDateStr)
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 19, self.TimeStr)
        buf = CommFunc.WriteBYTE(buf, self.ThanksState)
        buf = CommFunc.WriteWORD(buf, self.AssistPlayerLen)
@@ -125,6 +380,7 @@
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ushort)
        length += self.ExDataLen
        length += sizeof(ctypes.c_char) * 10
        length += sizeof(ctypes.c_char) * 19
        length += sizeof(ctypes.c_ubyte)
        length += sizeof(ctypes.c_ushort)
@@ -146,6 +402,7 @@
            NPCID = %s,
            ExDataLen = %s,
            ExData = %s,
            DailyDateStr = %s,
            TimeStr = %s,
            ThanksState = %s,
            AssistPlayerLen = %s,
@@ -165,6 +422,7 @@
                self.NPCID,
                self.ExDataLen,
                self.ExData,
                self.DailyDateStr,
                self.TimeStr,
                self.ThanksState,
                self.AssistPlayerLen,
@@ -186,6 +444,12 @@
        else:
            self.PlayerName = Str[:33]
            
    def SetDailyDateStr(self,Str):
        if len(Str)<=10:
            self.DailyDateStr = Str
        else:
            self.DailyDateStr = Str[:10]
    def SetTimeStr(self,Str):
        if len(Str)<=19:
            self.TimeStr = Str