Guest User

Untitled

a guest
Mar 5th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. package com.rs.cache.loaders;
  2.  
  3. import java.io.IOException;
  4. import java.util.concurrent.ConcurrentHashMap;
  5.  
  6. import com.rs.cache.Cache;
  7. import com.rs.io.InputStream;
  8.  
  9. public final class VarBitDefinitions {
  10.  
  11. private static final ConcurrentHashMap<Integer, VarBitDefinitions> varpbitDefs = new ConcurrentHashMap<Integer, VarBitDefinitions>();
  12.  
  13. public int id;
  14. public int baseVar;
  15. public int startBit;
  16. public int endBit;
  17.  
  18. public static final void main(String[] args) throws IOException {
  19. Cache.init();
  20. System.out.println("There are currently: " + Cache.STORE.getIndexes()[22].getLastArchiveId() * 0x3ff + " bitConfigs.");
  21. // List<BitConfigDefinitions> configs = new
  22. // ArrayList<BitConfigDefinitions>();
  23. for (int i = 0; i < Cache.STORE.getIndexes()[22].getLastArchiveId() * 0x3ff; i++) {
  24. VarBitDefinitions cd = getClientVarpBitDefinitions(i);
  25. if (cd.baseVar == 563) {
  26. System.out.println("BitConfig: " + i + ", from bitshift:" + cd.startBit + ", till bitshift: " + cd.endBit+", "+cd.baseVar);
  27. }
  28. }
  29. }
  30.  
  31. public static final VarBitDefinitions getClientVarpBitDefinitions(int id) {
  32. VarBitDefinitions script = varpbitDefs.get(id);
  33. if (script != null)// open new txt document
  34. return script;
  35. byte[] data = Cache.STORE.getIndexes()[22].getFile(id >>> 1416501898, id & 0x3ff);
  36. script = new VarBitDefinitions();
  37. script.id = id;
  38. if (data != null)
  39. script.readValueLoop(new InputStream(data));
  40. varpbitDefs.put(id, script);
  41. return script;
  42.  
  43. }
  44.  
  45. private void readValueLoop(InputStream stream) {
  46. for (;;) {
  47. int opcode = stream.readUnsignedByte();
  48. if (opcode == 0)
  49. break;
  50. readValues(stream, opcode);
  51. }
  52. }
  53.  
  54. private void readValues(InputStream stream, int opcode) {
  55. if (opcode == 1) {
  56. baseVar = stream.readUnsignedShort();
  57. startBit = stream.readUnsignedByte();
  58. endBit = stream.readUnsignedByte();
  59. }
  60. }
  61.  
  62. private VarBitDefinitions() {
  63.  
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment