Exemple #1
0
 public function Decode(CodeEngine &$buf, &$BecomeVIPTime = null)
 {
     $outlength = 0;
     $len = $buf->DecodeInt16();
     $outlength += 2;
     $this->setGameVipExpireTime($buf->DecodeInt32());
     $outlength += 4;
     $this->setGameVIPScore($buf->DecodeInt32());
     $outlength += 4;
     $this->setGameVIPLevel($buf->DecodeInt32());
     $outlength += 4;
     $this->setNextUpdateVIPLevelTime($buf->DecodeInt32());
     $outlength += 4;
     $this->setVIPTips($buf->DecodeString());
     $outlength += strlen($this->VIPTips) + 2;
     $this->setGameVIPType($buf->DecodeInt32());
     $outlength += 4;
     if (!is_null($BecomeVIPTime)) {
         $BecomeVIPTime = $buf->DecodeInt32();
         $outlength += 4;
     }
     $vipsize = $len - $outlength;
     if ($vipsize > 0) {
         $buf->DecodeMemory($vipsize);
     }
     return $len;
 }
Exemple #2
0
 public function Decode(CodeEngine &$buf)
 {
     $len = $buf->DecodeInt16();
     $len -= 2;
     $this->setBitMap($buf->DecodeInt32());
     $len -= 4;
     $this->setMinPoint($buf->DecodeInt32());
     $len -= 4;
     $this->setMaxPointGap($buf->DecodeInt32());
     $len -= 4;
     $this->setMaxOfflineRate($buf->DecodeInt8());
     $len -= 1;
     $this->setIPBit($buf->DecodeInt8());
     $len -= 1;
     $this->setOtherSize($buf->DecodeInt8());
     $len -= 1;
     if ($this->OtherSize > max_game_other_data_count) {
         $this->OtherSize = max_game_other_data_count;
     }
     $t = array();
     for ($i = 0; $i < $this->getOtherSize(); $i++) {
         $t[] = $buf->DecodeInt32();
         $len -= 4;
     }
     $this->setOthers($t);
     if ($len < 0) {
         return 0;
     } else {
         $buf->DecodeMemory($len);
     }
     return $len;
 }
Exemple #3
0
 public function Decode(CodeEngine &$buf)
 {
     $len = $buf->DecodeInt16();
     $this->ServiceID = $buf->DecodeInt32();
     $this->TimeChg = $buf->DecodeInt32();
     $this->ExpireTime = $buf->DecodeInt32();
     return $this;
 }
Exemple #4
0
 public static function decode_EquipmentUpdate(CodeEngine &$buf)
 {
     $eu = new EquipmentUpdate();
     $eu->setEquipmentUpdateMod($buf->DecodeInt8());
     $eu->setEquipmentPosi($buf->DecodeInt32());
     $eu->setItemId($buf->DecodeInt32());
     return $eu;
 }
Exemple #5
0
 public function Decode(CodeEngine &$buf)
 {
     $length = $buf->DecodeInt16();
     $this->ExtIndex = $buf->DecodeInt16();
     $this->UpdateMode = $buf->DecodeInt8();
     $this->ExtVal = $buf->DecodeInt32();
     return $this;
 }
Exemple #6
0
 public function getPackageLength()
 {
     $this->receiveData = socket_read($this->fp, 4, PHP_BINARY_READ);
     $myCodeEngine = new CodeEngine($this->receiveData);
     $this->packageLength = $myCodeEngine->DecodeInt32();
     if ($this->debug) {
         echo '解析出整个包的大小是: ' . $this->packageLength . PHP_EOL;
     }
     return $this->packageLength;
 }
Exemple #7
0
 public static function decode_goods_info(CodeEngine &$buf)
 {
     $gi = new GoodsInfo();
     $len = $buf->DecodeInt16();
     # 首先获得整个数组有多少个byte
     $gi->setGoodsID($buf->DecodeInt32());
     $gi->setCount($buf->DecodeInt32());
     $gi->setPrice($buf->DecodeInt32());
     return $gi;
 }
