Exemplo n.º 1
0
        public void handlePacket(Player player, Packet packet) {
		    int size = packet.getLength();
		    if(packet.getPacketId() == PacketHandlers.PacketId.WALK_2) {
			    size -= 14;
		    }
            player.getWalkingQueue().resetWalkingQueue();
		    int steps = (size - 5) / 2;

            if (steps > WalkingQueue.MAX_WALKING_WAYPOINTS)
            {
                misc.WriteError("Warning: Walk command contains too many steps (" + steps + ") currently set to 50 [maybe need increase?]");
                return;
            }

            player.getWalkingQueue().setIsRunning(packet.readByteA() == 1);
		    bool following = false;
            if (!canWalk(player, packet, following))
            {
                player.getPackets().clearMapFlag();
                player.getWalkingQueue().resetWalkingQueue();
                return;
            }

            int firstX = packet.readUShort() - (player.getLocation().getRegionX() - 6) * 8;
            int firstY = packet.readShortA() - (player.getLocation().getRegionY() - 6) * 8;
		    player.getWalkingQueue().addToWalkingQueue(firstX, firstY);

            for (int i = 0; i < steps; i++) //all the waypoints.
                player.getWalkingQueue().addToWalkingQueue((packet.readByteA() + firstX), (packet.readByteS() + firstY));

            if (player.getTeleportTo() != null) //is teleporting?
                player.getWalkingQueue().resetWalkingQueue();


		    if (player.getTemporaryAttribute("homeTeleporting") != null) {
			    player.removeTemporaryAttribute("homeTeleporting");
		    }
		    SkillHandler.resetAllSkills(player);
		    if (player.getTrade() != null)
			    player.getTrade().decline();
            if (player.getDuel() != null) {
                if (player.getDuel().getStatus() < 4)
                    player.getDuel().declineDuel();
                else if (player.getDuel().getStatus() == 8)
                    player.getDuel().recieveWinnings(player);
            }
			if (player.getTarget() != null) {
				if (!following && player.getTarget().getAttacker() != null && player.getTarget().getAttacker().Equals(player))
					player.getTarget().setAttacker(null);
			}		    
            
            if (!following) {
			    player.getFollow().setFollowing(null);
				player.setTarget(null);
				player.removeTemporaryAttribute("autoCasting");
			    if (player.getEntityFocus() != 65535)
				    player.setEntityFocus(65535);
		    }
		    player.getPackets().closeInterfaces();
	    }
	    public void handlePacket(Player player,  Packet packet) {
		    switch(packet.getPacketId()) {
                case PacketHandlers.PacketId.NPC_FIRST_CLICK:
				    handleFirstClickNPC(player, packet);
				    break;

                case PacketHandlers.PacketId.NPC_SECOND_CLICK:
				    handleSecondClickNPC(player, packet);
				    break;

                case PacketHandlers.PacketId.NPC_THIRD_CLICK:
				    handleThirdClickNPC(player, packet);
				    break;

                case PacketHandlers.PacketId.NPC_FOURTH_CLICK:
				    handleFourthClickNPC(player, packet);
				    return;

                case PacketHandlers.PacketId.NPC_FIFTH_CLICK:
				    handleFifthClickNPC(player, packet);
				    break;

                case PacketHandlers.PacketId.NPC_EXAMINE:
                    handleExamineNPC(player, packet);
                    break;

                case PacketHandlers.PacketId.MAGIC_ON_NPC:
				    handleMagicOnNPC(player, packet);
				    break;

                case PacketHandlers.PacketId.ITEM_ON_NPC:
				    handleItemOnNPC(player, packet);
				    break;
		    }
	    }
	    public void handlePacket(Player player, Packet packet) {
		    switch(packet.getPacketId()) {
			    case PacketHandlers.PacketId.OBJECT_FIRST_CLICK:
				    handleFirstClickObject(player, packet);
				    break;
				
			    case PacketHandlers.PacketId.OBJECT_SECOND_CLICK:
				    handleSecondClickObject(player, packet);
				    break;
				
			    case PacketHandlers.PacketId.OBJECT_THIRD_CLICK:
				    handleThirdClickObject(player, packet);
				    break;
				
			    case PacketHandlers.PacketId.OBJECT_FOURTH_CLICK:
				    handleFourthClickObject(player, packet);
				    break;
                case PacketHandlers.PacketId.OBJECT_FIFTH_CLICK:
                    handleFifthClickObject(player, packet);
                    break;

                case PacketHandlers.PacketId.OBJECT_EXAMINE:
                    handleExamineObject(player, packet);
                    break;
		    }
	    }
	    public void handlePacket(Player player, Packet packet) {
		    switch(packet.getPacketId()) {
                case PacketHandlers.PacketId.EQUIP:
				    handleEquipItem(player, packet);
				    break;

                case PacketHandlers.PacketId.ITEM_ON_ITEM:
				    handleItemOnItem(player, packet);
				    break;

                case PacketHandlers.PacketId.INV_CLICK:
				    handleInvenClickItem(player, packet);
				    break;

                case PacketHandlers.PacketId.ITEM_ON_OBJECT:
				    handleItemOnObject(player, packet);
				    break;

                case PacketHandlers.PacketId.ITEM_ON_GROUND_ITEM:
                    handleItemOnGroundItem(player, packet);
                    break;

                case PacketHandlers.PacketId.INV_OPERATE:
				    handleOperateItem(player, packet);
				    break;

                case PacketHandlers.PacketId.INV_DROP:
				    handleDropItem(player, packet);
				    break;

                case PacketHandlers.PacketId.PICKUP:
				    handlePickupItem(player, packet);
				    break;

                case PacketHandlers.PacketId.INV_SWAP_SLOT:
				    handleSwapSlot(player, packet);
				    break;

                case PacketHandlers.PacketId.INV_SWAP_SLOT2:
				    handleSwapSlot2(player, packet);
				    break;

                case PacketHandlers.PacketId.INV_RIGHT_CLICK_OPTION1:
				    handleRightClickOne(player, packet);
				    break;

                case PacketHandlers.PacketId.INV_RIGHT_CLICK_OPTION2:
				    handleRightClickTwo(player, packet);
				    break;

                case PacketHandlers.PacketId.INV_EXAMINE_ITEM:
				    handleExamineItem(player, packet);
				    break;

                case PacketHandlers.PacketId.INV_EXAMINE_ITEM_GE:
                    handleExamineItemGE(player, packet);
                    break;
		    }
	    }
	    public void handlePacket(Player player, Packet packet) {
            switch (packet.getPacketId())
            {
			    case PacketHandlers.PacketId.ENTER_AMOUNT:
				    handleEnterAmount(player, packet);
				    break;

                case PacketHandlers.PacketId.ENTER_TEXT:
				    handleEnterText(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_1:
				    handleClickOne(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_2:
				    handleClickTwo(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_3:
				    handleClickThree(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_4:
				    handleClickFour(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_5:
				    handleClickFive(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_6:
				    handleClickSix(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_7:
				    handleClickSeven(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_8:
				    handleClickEight(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_9:
				    handleClickNine(player, packet);
				    break;

                case PacketHandlers.PacketId.INTERFACE_CLICK_10:
				    handleClickTen(player, packet);
				    break;

                case PacketHandlers.PacketId.GE_SEARCH:
				    handleGeSearch(player, packet);
				    break;
		    }
	    }
	    public void handlePacket(Player player, Packet packet) {
            switch (packet.getPacketId())
            {
                case PacketHandlers.PacketId.CLOSE:
				    handleCloseButton(player, packet);
				    break;

                case PacketHandlers.PacketId.ACTIONBUTTON:
                case PacketHandlers.PacketId.ACTIONBUTTON2:
				    handleActionButton(player, packet);
				    break;

                case PacketHandlers.PacketId.ACTIONBUTTON3:
				    handleActionButton3(player, packet);
				    break;
		    }
	    }
	    public void handlePacket(Player player, Packet packet) {
		    switch(packet.getPacketId()) {
                case PacketHandlers.PacketId.IDLE:
                case PacketHandlers.PacketId.MOVE_CAMERA:
                case PacketHandlers.PacketId.PING:
                    player.getConnection().setPinged();
                    break;
                case PacketHandlers.PacketId.FOCUS:
                case PacketHandlers.PacketId.CLICK_MOUSE:
                case PacketHandlers.PacketId.SOUND_SETTINGS:
				    break;

                case PacketHandlers.PacketId.WINDOW_TYPE:
				    handleScreenSettings(player, packet);
				    break;
		    }
		
	    }
	    public void handlePacket(Player player, Packet packet) {
		    switch(packet.getPacketId()) {
                case PacketHandlers.PacketId.PUBLIC:
				    handlePublicChat(player, packet);
				    break;

                case PacketHandlers.PacketId.CLAN_CHAT:
				    handleClanChat(player, packet);
				    break;

                case PacketHandlers.PacketId.ADD_FRIEND:
				    handleAddFriend(player, packet);
				    break;

                case PacketHandlers.PacketId.DELETE_FRIEND:
				    handleDeleteFriend(player, packet);
				    break;

                case PacketHandlers.PacketId.ADD_IGNORE:
				    handleAddIgnore(player, packet);
				    break;

                case PacketHandlers.PacketId.DELETE_IGNORE:
				    handleDeleteIgnore(player, packet);
				    break;

                case PacketHandlers.PacketId.SEND_PM:
				    handleSendPm(player, packet);
				    break;

                case PacketHandlers.PacketId.CLAN_RANKS:
				    handleClanRanks(player, packet);
				    break;

                case PacketHandlers.PacketId.CLAN_KICK:
				    handleClanKick(player, packet);
				    break;

                case PacketHandlers.PacketId.PRIVACY_SETTINGS:
				    handlePrivacySettings(player, packet);
				    break;
		    }
	    }
	    public void handlePacket(Player player, Packet packet) {
		    switch(packet.getPacketId()) {
			    case PacketHandlers.PacketId.ATTACK_PLAYER:
				    handleAttackPlayer(player, packet);
				    break;
				
			    case PacketHandlers.PacketId.FOLLOW:
				    handleFollowPlayer(player, packet);
				    break;
				
			    case PacketHandlers.PacketId.TRADE:
				    handleTradePlayer(player, packet);
				    break;
				
			    case PacketHandlers.PacketId.MAGIC_ON_PLAYER:
				    handleMagicOnPlayer(player, packet);
				    break;
		    }
	    }
 /**
  * Handles a packet.
  * @param session
  * @param p
  */
 public static void handlePacket(Player player, Packet p)
 {
     if (p.getSize() != Packet.Size.Bare) {
         PacketHandler handler = null;
         if (handlers.TryGetValue(p.getPacketId(), out handler))
             handler.handlePacket(player, p);  
         else
             misc.WriteError("Unhandled packet: " + p + ".");
         //if(p.getId() != 93 && p.getId() != 75 && p.getId() != 22)
         //Console.WriteLine(p.ToString());
     }
 }