Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        try{
            Vector3 mousePos = Input.mousePosition;
            mousePos.z = SimController.INSTANCE.radius;

            Vector3 pointingAt = Camera.main.ScreenToWorldPoint(mousePos);


            LocalCoords local = SkyModel.Rectangular2Horizontal((double)pointingAt.x, (double)pointingAt.y, (double)pointingAt.z);

            EquatorialCoords equatorial = skyModel.Horizontal2Equatorial(
                local.Azimuth.Get(),
                local.Altitude.Get()
                );


            DisplaySelectedBodyDetailsIfAny(equatorial);


            raDecGUI.text = string.Format("RA/Dec: {0} / {1}", equatorial.RA.ToString(), equatorial.Declination.ToString());

            azimuthAltGUI.text = string.Format("Az/Alt: {0} / {1}", local.Azimuth.To0To360Range().ToString(), local.Altitude.ToString());

            fovGUI.text = "FOV: " + Camera.main.fieldOfView + "º";

            raDecGUI.color = azimuthAltGUI.color = fovGUI.color = sim.Settings.MouseHudColor;
        }catch (NullReferenceException n) {
            Debug.Log(n);
        }
    }
Beispiel #2
0
        static void Main(string[] args)
        {
            var       rep = new Repository <GameBoard>();
            GameBoard gb  = new GameBoard(1, 10);
            var       gb1 = rep.GetById("1");

            WarShip ws4  = new WarShip(Guid.NewGuid().ToString(), 1, gb1, 3, 1, 90, 15);
            WarShip ws5  = new WarShip(Guid.NewGuid().ToString(), 1, gb1, 2, 1, 90, 10);
            WarShip ws6  = new WarShip(Guid.NewGuid().ToString(), 1, gb1, 2, 1, 90, 11);
            var     rep2 = new Repository <WarShip>();
            var     tt   = rep2.GetById("3c9290c0-7aad-4494-a2a4-2cf3b5aab852");
            //rep2.Add(ws4);
            //rep2.Add(ws5);
            //rep2.Add(ws6);
            var cor    = new LocalCoords(Guid.NewGuid().ToString(), 1, gb1, 1, 1, 1);
            var cor1   = new LocalCoords(Guid.NewGuid().ToString(), 1, gb1, 2, 2, 2);
            var cor2   = new LocalCoords(Guid.NewGuid().ToString(), 1, gb1, 3, 2, 2);
            var repcor = new Repository <LocalCoords>();
            //repcor.Add(cor);
            //repcor.Add(cor1);
            //repcor.Add(cor2);
            var tttmp = repcor.GetById("d9f5f352-c034-4d7b-9803-9e35e79e9bfb");
            var www   = repcor.GetTs();
            //gb[1,1,1] = ws4;
            //Console.WriteLine(gb1.ToString());
            //TODO: добавить в локал кордс ссылку на корабль, что бы связать корабли с координатами
        }
Beispiel #3
0
        private GlobalCoords ConvertToGlobal(LocalCoords p)
        {
            LocalCoords ptemp = p;

            switch (p.Q)
            {
            case 1: break;

            case 2:
                ptemp.X *= -1;
                break;

            case 3:
                ptemp.X *= -1;
                ptemp.Y *= -1;
                break;

            case 4:
                ptemp.Y *= -1;
                break;
            }

            ptemp.X = Length / 2 + ptemp.X - 1;
            ptemp.Y = Length / 2 + ptemp.Y - 1;
            return(new GlobalCoords(ptemp.X, ptemp.Y));
        }
Beispiel #4
0
        public void TestLocalCoords()
        {
            LocalCoords coords = new LocalCoords(1.1, 2.2, 3.3);

            Assert.AreEqual("^1.1 ^2.2 ^3.3", coords.GetVectorString(), "Coords vector string wasn't correct");

            coords = new LocalCoords(0.1, 0, -0.1);
            Assert.AreEqual("^.1 ^ ^-.1", coords.GetVectorString(), "GetVectorString doesn't minimize coords correctly");
        }
Beispiel #5
0
    public override string GetBodyDetails()
    {
        string s = string.Format("{0}\n", "MOON");

        s += string.Format("RA/Dec: {0} / {1}\n", equatorialCoords.RA.ToString(), equatorialCoords.Declination.ToString());

        LocalCoords localCoords = GetLocalCoords();

        s += string.Format("Az/Alt: {0} / {1}\n", localCoords.Azimuth.ToString(), localCoords.Altitude.ToString());
        s += string.Format("Distance: {0} km\n", GetDistance());

        return(s);
    }
        private string MakeHidInfo(PacketLog log, int selectedIndex, ushort houseId)
        {
            StringBuilder            str            = new StringBuilder();
            CtoS_0xA9_PlayerPosition lastSelfCoords = null;
            LocalCoords lastObjectCoords            = null;
            LocalCoords regionGlobalCoords          = null;
            LocalCoords firstSelfCoords             = null;
            bool        flagInteriorFound           = false;
            bool        flagInsideUpdateFound       = false;
            bool        flagExteriorFound           = false;
            bool        flagHouseFound = false;

            for (int i = selectedIndex; i >= 0; i--)
            {
                Packet pak = log[i];
                if (pak is StoC_0x20_PlayerPositionAndObjectID)                 // stop scanning packets on enter region
                {
                    regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z);
                    break;
                }
                else if (pak is StoC_0xD1_HouseCreate)
                {
                    if (!flagHouseFound && (pak as StoC_0xD1_HouseCreate).HouseId == houseId)
                    {
                        flagHouseFound = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD1_HouseCreate).X, (pak as StoC_0xD1_HouseCreate).Y, (pak as StoC_0xD1_HouseCreate).Z);
                        }
                    }
                }
                else if (pak is StoC_0xD2_HouseUpdate)
                {
                    if (!flagExteriorFound && (pak as StoC_0xD2_HouseUpdate).HouseId == houseId && (pak as StoC_0xD2_HouseUpdate).UpdateCode == 0x80)
                    {
                        flagExteriorFound = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x09_HouseDecorationUpdate)
                {
                    if (!flagInteriorFound && (pak as StoC_0x09_HouseDecorationUpdate).HouseId == houseId && (pak as StoC_0x09_HouseDecorationUpdate).DecorationCode == 0x80)
                    {
                        flagInteriorFound = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x08_HouseInsideUpdate)
                {
                    if (!flagInsideUpdateFound && (pak as StoC_0x08_HouseInsideUpdate).HouseId == houseId)
                    {
                        flagInsideUpdateFound = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is CtoS_0xA9_PlayerPosition)
                {
                    if (firstSelfCoords == null)
                    {
                        firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF);
                    }
                    else
                    {
                        firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX;
                        firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY;
                        firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ;
                    }

                    if (lastSelfCoords == null)
                    {
                        lastSelfCoords = pak as CtoS_0xA9_PlayerPosition;
                    }
                }
            }
            str.Insert(0, string.Format("\nhouseId:0x{0:X4}\n", houseId));
            if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId)
            {
                long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int  range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (loc)\n", range));
            }
            else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null)             /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int  range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc)\n", range));
//				str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY));
            }
            else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF)             /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int  range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc)\n", range));
            }
            return(str.ToString());
        }
        private string MakeOidInfo(PacketLog log, int selectedIndex, ushort objectId, ushort sessionId, ushort keepId)
        {
            StringBuilder str = new StringBuilder();
            int           maxPacketsLookBackForGetCoords = 100000;   // look back in log max 30 packets for find coords after found obejct creation packet
            bool          fullInfoFound               = false;
            bool          flagPacketMove              = false;
            bool          flagPacketCreationRequest   = false;
            bool          flagPacketItem              = false;
            bool          flagPacketRide              = false;
            bool          flagPacketEquip             = false;
            bool          flagPacketGuild             = false;
            bool          flagPacketPet               = false;
            bool          flagPacketDialog            = false;
            bool          flagVisualEffect            = false;
            bool          flagPacketMobCreate         = false;
            bool          flagPacketCombatAnimation   = false;
            bool          flagAllowGetFirstSelfCoords = true;
            ushort        selfId                = 0;
            Hashtable     ObjectsOnMount        = null;
            BitArray      m_packetsBitArrayStoC = new BitArray(255);

            m_packetsBitArrayStoC.SetAll(false);
            BitArray m_packetsBitArrayCtoS = new BitArray(255);

            m_packetsBitArrayCtoS.SetAll(false);
            CtoS_0xA9_PlayerPosition lastSelfCoords = null;
            LocalCoords lastObjectCoords            = null;
            LocalCoords regionGlobalCoords          = null;
            LocalCoords firstSelfCoords             = null;
//			Packet lastObjectCoords = null;
            string objectType = "";

            for (int i = selectedIndex; i >= 0; i--)
            {
                Packet pak = log[i];
                if (fullInfoFound)
                {
                    maxPacketsLookBackForGetCoords--;
                }
                if (pak is StoC_0x20_PlayerPositionAndObjectID)                 // stop scanning packets on enter region
                {
                    if ((pak as StoC_0x20_PlayerPositionAndObjectID).PlayerOid == objectId)
                    {
                        objectType = " (Self)";
                    }
//					str.Insert(0, pak.ToHumanReadableString(TimeSpan(0), true) + '\n');
                    if (regionGlobalCoords == null)                     // skip if gloc Jump
                    {
                        regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z);
                    }
                    flagAllowGetFirstSelfCoords = false;
                    break;
                }
                else if (pak is StoC_0x04_CharacterJump)
                {
#warning TODO: Rewrite for find self Oid
                    if ((pak as StoC_0x04_CharacterJump).PlayerOid == selfId)
                    {
                        regionGlobalCoords          = new LocalCoords((pak as StoC_0x04_CharacterJump).X, (pak as StoC_0x04_CharacterJump).Y, (pak as StoC_0x04_CharacterJump).Z);
                        flagAllowGetFirstSelfCoords = false;
                        if (lastSelfCoords != null)
                        {
                            if (firstSelfCoords == null)
                            {
                                firstSelfCoords = new LocalCoords(lastSelfCoords.CurrentZoneX, lastSelfCoords.CurrentZoneY, lastSelfCoords.CurrentZoneZ, 0xFFFF);
                            }
                            else
                            {
                                firstSelfCoords.CurrentZoneX = lastSelfCoords.CurrentZoneX;
                                firstSelfCoords.CurrentZoneY = lastSelfCoords.CurrentZoneY;
                                firstSelfCoords.CurrentZoneZ = lastSelfCoords.CurrentZoneZ;
                            }
                        }
//						break;
                    }
                }
                else if (pak is StoC_0xD4_PlayerCreate)
                {
                    if (!fullInfoFound && (pak as StoC_0xD4_PlayerCreate).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType    = " (player)";
                        fullInfoFound = true;
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD4_PlayerCreate).ZoneX, (pak as StoC_0xD4_PlayerCreate).ZoneY, (pak as StoC_0xD4_PlayerCreate).ZoneZ, (ushort)(pak as StoC_0xD4_PlayerCreate).ZoneId);
                        }
                    }
                }
                else if (pak is StoC_0x4B_PlayerCreate_172)
                {
                    if (!fullInfoFound && (pak as StoC_0x4B_PlayerCreate_172).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType    = " (player)";
                        fullInfoFound = true;
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0x4B_PlayerCreate_172).ZoneX, (pak as StoC_0x4B_PlayerCreate_172).ZoneY, (pak as StoC_0x4B_PlayerCreate_172).ZoneZ, (pak as StoC_0x4B_PlayerCreate_172).ZoneId);
                        }
                    }
                }
                else if (pak is StoC_0xDA_NpcCreate)
                {
                    if (!fullInfoFound && !flagPacketMobCreate && (pak as StoC_0xDA_NpcCreate).Oid == objectId)
                    {
                        flagPacketMobCreate = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (NPC)";
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xDA_NpcCreate).X, (pak as StoC_0xDA_NpcCreate).Y, (pak as StoC_0xDA_NpcCreate).Z);
                        }
//						fullInfoFound = true; // need find 0x20 for get gloc region
                    }
                }
                else if (pak is StoC_0xD9_ItemDoorCreate)
                {
                    if (!fullInfoFound && !flagPacketItem && (pak as StoC_0xD9_ItemDoorCreate).Oid == objectId)
                    {
                        flagPacketItem = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        if ((pak as StoC_0xD9_ItemDoorCreate).ExtraBytes == 4)
                        {
                            objectType = " (Door)";
                        }
                        else
                        {
                            objectType = " (Object)";
                        }
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD9_ItemDoorCreate).X, (pak as StoC_0xD9_ItemDoorCreate).Y, (pak as StoC_0xD9_ItemDoorCreate).Z);
                        }