Exemple #8
0
 public function Decode(CodeEngine &$buf)
 {
     $this->DataType = $buf->DecodeInt8();
     switch ($this->DataType) {
         case PlayerActionDataType::PAD_TYPE_LOGIN:
             $this->DataValue->LoginCount = $buf->DecodeInt32();
             $this->DataValue->HallServerId = $buf->DecodeInt16();
             $this->DataValue->HallPlayerId = $buf->DecodeInt32();
             break;
     }
 }
Exemple #9
0
 public function Encode(CodeEngine &$buf)
 {
     #$UnitSize = 2 + 4 + 4 + 2 + strlen($this->Message);
     //unit size 不包含自身的2个字节
     $UnitSize = 4 + 4 + 2 + strlen($this->Message);
     $buf->EncodeInt16($UnitSize)->EncodeInt32($this->LowVersion)->EncodeInt32($this->HighVersion)->EncodeInt16($this->Size);
     if ($this->Size > strlen($this->Message)) {
         $this->Size = strlen($this->Message);
     }
     $buf->EncodeMemory($this->Message, $this->Size);
     return $UnitSize;
 }
Exemple #10
0
 public function Decode(CodeEngine &$buf)
 {
     $this->DataType = $buf->DecodeInt8();
     $this->DataValue = new DataValue();
     switch ($this->DataType) {
         case PlayCommandDataType::PCD_Charming:
             $this->DataValue->Charming = $buf->DecodeInt32();
             break;
         case PlayCommandDataType::PCD_Achievement:
             $this->DataValue->Achievement = $buf->DecodeInt32();
             break;
         case PlayCommandDataType::PCD_PunishMethod:
             $this->DataValue->Punish->ValidDate = $buf->DecodeString();
             $this->DataValue->Punish->BlackLevel = $buf->DecodeInt8();
             $this->DataValue->Punish->PunishMethod = $buf->DecodeInt16();
             $this->DataValue->Punish->DescString = $buf->DecodeString();
             break;
         case PlayCommandDataType::PCD_OtherData:
             $this->DataValue->OtherData->OtherDataIndex = $buf->DecodeInt8();
             $this->DataValue->OtherData->UpdateMode = $buf->DecodeInt8();
             $this->DataValue->OtherData->OtherDataValue = $buf->DecodeInt8();
             break;
         case PlayCommandDataType::PCD_LoginCount:
             $this->DataValue->LoginCount = $buf->DecodeInt32();
             break;
         case PlayCommandDataType::PCD_LastLoginTime:
             $this->DataValue->LastLoginTime = $buf->DecodeInt32();
             break;
         case PlayCommandDataType::PCD_LastLoginIP:
             $this->DataValue->LastLoginIP = $buf->DecodeInt32();
             break;
         case PlayCommandDataType::PCD_WebQunData:
             $this->DataValue->WebQunData->DataSize = $buf->DecodeInt32();
             $this->DataValue->WebQunData->WebQunInfo = $buf->DecodeMemory($this->DataValue->WebQunData->DataSize);
             break;
         case PlayCommandDataType::PCD_VipData:
             $this->DataValue->VipData = new VipData();
             $this->DataValue->VipData = $this->DataValue->VipData->Decode($buf);
             break;
         case PlayCommandDataType::PCD_IdCard:
             $this->DataValue->IDCard = $buf->DecodeString();
             break;
         case PlayCommandDataType::PCD_Sex:
             $this->DataValue->Sex = $buf->DecodeInt8();
             break;
         case PlayCommandDataType::PCD_Birthday:
             $this->DataValue->BirThday = new Birthday();
             $this->DataValue->BirThday->Year = $buf->DecodeInt16();
             $this->DataValue->BirThday->Month = $buf->DecodeInt16();
             $this->DataValue->BirThday->Day = $buf->DecodeInt16();
             break;
         default:
             break;
     }
     return $this;
 }
