From a7ee20f2467c3d04d23ad80ebd25e07b806b5c22 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 03 十一月 2025 10:47:21 +0800
Subject: [PATCH] 129 【战斗】战斗系统-服务端(词条技能1021、1022、1024;增加触发方式25-受到持续伤害,26-敌方单位死亡时,27-己方单位死亡时;优化效果6008可配置免控类型;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Collections/DataServerPlayerData.py | 4252 ++++++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 3,036 insertions(+), 1,216 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Collections/DataServerPlayerData.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Collections/DataServerPlayerData.py
index 5ada8ed..3b09467 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Collections/DataServerPlayerData.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyMongoDB/Collections/DataServerPlayerData.py
@@ -1898,7 +1898,7 @@
('ItemGUID', ctypes.c_char * 40),
('PlayerID', ctypes.c_ulong),
('ItemTypeID', ctypes.c_ulong),
- ('Count', ctypes.c_ushort),
+ ('Count', ctypes.c_ulong),
('IsLocked', ctypes.c_ubyte),
('ItemPlaceType', ctypes.c_ubyte),
('ItemPlaceIndex', ctypes.c_ushort),
@@ -1946,7 +1946,7 @@
self.ItemGUID, pos = CommFunc.ReadString(buf, pos, 40)
self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
self.ItemTypeID, pos = CommFunc.ReadDWORD(buf, pos)
- self.Count, pos = CommFunc.ReadWORD(buf, pos)
+ self.Count, pos = CommFunc.ReadDWORD(buf, pos)
self.IsLocked, pos = CommFunc.ReadBYTE(buf, pos)
self.ItemPlaceType, pos = CommFunc.ReadBYTE(buf, pos)
self.ItemPlaceIndex, pos = CommFunc.ReadWORD(buf, pos)
@@ -1965,7 +1965,7 @@
buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 40, self.ItemGUID)
buf = CommFunc.WriteDWORD(buf, self.PlayerID)
buf = CommFunc.WriteDWORD(buf, self.ItemTypeID)
- buf = CommFunc.WriteWORD(buf, self.Count)
+ buf = CommFunc.WriteDWORD(buf, self.Count)
buf = CommFunc.WriteBYTE(buf, self.IsLocked)
buf = CommFunc.WriteBYTE(buf, self.ItemPlaceType)
buf = CommFunc.WriteWORD(buf, self.ItemPlaceIndex)
@@ -1983,7 +1983,7 @@
length += sizeof(ctypes.c_char) * 40
length += sizeof(ctypes.c_ulong)
length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_ushort)
+ length += sizeof(ctypes.c_ulong)
length += sizeof(ctypes.c_ubyte)
length += sizeof(ctypes.c_ubyte)
length += sizeof(ctypes.c_ushort)
@@ -2259,7 +2259,6 @@
self.CreateTime = Str
else:
self.CreateTime = Str[:30]
-
@@ -5369,415 +5368,6 @@
#------------------------------------------------------
-#排行榜#tagDBBillboard
-class tagDBBillboard(Structure):
- _pack_ = 1
- _fields_ = [
- ('Type', ctypes.c_ubyte),
- ('ID', ctypes.c_ulong),
- ('ID2', ctypes.c_ulong),
- ('Name1', ctypes.c_char * 33),
- ('Name2', ctypes.c_char * 65),
- ('Type2', ctypes.c_ubyte),
- ('Value1', ctypes.c_ulong),
- ('Value2', ctypes.c_ulong),
- ('Value3', ctypes.c_ulong),
- ('Value4', ctypes.c_ulong),
- ('Value5', ctypes.c_ulong),
- ('Value6', ctypes.c_ulong),
- ('Value7', ctypes.c_ulong),
- ('Value8', ctypes.c_ulong),
- ('CmpValue', ctypes.c_ulong),
- ('CmpValue2', ctypes.c_ulong),
- ('CmpValue3', ctypes.c_ulong),
- ('DataLen', ctypes.c_ushort),
- ('UserData', ctypes.c_char_p),
- ('ADOResult', ctypes.c_ulong),
- ]
-
- def __init__(self):
- Structure.__init__(self)
- self.clear()
-
- def clear(self):
- self.Type = 0
- self.ID = 0
- self.ID2 = 0
- self.Name1 = ''
- self.Name2 = ''
- self.Type2 = 0
- self.Value1 = 0
- self.Value2 = 0
- self.Value3 = 0
- self.Value4 = 0
- self.Value5 = 0
- self.Value6 = 0
- self.Value7 = 0
- self.Value8 = 0
- self.CmpValue = 0
- self.CmpValue2 = 0
- self.CmpValue3 = 0
- self.DataLen = 0
- self.UserData = ''
-
- def readData(self, buf, pos = 0, length = 0):
- if not pos <= length:
- msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
- mylog.error(msg)
- return -1
- if len(buf) < pos + self.getLength():
- msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
- mylog.error(msg)
- self.clear()
- self.Type, 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, 65)
- self.Type2, pos = CommFunc.ReadBYTE(buf, pos)
- self.Value1, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value2, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value3, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value4, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value5, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value6, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value7, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value8, 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)
- self.DataLen, pos = CommFunc.ReadWORD(buf, pos)
- tmp, pos = CommFunc.ReadString(buf, pos, self.DataLen)
- self.UserData = ctypes.c_char_p(tmp)
- return self.getLength()
-
- def getBuffer(self):
- buf = ''
- buf = CommFunc.WriteBYTE(buf, self.Type)
- buf = CommFunc.WriteDWORD(buf, self.ID)
- buf = CommFunc.WriteDWORD(buf, self.ID2)
- buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.Name1)
- buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 65, self.Name2)
- buf = CommFunc.WriteBYTE(buf, self.Type2)
- buf = CommFunc.WriteDWORD(buf, self.Value1)
- buf = CommFunc.WriteDWORD(buf, self.Value2)
- buf = CommFunc.WriteDWORD(buf, self.Value3)
- buf = CommFunc.WriteDWORD(buf, self.Value4)
- buf = CommFunc.WriteDWORD(buf, self.Value5)
- buf = CommFunc.WriteDWORD(buf, self.Value6)
- buf = CommFunc.WriteDWORD(buf, self.Value7)
- buf = CommFunc.WriteDWORD(buf, self.Value8)
- buf = CommFunc.WriteDWORD(buf, self.CmpValue)
- buf = CommFunc.WriteDWORD(buf, self.CmpValue2)
- buf = CommFunc.WriteDWORD(buf, self.CmpValue3)
- buf = CommFunc.WriteWORD(buf, self.DataLen)
- buf = CommFunc.WriteString(buf, self.DataLen, self.UserData)
- return buf
-
- def getLength(self):
- length = 0
- length += sizeof(ctypes.c_ubyte)
- length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_char) * 33
- length += sizeof(ctypes.c_char) * 65
- 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_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_ulong)
- length += sizeof(ctypes.c_ushort)
- length += self.DataLen
- return length
-
- def getRecord(self):
- '''组织存储记录'''
- rec = {}
- rec[u'Type'] = self.Type
- rec[u'ID'] = self.ID
- rec[u'ID2'] = self.ID2
- rec[u'Name1'] = fix_incomingText(self.Name1)
- rec[u'Name2'] = fix_incomingText(self.Name2)
- rec[u'Type2'] = self.Type2
- rec[u'Value1'] = self.Value1
- rec[u'Value2'] = self.Value2
- rec[u'Value3'] = self.Value3
- rec[u'Value4'] = self.Value4
- rec[u'Value5'] = self.Value5
- rec[u'Value6'] = self.Value6
- rec[u'Value7'] = self.Value7
- rec[u'Value8'] = self.Value8
- rec[u'CmpValue'] = self.CmpValue
- rec[u'CmpValue2'] = self.CmpValue2
- rec[u'CmpValue3'] = self.CmpValue3
- rec[u'DataLen'] = self.DataLen
- rec[u'UserData'] = fix_incomingText(self.UserData)
- return rec
-
- def readRecord(self, rec):
- '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
- self.Type = rec.get(u'Type', 0)
- self.ID = rec.get(u'ID', 0)
- self.ID2 = rec.get(u'ID2', 0)
- self.Name1 = fix_outgoingText(rec.get(u'Name1', u''))
- self.Name2 = fix_outgoingText(rec.get(u'Name2', u''))
- self.Type2 = rec.get(u'Type2', 0)
- self.Value1 = rec.get(u'Value1', 0)
- self.Value2 = rec.get(u'Value2', 0)
- self.Value3 = rec.get(u'Value3', 0)
- self.Value4 = rec.get(u'Value4', 0)
- self.Value5 = rec.get(u'Value5', 0)
- self.Value6 = rec.get(u'Value6', 0)
- self.Value7 = rec.get(u'Value7', 0)
- self.Value8 = rec.get(u'Value8', 0)
- self.CmpValue = rec.get(u'CmpValue', 0)
- self.CmpValue2 = rec.get(u'CmpValue2', 0)
- self.CmpValue3 = rec.get(u'CmpValue3', 0)
- self.DataLen = rec.get(u'DataLen', 0)
- self.UserData = fix_outgoingText(rec.get(u'UserData', u''))
-
- def adoLoad(self, collection):
- '''使用KEY查找并读取'''
- resultCollection = collection.find({'Type':self.Type,'ID':self.ID,})
-
- if resultCollection.count() <= 0:
- return False
- #由于是KEY查找,所有如果存在就只有一条记录
- rec = resultCollection[0]
- #读取数据
- self.readRecord(rec)
- return True
-
-
- def adoInsert(self, collection):
- '''执行插入'''
-
- trycnt = 0
- rec = self.getRecord()
- while(True):
- try:
- collection.insert(rec, False, True)
- break
- except pymongo.errors.OperationFailure, err:
-
- if(DBConfig.TryCntOnWriteFail > trycnt):
- trycnt += 1
- continue
-
- addADOExceptionCount()
- mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
- msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!Type = %s, error = %s, trycnt = %d'%(self.Type, err, trycnt))
- mylog.error(msg)
-
- return False
- return True
-
-
- def adoUpdate(self, collection):
- '''执行更新'''
- trycnt = 0
- rec = self.getRecord()
- while(True):
- try:
- collection.update({'Type':self.Type,'ID':self.ID,}, {'$set':rec}, False, False, True, True)
- break
- except pymongo.errors.OperationFailure, err:
- if(DBConfig.TryCntOnWriteFail > trycnt):
- trycnt += 1
- continue
-
- addADOExceptionCount()
- mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
- msg = error.formatMsg('error', error.ERROR_NO_153, 'Update failed!Type = %s, error = %s, trycnt = %d'%(self.Type, err, trycnt))
- mylog.error(msg)
-
- return False
- return True
-
-
- def adoUpdateEx(self, collection, spec):
- '''执行更新'''
- trycnt = 0
- rec = self.getRecord()
- while(True):
- try:
- collection.update(spec, {'$set':rec}, False, False, True, True)
- break
- except pymongo.errors.OperationFailure, err:
- if(DBConfig.TryCntOnWriteFail > trycnt):
- trycnt += 1
- continue
- addADOExceptionCount()
- mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
- msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!Type = %s, error = %s, trycnt = %d'%(self.Type, err, trycnt))
- mylog.error(msg)
-
- return False
- return True
-
-
- def adoCheckUpdate(self, collection):
- '''根据情况执行插入或更新'''
- resultCollection = collection.find({'Type':self.Type,'ID':self.ID,})
-
- if resultCollection.count() <= 0:
- return self.adoInsert(collection)
- return self.adoUpdate(collection)
-
-
- def adoCheckUpdateEx(self, collection, spec):
- '''根据情况执行插入或更新'''
- resultCollection = collection.find(spec)
-
- if resultCollection.count() <= 0:
- return self.adoInsert(collection)
- return self.adoUpdateEx(collection, spec)
-
-
- def getAdoRecords(self, resultCollection):
- '''查询结果打包成二进制流'''
- result = ''
- result = CommFunc.WriteDWORD(result, resultCollection.count())
- for rec in resultCollection:
- self.readRecord(rec)
- result += self.getBuffer()
- return result
-
-
- def adoQueryIndex(self, collection):
- '''用索引字段查找'''
- resultCollection = collection.find({'Type':self.Type})
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoQueryCustom(self, collection, queryDict):
- '''自定义查询'''
- resultCollection = collection.find(queryDict)
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoQueryAll(self, collection):
- '''查询所有'''
- resultCollection = collection.find()
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoDeleteByIndex(self, collection):
- '''根据索引删除'''
- trycnt = 0
- while(True):
- try:
- collection.remove({'Type':self.Type})
- break
- except pymongo.errors.OperationFailure, err:
- if(DBConfig.TryCntOnWriteFail > trycnt):
- trycnt += 1
- continue
- addADOExceptionCount()
- mylog.info("%s.%s:Type = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.Type))
- msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.Type = %s, error = %s, trycnt = %d'%(self.Type, err, trycnt))
- mylog.error(msg)
-
- return False
- return True
-
- def outputString(self):
- output = '''//排行榜#tagDBBillboard:
- Type = %s,
- ID = %s,
- ID2 = %s,
- Name1 = %s,
- Name2 = %s,
- Type2 = %s,
- Value1 = %s,
- Value2 = %s,
- Value3 = %s,
- Value4 = %s,
- Value5 = %s,
- Value6 = %s,
- Value7 = %s,
- Value8 = %s,
- CmpValue = %s,
- CmpValue2 = %s,
- CmpValue3 = %s,
- DataLen = %s,
- UserData = %s,
- ADOResult = %s,
- '''%(
- self.Type,
- self.ID,
- self.ID2,
- self.Name1,
- self.Name2,
- self.Type2,
- self.Value1,
- self.Value2,
- self.Value3,
- self.Value4,
- self.Value5,
- self.Value6,
- self.Value7,
- self.Value8,
- self.CmpValue,
- self.CmpValue2,
- self.CmpValue3,
- self.DataLen,
- self.UserData,
- self.ADOResult,
- )
- return output
-
- def dumpString(self):
- output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
- self.Type,
- self.ID,
- self.ID2,
- self.Name1,
- self.Name2,
- self.Type2,
- self.Value1,
- self.Value2,
- self.Value3,
- self.Value4,
- self.Value5,
- self.Value6,
- self.Value7,
- self.Value8,
- self.CmpValue,
- self.CmpValue2,
- self.CmpValue3,
- self.DataLen,
- self.UserData,
- )
- 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)<=65:
- self.Name2 = Str
- else:
- self.Name2 = Str[:65]
-
-
-
-
-#------------------------------------------------------
#国家家族战排位赛表#tagDBCountryFamilyWarRace
class tagDBCountryFamilyWarRace(Structure):
_pack_ = 1
@@ -6676,288 +6266,7 @@
else:
self.KingName = Str[:33]
-#------------------------------------------------------
-#家族行为表#tagDBFamilyAction
-class tagDBFamilyAction(Structure):
- _pack_ = 1
- _fields_ = [
- ('FamilyID', ctypes.c_ulong),
- ('ActionType', ctypes.c_ubyte),
- ('Name', ctypes.c_char * 33),
- ('Time', ctypes.c_double),
- ('Value1', ctypes.c_ulong),
- ('Value2', ctypes.c_ulong),
- ('Value3', ctypes.c_ulong),
- ('Value4', ctypes.c_ulong),
- ('Value5', ctypes.c_ulong),
- ('Value6', ctypes.c_ulong),
- ('DataLen', ctypes.c_ushort),
- ('Data', ctypes.c_char_p),
- ('ADOResult', ctypes.c_ulong),
- ]
- def __init__(self):
- Structure.__init__(self)
- self.clear()
-
- def clear(self):
- self.FamilyID = 0
- self.ActionType = 0
- self.Name = ''
- self.Time = 0.0
- self.Value1 = 0
- self.Value2 = 0
- self.Value3 = 0
- self.Value4 = 0
- self.Value5 = 0
- self.Value6 = 0
- self.DataLen = 0
- self.Data = ''
-
- def readData(self, buf, pos = 0, length = 0):
- if not pos <= length:
- msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
- mylog.error(msg)
- return -1
- if len(buf) < pos + self.getLength():
- msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
- mylog.error(msg)
- self.clear()
- self.FamilyID, pos = CommFunc.ReadDWORD(buf, pos)
- self.ActionType, pos = CommFunc.ReadBYTE(buf, pos)
- self.Name, pos = CommFunc.ReadString(buf, pos, 33)
- self.Time, pos = CommFunc.ReadDouble(buf, pos)
- self.Value1, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value2, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value3, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value4, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value5, pos = CommFunc.ReadDWORD(buf, pos)
- self.Value6, pos = CommFunc.ReadDWORD(buf, pos)
- self.DataLen, pos = CommFunc.ReadWORD(buf, pos)
- tmp, pos = CommFunc.ReadString(buf, pos, self.DataLen)
- self.Data = ctypes.c_char_p(tmp)
- return self.getLength()
-
- def getBuffer(self):
- buf = ''
- buf = CommFunc.WriteDWORD(buf, self.FamilyID)
- buf = CommFunc.WriteBYTE(buf, self.ActionType)
- buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.Name)
- buf = CommFunc.WriteDouble(buf, self.Time)
- buf = CommFunc.WriteDWORD(buf, self.Value1)
- buf = CommFunc.WriteDWORD(buf, self.Value2)
- buf = CommFunc.WriteDWORD(buf, self.Value3)
- buf = CommFunc.WriteDWORD(buf, self.Value4)
- buf = CommFunc.WriteDWORD(buf, self.Value5)
- buf = CommFunc.WriteDWORD(buf, self.Value6)
- buf = CommFunc.WriteWORD(buf, self.DataLen)
- buf = CommFunc.WriteString(buf, self.DataLen, self.Data)
- return buf
-
- def getLength(self):
- length = 0
- length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_ubyte)
- length += sizeof(ctypes.c_char) * 33
- length += sizeof(ctypes.c_double)
- 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_ulong)
- length += sizeof(ctypes.c_ushort)
- length += self.DataLen
- return length
-
- def getRecord(self):
- '''组织存储记录'''
- rec = {}
- rec[u'FamilyID'] = self.FamilyID
- rec[u'ActionType'] = self.ActionType
- rec[u'Name'] = fix_incomingText(self.Name)
- rec[u'Time'] = self.Time
- rec[u'Value1'] = self.Value1
- rec[u'Value2'] = self.Value2
- rec[u'Value3'] = self.Value3
- rec[u'Value4'] = self.Value4
- rec[u'Value5'] = self.Value5
- rec[u'Value6'] = self.Value6
- rec[u'DataLen'] = self.DataLen
- rec[u'Data'] = fix_incomingText(self.Data)
- return rec
-
- def readRecord(self, rec):
- '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
- self.FamilyID = rec.get(u'FamilyID', 0)
- self.ActionType = rec.get(u'ActionType', 0)
- self.Name = fix_outgoingText(rec.get(u'Name', u''))
- self.Time = rec.get(u'Time', 0)
- self.Value1 = rec.get(u'Value1', 0)
- self.Value2 = rec.get(u'Value2', 0)
- self.Value3 = rec.get(u'Value3', 0)
- self.Value4 = rec.get(u'Value4', 0)
- self.Value5 = rec.get(u'Value5', 0)
- self.Value6 = rec.get(u'Value6', 0)
- self.DataLen = rec.get(u'DataLen', 0)
- self.Data = fix_outgoingText(rec.get(u'Data', u''))
-
-#Can not implement adoLoadStr method:No key defined!
-
- def adoInsert(self, collection):
- '''执行插入'''
-
- trycnt = 0
- rec = self.getRecord()
- while(True):
- try:
- collection.insert(rec, False, True)
- break
- except pymongo.errors.OperationFailure, err:
-
- if(DBConfig.TryCntOnWriteFail > trycnt):
- trycnt += 1
- continue
-
- addADOExceptionCount()
- mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
- msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!FamilyID = %s, error = %s, trycnt = %d'%(self.FamilyID, err, trycnt))
- mylog.error(msg)
-
- return False
- return True
-
-#Can not implement adoUpdateStr method:No key defined!
-
- def adoUpdateEx(self, collection, spec):
- '''执行更新'''
- trycnt = 0
- rec = self.getRecord()
- while(True):
- try:
- collection.update(spec, {'$set':rec}, False, False, True, True)
- break
- except pymongo.errors.OperationFailure, err:
- if(DBConfig.TryCntOnWriteFail > trycnt):
- trycnt += 1
- continue
- addADOExceptionCount()
- mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
- msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!FamilyID = %s, error = %s, trycnt = %d'%(self.FamilyID, err, trycnt))
- mylog.error(msg)
-
- return False
- return True
-
-#Can not implement adoCheckUpdateStr method:No key defined!
-#Can not implement adoCheckUpdateExStr method:No key defined!
-
- def getAdoRecords(self, resultCollection):
- '''查询结果打包成二进制流'''
- result = ''
- result = CommFunc.WriteDWORD(result, resultCollection.count())
- for rec in resultCollection:
- self.readRecord(rec)
- result += self.getBuffer()
- return result
-
-
- def adoQueryIndex(self, collection):
- '''用索引字段查找'''
- resultCollection = collection.find({'FamilyID':self.FamilyID})
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoQueryCustom(self, collection, queryDict):
- '''自定义查询'''
- resultCollection = collection.find(queryDict)
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoQueryAll(self, collection):
- '''查询所有'''
- resultCollection = collection.find()
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoDeleteByIndex(self, collection):
- '''根据索引删除'''
- trycnt = 0
- while(True):
- try:
- collection.remove({'FamilyID':self.FamilyID})
- break
- except pymongo.errors.OperationFailure, err:
- if(DBConfig.TryCntOnWriteFail > trycnt):
- trycnt += 1
- continue
- addADOExceptionCount()
- mylog.info("%s.%s:FamilyID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.FamilyID))
- msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.FamilyID = %s, error = %s, trycnt = %d'%(self.FamilyID, err, trycnt))
- mylog.error(msg)
-
- return False
- return True
-
- def outputString(self):
- output = '''//家族行为表#tagDBFamilyAction:
- FamilyID = %s,
- ActionType = %s,
- Name = %s,
- Time = %s,
- Value1 = %s,
- Value2 = %s,
- Value3 = %s,
- Value4 = %s,
- Value5 = %s,
- Value6 = %s,
- DataLen = %s,
- Data = %s,
- ADOResult = %s,
- '''%(
- self.FamilyID,
- self.ActionType,
- self.Name,
- self.Time,
- self.Value1,
- self.Value2,
- self.Value3,
- self.Value4,
- self.Value5,
- self.Value6,
- self.DataLen,
- self.Data,
- self.ADOResult,
- )
- return output
-
- def dumpString(self):
- output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
- self.FamilyID,
- self.ActionType,
- self.Name,
- self.Time,
- self.Value1,
- self.Value2,
- self.Value3,
- self.Value4,
- self.Value5,
- self.Value6,
- self.DataLen,
- self.Data,
- )
- return output
-
- #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
- def SetName(self,Str):
- if len(Str)<=33:
- self.Name = Str
- else:
- self.Name = Str[:33]
-
#------------------------------------------------------
#帮会科技表#tagDBFamilyTech
@@ -25279,527 +24588,6 @@
)
return output
-
-# 福地矿物表 #tagDBPyMineAreaItem
-class tagDBPyMineAreaItem(Structure):
- _pack_ = 1
- _fields_ = [
- ('PlayerID', ctypes.c_ulong),
- ('Index', ctypes.c_ubyte),
- ('MineID', ctypes.c_ushort),
- ('MineType', ctypes.c_ubyte),
- ('UpdTime', ctypes.c_ulong),
- ('PosLen', ctypes.c_ubyte),
- ('Position', ctypes.c_char_p),
- ('WorkerCount', ctypes.c_ubyte),
- ('WorkerState', ctypes.c_ubyte),
- ('RobPlayerID', ctypes.c_ulong),
- ('RobWorkerCount', ctypes.c_ubyte),
- ('RobWorkerState', ctypes.c_ubyte),
- ('ADOResult', ctypes.c_ulong),
- ]
-
- def __init__(self):
- Structure.__init__(self)
- self.clear()
-
- def clear(self):
- self.PlayerID = 0
- self.Index = 0
- self.MineID = 0
- self.MineType = 0
- self.UpdTime = 0
- self.PosLen = 0
- self.Position = ''
- self.WorkerCount = 0
- self.WorkerState = 0
- self.RobPlayerID = 0
- self.RobWorkerCount = 0
- self.RobWorkerState = 0
-
- def readData(self, buf, pos = 0, length = 0):
- if not pos <= length:
- msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
- mylog.error(msg)
- return -1
- if len(buf) < pos + self.getLength():
- msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
- mylog.error(msg)
- self.clear()
- self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
- self.Index, pos = CommFunc.ReadBYTE(buf, pos)
- self.MineID, pos = CommFunc.ReadWORD(buf, pos)
- self.MineType, pos = CommFunc.ReadBYTE(buf, pos)
- self.UpdTime, pos = CommFunc.ReadDWORD(buf, pos)
- self.PosLen, pos = CommFunc.ReadBYTE(buf, pos)
- tmp, pos = CommFunc.ReadString(buf, pos, self.PosLen)
- self.Position = ctypes.c_char_p(tmp)
- self.WorkerCount, pos = CommFunc.ReadBYTE(buf, pos)
- self.WorkerState, pos = CommFunc.ReadBYTE(buf, pos)
- self.RobPlayerID, pos = CommFunc.ReadDWORD(buf, pos)
- self.RobWorkerCount, pos = CommFunc.ReadBYTE(buf, pos)
- self.RobWorkerState, pos = CommFunc.ReadBYTE(buf, pos)
- return self.getLength()
-
- def getBuffer(self):
- buf = ''
- buf = CommFunc.WriteDWORD(buf, self.PlayerID)
- buf = CommFunc.WriteBYTE(buf, self.Index)
- buf = CommFunc.WriteWORD(buf, self.MineID)
- buf = CommFunc.WriteBYTE(buf, self.MineType)
- buf = CommFunc.WriteDWORD(buf, self.UpdTime)
- buf = CommFunc.WriteBYTE(buf, self.PosLen)
- buf = CommFunc.WriteString(buf, self.PosLen, self.Position)
- buf = CommFunc.WriteBYTE(buf, self.WorkerCount)
- buf = CommFunc.WriteBYTE(buf, self.WorkerState)
- buf = CommFunc.WriteDWORD(buf, self.RobPlayerID)
- buf = CommFunc.WriteBYTE(buf, self.RobWorkerCount)
- buf = CommFunc.WriteBYTE(buf, self.RobWorkerState)
- return buf
-
- def getLength(self):
- length = 0
- length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_ubyte)
- length += sizeof(ctypes.c_ushort)
- length += sizeof(ctypes.c_ubyte)
- length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_ubyte)
- length += self.PosLen
- length += sizeof(ctypes.c_ubyte)
- length += sizeof(ctypes.c_ubyte)
- length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_ubyte)
- length += sizeof(ctypes.c_ubyte)
- return length
-
- def getRecord(self):
- '''组织存储记录'''
- rec = {}
- rec[u'PlayerID'] = self.PlayerID
- rec[u'Index'] = self.Index
- rec[u'MineID'] = self.MineID
- rec[u'MineType'] = self.MineType
- rec[u'UpdTime'] = self.UpdTime
- rec[u'PosLen'] = self.PosLen
- rec[u'Position'] = fix_incomingText(self.Position)
- rec[u'WorkerCount'] = self.WorkerCount
- rec[u'WorkerState'] = self.WorkerState
- rec[u'RobPlayerID'] = self.RobPlayerID
- rec[u'RobWorkerCount'] = self.RobWorkerCount
- rec[u'RobWorkerState'] = self.RobWorkerState
- return rec
-
- def readRecord(self, rec):
- '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
- self.PlayerID = rec.get(u'PlayerID', 0)
- self.Index = rec.get(u'Index', 0)
- self.MineID = rec.get(u'MineID', 0)
- self.MineType = rec.get(u'MineType', 0)
- self.UpdTime = rec.get(u'UpdTime', 0)
- self.PosLen = rec.get(u'PosLen', 0)
- self.Position = fix_outgoingText(rec.get(u'Position', u''))
- self.WorkerCount = rec.get(u'WorkerCount', 0)
- self.WorkerState = rec.get(u'WorkerState', 0)
- self.RobPlayerID = rec.get(u'RobPlayerID', 0)
- self.RobWorkerCount = rec.get(u'RobWorkerCount', 0)
- self.RobWorkerState = rec.get(u'RobWorkerState', 0)
-
-#Can not implement adoLoadStr method:No key defined!
-#Can not implement adoInsertStr method:No key defined!
-#Can not implement adoUpdateStr method:No key defined!
-#Can not implement adoUpdateStr method:No key defined!
-#Can not implement adoCheckUpdateStr method:No key defined!
-#Can not implement adoCheckUpdateExStr method:No key defined!
-
- def getAdoRecords(self, resultCollection):
- '''查询结果打包成二进制流'''
- result = ''
- result = CommFunc.WriteDWORD(result, resultCollection.count())
- for rec in resultCollection:
- self.readRecord(rec)
- result += self.getBuffer()
- return result
-
-#Can not implement adoQueryIndexStr method:No key defined!
-
- def adoQueryCustom(self, collection, queryDict):
- '''自定义查询'''
- resultCollection = collection.find(queryDict)
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoQueryAll(self, collection):
- '''查询所有'''
- resultCollection = collection.find()
-
- return self.getAdoRecords(resultCollection)
-
-#Can not implement adoDeleteByIndexStr method:No key defined!
- def outputString(self):
- output = '''// 福地矿物表 #tagDBPyMineAreaItem:
- PlayerID = %s,
- Index = %s,
- MineID = %s,
- MineType = %s,
- UpdTime = %s,
- PosLen = %s,
- Position = %s,
- WorkerCount = %s,
- WorkerState = %s,
- RobPlayerID = %s,
- RobWorkerCount = %s,
- RobWorkerState = %s,
- ADOResult = %s,
- '''%(
- self.PlayerID,
- self.Index,
- self.MineID,
- self.MineType,
- self.UpdTime,
- self.PosLen,
- self.Position,
- self.WorkerCount,
- self.WorkerState,
- self.RobPlayerID,
- self.RobWorkerCount,
- self.RobWorkerState,
- self.ADOResult,
- )
- return output
-
- def dumpString(self):
- output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
- self.PlayerID,
- self.Index,
- self.MineID,
- self.MineType,
- self.UpdTime,
- self.PosLen,
- self.Position,
- self.WorkerCount,
- self.WorkerState,
- self.RobPlayerID,
- self.RobWorkerCount,
- self.RobWorkerState,
- )
- return output
-
-
-# 福地记录表 #tagDBPyMineAreaRecord
-class tagDBPyMineAreaRecord(Structure):
- _pack_ = 1
- _fields_ = [
- ('PlayerID', ctypes.c_ulong),
- ('RecordType', ctypes.c_ulong),
- ('TagPlayerID', ctypes.c_ulong),
- ('RecordTime', ctypes.c_ulong),
- ('MineID', ctypes.c_ushort),
- ('DataLen', ctypes.c_ushort),
- ('Data', ctypes.c_char_p),
- ('ADOResult', ctypes.c_ulong),
- ]
-
- def __init__(self):
- Structure.__init__(self)
- self.clear()
-
- def clear(self):
- self.PlayerID = 0
- self.RecordType = 0
- self.TagPlayerID = 0
- self.RecordTime = 0
- self.MineID = 0
- self.DataLen = 0
- self.Data = ''
-
- def readData(self, buf, pos = 0, length = 0):
- if not pos <= length:
- msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
- mylog.error(msg)
- return -1
- if len(buf) < pos + self.getLength():
- msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
- mylog.error(msg)
- self.clear()
- self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
- self.RecordType, pos = CommFunc.ReadDWORD(buf, pos)
- self.TagPlayerID, pos = CommFunc.ReadDWORD(buf, pos)
- self.RecordTime, pos = CommFunc.ReadDWORD(buf, pos)
- self.MineID, pos = CommFunc.ReadWORD(buf, pos)
- self.DataLen, pos = CommFunc.ReadWORD(buf, pos)
- tmp, pos = CommFunc.ReadString(buf, pos, self.DataLen)
- self.Data = ctypes.c_char_p(tmp)
- return self.getLength()
-
- def getBuffer(self):
- buf = ''
- buf = CommFunc.WriteDWORD(buf, self.PlayerID)
- buf = CommFunc.WriteDWORD(buf, self.RecordType)
- buf = CommFunc.WriteDWORD(buf, self.TagPlayerID)
- buf = CommFunc.WriteDWORD(buf, self.RecordTime)
- buf = CommFunc.WriteWORD(buf, self.MineID)
- buf = CommFunc.WriteWORD(buf, self.DataLen)
- buf = CommFunc.WriteString(buf, self.DataLen, self.Data)
- return buf
-
- def getLength(self):
- length = 0
- 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 += sizeof(ctypes.c_ushort)
- length += self.DataLen
- return length
-
- def getRecord(self):
- '''组织存储记录'''
- rec = {}
- rec[u'PlayerID'] = self.PlayerID
- rec[u'RecordType'] = self.RecordType
- rec[u'TagPlayerID'] = self.TagPlayerID
- rec[u'RecordTime'] = self.RecordTime
- rec[u'MineID'] = self.MineID
- rec[u'DataLen'] = self.DataLen
- rec[u'Data'] = fix_incomingText(self.Data)
- return rec
-
- def readRecord(self, rec):
- '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
- self.PlayerID = rec.get(u'PlayerID', 0)
- self.RecordType = rec.get(u'RecordType', 0)
- self.TagPlayerID = rec.get(u'TagPlayerID', 0)
- self.RecordTime = rec.get(u'RecordTime', 0)
- self.MineID = rec.get(u'MineID', 0)
- self.DataLen = rec.get(u'DataLen', 0)
- self.Data = fix_outgoingText(rec.get(u'Data', u''))
-
-#Can not implement adoLoadStr method:No key defined!
-#Can not implement adoInsertStr method:No key defined!
-#Can not implement adoUpdateStr method:No key defined!
-#Can not implement adoUpdateStr method:No key defined!
-#Can not implement adoCheckUpdateStr method:No key defined!
-#Can not implement adoCheckUpdateExStr method:No key defined!
-
- def getAdoRecords(self, resultCollection):
- '''查询结果打包成二进制流'''
- result = ''
- result = CommFunc.WriteDWORD(result, resultCollection.count())
- for rec in resultCollection:
- self.readRecord(rec)
- result += self.getBuffer()
- return result
-
-#Can not implement adoQueryIndexStr method:No key defined!
-
- def adoQueryCustom(self, collection, queryDict):
- '''自定义查询'''
- resultCollection = collection.find(queryDict)
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoQueryAll(self, collection):
- '''查询所有'''
- resultCollection = collection.find()
-
- return self.getAdoRecords(resultCollection)
-
-#Can not implement adoDeleteByIndexStr method:No key defined!
- def outputString(self):
- output = '''// 福地记录表 #tagDBPyMineAreaRecord:
- PlayerID = %s,
- RecordType = %s,
- TagPlayerID = %s,
- RecordTime = %s,
- MineID = %s,
- DataLen = %s,
- Data = %s,
- ADOResult = %s,
- '''%(
- self.PlayerID,
- self.RecordType,
- self.TagPlayerID,
- self.RecordTime,
- self.MineID,
- self.DataLen,
- self.Data,
- self.ADOResult,
- )
- return output
-
- def dumpString(self):
- output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
- self.PlayerID,
- self.RecordType,
- self.TagPlayerID,
- self.RecordTime,
- self.MineID,
- self.DataLen,
- self.Data,
- )
- return output
-
-
-# 福地结算奖励表 #tagDBPyMineAreaAward
-class tagDBPyMineAreaAward(Structure):
- _pack_ = 1
- _fields_ = [
- ('GUIDLen', ctypes.c_ubyte),
- ('GUID', ctypes.c_char_p),
- ('PlayerID', ctypes.c_ulong),
- ('AwardTime', ctypes.c_ulong),
- ('MineID', ctypes.c_ushort),
- ('WorkerCount', ctypes.c_ubyte),
- ('AreaPlayerID', ctypes.c_ulong),
- ('ADOResult', ctypes.c_ulong),
- ]
-
- def __init__(self):
- Structure.__init__(self)
- self.clear()
-
- def clear(self):
- self.GUIDLen = 0
- self.GUID = ''
- self.PlayerID = 0
- self.AwardTime = 0
- self.MineID = 0
- self.WorkerCount = 0
- self.AreaPlayerID = 0
-
- def readData(self, buf, pos = 0, length = 0):
- if not pos <= length:
- msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
- mylog.error(msg)
- return -1
- if len(buf) < pos + self.getLength():
- msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
- mylog.error(msg)
- self.clear()
- self.GUIDLen, pos = CommFunc.ReadBYTE(buf, pos)
- tmp, pos = CommFunc.ReadString(buf, pos, self.GUIDLen)
- self.GUID = ctypes.c_char_p(tmp)
- self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
- self.AwardTime, pos = CommFunc.ReadDWORD(buf, pos)
- self.MineID, pos = CommFunc.ReadWORD(buf, pos)
- self.WorkerCount, pos = CommFunc.ReadBYTE(buf, pos)
- self.AreaPlayerID, pos = CommFunc.ReadDWORD(buf, pos)
- return self.getLength()
-
- def getBuffer(self):
- buf = ''
- buf = CommFunc.WriteBYTE(buf, self.GUIDLen)
- buf = CommFunc.WriteString(buf, self.GUIDLen, self.GUID)
- buf = CommFunc.WriteDWORD(buf, self.PlayerID)
- buf = CommFunc.WriteDWORD(buf, self.AwardTime)
- buf = CommFunc.WriteWORD(buf, self.MineID)
- buf = CommFunc.WriteBYTE(buf, self.WorkerCount)
- buf = CommFunc.WriteDWORD(buf, self.AreaPlayerID)
- return buf
-
- def getLength(self):
- length = 0
- length += sizeof(ctypes.c_ubyte)
- length += self.GUIDLen
- length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_ulong)
- length += sizeof(ctypes.c_ushort)
- length += sizeof(ctypes.c_ubyte)
- length += sizeof(ctypes.c_ulong)
- return length
-
- def getRecord(self):
- '''组织存储记录'''
- rec = {}
- rec[u'GUIDLen'] = self.GUIDLen
- rec[u'GUID'] = fix_incomingText(self.GUID)
- rec[u'PlayerID'] = self.PlayerID
- rec[u'AwardTime'] = self.AwardTime
- rec[u'MineID'] = self.MineID
- rec[u'WorkerCount'] = self.WorkerCount
- rec[u'AreaPlayerID'] = self.AreaPlayerID
- return rec
-
- def readRecord(self, rec):
- '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
- self.GUIDLen = rec.get(u'GUIDLen', 0)
- self.GUID = fix_outgoingText(rec.get(u'GUID', u''))
- self.PlayerID = rec.get(u'PlayerID', 0)
- self.AwardTime = rec.get(u'AwardTime', 0)
- self.MineID = rec.get(u'MineID', 0)
- self.WorkerCount = rec.get(u'WorkerCount', 0)
- self.AreaPlayerID = rec.get(u'AreaPlayerID', 0)
-
-#Can not implement adoLoadStr method:No key defined!
-#Can not implement adoInsertStr method:No key defined!
-#Can not implement adoUpdateStr method:No key defined!
-#Can not implement adoUpdateStr method:No key defined!
-#Can not implement adoCheckUpdateStr method:No key defined!
-#Can not implement adoCheckUpdateExStr method:No key defined!
-
- def getAdoRecords(self, resultCollection):
- '''查询结果打包成二进制流'''
- result = ''
- result = CommFunc.WriteDWORD(result, resultCollection.count())
- for rec in resultCollection:
- self.readRecord(rec)
- result += self.getBuffer()
- return result
-
-#Can not implement adoQueryIndexStr method:No key defined!
-
- def adoQueryCustom(self, collection, queryDict):
- '''自定义查询'''
- resultCollection = collection.find(queryDict)
-
- return self.getAdoRecords(resultCollection)
-
-
- def adoQueryAll(self, collection):
- '''查询所有'''
- resultCollection = collection.find()
-
- return self.getAdoRecords(resultCollection)
-
-#Can not implement adoDeleteByIndexStr method:No key defined!
- def outputString(self):
- output = '''// 福地结算奖励表 #tagDBPyMineAreaAward:
- GUIDLen = %s,
- GUID = %s,
- PlayerID = %s,
- AwardTime = %s,
- MineID = %s,
- WorkerCount = %s,
- AreaPlayerID = %s,
- ADOResult = %s,
- '''%(
- self.GUIDLen,
- self.GUID,
- self.PlayerID,
- self.AwardTime,
- self.MineID,
- self.WorkerCount,
- self.AreaPlayerID,
- self.ADOResult,
- )
- return output
-
- def dumpString(self):
- output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
- self.GUIDLen,
- self.GUID,
- self.PlayerID,
- self.AwardTime,
- self.MineID,
- self.WorkerCount,
- self.AreaPlayerID,
- )
- return output
-
# 玩家记录表 #tagDBPlayerRecData
class tagDBPlayerRecData(Structure):
@@ -26851,3 +25639,3035 @@
)
return output
+# 事件触发表 #tagDBEventTrig
+class tagDBEventTrig(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('EventLen', ctypes.c_ulong),
+ ('EventID', ctypes.c_char_p),
+ ('EventValue', ctypes.c_ulong),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.EventLen = 0
+ self.EventID = ''
+ self.EventValue = 0
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.EventLen, pos = CommFunc.ReadDWORD(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.EventLen)
+ self.EventID = ctypes.c_char_p(tmp)
+ self.EventValue, pos = CommFunc.ReadDWORD(buf, pos)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteDWORD(buf, self.EventLen)
+ buf = CommFunc.WriteString(buf, self.EventLen, self.EventID)
+ buf = CommFunc.WriteDWORD(buf, self.EventValue)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_ulong)
+ length += self.EventLen
+ length += sizeof(ctypes.c_ulong)
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'EventLen'] = self.EventLen
+ rec[u'EventID'] = fix_incomingText(self.EventID)
+ rec[u'EventValue'] = self.EventValue
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.EventLen = rec.get(u'EventLen', 0)
+ self.EventID = fix_outgoingText(rec.get(u'EventID', u''))
+ self.EventValue = rec.get(u'EventValue', 0)
+
+ def adoLoad(self, collection):
+ '''使用KEY查找并读取'''
+ resultCollection = collection.find({'EventID':fix_incomingText(self.EventID)})
+
+ if resultCollection.count() <= 0:
+ return False
+ #由于是KEY查找,所有如果存在就只有一条记录
+ rec = resultCollection[0]
+ #读取数据
+ self.readRecord(rec)
+ return True
+
+
+ def adoInsert(self, collection):
+ '''执行插入'''
+
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.insert(rec, False, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!EventID = %s, error = %s, trycnt = %d'%(self.EventID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoUpdate(self, collection):
+ '''执行更新'''
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.update({'EventID':fix_incomingText(self.EventID)}, {'$set':rec}, False, False, True, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_153, 'Update failed!EventID = %s, error = %s, trycnt = %d'%(self.EventID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoUpdateEx(self, collection, spec):
+ '''执行更新'''
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.update(spec, {'$set':rec}, False, False, True, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!EventID = %s, error = %s, trycnt = %d'%(self.EventID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoCheckUpdate(self, collection):
+ '''根据情况执行插入或更新'''
+ resultCollection = collection.find({'EventID':fix_incomingText(self.EventID)})
+
+ if resultCollection.count() <= 0:
+ return self.adoInsert(collection)
+ return self.adoUpdate(collection)
+
+
+ def adoCheckUpdateEx(self, collection, spec):
+ '''根据情况执行插入或更新'''
+ resultCollection = collection.find(spec)
+
+ if resultCollection.count() <= 0:
+ return self.adoInsert(collection)
+ return self.adoUpdateEx(collection, spec)
+
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+
+ def adoQueryIndex(self, collection):
+ '''用索引字段查找'''
+ resultCollection = collection.find({'EventID':fix_incomingText(self.EventID)})
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoDeleteByIndex(self, collection):
+ '''根据索引删除'''
+ trycnt = 0
+ while(True):
+ try:
+ collection.remove({'EventID':fix_incomingText(self.EventID)})
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:EventID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.EventID))
+ msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.EventID = %s, error = %s, trycnt = %d'%(self.EventID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+ def outputString(self):
+ output = '''// 事件触发表 #tagDBEventTrig:
+ EventLen = %s,
+ EventID = %s,
+ EventValue = %s,
+ ADOResult = %s,
+ '''%(
+ self.EventLen,
+ self.EventID,
+ self.EventValue,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s'''%(
+ self.EventLen,
+ self.EventID,
+ self.EventValue,
+ )
+ return output
+
+
+# 玩家查看缓存表 #tagDBPlayerViewCache
+class tagDBPlayerViewCache(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('PlayerID', ctypes.c_ulong),
+ ('AccID', ctypes.c_char * 65),
+ ('PlayerName', ctypes.c_char * 33),
+ ('LV', ctypes.c_int),
+ ('Job', ctypes.c_int),
+ ('RealmLV', ctypes.c_ubyte),
+ ('Face', ctypes.c_int),
+ ('FacePic', ctypes.c_int),
+ ('ModelMark', ctypes.c_ulong),
+ ('FamilyID', ctypes.c_ulong),
+ ('FamilyName', ctypes.c_char * 33),
+ ('FamilyEmblemID', ctypes.c_ushort),
+ ('FamilyEmblemWord', ctypes.c_char * 3),
+ ('TitleID', ctypes.c_ulong),
+ ('FightPower', ctypes.c_ulong),
+ ('FightPowerEx', ctypes.c_ulong),
+ ('ServerID', ctypes.c_ulong),
+ ('OffTime', ctypes.c_ulong),
+ ('PlusDataSize', ctypes.c_ulong),
+ ('PlusData', ctypes.c_char_p),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.PlayerID = 0
+ self.AccID = ''
+ self.PlayerName = ''
+ self.LV = 0
+ self.Job = 0
+ self.RealmLV = 0
+ self.Face = 0
+ self.FacePic = 0
+ self.ModelMark = 0
+ self.FamilyID = 0
+ self.FamilyName = ''
+ self.FamilyEmblemID = 0
+ self.FamilyEmblemWord = ''
+ self.TitleID = 0
+ self.FightPower = 0
+ self.FightPowerEx = 0
+ self.ServerID = 0
+ self.OffTime = 0
+ self.PlusDataSize = 0
+ self.PlusData = ''
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.AccID, pos = CommFunc.ReadString(buf, pos, 65)
+ self.PlayerName, pos = CommFunc.ReadString(buf, pos, 33)
+ self.LV, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Job, pos = CommFunc.ReadDWORD(buf, pos)
+ self.RealmLV, pos = CommFunc.ReadBYTE(buf, pos)
+ self.Face, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FacePic, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ModelMark, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyName, pos = CommFunc.ReadString(buf, pos, 33)
+ self.FamilyEmblemID, pos = CommFunc.ReadWORD(buf, pos)
+ self.FamilyEmblemWord, pos = CommFunc.ReadString(buf, pos, 3)
+ self.TitleID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPower, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPowerEx, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ServerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.OffTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PlusDataSize, pos = CommFunc.ReadDWORD(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.PlusDataSize)
+ self.PlusData = ctypes.c_char_p(tmp)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteDWORD(buf, self.PlayerID)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 65, self.AccID)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.PlayerName)
+ buf = CommFunc.WriteDWORD(buf, self.LV)
+ buf = CommFunc.WriteDWORD(buf, self.Job)
+ buf = CommFunc.WriteBYTE(buf, self.RealmLV)
+ buf = CommFunc.WriteDWORD(buf, self.Face)
+ buf = CommFunc.WriteDWORD(buf, self.FacePic)
+ buf = CommFunc.WriteDWORD(buf, self.ModelMark)
+ buf = CommFunc.WriteDWORD(buf, self.FamilyID)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.FamilyName)
+ buf = CommFunc.WriteWORD(buf, self.FamilyEmblemID)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 3, self.FamilyEmblemWord)
+ buf = CommFunc.WriteDWORD(buf, self.TitleID)
+ buf = CommFunc.WriteDWORD(buf, self.FightPower)
+ buf = CommFunc.WriteDWORD(buf, self.FightPowerEx)
+ buf = CommFunc.WriteDWORD(buf, self.ServerID)
+ buf = CommFunc.WriteDWORD(buf, self.OffTime)
+ buf = CommFunc.WriteDWORD(buf, self.PlusDataSize)
+ buf = CommFunc.WriteString(buf, self.PlusDataSize, self.PlusData)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_char) * 65
+ length += sizeof(ctypes.c_char) * 33
+ length += sizeof(ctypes.c_int)
+ length += sizeof(ctypes.c_int)
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_int)
+ length += sizeof(ctypes.c_int)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_char) * 33
+ length += sizeof(ctypes.c_ushort)
+ length += sizeof(ctypes.c_char) * 3
+ 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_ulong)
+ length += self.PlusDataSize
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'PlayerID'] = self.PlayerID
+ rec[u'AccID'] = fix_incomingText(self.AccID)
+ rec[u'PlayerName'] = fix_incomingText(self.PlayerName)
+ rec[u'LV'] = self.LV
+ rec[u'Job'] = self.Job
+ rec[u'RealmLV'] = self.RealmLV
+ rec[u'Face'] = self.Face
+ rec[u'FacePic'] = self.FacePic
+ rec[u'ModelMark'] = self.ModelMark
+ rec[u'FamilyID'] = self.FamilyID
+ rec[u'FamilyName'] = fix_incomingText(self.FamilyName)
+ rec[u'FamilyEmblemID'] = self.FamilyEmblemID
+ rec[u'FamilyEmblemWord'] = fix_incomingText(self.FamilyEmblemWord)
+ rec[u'TitleID'] = self.TitleID
+ rec[u'FightPower'] = self.FightPower
+ rec[u'FightPowerEx'] = self.FightPowerEx
+ rec[u'ServerID'] = self.ServerID
+ rec[u'OffTime'] = self.OffTime
+ rec[u'PlusDataSize'] = self.PlusDataSize
+ rec[u'PlusData'] = fix_incomingText(self.PlusData)
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.PlayerID = rec.get(u'PlayerID', 0)
+ self.AccID = fix_outgoingText(rec.get(u'AccID', u''))
+ self.PlayerName = fix_outgoingText(rec.get(u'PlayerName', u''))
+ self.LV = rec.get(u'LV', 0)
+ self.Job = rec.get(u'Job', 0)
+ self.RealmLV = rec.get(u'RealmLV', 0)
+ self.Face = rec.get(u'Face', 0)
+ self.FacePic = rec.get(u'FacePic', 0)
+ self.ModelMark = rec.get(u'ModelMark', 0)
+ self.FamilyID = rec.get(u'FamilyID', 0)
+ self.FamilyName = fix_outgoingText(rec.get(u'FamilyName', u''))
+ self.FamilyEmblemID = rec.get(u'FamilyEmblemID', 0)
+ self.FamilyEmblemWord = fix_outgoingText(rec.get(u'FamilyEmblemWord', u''))
+ self.TitleID = rec.get(u'TitleID', 0)
+ self.FightPower = rec.get(u'FightPower', 0)
+ self.FightPowerEx = rec.get(u'FightPowerEx', 0)
+ self.ServerID = rec.get(u'ServerID', 0)
+ self.OffTime = rec.get(u'OffTime', 0)
+ self.PlusDataSize = rec.get(u'PlusDataSize', 0)
+ self.PlusData = fix_outgoingText(rec.get(u'PlusData', u''))
+
+#Can not implement adoLoadStr method:No key defined!
+
+ def adoInsert(self, collection):
+ '''执行插入'''
+
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.insert(rec, False, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+#Can not implement adoUpdateStr method:No key defined!
+
+ def adoUpdateEx(self, collection, spec):
+ '''执行更新'''
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.update(spec, {'$set':rec}, False, False, True, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+
+ def adoQueryIndex(self, collection):
+ '''用索引字段查找'''
+ resultCollection = collection.find({'PlayerID':self.PlayerID})
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoDeleteByIndex(self, collection):
+ '''根据索引删除'''
+ trycnt = 0
+ while(True):
+ try:
+ collection.remove({'PlayerID':self.PlayerID})
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:PlayerID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.PlayerID))
+ msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+ def outputString(self):
+ output = '''// 玩家查看缓存表 #tagDBPlayerViewCache:
+ PlayerID = %s,
+ AccID = %s,
+ PlayerName = %s,
+ LV = %s,
+ Job = %s,
+ RealmLV = %s,
+ Face = %s,
+ FacePic = %s,
+ ModelMark = %s,
+ FamilyID = %s,
+ FamilyName = %s,
+ FamilyEmblemID = %s,
+ FamilyEmblemWord = %s,
+ TitleID = %s,
+ FightPower = %s,
+ FightPowerEx = %s,
+ ServerID = %s,
+ OffTime = %s,
+ PlusDataSize = %s,
+ PlusData = %s,
+ ADOResult = %s,
+ '''%(
+ self.PlayerID,
+ self.AccID,
+ self.PlayerName,
+ self.LV,
+ self.Job,
+ self.RealmLV,
+ self.Face,
+ self.FacePic,
+ self.ModelMark,
+ self.FamilyID,
+ self.FamilyName,
+ self.FamilyEmblemID,
+ self.FamilyEmblemWord,
+ self.TitleID,
+ self.FightPower,
+ self.FightPowerEx,
+ self.ServerID,
+ self.OffTime,
+ self.PlusDataSize,
+ self.PlusData,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.PlayerID,
+ self.AccID,
+ self.PlayerName,
+ self.LV,
+ self.Job,
+ self.RealmLV,
+ self.Face,
+ self.FacePic,
+ self.ModelMark,
+ self.FamilyID,
+ self.FamilyName,
+ self.FamilyEmblemID,
+ self.FamilyEmblemWord,
+ self.TitleID,
+ self.FightPower,
+ self.FightPowerEx,
+ self.ServerID,
+ self.OffTime,
+ self.PlusDataSize,
+ self.PlusData,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetAccID(self,Str):
+ if len(Str)<=65:
+ self.AccID = Str
+ else:
+ self.AccID = Str[:65]
+
+ def SetPlayerName(self,Str):
+ if len(Str)<=33:
+ self.PlayerName = Str
+ else:
+ self.PlayerName = Str[:33]
+
+ def SetFamilyName(self,Str):
+ if len(Str)<=33:
+ self.FamilyName = Str
+ else:
+ self.FamilyName = Str[:33]
+
+ def SetFamilyEmblemWord(self,Str):
+ if len(Str)<=3:
+ self.FamilyEmblemWord = Str
+ else:
+ self.FamilyEmblemWord = Str[:3]
+
+
+# 排行榜表 #tagDBBillboard
+class tagDBBillboard(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('GroupValue1', ctypes.c_ulong),
+ ('GroupValue2', ctypes.c_ulong),
+ ('BillboardType', ctypes.c_ubyte),
+ ('ID', ctypes.c_ulong),
+ ('ID2', ctypes.c_ulong),
+ ('Name1', ctypes.c_char * 33),
+ ('Name2', ctypes.c_char * 65),
+ ('Type2', ctypes.c_ubyte),
+ ('Value1', ctypes.c_ulong),
+ ('Value2', ctypes.c_ulong),
+ ('Value3', ctypes.c_ulong),
+ ('Value4', ctypes.c_ulong),
+ ('Value5', ctypes.c_ulong),
+ ('Value6', ctypes.c_ulong),
+ ('Value7', ctypes.c_ulong),
+ ('Value8', ctypes.c_ulong),
+ ('CmpValue', ctypes.c_ulong),
+ ('CmpValue2', ctypes.c_ulong),
+ ('CmpValue3', ctypes.c_ulong),
+ ('Time', ctypes.c_ulong),
+ ('DataLen', ctypes.c_ushort),
+ ('UserData', ctypes.c_char_p),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.GroupValue1 = 0
+ self.GroupValue2 = 0
+ self.BillboardType = 0
+ self.ID = 0
+ self.ID2 = 0
+ self.Name1 = ''
+ self.Name2 = ''
+ self.Type2 = 0
+ self.Value1 = 0
+ self.Value2 = 0
+ self.Value3 = 0
+ self.Value4 = 0
+ self.Value5 = 0
+ self.Value6 = 0
+ self.Value7 = 0
+ self.Value8 = 0
+ self.CmpValue = 0
+ self.CmpValue2 = 0
+ self.CmpValue3 = 0
+ self.Time = 0
+ self.DataLen = 0
+ self.UserData = ''
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.GroupValue1, pos = CommFunc.ReadDWORD(buf, pos)
+ self.GroupValue2, pos = CommFunc.ReadDWORD(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, 65)
+ self.Type2, pos = CommFunc.ReadBYTE(buf, pos)
+ self.Value1, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value2, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value3, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value4, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value5, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value6, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value7, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value8, 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)
+ self.Time, pos = CommFunc.ReadDWORD(buf, pos)
+ self.DataLen, pos = CommFunc.ReadWORD(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.DataLen)
+ self.UserData = ctypes.c_char_p(tmp)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteDWORD(buf, self.GroupValue1)
+ buf = CommFunc.WriteDWORD(buf, self.GroupValue2)
+ buf = CommFunc.WriteBYTE(buf, self.BillboardType)
+ buf = CommFunc.WriteDWORD(buf, self.ID)
+ buf = CommFunc.WriteDWORD(buf, self.ID2)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.Name1)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 65, self.Name2)
+ buf = CommFunc.WriteBYTE(buf, self.Type2)
+ buf = CommFunc.WriteDWORD(buf, self.Value1)
+ buf = CommFunc.WriteDWORD(buf, self.Value2)
+ buf = CommFunc.WriteDWORD(buf, self.Value3)
+ buf = CommFunc.WriteDWORD(buf, self.Value4)
+ buf = CommFunc.WriteDWORD(buf, self.Value5)
+ buf = CommFunc.WriteDWORD(buf, self.Value6)
+ buf = CommFunc.WriteDWORD(buf, self.Value7)
+ buf = CommFunc.WriteDWORD(buf, self.Value8)
+ buf = CommFunc.WriteDWORD(buf, self.CmpValue)
+ buf = CommFunc.WriteDWORD(buf, self.CmpValue2)
+ buf = CommFunc.WriteDWORD(buf, self.CmpValue3)
+ buf = CommFunc.WriteDWORD(buf, self.Time)
+ buf = CommFunc.WriteWORD(buf, self.DataLen)
+ buf = CommFunc.WriteString(buf, self.DataLen, self.UserData)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_char) * 33
+ length += sizeof(ctypes.c_char) * 65
+ 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_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_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ushort)
+ length += self.DataLen
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'GroupValue1'] = self.GroupValue1
+ rec[u'GroupValue2'] = self.GroupValue2
+ rec[u'BillboardType'] = self.BillboardType
+ rec[u'ID'] = self.ID
+ rec[u'ID2'] = self.ID2
+ rec[u'Name1'] = fix_incomingText(self.Name1)
+ rec[u'Name2'] = fix_incomingText(self.Name2)
+ rec[u'Type2'] = self.Type2
+ rec[u'Value1'] = self.Value1
+ rec[u'Value2'] = self.Value2
+ rec[u'Value3'] = self.Value3
+ rec[u'Value4'] = self.Value4
+ rec[u'Value5'] = self.Value5
+ rec[u'Value6'] = self.Value6
+ rec[u'Value7'] = self.Value7
+ rec[u'Value8'] = self.Value8
+ rec[u'CmpValue'] = self.CmpValue
+ rec[u'CmpValue2'] = self.CmpValue2
+ rec[u'CmpValue3'] = self.CmpValue3
+ rec[u'Time'] = self.Time
+ rec[u'DataLen'] = self.DataLen
+ rec[u'UserData'] = fix_incomingText(self.UserData)
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.GroupValue1 = rec.get(u'GroupValue1', 0)
+ self.GroupValue2 = rec.get(u'GroupValue2', 0)
+ self.BillboardType = rec.get(u'BillboardType', 0)
+ self.ID = rec.get(u'ID', 0)
+ self.ID2 = rec.get(u'ID2', 0)
+ self.Name1 = fix_outgoingText(rec.get(u'Name1', u''))
+ self.Name2 = fix_outgoingText(rec.get(u'Name2', u''))
+ self.Type2 = rec.get(u'Type2', 0)
+ self.Value1 = rec.get(u'Value1', 0)
+ self.Value2 = rec.get(u'Value2', 0)
+ self.Value3 = rec.get(u'Value3', 0)
+ self.Value4 = rec.get(u'Value4', 0)
+ self.Value5 = rec.get(u'Value5', 0)
+ self.Value6 = rec.get(u'Value6', 0)
+ self.Value7 = rec.get(u'Value7', 0)
+ self.Value8 = rec.get(u'Value8', 0)
+ self.CmpValue = rec.get(u'CmpValue', 0)
+ self.CmpValue2 = rec.get(u'CmpValue2', 0)
+ self.CmpValue3 = rec.get(u'CmpValue3', 0)
+ self.Time = rec.get(u'Time', 0)
+ self.DataLen = rec.get(u'DataLen', 0)
+ self.UserData = fix_outgoingText(rec.get(u'UserData', u''))
+
+#Can not implement adoLoadStr method:No key defined!
+#Can not implement adoInsertStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+#Can not implement adoQueryIndexStr method:No key defined!
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+#Can not implement adoDeleteByIndexStr method:No key defined!
+ def outputString(self):
+ output = '''// 排行榜表 #tagDBBillboard:
+ GroupValue1 = %s,
+ GroupValue2 = %s,
+ BillboardType = %s,
+ ID = %s,
+ ID2 = %s,
+ Name1 = %s,
+ Name2 = %s,
+ Type2 = %s,
+ Value1 = %s,
+ Value2 = %s,
+ Value3 = %s,
+ Value4 = %s,
+ Value5 = %s,
+ Value6 = %s,
+ Value7 = %s,
+ Value8 = %s,
+ CmpValue = %s,
+ CmpValue2 = %s,
+ CmpValue3 = %s,
+ Time = %s,
+ DataLen = %s,
+ UserData = %s,
+ ADOResult = %s,
+ '''%(
+ self.GroupValue1,
+ self.GroupValue2,
+ self.BillboardType,
+ self.ID,
+ self.ID2,
+ self.Name1,
+ self.Name2,
+ self.Type2,
+ self.Value1,
+ self.Value2,
+ self.Value3,
+ self.Value4,
+ self.Value5,
+ self.Value6,
+ self.Value7,
+ self.Value8,
+ self.CmpValue,
+ self.CmpValue2,
+ self.CmpValue3,
+ self.Time,
+ self.DataLen,
+ self.UserData,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.GroupValue1,
+ self.GroupValue2,
+ self.BillboardType,
+ self.ID,
+ self.ID2,
+ self.Name1,
+ self.Name2,
+ self.Type2,
+ self.Value1,
+ self.Value2,
+ self.Value3,
+ self.Value4,
+ self.Value5,
+ self.Value6,
+ self.Value7,
+ self.Value8,
+ self.CmpValue,
+ self.CmpValue2,
+ self.CmpValue3,
+ self.Time,
+ self.DataLen,
+ self.UserData,
+ )
+ 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)<=65:
+ self.Name2 = Str
+ else:
+ self.Name2 = Str[:65]
+
+
+# 邮件个人邮件表 #tagDBMailPersonal
+class tagDBMailPersonal(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('PlayerID', ctypes.c_ulong),
+ ('GUID', ctypes.c_char * 36),
+ ('Type', ctypes.c_ubyte),
+ ('CreateTime', ctypes.c_char * 30),
+ ('LimitDays', ctypes.c_ubyte),
+ ('TitleLen', ctypes.c_ubyte),
+ ('Title', ctypes.c_char_p),
+ ('TextLen', ctypes.c_ushort),
+ ('Text', ctypes.c_char_p),
+ ('MailState', ctypes.c_ubyte),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.PlayerID = 0
+ self.GUID = ''
+ self.Type = 0
+ self.CreateTime = ''
+ self.LimitDays = 0
+ self.TitleLen = 0
+ self.Title = ''
+ self.TextLen = 0
+ self.Text = ''
+ self.MailState = 0
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.GUID, pos = CommFunc.ReadString(buf, pos, 36)
+ self.Type, pos = CommFunc.ReadBYTE(buf, pos)
+ self.CreateTime, pos = CommFunc.ReadString(buf, pos, 30)
+ self.LimitDays, pos = CommFunc.ReadBYTE(buf, pos)
+ self.TitleLen, pos = CommFunc.ReadBYTE(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.TitleLen)
+ self.Title = ctypes.c_char_p(tmp)
+ self.TextLen, pos = CommFunc.ReadWORD(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.TextLen)
+ self.Text = ctypes.c_char_p(tmp)
+ self.MailState, pos = CommFunc.ReadBYTE(buf, pos)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteDWORD(buf, self.PlayerID)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 36, self.GUID)
+ buf = CommFunc.WriteBYTE(buf, self.Type)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 30, self.CreateTime)
+ buf = CommFunc.WriteBYTE(buf, self.LimitDays)
+ buf = CommFunc.WriteBYTE(buf, self.TitleLen)
+ buf = CommFunc.WriteString(buf, self.TitleLen, self.Title)
+ buf = CommFunc.WriteWORD(buf, self.TextLen)
+ buf = CommFunc.WriteString(buf, self.TextLen, self.Text)
+ buf = CommFunc.WriteBYTE(buf, self.MailState)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_char) * 36
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_char) * 30
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ubyte)
+ length += self.TitleLen
+ length += sizeof(ctypes.c_ushort)
+ length += self.TextLen
+ length += sizeof(ctypes.c_ubyte)
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'PlayerID'] = self.PlayerID
+ rec[u'GUID'] = fix_incomingText(self.GUID)
+ rec[u'Type'] = self.Type
+ rec[u'CreateTime'] = fix_incomingText(self.CreateTime)
+ rec[u'LimitDays'] = self.LimitDays
+ rec[u'TitleLen'] = self.TitleLen
+ rec[u'Title'] = fix_incomingText(self.Title)
+ rec[u'TextLen'] = self.TextLen
+ rec[u'Text'] = fix_incomingText(self.Text)
+ rec[u'MailState'] = self.MailState
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.PlayerID = rec.get(u'PlayerID', 0)
+ self.GUID = fix_outgoingText(rec.get(u'GUID', u''))
+ self.Type = rec.get(u'Type', 0)
+ self.CreateTime = fix_outgoingText(rec.get(u'CreateTime', u''))
+ self.LimitDays = rec.get(u'LimitDays', 0)
+ self.TitleLen = rec.get(u'TitleLen', 0)
+ self.Title = fix_outgoingText(rec.get(u'Title', u''))
+ self.TextLen = rec.get(u'TextLen', 0)
+ self.Text = fix_outgoingText(rec.get(u'Text', u''))
+ self.MailState = rec.get(u'MailState', 0)
+
+#Can not implement adoLoadStr method:No key defined!
+#Can not implement adoInsertStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+#Can not implement adoQueryIndexStr method:No key defined!
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+#Can not implement adoDeleteByIndexStr method:No key defined!
+ def outputString(self):
+ output = '''// 邮件个人邮件表 #tagDBMailPersonal:
+ PlayerID = %s,
+ GUID = %s,
+ Type = %s,
+ CreateTime = %s,
+ LimitDays = %s,
+ TitleLen = %s,
+ Title = %s,
+ TextLen = %s,
+ Text = %s,
+ MailState = %s,
+ ADOResult = %s,
+ '''%(
+ self.PlayerID,
+ self.GUID,
+ self.Type,
+ self.CreateTime,
+ self.LimitDays,
+ self.TitleLen,
+ self.Title,
+ self.TextLen,
+ self.Text,
+ self.MailState,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.PlayerID,
+ self.GUID,
+ self.Type,
+ self.CreateTime,
+ self.LimitDays,
+ self.TitleLen,
+ self.Title,
+ self.TextLen,
+ self.Text,
+ self.MailState,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetGUID(self,Str):
+ if len(Str)<=36:
+ self.GUID = Str
+ else:
+ self.GUID = Str[:36]
+
+ def SetCreateTime(self,Str):
+ if len(Str)<=30:
+ self.CreateTime = Str
+ else:
+ self.CreateTime = Str[:30]
+
+
+# 邮件全服邮件表 #tagDBMailServer
+class tagDBMailServer(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('GUID', ctypes.c_char * 36),
+ ('Type', ctypes.c_ubyte),
+ ('CreateTime', ctypes.c_char * 30),
+ ('LimitDays', ctypes.c_ubyte),
+ ('TitleLen', ctypes.c_ubyte),
+ ('Title', ctypes.c_char_p),
+ ('TextLen', ctypes.c_ushort),
+ ('Text', ctypes.c_char_p),
+ ('LimitLV', ctypes.c_ushort),
+ ('LimitLVType', ctypes.c_ubyte),
+ ('CheckState', ctypes.c_ubyte),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.GUID = ''
+ self.Type = 0
+ self.CreateTime = ''
+ self.LimitDays = 0
+ self.TitleLen = 0
+ self.Title = ''
+ self.TextLen = 0
+ self.Text = ''
+ self.LimitLV = 0
+ self.LimitLVType = 0
+ self.CheckState = 0
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.GUID, pos = CommFunc.ReadString(buf, pos, 36)
+ self.Type, pos = CommFunc.ReadBYTE(buf, pos)
+ self.CreateTime, pos = CommFunc.ReadString(buf, pos, 30)
+ self.LimitDays, pos = CommFunc.ReadBYTE(buf, pos)
+ self.TitleLen, pos = CommFunc.ReadBYTE(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.TitleLen)
+ self.Title = ctypes.c_char_p(tmp)
+ self.TextLen, pos = CommFunc.ReadWORD(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.TextLen)
+ self.Text = ctypes.c_char_p(tmp)
+ self.LimitLV, pos = CommFunc.ReadWORD(buf, pos)
+ self.LimitLVType, pos = CommFunc.ReadBYTE(buf, pos)
+ self.CheckState, pos = CommFunc.ReadBYTE(buf, pos)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 36, self.GUID)
+ buf = CommFunc.WriteBYTE(buf, self.Type)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 30, self.CreateTime)
+ buf = CommFunc.WriteBYTE(buf, self.LimitDays)
+ buf = CommFunc.WriteBYTE(buf, self.TitleLen)
+ buf = CommFunc.WriteString(buf, self.TitleLen, self.Title)
+ buf = CommFunc.WriteWORD(buf, self.TextLen)
+ buf = CommFunc.WriteString(buf, self.TextLen, self.Text)
+ buf = CommFunc.WriteWORD(buf, self.LimitLV)
+ buf = CommFunc.WriteBYTE(buf, self.LimitLVType)
+ buf = CommFunc.WriteBYTE(buf, self.CheckState)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_char) * 36
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_char) * 30
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ubyte)
+ length += self.TitleLen
+ length += sizeof(ctypes.c_ushort)
+ length += self.TextLen
+ length += sizeof(ctypes.c_ushort)
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ubyte)
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'GUID'] = fix_incomingText(self.GUID)
+ rec[u'Type'] = self.Type
+ rec[u'CreateTime'] = fix_incomingText(self.CreateTime)
+ rec[u'LimitDays'] = self.LimitDays
+ rec[u'TitleLen'] = self.TitleLen
+ rec[u'Title'] = fix_incomingText(self.Title)
+ rec[u'TextLen'] = self.TextLen
+ rec[u'Text'] = fix_incomingText(self.Text)
+ rec[u'LimitLV'] = self.LimitLV
+ rec[u'LimitLVType'] = self.LimitLVType
+ rec[u'CheckState'] = self.CheckState
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.GUID = fix_outgoingText(rec.get(u'GUID', u''))
+ self.Type = rec.get(u'Type', 0)
+ self.CreateTime = fix_outgoingText(rec.get(u'CreateTime', u''))
+ self.LimitDays = rec.get(u'LimitDays', 0)
+ self.TitleLen = rec.get(u'TitleLen', 0)
+ self.Title = fix_outgoingText(rec.get(u'Title', u''))
+ self.TextLen = rec.get(u'TextLen', 0)
+ self.Text = fix_outgoingText(rec.get(u'Text', u''))
+ self.LimitLV = rec.get(u'LimitLV', 0)
+ self.LimitLVType = rec.get(u'LimitLVType', 0)
+ self.CheckState = rec.get(u'CheckState', 0)
+
+#Can not implement adoLoadStr method:No key defined!
+#Can not implement adoInsertStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+#Can not implement adoQueryIndexStr method:No key defined!
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+#Can not implement adoDeleteByIndexStr method:No key defined!
+ def outputString(self):
+ output = '''// 邮件全服邮件表 #tagDBMailServer:
+ GUID = %s,
+ Type = %s,
+ CreateTime = %s,
+ LimitDays = %s,
+ TitleLen = %s,
+ Title = %s,
+ TextLen = %s,
+ Text = %s,
+ LimitLV = %s,
+ LimitLVType = %s,
+ CheckState = %s,
+ ADOResult = %s,
+ '''%(
+ self.GUID,
+ self.Type,
+ self.CreateTime,
+ self.LimitDays,
+ self.TitleLen,
+ self.Title,
+ self.TextLen,
+ self.Text,
+ self.LimitLV,
+ self.LimitLVType,
+ self.CheckState,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.GUID,
+ self.Type,
+ self.CreateTime,
+ self.LimitDays,
+ self.TitleLen,
+ self.Title,
+ self.TextLen,
+ self.Text,
+ self.LimitLV,
+ self.LimitLVType,
+ self.CheckState,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetGUID(self,Str):
+ if len(Str)<=36:
+ self.GUID = Str
+ else:
+ self.GUID = Str[:36]
+
+ def SetCreateTime(self,Str):
+ if len(Str)<=30:
+ self.CreateTime = Str
+ else:
+ self.CreateTime = Str[:30]
+
+
+# 邮件全服记录表 #tagDBMailPlayerRec
+class tagDBMailPlayerRec(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('PlayerID', ctypes.c_ulong),
+ ('GUID', ctypes.c_char * 36),
+ ('MailState', ctypes.c_ubyte),
+ ('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:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.GUID, pos = CommFunc.ReadString(buf, pos, 36)
+ self.MailState, pos = CommFunc.ReadBYTE(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(tagDBMailPlayerRec)
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'PlayerID'] = self.PlayerID
+ rec[u'GUID'] = fix_incomingText(self.GUID)
+ rec[u'MailState'] = self.MailState
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.PlayerID = rec.get(u'PlayerID', 0)
+ self.GUID = fix_outgoingText(rec.get(u'GUID', u''))
+ self.MailState = rec.get(u'MailState', 0)
+
+#Can not implement adoLoadStr method:No key defined!
+#Can not implement adoInsertStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+#Can not implement adoQueryIndexStr method:No key defined!
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+#Can not implement adoDeleteByIndexStr method:No key defined!
+ def outputString(self):
+ output = '''// 邮件全服记录表 #tagDBMailPlayerRec:
+ PlayerID = %s,
+ GUID = %s,
+ MailState = %s,
+ ADOResult = %s,
+ '''%(
+ self.PlayerID,
+ self.GUID,
+ self.MailState,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s'''%(
+ self.PlayerID,
+ self.GUID,
+ self.MailState,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetGUID(self,Str):
+ if len(Str)<=36:
+ self.GUID = Str
+ else:
+ self.GUID = Str[:36]
+
+
+# 邮件物品表 #tagDBMailItem
+class tagDBMailItem(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('GUID', ctypes.c_char * 36),
+ ('ItemID', ctypes.c_ulong),
+ ('Count', ctypes.c_ulong),
+ ('IsBind', ctypes.c_ubyte),
+ ('UserDataLen', ctypes.c_ushort),
+ ('UserData', ctypes.c_char_p),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.GUID = ''
+ self.ItemID = 0
+ self.Count = 0
+ self.IsBind = 0
+ self.UserDataLen = 0
+ self.UserData = ''
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.GUID, pos = CommFunc.ReadString(buf, pos, 36)
+ self.ItemID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Count, pos = CommFunc.ReadDWORD(buf, pos)
+ self.IsBind, 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)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 36, self.GUID)
+ buf = CommFunc.WriteDWORD(buf, self.ItemID)
+ buf = CommFunc.WriteDWORD(buf, self.Count)
+ buf = CommFunc.WriteBYTE(buf, self.IsBind)
+ buf = CommFunc.WriteWORD(buf, self.UserDataLen)
+ buf = CommFunc.WriteString(buf, self.UserDataLen, self.UserData)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_char) * 36
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ushort)
+ length += self.UserDataLen
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'GUID'] = fix_incomingText(self.GUID)
+ rec[u'ItemID'] = self.ItemID
+ rec[u'Count'] = self.Count
+ rec[u'IsBind'] = self.IsBind
+ rec[u'UserDataLen'] = self.UserDataLen
+ rec[u'UserData'] = fix_incomingText(self.UserData)
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.GUID = fix_outgoingText(rec.get(u'GUID', u''))
+ self.ItemID = rec.get(u'ItemID', 0)
+ self.Count = rec.get(u'Count', 0)
+ self.IsBind = rec.get(u'IsBind', 0)
+ self.UserDataLen = rec.get(u'UserDataLen', 0)
+ self.UserData = fix_outgoingText(rec.get(u'UserData', u''))
+
+#Can not implement adoLoadStr method:No key defined!
+#Can not implement adoInsertStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+#Can not implement adoQueryIndexStr method:No key defined!
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+#Can not implement adoDeleteByIndexStr method:No key defined!
+ def outputString(self):
+ output = '''// 邮件物品表 #tagDBMailItem:
+ GUID = %s,
+ ItemID = %s,
+ Count = %s,
+ IsBind = %s,
+ UserDataLen = %s,
+ UserData = %s,
+ ADOResult = %s,
+ '''%(
+ self.GUID,
+ self.ItemID,
+ self.Count,
+ self.IsBind,
+ self.UserDataLen,
+ self.UserData,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.GUID,
+ self.ItemID,
+ self.Count,
+ self.IsBind,
+ self.UserDataLen,
+ self.UserData,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetGUID(self,Str):
+ if len(Str)<=36:
+ self.GUID = Str
+ else:
+ self.GUID = Str[:36]
+
+
+# 家族表 #tagDBFamily
+class tagDBFamily(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ID', ctypes.c_ulong),
+ ('Name', ctypes.c_char * 33),
+ ('LeaderID', ctypes.c_ulong),
+ ('LV', ctypes.c_ubyte),
+ ('Exp', ctypes.c_ulong),
+ ('JoinReview', ctypes.c_ubyte),
+ ('JoinLVMin', ctypes.c_ushort),
+ ('CreateTime', ctypes.c_ulong),
+ ('ServerID', ctypes.c_ulong),
+ ('BroadcastLen', ctypes.c_ubyte),
+ ('Broadcast', ctypes.c_char_p),
+ ('FightPower', ctypes.c_ulong),
+ ('FightPowerEx', ctypes.c_ulong),
+ ('EmblemID', ctypes.c_ushort),
+ ('EmblemWord', ctypes.c_char * 3),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.ID = 0
+ self.Name = ''
+ self.LeaderID = 0
+ self.LV = 0
+ self.Exp = 0
+ self.JoinReview = 0
+ self.JoinLVMin = 0
+ self.CreateTime = 0
+ self.ServerID = 0
+ self.BroadcastLen = 0
+ self.Broadcast = ''
+ self.FightPower = 0
+ self.FightPowerEx = 0
+ self.EmblemID = 0
+ self.EmblemWord = ''
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.ID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Name, pos = CommFunc.ReadString(buf, pos, 33)
+ self.LeaderID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LV, pos = CommFunc.ReadBYTE(buf, pos)
+ self.Exp, pos = CommFunc.ReadDWORD(buf, pos)
+ self.JoinReview, pos = CommFunc.ReadBYTE(buf, pos)
+ self.JoinLVMin, pos = CommFunc.ReadWORD(buf, pos)
+ self.CreateTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ServerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.BroadcastLen, pos = CommFunc.ReadBYTE(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.BroadcastLen)
+ self.Broadcast = ctypes.c_char_p(tmp)
+ self.FightPower, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPowerEx, pos = CommFunc.ReadDWORD(buf, pos)
+ self.EmblemID, pos = CommFunc.ReadWORD(buf, pos)
+ self.EmblemWord, pos = CommFunc.ReadString(buf, pos, 3)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteDWORD(buf, self.ID)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.Name)
+ buf = CommFunc.WriteDWORD(buf, self.LeaderID)
+ buf = CommFunc.WriteBYTE(buf, self.LV)
+ buf = CommFunc.WriteDWORD(buf, self.Exp)
+ buf = CommFunc.WriteBYTE(buf, self.JoinReview)
+ buf = CommFunc.WriteWORD(buf, self.JoinLVMin)
+ buf = CommFunc.WriteDWORD(buf, self.CreateTime)
+ buf = CommFunc.WriteDWORD(buf, self.ServerID)
+ buf = CommFunc.WriteBYTE(buf, self.BroadcastLen)
+ buf = CommFunc.WriteString(buf, self.BroadcastLen, self.Broadcast)
+ buf = CommFunc.WriteDWORD(buf, self.FightPower)
+ buf = CommFunc.WriteDWORD(buf, self.FightPowerEx)
+ buf = CommFunc.WriteWORD(buf, self.EmblemID)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 3, self.EmblemWord)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_char) * 33
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ushort)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ubyte)
+ length += self.BroadcastLen
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ushort)
+ length += sizeof(ctypes.c_char) * 3
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'ID'] = self.ID
+ rec[u'Name'] = fix_incomingText(self.Name)
+ rec[u'LeaderID'] = self.LeaderID
+ rec[u'LV'] = self.LV
+ rec[u'Exp'] = self.Exp
+ rec[u'JoinReview'] = self.JoinReview
+ rec[u'JoinLVMin'] = self.JoinLVMin
+ rec[u'CreateTime'] = self.CreateTime
+ rec[u'ServerID'] = self.ServerID
+ rec[u'BroadcastLen'] = self.BroadcastLen
+ rec[u'Broadcast'] = fix_incomingText(self.Broadcast)
+ rec[u'FightPower'] = self.FightPower
+ rec[u'FightPowerEx'] = self.FightPowerEx
+ rec[u'EmblemID'] = self.EmblemID
+ rec[u'EmblemWord'] = fix_incomingText(self.EmblemWord)
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.ID = rec.get(u'ID', 0)
+ self.Name = fix_outgoingText(rec.get(u'Name', u''))
+ self.LeaderID = rec.get(u'LeaderID', 0)
+ self.LV = rec.get(u'LV', 0)
+ self.Exp = rec.get(u'Exp', 0)
+ self.JoinReview = rec.get(u'JoinReview', 0)
+ self.JoinLVMin = rec.get(u'JoinLVMin', 0)
+ self.CreateTime = rec.get(u'CreateTime', 0)
+ self.ServerID = rec.get(u'ServerID', 0)
+ self.BroadcastLen = rec.get(u'BroadcastLen', 0)
+ self.Broadcast = fix_outgoingText(rec.get(u'Broadcast', u''))
+ self.FightPower = rec.get(u'FightPower', 0)
+ self.FightPowerEx = rec.get(u'FightPowerEx', 0)
+ self.EmblemID = rec.get(u'EmblemID', 0)
+ self.EmblemWord = fix_outgoingText(rec.get(u'EmblemWord', u''))
+
+ def adoLoad(self, collection):
+ '''使用KEY查找并读取'''
+ resultCollection = collection.find({'ID':self.ID})
+
+ if resultCollection.count() <= 0:
+ return False
+ #由于是KEY查找,所有如果存在就只有一条记录
+ rec = resultCollection[0]
+ #读取数据
+ self.readRecord(rec)
+ return True
+
+
+ def adoInsert(self, collection):
+ '''执行插入'''
+
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.insert(rec, False, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!ID = %s, error = %s, trycnt = %d'%(self.ID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoUpdate(self, collection):
+ '''执行更新'''
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.update({'ID':self.ID}, {'$set':rec}, False, False, True, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_153, 'Update failed!ID = %s, error = %s, trycnt = %d'%(self.ID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoUpdateEx(self, collection, spec):
+ '''执行更新'''
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.update(spec, {'$set':rec}, False, False, True, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!ID = %s, error = %s, trycnt = %d'%(self.ID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoCheckUpdate(self, collection):
+ '''根据情况执行插入或更新'''
+ resultCollection = collection.find({'ID':self.ID})
+
+ if resultCollection.count() <= 0:
+ return self.adoInsert(collection)
+ return self.adoUpdate(collection)
+
+
+ def adoCheckUpdateEx(self, collection, spec):
+ '''根据情况执行插入或更新'''
+ resultCollection = collection.find(spec)
+
+ if resultCollection.count() <= 0:
+ return self.adoInsert(collection)
+ return self.adoUpdateEx(collection, spec)
+
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+
+ def adoQueryIndex(self, collection):
+ '''用索引字段查找'''
+ resultCollection = collection.find({'ID':self.ID})
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoDeleteByIndex(self, collection):
+ '''根据索引删除'''
+ trycnt = 0
+ while(True):
+ try:
+ collection.remove({'ID':self.ID})
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:ID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.ID))
+ msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.ID = %s, error = %s, trycnt = %d'%(self.ID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+ def outputString(self):
+ output = '''// 家族表 #tagDBFamily:
+ ID = %s,
+ Name = %s,
+ LeaderID = %s,
+ LV = %s,
+ Exp = %s,
+ JoinReview = %s,
+ JoinLVMin = %s,
+ CreateTime = %s,
+ ServerID = %s,
+ BroadcastLen = %s,
+ Broadcast = %s,
+ FightPower = %s,
+ FightPowerEx = %s,
+ EmblemID = %s,
+ EmblemWord = %s,
+ ADOResult = %s,
+ '''%(
+ self.ID,
+ self.Name,
+ self.LeaderID,
+ self.LV,
+ self.Exp,
+ self.JoinReview,
+ self.JoinLVMin,
+ self.CreateTime,
+ self.ServerID,
+ self.BroadcastLen,
+ self.Broadcast,
+ self.FightPower,
+ self.FightPowerEx,
+ self.EmblemID,
+ self.EmblemWord,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.ID,
+ self.Name,
+ self.LeaderID,
+ self.LV,
+ self.Exp,
+ self.JoinReview,
+ self.JoinLVMin,
+ self.CreateTime,
+ self.ServerID,
+ self.BroadcastLen,
+ self.Broadcast,
+ self.FightPower,
+ self.FightPowerEx,
+ self.EmblemID,
+ self.EmblemWord,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetName(self,Str):
+ if len(Str)<=33:
+ self.Name = Str
+ else:
+ self.Name = Str[:33]
+
+ def SetEmblemWord(self,Str):
+ if len(Str)<=3:
+ self.EmblemWord = Str
+ else:
+ self.EmblemWord = Str[:3]
+
+
+# 家族成员表 #tagDBFamilyMem
+class tagDBFamilyMem(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('PlayerID', ctypes.c_ulong),
+ ('FamilyID', ctypes.c_ulong),
+ ('JoinTime', ctypes.c_ulong),
+ ('PlayerName', ctypes.c_char * 33),
+ ('LV', ctypes.c_int),
+ ('Job', ctypes.c_int),
+ ('RealmLV', ctypes.c_ubyte),
+ ('Face', ctypes.c_int),
+ ('FacePic', ctypes.c_int),
+ ('FightPower', ctypes.c_ulong),
+ ('FightPowerEx', ctypes.c_ulong),
+ ('ServerID', ctypes.c_ulong),
+ ('OffTime', ctypes.c_ulong),
+ ('FmLV', ctypes.c_ubyte),
+ ('ContribTotal', ctypes.c_ulong),
+ ('ContribDay', ctypes.c_ulong),
+ ('DonateCntTotal', ctypes.c_ulong),
+ ('DonateCntDay', ctypes.c_ubyte),
+ ('TitleID', 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:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.JoinTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PlayerName, pos = CommFunc.ReadString(buf, pos, 33)
+ self.LV, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Job, pos = CommFunc.ReadDWORD(buf, pos)
+ self.RealmLV, pos = CommFunc.ReadBYTE(buf, pos)
+ self.Face, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FacePic, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPower, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPowerEx, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ServerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.OffTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FmLV, pos = CommFunc.ReadBYTE(buf, pos)
+ self.ContribTotal, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ContribDay, pos = CommFunc.ReadDWORD(buf, pos)
+ self.DonateCntTotal, pos = CommFunc.ReadDWORD(buf, pos)
+ self.DonateCntDay, pos = CommFunc.ReadBYTE(buf, pos)
+ self.TitleID, 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(tagDBFamilyMem)
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'PlayerID'] = self.PlayerID
+ rec[u'FamilyID'] = self.FamilyID
+ rec[u'JoinTime'] = self.JoinTime
+ rec[u'PlayerName'] = fix_incomingText(self.PlayerName)
+ rec[u'LV'] = self.LV
+ rec[u'Job'] = self.Job
+ rec[u'RealmLV'] = self.RealmLV
+ rec[u'Face'] = self.Face
+ rec[u'FacePic'] = self.FacePic
+ rec[u'FightPower'] = self.FightPower
+ rec[u'FightPowerEx'] = self.FightPowerEx
+ rec[u'ServerID'] = self.ServerID
+ rec[u'OffTime'] = self.OffTime
+ rec[u'FmLV'] = self.FmLV
+ rec[u'ContribTotal'] = self.ContribTotal
+ rec[u'ContribDay'] = self.ContribDay
+ rec[u'DonateCntTotal'] = self.DonateCntTotal
+ rec[u'DonateCntDay'] = self.DonateCntDay
+ rec[u'TitleID'] = self.TitleID
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.PlayerID = rec.get(u'PlayerID', 0)
+ self.FamilyID = rec.get(u'FamilyID', 0)
+ self.JoinTime = rec.get(u'JoinTime', 0)
+ self.PlayerName = fix_outgoingText(rec.get(u'PlayerName', u''))
+ self.LV = rec.get(u'LV', 0)
+ self.Job = rec.get(u'Job', 0)
+ self.RealmLV = rec.get(u'RealmLV', 0)
+ self.Face = rec.get(u'Face', 0)
+ self.FacePic = rec.get(u'FacePic', 0)
+ self.FightPower = rec.get(u'FightPower', 0)
+ self.FightPowerEx = rec.get(u'FightPowerEx', 0)
+ self.ServerID = rec.get(u'ServerID', 0)
+ self.OffTime = rec.get(u'OffTime', 0)
+ self.FmLV = rec.get(u'FmLV', 0)
+ self.ContribTotal = rec.get(u'ContribTotal', 0)
+ self.ContribDay = rec.get(u'ContribDay', 0)
+ self.DonateCntTotal = rec.get(u'DonateCntTotal', 0)
+ self.DonateCntDay = rec.get(u'DonateCntDay', 0)
+ self.TitleID = rec.get(u'TitleID', 0)
+
+ def adoLoad(self, collection):
+ '''使用KEY查找并读取'''
+ resultCollection = collection.find({'PlayerID':self.PlayerID})
+
+ if resultCollection.count() <= 0:
+ return False
+ #由于是KEY查找,所有如果存在就只有一条记录
+ rec = resultCollection[0]
+ #读取数据
+ self.readRecord(rec)
+ return True
+
+
+ def adoInsert(self, collection):
+ '''执行插入'''
+
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.insert(rec, False, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoUpdate(self, collection):
+ '''执行更新'''
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.update({'PlayerID':self.PlayerID}, {'$set':rec}, False, False, True, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_153, 'Update failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoUpdateEx(self, collection, spec):
+ '''执行更新'''
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.update(spec, {'$set':rec}, False, False, True, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+
+ def adoCheckUpdate(self, collection):
+ '''根据情况执行插入或更新'''
+ resultCollection = collection.find({'PlayerID':self.PlayerID})
+
+ if resultCollection.count() <= 0:
+ return self.adoInsert(collection)
+ return self.adoUpdate(collection)
+
+
+ def adoCheckUpdateEx(self, collection, spec):
+ '''根据情况执行插入或更新'''
+ resultCollection = collection.find(spec)
+
+ if resultCollection.count() <= 0:
+ return self.adoInsert(collection)
+ return self.adoUpdateEx(collection, spec)
+
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+
+ def adoQueryIndex(self, collection):
+ '''用索引字段查找'''
+ resultCollection = collection.find({'PlayerID':self.PlayerID})
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoDeleteByIndex(self, collection):
+ '''根据索引删除'''
+ trycnt = 0
+ while(True):
+ try:
+ collection.remove({'PlayerID':self.PlayerID})
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:PlayerID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.PlayerID))
+ msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.PlayerID = %s, error = %s, trycnt = %d'%(self.PlayerID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+ def outputString(self):
+ output = '''// 家族成员表 #tagDBFamilyMem:
+ PlayerID = %s,
+ FamilyID = %s,
+ JoinTime = %s,
+ PlayerName = %s,
+ LV = %s,
+ Job = %s,
+ RealmLV = %s,
+ Face = %s,
+ FacePic = %s,
+ FightPower = %s,
+ FightPowerEx = %s,
+ ServerID = %s,
+ OffTime = %s,
+ FmLV = %s,
+ ContribTotal = %s,
+ ContribDay = %s,
+ DonateCntTotal = %s,
+ DonateCntDay = %s,
+ TitleID = %s,
+ ADOResult = %s,
+ '''%(
+ self.PlayerID,
+ self.FamilyID,
+ self.JoinTime,
+ self.PlayerName,
+ self.LV,
+ self.Job,
+ self.RealmLV,
+ self.Face,
+ self.FacePic,
+ self.FightPower,
+ self.FightPowerEx,
+ self.ServerID,
+ self.OffTime,
+ self.FmLV,
+ self.ContribTotal,
+ self.ContribDay,
+ self.DonateCntTotal,
+ self.DonateCntDay,
+ self.TitleID,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.PlayerID,
+ self.FamilyID,
+ self.JoinTime,
+ self.PlayerName,
+ self.LV,
+ self.Job,
+ self.RealmLV,
+ self.Face,
+ self.FacePic,
+ self.FightPower,
+ self.FightPowerEx,
+ self.ServerID,
+ self.OffTime,
+ self.FmLV,
+ self.ContribTotal,
+ self.ContribDay,
+ self.DonateCntTotal,
+ self.DonateCntDay,
+ self.TitleID,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetPlayerName(self,Str):
+ if len(Str)<=33:
+ self.PlayerName = Str
+ else:
+ self.PlayerName = Str[:33]
+
+
+# 家族行为表 #tagDBFamilyAction
+class tagDBFamilyAction(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('FamilyID', ctypes.c_ulong),
+ ('ActionType', ctypes.c_ubyte),
+ ('Name', ctypes.c_char * 33),
+ ('Time', ctypes.c_ulong),
+ ('Value1', ctypes.c_ulong),
+ ('Value2', ctypes.c_ulong),
+ ('Value3', ctypes.c_ulong),
+ ('Value4', ctypes.c_ulong),
+ ('Value5', ctypes.c_ulong),
+ ('Value6', ctypes.c_ulong),
+ ('DataLen', ctypes.c_ushort),
+ ('Data', ctypes.c_char_p),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.FamilyID = 0
+ self.ActionType = 0
+ self.Name = ''
+ self.Time = 0
+ self.Value1 = 0
+ self.Value2 = 0
+ self.Value3 = 0
+ self.Value4 = 0
+ self.Value5 = 0
+ self.Value6 = 0
+ self.DataLen = 0
+ self.Data = ''
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.FamilyID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ActionType, pos = CommFunc.ReadBYTE(buf, pos)
+ self.Name, pos = CommFunc.ReadString(buf, pos, 33)
+ self.Time, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value1, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value2, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value3, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value4, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value5, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value6, pos = CommFunc.ReadDWORD(buf, pos)
+ self.DataLen, pos = CommFunc.ReadWORD(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.DataLen)
+ self.Data = ctypes.c_char_p(tmp)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteDWORD(buf, self.FamilyID)
+ buf = CommFunc.WriteBYTE(buf, self.ActionType)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.Name)
+ buf = CommFunc.WriteDWORD(buf, self.Time)
+ buf = CommFunc.WriteDWORD(buf, self.Value1)
+ buf = CommFunc.WriteDWORD(buf, self.Value2)
+ buf = CommFunc.WriteDWORD(buf, self.Value3)
+ buf = CommFunc.WriteDWORD(buf, self.Value4)
+ buf = CommFunc.WriteDWORD(buf, self.Value5)
+ buf = CommFunc.WriteDWORD(buf, self.Value6)
+ buf = CommFunc.WriteWORD(buf, self.DataLen)
+ buf = CommFunc.WriteString(buf, self.DataLen, self.Data)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ubyte)
+ 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_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ushort)
+ length += self.DataLen
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'FamilyID'] = self.FamilyID
+ rec[u'ActionType'] = self.ActionType
+ rec[u'Name'] = fix_incomingText(self.Name)
+ rec[u'Time'] = self.Time
+ rec[u'Value1'] = self.Value1
+ rec[u'Value2'] = self.Value2
+ rec[u'Value3'] = self.Value3
+ rec[u'Value4'] = self.Value4
+ rec[u'Value5'] = self.Value5
+ rec[u'Value6'] = self.Value6
+ rec[u'DataLen'] = self.DataLen
+ rec[u'Data'] = fix_incomingText(self.Data)
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.FamilyID = rec.get(u'FamilyID', 0)
+ self.ActionType = rec.get(u'ActionType', 0)
+ self.Name = fix_outgoingText(rec.get(u'Name', u''))
+ self.Time = rec.get(u'Time', 0)
+ self.Value1 = rec.get(u'Value1', 0)
+ self.Value2 = rec.get(u'Value2', 0)
+ self.Value3 = rec.get(u'Value3', 0)
+ self.Value4 = rec.get(u'Value4', 0)
+ self.Value5 = rec.get(u'Value5', 0)
+ self.Value6 = rec.get(u'Value6', 0)
+ self.DataLen = rec.get(u'DataLen', 0)
+ self.Data = fix_outgoingText(rec.get(u'Data', u''))
+
+#Can not implement adoLoadStr method:No key defined!
+
+ def adoInsert(self, collection):
+ '''执行插入'''
+
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.insert(rec, False, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_152, 'Insert failed!FamilyID = %s, error = %s, trycnt = %d'%(self.FamilyID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+#Can not implement adoUpdateStr method:No key defined!
+
+ def adoUpdateEx(self, collection, spec):
+ '''执行更新'''
+ trycnt = 0
+ rec = self.getRecord()
+ while(True):
+ try:
+ collection.update(spec, {'$set':rec}, False, False, True, True)
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:rec = %s"%(self.__class__.__name__, inspect.stack()[0][3], rec))
+ msg = error.formatMsg('error', error.ERROR_NO_154, 'Update failed!FamilyID = %s, error = %s, trycnt = %d'%(self.FamilyID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+
+ def adoQueryIndex(self, collection):
+ '''用索引字段查找'''
+ resultCollection = collection.find({'FamilyID':self.FamilyID})
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoDeleteByIndex(self, collection):
+ '''根据索引删除'''
+ trycnt = 0
+ while(True):
+ try:
+ collection.remove({'FamilyID':self.FamilyID})
+ break
+ except pymongo.errors.OperationFailure, err:
+ if(DBConfig.TryCntOnWriteFail > trycnt):
+ trycnt += 1
+ continue
+ addADOExceptionCount()
+ mylog.info("%s.%s:FamilyID = %s"%(self.__class__.__name__, inspect.stack()[0][3], self.FamilyID))
+ msg = error.formatMsg('error', error.ERROR_NO_155, 'delete failure!self.FamilyID = %s, error = %s, trycnt = %d'%(self.FamilyID, err, trycnt))
+ mylog.error(msg)
+
+ return False
+ return True
+
+ def outputString(self):
+ output = '''// 家族行为表 #tagDBFamilyAction:
+ FamilyID = %s,
+ ActionType = %s,
+ Name = %s,
+ Time = %s,
+ Value1 = %s,
+ Value2 = %s,
+ Value3 = %s,
+ Value4 = %s,
+ Value5 = %s,
+ Value6 = %s,
+ DataLen = %s,
+ Data = %s,
+ ADOResult = %s,
+ '''%(
+ self.FamilyID,
+ self.ActionType,
+ self.Name,
+ self.Time,
+ self.Value1,
+ self.Value2,
+ self.Value3,
+ self.Value4,
+ self.Value5,
+ self.Value6,
+ self.DataLen,
+ self.Data,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.FamilyID,
+ self.ActionType,
+ self.Name,
+ self.Time,
+ self.Value1,
+ self.Value2,
+ self.Value3,
+ self.Value4,
+ self.Value5,
+ self.Value6,
+ self.DataLen,
+ self.Data,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetName(self,Str):
+ if len(Str)<=33:
+ self.Name = Str
+ else:
+ self.Name = Str[:33]
+
+
+
+# 功能队伍表 #tagDBFuncTeam
+class tagDBFuncTeam(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('TeamID', ctypes.c_ulong),
+ ('TeamName', ctypes.c_char * 33),
+ ('ZoneID', ctypes.c_ubyte),
+ ('FuncMapID', ctypes.c_ulong),
+ ('FuncMapEx', ctypes.c_ulong),
+ ('CreateTime', ctypes.c_ulong),
+ ('CaptainID', ctypes.c_ulong),
+ ('MinLV', ctypes.c_ushort),
+ ('MinFightPower', ctypes.c_ulong),
+ ('MinFightPowerEx', ctypes.c_ulong),
+ ('ServerOnly', ctypes.c_ubyte),
+ ('NeedCheck', ctypes.c_ubyte),
+ ('ApplyIDLen', ctypes.c_ushort),
+ ('ApplyIDList', ctypes.c_char_p),
+ ('Value1', ctypes.c_ulong),
+ ('Value2', ctypes.c_ulong),
+ ('Value3', ctypes.c_ulong),
+ ('Value4', ctypes.c_ulong),
+ ('Value5', ctypes.c_ulong),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+ def clear(self):
+ self.TeamID = 0
+ self.TeamName = ''
+ self.ZoneID = 0
+ self.FuncMapID = 0
+ self.FuncMapEx = 0
+ self.CreateTime = 0
+ self.CaptainID = 0
+ self.MinLV = 0
+ self.MinFightPower = 0
+ self.MinFightPowerEx = 0
+ self.ServerOnly = 0
+ self.NeedCheck = 0
+ self.ApplyIDLen = 0
+ self.ApplyIDList = ''
+ self.Value1 = 0
+ self.Value2 = 0
+ self.Value3 = 0
+ self.Value4 = 0
+ self.Value5 = 0
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.TeamID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TeamName, pos = CommFunc.ReadString(buf, pos, 33)
+ self.ZoneID, pos = CommFunc.ReadBYTE(buf, pos)
+ self.FuncMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FuncMapEx, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CreateTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CaptainID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.MinLV, pos = CommFunc.ReadWORD(buf, pos)
+ self.MinFightPower, pos = CommFunc.ReadDWORD(buf, pos)
+ self.MinFightPowerEx, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ServerOnly, pos = CommFunc.ReadBYTE(buf, pos)
+ self.NeedCheck, pos = CommFunc.ReadBYTE(buf, pos)
+ self.ApplyIDLen, pos = CommFunc.ReadWORD(buf, pos)
+ tmp, pos = CommFunc.ReadString(buf, pos, self.ApplyIDLen)
+ self.ApplyIDList = ctypes.c_char_p(tmp)
+ self.Value1, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value2, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value3, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value4, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value5, pos = CommFunc.ReadDWORD(buf, pos)
+ return self.getLength()
+
+ def getBuffer(self):
+ buf = ''
+ buf = CommFunc.WriteDWORD(buf, self.TeamID)
+ buf = CommFunc.WriteString(buf, sizeof(ctypes.c_char) * 33, self.TeamName)
+ buf = CommFunc.WriteBYTE(buf, self.ZoneID)
+ buf = CommFunc.WriteDWORD(buf, self.FuncMapID)
+ buf = CommFunc.WriteDWORD(buf, self.FuncMapEx)
+ buf = CommFunc.WriteDWORD(buf, self.CreateTime)
+ buf = CommFunc.WriteDWORD(buf, self.CaptainID)
+ buf = CommFunc.WriteWORD(buf, self.MinLV)
+ buf = CommFunc.WriteDWORD(buf, self.MinFightPower)
+ buf = CommFunc.WriteDWORD(buf, self.MinFightPowerEx)
+ buf = CommFunc.WriteBYTE(buf, self.ServerOnly)
+ buf = CommFunc.WriteBYTE(buf, self.NeedCheck)
+ buf = CommFunc.WriteWORD(buf, self.ApplyIDLen)
+ buf = CommFunc.WriteString(buf, self.ApplyIDLen, self.ApplyIDList)
+ buf = CommFunc.WriteDWORD(buf, self.Value1)
+ buf = CommFunc.WriteDWORD(buf, self.Value2)
+ buf = CommFunc.WriteDWORD(buf, self.Value3)
+ buf = CommFunc.WriteDWORD(buf, self.Value4)
+ buf = CommFunc.WriteDWORD(buf, self.Value5)
+ return buf
+
+ def getLength(self):
+ length = 0
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_char) * 33
+ 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_ushort)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ulong)
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ubyte)
+ length += sizeof(ctypes.c_ushort)
+ length += self.ApplyIDLen
+ 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)
+ return length
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'TeamID'] = self.TeamID
+ rec[u'TeamName'] = fix_incomingText(self.TeamName)
+ rec[u'ZoneID'] = self.ZoneID
+ rec[u'FuncMapID'] = self.FuncMapID
+ rec[u'FuncMapEx'] = self.FuncMapEx
+ rec[u'CreateTime'] = self.CreateTime
+ rec[u'CaptainID'] = self.CaptainID
+ rec[u'MinLV'] = self.MinLV
+ rec[u'MinFightPower'] = self.MinFightPower
+ rec[u'MinFightPowerEx'] = self.MinFightPowerEx
+ rec[u'ServerOnly'] = self.ServerOnly
+ rec[u'NeedCheck'] = self.NeedCheck
+ rec[u'ApplyIDLen'] = self.ApplyIDLen
+ rec[u'ApplyIDList'] = fix_incomingText(self.ApplyIDList)
+ rec[u'Value1'] = self.Value1
+ rec[u'Value2'] = self.Value2
+ rec[u'Value3'] = self.Value3
+ rec[u'Value4'] = self.Value4
+ rec[u'Value5'] = self.Value5
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.TeamID = rec.get(u'TeamID', 0)
+ self.TeamName = fix_outgoingText(rec.get(u'TeamName', u''))
+ self.ZoneID = rec.get(u'ZoneID', 0)
+ self.FuncMapID = rec.get(u'FuncMapID', 0)
+ self.FuncMapEx = rec.get(u'FuncMapEx', 0)
+ self.CreateTime = rec.get(u'CreateTime', 0)
+ self.CaptainID = rec.get(u'CaptainID', 0)
+ self.MinLV = rec.get(u'MinLV', 0)
+ self.MinFightPower = rec.get(u'MinFightPower', 0)
+ self.MinFightPowerEx = rec.get(u'MinFightPowerEx', 0)
+ self.ServerOnly = rec.get(u'ServerOnly', 0)
+ self.NeedCheck = rec.get(u'NeedCheck', 0)
+ self.ApplyIDLen = rec.get(u'ApplyIDLen', 0)
+ self.ApplyIDList = fix_outgoingText(rec.get(u'ApplyIDList', u''))
+ self.Value1 = rec.get(u'Value1', 0)
+ self.Value2 = rec.get(u'Value2', 0)
+ self.Value3 = rec.get(u'Value3', 0)
+ self.Value4 = rec.get(u'Value4', 0)
+ self.Value5 = rec.get(u'Value5', 0)
+
+#Can not implement adoLoadStr method:No key defined!
+#Can not implement adoInsertStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+#Can not implement adoQueryIndexStr method:No key defined!
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+#Can not implement adoDeleteByIndexStr method:No key defined!
+ def outputString(self):
+ output = '''// 功能队伍表 #tagDBFuncTeam:
+ TeamID = %s,
+ TeamName = %s,
+ ZoneID = %s,
+ FuncMapID = %s,
+ FuncMapEx = %s,
+ CreateTime = %s,
+ CaptainID = %s,
+ MinLV = %s,
+ MinFightPower = %s,
+ MinFightPowerEx = %s,
+ ServerOnly = %s,
+ NeedCheck = %s,
+ ApplyIDLen = %s,
+ ApplyIDList = %s,
+ Value1 = %s,
+ Value2 = %s,
+ Value3 = %s,
+ Value4 = %s,
+ Value5 = %s,
+ ADOResult = %s,
+ '''%(
+ self.TeamID,
+ self.TeamName,
+ self.ZoneID,
+ self.FuncMapID,
+ self.FuncMapEx,
+ self.CreateTime,
+ self.CaptainID,
+ self.MinLV,
+ self.MinFightPower,
+ self.MinFightPowerEx,
+ self.ServerOnly,
+ self.NeedCheck,
+ self.ApplyIDLen,
+ self.ApplyIDList,
+ self.Value1,
+ self.Value2,
+ self.Value3,
+ self.Value4,
+ self.Value5,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.TeamID,
+ self.TeamName,
+ self.ZoneID,
+ self.FuncMapID,
+ self.FuncMapEx,
+ self.CreateTime,
+ self.CaptainID,
+ self.MinLV,
+ self.MinFightPower,
+ self.MinFightPowerEx,
+ self.ServerOnly,
+ self.NeedCheck,
+ self.ApplyIDLen,
+ self.ApplyIDList,
+ self.Value1,
+ self.Value2,
+ self.Value3,
+ self.Value4,
+ self.Value5,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetTeamName(self,Str):
+ if len(Str)<=33:
+ self.TeamName = Str
+ else:
+ self.TeamName = Str[:33]
+
+
+# 功能队伍成员表 #tagDBFuncTeamMem
+class tagDBFuncTeamMem(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('TeamID', ctypes.c_ulong),
+ ('PlayerID', ctypes.c_ulong),
+ ('Value1', ctypes.c_ulong),
+ ('Value2', ctypes.c_ulong),
+ ('Value3', ctypes.c_ulong),
+ ('Value4', ctypes.c_ulong),
+ ('Value5', 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:
+ msg = error.formatMsg('error', error.ERROR_NO_148, '(pos = %s) > (length = %s)'%(pos, length))
+ mylog.error(msg)
+ return -1
+ if len(buf) < pos + self.getLength():
+ msg = error.formatMsg('error', error.ERROR_NO_149, 'len = %s while %s expected!'%(len(buf) - pos, self.getLength()))
+ mylog.error(msg)
+ self.clear()
+ self.TeamID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value1, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value2, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value3, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value4, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Value5, 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(tagDBFuncTeamMem)
+
+ def getRecord(self):
+ '''组织存储记录'''
+ rec = {}
+ rec[u'TeamID'] = self.TeamID
+ rec[u'PlayerID'] = self.PlayerID
+ rec[u'Value1'] = self.Value1
+ rec[u'Value2'] = self.Value2
+ rec[u'Value3'] = self.Value3
+ rec[u'Value4'] = self.Value4
+ rec[u'Value5'] = self.Value5
+ return rec
+
+ def readRecord(self, rec):
+ '''由于MongoDB读出来是unicode,所有字符串需要进行转换'''
+ self.TeamID = rec.get(u'TeamID', 0)
+ self.PlayerID = rec.get(u'PlayerID', 0)
+ self.Value1 = rec.get(u'Value1', 0)
+ self.Value2 = rec.get(u'Value2', 0)
+ self.Value3 = rec.get(u'Value3', 0)
+ self.Value4 = rec.get(u'Value4', 0)
+ self.Value5 = rec.get(u'Value5', 0)
+
+#Can not implement adoLoadStr method:No key defined!
+#Can not implement adoInsertStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateStr method:No key defined!
+#Can not implement adoCheckUpdateExStr method:No key defined!
+
+ def getAdoRecords(self, resultCollection):
+ '''查询结果打包成二进制流'''
+ result = ''
+ result = CommFunc.WriteDWORD(result, resultCollection.count())
+ for rec in resultCollection:
+ self.readRecord(rec)
+ result += self.getBuffer()
+ return result
+
+#Can not implement adoQueryIndexStr method:No key defined!
+
+ def adoQueryCustom(self, collection, queryDict):
+ '''自定义查询'''
+ resultCollection = collection.find(queryDict)
+
+ return self.getAdoRecords(resultCollection)
+
+
+ def adoQueryAll(self, collection):
+ '''查询所有'''
+ resultCollection = collection.find()
+
+ return self.getAdoRecords(resultCollection)
+
+#Can not implement adoDeleteByIndexStr method:No key defined!
+ def outputString(self):
+ output = '''// 功能队伍成员表 #tagDBFuncTeamMem:
+ TeamID = %s,
+ PlayerID = %s,
+ Value1 = %s,
+ Value2 = %s,
+ Value3 = %s,
+ Value4 = %s,
+ Value5 = %s,
+ ADOResult = %s,
+ '''%(
+ self.TeamID,
+ self.PlayerID,
+ self.Value1,
+ self.Value2,
+ self.Value3,
+ self.Value4,
+ self.Value5,
+ self.ADOResult,
+ )
+ return output
+
+ def dumpString(self):
+ output = '''%1s\t%1s\t%1s\t%1s\t%1s\t%1s\t%1s'''%(
+ self.TeamID,
+ self.PlayerID,
+ self.Value1,
+ self.Value2,
+ self.Value3,
+ self.Value4,
+ self.Value5,
+ )
+ return output
+
+
--
Gitblit v1.8.0