Commit 1886443d authored by aleajactaest's avatar aleajactaest

update

parent 65f0ee64
......@@ -942,12 +942,12 @@ def main():
#logger.append(logging.getLogger(LOGGER))
# logger.append(logging.getLogger(CImpulseDecoder.LOGGER))
# #logger.append(logging.getLogger(DecodeImpuls.LOGGER))
# #logger.append(logging.getLogger(BitStream.LOGGER))
logger.append(logging.getLogger(BitStream.LOGGER))
# logger.append(logging.getLogger(CStringManager.LOGGER))
#logger.append(logging.getLogger(CAction.LOGGER))
#logger.append(logging.getLogger(CActionFactory.LOGGER))
#logger.append(logging.getLogger(BitStream.LOGGER))
#logger.append(logging.getLogger(DecodeDatabase.LOGGER))
logger.append(logging.getLogger(DecodeDatabase.LOGGER))
logger.append(logging.getLogger(Impulse.LOGGER))
#logger.append(logging.getLogger(TVPNodeBase.LOGGER))
# CImpulseDecoder
......
......@@ -542,7 +542,8 @@ class BitStream():
if nbits == 0:
return
elif nbits > 32:
raise "Out of range"
logging.getLogger(LOGGER).error("Error: Stream Overflow - nbits:%d/%d name:'%s' decode:'%s' typeName:'%s' emulate:%s msg:%s" % (nbits, self._pos-self._read, name, str(decode), typeName, str(emulate), self.showAllData()))
raise OverflowError
if self._read + nbits > self._pos:
if self._CheckStreamOverflow:
logging.getLogger(LOGGER).error("Error: Stream Overflow - nbits:%d/%d name:'%s' decode:'%s' typeName:'%s' emulate:%s msg:%s" % (nbits, self._pos-self._read, name, str(decode), typeName, str(emulate), self.showAllData()))
......@@ -568,9 +569,9 @@ class BitStream():
self._groupRead.append((v1, v1+nbits, name, typeName, value, commentValue))
return value
def readSerial64(self, nbits, name="", decode=True, typeName=None, commentValue=None):
def readSerialUint64(self, nbits, name="", decode=True, typeName=None, commentValue=None):
v1 = self._read
if nbits > 32:
v1 = self._read
msd = self.readSerial(nbits - 32, name, False, typeName)
msd2 = self.readSerial(32, name, False, typeName)
value = msd << 32 | msd2
......@@ -579,10 +580,31 @@ class BitStream():
typeName = 'Uint{0}'.format(nbits)
self._groupRead.append((v1, v1+nbits, name, typeName, value, commentValue))
return value
else:
if decode:
if typeName is None:
typeName = 'Uint{0}'.format(nbits)
value = self.readSerial(nbits, name, False, None, commentValue=None)
self._groupRead.append((v1, v1+nbits, name, typeName, value, commentValue))
return value
def readSerialSint64(self, nbits, name="", decode=True, typeName=None, commentValue=None):
v1 = self._read
if nbits > 32:
msd = self.readSerial(nbits - 32, name, False, typeName)
msd2 = self.readSerial(32, name, False, typeName)
value = msd << 32 | msd2
if decode:
if typeName is None:
typeName = 'Sint{0}'.format(nbits)
self._groupRead.append((v1, v1+nbits, name, typeName, value, commentValue))
else:
if typeName is None:
typeName = 'Uint{0}'.format(nbits)
return self.readSerial(nbits, name, decode, typeName, commentValue=commentValue)
typeName = 'Sint{0}'.format(nbits)
value = self.readSerial(nbits, name, False, None, commentValue=None)
self._groupRead.append((v1, v1+nbits, name, typeName, value, commentValue))
#value = self.readSerial(nbits, name, decode, typeName, commentValue=commentValue)
return c_int64(value).value
def readCBitSet(self, nbits, name="", decode=True, typeName=None, commentValue=None):
# khanat-opennel-code/code/nel/src/misc/bit_mem_stream.cpp void CBitMemStream::readBits( NLMISC::CBitSet& bitfield )
......@@ -610,8 +632,9 @@ class BitStream():
if decode:
valuereal = cBitSet.showBitString()
_size = len(valuereal)
_start = _size - nbits
self._groupRead.append((v1, v1+nbits, name, typeName, valuereal[0:nbits], commentValue))
# _start = _size - nbits
#self._groupRead.append((v1, v1+nbits, name, typeName, valuereal[0:nbits], commentValue))
self._groupRead.append((v1, v1+nbits, name, typeName, valuereal[-nbits:], commentValue))
return cBitSet
def readCBitSetOld2(self, nbits, name="", decode=True, typeName=None, commentValue=None):
......@@ -755,6 +778,20 @@ class BitStream():
def readChar(self, name, decode=True):
v = self.readUint8(name=name, decode=decode, typeName='Char')
return chr(v)
def readNbChar(self, size, name, decode=True):
tmp = ''
_size = size
v1 = self._read
while _size > 0:
x = self.readChar('', decode=False)
tmp += x
_size -= 1
v2 = self._read
if v2 > self._pos:
raise ValueError
if v1 < v2:
self._groupRead.append((v1, v2, name + ':string', 'String', tmp, None))
return tmp
def readString(self, name):
tmp = ''
......
......@@ -453,7 +453,7 @@ class CActionSint64(CAction):
logging.getLogger(LOGGER).debug("nb bit:{0}".format(self.NbBits))
logging.getLogger(LOGGER).debug("msgin:%s" % msgin.showAllData())
# self.value = msgin.readSerial( self.NbBits, 'value')
self.value = msgin.readSerial64( self.NbBits, self.NameProperty)
self.value = msgin.readSerialUint64( self.NbBits, self.NameProperty)
logging.getLogger(LOGGER).debug("msgin:%s" % msgin.showAllData())
#self.NbBits = msgin.readUint32('NbBits')
logging.getLogger(LOGGER).debug("value:%u" % self.value)
......
......@@ -52,25 +52,26 @@ class CGenericMultiPartTemp():
self.block.setdefault(Part, PartCont)
self.block.setdefault(Part, None)
self.block[Part] = PartCont
logging.getLogger(LOGGER).error("CGenericMultiPartTemp : Number:%d len:%d/%d" % (Number, len(self.block), self.NbBlock))
logging.getLogger(LOGGER).debug("CGenericMultiPartTemp : Number:%d len:%d/%d" % (Number, len(self.block), self.NbBlock))
if len(self.block) == self.NbBlock:
# reform the total action
bms = BitStream.BitStream()
self.NbBlock == 0xFFFFFFFF
for data in self.block:
logging.getLogger(LOGGER).error("CGenericMultiPartTemp : Number:%d id:%d len:%d/%d" % (Number, data, len(self.block), self.NbBlock))
logging.getLogger(LOGGER).debug("CGenericMultiPartTemp : Number:%d id:%d len:%d/%d" % (Number, data, len(self.block), self.NbBlock))
bms.pushBitStream(self.block[data])
if self.AutoDecompile:
try:
ret = decodeImpulse.execute(bms, world)
except:
logging.getLogger(LOGGER).error("CGenericMultiPartTemp : Error to decode - Number:%d len:%d/%d msg:%s" % (Number, len(self.block), self.NbBlock, bms.showAllData()))
return ret
logging.getLogger(LOGGER).error("CGenericMultiPartTemp : data : %s" % bms.showAllData())
#return ret
raise ValueError
logging.getLogger(LOGGER).debug("CGenericMultiPartTemp : data : %s" % bms.showAllData())
self.MsgDecoded = bms
else:
logging.getLogger(LOGGER).error("CGenericMultiPartTemp : Wait other block Number:%d [%d/%d]" % (Number, len(self.block), self.NbBlock))
logging.getLogger(LOGGER).debug("CGenericMultiPartTemp : Wait other block Number:%d [%d/%d]" % (Number, len(self.block), self.NbBlock))
return ret
def isDecoded(self):
......
This diff is collapsed.
......@@ -664,6 +664,7 @@ class impulseDatabaseInitPlayer(ImpulseBase):
# _ = self.readUint32(msgin, '%s_property' % id)
for i in range(0, propertyCount):
logging.getLogger(LOGGER).debug("read i:%d" % i)
logging.getLogger(LOGGER).debug("#" * 80)
databaseXml.execute(msgin, world)
#raise "TODO"
if msgin.needRead() > 5:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment