Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Gets the packet to update the world list in the lobby.
- * @param player The player.
- * @param worldConfiguration If the configuration should be added.
- * @param worldStatus If the status should be added.
- * @return The {@code OutgoingPacket} to write.
- */
- public static ChannelBuffer getData(boolean worldConfiguration, boolean worldStatus) {
- ChannelBuffer bldr = ChannelBuffers.buffer(1024);
- bldr.writeByte(1);
- bldr.writeByte(2);
- bldr.writeByte(1);
- if (worldConfiguration) {
- populateConfiguration(bldr);
- }
- if (worldStatus) {
- populateStatus(bldr);
- }
- return bldr;
- }
- private static void populateConfiguration(ChannelBuffer buffer) {
- WorldUtilities.getSingleton().putSmart(buffer, worldList.length);
- WorldUtilities.getSingleton().putSmart(buffer, worldList.length);
- setCountry(buffer);
- WorldUtilities.getSingleton().putSmart(buffer, worldList.length + 1);
- WorldUtilities.getSingleton().putSmart(buffer, worldList.length );
- for (RS2WorldList w : worldList) {
- WorldUtilities.getSingleton().putSmart(buffer, w.getWorldId());
- buffer.writeByte(w.getLocation());
- buffer.writeInt(w.getFlag());
- WorldUtilities.getSingleton().putJagString(buffer, w.getActivity());
- WorldUtilities.getSingleton().putJagString(buffer, w.getIp());
- }
- buffer.writeInt(-626474014);
- }
- /**
- * Adds the world status on the packet.
- * @param buffer The current packet.
- */
- private static void populateStatus(ChannelBuffer buffer) {
- for (RS2WorldList w : worldList) {
- WorldUtilities.getSingleton().putSmart(buffer, w.getWorldId());
- buffer.writeShort(5);// players
- }
- }
- /**
- * The country data being written.
- */
- private static void setCountry(ChannelBuffer buffer) {
- for (final RS2WorldList w : worldList) {
- WorldUtilities.getSingleton().putSmart(buffer, w.getCountry());
- WorldUtilities.getSingleton().putJagString(buffer, w.getRegion());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement