hxp
2019-11-27 7b6e4af3ca3ea15dee2e7933e7445c3c2dc25d21
ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py
@@ -15,27 +15,25 @@
from ctypes import (Structure, memset, memmove, sizeof, addressof, create_string_buffer, string_at)
import CommFunc
# 协助表 #tagDBAssist
class tagDBAssist(Structure):
# 协助感谢表 #tagDBAssistThanks
class tagDBAssistThanks(Structure):
    _pack_ = 1
    _fields_ = [
        ('GUID', ctypes.c_char * 40),
        ('ItemID', ctypes.c_ulong),
        ('FamilyID', ctypes.c_ulong),
        ('PlayerID', ctypes.c_ulong),
        ('PlayerName', ctypes.c_char * 33),
        ('Job', ctypes.c_ubyte),
        ('LV', ctypes.c_ushort),
        ('RealmLV', ctypes.c_ubyte),
        ('AssistType', ctypes.c_ubyte),
        ('AssistValue1', ctypes.c_ulong),
        ('AssistValue2', ctypes.c_ulong),
        ('AssistValue3', ctypes.c_ulong),
        ('AssistValue4', ctypes.c_ulong),
        ('AssistValue5', ctypes.c_ulong),
        ('AssistDataLen', ctypes.c_ushort),
        ('AssistData', ctypes.c_char_p),
        ('FinishTime', ctypes.c_char * 19),
        ('AssistState', ctypes.c_ubyte),
        ('MapID', ctypes.c_ulong),
        ('LineID', ctypes.c_ulong),
        ('NPCID', ctypes.c_ulong),
        ('ExDataLen', ctypes.c_ushort),
        ('ExData', ctypes.c_char_p),
        ('TimeStr', ctypes.c_char * 19),
        ('ThanksState', ctypes.c_ubyte),
        ('AssistPlayerLen', ctypes.c_ushort),
        ('AssistPlayer', ctypes.c_char_p),
        ('ADOResult', ctypes.c_ulong),
@@ -47,22 +45,20 @@
    def clear(self):
        self.GUID = ''
        self.ItemID = 0
        self.FamilyID = 0
        self.PlayerID = 0
        self.PlayerName = ''
        self.Job = 0
        self.LV = 0
        self.RealmLV = 0
        self.AssistType = 0
        self.AssistValue1 = 0
        self.AssistValue2 = 0
        self.AssistValue3 = 0
        self.AssistValue4 = 0
        self.AssistValue5 = 0
        self.AssistDataLen = 0
        self.AssistData = ''
        self.FinishTime = ''
        self.AssistState = 0
        self.MapID = 0
        self.LineID = 0
        self.NPCID = 0
        self.ExDataLen = 0
        self.ExData = ''
        self.TimeStr = ''
        self.ThanksState = 0
        self.AssistPlayerLen = 0
        self.AssistPlayer = ''
@@ -73,23 +69,21 @@
            return -1
        self.clear()
        self.GUID, pos = CommFunc.ReadString(buf, pos, 40)
        self.ItemID, pos = CommFunc.ReadDWORD(buf, pos)
        self.FamilyID, pos = CommFunc.ReadDWORD(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.LV, pos = CommFunc.ReadWORD(buf, pos)
        self.RealmLV, pos = CommFunc.ReadBYTE(buf, pos)
        self.AssistType, pos = CommFunc.ReadBYTE(buf, pos)
        self.AssistValue1, pos = CommFunc.ReadDWORD(buf, pos)
        self.AssistValue2, pos = CommFunc.ReadDWORD(buf, pos)
        self.AssistValue3, pos = CommFunc.ReadDWORD(buf, pos)
        self.AssistValue4, pos = CommFunc.ReadDWORD(buf, pos)
        self.AssistValue5, pos = CommFunc.ReadDWORD(buf, pos)
        self.AssistDataLen, pos = CommFunc.ReadWORD(buf, pos)
        tmp, pos = CommFunc.ReadString(buf, pos, self.AssistDataLen)
        self.AssistData = ctypes.c_char_p(tmp)
        self.FinishTime, pos = CommFunc.ReadString(buf, pos, 19)
        self.AssistState, pos = CommFunc.ReadBYTE(buf, pos)
        self.MapID, pos = CommFunc.ReadDWORD(buf, pos)
        self.LineID, pos = CommFunc.ReadDWORD(buf, pos)
        self.NPCID, pos = CommFunc.ReadDWORD(buf, pos)
        self.ExDataLen, pos = CommFunc.ReadWORD(buf, pos)
        tmp, pos = CommFunc.ReadString(buf, pos, self.ExDataLen)
        self.ExData = ctypes.c_char_p(tmp)
        self.TimeStr, pos = CommFunc.ReadString(buf, pos, 19)
        self.ThanksState, pos = CommFunc.ReadBYTE(buf, pos)
        self.AssistPlayerLen, pos = CommFunc.ReadWORD(buf, pos)
        tmp, pos = CommFunc.ReadString(buf, pos, self.AssistPlayerLen)
        self.AssistPlayer = ctypes.c_char_p(tmp)
@@ -98,22 +92,20 @@
    def getBuffer(self):
        buf = ''
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 40, self.GUID)
        buf = CommFunc.WriteDWORD(buf, self.ItemID)
        buf = CommFunc.WriteDWORD(buf, self.FamilyID)
        buf = CommFunc.WriteDWORD(buf, self.PlayerID)
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.PlayerName)
        buf = CommFunc.WriteBYTE(buf, self.Job)
        buf = CommFunc.WriteWORD(buf, self.LV)
        buf = CommFunc.WriteBYTE(buf, self.RealmLV)
        buf = CommFunc.WriteBYTE(buf, self.AssistType)
        buf = CommFunc.WriteDWORD(buf, self.AssistValue1)
        buf = CommFunc.WriteDWORD(buf, self.AssistValue2)
        buf = CommFunc.WriteDWORD(buf, self.AssistValue3)
        buf = CommFunc.WriteDWORD(buf, self.AssistValue4)
        buf = CommFunc.WriteDWORD(buf, self.AssistValue5)
        buf = CommFunc.WriteWORD(buf, self.AssistDataLen)
        buf = CommFunc.WriteString(buf, self.AssistDataLen, self.AssistData)
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 19, self.FinishTime)
        buf = CommFunc.WriteBYTE(buf, self.AssistState)
        buf = CommFunc.WriteDWORD(buf, self.MapID)
        buf = CommFunc.WriteDWORD(buf, self.LineID)
        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) * 19, self.TimeStr)
        buf = CommFunc.WriteBYTE(buf, self.ThanksState)
        buf = CommFunc.WriteWORD(buf, self.AssistPlayerLen)
        buf = CommFunc.WriteString(buf, self.AssistPlayerLen, self.AssistPlayer)
        return buf
