public static void Load(ReceivePacket p)
        {
            uint UniqueRoomId = p.readUD();
            int  gen2 = p.readD();
            long roomTick = p.readQ();
            int  syncType = p.readC();
            int  round = p.readC();
            int  slotId = p.readC();
            int  spawnNumber = p.readC();
            byte accountId = p.readC();
            int  type = 0, number = 0, HPBonus = 0;
            bool C4Speed = false;

            if (syncType == 0 || syncType == 2)
            {
                type    = p.readC();
                number  = p.readH();
                HPBonus = p.readC();
                C4Speed = p.readC() == 1;
                if (28 < p.getBuffer().Length)
                {
                    Printf.warning("[RespawnSync.Load] - PacketSize > 28 " + BitConverter.ToString(p.getBuffer()));
                    SaveLog.warning("[RespawnSync.Load] - Invalid! PacketSize > 28 | pId:" + accountId + "; syncType:" + syncType + "; pkLenght:" + p.getBuffer().Length + " " + BitConverter.ToString(p.getBuffer()));
                }
            }
            else if (23 < p.getBuffer().Length)
            {
                Printf.warning("[RespawnSync.Load] - PacketSize > 23 " + BitConverter.ToString(p.getBuffer()));
                SaveLog.warning("[RespawnSync.Load] - ALTO! PacketSize > 23 | pId:" + accountId + "; syncType:" + syncType + "; pkLenght:" + p.getBuffer().Length + " " + BitConverter.ToString(p.getBuffer()));
            }

            Room room = RoomsManager.getRoom(UniqueRoomId);

            if (room == null)
            {
                return;
            }

            room.ResyncTick(roomTick, gen2); //Colocar dentro do IF
            Player player = room.getPlayer(slotId, true);

            if (player != null && player._playerIdByUser != accountId)
            {
                SaveLog.warning("Invalid User Ids: [By user: "******"/ Server: " + accountId + "]");
                Printf.warning("[RespawSync] Invalid user id");
            }

            if (player != null && player._playerIdByUser == accountId)
            {
                player._playerIdByServer = accountId;
                player._respawnByServer  = spawnNumber;
                player.Integrity         = false;
                if (round > room._serverRound)
                {
                    room._serverRound = round;
                }
                if (syncType == 0 || syncType == 2) //0 = Entrando na partida (normalmente) | 1 = Entrando na partida de espectador (Destru/Supressão) | 2 = Entrando na partida (normalmente/não é o primeiro respawn do jogador)
                {
                    player._respawnByLogic++;
                    player.isDead          = false;
                    player._plantDuration  = Config.plantDuration;
                    player._defuseDuration = Config.defuseDuration;
                    if (C4Speed)
                    {
                        player._plantDuration  -= AllUtils.percentage(Config.plantDuration, 50);
                        player._defuseDuration -= AllUtils.percentage(Config.defuseDuration, 25);
                    }
                    if (!room._isBotMode)
                    {
                        if (room._sourceToMap == -1)
                        {
                            room.RoundResetRoomF1(round);
                        }
                        else
                        {
                            room.RoundResetRoomS1(round);
                        }
                    }
                    if (type == 255)
                    {
                        player.Immortal = true;
                    }
                    else
                    {
                        player.Immortal = false;
                        int CharaHP = CharaXML.getLifeById(number, type);
                        CharaHP        += AllUtils.percentage(CharaHP, HPBonus);
                        player._maxLife = CharaHP;
                        player.ResetLife();
                    }
                }
                if (room._isBotMode || syncType == 2 || !room.ObjectsIsValid())
                {
                    return;
                }

                List <ObjectHitInfo> syncList = new List <ObjectHitInfo>();
                for (int i = 0; i < room._objects.Length; i++)
                {
                    ObjectInfo rObj = room._objects[i];
                    ObjModel   mObj = rObj._model;
                    if (mObj != null && (syncType != 2 && mObj.isDestroyable && rObj._life != mObj._life || mObj._needSync))
                    {
                        syncList.Add(new ObjectHitInfo(3)
                        {
                            objSyncId     = mObj._needSync ? 1 : 0,
                            _animId1      = mObj._anim1,
                            _animId2      = rObj._anim != null ? rObj._anim._id : 255,
                            _destroyState = rObj.DestroyState,
                            objId         = mObj._id,
                            objLife       = rObj._life,
                            _specialUse   = AllUtils.GetDuration(rObj._useDate)
                        });
                    }
                }
                for (int i = 0; i < room._players.Length; i++)
                {
                    Player pR = room._players[i];
                    if (pR._slot != slotId && pR.AccountIdIsValid() && !pR.Immortal && pR._date != new DateTime() && (pR._maxLife != pR._life || pR.isDead))
                    {
                        syncList.Add(new ObjectHitInfo(4)
                        {
                            objId   = pR._slot,
                            objLife = pR._life
                        });
                    }
                }
                if (syncList.Count > 0)
                {
                    byte[] packet = Packet4Creator.getCode4(Packet4Creator.getCode4SyncData(syncList), room._startTime, round, 255);
                    BattleManager.Send(packet, player._client);
                }
                syncList = null;
            }
        }