Exemple #11
0
 public function Decode(CodeEngine &$buf)
 {
     # 未完善
     # 不完善的地方是ExtInt这个地方,C++默认已经使用了max_game_ext_int_count的数值
     $len = $buf->DecodeInt16();
     $len -= 2;
     for ($i = 0; $i < 128 && $len > 0; $i++) {
         $this->ExtInt[] = $buf->DecodeInt32();
         $len -= 4;
     }
     if ($len < 0) {
         return 0;
     }
     $this->ExtDataSize = $buf->DecodeInt16();
     $len -= 2;
     if ($this->ExtDataSize > 0) {
         $this->ExtData = $buf->DecodeMemory($this->ExtDataSize);
         $len -= $this->ExtDataSize;
     }
     return $len;
 }
Exemple #12
0
 public function Decode(CodeEngine &$buf)
 {
     $len = 0;
     $StatusSize = $buf->DecodeInt16();
     $len += 2;
     $this->GameID = $buf->DecodeInt16();
     $len += 2;
     $StatusSize -= 2;
     $this->ServerID = $buf->DecodeInt32();
     $len += 4;
     $StatusSize -= 4;
     $this->RoomID = $buf->DecodeInt32();
     $len += 4;
     $StatusSize -= 4;
     $this->TableID = $buf->DecodeInt32();
     $len += 4;
     $StatusSize -= 4;
     $this->SeatID = $buf->DecodeInt8();
     $len += 1;
     $StatusSize -= 1;
     $this->State = $buf->DecodeInt8();
     $len += 1;
     $StatusSize -= 1;
     $this->Path = $buf->DecodeString();
     $StatusSize -= 2;
     $len += 2;
     $len += strlen($this->Path);
     $StatusSize -= strlen($this->Path);
     if ($StatusSize < 0) {
         return 0;
     } else {
         $buf->DecodeMemory($StatusSize);
         $len += $StatusSize;
     }
     return $len;
 }
Exemple #13
0
 public function Decode(CodeEngine &$buf)
 {
     $len = 0;
     $DataSize = $buf->DecodeInt16();
     $len += 2;
     $this->Class = $buf->DecodeInt8();
     $DataSize -= 1;
     $len += 1;
     if (StateClass::HALL_SERVER_STATUE_DATA_TYPE == $this->Class) {
         $temp = new HallServerStateGM();
         $temp->State = $buf->DecodeInt32();
         $DataSize -= 4;
         $len += 4;
         $temp->ServerId = $buf->DecodeInt32();
         $DataSize -= 4;
         $len += 4;
         $this->hallState = $temp;
     } elseif (StateClass::LOGIC_SERVER_STATUE_DATA_TYPE == $this->Class) {
         $temp = new LogicServerState();
         $temp->RoomCount = $buf->DecodeInt8();
         $DataSize -= 1;
         $len += 1;
         if ($temp->RoomCount > MAX_ROOM_SESSION_COUNT) {
             $temp->RoomCount = MAX_ROOM_SESSION_COUNT;
         }
         $temp->Status = array();
         for ($i = 0; $i < $temp->RoomCount; $i++) {
             $temp1 = new UserStatus();
             $r = $temp1->Decode($buf);
             $DataSize -= $r;
             $len += $r;
             $temp->Status[] = $temp1;
         }
         $this->logicState = $temp;
     } else {
         return 0;
     }
     if ($DataSize < 0) {
         return 0;
     } else {
         $len += $DataSize;
         $buf->DecodeMemory($DataSize);
     }
     return $len;
 }
Exemple #14
0
 public function decode_item_info2(CodeEngine &$buf)
 {
     $ItemSize = $buf->DecodeInt16();
     $len = 0;
     $this->setItemID($buf->DecodeInt32());
     $len += 4;
     $ItemSize -= 4;
     $this->setCount($buf->DecodeInt32());
     $len += 4;
     $ItemSize -= 4;
     $this->setExpiredTime($buf->DecodeInt32());
     $len += 4;
     $ItemSize -= 4;
     if ($ItemSize < 0) {
         return 0;
     } else {
         $buf->DecodeMemory($ItemSize);
     }
     return $len;
 }