//						fullInfoFound = true; // need find 0x20 for get gloc region
                    }
                }
                else if (pak is StoC_0x12_CreateMovingObject)
                {
                    if (!fullInfoFound && (pak as StoC_0x12_CreateMovingObject).ObjectOid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType    = " (MovingObject)";
                        fullInfoFound = true;
                    }
                }
                else if (pak is StoC_0xC8_PlayerRide)                 // show object if rided
                {
                    if (!fullInfoFound && !flagPacketRide && (pak as StoC_0xC8_PlayerRide).RiderOid == objectId)
                    {
                        flagPacketRide = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                    else if ((pak as StoC_0xC8_PlayerRide).MountOid == objectId)
                    {
                        if (ObjectsOnMount == null)
                        {
                            ObjectsOnMount = new Hashtable();
                        }
                        if (!ObjectsOnMount.ContainsKey((pak as StoC_0xC8_PlayerRide).Slot))
                        {
                            ObjectsOnMount.Add((pak as StoC_0xC8_PlayerRide).Slot, (ushort)(pak as StoC_0xC8_PlayerRide).RiderOid);
                            str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        }
                    }
                }
                else if (pak is StoC_0x15_EquipmentUpdate)
                {
                    if (!fullInfoFound && !flagPacketEquip && (pak as StoC_0x15_EquipmentUpdate).Oid == objectId)
                    {
                        flagPacketEquip = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0xEE_NpcChangeProperties)
                {
                    if (!fullInfoFound && (pak as StoC_0xEE_NpcChangeProperties).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0xDE_SetObjectGuildId)
                {
                    if (!fullInfoFound && !flagPacketGuild && (pak as StoC_0xDE_SetObjectGuildId).Oid == objectId)
                    {
                        flagPacketGuild = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0xA1_NpcUpdate)
                {
                    if (!fullInfoFound && !flagPacketMove && (pak as StoC_0xA1_NpcUpdate).NpcOid == objectId)
                    {
                        flagPacketMove = true;
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xA1_NpcUpdate).CurrentZoneX, (pak as StoC_0xA1_NpcUpdate).CurrentZoneY, (pak as StoC_0xA1_NpcUpdate).CurrentZoneZ, (pak as StoC_0xA1_NpcUpdate).CurrentZoneId);
                        }
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x81_ShowDialog)
                {
                    if (!fullInfoFound && !flagPacketDialog && (pak as StoC_0x81_ShowDialog).ObjectIds != null && (pak as StoC_0x81_ShowDialog).ObjectIds.Length > 0 && (pak as StoC_0x81_ShowDialog).ObjectIds[0] == objectId)
                    {
                        flagPacketDialog = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0xA9_PlayerPosition)
                {
                    if (!flagPacketMove && (pak as StoC_0xA9_PlayerPosition).SessionId == sessionId)
                    {
                        if (!fullInfoFound)
                        {
                            flagPacketMove = true;
                            if (lastObjectCoords == null)
                            {
                                lastObjectCoords = new LocalCoords((pak as StoC_0xA9_PlayerPosition).CurrentZoneX, (pak as StoC_0xA9_PlayerPosition).CurrentZoneY, (pak as StoC_0xA9_PlayerPosition).CurrentZoneZ, (pak as StoC_0xA9_PlayerPosition).CurrentZoneId);
                            }
                        }
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x88_PetWindowUpdate)
                {
                    if (!fullInfoFound && !flagPacketPet && (pak as StoC_0x88_PetWindowUpdate).PetId == objectId)
                    {
                        flagPacketPet = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x4C_VisualEffect)
                {
                    if (!fullInfoFound && !flagVisualEffect && (pak as StoC_0x4C_VisualEffect).Oid == objectId)
                    {
                        flagVisualEffect = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is CtoS_0xA9_PlayerPosition)
                {
                    if (flagAllowGetFirstSelfCoords)
                    {
                        if (firstSelfCoords == null)
                        {
                            firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF);
                        }
                        else
                        {
                            firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX;
                            firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY;
                            firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ;
                        }
                    }

                    if (lastSelfCoords == null)
                    {
                        lastSelfCoords = pak as CtoS_0xA9_PlayerPosition;
                    }
                }
                else if (pak is CtoS_0xBE_NpcCreationRequest)
                {
                    if (!flagPacketCreationRequest && (pak as CtoS_0xBE_NpcCreationRequest).NpcOid == objectId)
                    {
                        flagPacketCreationRequest = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x69_KeepOverview)
                {
                    if ((pak as StoC_0x69_KeepOverview).KeepId == keepId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0x69_KeepOverview).KeepX, (pak as StoC_0x69_KeepOverview).KeepY);
                        }
                    }
                }
                else if (pak is StoC_0x61_KeepRepair)
                {
                    if (!fullInfoFound && (pak as StoC_0x61_KeepRepair).KeepId == keepId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x62_KeepClaim)
                {
                    if (!fullInfoFound && (pak as StoC_0x62_KeepClaim).KeepId == keepId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x67_KeepUpdate)
                {
                    if (!fullInfoFound && (pak as StoC_0x67_KeepUpdate).KeepId == keepId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x6C_KeepComponentOverview)
                {
                    if (!fullInfoFound && (pak as StoC_0x6C_KeepComponentOverview).KeepId == keepId)
//					if (!fullInfoFound && (pak as StoC_0x6C_KeepComponentOverview).Uid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (KeepComponent)";
//						fullInfoFound = true;
                    }
                }
                else if (pak is StoC_0xBC_CombatAnimation)
                {
                    if (!fullInfoFound && !flagPacketCombatAnimation && ((pak as StoC_0xBC_CombatAnimation).AttackerOid == objectId || (pak as StoC_0xBC_CombatAnimation).DefenderOid == objectId))
                    {
                        flagPacketCombatAnimation = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else
                {
                    if (pak is IObjectIdPacket)                                        // all other packet's with OID
                    {
                        if (!(fullInfoFound || flagPacketMobCreate || flagPacketItem)) // not show packet's before creation object packet
                        {
                            if ((pak.Direction == ePacketDirection.ServerToClient && !m_packetsBitArrayStoC[pak.Code]) ||
                                (pak.Direction == ePacketDirection.ClientToServer && !m_packetsBitArrayCtoS[pak.Code]))
                            {
                                ushort[] objectIds = (pak as IObjectIdPacket).ObjectIds;
                                if (objectIds != null && objectIds.Length > 0)
                                {
                                    for (int j = 0; j < objectIds.Length; j++)
                                    {
                                        if (objectIds[j] > 0 && objectIds[j] == objectId)
                                        {
                                            str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                                            if (pak.Direction == ePacketDirection.ServerToClient)
                                            {
                                                m_packetsBitArrayStoC[pak.Code] = true;
                                            }
                                            else if (pak.Direction == ePacketDirection.ClientToServer)
                                            {
                                                m_packetsBitArrayCtoS[pak.Code] = true;
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                // if we found object creation packets and both coords (self and object) then break;
                // if we found object creation packets but not find any coords break after maxPacketsLookBackForGetCoords look back
                if (fullInfoFound && ((lastObjectCoords != null && lastSelfCoords != null) || maxPacketsLookBackForGetCoords <= 0))
                {
                    break;
                }
            }
//			if (!fullInfoFound)
//				str.Insert(0, "No more info found\n");
            // TODO add zone checks... (mb recalc in global coords if zones is different ?)
            {
                if (regionGlobalCoords != null)
                {
                    str.Insert(0, string.Format("regionGlobalCoords (x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY));
                }
                if (firstSelfCoords != null)
                {
                    str.Insert(0, string.Format("firstSelfCoords (x:{0} y:{1})\n", firstSelfCoords.CurrentZoneX, firstSelfCoords.CurrentZoneY));
                }
                if (lastSelfCoords != null)
                {
                    str.Insert(0, string.Format("lastSelfCoords (x:{0} y:{1})\n", lastSelfCoords.CurrentZoneX, lastSelfCoords.CurrentZoneY));
                }
                if (lastObjectCoords != null)
                {
                    str.Insert(0, string.Format("lastObjectCoords (x:{0} y:{1})\n", lastObjectCoords.CurrentZoneX, lastObjectCoords.CurrentZoneY));
                }
            }
            if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId)
            {
                long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int  range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (loc/loc)\n", range));
            }
            else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null)             /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = 0;
                if (lastObjectCoords.CurrentZoneZ != 0xFFFF)
                {
                    zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                }
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (loc/gloc)\n", range));
                str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY));
            }
            else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF)             /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = 0;
                if (lastObjectCoords.CurrentZoneZ != 0xFFFF)
                {
                    zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                }
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc/gloc)\n", range));
            }
            if (objectId != 0xFFFF)
            {
                str.Insert(0, string.Format("\nobjectId:0x{0:X4}{1}\n", objectId, objectType));
            }
            return(str.ToString());
        }
        private string MakeHidInfo(PacketLog log, int selectedIndex, ushort houseId)
        {
            StringBuilder str = new StringBuilder();
            CtoS_0xA9_PlayerPosition lastSelfCoords = null;
            LocalCoords lastObjectCoords = null;
            LocalCoords regionGlobalCoords = null;
            LocalCoords firstSelfCoords = null;
            bool flagInteriorFound = false;
            bool flagInsideUpdateFound = false;
            bool flagExteriorFound = false;
            bool flagHouseFound = false;
            for (int i = selectedIndex; i >= 0; i--)
            {
                Packet pak = log[i];
                if (pak is StoC_0x20_PlayerPositionAndObjectID) // stop scanning packets on enter region
                {
                    regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z);
                    break;
                }
                else if (pak is StoC_0xD1_HouseCreate)
                {
                    if (!flagHouseFound && (pak as StoC_0xD1_HouseCreate).HouseId == houseId)
                    {
                        flagHouseFound = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD1_HouseCreate).X, (pak as StoC_0xD1_HouseCreate).Y, (pak as StoC_0xD1_HouseCreate).Z);
                    }
                }
                else if (pak is StoC_0xD2_HouseUpdate)
                {
                    if (!flagExteriorFound && (pak as StoC_0xD2_HouseUpdate).HouseId == houseId && (pak as StoC_0xD2_HouseUpdate).UpdateCode == 0x80)
                    {
                        flagExteriorFound = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x09_HouseDecorationUpdate)
                {
                    if (!flagInteriorFound && (pak as StoC_0x09_HouseDecorationUpdate).HouseId == houseId && (pak as StoC_0x09_HouseDecorationUpdate).DecorationCode == 0x80)
                    {
                        flagInteriorFound = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x08_HouseInsideUpdate)
                {
                    if (!flagInsideUpdateFound && (pak as StoC_0x08_HouseInsideUpdate).HouseId == houseId)
                    {
                        flagInsideUpdateFound = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is CtoS_0xA9_PlayerPosition)
                {
                    if (firstSelfCoords == null)
                    {
                        firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF);
                    }
                    else
                    {
                        firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX;
                        firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY;
                        firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ;
                    }

                    if (lastSelfCoords == null)
                    {
                        lastSelfCoords = pak as CtoS_0xA9_PlayerPosition;
                    }
                }
            }
            str.Insert(0, string.Format("\nhouseId:0x{0:X4}\n", houseId));
            if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId)
            {
                long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (loc)\n", range));
            }
            else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null) /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc)\n", range));
            //				str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY));
            }
            else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF) /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc)\n", range));
            }
            return str.ToString();
        }
        private string MakeOidInfo(PacketLog log, int selectedIndex, ushort objectId, ushort sessionId, ushort keepId)
        {
            StringBuilder str = new StringBuilder();
            int maxPacketsLookBackForGetCoords = 100000; // look back in log max 30 packets for find coords after found obejct creation packet
            bool fullInfoFound = false;
            bool flagPacketMove = false;
            bool flagPacketCreationRequest = false;
            bool flagPacketItem = false;
            bool flagPacketRide = false;
            bool flagPacketEquip = false;
            bool flagPacketGuild = false;
            bool flagPacketPet = false;
            bool flagPacketDialog = false;
            bool flagVisualEffect = false;
            bool flagPacketMobCreate = false;
            bool flagPacketCombatAnimation = false;
            bool flagAllowGetFirstSelfCoords = true;
            ushort selfId = 0;
            Hashtable ObjectsOnMount = null;
            BitArray m_packetsBitArrayStoC = new BitArray(255);
            m_packetsBitArrayStoC.SetAll(false);
            BitArray m_packetsBitArrayCtoS = new BitArray(255);
            m_packetsBitArrayCtoS.SetAll(false);
            CtoS_0xA9_PlayerPosition lastSelfCoords = null;
            LocalCoords lastObjectCoords = null;
            LocalCoords regionGlobalCoords = null;
            LocalCoords firstSelfCoords = null;
            //			Packet lastObjectCoords = null;
            string objectType = "";
            for (int i = selectedIndex; i >= 0; i--)
            {
                Packet pak = log[i];
                if (fullInfoFound)
                    maxPacketsLookBackForGetCoords--;
                if (pak is StoC_0x20_PlayerPositionAndObjectID) // stop scanning packets on enter region
                {
                    if ((pak as StoC_0x20_PlayerPositionAndObjectID).PlayerOid == objectId)
                        objectType = " (Self)";
            //					str.Insert(0, pak.ToHumanReadableString(TimeSpan(0), true) + '\n');
                    if (regionGlobalCoords == null) // skip if gloc Jump
                        regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z);
                    flagAllowGetFirstSelfCoords = false;
                    break;
                }
                else if (pak is StoC_0x04_CharacterJump)
                {
            #warning TODO: Rewrite for find self Oid
                    if ((pak as StoC_0x04_CharacterJump).PlayerOid == selfId)
                    {
                        regionGlobalCoords = new LocalCoords((pak as StoC_0x04_CharacterJump).X, (pak as StoC_0x04_CharacterJump).Y, (pak as StoC_0x04_CharacterJump).Z);
                        flagAllowGetFirstSelfCoords = false;
                        if (lastSelfCoords != null)
                        {
                            if (firstSelfCoords == null)
                            {
                                firstSelfCoords = new LocalCoords(lastSelfCoords.CurrentZoneX, lastSelfCoords.CurrentZoneY, lastSelfCoords.CurrentZoneZ, 0xFFFF);
                            }
                            else
                            {
                                firstSelfCoords.CurrentZoneX = lastSelfCoords.CurrentZoneX;
                                firstSelfCoords.CurrentZoneY = lastSelfCoords.CurrentZoneY;
                                firstSelfCoords.CurrentZoneZ = lastSelfCoords.CurrentZoneZ;
                            }
                        }
            //						break;
                    }
                }
                else if (pak is StoC_0xD4_PlayerCreate)
                {
                    if (!fullInfoFound && (pak as StoC_0xD4_PlayerCreate).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (player)";
                        fullInfoFound = true;
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD4_PlayerCreate).ZoneX, (pak as StoC_0xD4_PlayerCreate).ZoneY, (pak as StoC_0xD4_PlayerCreate).ZoneZ, (ushort)(pak as StoC_0xD4_PlayerCreate).ZoneId);
                    }
                }
                else if (pak is StoC_0x4B_PlayerCreate_172)
                {
                    if (!fullInfoFound && (pak as StoC_0x4B_PlayerCreate_172).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (player)";
                        fullInfoFound = true;
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0x4B_PlayerCreate_172).ZoneX, (pak as StoC_0x4B_PlayerCreate_172).ZoneY, (pak as StoC_0x4B_PlayerCreate_172).ZoneZ, (pak as StoC_0x4B_PlayerCreate_172).ZoneId);
                    }
                }
                else if (pak is StoC_0xDA_NpcCreate)
                {
                    if (!fullInfoFound && !flagPacketMobCreate && (pak as StoC_0xDA_NpcCreate).Oid == objectId)
                    {
                        flagPacketMobCreate = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (NPC)";
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xDA_NpcCreate).X, (pak as StoC_0xDA_NpcCreate).Y, (pak as StoC_0xDA_NpcCreate).Z);
            //						fullInfoFound = true; // need find 0x20 for get gloc region
                    }
                }
                else if (pak is StoC_0xD9_ItemDoorCreate)
                {
                    if (!fullInfoFound && !flagPacketItem && (pak as StoC_0xD9_ItemDoorCreate).Oid == objectId)
                    {
                        flagPacketItem = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        if ((pak as StoC_0xD9_ItemDoorCreate).ExtraBytes == 4)
                            objectType = " (Door)";
                        else
                            objectType = " (Object)";
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD9_ItemDoorCreate).X, (pak as StoC_0xD9_ItemDoorCreate).Y, (pak as StoC_0xD9_ItemDoorCreate).Z);
            //						fullInfoFound = true; // need find 0x20 for get gloc region
                    }
                }
                else if (pak is StoC_0x12_CreateMovingObject)
                {
                    if (!fullInfoFound && (pak as StoC_0x12_CreateMovingObject).ObjectOid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (MovingObject)";
                        fullInfoFound = true;
                    }
                }
                else if (pak is StoC_0xC8_PlayerRide) // show object if rided
                {
                    if (!fullInfoFound && !flagPacketRide && (pak as StoC_0xC8_PlayerRide).RiderOid == objectId)
                    {
                        flagPacketRide = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                    else if ((pak as StoC_0xC8_PlayerRide).MountOid == objectId)
                    {
                        if (ObjectsOnMount == null)
                            ObjectsOnMount = new Hashtable();
                        if (!ObjectsOnMount.ContainsKey((pak as StoC_0xC8_PlayerRide).Slot))
                        {
                            ObjectsOnMount.Add((pak as StoC_0xC8_PlayerRide).Slot, (ushort)(pak as StoC_0xC8_PlayerRide).RiderOid);
                            str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        }
                    }
                }
                else if (pak is StoC_0x15_EquipmentUpdate)
                {
                    if (!fullInfoFound && !flagPacketEquip && (pak as StoC_0x15_EquipmentUpdate).Oid == objectId)
                    {
                        flagPacketEquip = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0xEE_NpcChangeProperties)
                {
                    if (!fullInfoFound && (pak as StoC_0xEE_NpcChangeProperties).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0xDE_SetObjectGuildId)
                {
                    if (!fullInfoFound && !flagPacketGuild && (pak as StoC_0xDE_SetObjectGuildId).Oid == objectId)
                    {
                        flagPacketGuild = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0xA1_NpcUpdate)
                {
                    if (!fullInfoFound && !flagPacketMove && (pak as StoC_0xA1_NpcUpdate).NpcOid == objectId)
                    {
                        flagPacketMove = true;
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xA1_NpcUpdate).CurrentZoneX, (pak as StoC_0xA1_NpcUpdate).CurrentZoneY, (pak as StoC_0xA1_NpcUpdate).CurrentZoneZ, (pak as StoC_0xA1_NpcUpdate).CurrentZoneId);
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x81_ShowDialog)
                {
                    if (!fullInfoFound && !flagPacketDialog && (pak as StoC_0x81_ShowDialog).ObjectIds != null && (pak as StoC_0x81_ShowDialog).ObjectIds.Length > 0 && (pak as StoC_0x81_ShowDialog).ObjectIds[0] == objectId)
                    {
                        flagPacketDialog = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0xA9_PlayerPosition)
                {
                    if (!flagPacketMove && (pak as StoC_0xA9_PlayerPosition).SessionId == sessionId)
                    {
                        if (!fullInfoFound)
                        {
                            flagPacketMove = true;
                            if (lastObjectCoords == null)
                                lastObjectCoords = new LocalCoords((pak as StoC_0xA9_PlayerPosition).CurrentZoneX, (pak as StoC_0xA9_PlayerPosition).CurrentZoneY, (pak as StoC_0xA9_PlayerPosition).CurrentZoneZ, (pak as StoC_0xA9_PlayerPosition).CurrentZoneId);
                        }
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x88_PetWindowUpdate)
                {
                    if (!fullInfoFound && !flagPacketPet && (pak as StoC_0x88_PetWindowUpdate).PetId == objectId)
                    {
                        flagPacketPet = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x4C_VisualEffect)
                {
                    if (!fullInfoFound && !flagVisualEffect && (pak as StoC_0x4C_VisualEffect).Oid == objectId)
                    {
                        flagVisualEffect = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is CtoS_0xA9_PlayerPosition)
                {
                    if (flagAllowGetFirstSelfCoords)
                    {
                        if (firstSelfCoords == null)
                        {
                            firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF);
                        }
                        else
                        {
                            firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX;
                            firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY;
                            firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ;
                        }
                    }

                    if (lastSelfCoords == null)
                    {
                        lastSelfCoords = pak as CtoS_0xA9_PlayerPosition;
                    }
                }
                else if (pak is CtoS_0xBE_NpcCreationRequest)
                {
                    if (!flagPacketCreationRequest && (pak as CtoS_0xBE_NpcCreationRequest).NpcOid == objectId)
                    {
                        flagPacketCreationRequest = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x69_KeepOverview)
                {
                    if ((pak as StoC_0x69_KeepOverview).KeepId == keepId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0x69_KeepOverview).KeepX, (pak as StoC_0x69_KeepOverview).KeepY);
                    }
                }
                else if (pak is StoC_0x61_KeepRepair)
                {
                    if (!fullInfoFound && (pak as StoC_0x61_KeepRepair).KeepId == keepId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x62_KeepClaim)
                {
                    if (!fullInfoFound && (pak as StoC_0x62_KeepClaim).KeepId == keepId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x67_KeepUpdate)
                {
                    if (!fullInfoFound && (pak as StoC_0x67_KeepUpdate).KeepId == keepId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is StoC_0x6C_KeepComponentOverview)
                {
                    if (!fullInfoFound && (pak as StoC_0x6C_KeepComponentOverview).KeepId == keepId)
            //					if (!fullInfoFound && (pak as StoC_0x6C_KeepComponentOverview).Uid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (KeepComponent)";
            //						fullInfoFound = true;
                    }
                }
                else if (pak is StoC_0xBC_CombatAnimation)
                {
                    if (!fullInfoFound && !flagPacketCombatAnimation && ((pak as StoC_0xBC_CombatAnimation).AttackerOid == objectId || (pak as StoC_0xBC_CombatAnimation).DefenderOid == objectId))
                    {
                        flagPacketCombatAnimation = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else
                {
                    if (pak is IObjectIdPacket)  // all other packet's with OID
                    {
                        if (!(fullInfoFound || flagPacketMobCreate || flagPacketItem)) // not show packet's before creation object packet
                        {
                            if ((pak.Direction == ePacketDirection.ServerToClient && !m_packetsBitArrayStoC[pak.Code]) ||
                                (pak.Direction == ePacketDirection.ClientToServer && !m_packetsBitArrayCtoS[pak.Code]))
                            {
                                ushort[] objectIds = (pak as IObjectIdPacket).ObjectIds;
                                if (objectIds != null && objectIds.Length > 0)
                                {
                                    for (int j = 0; j < objectIds.Length; j++)
                                    {
                                        if (objectIds[j] > 0 && objectIds[j] == objectId)
                                        {
                                            str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                                            if (pak.Direction == ePacketDirection.ServerToClient)
                                                m_packetsBitArrayStoC[pak.Code] = true;
                                            else if (pak.Direction == ePacketDirection.ClientToServer)
                                                m_packetsBitArrayCtoS[pak.Code] = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                // if we found object creation packets and both coords (self and object) then break;
                // if we found object creation packets but not find any coords break after maxPacketsLookBackForGetCoords look back
                if (fullInfoFound && ((lastObjectCoords != null && lastSelfCoords != null) || maxPacketsLookBackForGetCoords <= 0))
                    break;
            }
            //			if (!fullInfoFound)
            //				str.Insert(0, "No more info found\n");
            // TODO add zone checks... (mb recalc in global coords if zones is different ?)
            {
                if (regionGlobalCoords != null)
                    str.Insert(0, string.Format("regionGlobalCoords (x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY));
                if (firstSelfCoords != null)
                    str.Insert(0, string.Format("firstSelfCoords (x:{0} y:{1})\n", firstSelfCoords.CurrentZoneX, firstSelfCoords.CurrentZoneY));
                if (lastSelfCoords != null)
                    str.Insert(0, string.Format("lastSelfCoords (x:{0} y:{1})\n", lastSelfCoords.CurrentZoneX, lastSelfCoords.CurrentZoneY));
                if (lastObjectCoords != null)
                    str.Insert(0, string.Format("lastObjectCoords (x:{0} y:{1})\n", lastObjectCoords.CurrentZoneX, lastObjectCoords.CurrentZoneY));
            }
            if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId)
            {
                long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (loc/loc)\n", range));
            }
            else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null) /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = 0;
                if (lastObjectCoords.CurrentZoneZ != 0xFFFF)
                {
                    zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                }
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (loc/gloc)\n", range));
                str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY));
            }
            else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF) /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = 0;
                if (lastObjectCoords.CurrentZoneZ != 0xFFFF)
                {
                    zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                }
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc/gloc)\n", range));
            }
            if (objectId != 0xFFFF)
                str.Insert(0, string.Format("\nobjectId:0x{0:X4}{1}\n", objectId, objectType));
            return str.ToString();
        }
        private string MakeOidInfo(PacketLog log, int selectedIndex, ushort objectId, ushort sessionId)
        {
            StringBuilder str = new StringBuilder();
            int maxPacketsLookBackForGetCoords = 50; // look back in log max 30 packets for find coords after found obejct creation packet
            bool fullInfoFound = false;
            bool flagPacketMove = false;
            bool flagPacketItem = false;
            bool flagPacketRide = false;
            bool flagPacketEquip = false;
            bool flagPacketGuild = false;
            bool flagPacketPet = false;
            bool flagPacketDialog = false;
            bool flagVisualEffect = false;
            bool flagPacketMobCreate = false;
            CtoS_0xA9_PlayerPosition lastSelfCoords = null;
            LocalCoords lastObjectCoords = null;
            LocalCoords regionGlobalCoords = null;
            LocalCoords firstSelfCoords = null;
            //			Packet lastObjectCoords = null;
            string objectType = "";
            for (int i = selectedIndex; i >= 0; i--)
            {
                Packet pak = log[i];
                if (fullInfoFound)
                    maxPacketsLookBackForGetCoords--;
                if (pak is StoC_0x20_PlayerPositionAndObjectID) // stop scanning packets on enter region
                {
                    if ((pak as StoC_0x20_PlayerPositionAndObjectID).PlayerOid == objectId)
                        objectType = " (Self)";
            //					str.Insert(0, pak.ToHumanReadableString(TimeSpan(0), true) + '\n');
                    regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z);
                    break;
                }
                else if (!fullInfoFound && pak is StoC_0xD4_PlayerCreate)
                {
                    if ((pak as StoC_0xD4_PlayerCreate).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (player)";
                        fullInfoFound = true;
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD4_PlayerCreate).ZoneX, (pak as StoC_0xD4_PlayerCreate).ZoneY, (pak as StoC_0xD4_PlayerCreate).ZoneZ, (ushort)(pak as StoC_0xD4_PlayerCreate).ZoneId);
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x4B_PlayerCreate_172)
                {
                    if ((pak as StoC_0x4B_PlayerCreate_172).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (player)";
                        fullInfoFound = true;
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0x4B_PlayerCreate_172).ZoneX, (pak as StoC_0x4B_PlayerCreate_172).ZoneY, (pak as StoC_0x4B_PlayerCreate_172).ZoneZ, (pak as StoC_0x4B_PlayerCreate_172).ZoneId);
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xDA_NpcCreate)
                {
                    if (!flagPacketMobCreate && (pak as StoC_0xDA_NpcCreate).Oid == objectId)
                    {
                        flagPacketMobCreate = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (NPC)";
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xDA_NpcCreate).X, (pak as StoC_0xDA_NpcCreate).Y, (pak as StoC_0xDA_NpcCreate).Z);
            //						fullInfoFound = true; // need find 0x20 for get gloc region
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x6C_KeepComponentOverview)
                {
                    if ((pak as StoC_0x6C_KeepComponentOverview).Uid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (KeepComponent)";
                        fullInfoFound = true;
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xD9_ItemDoorCreate)
                {
                    if (!flagPacketItem && (pak as StoC_0xD9_ItemDoorCreate).Oid == objectId)
                    {
                        flagPacketItem = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        if ((pak as StoC_0xD9_ItemDoorCreate).ExtraBytes == 4)
                            objectType = " (Door)";
                        else
                            objectType = " (Object)";
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD9_ItemDoorCreate).X, (pak as StoC_0xD9_ItemDoorCreate).Y, (pak as StoC_0xD9_ItemDoorCreate).Z);
            //						fullInfoFound = true; // need find 0x20 for get gloc region
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x12_CreateMovingObject)
                {
                    if ((pak as StoC_0x12_CreateMovingObject).ObjectOid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (MovingObject)";
                        fullInfoFound = true;
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xC8_PlayerRide) // show object if rided
                {
                    if (!flagPacketRide && (pak as StoC_0xC8_PlayerRide).RiderOid == objectId)
                    {
                        flagPacketRide = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                    else if ((pak as StoC_0xC8_PlayerRide).MountOid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x15_EquipmentUpdate)
                {
                    if (!flagPacketEquip && (pak as StoC_0x15_EquipmentUpdate).Oid == objectId)
                    {
                        flagPacketEquip = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xEE_NpcChangeProperties)
                {
                    if ((pak as StoC_0xEE_NpcChangeProperties).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xDE_SetObjectGuildId)
                {
                    if (!flagPacketGuild && (pak as StoC_0xDE_SetObjectGuildId).Oid == objectId)
                    {
                        flagPacketGuild = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xA1_NpcUpdate)
                {
                    if (!flagPacketMove && (pak as StoC_0xA1_NpcUpdate).NpcOid == objectId)
                    {
                        flagPacketMove = true;
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xA1_NpcUpdate).CurrentZoneX, (pak as StoC_0xA1_NpcUpdate).CurrentZoneY, (pak as StoC_0xA1_NpcUpdate).CurrentZoneZ, (pak as StoC_0xA1_NpcUpdate).CurrentZoneId);
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x81_ShowDialog)
                {
                    if (!flagPacketDialog && (pak as StoC_0x81_ShowDialog).ObjectIds != null && (pak as StoC_0x81_ShowDialog).ObjectIds.Length > 0 && (pak as StoC_0x81_ShowDialog).ObjectIds[0] == objectId)
                    {
                        flagPacketDialog = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xA9_PlayerPosition)
                {
                    if (!flagPacketMove && (pak as StoC_0xA9_PlayerPosition).SessionId == sessionId)
                    {
                        flagPacketMove = true;
                        if (lastObjectCoords == null)
                            lastObjectCoords = new LocalCoords((pak as StoC_0xA9_PlayerPosition).CurrentZoneX, (pak as StoC_0xA9_PlayerPosition).CurrentZoneY, (pak as StoC_0xA9_PlayerPosition).CurrentZoneZ, (pak as StoC_0xA9_PlayerPosition).CurrentZoneId);
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x88_PetWindowUpdate)
                {
                    if (!flagPacketPet && (pak as StoC_0x88_PetWindowUpdate).PetId == objectId)
                    {
                        flagPacketPet = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x4C_VisualEffect)
                {
                    if (!flagVisualEffect && (pak as StoC_0x4C_VisualEffect).Oid == objectId)
                    {
                        flagVisualEffect = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is CtoS_0xA9_PlayerPosition)
                {
                    if (firstSelfCoords == null)
                    {
                        firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF);
                    }
                    else
                    {
                        firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX;
                        firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY;
                        firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ;
                    }

                    if (lastSelfCoords == null)
                    {
                        lastSelfCoords = pak as CtoS_0xA9_PlayerPosition;
                    }
                }
                // if we found object creation packets and both coords (self and object) then break;
                // if we found object creation packets but not find any coords break after maxPacketsLookBackForGetCoords look back
                if (fullInfoFound && ((lastObjectCoords != null && lastSelfCoords != null) || maxPacketsLookBackForGetCoords <= 0))
                    break;
            }
            if (!fullInfoFound)
                str.Insert(0, "No more info found\n");
            // TODO add zone checks... (mb recalc in global coords if zones is different ?)
            if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId)
            {
                long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (loc)\n", range));
            }
            else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null) /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc)\n", range));
            //				str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY));
            }
            else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF) /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc)\n", range));
            }
            str.Insert(0, string.Format("\nobjectId:0x{0:X4}{1}\n", objectId, objectType));
            return str.ToString();
        }
Beispiel #11
0
        public BaseShip this [int q, int x, int y]
        {
            get
            {
                ValidateQuadrant(q);

                for (int i = 0; i < coords.Count; i++)
                {
                    if (coords[i].X == x && coords[i].Y == y)
                    {
                        return(ships[i]);
                    }
                }

                return(null);
            }
            set
            {
                ValidateQuadrant(q);
                var coord       = new LocalCoords(Guid.NewGuid().ToString(), Id, this, q, x, y);
                var globalCoord = ConvertToGlobal(coord);
                var Coordslist  = new List <GlobalCoords>();
                for (int i = 0; i < value.Length; i++)
                {
                    switch (ReversDirection(value.Direction))
                    {
                    case 180:
                        globalCoord.X -= 1;
                        break;

                    case 0:
                        globalCoord.X += 1;
                        break;

                    case 90:
                        globalCoord.Y += 1;
                        break;

                    case 270:
                        globalCoord.Y -= 1;
                        break;
                    }

                    if (CoordsIsValid(globalCoord))
                    {
                        Coordslist.Add(globalCoord);
                    }
                    else
                    {
                        throw new Exception("Ship leavs borders or crosses another borad");
                    }
                }

                foreach (var item in Coordslist)
                {
                    gameField[item.X, item.Y] = 1;
                }

                coords.Add(coord);
                ships.Add(value);
                for (int i = 0; i < length; i++)
                {
                    for (int j = 0; j < length; j++)
                    {
                        Console.Write(gameField[j, i] + " ");
                    }
                    Console.WriteLine("");
                }
            }
        }
Beispiel #12
0
 public void Move(LocalCoords coords)
 {
     coords.X += Speed * (int)Math.Round(Math.Cos((double)Direction / 180.0 * Math.PI));
     coords.Y += Speed * (int)Math.Round(Math.Sin((double)Direction / 180.0 * Math.PI));
 }
        private string MakeOidInfo(PacketLog log, int selectedIndex, ushort objectId, ushort sessionId)
        {
            StringBuilder            str = new StringBuilder();
            int                      maxPacketsLookBackForGetCoords = 50; // look back in log max 30 packets for find coords after found obejct creation packet
            bool                     fullInfoFound       = false;
            bool                     flagPacketMove      = false;
            bool                     flagPacketItem      = false;
            bool                     flagPacketRide      = false;
            bool                     flagPacketEquip     = false;
            bool                     flagPacketGuild     = false;
            bool                     flagPacketPet       = false;
            bool                     flagPacketDialog    = false;
            bool                     flagVisualEffect    = false;
            bool                     flagPacketMobCreate = false;
            CtoS_0xA9_PlayerPosition lastSelfCoords      = null;
            LocalCoords              lastObjectCoords    = null;
            LocalCoords              regionGlobalCoords  = null;
            LocalCoords              firstSelfCoords     = null;
//			Packet lastObjectCoords = null;
            string objectType = "";

            for (int i = selectedIndex; i >= 0; i--)
            {
                Packet pak = log[i];
                if (fullInfoFound)
                {
                    maxPacketsLookBackForGetCoords--;
                }
                if (pak is StoC_0x20_PlayerPositionAndObjectID)                 // stop scanning packets on enter region
                {
                    if ((pak as StoC_0x20_PlayerPositionAndObjectID).PlayerOid == objectId)
                    {
                        objectType = " (Self)";
                    }
//					str.Insert(0, pak.ToHumanReadableString(TimeSpan(0), true) + '\n');
                    regionGlobalCoords = new LocalCoords((pak as StoC_0x20_PlayerPositionAndObjectID).X, (pak as StoC_0x20_PlayerPositionAndObjectID).Y, (pak as StoC_0x20_PlayerPositionAndObjectID).Z);
                    break;
                }
                else if (!fullInfoFound && pak is StoC_0xD4_PlayerCreate)
                {
                    if ((pak as StoC_0xD4_PlayerCreate).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType    = " (player)";
                        fullInfoFound = true;
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD4_PlayerCreate).ZoneX, (pak as StoC_0xD4_PlayerCreate).ZoneY, (pak as StoC_0xD4_PlayerCreate).ZoneZ, (ushort)(pak as StoC_0xD4_PlayerCreate).ZoneId);
                        }
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x4B_PlayerCreate_172)
                {
                    if ((pak as StoC_0x4B_PlayerCreate_172).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType    = " (player)";
                        fullInfoFound = true;
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0x4B_PlayerCreate_172).ZoneX, (pak as StoC_0x4B_PlayerCreate_172).ZoneY, (pak as StoC_0x4B_PlayerCreate_172).ZoneZ, (pak as StoC_0x4B_PlayerCreate_172).ZoneId);
                        }
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xDA_NpcCreate)
                {
                    if (!flagPacketMobCreate && (pak as StoC_0xDA_NpcCreate).Oid == objectId)
                    {
                        flagPacketMobCreate = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType = " (NPC)";
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xDA_NpcCreate).X, (pak as StoC_0xDA_NpcCreate).Y, (pak as StoC_0xDA_NpcCreate).Z);
                        }
//						fullInfoFound = true; // need find 0x20 for get gloc region
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x6C_KeepComponentOverview)
                {
                    if ((pak as StoC_0x6C_KeepComponentOverview).Uid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType    = " (KeepComponent)";
                        fullInfoFound = true;
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xD9_ItemDoorCreate)
                {
                    if (!flagPacketItem && (pak as StoC_0xD9_ItemDoorCreate).Oid == objectId)
                    {
                        flagPacketItem = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        if ((pak as StoC_0xD9_ItemDoorCreate).ExtraBytes == 4)
                        {
                            objectType = " (Door)";
                        }
                        else
                        {
                            objectType = " (Object)";
                        }
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xD9_ItemDoorCreate).X, (pak as StoC_0xD9_ItemDoorCreate).Y, (pak as StoC_0xD9_ItemDoorCreate).Z);
                        }
//						fullInfoFound = true; // need find 0x20 for get gloc region
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x12_CreateMovingObject)
                {
                    if ((pak as StoC_0x12_CreateMovingObject).ObjectOid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                        objectType    = " (MovingObject)";
                        fullInfoFound = true;
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xC8_PlayerRide)                 // show object if rided
                {
                    if (!flagPacketRide && (pak as StoC_0xC8_PlayerRide).RiderOid == objectId)
                    {
                        flagPacketRide = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                    else if ((pak as StoC_0xC8_PlayerRide).MountOid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x15_EquipmentUpdate)
                {
                    if (!flagPacketEquip && (pak as StoC_0x15_EquipmentUpdate).Oid == objectId)
                    {
                        flagPacketEquip = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xEE_NpcChangeProperties)
                {
                    if ((pak as StoC_0xEE_NpcChangeProperties).Oid == objectId)
                    {
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xDE_SetObjectGuildId)
                {
                    if (!flagPacketGuild && (pak as StoC_0xDE_SetObjectGuildId).Oid == objectId)
                    {
                        flagPacketGuild = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xA1_NpcUpdate)
                {
                    if (!flagPacketMove && (pak as StoC_0xA1_NpcUpdate).NpcOid == objectId)
                    {
                        flagPacketMove = true;
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xA1_NpcUpdate).CurrentZoneX, (pak as StoC_0xA1_NpcUpdate).CurrentZoneY, (pak as StoC_0xA1_NpcUpdate).CurrentZoneZ, (pak as StoC_0xA1_NpcUpdate).CurrentZoneId);
                        }
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x81_ShowDialog)
                {
                    if (!flagPacketDialog && (pak as StoC_0x81_ShowDialog).ObjectIds != null && (pak as StoC_0x81_ShowDialog).ObjectIds.Length > 0 && (pak as StoC_0x81_ShowDialog).ObjectIds[0] == objectId)
                    {
                        flagPacketDialog = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0xA9_PlayerPosition)
                {
                    if (!flagPacketMove && (pak as StoC_0xA9_PlayerPosition).SessionId == sessionId)
                    {
                        flagPacketMove = true;
                        if (lastObjectCoords == null)
                        {
                            lastObjectCoords = new LocalCoords((pak as StoC_0xA9_PlayerPosition).CurrentZoneX, (pak as StoC_0xA9_PlayerPosition).CurrentZoneY, (pak as StoC_0xA9_PlayerPosition).CurrentZoneZ, (pak as StoC_0xA9_PlayerPosition).CurrentZoneId);
                        }
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x88_PetWindowUpdate)
                {
                    if (!flagPacketPet && (pak as StoC_0x88_PetWindowUpdate).PetId == objectId)
                    {
                        flagPacketPet = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (!fullInfoFound && pak is StoC_0x4C_VisualEffect)
                {
                    if (!flagVisualEffect && (pak as StoC_0x4C_VisualEffect).Oid == objectId)
                    {
                        flagVisualEffect = true;
                        str.Insert(0, pak.ToHumanReadableString(TimeSpan.Zero, true) + '\n');
                    }
                }
                else if (pak is CtoS_0xA9_PlayerPosition)
                {
                    if (firstSelfCoords == null)
                    {
                        firstSelfCoords = new LocalCoords((pak as CtoS_0xA9_PlayerPosition).CurrentZoneX, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY, (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ, 0xFFFF);
                    }
                    else
                    {
                        firstSelfCoords.CurrentZoneX = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneX;
                        firstSelfCoords.CurrentZoneY = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneY;
                        firstSelfCoords.CurrentZoneZ = (pak as CtoS_0xA9_PlayerPosition).CurrentZoneZ;
                    }

                    if (lastSelfCoords == null)
                    {
                        lastSelfCoords = pak as CtoS_0xA9_PlayerPosition;
                    }
                }
                // if we found object creation packets and both coords (self and object) then break;
                // if we found object creation packets but not find any coords break after maxPacketsLookBackForGetCoords look back
                if (fullInfoFound && ((lastObjectCoords != null && lastSelfCoords != null) || maxPacketsLookBackForGetCoords <= 0))
                {
                    break;
                }
            }
            if (!fullInfoFound)
            {
                str.Insert(0, "No more info found\n");
            }
            // TODO add zone checks... (mb recalc in global coords if zones is different ?)
            if (lastSelfCoords != null && lastObjectCoords != null && lastSelfCoords.CurrentZoneId == lastObjectCoords.CurrentZoneId)
            {
                long xdiff = (long)lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int  range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (loc)\n", range));
            }
            else if (lastSelfCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF && regionGlobalCoords != null && firstSelfCoords != null)             /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)lastSelfCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int  range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc)\n", range));
//				str.Insert(0, string.Format("Your gloc:(x:{0} y:{1})\n", regionGlobalCoords.CurrentZoneX - firstSelfCoords.CurrentZoneX + lastSelfCoords.CurrentZoneX, regionGlobalCoords.CurrentZoneY - firstSelfCoords.CurrentZoneY + lastSelfCoords.CurrentZoneY));
            }
            else if (regionGlobalCoords != null && lastObjectCoords != null && lastObjectCoords.CurrentZoneId == 0xFFFF)             /* gloc Object */
            {
                long xdiff = (long)regionGlobalCoords.CurrentZoneX - lastObjectCoords.CurrentZoneX;
                long ydiff = (long)regionGlobalCoords.CurrentZoneY - lastObjectCoords.CurrentZoneY;
                long zdiff = (long)regionGlobalCoords.CurrentZoneZ - lastObjectCoords.CurrentZoneZ;
                int  range = (int)Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff);
                str.Insert(0, string.Format("range from you:{0} (gloc)\n", range));
            }
            str.Insert(0, string.Format("\nobjectId:0x{0:X4}{1}\n", objectId, objectType));
            return(str.ToString());
        }