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(); }
private void handleClanRanks(Player player, Packet packet) { int rank = packet.readByteA(); long name = packet.readLong(); if (name < 0 || (rank < 0 || rank > 6)) { return; } Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername()); if (clan != null) { ClanUser user = clan.getUserByName(misc.longToPlayerName(name)); if (user != null) { user.setClanRights((Clan.ClanRank)rank); Server.getClanManager().updateClan(clan); } Clan.ClanRank userExists; if (clan.getUsersWithRank().TryGetValue(misc.longToPlayerName(name), out userExists)) clan.getUsersWithRank()[misc.longToPlayerName(name)] = (Clan.ClanRank)rank; //Exists already, so altar. else clan.getUsersWithRank().Add(misc.longToPlayerName(name), (Clan.ClanRank)rank); //Not existed yet. so add } }