Exemple #15
0
 public function Decode(CodeEngine &$buf)
 {
     $len = 0;
     $PlayStatusSize = $buf->DecodeInt16();
     $len += 2;
     $this->Uin = $buf->DecodeInt32();
     $len += 4;
     $PlayStatusSize -= 4;
     $this->Account = $buf->DecodeString();
     //lsybegin
     //字符串前头自带2字节长度前缀,在字符数据之外
     $len += 2;
     $PlayStatusSize -= 2;
     //lsyend
     $len += strlen($this->Account);
     $PlayStatusSize -= strlen($this->Account);
     $this->ClassCount = $buf->DecodeInt8();
     $len += 1;
     $PlayStatusSize -= 1;
     if ($this->ClassCount > StateClass::MAX_CLASS_COUNT) {
         $this->ClassCount = StateClass::MAX_CLASS_COUNT;
     }
     $this->StateData = array();
     for ($i = 0; $i < $this->ClassCount; $i++) {
         $temp = new StateData();
         $r = $temp->Decode($buf);
         $len += $r;
         $PlayStatusSize -= $r;
         $this->StateData[] = $temp;
     }
     if ($PlayStatusSize < 0) {
         return 0;
     } else {
         $len += $PlayStatusSize;
         $buf->DecodeMemory($PlayStatusSize);
     }
     return $len;
 }
Exemple #16
0
 public static function decode_item_info(CodeEngine &$buf)
 {
     $ii = new ItemInfo();
     $temp = $buf->DecodeInt16();
     $ii->setItemID($buf->DecodeInt32());
     $ii->setItemType($buf->DecodeInt16());
     $ii->setCount($buf->DecodeInt32());
     $ii->setGameID($buf->DecodeInt16());
     $ii->setExpiredTime($buf->DecodeInt32());
     $ii->setUpdateMode($buf->DecodeInt8());
     return $ii;
 }
Exemple #17
0
 public function Decode(CodeEngine &$buf)
 {
     $playercommonSize = 0;
     $outlength = 0;
     $len = $buf->DecodeInt16();
     $outlength += 2;
     $this->setCoin($buf->DecodeInt32());
     $outlength += 4;
     $this->setLoginCount($buf->DecodeInt32());
     $outlength += 4;
     $this->setOfflineCount($buf->DecodeInt32());
     $outlength += 4;
     $this->setCharming($buf->DecodeInt32());
     $outlength += 4;
     $this->setAchievement($buf->DecodeInt32());
     $outlength += 4;
     $this->setHappyBean($buf->DecodeInt64());
     $outlength += 8;
     $this->setBlackLevel($buf->DecodeInt32());
     $outlength += 4;
     $this->setValidDate($buf->DecodeString());
     $outlength += strlen($this->ValidDate) + 2;
     $this->setPunishMethod($buf->DecodeInt32());
     $outlength += 4;
     $this->setLastLoginDate($buf->DecodeString());
     $outlength += strlen($this->LastLoginDate) + 2;
     $this->setLastLoginIP($buf->DecodeInt32());
     $outlength += 4;
     $this->setDescString($buf->DecodeString());
     $outlength += strlen($this->DescString) + 2;
     $this->setLastConsumeDate($buf->DecodeString());
     $outlength += strlen($this->LastConsumeDate) + 2;
     $this->setMiscFlag($buf->DecodeInt32());
     $outlength += 4;
     $this->setHappyBeanDailyPresentedCount($buf->DecodeInt32());
     $outlength += 4;
     $this->setHappyBeanDailyLastPresentedTime($buf->DecodeInt32());
     $outlength += 4;
     $t = new WebQunData();
     $t->DataSize = $buf->DecodeInt16();
     $outlength += 2;
     $t->WebQunInfo = $buf->DecodeMemory($t->DataSize);
     $outlength += $t->DataSize;
     $this->setWebQunData($t);
     # 如何获取Others的长度
     # 卡住了 貌似有逻辑问题
     $this->Others = array();
     for ($i = 0; $i < player_data_other_count; $i++) {
         $this->Others[] = $buf->DecodeInt32();
     }
     $outlength += player_data_other_count * 4;
     $this->FirstLoginDatetime = $buf->DecodeInt32();
     $outlength += 4;
     $tt = new VipData();
     $r = $tt->Decode($buf);
     $this->setVipData($tt);
     $outlength += $r;
     $this->setIDCard($buf->DecodeString());
     $outlength += strlen($this->IDCard) + 2;
     $this->setSex($buf->DecodeInt8());
     $outlength += 1;
     $ttt = new Birthday();
     $ttt->setYear($buf->DecodeInt16());
     $outlength += 2;
     $ttt->setMonth($buf->DecodeInt16());
     $outlength += 2;
     $ttt->setDay($buf->DecodeInt16());
     $outlength += 2;
     $this->setBirThday($ttt);
     $playercommonSize = $len - $outlength;
     if ($playercommonSize > 0) {
         $buf->DecodeMemory($playercommonSize);
     }
     return $len;
 }
