Commit 9755a294 authored by aleajactaest's avatar aleajactaest

decode visual properties

parent 317fd2cf
This diff is collapsed.
......@@ -125,6 +125,20 @@ class BitStream():
name = name.strip().split(' ')[0].strip()
self._groupWrite.append((p1, p1+nbits, name, typeName, value))
def pushSerial64(self, value, nbits, decode=True, typeName=None):
if nbits > 32:
p1 = self._pos
msd = value >> 32
self.internalSerial(msd, nbits - 32, False, typeName)
self.internalSerial(value, 32, False, typeName)
value = msd << 32 | msd2
if typeName is None:
typeName = 'Uint{0}'.format(nbits)
self._groupWrite.append((p1, p1+nbits, name, typeName, value))
return value
else:
return self.internalSerial(value, nbits, decode, typeName)
def pushBool(self, value, decode=True):
p1 = self._pos
if value:
......@@ -553,6 +567,22 @@ class BitStream():
self._groupRead.append((v1, v1+nbits, name, typeName, value))
return value
def readSerial64(self, nbits, name="", decode=True, typeName=None):
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
if decode:
if typeName is None:
typeName = 'Uint{0}'.format(nbits)
self._groupRead.append((v1, v1+nbits, name, typeName, value))
return value
else:
if typeName is None:
typeName = 'Uint{0}'.format(nbits)
return self.readSerial(nbits, name, decode, typeName)
def readBool(self, name):
v1 = self._read
v = self.readSerial(1, name=name, decode=False, typeName='Bool')
......
......@@ -27,6 +27,32 @@ from tools import Enum
LOGGER='CActionFactory'
INVALID_SLOT = 0xff
# khanat-opennel-code/code/ryzom/common/src/game_share/action_sint64.cpp:55 void CActionSint64::registerNumericPropertiesRyzom()
PROPERTY_TO_NB_BIT = [0 for _ in range(0, Enum.TPropIndex.NB_VISUAL_PROPERTIES)]
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_ORIENTATION] = 32
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_SHEET] = 52
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_BEHAVIOUR] = 48
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_NAME_STRING_ID] = 32
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_TARGET_ID] = 8
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_MODE] = 44
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_VPA] = 64
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_VPB] = 47
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_VPC] = 58
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_ENTITY_MOUNTED_ID] = 8
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_RIDER_ENTITY_ID] = 8
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_CONTEXTUAL] = 16
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_BARS] = 32
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_TARGET_LIST] = 32 # USER_DEFINED_PROPERTY_NB_BITS
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_VISUAL_FX] = 11
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_GUILD_SYMBOL] = 60
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_GUILD_NAME_ID] = 32
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_EVENT_FACTION_ID] = 32
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_PVP_MODE] = Enum.TPVPMode.NbBits
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_PVP_CLAN] = 32
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_OWNER_PEOPLE] = 3 # 4 races + unknow
PROPERTY_TO_NB_BIT[Enum.TPropIndex.PROPERTY_OUTPOST_INFOS] = 16 # 15+1
class CAction:
def __init__(self, slot, code, world):
self.Code = code
......@@ -385,8 +411,10 @@ class CActionSint64(CAction):
def __init__(self, slot, code, world):
super().__init__(slot, code, world)
self.value = 0
self.NbBits = 0
self.PropertyToNbBit = { TPropIndex.TPropIndex.PROPERTY_ORIENTATION: 32,
self.NbBits = 64
self.NameProperty = 'None'
self.PropertyToNbBit = {
TPropIndex.TPropIndex.PROPERTY_ORIENTATION: 32,
TPropIndex.TPropIndex.PROPERTY_SHEET: 52,
TPropIndex.TPropIndex.PROPERTY_BEHAVIOUR: 48,
TPropIndex.TPropIndex.PROPERTY_NAME_STRING_ID: 32,
......@@ -418,22 +446,31 @@ class CActionSint64(CAction):
return "CActionSint64" + super().__str__()
def unpack(self, msgin):
logging.getLogger(LOGGER).debug("nb bit:{0}".format(self.NbBits))
logging.getLogger(LOGGER).debug("msgin:%s" % msgin.showAllData())
self.value = msgin.readUint64('value')
# self.value = msgin.readSerial( self.NbBits, 'value')
self.value = msgin.readSerial64( 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)
logging.getLogger(LOGGER).debug("msgin:%s" % msgin.showAllData())
def pack(self, msgout):
super().pack(msgout)
msgout.pushUint64(self.value)
#msgout.pushUint64(self.value)
msgout.pushSerial64(self.value, self.NbBits)
#msgout.pushUint32(self.NbBits)
def reset(self):
self.value = 0
self.NbBits = 0
self.NameProperty = 'None'
def setNbBits(self, propIndex, nameproperty):
self.NbBits = PROPERTY_TO_NB_BIT[propIndex]
self.NameProperty = nameproperty
self.set_name(nameproperty)
logging.getLogger(LOGGER).debug("NameProperty:{1} NbBits:{0}".format(self.NbBits, self.NameProperty ))
class CActionBlock:
......
......@@ -91,6 +91,18 @@ class CActionFactory:
action.Slot = slot
return action
def createByPropIndex(self, slot, propIndex, nameproperty):
logging.getLogger(LOGGER).debug('createByPropIndex (slot:{0}, propIndex:{1}, nameproperty:{2})'.format(slot, propIndex, nameproperty))
if propIndex == Enum.TPropIndex.PROPERTY_POSITION:
action = self.create(slot, Enum.TActionCode.ACTION_POSITION_CODE)
else:
action =self. create(slot, Enum.TActionCode.ACTION_SINT64)
action.setNbBits(propIndex, nameproperty)
action.PropertyCode = propIndex
return action
# khanat-opennel-code/code/ryzom/common/src/game_share/action_factory.cpp:152
def unpack(self, msgin, Reference = None, Name = None):
'''
khanat-opennel-code/code/ryzom/common/src/game_share/action_factory.cpp : CAction *CActionFactory::unpack (NLMISC::CBitMemStream &message, NLMISC::TGameCycle /* currentCycle */ )
......@@ -107,12 +119,10 @@ class CActionFactory:
try:
action.unpack (msgin);
except RuntimeError:
log = logging.getLogger('myLogger')
log.warning('Missing code to unpack (code :%u)' % code)
logging.getLogger(LOGGER).warning('Missing code to unpack (code :%u)' % code)
raise RuntimeError
else:
log = logging.getLogger('myLogger')
log.warning('Unpacking an action with unknown code, skip it (%u)' % code)
logging.getLogger(LOGGER).warning('Unpacking an action with unknown code, skip it (%u)' % code)
if Reference:
action.add_reference(Reference)
if Name:
......
......@@ -38,9 +38,9 @@ class CEntityEntry():
class CPropertyDecoder():
def __init__(self):
# khanat-opennel-code/code/ryzom/client/src/network_connection.cpp:2937 _PropertyDecoder.init (256);
for i in range(0, 256):
self.Entities[i] = CEntityEntry()
self.Entities = [CEntityEntry() for _ in range(0, 256)]
#for i in range(0, 256):
# self.Entities[i] = CEntityEntry()
self._RefPosX = 0
self._RefPosY = 0
self._RefBitsX = 0
......
......@@ -266,7 +266,6 @@ class TPeople(IntEnum):
EndPeople = 142
class ECharacterTitle(IntEnum):
'''
khanat-opennel-code/code/ryzom/common/src/game_share/character_title.h # enum ECharacterTitle
......@@ -579,11 +578,11 @@ class NPC_ICON(IntEnum): # TNPCMissionGiverState
NbMissionGiverStates = 7
class TInventoryId(IntEnum):
Bag = 0,
Packers = 1,
Room= 5, # Packers+MaxNbPackers,
InvalidInvId = 6,
NbInventoryIds = 6, # =InvalidInvId
Bag = 0,
Packers = 1,
Room= 5, # Packers+MaxNbPackers,
InvalidInvId = 6,
NbInventoryIds = 6, # =InvalidInvId
class TItemPropId(IntEnum):
Sheet = 0,
......@@ -646,3 +645,18 @@ class TPropIndex(IntEnum):
PROPERTY_OUTPOST_INFOS = 27,
NB_VISUAL_PROPERTIES = 28
class TPVPMode(IntEnum):
NONE = 0,
PvpDuel = 1,
PvpChallenge = 2,
PvpZoneFree = 4,
PvpZoneFaction = 8,
PvpZoneGuild = 16,
PvpZoneOutpost = 32,
PvpFaction = 64,
PvpFactionFlagged = 128,
PvpZoneSafe = 256,
PvpSafe = 512,
#Unknown = 513,
#NbModes = 513,
NbBits = 10 #// number of bits needed to store all valid values
......@@ -701,7 +701,7 @@ class impulseUserBars(ImpulseBase):
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()
# 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(':', '_')
......
This diff is collapsed.
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