Advertisement
Guest User

der

a guest
Dec 20th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.26 KB | None | 0 0
  1. package org.rse.cache.loaders;
  2.  
  3. import org.rse.cache.Cache;
  4. import org.rse.network.stream.InStream;
  5.  
  6. import java.lang.reflect.Field;
  7. import java.util.Arrays;
  8. import java.util.HashMap;
  9. import java.util.concurrent.ConcurrentHashMap;
  10.  
  11. @SuppressWarnings("unused")
  12. public class ObjectDefinitions {
  13.  
  14. private static final ConcurrentHashMap<Integer, ObjectDefinitions> objectDefinitions = new ConcurrentHashMap<Integer, ObjectDefinitions>();
  15.  
  16. private short[] originalColors;
  17. int[] toObjectIds;
  18. static int anInt3832;
  19. int[] anIntArray3833 = null;
  20. private int anInt3834;
  21. int anInt3835;
  22. static int anInt3836;
  23. private byte aByte3837;
  24. int anInt3838 = -1;
  25. boolean aBoolean3839;
  26. private int anInt3840;
  27. private int anInt3841;
  28. static int anInt3842;
  29. static int anInt3843;
  30. int anInt3844;
  31. boolean aBoolean3845;
  32. static int anInt3846;
  33. private byte aByte3847;
  34. private byte aByte3849;
  35. int anInt3850;
  36. int anInt3851;
  37. public boolean secondBool;
  38. public boolean aBoolean3853;
  39. int anInt3855;
  40. public boolean notCliped;
  41. int anInt3857;
  42. private byte[] aByteArray3858;
  43. int[] anIntArray3859;
  44. int anInt3860;
  45. String[] options;
  46. int configFileId;
  47. private short[] modifiedColors;
  48. int anInt3865;
  49. boolean aBoolean3866;
  50. boolean aBoolean3867;
  51. public boolean solid;
  52. private int[] anIntArray3869;
  53. boolean aBoolean3870;
  54. public int sizeY;
  55. boolean aBoolean3872;
  56. boolean aBoolean3873;
  57. public int thirdInt;
  58. private int anInt3875;
  59. public int objectAnimation;
  60. private int anInt3877;
  61. private int anInt3878;
  62. public int clipType;
  63. private int anInt3881;
  64. private int anInt3882;
  65. private int anInt3883;
  66. Object loader;
  67. private int anInt3889;
  68. public int sizeX;
  69. public boolean aBoolean3891;
  70. int anInt3892;
  71. public int secondInt;
  72. boolean aBoolean3894;
  73. boolean aBoolean3895;
  74. int anInt3896;
  75. int configId;
  76. private byte[] aByteArray3899;
  77. int anInt3900;
  78. public String name;
  79. private int anInt3902;
  80. int anInt3904;
  81. int anInt3905;
  82. boolean aBoolean3906;
  83. int[] anIntArray3908;
  84. private byte aByte3912;
  85. int anInt3913;
  86. private byte aByte3914;
  87. private int anInt3915;
  88. public int[][] modelIds;
  89. private int anInt3917;
  90. /**
  91. * Object anim shit 1
  92. */
  93. private short[] aShortArray3919;
  94. /**
  95. * Object anim shit 2
  96. */
  97. private short[] aShortArray3920;
  98. int anInt3921;
  99. private HashMap<Integer, Object> parameters;
  100. boolean aBoolean3923;
  101. boolean aBoolean3924;
  102. public int directionClip;
  103. public int id;
  104.  
  105. public String getFirstOption() {
  106. if (options == null || options.length < 1)
  107. return "";
  108. return options[0];
  109. }
  110.  
  111. public String getSecondOption() {
  112. if (options == null || options.length < 2)
  113. return "";
  114. return options[1];
  115. }
  116.  
  117. public String getOption(int option) {
  118. if (options == null || options.length < option || option == 0)
  119. return "";
  120. return options[option - 1];
  121. }
  122.  
  123. public String getThirdOption() {
  124. if (options == null || options.length < 3)
  125. return "";
  126. return options[2];
  127. }
  128.  
  129. public boolean containsOption(int i, String option) {
  130. if (options == null || options[i] == null || options.length <= i)
  131. return false;
  132. return options[i].equals(option);
  133. }
  134.  
  135. public boolean containsOption(String o) {
  136. if (options == null)
  137. return false;
  138. for (String option : options) {
  139. if (option == null)
  140. continue;
  141. if (option.equalsIgnoreCase(o))
  142. return true;
  143. }
  144. return false;
  145. }
  146.  
  147. private void readValues(InStream stream, int opcode) {
  148. // System.out.println(opcode);
  149. if (opcode != 1 && opcode != 5) {
  150. if (opcode != 2) {
  151. if (opcode != 14) {
  152. if (opcode != 15) {
  153. if (opcode == 17) { // nocliped
  154. solid = false;
  155. clipType = 0;
  156. } else if (opcode != 18) {
  157. if (opcode == 19)
  158. secondInt = stream.readUnsignedByte();
  159. else if (opcode == 21)
  160. aByte3912 = (byte) 1;
  161. else if (opcode != 22) {
  162. if (opcode != 23) {
  163. if (opcode != 24) {
  164. if (opcode == 27) // cliped, no idea
  165. // diff between 2
  166. // and 1
  167. clipType = 1;
  168. else if (opcode == 28)
  169. anInt3892 = (stream
  170. .readUnsignedByte() << 2);
  171. else if (opcode != 29) {
  172. if (opcode != 39) {
  173. if (opcode < 30 || opcode >= 35) {
  174. if (opcode == 40) {
  175. int i_53_ = (stream
  176. .readUnsignedByte());
  177. originalColors = new short[i_53_];
  178. modifiedColors = new short[i_53_];
  179. for (int i_54_ = 0; i_53_ > i_54_; i_54_++) {
  180. originalColors[i_54_] = (short) (stream
  181. .readUnsignedShort());
  182. modifiedColors[i_54_] = (short) (stream
  183. .readUnsignedShort());
  184. }
  185. } else if (opcode != 41) { // object
  186. // anim
  187. if(opcode == 44 || opcode == 45) {
  188. stream.skip(2);
  189. } else if (opcode != 42) {
  190. if (opcode != 62) {
  191. if (opcode != 64) {
  192. if (opcode == 65)
  193. anInt3902 = stream
  194. .readUnsignedShort();
  195. else if (opcode != 66) {
  196. if (opcode != 67) {
  197. if (opcode == 69)
  198. directionClip = stream
  199. .readUnsignedByte();
  200. else if (opcode != 70) {
  201. if (opcode == 71)
  202. anInt3889 = stream
  203. .readShort() << 2;
  204. else if (opcode != 72) {
  205. if (opcode == 73)
  206. secondBool = true;
  207. else if (opcode == 74)
  208. notCliped = true;
  209. else if (opcode != 75) {
  210. if (opcode != 77
  211. && opcode != 92) {
  212. if (opcode == 78) {
  213. anInt3860 = stream
  214. .readUnsignedShort();
  215. anInt3904 = stream
  216. .readUnsignedByte();
  217. } else if (opcode != 79) {
  218. if (opcode == 81) {
  219. aByte3912 = (byte) 2;
  220. anInt3882 = 256 * stream
  221. .readUnsignedByte();
  222. } else if (opcode != 82) {
  223. if (opcode == 88)
  224. aBoolean3853 = false;
  225. else if (opcode != 89) {
  226. if (opcode == 90)
  227. aBoolean3870 = true;
  228. else if (opcode != 91) {
  229. if (opcode != 93) {
  230. if (opcode == 94)
  231. aByte3912 = (byte) 4;
  232. else if (opcode != 95) {
  233. if (opcode != 96) {
  234. if (opcode == 97)
  235. aBoolean3866 = true;
  236. else if (opcode == 98)
  237. aBoolean3923 = true;
  238. else if (opcode == 99) {
  239. anInt3857 = stream
  240. .readUnsignedByte();
  241. anInt3835 = stream
  242. .readUnsignedShort();
  243. } else if (opcode == 100) {
  244. anInt3844 = stream
  245. .readUnsignedByte();
  246. anInt3913 = stream
  247. .readUnsignedShort();
  248. } else if (opcode != 101) {
  249. if (opcode == 102)
  250. anInt3838 = stream
  251. .readUnsignedShort();
  252. else if (opcode == 103)
  253. thirdInt = 0;
  254. else if (opcode != 104) {
  255. if (opcode == 105)
  256. aBoolean3906 = true;
  257. else if (opcode == 106) {
  258. int i_55_ = stream
  259. .readUnsignedByte();
  260. anIntArray3869 = new int[i_55_];
  261. anIntArray3833 = new int[i_55_];
  262. for (int i_56_ = 0; i_56_ < i_55_; i_56_++) {
  263. anIntArray3833[i_56_] = stream
  264. .readBigSmart();
  265. int i_57_ = stream
  266. .readUnsignedByte();
  267. anIntArray3869[i_56_] = i_57_;
  268. anInt3881 += i_57_;
  269. }
  270. } else if (opcode == 107)
  271. anInt3851 = stream
  272. .readUnsignedShort();
  273. else if (opcode >= 150
  274. && opcode < 155) {
  275. options[opcode
  276. + -150] = stream
  277. .readString();
  278. /*
  279. * if
  280. * (
  281. * !
  282. * loader
  283. * .
  284. * showOptions
  285. * )
  286. * options
  287. * [
  288. * opcode
  289. * +
  290. * -
  291. * 150
  292. * ]
  293. * =
  294. * null
  295. * ;
  296. */
  297. } else if (opcode != 160) {
  298. if (opcode == 162) {
  299. aByte3912 = (byte) 3;
  300. anInt3882 = stream
  301. .readInt();
  302. } else if (opcode == 163) {
  303. aByte3847 = (byte) stream
  304. .readByte();
  305. aByte3849 = (byte) stream
  306. .readByte();
  307. aByte3837 = (byte) stream
  308. .readByte();
  309. aByte3914 = (byte) stream
  310. .readByte();
  311. } else if (opcode != 164) {
  312. if (opcode != 165) {
  313. if (opcode != 166) {
  314. if (opcode == 167)
  315. anInt3921 = stream
  316. .readUnsignedShort();
  317. else if (opcode != 168) {
  318. if (opcode == 169) {
  319. aBoolean3845 = true;
  320. // added
  321. // opcode
  322. } else if (opcode == 170) {
  323. int anInt3383 = stream
  324. .readSmart();
  325. // added
  326. // opcode
  327. } else if (opcode == 171) {
  328. int anInt3362 = stream
  329. .readSmart();
  330. // added
  331. // opcode
  332. } else if (opcode == 173) {
  333. int anInt3302 = stream
  334. .readUnsignedShort();
  335. int anInt3336 = stream
  336. .readUnsignedShort();
  337. // added
  338. // opcode
  339. } else if (opcode == 177) {
  340. boolean ub = true;
  341. // added
  342. // opcode
  343. } else if (opcode == 178) {
  344. int db = stream
  345. .readUnsignedByte();
  346. } else if (opcode == 189) {
  347. boolean bloom = true;
  348. } else if (opcode == 249) {
  349. int length = stream
  350. .readUnsignedByte();
  351. if (parameters == null)
  352. parameters = new HashMap<Integer, Object>(
  353. length);
  354. for (int i_60_ = 0; i_60_ < length; i_60_++) {
  355. boolean bool = stream
  356. .readUnsignedByte() == 1;
  357. int i_61_ = stream
  358. .readTriByte();
  359. if (!bool)
  360. parameters
  361. .put(i_61_,
  362. stream.readInt());
  363. else
  364. parameters
  365. .put(i_61_,
  366. stream.readString());
  367.  
  368. }
  369. }
  370. } else
  371. aBoolean3894 = true;
  372. } else
  373. anInt3877 = stream
  374. .readShort();
  375. } else
  376. anInt3875 = stream
  377. .readShort();
  378. } else
  379. anInt3834 = stream
  380. .readShort();
  381. } else {
  382. int i_62_ = stream
  383. .readUnsignedByte();
  384. anIntArray3908 = new int[i_62_];
  385. for (int i_63_ = 0; i_62_ > i_63_; i_63_++)
  386. anIntArray3908[i_63_] = stream
  387. .readUnsignedShort();
  388. }
  389. } else
  390. anInt3865 = stream
  391. .readUnsignedByte();
  392. } else
  393. anInt3850 = stream
  394. .readUnsignedByte();
  395. } else
  396. aBoolean3924 = true;
  397. } else {
  398. aByte3912 = (byte) 5;
  399. anInt3882 = stream
  400. .readShort();
  401. }
  402. } else {
  403. aByte3912 = (byte) 3;
  404. anInt3882 = stream
  405. .readUnsignedShort();
  406. }
  407. } else
  408. aBoolean3873 = true;
  409. } else
  410. aBoolean3895 = false;
  411. } else
  412. aBoolean3891 = true;
  413. } else {
  414. anInt3900 = stream
  415. .readUnsignedShort();
  416. anInt3905 = stream
  417. .readUnsignedShort();
  418. anInt3904 = stream
  419. .readUnsignedByte();
  420. int i_64_ = stream
  421. .readUnsignedByte();
  422. anIntArray3859 = new int[i_64_];
  423. for (int i_65_ = 0; i_65_ < i_64_; i_65_++)
  424. anIntArray3859[i_65_] = stream
  425. .readUnsignedShort();
  426. }
  427. } else {
  428. configFileId = stream
  429. .readUnsignedShort();
  430. if (configFileId == 65535)
  431. configFileId = -1;
  432. configId = stream
  433. .readUnsignedShort();
  434. if (configId == 65535)
  435. configId = -1;
  436. int i_66_ = -1;
  437. if (opcode == 92) {
  438. i_66_ = stream
  439. .readBigSmart();
  440. }
  441. int i_67_ = stream
  442. .readUnsignedByte();
  443. toObjectIds = new int[i_67_
  444. - -2];
  445. for (int i_68_ = 0; i_67_ >= i_68_; i_68_++) {
  446. toObjectIds[i_68_] = stream
  447. .readBigSmart();
  448. }
  449. toObjectIds[i_67_ + 1] = i_66_;
  450. }
  451. } else
  452. anInt3855 = stream
  453. .readUnsignedByte();
  454. } else
  455. anInt3915 = stream
  456. .readShort() << 2;
  457. } else
  458. anInt3883 = stream
  459. .readShort() << 2;
  460. } else
  461. anInt3917 = stream
  462. .readUnsignedShort();
  463. } else
  464. anInt3841 = stream
  465. .readUnsignedShort();
  466. } else
  467. // 64
  468. aBoolean3872 = false;
  469. } else
  470. aBoolean3839 = true;
  471. } else {
  472. int i_69_ = (stream
  473. .readUnsignedByte());
  474. aByteArray3858 = (new byte[i_69_]);
  475. for (int i_70_ = 0; i_70_ < i_69_; i_70_++)
  476. aByteArray3858[i_70_] = (byte) (stream
  477. .readByte());
  478. }
  479. } else { //object anim?
  480. int i_71_ = (stream
  481. .readUnsignedByte());
  482. aShortArray3920 = new short[i_71_];
  483. aShortArray3919 = new short[i_71_];
  484. for (int i_72_ = 0; i_71_ > i_72_; i_72_++) {
  485. aShortArray3920[i_72_] = (short) (stream
  486. .readUnsignedShort());
  487. aShortArray3919[i_72_] = (short) (stream
  488. .readUnsignedShort());
  489. }
  490. }
  491. } else {
  492. options[-30 + opcode] = (stream
  493. .readString());
  494. }
  495. } else
  496. // 39
  497. anInt3840 = (stream.readByte() * 5);
  498. } else {// 29
  499. anInt3878 = stream.readByte();
  500. }
  501. } else {
  502. objectAnimation = stream.readBigSmart();
  503. }
  504. } else
  505. thirdInt = 1;
  506. } else
  507. aBoolean3867 = true;
  508. } else
  509. solid = false;
  510. } else
  511. // 15
  512. sizeY = stream.readUnsignedByte();
  513. } else
  514. // 14
  515. sizeX = stream.readUnsignedByte();
  516. } else {
  517. name = stream.readString();
  518. }
  519. } else {
  520. boolean aBoolean1162 = false;
  521. if (opcode == 5 && aBoolean1162)
  522. skipReadModelIds(stream);
  523. int i_73_ = stream.readUnsignedByte();
  524. modelIds = new int[i_73_][];
  525. aByteArray3899 = new byte[i_73_];
  526. for (int i_74_ = 0; i_74_ < i_73_; i_74_++) {
  527. aByteArray3899[i_74_] = (byte) stream.readByte();
  528. int i_75_ = stream.readUnsignedByte();
  529. modelIds[i_74_] = new int[i_75_];
  530. for (int i_76_ = 0; i_75_ > i_76_; i_76_++)
  531. modelIds[i_74_][i_76_] = stream.readBigSmart();
  532. }
  533. if (opcode == 5 && !aBoolean1162)
  534. skipReadModelIds(stream);
  535. }
  536. }
  537.  
  538. private void skipReadModelIds(InStream stream) {
  539. int length = stream.readUnsignedByte();
  540. for (int index = 0; index < length; index++) {
  541. stream.skip(1);
  542. int length2 = stream.readUnsignedByte();
  543. for (int i = 0; i < length2; i++)
  544. stream.readBigSmart();
  545. }
  546. }
  547.  
  548. private void readValueLoop(InStream stream) {
  549. for (;;) {
  550. int opcode = stream.readUnsignedByte();
  551. if (opcode == 0) {
  552. // System.out.println("Remaining: "+stream.getRemaining());
  553. break;
  554. }
  555. readValues(stream, opcode);
  556. }
  557. }
  558.  
  559. private ObjectDefinitions() {
  560. anInt3835 = -1;
  561. anInt3860 = -1;
  562. configFileId = -1;
  563. aBoolean3866 = false;
  564. anInt3851 = -1;
  565. anInt3865 = 255;
  566. aBoolean3845 = false;
  567. aBoolean3867 = false;
  568. anInt3850 = 0;
  569. anInt3844 = -1;
  570. anInt3881 = 0;
  571. anInt3857 = -1;
  572. aBoolean3872 = true;
  573. anInt3882 = -1;
  574. anInt3834 = 0;
  575. options = new String[5];
  576. anInt3875 = 0;
  577. aBoolean3839 = false;
  578. anIntArray3869 = null;
  579. sizeY = 1;
  580. thirdInt = -1;
  581. anInt3883 = 0;
  582. aBoolean3895 = true;
  583. anInt3840 = 0;
  584. aBoolean3870 = false;
  585. anInt3889 = 0;
  586. aBoolean3853 = true;
  587. secondBool = false;
  588. clipType = 2;
  589. solid = true;
  590. notCliped = false;
  591. anInt3855 = -1;
  592. anInt3878 = 0;
  593. anInt3904 = 0;
  594. sizeX = 1;
  595. objectAnimation = -1;
  596. aBoolean3891 = false;
  597. anInt3905 = 0;
  598. name = "null";
  599. anInt3913 = -1;
  600. aBoolean3906 = false;
  601. aBoolean3873 = false;
  602. aByte3914 = (byte) 0;
  603. anInt3915 = 0;
  604. anInt3900 = 0;
  605. secondInt = -1;
  606. aBoolean3894 = false;
  607. aByte3912 = (byte) 0;
  608. anInt3921 = 0;
  609. anInt3902 = 128;
  610. configId = -1;
  611. anInt3877 = 0;
  612. directionClip = 0;
  613. anInt3892 = 64;
  614. aBoolean3923 = false;
  615. aBoolean3924 = false;
  616. anInt3841 = 128;
  617. anInt3917 = 128;
  618. }
  619.  
  620. final void method3287() {
  621. if (secondInt == -1) {
  622. secondInt = 0;
  623. if (aByteArray3899 != null && aByteArray3899.length == 1
  624. && aByteArray3899[0] == 10)
  625. secondInt = 1;
  626. for (int i_13_ = 0; i_13_ < 5; i_13_++) {
  627. if (options[i_13_] != null) {
  628. secondInt = 1;
  629. break;
  630. }
  631. }
  632. }
  633. if (anInt3855 == -1)
  634. anInt3855 = clipType != 0 ? 1 : 0;
  635. }
  636.  
  637. private static int getArchiveId(int i_0_) {
  638. return i_0_ >>> -1135990488;
  639. }
  640.  
  641. public static ObjectDefinitions getObjectDefinitions(int id) {
  642. ObjectDefinitions def = objectDefinitions.get(id);
  643. if (def == null) {
  644. def = new ObjectDefinitions();
  645. def.id = id;
  646. byte[] data = Cache.STORE.getIndexes()[16].getFile(
  647. getArchiveId(id), id & 0xff);
  648. if (data == null) {
  649. //System.out.println("Failed loading Object " + id + ".");
  650. } else
  651. def.readValueLoop(new InStream(data));
  652. def.method3287();
  653. if ((def.name != null && (def.name.equalsIgnoreCase("bank booth") || def.name
  654. .equalsIgnoreCase("counter")))) {
  655. def.notCliped = false;
  656. def.solid = true;
  657. if (def.clipType == 0)
  658. def.clipType = 1;
  659. } else if (false) {//DungeonUtils.isDoor(id)) {
  660. def.notCliped = false;
  661. def.solid = true;
  662. if (def.clipType == 0)
  663. def.clipType = 1;
  664. }
  665. if (def.notCliped) {
  666. def.solid = false;
  667. def.clipType = 0;
  668. }
  669. objectDefinitions.put(id, def);
  670. }
  671. return def;
  672. }
  673.  
  674. public int getClipType() {
  675. return clipType;
  676. }
  677.  
  678. public boolean isSolid() {
  679. return solid;
  680. }
  681.  
  682. public int getSizeX() {
  683. return sizeX;
  684. }
  685.  
  686. public int getSizeY() {
  687. return sizeY;
  688. }
  689.  
  690. public static void clearObjectDefinitions() {
  691. objectDefinitions.clear();
  692. }
  693.  
  694. /**
  695. * Prints all fields in this class.
  696. */
  697. public void printFields() {
  698. for (Field field : getClass().getDeclaredFields()) {
  699. if ((field.getModifiers() & 8) != 0) {
  700. continue;
  701. }
  702. try {
  703. System.out.println(field.getName() + ": " + getValue(field));
  704. } catch (Throwable e) {
  705. e.printStackTrace();
  706. }
  707. }
  708. System.out.println("-- end of " + getClass().getSimpleName() + " fields --");
  709. }
  710.  
  711. private Object getValue(Field field) throws Throwable {
  712. field.setAccessible(true);
  713. Class<?> type = field.getType();
  714. if (type == int[][].class) {
  715. return Arrays.toString((int[][]) field.get(this));
  716. } else if (type == int[].class) {
  717. return Arrays.toString((int[]) field.get(this));
  718. } else if (type == byte[].class) {
  719. return Arrays.toString((byte[]) field.get(this));
  720. } else if (type == short[].class) {
  721. return Arrays.toString((short[]) field.get(this));
  722. } else if (type == double[].class) {
  723. return Arrays.toString((double[]) field.get(this));
  724. } else if (type == float[].class) {
  725. return Arrays.toString((float[]) field.get(this));
  726. } else if (type == Object[].class) {
  727. return Arrays.toString((Object[]) field.get(this));
  728. }
  729. return field.get(this);
  730. }
  731.  
  732. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement