示例#1
0
        private static Struct BaseReadInfo(ReceivePacket p, bool OnlyBytes, bool genLog)
        {
            Struct info = new Struct
            {
                _weaponInfo    = p.readUH(),
                _weaponSlot    = p.readC(),
                _unk           = p.readUH(),
                _objPos_x      = p.readUH(),
                _objPos_y      = p.readUH(),
                _objPos_z      = p.readUH(),
                _unk5          = p.readUH(),
                _unk6          = p.readUH(),
                _unk7          = p.readUH(),
                _grenadesCount = p.readUH()
            };                       //id do item do mapa

            info._unk8 = p.readB(6); //Null 1.15.37

            /*
             * 1.15.42 - p.readB(6);
             */
            if (!OnlyBytes)
            {
                info.WeaponNumber = (info._weaponInfo >> 6);
                info.WeaponClass  = (info._weaponInfo & 47);
            }
            if (genLog)
            {
                Printf.warning("[code1_GrenadeSync] " + BitConverter.ToString(p.getBuffer()));
                Printf.warning("[code1_GrenadeSync] wInfo: " + info._weaponInfo + "; wSlot: " + info._weaponSlot + "; u: " + info._unk + "; obpX: " + info._objPos_x + "; obpY: " + info._objPos_y + "; obpZ: " + info._objPos_z + "; u5: " + info._unk5 + "; u6: " + info._unk6 + "; u7: " + info._unk7 + "; u8: " + info._unk8);
            }
            return(info);
        }
示例#2
0
 private static code1_GrenadeSync.Struct BaseReadInfo(ReceivePacket p, bool OnlyBytes, bool genLog)
 {
     code1_GrenadeSync.Struct @struct = new code1_GrenadeSync.Struct()
     {
         _weaponInfo    = p.readUH(),
         _weaponSlot    = p.readC(),
         _unk           = p.readUH(),
         _objPos_x      = p.readUH(),
         _objPos_y      = p.readUH(),
         _objPos_z      = p.readUH(),
         _unk5          = p.readUH(),
         _unk6          = p.readUH(),
         _unk7          = p.readUH(),
         _grenadesCount = p.readUH()
     };
     @struct._unk8 = p.readB(6);
     if (!OnlyBytes)
     {
         @struct.WeaponNumber = (int)@struct._weaponInfo >> 6;
         @struct.WeaponClass  = (int)@struct._weaponInfo & 47;
     }
     if (genLog)
     {
         Logger.warning("[code1_GrenadeSync] " + BitConverter.ToString(p.getBuffer()), false);
         Logger.warning("[code1_GrenadeSync] wInfo: " + (object)@struct._weaponInfo + "; wSlot: " + (object)@struct._weaponSlot + "; u: " + (object)@struct._unk + "; obpX: " + (object)@struct._objPos_x + "; obpY: " + (object)@struct._objPos_y + "; obpZ: " + (object)@struct._objPos_z + "; u5: " + (object)@struct._unk5 + "; u6: " + (object)@struct._unk6 + "; u7: " + (object)@struct._unk7 + "; u8: " + (object)@struct._unk8, false);
     }
     return(@struct);
 }
        public static List <HitData> ReadInfo(ReceivePacket p, bool genLog)
        {
            List <HitData> hits  = new List <HitData>();
            int            count = p.readC();

            for (int k = 0; k < count; k++)
            {
                HitData hit = new HitData
                {
                    _hitInfo    = p.readUD(),
                    _weaponInfo = p.readUH(),
                    _weaponSlot = p.readC(),
                    _unk        = p.readUH(),
                    _eixoX      = p.readUH(),
                    _eixoY      = p.readUH(),
                    _eixoZ      = p.readUH()
                };
                if (genLog)
                {
                    Printf.warning("P: " + hit._eixoX + ";" + hit._eixoY + ";" + hit._eixoZ);
                    Printf.warning("[" + k + "] 16384: " + BitConverter.ToString(p.getBuffer()));
                }
                hits.Add(hit);
            }
            return(hits);
        }
示例#4
0
 public static a1000_DropWeapon.Struct ReadInfo(ReceivePacket p, bool genLog)
 {
     a1000_DropWeapon.Struct @struct = new a1000_DropWeapon.Struct()
     {
         _weaponFlag  = p.readC(),
         _weaponClass = p.readC(),
         _weaponId    = p.readUH(),
         _ammoPrin    = p.readC(),
         _ammoDual    = p.readC(),
         _ammoTotal   = p.readUH()
     };
     if (genLog)
     {
         Logger.warning("[ActionBuffer]: " + BitConverter.ToString(p.getBuffer()), false);
         Logger.warning("[DropWeapon] Flag: " + (object)@struct._weaponFlag + "; Class: " + (object)(ClassType)@struct._weaponClass + "; Id: " + (object)@struct._weaponId, false);
     }
     return(@struct);
 }
        public static Struct ReadInfo(ReceivePacket p, bool genLog)
        {
            Struct info = new Struct
            {
                _weaponFlag  = p.readC(),
                _weaponClass = p.readC(),
                _weaponId    = p.readUH(),
                _ammoPrin    = p.readC(),
                _ammoDual    = p.readC(),
                _ammoTotal   = p.readUH()
            };

            if (genLog)
            {
                Printf.warning("[ActionBuffer]: " + BitConverter.ToString(p.getBuffer()));
                Printf.warning("[DropWeapon] Flag: " + info._weaponFlag + "; Class: " + (ClassType)info._weaponClass + "; Id: " + info._weaponId);
            }
            return(info);
        }