Ejemplo n.º 2
0
        public static void Load(ReceivePacket p)
        {
            uint UniqueRoomId = p.readUD();
            int  gen2         = p.readD();
            long startTick    = p.readQ();
            int  num1         = (int)p.readC();
            int  round        = (int)p.readC();
            int  slot         = (int)p.readC();
            int  num2         = (int)p.readC();
            byte num3         = p.readC();
            int  type         = 0;
            int  charaId      = 0;
            int  percent      = 0;
            bool flag         = false;

            if (num1 == 0 || num1 == 2)
            {
                type    = (int)p.readC();
                charaId = (int)p.readH();
                percent = (int)p.readC();
                flag    = p.readC() == (byte)1;
                if (28 < p.getBuffer().Length)
                {
                    Logger.warning("[ALTO]: " + BitConverter.ToString(p.getBuffer()), false);
                }
            }
            else if (23 < p.getBuffer().Length)
            {
                Logger.warning("[ALTO]: " + BitConverter.ToString(p.getBuffer()), false);
            }
            Room room = RoomsManager.getRoom(UniqueRoomId);

            if (room == null)
            {
                return;
            }
            room.ResyncTick(startTick, gen2);
            Player player1 = room.getPlayer(slot, true);

            if (player1 != null && player1._playerIdByUser != (int)num3)
            {
                Logger.warning("Invalid User Ids: [By user: "******"/ Server: " + (object)num3 + "]", false);
            }
            if (player1 == null || player1._playerIdByUser != (int)num3)
            {
                return;
            }
            player1._playerIdByServer = (int)num3;
            player1._respawnByServer  = num2;
            player1.Integrity         = false;
            if (round > room._serverRound)
            {
                room._serverRound = round;
            }
            if (num1 == 0 || num1 == 2)
            {
                ++player1._respawnByLogic;
                player1.isDead          = false;
                player1._plantDuration  = Config.plantDuration;
                player1._defuseDuration = Config.defuseDuration;
                if (flag)
                {
                    player1._plantDuration  -= AllUtils.percentage(Config.plantDuration, 50);
                    player1._defuseDuration -= AllUtils.percentage(Config.defuseDuration, 25);
                }
                if (!room._isBotMode)
                {
                    if (room._sourceToMap == -1)
                    {
                        room.RoundResetRoomF1(round);
                    }
                    else
                    {
                        room.RoundResetRoomS1(round);
                    }
                }
                if (type == (int)byte.MaxValue)
                {
                    player1.Immortal = true;
                }
                else
                {
                    player1.Immortal = false;
                    int lifeById = CharaXML.getLifeById(charaId, type);
                    int num4     = lifeById + AllUtils.percentage(lifeById, percent);
                    player1._maxLife = num4;
                    player1.ResetLife();
                }
            }
            if (room._isBotMode || num1 == 2 || !room.ObjectsIsValid())
            {
                return;
            }
            List <ObjectHitInfo> objs = new List <ObjectHitInfo>();

            for (int index = 0; index < room._objects.Length; ++index)
            {
                ObjectInfo objectInfo = room._objects[index];
                ObjModel   model      = objectInfo._model;
                if (model != null && (num1 != 2 && model.isDestroyable && objectInfo._life != model._life || model._needSync))
                {
                    objs.Add(new ObjectHitInfo(3)
                    {
                        objSyncId     = model._needSync ? 1 : 0,
                        _animId1      = model._anim1,
                        _animId2      = objectInfo._anim != null ? objectInfo._anim._id : (int)byte.MaxValue,
                        _destroyState = objectInfo.DestroyState,
                        objId         = model._id,
                        objLife       = objectInfo._life,
                        _specialUse   = objectInfo.GetCurrentAnimProgress()
                    });
                }
            }
            for (int index = 0; index < room._players.Length; ++index)
            {
                Player player2 = room._players[index];
                if (player2._slot != slot && player2.AccountIdIsValid() && !player2.Immortal && player2._date != new DateTime() && (player2._maxLife != player2._life || player2.isDead))
                {
                    objs.Add(new ObjectHitInfo(4)
                    {
                        objId   = player2._slot,
                        objLife = player2._life
                    });
                }
            }
            if (objs.Count > 0)
            {
                BattleManager.Send(Packet4Creator.getCode4(Packet4Creator.getCode4SyncData(objs), room._startTime, round, (int)byte.MaxValue), player1._client);
            }
        }