Commit 1df1ee15 authored by aleajactaest's avatar aleajactaest
Browse files

update

parent 065b2907
This diff is collapsed.
......@@ -41,6 +41,10 @@ class BitStream():
def __len__(self):
return (self._pos + 7) // 8
def reset_read(self):
self._read = 0
self._groupRead = []
def __deepcopy__(self, memo):
ret = BitStream()
......@@ -583,27 +587,53 @@ class BitStream():
return c_int8(v).value
def readUint64(self, name):
# khanat-opennel-code/code/nel/include/nel/misc/stream.h #define NLMISC_BSWAP64(src) (src) = (((src)>>56)&0xFF) | ((((src)>>48)&0xFF)<<8) | ((((src)>>40)&0xFF)<<16) | ((((src)>>32)&0xFF)<<24) | ((((src)>>24)&0xFF)<<32) | ((((src)>>16)&0xFF)<<40) | ((((src)>>8)&0xFF)<<48) | (((src)&0xFF)<<56)
p1 = self._read
if sys.byteorder == "little":
v1 = self.readSerial(32, decode=False)
v2 = self.readSerial(32, decode=False)
v4 = self.readSerial(8, decode=False)
v3 = self.readSerial(8, decode=False)
v2 = self.readSerial(8, decode=False)
v1 = self.readSerial(8, decode=False)
v8 = self.readSerial(8, decode=False)
v7 = self.readSerial(8, decode=False)
v6 = self.readSerial(8, decode=False)
v5 = self.readSerial(8, decode=False)
else:
v2 = self.readSerial(32, decode=False)
v1 = self.readSerial(32, decode=False)
v3 = (v1 << 32) | v2
self._groupRead.append((p1, p1+64, name, 'Uint64', v3))
v1 = self.readSerial(8, decode=False)
v2 = self.readSerial(8, decode=False)
v3 = self.readSerial(8, decode=False)
v4 = self.readSerial(8, decode=False)
v5 = self.readSerial(8, decode=False)
v6 = self.readSerial(8, decode=False)
v7 = self.readSerial(8, decode=False)
v8 = self.readSerial(8, decode=False)
ret = v8 << 56 | v7 << 48 | v6 << 40 | v5 << 32 | v4 << 24 | v3 << 16 | v2 << 8 | v1
self._groupRead.append((p1, p1+64, name, 'Uint64', ret))
return v3
def readSint64(self, name):
# khanat-opennel-code/code/nel/include/nel/misc/stream.h #define NLMISC_BSWAP64(src) (src) = (((src)>>56)&0xFF) | ((((src)>>48)&0xFF)<<8) | ((((src)>>40)&0xFF)<<16) | ((((src)>>32)&0xFF)<<24) | ((((src)>>24)&0xFF)<<32) | ((((src)>>16)&0xFF)<<40) | ((((src)>>8)&0xFF)<<48) | (((src)&0xFF)<<56)
p1 = self._read
if sys.byteorder == "little":
v1 = self.readSerial(32, decode=False)
v2 = self.readSerial(32, decode=False)
v4 = self.readSerial(8, decode=False)
v3 = self.readSerial(8, decode=False)
v2 = self.readSerial(8, decode=False)
v1 = self.readSerial(8, decode=False)
v8 = self.readSerial(8, decode=False)
v7 = self.readSerial(8, decode=False)
v6 = self.readSerial(8, decode=False)
v5 = self.readSerial(8, decode=False)
else:
v2 = self.readSerial(32, decode=False)
v1 = self.readSerial(32, decode=False)
v3 = (v1 << 32) | v2
self._groupRead.append((p1, p1+64, name, 'Sint64', c_int64(v3).value))
v1 = self.readSerial(8, decode=False)
v2 = self.readSerial(8, decode=False)
v3 = self.readSerial(8, decode=False)
v4 = self.readSerial(8, decode=False)
v5 = self.readSerial(8, decode=False)
v6 = self.readSerial(8, decode=False)
v7 = self.readSerial(8, decode=False)
v8 = self.readSerial(8, decode=False)
ret = v8 << 56 | v7 << 48 | v6 << 40 | v5 << 32 | v4 << 24 | v3 << 16 | v2 << 8 | v1
self._groupRead.append((p1, p1+64, name, 'Sint64', c_int64(ret).value))
return c_int64(v3).value
def readFloat(self, name):
......
......@@ -115,6 +115,10 @@ class CAction:
return "[%d,%d]" % (self.Code , self.Slot)
class CActionPosition(CAction):
"""
Method use to decode position
khanat/khanat-opennel-code/code/ryzom/client/src/property_decoder.cpp:39 - void CPropertyDecoder::receive(TPacketNumber /* packetNumber */, CAction *action)
"""
def __init__(self, slot, code, world):
super().__init__(slot, code, world)
self.Position = [0, 0, 0]
......@@ -503,3 +507,8 @@ class CActionFake():
ret["Reference"] = self.Reference
ret["Message"] = self._Message.extractAllData()
return ret
def decodeImpulseSimple(self, decodeImpulseSimple, world, cGenericMultiPartTemp, Reference = None, Name = ""):
ret = decodeImpulseSimple.execute(self._Message, world, Reference, Name)
self.decoded = True
return ret
......@@ -24,13 +24,14 @@ from tools import BitStream
LOGGER='CGenericMultiPartTemp'
class CGenericMultiPartTemp():
def __init__(self):
def __init__(self, autoDecompile=True):
self.NbBlock = 0xFFFFFFFF
self.MsgDecoded = None
self.FirstRead = False
self.Reference = []
self.block = {}
self.Name = None
self.AutoDecompile = autoDecompile
def getNbCurrentBlock(self):
return len(self.block)
......@@ -60,11 +61,12 @@ class CGenericMultiPartTemp():
for data in self.block:
logging.getLogger(LOGGER).error("CGenericMultiPartTemp : Number:%d id:%d len:%d/%d" % (Number, data, len(self.block), self.NbBlock))
bms.pushBitStream(self.block[data])
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
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())
self.MsgDecoded = bms
else:
......
......@@ -24,6 +24,7 @@ from tools import getPowerOf2
from tools import CShardName
from tools import CCharacterSummary
from tools import CMainlandSummary
from tools import DecodeDatabase
LOGGER='DecodeImpulse'
......@@ -34,9 +35,10 @@ class DecodeImpulse():
khanat-opennel-code/code/ryzom/client/src/net_manager.cpp # void initializeNetwork()
'''
self.msgXml = None
self.databaseXml = None
# self.databaseXml = None
self.GenericMsgHeaderMngr = {}
self.initializeNetwork()
self.decodeDatabase = DecodeDatabase.DecodeDatabase()
def updatePatcherPriorityBasedOnCharacters(self, world):
logging.getLogger(LOGGER).debug('Load character')
......@@ -581,4 +583,4 @@ class DecodeImpulse():
self.msgXml = msgXml
def loadDatabase(self, databaseXml):
self.databaseXml = databaseXml
self.decodeDatabase.loadDatabase(self.databaseXml)
......@@ -612,3 +612,37 @@ class TCDBBank(IntEnum):
# CDBGlobal,
NB_CDB_BANKS = 3,
INVALID_CDB_BANK = 4
class TPropIndex(IntEnum):
PROPERTY_POSITION = 0,
PROPERTY_POSX = 0,
PROPERTY_POSY = 1,
PROPERTY_POSZ = 2,
PROPERTY_ORIENTATION = 3,
PROPERTY_SHEET = 4
PROPERTY_BEHAVIOUR = 5,
PROPERTY_NAME_STRING_ID = 6,
PROPERTY_TARGET_ID = 7,
PROPERTY_MODE = 8,
PROPERTY_VPA = 9,
PROPERTY_VPB = 10,
PROPERTY_VPC = 11,
PROPERTY_ENTITY_MOUNTED_ID = 12,
PROPERTY_RIDER_ENTITY_ID = 13,
PROPERTY_CONTEXTUAL = 14,
PROPERTY_BARS = 15
PROPERTY_TARGET_LIST = 16,
PROPERTY_TARGET_LIST_0 = 16,
PROPERTY_TARGET_LIST_1 = 17,
PROPERTY_TARGET_LIST_2 = 18,
PROPERTY_TARGET_LIST_3 = 19,
PROPERTY_GUILD_SYMBOL = 20,
PROPERTY_GUILD_NAME_ID = 21,
PROPERTY_VISUAL_FX = 22,
PROPERTY_EVENT_FACTION_ID = 23,
PROPERTY_PVP_MODE = 24,
PROPERTY_PVP_CLAN = 25,
PROPERTY_OWNER_PEOPLE = 26,
PROPERTY_OUTPOST_INFOS = 27,
NB_VISUAL_PROPERTIES = 28
......@@ -164,6 +164,8 @@ class ImpulseBase:
value = msgin.readUint32(id + '_extended')
self.param.setdefault(id, value)
return value
def readDatabases(self, world, decodeDatabase):
return None
class ImpulseBotchatSetFilters(ImpulseBase):
def __init__(self):
......@@ -315,9 +317,10 @@ class ImpulseGuildFemaleTitles(ImpulseBase):
self.readSerial(msgin, 1, 'UseFemaleTitles')
class ImpulseNpsIconSetDesc(ImpulseBase):
class ImpulseNpcIconSetDesc(ImpulseBase):
def __init__(self):
super().__init__()
self.data = BitStream.BitStream()
def read(self, name, msgin, world):
'''
......@@ -326,9 +329,15 @@ class ImpulseNpsIconSetDesc(ImpulseBase):
logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_')
nb8 = self.readUint8(msgin, 'nb8')
self.data.pushUint8(nb8)
for i in range(0, nb8):
self.readUint32(msgin, 'NpcIconSetDesc_%d_npcAlias' % nb8)
self.readUint32(msgin, 'NpcIconSetDesc_%d_state' % nb8)
npcAlias = self.readUint32(msgin, 'NpcIconSetDesc_%d_npcAlias' % nb8)
self.data.pushUint32(npcAlias)
state = self.readUint32(msgin, 'NpcIconSetDesc_%d_state' % nb8)
self.data.pushUint32(state)
def readDatabases(self, world, decodeDatabase):
return decodeDatabase.execute(self.data, world)
class ImpulsePhraseDownload(ImpulseBase):
......@@ -392,8 +401,10 @@ class ImpulsePosition(ImpulseBase):
super().__init__()
def read(self, name, msgin, world):
# khanat-opennel-code/code/ryzom/server/src/gpm_service/client_messages.cpp void cbClientPosition( CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId )
logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_')
self.readBool(msgin, '')
self.readSint32(msgin, 'X')
self.readSint32(msgin, 'Y')
self.readSint32(msgin, 'Z')
......@@ -636,7 +647,7 @@ class impulseDatabaseInitPlayer(ImpulseBase):
self.readUint32(msgin, '%s_serverTick' % id)
propertyCount = self.readUint16(msgin, '%s_propertyCount' % id)
for i in range(0, propertyCount):
propertyCount = self.readUint32(msgin, '%s_propertyCount' % id)
_ = self.readUint32(msgin, '%s_property' % id)
class ImpulseConnectionDeleteChar(ImpulseBase):
......@@ -651,6 +662,56 @@ class ImpulseConnectionDeleteChar(ImpulseBase):
self.name = name.replace(':', '_')
self.readUint8(msgin, '%s_slot' % id)
class impulseTeamContactInit(ImpulseBase):
def __init__(self):
super().__init__()
def read(self, name, msgin, world):
id = "TeamContactInit"
logging.getLogger(LOGGER).debug("read")
self.name = name.replace(':', '_')
friend_string_ids_len = self.readUint32(msgin, '%s_friend_string_ids_len' % id)
for i in range(0, friend_string_ids_len):
_ = self.readUint32(msgin, '%s_friend_string_ids_%d' % (id, i))
nb_state = self.readUint32(msgin, '%s_nb_state' % id)
for i in range(0, nb_state):
_ = self.readUint32(msgin, '%s_friend_online_status_%d' % (id, i))
ignore_list_len = self.readUint32(msgin, '%s_ignore_list_len' % id)
for i in range(0, ignore_list_len):
_ = self.readUString(msgin, '%s_ignore_list_%d' % (id, i))
class impulseNpcIconGetDesc(ImpulseBase):
def __init__(self):
super().__init__()
def read(self, name, msgin, world):
# khanat-opennel-code/code/ryzom/server/src/frontend_service/id_impulsions.cpp void cbImpulsionGetNpcIconDesc( CEntityId& sender, CBitMemStream &bms, TGameCycle gamecycle, uint16 serviceId )
id = "ClientNpcIcon"
logging.getLogger(LOGGER).debug("read %s" % id)
self.name = name.replace(':', '_')
nb8 = self.readUint8(msgin, '%s_nb8' % id)
for i in range(0, nb8):
_ = self.readUint32(msgin, '%s_NPCIconCacheKey_%d' % (id, i))
class impulseUserBars(ImpulseBase):
def __init__(self):
super().__init__()
def read(self, name, msgin, world):
# khanat-opennel-code/code/ryzom/server/src/entities_game_service/player_manager/character.cpp void CCharacter::barUpdate()
id = "UserBars"
logging.getLogger(LOGGER).debug("read %s" % id)
self.name = name.replace(':', '_')
_ = self.readUint8(msgin, '%s_barsenttoplayermsgnumber' % id)
_ = self.readSint32(msgin, '%s_oldchascore1barsenttoplayer' % id)
_ = self.readSint32(msgin, '%s_oldchascore2barsenttoplayer' % id)
_ = self.readSint32(msgin, '%s_oldchascore3barsenttoplayer' % id)
_ = self.readSint32(msgin, '%s_oldchascore4barsenttoplayer' % id)
class DecodeImpulseSimple:
def __init__(self):
'''
......@@ -677,7 +738,7 @@ class DecodeImpulseSimple:
self.GenericMsgHeaderMngr.setdefault( "DEATH:RESPAWN_POINT", impulseDeathRespawnPoint)
self.GenericMsgHeaderMngr.setdefault( "GUILD:UPDATE_PLAYER_TITLE", impulseGuildUpdatePlayerTitle)
self.GenericMsgHeaderMngr.setdefault( "GUILD:USE_FEMALE_TITLES", ImpulseGuildFemaleTitles )
self.GenericMsgHeaderMngr.setdefault( "NPC_ICON:SET_DESC", ImpulseNpsIconSetDesc )
self.GenericMsgHeaderMngr.setdefault( "NPC_ICON:SET_DESC", ImpulseNpcIconSetDesc )
self.GenericMsgHeaderMngr.setdefault( "PHRASE:DOWNLOAD", ImpulsePhraseDownload )
self.GenericMsgHeaderMngr.setdefault( "POSITION", ImpulsePosition )
self.GenericMsgHeaderMngr.setdefault( "STRING:DYN_STRING", ImpulseSringDynString )
......@@ -688,6 +749,9 @@ class DecodeImpulseSimple:
self.GenericMsgHeaderMngr.setdefault( "ENCYCLOPEDIA:INIT", impulseEncyclopediaInit )
self.GenericMsgHeaderMngr.setdefault( "DB_INIT:INV", impulseInitInventory)
self.GenericMsgHeaderMngr.setdefault( "DB_INIT:PLR", impulseDatabaseInitPlayer)
self.GenericMsgHeaderMngr.setdefault( "TEAM:CONTACT_INIT", impulseTeamContactInit)
self.GenericMsgHeaderMngr.setdefault( "NPC_ICON:GET_DESC", impulseNpcIconGetDesc)
self.GenericMsgHeaderMngr.setdefault( "USER:BARS", impulseUserBars)
def execute(self, msgin, world, references = [], name=""):
'''
......@@ -743,6 +807,11 @@ class DecodeImpulseSimple:
if a == 0:
return impulse
logging.getLogger(LOGGER).error("MessageXML not decoded: [%s] %s [size:%d, not read:%d]" % (fullname, msgin.showAllData(), nbBitNotRead, a))
elif nbBitNotRead < 32:
a = msgin.readSerial(nbBitNotRead, decode=False)
if a == 0:
return impulse
logging.getLogger(LOGGER).error("MessageXML not decoded: [%s] %s [size:%d, not read:%d]" % (fullname, msgin.showAllData(), nbBitNotRead, a))
logging.getLogger(LOGGER).error("MessageXML not decoded: [%s] %s [size:%d]" % (fullname, msgin.showAllData(), nbBitNotRead))
return None
else:
......
......@@ -26,3 +26,11 @@ def getPowerOf2(v):
ret += 1
res *= 2
return ret
def getPowerOf2_Bis(v):
res=1;
ret=0;
while res<=v:
ret += 1
res *= 2
return ret
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