示例#6
0
 public static code2_WeaponSync.Struct ReadInfo(ReceivePacket p, bool genLog)
 {
     code2_WeaponSync.Struct @struct = new code2_WeaponSync.Struct()
     {
         _weaponFlag = p.readC(),
         _posX       = p.readUH(),
         _posY       = p.readUH(),
         _posZ       = p.readUH(),
         _unk4       = p.readUH(),
         _unk5       = p.readUH(),
         _unk6       = p.readUH(),
         _unk7       = p.readUH()
     };
     if (genLog)
     {
         Logger.warning("[code2_WeaponSync] " + BitConverter.ToString(p.getBuffer()), false);
         Logger.warning("[code2_WeaponSync] Flag: " + (object)@struct._weaponFlag + "; u4: " + (object)@struct._unk4 + "; u5: " + (object)@struct._unk5 + "; u6: " + (object)@struct._unk6 + "; u7: " + (object)@struct._unk7, false);
     }
     return(@struct);
 }
示例#7
0
        public static Struct ReadInfo(ReceivePacket p, bool genLog)
        {
            Struct info = new Struct
            {
                _weaponFlag = p.readC(),
                _posX       = p.readUH(),
                _posY       = p.readUH(),
                _posZ       = p.readUH(),
                _unk4       = p.readUH(),
                _unk5       = p.readUH(),
                _unk6       = p.readUH(),
                _unk7       = p.readUH()
            };

            if (genLog)
            {
                Printf.warning("[code2_WeaponSync] " + BitConverter.ToString(p.getBuffer()));
                Printf.warning("[code2_WeaponSync] Flag: " + info._weaponFlag + "; u4: " + info._unk4 + "; u5: " + info._unk5 + "; u6: " + info._unk6 + "; u7: " + info._unk7);
                //Vector3 vec = new Half3(info._posX, info._posY, info._posZ);
                //Logger.warning("[code2_WeaponSync] X: " + vec.X + "; Y: " + vec.Y + "; Z: " + vec.Z);
            }
            return(info);
        }
        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;
            }
        }
示例#9
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);
            }
        }
示例#10
0
        private static void LoadPacket(byte[] buffer)
        {
            ReceivePacket p      = new ReceivePacket(buffer);
            short         opcode = p.readH();

            try
            {
                switch (opcode)
                {
                case 1:
                    RespawnSync.Load(p);
                    break;

                case 2:
                    RemovePlayerSync.Load(p);
                    break;

                case 3:
                    uint UniqueRoomId = p.readUD();
                    int  gen2         = p.readD();
                    int  round        = p.readC();
                    Room room         = RoomsManager.getRoom(UniqueRoomId, gen2);
                    if (room != null)
                    {
                        room._serverRound = round;
                    }
                    break;

                default:
                    Console.WriteLine("[BattleSync]\n Opcode invalido: " + opcode);
                    break;
                }
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString() + "\nOpcode: " + opcode);
                if (p != null)
                {
                    SaveLog.fatal("[Crash/Battle_SyncNet] COMP: " + BitConverter.ToString(p.getBuffer()));
                }
                Printf.b_danger("[Battle_SyncNet.LoadPacket] Erro fatal!");
            }
        }
示例#11
0
        public static List <a4000_BotHitData.HitData> ReadInfo(ReceivePacket p, bool genLog)
        {
            List <a4000_BotHitData.HitData> hitDataList = new List <a4000_BotHitData.HitData>();
            int num = (int)p.readC();

            for (int index = 0; index < num; ++index)
            {
                a4000_BotHitData.HitData hitData = new a4000_BotHitData.HitData()
                {
                    _hitInfo    = p.readUD(),
                    _weaponInfo = p.readUH(),
                    _weaponSlot = p.readC(),
                    _unk        = p.readUH(),
                    _eixoX      = p.readUH(),
                    _eixoY      = p.readUH(),
                    _eixoZ      = p.readUH()
                };
                if (genLog)
                {
                    Logger.warning("P: " + (object)hitData._eixoX + ";" + (object)hitData._eixoY + ";" + (object)hitData._eixoZ, false);
                    Logger.warning("[" + (object)index + "] 16384: " + BitConverter.ToString(p.getBuffer()), false);
                }
                hitDataList.Add(hitData);
            }
            return(hitDataList);
        }