update client

This commit is contained in:
AleaJactaEst 2019-05-19 16:10:18 +02:00
parent 7fce47e67c
commit a0640936c2

View file

@ -127,7 +127,6 @@ class BitStream():
def pushString(self, valeur): def pushString(self, valeur):
size=len(valeur) size=len(valeur)
print(size)
#self.internalSerial(size, 32) #self.internalSerial(size, 32)
self.pushUint32(len(valeur)) self.pushUint32(len(valeur))
for x in valeur: for x in valeur:
@ -235,9 +234,14 @@ class BitStream():
# return str(self._pos) + ':' + str(self._tampon) # return str(self._pos) + ':' + str(self._tampon)
return str(self._pos) + ':' + '.'.join([ format(x, "02x") for x in self._tampon]) return str(self._pos) + ':' + '.'.join([ format(x, "02x") for x in self._tampon])
def bytes(self): def toBytes(self):
return bytes( self._tampon ) return bytes( self._tampon )
def fromBytes(self, data):
self._read = 0
self._tampon = [int(x) for x in data]
self._pos = len(self._tampon) * 8
def Test(): def Test():
a = BitStream() a = BitStream()
a.pushBool(True) a.pushBool(True)
@ -256,7 +260,8 @@ def Test():
a.pushSint64(-1) a.pushSint64(-1)
a.pushChar('a') a.pushChar('a')
a.pushString("Test A Faire") a.pushString("Test A Faire")
print("A6:", a) print('raw:', a)
print("-" * 80)
print(a.readBool()) print(a.readBool())
print(a.readBool()) print(a.readBool())
print(a.readBool()) print(a.readBool())
@ -273,7 +278,27 @@ def Test():
print(a.readSint64()) print(a.readSint64())
print(a.readChar()) print(a.readChar())
print(a.readString()) print(a.readString())
print(a.bytes()) print(a.toBytes())
print("-" * 80)
b = BitStream()
b.fromBytes(a.toBytes())
print(b.readBool())
print(b.readBool())
print(b.readBool())
print(b.readBool())
print(b.readUint32())
print(b.readSint32())
print(b.readUint16())
print(b.readSint16())
print(b.readUint8())
print(b.readSint8())
print(b.readFloat())
print(b.readDouble())
print(b.readUint64())
print(b.readSint64())
print(b.readChar())
print(b.readString())
print(b.toBytes())
class TConnectionState(IntEnum): class TConnectionState(IntEnum):
@ -927,7 +952,6 @@ class CPersistentDataRecord:
tmp = int.from_bytes(buffer[offset:offset+4], byteorder='little', signed=False) tmp = int.from_bytes(buffer[offset:offset+4], byteorder='little', signed=False)
self.ArgTable.append(tmp) self.ArgTable.append(tmp)
offset += 4 offset += 4
print(self.ArgTable)
# READ the string table data # READ the string table data
if self.stringsSize != 0: if self.stringsSize != 0:
@ -1372,7 +1396,7 @@ class ClientNetworkConnection:
msg.pushUint32(self.UserId) msg.pushUint32(self.UserId)
msg.pushString(self.LanguageCode) msg.pushString(self.LanguageCode)
self._sock.sendto(msg.bytes(), self.frontend) self._sock.sendto(msg.toBytes(), self.frontend)
self._CurrentSendNumber += 1 self._CurrentSendNumber += 1
self._ConnectionState = TConnectionState.Login self._ConnectionState = TConnectionState.Login
@ -1386,15 +1410,34 @@ class ClientNetworkConnection:
self.buildSystemHeader(msg) self.buildSystemHeader(msg)
msg.pushUint8(8) # SYSTEM_LOGIN_CODE msg.pushUint8(8) # SYSTEM_LOGIN_CODE
msg.pushSint32(self._QuitId) # _QuitId msg.pushSint32(self._QuitId) # _QuitId
self._sock.sendto(msg.bytes(), self.frontend) self._sock.sendto(msg.toBytes(), self.frontend)
self._ConnectionState = TConnectionState.Quit self._ConnectionState = TConnectionState.Quit
def readDelta(self, msg):
propertyCount = msg.readUint16()
self.log.debug("propertyCount:%d" % propertyCount)
for _ in range(0, propertyCount):
pass
def impulseCallBack(self, data):
# code/ryzom/common/src/game_share/generic_xml_msg_mngr.h : CNode *select(NLMISC::CBitMemStream &strm)
msg = BitStream()
msg.fromBytes(data)
serverTick = msg.readUint32()
self.log.debug("serverTick:%d" % serverTick)
#self.readDelta(msg)
def EmulateFirst(self): def EmulateFirst(self):
self.log.info("Client Login")
self.sendSystemLogin() self.sendSystemLogin()
for _ in range(1, 20): # while True: self.log.info("Receive Message")
for _ in range(0, 20): # while True:
data, addr = self._sock.recvfrom(1024) # buffer size is 1024 bytes data, addr = self._sock.recvfrom(1024) # buffer size is 1024 bytes
print( "received message:", data) self.log.debug("received message: %s" % data)
self.impulseCallBack(data)
self.log.info("Client Logout")
self.sendSystemQuit() self.sendSystemQuit()
@ -1407,7 +1450,8 @@ class ClientKhanat:
LanguageCode="fr", LanguageCode="fr",
url="/login/r2_login.php", url="/login/r2_login.php",
suffix = None, suffix = None,
download_patch = False): download_patch = False,
show_patch_detail=False):
self.log = logging.getLogger('myLogger') self.log = logging.getLogger('myLogger')
if suffix is None: if suffix is None:
@ -1415,6 +1459,7 @@ class ClientKhanat:
self.log.debug("suffix : %s" % suffix) self.log.debug("suffix : %s" % suffix)
self.download_patch = download_patch self.download_patch = download_patch
self.show_patch_detail = show_patch_detail
self.khanaturl = khanaturl self.khanaturl = khanaturl
self.login = login + suffix self.login = login + suffix
self.password = password self.password = password
@ -1615,6 +1660,7 @@ class ClientKhanat:
self.khanat_idx.readFromBinFile(self.ryzomidx) self.khanat_idx.readFromBinFile(self.ryzomidx)
self.khanat_idx.CProductDescriptionForClient_apply() self.khanat_idx.CProductDescriptionForClient_apply()
# Show detail patch # Show detail patch
if self.show_patch_detail:
self.khanat_idx.decrypt_token() self.khanat_idx.decrypt_token()
self.khanat_idx.show() self.khanat_idx.show()
# Todo analyze patch and download if necessary or update if incremental - see category # Todo analyze patch and download if necessary or update if incremental - see category
@ -1634,6 +1680,7 @@ def main():
parser.add_argument("--suffix", help="define suffix") parser.add_argument("--suffix", help="define suffix")
parser.add_argument("-d", "--debug", help="show debug message", action='store_true') parser.add_argument("-d", "--debug", help="show debug message", action='store_true')
parser.add_argument("-p", "--download-patch", help="show debug message", action='store_true') parser.add_argument("-p", "--download-patch", help="show debug message", action='store_true')
parser.add_argument("-s", "--show-patch-detail", help="show debug message", action='store_true')
args = parser.parse_args() args = parser.parse_args()
if args.debug: if args.debug:
@ -1642,10 +1689,10 @@ def main():
level = logging.getLevelName('INFO') level = logging.getLevelName('INFO')
log.setLevel(level) log.setLevel(level)
client = ClientKhanat(args.khanaturl, suffix=args.suffix, download_patch=args.download_patch) client = ClientKhanat(args.khanaturl, suffix=args.suffix, download_patch=args.download_patch, show_patch_detail=args.show_patch_detail)
client.Emulate() client.Emulate()
log.info("End") log.info("End")
if __name__ == "__main__": if __name__ == "__main__":
main()
#Test() #Test()
main()