Exemple #18
0
 public function Decode(CodeEngine &$buf)
 {
     $len = $buf->DecodeInt16();
     $len -= 2;
     $this->GameID = $buf->DecodeInt16();
     $len -= 2;
     $this->Level = $buf->DecodeInt8();
     $len -= 1;
     $this->Point = $buf->DecodeInt32();
     $len -= 4;
     $this->WinRound = $buf->DecodeInt32();
     $len -= 4;
     $this->LoseRound = $buf->DecodeInt32();
     $len -= 4;
     $this->DrawRound = $buf->DecodeInt32();
     $len -= 4;
     $this->EscapeRound = $buf->DecodeInt32();
     $len -= 4;
     $this->OrgID = $buf->DecodeInt32();
     $len -= 4;
     $this->Position = $buf->DecodeInt16();
     $len -= 2;
     $this->TotalSecs = $buf->DecodeInt32();
     $len -= 4;
     $this->LastDate = $buf->DecodeString();
     $len -= strlen($this->LastDate);
     $this->ExtGameInfo = new TDBExtGameInfo();
     $this->ExtGameInfo->Decode($buf);
     $this->GameConfig = new PlayerGameConfig();
     $this->GameConfig->Decode($buf);
     return $len;
 }
Exemple #19
0
 public function Decode(CodeEngine &$buf)
 {
     $this->DataType = $buf->DecodeInt8();
     switch ($this->DataType) {
         case QunPlayerDataType::QPD_Type_Charming:
             $this->Charming->DeltaValue = $buf->DecodeInt32();
             $this->Charming->CurrentValue = $buf->DecodeInt32();
             break;
         case QunPlayerDataType::QPD_Type_Achievement:
             $this->Achievement->DeltaValue = $buf->DecodeInt32();
             $this->Achievement->CurrentValue = $buf->DecodeInt32();
             break;
         case QunPlayerDataType::QPD_Type_Money:
             $this->Money->DeltaValue = $buf->DecodeInt32();
             $this->Money->DeltaValue = $buf->DecodeInt32();
             break;
         case QunPlayerDataType::QPD_Type_HappyBean:
             $this->HappyBean->DeltaValue = $buf->DecodeInt32();
             $this->HappyBean->CurrentValue = $buf->DecodeInt32();
             break;
         case QunPlayerDataType::QPD_Type_GameResultChange:
             $this->GameResultChange->DeltaGamePoint = $buf->DecodeInt32();
             $this->GameResultChange->DeltaWinRound = $buf->DecodeInt32();
             $this->GameResultChange->DeltaLossRound = $buf->DecodeInt32();
             $this->GameResultChange->DeltaDrawRound = $buf->DecodeInt32();
             $this->GameResultChange->DeltaEscapeRound = $buf->DecodeInt32();
             $this->GameResultChange->DeltaCostTime = $buf->DecodeInt32();
             $this->GameResultChange->GamePoint = $buf->DecodeInt32();
             $this->GameResultChange->WinRound = $buf->DecodeInt32();
             $this->GameResultChange->LossRound = $buf->DecodeInt32();
             $this->GameResultChange->DrawRound = $buf->DecodeInt32();
             $this->GameResultChange->EscapeRound = $buf->DecodeInt32();
             $this->GameResultChange->CostTime = $buf->DecodeInt32();
             break;
     }
     return $this;
 }