Advertisement
Tyluur

Untitled

Jul 2nd, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1.  
  2. /**
  3. * Gets the packet to update the world list in the lobby.
  4. * @param player The player.
  5. * @param worldConfiguration If the configuration should be added.
  6. * @param worldStatus If the status should be added.
  7. * @return The {@code OutgoingPacket} to write.
  8. */
  9. public static ChannelBuffer getData(boolean worldConfiguration, boolean worldStatus) {
  10. ChannelBuffer bldr = ChannelBuffers.buffer(1024);
  11. bldr.writeByte(1);
  12. bldr.writeByte(2);
  13. bldr.writeByte(1);
  14. if (worldConfiguration) {
  15. populateConfiguration(bldr);
  16. }
  17. if (worldStatus) {
  18. populateStatus(bldr);
  19. }
  20. return bldr;
  21. }
  22.  
  23. private static void populateConfiguration(ChannelBuffer buffer) {
  24. WorldUtilities.getSingleton().putSmart(buffer, worldList.length);
  25. WorldUtilities.getSingleton().putSmart(buffer, worldList.length);
  26. setCountry(buffer);
  27. WorldUtilities.getSingleton().putSmart(buffer, worldList.length + 1);
  28. WorldUtilities.getSingleton().putSmart(buffer, worldList.length );
  29. for (RS2WorldList w : worldList) {
  30. WorldUtilities.getSingleton().putSmart(buffer, w.getWorldId());
  31. buffer.writeByte(w.getLocation());
  32. buffer.writeInt(w.getFlag());
  33. WorldUtilities.getSingleton().putJagString(buffer, w.getActivity());
  34. WorldUtilities.getSingleton().putJagString(buffer, w.getIp());
  35. }
  36. buffer.writeInt(-626474014);
  37. }
  38.  
  39. /**
  40. * Adds the world status on the packet.
  41. * @param buffer The current packet.
  42. */
  43. private static void populateStatus(ChannelBuffer buffer) {
  44. for (RS2WorldList w : worldList) {
  45. WorldUtilities.getSingleton().putSmart(buffer, w.getWorldId());
  46. buffer.writeShort(5);// players
  47. }
  48. }
  49.  
  50. /**
  51. * The country data being written.
  52. */
  53. private static void setCountry(ChannelBuffer buffer) {
  54. for (final RS2WorldList w : worldList) {
  55. WorldUtilities.getSingleton().putSmart(buffer, w.getCountry());
  56. WorldUtilities.getSingleton().putJagString(buffer, w.getRegion());
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement