correct decoder user data

This commit is contained in:
AleaJactaEst 2019-06-12 23:14:56 +02:00
parent 94498be11c
commit 042b01b7f5

478
client.py
View file

@ -221,8 +221,8 @@ class BitStream():
v = self.readSerial(32, name=name, decode=decode, typeName=typeName)
return v
def readSint32(self, name):
v = self.readSerial(32, name=name, typeName='Sint32')
def readSint32(self, name, decode=True):
v = self.readSerial(32, name=name, decode=decode, typeName='Sint32')
return c_int32(v).value
def readUint16(self, name):
@ -277,8 +277,8 @@ class BitStream():
def readString(self, name):
tmp = ''
_size = self.readUint32(name + ':size', decode=True)
v1 = self._read
_size = self.readUint32('', decode=False)
while _size > 0:
x = self.readChar('', decode=False)
tmp += x
@ -286,7 +286,8 @@ class BitStream():
v2 = self._read
if v2 > self._pos:
raise ValueError
self._groupRead.append((v1, v2, name, 'String'))
if v1 < v2:
self._groupRead.append((v1, v2, name + ':string', 'String'))
return tmp
def readArrayUint8(self, size, name):
@ -307,6 +308,16 @@ class BitStream():
self._groupRead.append((v1, v2, name, 'StreamUint8'))
return ret
def readCont(self, name):
ret = BitStream()
size = self.readSint32(name = name + ':len', decode=True)
v1 = self._read
for i in range(0, size):
ret.pushBool(self.readSerial(1,name = '', decode=False))
v2 = self._read
self._groupRead.append((v1, v2, name + ':data', 'readCont'))
return size, ret
# ------------------------------------
def __str__(self):
return ''.join([ chr(x) for x in self._tampon])
@ -569,6 +580,8 @@ class CBitSet:
self.data[i] = 0
def set(self, bitNumber, value):
log = logging.getLogger('myLogger')
log.debug("CBitSet::set %d %s" % (bitNumber, str(value)))
mask = bitNumber & (NL_BITLEN-1)
mask = 1 << mask
if value:
@ -596,6 +609,10 @@ class CBitSet:
# msgout.pushUint8(v)
# else:
# msgout.pushUint8(v)
log = logging.getLogger('myLogger')
log.debug("CBitSet::writeSerial NumBits:%d len:%d" % (self.NumBits, len(self.data)))
msgout.pushUint8(0) # currentVersion = 0
msgout.pushUint32(self.NumBits)
msgout.pushUint32(len(self.data)) # il est lié à 'self.NumBits' dommage que l'on envoie celui-la
@ -1127,7 +1144,7 @@ class CGenericMultiPartTemp():
self.Temp = []
self.BlockReceived = []
def set(self, Number, Part, NbBlock, PartCont):
def set(self, Number, Part, NbBlock, PartCont, decodeImpulse):
'''
khanat-opennel-code/code/ryzom/client/src/network_connection.cpp # void CNetworkConnection::CGenericMultiPartTemp::set (CActionGenericMultiPart *agmp, CNetworkConnection *parent)
'''
@ -1157,8 +1174,392 @@ class CGenericMultiPartTemp():
self.NbBlock == 0xFFFFFFFF
for data in self.Temp:
bms.pushBitStream(data)
self.log.debug("data : %s" % bms.showAllData())
self.log.debug("*" * 80)
self.log.debug("CGenericMultiPartTemp : data : %s" % bms.showAllData())
self.log.debug("TODO")
decodeImpulse.execute(bms)
else:
self.log.debug("CGenericMultiPartTemp : Wait other block")
class ECharacterTitle(IntEnum):
'''
khanat-opennel-code/code/ryzom/common/src/game_share/character_title.h # enum ECharacterTitle
'''
Refugee = 0
Homin = 1 #
Novice_Artisan = 2 #
Novice_Warrior = 3 #
Novice_Harvester = 4 #
Novice_Magician = 5 #
Artisan_Apprentice = 6 #
Magician_Apprentice = 7 #
Defensive_Magician = 8 #
Offensive_Magician = 9 #
Mentalist = 10 #
Summoner = 11 #
Master_Of_Illusion = 12 #
Mind_Lord = 13 #
Healer = 14 #
Priest = 15 #
Master_Of_Life = 16 #
Celestial_Guardian = 17 #
Disturber = 18 #
Affliction_Bringer = 19 #
Master_Of_Torment = 20 #
Avatar_Of_Sorrow = 21 #
Destroyer = 22 #
Archmage = 23 #
Master_Of_Pain = 24 #
Avatar_Of_Destruction = 25 #
Elementalist = 26 #
Alchemist = 27 #
Biomancer = 28 #
Master_Of_Energies = 29 #
Chosen_Of_Atys = 30 #
Warrior_Apprentice = 31 #
Melee_Warrior = 32 #
Range_Fighter = 33 #
Light_Armsman = 34 #
Heavy_Armsman = 35 #
Close_Fighter = 36 #
Gunman = 37 #
Heavy_Gunman = 38 #
Advanced_Gunman = 39 #
Advanced_Heavy_Gunman = 40 #
Bludgeoner = 41 #
Skewerer = 42 #
Slasher = 43 #
Smasher = 44 #
Impaler = 45 #
Cleaver = 46 #
Advanced_Close_Fighter = 47 #
Maceman = 48 #
Brute = 49 #
Spearman = 50 #
Axeman = 51 #
Swordsman = 52 #
Heavy_Maceman = 53 #
Pikeman = 54 #
Heavy_Axeman = 55 #
Heavy_Swordsman = 56 #
Knifeman = 57 #
Hand_To_Hand_Fighter = 58 #
Bowman = 59 #
Pistoleer = 60 #
Heavy_Bowman = 61 #
Artilleryman = 62 #
Rifleman = 63 #
Master_Maceman = 64 #
Master_Brute = 65 #
Master_Spearman = 66 #
Master_Axeman = 67 #
Master_Swordsman = 68 #
Master_Heavy_Maceman = 69 #
Master_Pikeman = 70 #
Master_Heavy_Axeman = 71 #
Master_Heavy_Swordsman = 72 #
Master_Knifeman = 73 #
Master_Hand_To_Hand_Fighter = 74 #
Master_Bowman = 75 #
Master_Pistoleer = 76 #
Master_Heavy_Bowman = 77 #
Master_Artilleryman = 78 #
Master_Rifleman = 79 #
Armorer_Apprentice = 80 #
Jeweler_Apprentice = 81 #
Melee_Weapon_Smith_Apprentice = 82 #
Range_Weapon_Smith_Apprentice = 83 #
Heavy_Armorer = 84 #
Light_Armorer = 85 #
Medium_Armorer = 86 #
Shield_Smith = 87 #
Jeweler = 88 #
Melee_Weapon_Smith = 89 #
Melee_Heavy_Weapon_Smith = 90 #
Melee_Light_Weapon_Smith = 91 #
Range_Weapon_Smith = 92 #
Range_Heavy_Weapon_Smith = 93 #
Advanced_Heavy_Armorer = 94 #
Advanced_Light_Armorer = 95 #
Advanced_Medium_Armorer = 96 #
Advanced_Shield_Smith = 97 #
Advanced_Jeweler = 98 #
Advanced_Melee_Weapon_Smith = 99 #
Advanced_Melee_Heavy_Weapon_Smith = 100 #
Advanced_Melee_Light_Weapon_Smith = 101 #
Advanced_Range_Weapon_Smith = 102 #
Advanced_Range_Heavy_Weapon_Smith = 103 #
Expert_Heavy_Armorer = 104 #
Expert_Light_Armorer = 105 #
Expert_Medium_Armorer = 106 #
Expert_Shield_Smith = 107 #
Expert_Jeweler = 108 #
Expert_Melee_Weapon_Smith = 109 #
Expert_Melee_Heavy_Weapon_Smith = 110 #
Expert_Melee_Light_Weapon_Smith = 111 #
Expert_Range_Weapon_Smith = 112 #
Expert_Range_Heavy_Weapon_Smith = 113 #
Heavy_Armorer_Master = 114 #
Light_Armorer_Master = 115 #
Medium_Armorer_Master = 116 #
Shield_Smith_Master = 117 #
Jeweler_Master = 118 #
Melee_Weapon_Smith_Master = 119 #
Melee_Heavy_Weapon_Smith_Master = 120 #
Melee_Light_Weapon_Smith_Master = 121 #
Range_Weapon_Smith_Master = 122 #
Range_Heavy_Weapon_Smith_Master = 123 #
Forager_Apprentice = 124 #
Forager = 125 #
Desert_Forager = 126 #
Forest_Forager = 127 #
Jungle_Forager = 128 #
Lacustre_Forager = 129 #
Prime_Roots_Forager = 130 #
Advanced_Desert_Forager = 131 #
Advanced_Forest_Forager = 132 #
Advanced_Jungle_Forager = 133 #
Advanced_Lacustre_Forager = 134 #
Advanced_Prime_Roots_Forager = 135 #
Expert_Desert_Forager = 136 #
Expert_Forest_Forager = 137 #
Expert_Jungle_Forager = 138 #
Expert_Lacustre_Forager = 139 #
Expert_Prime_Roots_Forager = 140 #
Master_Desert_Forager = 141 #
Master_Forest_Forager = 142 #
Master_Jungle_Forager = 143 #
Master_Lacustre_Forager = 144 #
Master_Prime_Roots_Forager = 145 #
Kami_Ally = 146 #
Karavan_Ally = 147 #
Title00000 = 148 #
Title00001 = 149 # // Journeyer
Title00002 = 150 # // Novice Kitin Hunter
Title00003 = 151 # // Kitin Hunter
Title00004 = 152 # // Master Kitin Hunter
Title00005 = 153 # // Kitin Eradicator
Title00006 = 154 # // Kitin Mass Murderer
Title00007 = 155 # // Matis Guardian
Title00008 = 156 # // Fyros Guardian
Title00009 = 157 # // Tryker Guardian
Title00010 = 158 # // Zorai Guardian
Title00011 = 159 # // Atys Guardian
Title00012 = 160 #
Title00013 = 161 #
Title00014 = 162 # // The fortunate
Title00015 = 163 # // Jinxed
Title00016 = 164 #
Title00017 = 165 #
Title00018 = 166 #
Title00019 = 167 #
Title00020 = 168 # // Fyros Patriot
Title00021 = 169 # // Matis Vassal
Title00022 = 170 # // Tryker Citizen
Title00023 = 171 # // Zorai Initiate
Title00024 = 172 # // Kami Disciple
Title00025 = 173 # // Karavan Follower
Title00026 = 174 # // Fyros Akenak
Title00027 = 175 # // Matis Noble
Title00028 = 176 # // Tryker Taliar
Title00029 = 177 # // Zorai Awakened
Title00030 = 178 # // Marauder
Title00031 = 179 # // Fyros Ambassador
Title00032 = 180 # // Matis Ambassador
Title00033 = 181 # // Tryker Ambassador
Title00034 = 182 # // Zorai Ambassador
Title00035 = 183 #
Title00036 = 184 #
Title00037 = 185 #
Title00038 = 186 #
Title00039 = 187 #
Title00040 = 188 #
Title00041 = 189 #
Title00042 = 190 #
Title00043 = 191 #
Title00044 = 192 #
Title00045 = 193 #
Title00046 = 194 #
Title00047 = 195 # // Machinegunner
Title00048 = 196 # // Assault Machinegunner
Title00049 = 197 #
Title00050 = 198 # // Apprentice Butcher
Title00051 = 199 # // Butcher
Title00052 = 200 # // Apprentice Florist
Title00053 = 201 # // Florist
Title00054 = 202 # // Apprentice Water-Carrier
Title00055 = 203 # // Water-Carrier
Title00056 = 204 # // Apprentice Magnetic
Title00057 = 205 # // Magnetic Cartographe
Title00058 = 206 # // Apprentice Toolmaker
Title00059 = 207 # // Toolmaker
Title00060 = 208 # // Apprentice Rescuer
Title00061 = 209 # // Rescuer
Title00062 = 210 # // Apprentice Larvester
Title00063 = 211 # // Larvester
Title00064 = 212 # // Apprentice Scrollmaker
Title00065 = 213 # // Scrollmaker
Title00066 = 214 #
Title00067 = 215 #
Title00068 = 216 #
Title00069 = 217 #
Title00070 = 218 #
Title00071 = 219 #
Title00072 = 220 #
Title00073 = 221 #
Title00074 = 222 #
Title00075 = 223 #
Title00076 = 224 #
Title00077 = 225 #
Title00078 = 226 #
Title00079 = 227 # // Wayfarer
WIND = Title00079 # // Title for player come from old Windermmer community
FBT = 228 #
BeginGmTitle = 229 #
# SGM = BeginGmTitle #
GM = 230 #
VG = 231 #
SG = 232 #
G = 233 #
CM = 234 #
EM = 235 #
EG = 236 #
OBSERVER = 237 #
# EndGmTitle = OBSERVER,
NB_CHARACTER_TITLE = 238
class SPropVisualA():
def __init__(self):
'''
khanat-opennel-code/code/ryzom/common/src/game_share/player_visual_properties.h # struct SPropVisualA
'''
self.Sex = False #: 1; // max: 2 current: 2
self.JacketModel = 0 #: 8; // max: 256 current: 93
self.JacketColor = 0 #: 3; // max: 8 current: 8
self.TrouserModel = 0 #: 8; // max: 256 current: 104
self.TrouserColor = 0 #: 3; // max: 8 current: 8
self.WeaponRightHand = 0 #: 10; // max: 1024 current: 457
self.WeaponLeftHand = 0 #: 8; // max: 256 current: 63
self.ArmModel = 0 #: 8; // max: 256 current: 94
self.ArmColor = 0 #: 3; // max: 8 current: 8
self.HatModel = 0 #: 9; // max: 512 current: 192
self.HatColor = 0 #: 3; // max: 8 current: 8
def read(self, msgin):
self.Sex = msgin.readBool('Sex')
self.JacketModel = msgin.readUint8('JacketModel')
self.JacketColor = msgin.readSerial(3, 'JacketModel')
self.TrouserModel = msgin.readSerial(8, 'TrouserModel')
self.TrouserColor = msgin.readSerial(3, 'TrouserColor')
self.WeaponRightHand = msgin.readSerial(10, 'WeaponRightHand')
self.WeaponLeftHand = msgin.readSerial(8, 'WeaponLeftHand')
self.ArmModel = msgin.readSerial(8, 'ArmModel')
self.ArmColor = msgin.readSerial(3, 'ArmColor')
self.HatModel = msgin.readSerial(9, 'HatModel')
self.HatColor = msgin.readSerial(3, 'HatColor')
class SPropVisualB():
def __init__(self):
self.Name = "" #: 16;
self.HandsModel = 0 #: 9; // max: 512 current: 90
self.HandsColor = 0 #: 3; // max: 8 current: 8
self.FeetModel = 0 #: 9; // max: 512 current: 94
self.FeetColor = 0 #: 3; // max: 8 current: 8
self.RTrail = 0 #: 4;
self.LTrail = 0 #: 3;
self.NotUsed = 0 # 17 : # not used -> just to complete 64 bit
def read(self, msgin):
self.Name = msgin.readSerial(16, 'Name')
self.HandsModel = msgin.readSerial(9, 'HandsModel')
self.HandsColor = msgin.readSerial(3, 'HandsColor')
self.FeetModel = msgin.readSerial(9, 'FeetModel')
self.FeetColor = msgin.readSerial(3, 'FeetColor')
self.RTrail = msgin.readSerial(4, 'RTrail')
self.LTrail = msgin.readSerial(3, 'LTrail')
self.NotUsed = msgin.readSerial(17, 'NotUsed')
class SPropVisualC():
def __init__(self):
self.MorphTarget1 = 0 # : 3; // max: 8 current: 8
self.MorphTarget2 = 0 # : 3; // max: 8 current: 8
self.MorphTarget3 = 0 # : 3; // max: 8 current: 8
self.MorphTarget4 = 0 # : 3; // max: 8 current: 8
self.MorphTarget5 = 0 # : 3; // max: 8 current: 8
self.MorphTarget6 = 0 # : 3; // max: 8 current: 8
self.MorphTarget7 = 0 # : 3; // max: 8 current: 8
self.MorphTarget8 = 0 # : 3; // max: 8 current: 8
self.EyesColor = 0 # : 3; // max: 8 current: 8
self.Tattoo = 0 # : 7; // max: 128 current: 64
self.CharacterHeight = 0 # : 4; // max: 16 current: 16
self.TorsoWidth = 0 # : 4; // max: 16 current: 16
self.ArmsWidth = 0 # : 4; // max: 16 current: 16
self.LegsWidth = 0 # : 4; // max: 16 current: 16
self.BreastSize = 0 # : 4; // max: 16 current: 16
self.NotUsed = 0 # 10 : # not used -> just to complete 64 bit
def read(self, msgin):
self.MorphTarget1 = msgin.readSerial(3, 'MorphTarget1')
self.MorphTarget2 = msgin.readSerial(3, 'MorphTarget2')
self.MorphTarget3 = msgin.readSerial(3, 'MorphTarget3')
self.MorphTarget4 = msgin.readSerial(3, 'MorphTarget4')
self.MorphTarget5 = msgin.readSerial(3, 'MorphTarget5')
self.MorphTarget6 = msgin.readSerial(3, 'MorphTarget6')
self.MorphTarget7 = msgin.readSerial(3, 'MorphTarget7')
self.MorphTarget8 = msgin.readSerial(3, 'MorphTarget8')
self.EyesColor = msgin.readSerial(3, 'EyesColor')
self.Tattoo = msgin.readSerial(7, 'Tattoo')
self.CharacterHeight = msgin.readSerial(4, 'CharacterHeight')
self.TorsoWidth = msgin.readSerial(4, 'TorsoWidth')
self.ArmsWidth = msgin.readSerial(4, 'ArmsWidth')
self.LegsWidth = msgin.readSerial(4, 'LegsWidth')
self.BreastSize = msgin.readSerial(4, 'BreastSize')
self.NotUsed = msgin.readSerial(10, 'NotUsed')
class CCharacterSummary():
def __init__(self):
self.version = -1
self.Mainland = 0 # CSessionId
self.Name = ""
self.People = 142
self.Location = 0
self.sPropVisualA = SPropVisualA()
self.sPropVisualB = SPropVisualB()
self.sPropVisualC = SPropVisualC()
self.sheetId = 0
self.Title = ECharacterTitle.NB_CHARACTER_TITLE
self.CharacterSlot = 255
self.InRingSession = False
self.HasEditSession = False
self.InNewbieland = False
def read(self, msgin):
'''
khanat-opennel-code/code/ryzom/common/src/game_share/character_summary.cpp # void CCharacterSummary::serial(NLMISC::IStream &f)
'''
self.version = msgin.readUint8('version')
self.Mainland = msgin.readUint32('Mainland')
self.Name = msgin.readString('Name')
self.People = msgin.readSint32('People')
self.Location = msgin.readUint32('Location')
self.sPropVisualA.read(msgin)
self.sPropVisualB.read(msgin)
self.sPropVisualC.read(msgin)
self.sheetId = msgin.readUint32('SheetId')
self.Title = msgin.readSint32('Title') # see ECharacterTitle
self.CharacterSlot = msgin.readUint8('CharacterSlot')
self.InRingSession = msgin.readBool('InRingSession')
self.HasEditSession = msgin.readBool('HasEditSession')
self.InNewbieland = msgin.readBool('InNewbieland')
# f.serial (CharacterSlot);
# f.serial (InRingSession);
# f.serial (HasEditSession);
# if (serialNB)
# f.serial (InNewbieland);
class World():
@ -1166,12 +1567,15 @@ class World():
self.log = log
self.GenericMultiPartTemp = {}
self.timestamp = 0
self.ServerPeopleActive = 255
self.ServerCareerActive = 255
self.CharacterSummaries = []
def addGenericMultiPartTemp(self, id):
self.GenericMultiPartTemp.setdefault(id, CGenericMultiPartTemp(self.log))
def setGenericMultiPartTemp(self, Number, Part, NbBlock, PartCont):
self.GenericMultiPartTemp[Number].set(Number, Part, NbBlock, PartCont)
def setGenericMultiPartTemp(self, Number, Part, NbBlock, PartCont, decodeImpulse):
self.GenericMultiPartTemp[Number].set(Number, Part, NbBlock, PartCont, decodeImpulse)
class CPersistentDataRecord:
def __init__(self, log):
@ -1875,7 +2279,26 @@ class DecodeImpulse():
def impulseNoUserChar(self, msgin):
self.log.debug("TODO")
def impulseUserChars(self, msgin):
'''
khanat-opennel-code/code/ryzom/client/src/net_manager.cpp # void impulseUserChars(NLMISC::CBitMemStream &impulse)
'''
self.world.ServerPeopleActive = msgin.readUint8('ServerPeopleActive')
self.world.ServerCareerActive = msgin.readUint8('ServerCareerActive')
self.world.CharacterSummaries = []
size = msgin.readUint32('CharacterSummaries:len')
for _ in range(0, size):
tmp = CCharacterSummary()
tmp.read(msgin)
self.world.CharacterSummaries.append(tmp)
#_, CharacterSummaries = msgin.readCont('CharacterSummaries')
_, shardNames = msgin.readCont('shardNames')
# readPrivileges(impulse);
UserPrivileges = msgin.readString('UserPrivileges')
FreeTrial = msgin.readBool('FreeTrial')
_, Mainlands = msgin.readCont('Mainlands')
self.log.debug("Mesage UserChars: %s" % msgin.showAllData())
self.log.debug("TODO")
def impulseUserChar(self, msgin):
self.log.debug("TODO")
def impulseFarTP(self, msgin):
@ -2451,6 +2874,8 @@ class CActionGenericMultiPart(CAction):
size = message.readUint32('size')
self.PartCont = message.readBitStreamUint8(size, 'PartCont')
self.log = logging.getLogger('myLogger')
self.log.debug("unpack - Number:%d Part:%d NbBlock:%d" % (self.Number, self.Part, self.NbBlock))
def pack(self, msgout):
@ -2472,7 +2897,7 @@ class CActionGenericMultiPart(CAction):
self.log = logging.getLogger('myLogger')
self.log.debug("Number:%d Part:%d NbBlock:%d" % (self.Number, self.Part, self.NbBlock))
self.world.addGenericMultiPartTemp(self.Number)
self.world.setGenericMultiPartTemp(self.Number, self.Part, self.NbBlock, self.PartCont)
self.world.setGenericMultiPartTemp(self.Number, self.Part, self.NbBlock, self.PartCont, decodeImpulse)
def __str__(self):
return "CActionGenericMultiPart" + super().__str__() + "[" + str(self.Number) + ',' + str(self.Part) + ',' + str(self.NbBlock) + ',' + self.PartCont.showAllData() + ']'
@ -2630,7 +3055,7 @@ class CImpulseDecoder:
keep = True
checkOnce = False
num = 0
self.log.debug("channel:%d lAck:%s" %(channel, ':'.join([str(x) for x in lAck])))
self.log.debug("level:%d channel:%d lAck:%s" %(level, channel, ':'.join([str(x) for x in lAck])))
# lastAck = lAck[channel]
while True:
next = msgin.readBool('next:' + str(level) + ':' + str(channel))
@ -2639,7 +3064,7 @@ class CImpulseDecoder:
if not checkOnce:
checkOnce = True
keep = receivedAck >= lAck[channel]
self.log.debug("keep:%s" % str(keep))
self.log.debug("keep:%s [%d => %d]" % (str(keep), receivedAck, lAck[channel]))
if keep:
lAck[channel] = nextSentPacket
self.log.debug("lAck:%s" % ':'.join([str(x) for x in lAck]))
@ -2788,7 +3213,7 @@ class ClientNetworkConnection:
self._ConnectionState = TConnectionState.Quit
def sendSystemAckSync(self): # code/ryzom/client/src/network_connection.cpp # void CNetworkConnection::sendSystemAckSync()
self.log.debug("sendSystemAckSync")
self.log.debug("sendSystemAckSync _LastReceivedNumber:%d _LastAckInLongAck:%d _LatestSync:%d" % (self._LastReceivedNumber, self._LastAckInLongAck, self._LatestSync))
msgout = BitStream()
self.buildSystemHeader(msgout)
msgout.pushUint8(CLFECOMMON.SYSTEM_ACK_SYNC_CODE)
@ -2796,9 +3221,25 @@ class ClientNetworkConnection:
msgout.pushSint32(self._LastAckInLongAck)
self._LongAckBitField.writeSerial(msgout) # Signale le nombre de packet perdu
msgout.pushSint32(self._LatestSync)
self._sock.sendto(msgout.toBytes(), self.frontend)
self._LatestSyncTime = self._UpdateTime
# Only to decode message send
msgout.readSint32('_CurrentSendNumber')
msgout.readBool('systemMode')
msgout.readUint8('SYSTEM_ACK_SYNC_CODE')
msgout.readSint32('_LastReceivedNumber')
msgout.readSint32('_LastAckInLongAck')
msgout.readUint8('currentVersion') # currentVersion = 0
msgout.readUint32('NumBits')
size = msgout.readUint32('size')
for _ in range(0, size):
msgout.readUint32('data')
msgout.readSint32('_LatestSync')
self.log.debug("sendSystemAckSync : %s" % msgout.showAllData())
def sendSystemAckProbe(self):
self.log.debug("sendSystemAckProbe")
msgout = BitStream()
@ -2863,6 +3304,9 @@ class ClientNetworkConnection:
return data, addr
def decodeHeader(self, msg):
'''
khanat-opennel-code/code/ryzom/client/src/network_connection.cpp # bool CNetworkConnection::decodeHeader(CBitMemStream &msgin, bool checkMessageNumber)
'''
self._TotalMessages += 1
self._LastReceivedTime = self._UpdateTime
self._CurrentReceivedNumber = msg.readSint32('CurrentReceivedNumber')
@ -2894,16 +3338,18 @@ class ClientNetworkConnection:
else:
ackBit = 0
if self._CurrentReceivedNumber - self._LastReceivedNumber < 32:
self._AckBitMask <<= self._CurrentReceivedNumber - self._LastReceivedNumber;
self._AckBitMask <<= self._CurrentReceivedNumber - self._LastReceivedNumber
self._AckBitMask |= self._LastAckBit << (self._CurrentReceivedNumber - self._LastReceivedNumber - 1)
elif (self_CurrentReceivedNumber - self_LastReceivedNumber) == 32 and self._LastAckBit != 0:
self._AckBitMask = 0x80000000
else:
self._AckBitMask = 0x00000000
self._LastAckBit = ackBit;
for i in range(self._LastReceivedNumber+1, self._CurrentReceivedNumber+1):
for i in range(self._LastReceivedNumber+1, self._CurrentReceivedNumber):
self._LongAckBitField.clearBit(i & 511) # (512 - 1) mask 9bit
self._LongAckBitField.set(self._CurrentReceivedNumber & 511, ackBool) # (512 - 1) mask 9bit
self.log.debug("_LastAckInLongAck:%d _CurrentReceivedNumber:%d" % (self._LastAckInLongAck, self._CurrentReceivedNumber))
if self._LastAckInLongAck <= (self._CurrentReceivedNumber-512):
self._LastAckInLongAck = self._CurrentReceivedNumber-511; # (512 - 1) mask 9bit
@ -3100,8 +3546,10 @@ class ClientNetworkConnection:
self._ConnectionState = TConnectionState.Connected
self.log.warning("CNET: synchronize->connected")
# _Changes.push_back(CChange(0, ConnectionReady));
self._ImpulseDecoder.reset();
self.receiveNormalMessage(msgin);
return True
self.log.debug("sendSystemAckSync ? (%d , %d , %d)" %(self._UpdateTime, self._LatestSyncTime, self._UpdateTime - self._LatestSyncTime))
if self._UpdateTime - self._LatestSyncTime > 300:
self.sendSystemAckSync();
return False