Advertisement
Tyluur

Untitled

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