Пример #1
0
        public void sendMapRegion()
        {
            player.getUpdateFlags().setLastRegion((Location)player.getLocation().Clone());
            if (player.getLocation().getX() >= 19000)
            {
                sendFightCaveMapdata();
                return;
            }
            PacketBuilder pb        = new PacketBuilder().setId(162).setSize(Packet.Size.VariableShort);
            bool          forceSend = true;

            if (((((player.getLocation().getRegionX() / 8) == 48) || ((player.getLocation().getRegionX() / 8) == 49)) && ((player.getLocation().getRegionY() / 8) == 48)) ||
                (((player.getLocation().getRegionX() / 8) == 48) && ((player.getLocation().getRegionY() / 8) == 148)))
            {
                forceSend = false;
            }
            pb.addShortA(player.getLocation().getLocalX());

            for (int xCalc = (player.getLocation().getRegionX() - 6) / 8; xCalc <= ((player.getLocation().getRegionX() + 6) / 8); xCalc++)
            {
                for (int yCalc = (player.getLocation().getRegionY() - 6) / 8; yCalc <= ((player.getLocation().getRegionY() + 6) / 8); yCalc++)
                {
                    int region = yCalc + (xCalc << 8);
                    if (forceSend || ((yCalc != 49) && (yCalc != 149) && (yCalc != 147) && (xCalc != 50) && ((xCalc != 49) || (yCalc != 47))))
                    {
                        int[] mapData = MapData.getData(region);
                        if (mapData == null)
                        {
                            pb.addInt2(0);
                            pb.addInt2(0);
                            pb.addInt2(0);
                            pb.addInt2(0);
                        }
                        else
                        {
                            pb.addInt2(mapData[0]);
                            pb.addInt2(mapData[1]);
                            pb.addInt2(mapData[2]);
                            pb.addInt2(mapData[3]);
                        }
                    }
                }
            }
            pb.addByteS(player.getLocation().getZ());
            pb.addUShort(player.getLocation().getRegionX());
            pb.addShortA(player.getLocation().getRegionY());
            pb.addShortA(player.getLocation().getLocalY());
            connection.SendPacket(pb.toPacket());
            Server.getGroundItems().refreshGlobalItems(player);
            Server.getGlobalObjects().refreshGlobalObjects(player);
        }
Пример #2
0
 private static void appendGraphicsUpdate(Player p, PacketBuilder updateBlock)
 {
     updateBlock.addLEShort(p.getLastGraphics().getId());
     updateBlock.addInt2(p.getLastGraphics().getHeight() << 16 + p.getLastGraphics().getDelay());
 }
Пример #3
0
 private static void appendGraphicsUpdate(Player p, PacketBuilder updateBlock)
 {
     updateBlock.addLEShort(p.getLastGraphics().getId());
     updateBlock.addInt2(p.getLastGraphics().getHeight() << 16 + p.getLastGraphics().getDelay());
 }
Пример #4
0
        public void sendFightCaveMapdata()
        {
            lastX = lastX == 0 ? 2413 : (player.getLocation().getX() - (20000 + (200 * player.getIndex())));
            lastY = lastY == 0 ? 5116 : (player.getLocation().getY() - 20000);
            PacketBuilder pb = new PacketBuilder().setId(214).setSize(Packet.Size.VariableShort);

            pb.addUShortA(player.getLocation().getLocalX());
            pb.addUShortA(player.getLocation().getRegionX());
            pb.addByteS(player.getLocation().getZ());
            pb.addUShortA(player.getLocation().getLocalY());
            pb.initBitAccess();
            for (int height = 0; height < 4; height++)
            {
                for (int xCalc = ((lastX >> 3) - 6); xCalc <= ((lastX >> 3) + 6); xCalc++)
                {
                    for (int yCalc = ((lastY >> 3) - 6); yCalc <= ((lastY >> 3) + 6); yCalc++)
                    {
                        int region = yCalc / 8 + (xCalc / 8 << 8);
                        if (height == player.getLocation().getZ() && region == 9551)
                        {
                            pb.addBits(1, 1);
                            pb.addBits(26, (xCalc << 14) | (yCalc << 3) | (0 << 1) | (0 << 24));
                        }
                        else
                        {
                            pb.addBits(1, 0);
                        }
                    }
                }
            }
            pb.finishBitAccess();
            int[] sent      = new int[4 * 13 * 13];
            int   sentIndex = 0;

            for (int xCalc = (((lastX >> 3) - 6) / 8); xCalc <= (((lastX >> 3) + 6) / 8); xCalc++)
            {
outer:
                for (int yCalc = (((lastY >> 3) - 6) / 8); yCalc <= (((lastY >> 3) + 6) / 8); yCalc++)
                {
                    int region = yCalc + (xCalc << 8);
                    if (region != 9551)
                    {
                        continue;
                    }
                    for (int i = 0; i < sentIndex; i++)
                    {
                        if (sent[i] == region)
                        {
                            goto outer;
                        }
                    }
                    sent[sentIndex] = region;
                    sentIndex++;
                    int[] mapData = MapData.getData(region);
                    if (mapData == null)
                    {
                        pb.addInt2(0);
                        pb.addInt2(0);
                        pb.addInt2(0);
                        pb.addInt2(0);
                    }
                    else
                    {
                        pb.addInt2(mapData[0]);
                        pb.addInt2(mapData[1]);
                        pb.addInt2(mapData[2]);
                        pb.addInt2(mapData[3]);
                    }
                }
            }
            pb.addUShort(player.getLocation().getRegionY());
            connection.SendPacket(pb.toPacket());
        }