From 0db89eaeb15634460eb8a15bdcb44e3cdb8a752d Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 22 Nov 2016 12:13:29 +0000 Subject: [PATCH] Trying to fix serialization of flags... --- src/danog/MadelineProto/MTProto.php | 2 +- src/danog/MadelineProto/TL/TL.php | 32 ++++++++++++++------ src/danog/MadelineProto/TL/TLConstructor.php | 2 +- src/danog/MadelineProto/TL/TLMethod.php | 2 +- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 2d538492..0a92a213 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -177,7 +177,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB ), ] ); - \danog\MadelineProto\Logger::log('Current dc is '.$nearest_dc['this_dc'].', nearest dc is '.$nearest_dc['nearest_dc'].' in '.$nearest_dc['country'].'.'); + \danog\MadelineProto\Logger::log("We're in ".$nearest_dc['country'].', current dc is '.$nearest_dc['this_dc'].', nearest dc is '.$nearest_dc['nearest_dc'].'.'); if ($nearest_dc['nearest_dc'] != $nearest_dc['this_dc'] && $allow_switch) { $this->switch_dc($nearest_dc['nearest_dc']); diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index 210fd468..c1704479 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -78,17 +78,30 @@ class TL extends \danog\MadelineProto\Tools } $serialized = \danog\PHP\Struct::pack('serialize_param($current_argument['type'], $current_argument['subtype'], $arguments[$current_argument['name']]); } @@ -245,6 +258,7 @@ class TL extends \danog\MadelineProto\Tools $x = $this->deserialize($bytes_io, $tl_elem['predicate'], $subtype); } else { $x = ['_' => $tl_elem['predicate']]; + $done_opt = false; foreach ($tl_elem['params'] as $arg) { $x[$arg['name']] = $this->deserialize($bytes_io, $arg['type'], $arg['subtype']); } diff --git a/src/danog/MadelineProto/TL/TLConstructor.php b/src/danog/MadelineProto/TL/TLConstructor.php index 69591012..7ce61b5d 100644 --- a/src/danog/MadelineProto/TL/TLConstructor.php +++ b/src/danog/MadelineProto/TL/TLConstructor.php @@ -31,7 +31,7 @@ class TLConstructor $param['subtype'] = null; if (preg_match('/^flags\.\d\?/', $param['type'])) { $param['opt'] = true; - $param['flag'] = preg_replace(['/^flags\./', '/\?.*/'], '', $param['type']); + $param['pow'] = preg_replace(['/^flags\./', '/\?.*/'], '', $param['type']); $param['type'] = preg_replace('/^flags\.\d\?/', '', $param['type']); } if (preg_match('/vector<.*>/i', $param['type'])) { diff --git a/src/danog/MadelineProto/TL/TLMethod.php b/src/danog/MadelineProto/TL/TLMethod.php index 8a05c71b..73610f3e 100644 --- a/src/danog/MadelineProto/TL/TLMethod.php +++ b/src/danog/MadelineProto/TL/TLMethod.php @@ -37,7 +37,7 @@ class TLMethod $param['subtype'] = null; if (preg_match('/^flags\.\d\?/', $param['type'])) { $param['opt'] = true; - $param['flag'] = preg_replace(['/^flags\./', '/\?.*/'], '', $param['type']); + $param['pow'] = preg_replace(['/^flags\./', '/\?.*/'], '', $param['type']); $param['type'] = preg_replace('/^flags\.\d\?/', '', $param['type']); } if (preg_match('/vector<.*>/i', $param['type'])) {