@@ -123,18 +115,16 @@
        length += sizeof(ctypes.c_char) * 40
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_char) * 33
        length += sizeof(ctypes.c_ubyte)
        length += sizeof(ctypes.c_ushort)
        length += sizeof(ctypes.c_ubyte)
        length += sizeof(ctypes.c_ubyte)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ushort)
        length += self.AssistDataLen
        length += self.ExDataLen
        length += sizeof(ctypes.c_char) * 19
        length += sizeof(ctypes.c_ubyte)
        length += sizeof(ctypes.c_ushort)
@@ -142,45 +132,41 @@
        return length
    def outputString(self):
        output = '''// 协助表 #tagDBAssist:
        output = '''// 协助感谢表 #tagDBAssistThanks:
            GUID = %s,
            ItemID = %s,
            FamilyID = %s,
            PlayerID = %s,
            PlayerName = %s,
            Job = %s,
            LV = %s,
            RealmLV = %s,
            AssistType = %s,
            AssistValue1 = %s,
            AssistValue2 = %s,
            AssistValue3 = %s,
            AssistValue4 = %s,
            AssistValue5 = %s,
            AssistDataLen = %s,
            AssistData = %s,
            FinishTime = %s,
            AssistState = %s,
            MapID = %s,
            LineID = %s,
            NPCID = %s,
            ExDataLen = %s,
            ExData = %s,
            TimeStr = %s,
            ThanksState = %s,
            AssistPlayerLen = %s,
            AssistPlayer = %s,
            ADOResult = %s,
            '''%(
                self.GUID,
                self.ItemID,
                self.FamilyID,
                self.PlayerID,
                self.PlayerName,
                self.Job,
                self.LV,
                self.RealmLV,
                self.AssistType,
                self.AssistValue1,
                self.AssistValue2,
                self.AssistValue3,
                self.AssistValue4,
                self.AssistValue5,
                self.AssistDataLen,
                self.AssistData,
                self.FinishTime,
                self.AssistState,
                self.MapID,
                self.LineID,
                self.NPCID,
                self.ExDataLen,
                self.ExData,
                self.TimeStr,
                self.ThanksState,
                self.AssistPlayerLen,
                self.AssistPlayer,
                self.ADOResult,
@@ -200,11 +186,154 @@
        else:
            self.PlayerName = Str[:33]
            
    def SetFinishTime(self,Str):
    def SetTimeStr(self,Str):
        if len(Str)<=19:
            self.FinishTime = Str
            self.TimeStr = Str
        else:
            self.FinishTime = Str[:19]
            self.TimeStr = Str[:19]
# 协助表 #tagDBAssist
class tagDBAssist(Structure):
    _pack_ = 1
    _fields_ = [
        ('GUID', ctypes.c_char * 40),
        ('FamilyID', ctypes.c_ulong),
        ('PlayerID', ctypes.c_ulong),
        ('PlayerName', ctypes.c_char * 33),
        ('Job', ctypes.c_ubyte),
        ('LV', ctypes.c_ushort),
        ('RealmLV', ctypes.c_ubyte),
        ('AssistType', ctypes.c_ubyte),
        ('MapID', ctypes.c_ulong),
        ('LineID', ctypes.c_ulong),
        ('NPCID', ctypes.c_ulong),
        ('ExDataLen', ctypes.c_ushort),
        ('ExData', ctypes.c_char_p),
        ('ADOResult', ctypes.c_ulong),
    ]
    def __init__(self):
        Structure.__init__(self)
        self.clear()
    def clear(self):
        self.GUID = ''
        self.FamilyID = 0
        self.PlayerID = 0
        self.PlayerName = ''
        self.Job = 0
        self.LV = 0
        self.RealmLV = 0
        self.AssistType = 0
        self.MapID = 0
        self.LineID = 0
        self.NPCID = 0
        self.ExDataLen = 0
        self.ExData = ''
    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.GUID, pos = CommFunc.ReadString(buf, pos, 40)
        self.FamilyID, pos = CommFunc.ReadDWORD(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.LV, pos = CommFunc.ReadWORD(buf, pos)
        self.RealmLV, pos = CommFunc.ReadBYTE(buf, pos)
        self.AssistType, pos = CommFunc.ReadBYTE(buf, pos)
        self.MapID, pos = CommFunc.ReadDWORD(buf, pos)
        self.LineID, pos = CommFunc.ReadDWORD(buf, pos)
        self.NPCID, pos = CommFunc.ReadDWORD(buf, pos)
        self.ExDataLen, pos = CommFunc.ReadWORD(buf, pos)
        tmp, pos = CommFunc.ReadString(buf, pos, self.ExDataLen)
        self.ExData = ctypes.c_char_p(tmp)
        return self.getLength()
    def getBuffer(self):
        buf = ''
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 40, self.GUID)
        buf = CommFunc.WriteDWORD(buf, self.FamilyID)
        buf = CommFunc.WriteDWORD(buf, self.PlayerID)
        buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.PlayerName)
        buf = CommFunc.WriteBYTE(buf, self.Job)
        buf = CommFunc.WriteWORD(buf, self.LV)
        buf = CommFunc.WriteBYTE(buf, self.RealmLV)
        buf = CommFunc.WriteBYTE(buf, self.AssistType)
        buf = CommFunc.WriteDWORD(buf, self.MapID)
        buf = CommFunc.WriteDWORD(buf, self.LineID)
        buf = CommFunc.WriteDWORD(buf, self.NPCID)
        buf = CommFunc.WriteWORD(buf, self.ExDataLen)
        buf = CommFunc.WriteString(buf, self.ExDataLen, self.ExData)
        return buf
    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_char) * 33
        length += sizeof(ctypes.c_ubyte)
        length += sizeof(ctypes.c_ushort)
        length += sizeof(ctypes.c_ubyte)
        length += sizeof(ctypes.c_ubyte)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ulong)
        length += sizeof(ctypes.c_ushort)
        length += self.ExDataLen
        return length
    def outputString(self):
        output = '''// 协助表 #tagDBAssist:
            GUID = %s,
            FamilyID = %s,
            PlayerID = %s,
            PlayerName = %s,
            Job = %s,
            LV = %s,
            RealmLV = %s,
            AssistType = %s,
            MapID = %s,
            LineID = %s,
            NPCID = %s,
            ExDataLen = %s,
            ExData = %s,
            ADOResult = %s,
            '''%(
                self.GUID,
                self.FamilyID,
                self.PlayerID,
                self.PlayerName,
                self.Job,
                self.LV,
                self.RealmLV,
                self.AssistType,
                self.MapID,
                self.LineID,
                self.NPCID,
                self.ExDataLen,
                self.ExData,
                self.ADOResult,
            )
        return output
    #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
    def SetGUID(self,Str):
        if len(Str)<=40:
            self.GUID = Str
        else:
            self.GUID = Str[:40]
    def SetPlayerName(self,Str):
        if len(Str)<=33:
            self.PlayerName = Str
        else:
            self.PlayerName = Str[:33]
            
            
# 玩家数据查看缓存表Py #tagPlayerViewCachePy