Guest User

Untitled

a guest
Jul 8th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 107.59 KB | None | 0 0
  1. package com.client;
  2.  
  3. final class SceneGraph {
  4.  
  5. public SceneGraph(int ai[][][]) {
  6. int i = 104;// was parameter
  7. int j = 104;// was parameter
  8. int k = 4;// was parameter
  9. aBoolean434 = true;
  10. gameObjectsCache = new GameObject[5000];
  11. anIntArray486 = new int[10000];
  12. anIntArray487 = new int[10000];
  13. numberOfZ = k;
  14. maxX = j;
  15. maxZ = i;
  16. tileArray = new Tile[k][j][i];
  17. anIntArrayArrayArray445 = new int[k][j + 1][i + 1];
  18. heightMap = ai;
  19. initToNull();
  20. }
  21.  
  22. public static void destructor() {
  23. interactableObjects = null;
  24. sceneClusterCounts = null;
  25. sceneClusters = null;
  26. tileDeque = null;
  27. visibilityMap = null;
  28. renderArea = null;
  29. }
  30.  
  31. public void initToNull() {
  32. for (int j = 0; j < numberOfZ; j++)
  33. for (int k = 0; k < maxX; k++)
  34. for (int i1 = 0; i1 < maxZ; i1++)
  35. tileArray[j][k][i1] = null;
  36. for (int l = 0; l < cullingClusterPlaneCount; l++) {
  37. for (int j1 = 0; j1 < sceneClusterCounts[l]; j1++)
  38. sceneClusters[l][j1] = null;
  39. sceneClusterCounts[l] = 0;
  40. }
  41. for (int k1 = 0; k1 < interactableObjectCacheCurrPos; k1++)
  42. gameObjectsCache[k1] = null;
  43. interactableObjectCacheCurrPos = 0;
  44. for (int l1 = 0; l1 < interactableObjects.length; l1++)
  45. interactableObjects[l1] = null;
  46. }
  47.  
  48. public void method275(int i) {
  49. zAnInt442 = i;
  50. for (int k = 0; k < maxX; k++) {
  51. for (int l = 0; l < maxZ; l++)
  52. if (tileArray[i][k][l] == null)
  53. tileArray[i][k][l] = new Tile(i, k, l);
  54.  
  55. }
  56.  
  57. }
  58.  
  59. public void applyBridgeMode(int yLoc, int xLoc) {
  60. Tile tileFirstFloor = tileArray[0][xLoc][yLoc];
  61. for (int l = 0; l < 3; l++) {
  62. Tile tile = tileArray[l][xLoc][yLoc] = tileArray[l + 1][xLoc][yLoc];
  63. if (tile != null) {
  64. tile.z1AnInt1307--;
  65. for (int j1 = 0; j1 < tile.gameObjectIndex; j1++) {
  66. GameObject gameObject = tile.gameObjects[j1];
  67. if ((gameObject.uid >> 29 & 3) == 2 && gameObject.xLocLow == xLoc && gameObject.yLocHigh == yLoc)
  68. gameObject.zLoc--;
  69. }
  70.  
  71. }
  72. }
  73. if (tileArray[0][xLoc][yLoc] == null)
  74. tileArray[0][xLoc][yLoc] = new Tile(0, xLoc, yLoc);
  75. tileArray[0][xLoc][yLoc].firstFloorTile = tileFirstFloor;
  76. tileArray[3][xLoc][yLoc] = null;
  77. }
  78.  
  79.  
  80. public static void createNewSceneCluster(int z, int lowestX, int lowestZ, int highestX, int highestY, int highestZ, int lowestY, int searchMask) {
  81. SceneCluster sceneCluster = new SceneCluster();
  82. sceneCluster.startXLoc = lowestX / 128;
  83. sceneCluster.endXLoc = highestX / 128;
  84. sceneCluster.startYLoc = lowestY / 128;
  85. sceneCluster.endYLoc = highestY / 128;
  86. sceneCluster.orientation = searchMask;
  87. sceneCluster.startXPos = lowestX;
  88. sceneCluster.endXPos = highestX;
  89. sceneCluster.startYPos = lowestY;
  90. sceneCluster.endYPos = highestY;
  91. sceneCluster.startZPos = highestZ;
  92. sceneCluster.endZPos = lowestZ;
  93. sceneClusters[z][sceneClusterCounts[z]++] = sceneCluster;
  94. }
  95.  
  96. public void setTileLogicHeight(int zLoc, int xLoc, int yLoc, int logicHeight) {
  97. Tile tile = tileArray[zLoc][xLoc][yLoc];
  98. if (tile != null)
  99. tileArray[zLoc][xLoc][yLoc].logicHeight = logicHeight;
  100. }
  101. public void addTile(int i, int j, int k, int l, int i1, int j1, int k1,
  102. int l1, int i2, int j2, int k2, int l2, int i3, int j3, int k3,
  103. int l3, int i4, int j4, int k4, int l4) {
  104. if (l == 0) {
  105. SimpleTile simpleTile = new SimpleTile(k2, l2, i3, j3, -1, k4, false);
  106. for (int i5 = i; i5 >= 0; i5--)
  107. if (tileArray[i5][j][k] == null)
  108. tileArray[i5][j][k] = new Tile(i5, j, k);
  109.  
  110. tileArray[i][j][k].mySimpleTile = simpleTile;
  111. return;
  112. }
  113. if (l == 1) {
  114. SimpleTile simpleTile = new SimpleTile(k3, l3, i4, j4, j1, l4, k1 == l1 && k1 == i2 && k1 == j2);
  115. for (int j5 = i; j5 >= 0; j5--)
  116. if (tileArray[j5][j][k] == null)
  117. tileArray[j5][j][k] = new Tile(j5, j, k);
  118.  
  119. tileArray[i][j][k].mySimpleTile = simpleTile;
  120. return;
  121. }
  122. ShapedTile shapedTile = new ShapedTile(k, k3, j3, i2, j1, i4, i1, k2, k4, i3,
  123. j2, l1, k1, l, j4, l3, l2, j, l4);
  124. for (int k5 = i; k5 >= 0; k5--)
  125. if (tileArray[k5][j][k] == null)
  126. tileArray[k5][j][k] = new Tile(k5, j, k);
  127.  
  128. tileArray[i][j][k].myShapedTile = shapedTile;
  129. }
  130.  
  131. public void addGroundDecoration(int i, int j, int k, Renderable class30_sub2_sub4,
  132. byte byte0, int i1, int j1, int var) {
  133. if (class30_sub2_sub4 == null)
  134. return;
  135. GroundObject class49 = new GroundObject();
  136. class49.renderable = class30_sub2_sub4;
  137. class49.anInt812 = j1 * 128 + 64;
  138. class49.anInt813 = k * 128 + 64;
  139. class49.anInt811 = j;
  140. class49.uid = i1;
  141. class49.aByte816 = byte0;
  142. class49.setNewUID(var);
  143. if (tileArray[i][j1][k] == null)
  144. tileArray[i][j1][k] = new Tile(i, j1, k);
  145. tileArray[i][j1][k].groundDecoration = class49;
  146. }
  147.  
  148. public void addGroundItemTile(int i, int j, Renderable class30_sub2_sub4, int k,
  149. Renderable class30_sub2_sub4_1, Renderable class30_sub2_sub4_2, int l,
  150. int i1) {
  151. Object4 object4 = new Object4();
  152. object4.aClass30_Sub2_Sub4_48 = class30_sub2_sub4_2;
  153. object4.anInt46 = i * 128 + 64;
  154. object4.anInt47 = i1 * 128 + 64;
  155. object4.anInt45 = k;
  156. object4.uid = j;
  157. object4.aClass30_Sub2_Sub4_49 = class30_sub2_sub4;
  158. object4.aClass30_Sub2_Sub4_50 = class30_sub2_sub4_1;
  159. int j1 = 0;
  160. Tile class30_sub3 = tileArray[l][i][i1];
  161. if (class30_sub3 != null) {
  162. for (int k1 = 0; k1 < class30_sub3.gameObjectIndex; k1++)
  163. if (class30_sub3.gameObjects[k1].renderable instanceof Model) {
  164. int l1 = ((Model) class30_sub3.gameObjects[k1].renderable).itemDropHeight;
  165. if (l1 > j1)
  166. j1 = l1;
  167. }
  168.  
  169. }
  170. object4.anInt52 = j1;
  171. if (tileArray[l][i][i1] == null)
  172. tileArray[l][i][i1] = new Tile(l, i, i1);
  173. tileArray[l][i][i1].obj4 = object4;
  174. }
  175.  
  176. public void addWallObject(int i, Renderable class30_sub2_sub4, int j, int k,
  177. byte byte0, int l, Renderable class30_sub2_sub4_1, int i1, int j1,
  178. int k1, int var) {
  179. if (class30_sub2_sub4 == null && class30_sub2_sub4_1 == null)
  180. return;
  181. WallObject object1 = new WallObject();
  182. object1.uid = j;
  183. object1.aByte281 = byte0;
  184. object1.anInt274 = l * 128 + 64;
  185. object1.anInt275 = k * 128 + 64;
  186. object1.anInt273 = i1;
  187. object1.renderable1 = class30_sub2_sub4;
  188. object1.renderable2 = class30_sub2_sub4_1;
  189. object1.orientation = i;
  190. object1.orientation1 = j1;
  191. object1.setNewUID(var);
  192. for (int l1 = k1; l1 >= 0; l1--)
  193. if (tileArray[l1][l][k] == null)
  194. tileArray[l1][l][k] = new Tile(l1, l, k);
  195.  
  196. tileArray[k1][l][k].wallObject = object1;
  197. }
  198.  
  199. public void addWallDecoration(int i, int j, int k, int i1, int j1, int k1,
  200. Renderable class30_sub2_sub4, int l1, byte byte0, int i2, int j2, int var) {
  201. if (class30_sub2_sub4 == null)
  202. return;
  203. WallDecoration class26 = new WallDecoration();
  204. class26.uid = i;
  205. class26.aByte506 = byte0;
  206. class26.anInt500 = l1 * 128 + 64 + j1;
  207. class26.anInt501 = j * 128 + 64 + i2;
  208. class26.anInt499 = k1;
  209. class26.aClass30_Sub2_Sub4_504 = class30_sub2_sub4;
  210. class26.anInt502 = j2;
  211. class26.anInt503 = k;
  212. class26.setNewUID(var);
  213. for (int k2 = i1; k2 >= 0; k2--)
  214. if (tileArray[k2][l1][j] == null)
  215. tileArray[k2][l1][j] = new Tile(k2, l1, j);
  216.  
  217. tileArray[i1][l1][j].obj2 = class26;
  218. }
  219.  
  220. public boolean addTiledObject(int i, byte byte0, int j, int k,
  221. Renderable class30_sub2_sub4, int l, int i1, int j1, int k1, int l1, int var11) {
  222. if (class30_sub2_sub4 == null) {
  223. return true;
  224. } else {
  225. int i2 = l1 * 128 + 64 * l;
  226. int j2 = k1 * 128 + 64 * k;
  227. return addAnimableC(i1, l1, k1, l, k, i2, j2, j, class30_sub2_sub4,
  228. j1, false, i, byte0, var11);
  229. }
  230. }
  231.  
  232. public boolean addAnimableA(int i, int j, int k, int l, int i1, int j1,
  233. int k1, Renderable class30_sub2_sub4, boolean flag) {
  234. if (class30_sub2_sub4 == null)
  235. return true;
  236. int l1 = k1 - j1;
  237. int i2 = i1 - j1;
  238. int j2 = k1 + j1;
  239. int k2 = i1 + j1;
  240. if (flag) {
  241. if (j > 640 && j < 1408)
  242. k2 += 128;
  243. if (j > 1152 && j < 1920)
  244. j2 += 128;
  245. if (j > 1664 || j < 384)
  246. i2 -= 128;
  247. if (j > 128 && j < 896)
  248. l1 -= 128;
  249. }
  250. l1 /= 128;
  251. i2 /= 128;
  252. j2 /= 128;
  253. k2 /= 128;
  254. return addAnimableC(i, l1, i2, (j2 - l1) + 1, (k2 - i2) + 1, k1, i1, k,
  255. class30_sub2_sub4, j, true, l, (byte) 0, 0);
  256. }
  257.  
  258. public boolean addToScenePlayerAsObject(int j, int k, Renderable class30_sub2_sub4, int l,
  259. int i1, int j1, int k1, int l1, int i2, int j2, int k2) {
  260. return class30_sub2_sub4 == null
  261. || addAnimableC(j, l1, k2, (i2 - l1) + 1, (i1 - k2) + 1, j1, k,
  262. k1, class30_sub2_sub4, l, true, j2, (byte) 0, 0);
  263. }
  264.  
  265. private boolean addAnimableC(int i, int j, int k, int l, int i1, int j1,
  266. int k1, int l1, Renderable class30_sub2_sub4, int i2, boolean flag,
  267. int j2, byte byte0, int var) {
  268. for (int k2 = j; k2 < j + l; k2++) {
  269. for (int l2 = k; l2 < k + i1; l2++) {
  270. if (k2 < 0 || l2 < 0 || k2 >= maxX || l2 >= maxZ)
  271. return false;
  272. Tile class30_sub3 = tileArray[i][k2][l2];
  273. if (class30_sub3 != null && class30_sub3.gameObjectIndex >= 5)
  274. return false;
  275. }
  276.  
  277. }
  278.  
  279. GameObject class28 = new GameObject();
  280. class28.uid = j2;
  281. class28.mask = byte0;
  282. class28.zLoc = i;
  283. class28.xPos = j1;
  284. class28.yPos = k1;
  285. class28.tileHeight = l1;
  286. class28.renderable = class30_sub2_sub4;
  287. class28.turnValue = i2;
  288. class28.xLocLow = j;
  289. class28.yLocHigh = k;
  290. class28.xLocHigh = (j + l) - 1;
  291. class28.yLocLow = (k + i1) - 1;
  292. class28.setNewUID(var);
  293. for (int i3 = j; i3 < j + l; i3++) {
  294. for (int j3 = k; j3 < k + i1; j3++) {
  295. int k3 = 0;
  296. if (i3 > j)
  297. k3++;
  298. if (i3 < (j + l) - 1)
  299. k3 += 4;
  300. if (j3 > k)
  301. k3 += 8;
  302. if (j3 < (k + i1) - 1)
  303. k3 += 2;
  304. for (int l3 = i; l3 >= 0; l3--)
  305. if (tileArray[l3][i3][j3] == null)
  306. tileArray[l3][i3][j3] = new Tile(l3, i3, j3);
  307.  
  308. Tile class30_sub3_1 = tileArray[i][i3][j3];
  309. class30_sub3_1.gameObjects[class30_sub3_1.gameObjectIndex] = class28;
  310. class30_sub3_1.gameObjectsChanged[class30_sub3_1.gameObjectIndex] = k3;
  311. class30_sub3_1.totalTiledObjectMask |= k3;
  312. class30_sub3_1.gameObjectIndex++;
  313. }
  314.  
  315. }
  316.  
  317. if (flag)
  318. gameObjectsCache[interactableObjectCacheCurrPos++] = class28;
  319. return true;
  320. }
  321.  
  322. public void clearGameObjectCache() {
  323. for (int i = 0; i < interactableObjectCacheCurrPos; i++) {
  324. GameObject object5 = gameObjectsCache[i];
  325. remove(object5);
  326. gameObjectsCache[i] = null;
  327. }
  328.  
  329. interactableObjectCacheCurrPos = 0;
  330. }
  331.  
  332. private void remove(GameObject gameObject) {
  333. for (int j = gameObject.xLocLow; j <= gameObject.xLocHigh; j++) {
  334. for (int k = gameObject.yLocHigh; k <= gameObject.yLocLow; k++) {
  335. Tile tile = tileArray[gameObject.zLoc][j][k];
  336. if (tile != null) {
  337. for (int l = 0; l < tile.gameObjectIndex; l++) {
  338. if (tile.gameObjects[l] != gameObject)
  339. continue;
  340. tile.gameObjectIndex--;
  341. for (int i1 = l; i1 < tile.gameObjectIndex; i1++) {
  342. tile.gameObjects[i1] = tile.gameObjects[i1 + 1];
  343. tile.gameObjectsChanged[i1] = tile.gameObjectsChanged[i1 + 1];
  344. }
  345.  
  346. tile.gameObjects[tile.gameObjectIndex] = null;
  347. break;
  348. }
  349.  
  350. tile.totalTiledObjectMask = 0;
  351. for (int j1 = 0; j1 < tile.gameObjectIndex; j1++)
  352. tile.totalTiledObjectMask |= tile.gameObjectsChanged[j1];
  353.  
  354. }
  355. }
  356.  
  357. }
  358.  
  359. }
  360.  
  361. public void method290(int i, int k, int l, int i1) {
  362. Tile tile = tileArray[i1][l][i];
  363. if (tile == null)
  364. return;
  365. WallDecoration wallDecoration = tile.obj2;
  366. if (wallDecoration != null) {
  367. int j1 = l * 128 + 64;
  368. int k1 = i * 128 + 64;
  369. wallDecoration.anInt500 = j1 + ((wallDecoration.anInt500 - j1) * k) / 16;
  370. wallDecoration.anInt501 = k1 + ((wallDecoration.anInt501 - k1) * k) / 16;
  371. }
  372. }
  373.  
  374. public void removeWallObject(int i, int j, int k) {
  375. Tile tile = tileArray[j][i][k];
  376. if (tile != null) {
  377. tile.wallObject = null;
  378. }
  379. }
  380.  
  381. public void removeWallDecoration(int j, int k, int l) {
  382. Tile tile = tileArray[k][l][j];
  383. if (tile != null) {
  384. tile.obj2 = null;
  385. }
  386. }
  387.  
  388. public void removeTiledObject(int i, int k, int l) {
  389. Tile tile = tileArray[i][k][l];
  390. if (tile == null)
  391. return;
  392. for (int j1 = 0; j1 < tile.gameObjectIndex; j1++) {
  393. GameObject gameObject = tile.gameObjects[j1];
  394. if ((gameObject.uid >> 29 & 3) == 2 && gameObject.xLocLow == k
  395. && gameObject.yLocHigh == l) {
  396. remove(gameObject);
  397. return;
  398. }
  399. }
  400.  
  401. }
  402.  
  403. public void removeGroundDecoration(int i, int j, int k) {
  404. Tile tile = tileArray[i][k][j];
  405. if (tile == null)
  406. return;
  407. tile.groundDecoration = null;
  408. }
  409.  
  410. public void removeGroundItemTile(int i, int j, int k) {
  411. Tile class30_sub3 = tileArray[i][j][k];
  412. if (class30_sub3 != null) {
  413. class30_sub3.obj4 = null;
  414. }
  415. }
  416.  
  417. public WallObject getWallObject(int i, int j, int k) {
  418. Tile tile = tileArray[i][j][k];
  419. if (tile == null)
  420. return null;
  421. else
  422. return tile.wallObject;
  423. }
  424.  
  425. public WallDecoration getWallDecoration(int i, int k, int l) {
  426. Tile tile = tileArray[l][i][k];
  427. if (tile == null)
  428. return null;
  429. else
  430. return tile.obj2;
  431. }
  432.  
  433. public GameObject getGameObject(int i, int j, int k) {
  434. Tile tile = tileArray[k][i][j];
  435. if (tile == null)
  436. return null;
  437. for (int l = 0; l < tile.gameObjectIndex; l++) {
  438. GameObject gameObject = tile.gameObjects[l];
  439. if ((gameObject.uid >> 29 & 3) == 2 && gameObject.xLocLow == i
  440. && gameObject.yLocHigh == j)
  441. return gameObject;
  442. }
  443. return null;
  444. }
  445.  
  446. public GroundObject getGroundDecoration(int i, int j, int k) {
  447. Tile tile = tileArray[k][j][i];
  448. if (tile == null || tile.groundDecoration == null)
  449. return null;
  450. else
  451. return tile.groundDecoration;
  452. }
  453.  
  454. //fetchWallObjectUID
  455. public int getWallObjectUid(int i, int j, int k) {
  456. Tile tile = tileArray[i][j][k];
  457. if(tile == null || tile.wallObject == null)
  458. return 0;
  459. else
  460. return tile.wallObject.uid;
  461. }
  462.  
  463. //fetchWallObjectNewUID
  464. public int fetchWallObjectNewUID(int i, int j, int k) {
  465. Tile tile = tileArray[i][j][k];
  466. if(tile == null || tile.wallObject == null)
  467. return 0;
  468. else
  469. return tile.wallObject.newuid;
  470. }
  471.  
  472. //fetchWallDecorationUID
  473. public int method301(int i, int j, int l) {
  474. Tile tile = tileArray[i][j][l];
  475. if(tile == null || tile.obj2 == null)
  476. return 0;
  477. else
  478. return tile.obj2.uid;
  479. }
  480.  
  481. //fetchWallDecorationNewUID
  482. public int fetchWallDecorationNewUID(int i, int j, int l) {
  483. Tile tile = tileArray[i][j][l];
  484. if(tile == null || tile.obj2 == null)
  485. return 0;
  486. else
  487. return tile.obj2.newuid;
  488. }
  489.  
  490. //fetchObjectMeshUID
  491. public int method302(int z, int x, int y) {
  492. Tile tile = tileArray[z][x][y];
  493. if(tile == null)
  494. return 0;
  495. for(int l = 0; l < tile.gameObjectIndex; l++) {
  496. GameObject interactableObject = tile.gameObjects[l];
  497. if((interactableObject.uid >> 29 & 3) == 2 &&
  498. interactableObject.xLocLow == x && interactableObject.yLocHigh == y) {
  499. return interactableObject.uid;
  500. }
  501. }
  502. return 0;
  503. }
  504.  
  505. //fetchObjectMeshNewUID
  506. public int fetchObjectMeshNewUID(int z, int x, int y) {
  507. Tile tile = tileArray[z][x][y];
  508. if(tile == null)
  509. return 0;
  510. for(int l = 0; l < tile.gameObjectIndex; l++) {
  511. GameObject interactableObject = tile.gameObjects[l];
  512. if((interactableObject.uid >> 29 & 3) == 2 &&
  513. interactableObject.xLocLow == x && interactableObject.yLocHigh == y) {
  514. return interactableObject.newuid;
  515. }
  516. }
  517. return 0;
  518. }
  519. //fetchGroundDecorationUID
  520. public int method303(int i, int j, int k) {
  521. Tile tile = tileArray[i][j][k];
  522. if(tile == null || tile.groundDecoration == null)
  523. return 0;
  524. else
  525. return tile.groundDecoration.uid;
  526. }
  527.  
  528. //fetchGroundDecorationNewUID
  529. public int fetchGroundDecorationNewUID(int i, int j, int k) {
  530. Tile tile = tileArray[i][j][k];
  531. if(tile == null || tile.groundDecoration == null)
  532. return 0;
  533. else
  534. return tile.groundDecoration.newuid;
  535. }
  536.  
  537. //fetchObjectIDTAGForXYZ
  538. public int method304(int z, int x, int y, int objectMesh) {//fecthObjectIDXYZ
  539. Tile tile = tileArray[z][x][y];
  540. if(tile == null)
  541. return -1;
  542. if(tile.wallObject != null && tile.wallObject.uid == objectMesh)//obj1 = wall
  543. return tile.wallObject.aByte281 & 255;
  544. if(tile.obj2 != null && tile.obj2.uid == objectMesh)//obj2 = wallDec
  545. return tile.obj2.aByte506 & 255;
  546. if(tile.groundDecoration != null && tile.groundDecoration.uid == objectMesh)//obj3 = groundDec
  547. return tile.groundDecoration.aByte816 & 255;
  548. for(int i1 = 0; i1 < tile.gameObjectIndex; i1++)//anInt1317 = count?
  549. if(tile.gameObjects[i1].uid == objectMesh)
  550. return tile.gameObjects[i1].mask & 255;
  551.  
  552. return -1;
  553. }
  554.  
  555. public void shadeModels(int lightY, int lightX, int lightZ) {
  556. int intensity = 64;// was parameter
  557. int diffusion = 768;// was parameter
  558. int lightDistance = (int) Math.sqrt(lightX * lightX + lightY * lightY + lightZ * lightZ);
  559. int someLightQualityVariable = diffusion * lightDistance >> 8;
  560. for (int zLoc = 0; zLoc < numberOfZ; zLoc++) {
  561. for (int xLoc = 0; xLoc < maxX; xLoc++) {
  562. for (int yLoc = 0; yLoc < maxZ; yLoc++) {
  563. Tile tile = tileArray[zLoc][xLoc][yLoc];
  564. if (tile != null) {
  565. WallObject wallObject = tile.wallObject;
  566. if (wallObject != null && wallObject.renderable1 != null
  567. && wallObject.renderable1.normals != null) {
  568. method307(zLoc, 1, 1, xLoc, yLoc, (Model) wallObject.renderable1);
  569. if (wallObject.renderable2 != null && wallObject.renderable2.normals != null) {
  570. method307(zLoc, 1, 1, xLoc, yLoc, (Model) wallObject.renderable2);
  571. mergeNormals((Model) wallObject.renderable1, (Model) wallObject.renderable2, 0, 0,
  572. 0, false);
  573. ((Model) wallObject.renderable2).setLighting(intensity, someLightQualityVariable,
  574. lightX, lightY, lightZ);
  575. }
  576. ((Model) wallObject.renderable1).setLighting(intensity, someLightQualityVariable,
  577. lightX, lightY, lightZ);
  578. }
  579. for (int k2 = 0; k2 < tile.gameObjectIndex; k2++) {
  580. GameObject interactableObject = tile.gameObjects[k2];
  581. if (interactableObject != null && interactableObject.renderable != null
  582. && interactableObject.renderable.normals != null) {
  583. method307(zLoc, (interactableObject.xLocHigh - interactableObject.xLocLow) + 1,
  584. (interactableObject.yLocLow - interactableObject.yLocHigh) + 1, xLoc, yLoc,
  585. (Model) interactableObject.renderable);
  586. ((Model) interactableObject.renderable).setLighting(intensity,
  587. someLightQualityVariable, lightX, lightY, lightZ);
  588. }
  589. }
  590.  
  591. GroundObject groundDecoration = tile.groundDecoration;
  592. if (groundDecoration != null && groundDecoration.renderable.normals != null) {
  593. method306GroundDecorationOnly(xLoc, zLoc, (Model) groundDecoration.renderable, yLoc);
  594. ((Model) groundDecoration.renderable).setLighting(intensity, someLightQualityVariable,
  595. lightX, lightY, lightZ);
  596. }
  597.  
  598. }
  599. }
  600. }
  601. }
  602. }
  603.  
  604.  
  605. /* public void method306GroundDecorationOnly(int modelXLoc, int modelZLoc, Model model,
  606. int modelYLoc) { //TODO figure it out
  607. if (modelXLoc < maxX) {
  608. Tile tile = tileArray[modelZLoc][modelXLoc + 1][modelYLoc];
  609. if (tile != null && tile.groundDecoration != null
  610. && tile.groundDecoration.renderable.vertexNormals != null) {
  611. mergeNormals(model, (Model) tile.groundDecoration.renderable, 128, 0, 0, true);
  612. }
  613. }
  614. if (modelYLoc < maxX) {
  615. Tile tile = tileArray[modelZLoc][modelXLoc][modelYLoc + 1];
  616. if (tile != null && tile.groundDecoration != null
  617. && tile.groundDecoration.renderable.vertexNormals != null) {
  618. mergeNormals(model, (Model) tile.groundDecoration.renderable, 0, 0, 128, true);
  619. }
  620. }
  621. if (modelXLoc < maxX && modelYLoc < maxZ) {
  622. Tile tile = tileArray[modelZLoc][modelXLoc + 1][modelYLoc + 1];
  623. if (tile != null && tile.groundDecoration != null
  624. && tile.groundDecoration.renderable.vertexNormals != null) {
  625. mergeNormals(model, (Model) tile.groundDecoration.renderable, 128, 0, 128, true);
  626. }
  627. }
  628. if (modelXLoc < maxX && modelYLoc > 0) {
  629. Tile tile = tileArray[modelZLoc][modelXLoc + 1][modelYLoc - 1];
  630. if (tile != null && tile.groundDecoration != null
  631. && tile.groundDecoration.renderable.vertexNormals != null) {
  632. mergeNormals(model, (Model) tile.groundDecoration.renderable, 128, 0, -128, true);
  633. }
  634. }
  635. }
  636.  
  637.  
  638. public void method307(int modelZLoc, int modelXSize, int modelYSize, int modelXLoc,
  639. int modelYLoc, Model model) {
  640. boolean flag = true;
  641. int startX = modelXLoc;
  642. int stopX = modelXLoc + modelXSize;
  643. int startY = modelYLoc - 1;
  644. int stopY = modelYLoc + modelYSize;
  645. for (int zLoc = modelZLoc; zLoc <= modelZLoc + 1; zLoc++) {
  646. if (zLoc != numberOfZ) {//TODO Always?
  647. for (int xLoc = startX; xLoc <= stopX; xLoc++) {
  648. if (xLoc >= 0 && xLoc < maxX) {
  649. for (int yLoc = startY; yLoc <= stopY; yLoc++) {
  650. if (yLoc >= 0 && yLoc < maxZ && (!flag || xLoc >= stopX || yLoc >= stopY
  651. || yLoc < modelYLoc && xLoc != modelXLoc)) {
  652. Tile tile = tileArray[zLoc][xLoc][yLoc];
  653. if (tile != null) {
  654. int relativeHeightToModelTile = (heightMap[zLoc][xLoc][yLoc]
  655. + heightMap[zLoc][xLoc + 1][yLoc] + heightMap[zLoc][xLoc][yLoc + 1]
  656. + heightMap[zLoc][xLoc + 1][yLoc + 1]) / 4
  657. - (heightMap[modelZLoc][modelXLoc][modelYLoc]
  658. + heightMap[modelZLoc][modelXLoc + 1][modelYLoc]
  659. + heightMap[modelZLoc][modelXLoc][modelYLoc + 1]
  660. + heightMap[modelZLoc][modelXLoc + 1][modelYLoc + 1]) / 4;
  661. WallObject wallObject = tile.wallObject;
  662. if (wallObject != null && wallObject.renderable1 != null
  663. && wallObject.renderable1.vertexNormals != null) {
  664. mergeNormals(model, (Model) wallObject.renderable1,
  665. (xLoc - modelXLoc) * 128 + (1 - modelXSize) * 64, relativeHeightToModelTile,
  666. (yLoc - modelYLoc) * 128 + (1 - modelYSize) * 64, flag);
  667. }
  668. if (wallObject != null && wallObject.renderable2 != null
  669. && wallObject.renderable2.vertexNormals != null) {
  670. mergeNormals(model, (Model) wallObject.renderable2,
  671. (xLoc - modelXLoc) * 128 + (1 - modelXSize) * 64, relativeHeightToModelTile,
  672. (yLoc - modelYLoc) * 128 + (1 - modelYSize) * 64, flag);
  673. }
  674. for (int i = 0; i < tile.anInt1317; i++) {
  675. GameObject gameObject = tile.gameObjects[i];
  676. if (gameObject != null && gameObject.renderable != null
  677. && gameObject.renderable.vertexNormals != null) {
  678. int tiledObjectXSize = (gameObject.xLocHigh - gameObject.xLocLow) + 1;
  679. int tiledObjectYSize = (gameObject.yLocLow - gameObject.yLocHigh) + 1;
  680. mergeNormals(model, (Model) gameObject.renderable,
  681. (gameObject.xLocLow - modelXLoc) * 128
  682. + (tiledObjectXSize - modelXSize) * 64,
  683. relativeHeightToModelTile, (gameObject.yLocHigh - modelYLoc) * 128
  684. + (tiledObjectYSize - modelYSize) * 64,
  685. flag);
  686. }
  687. }
  688. }
  689. }
  690. }
  691. }
  692. }
  693. startX--;
  694. flag = false;
  695. }
  696. }
  697.  
  698. }*/
  699. private void method306GroundDecorationOnly(int modelXLoc, int modelZLoc, Model model, int modelYLoc) { //TODO figure it out
  700. if (modelXLoc < maxX) {
  701. Tile tile = tileArray[modelZLoc][modelXLoc + 1][modelYLoc];
  702. if (tile != null && tile.groundDecoration != null && tile.groundDecoration.renderable.normals != null)
  703. mergeNormals(model, (Model) tile.groundDecoration.renderable, 128, 0, 0, true);
  704. }
  705. if (modelYLoc < maxX) {
  706. Tile tile = tileArray[modelZLoc][modelXLoc][modelYLoc + 1];
  707. if (tile != null && tile.groundDecoration != null && tile.groundDecoration.renderable.normals != null)
  708. mergeNormals(model, (Model) tile.groundDecoration.renderable, 0, 0, 128, true);
  709. }
  710. if (modelXLoc < maxX && modelYLoc < maxZ) {
  711. Tile tile = tileArray[modelZLoc][modelXLoc + 1][modelYLoc + 1];
  712. if (tile != null && tile.groundDecoration != null && tile.groundDecoration.renderable.normals != null)
  713. mergeNormals(model, (Model) tile.groundDecoration.renderable, 128, 0, 128, true);
  714. }
  715. if (modelXLoc < maxX && modelYLoc > 0) {
  716. Tile tile = tileArray[modelZLoc][modelXLoc + 1][modelYLoc - 1];
  717. if (tile != null && tile.groundDecoration != null && tile.groundDecoration.renderable.normals != null)
  718. mergeNormals(model, (Model) tile.groundDecoration.renderable, 128, 0, -128, true);
  719. }
  720. }
  721.  
  722. private void method307(int modelZLoc, int modelXSize, int modelYSize, int modelXLoc, int modelYLoc, Model model) {
  723. boolean flag = true;
  724. int startX = modelXLoc;
  725. int stopX = modelXLoc + modelXSize;
  726. int startY = modelYLoc - 1;
  727. int stopY = modelYLoc + modelYSize;
  728. for (int zLoc = modelZLoc; zLoc <= modelZLoc + 1; zLoc++)
  729. if (zLoc != numberOfZ) {//TODO Always?
  730. for (int xLoc = startX; xLoc <= stopX; xLoc++)
  731. if (xLoc >= 0 && xLoc < maxX) {
  732. for (int yLoc = startY; yLoc <= stopY; yLoc++)
  733. if (yLoc >= 0 && yLoc < maxZ && (!flag || xLoc >= stopX || yLoc >= stopY || yLoc < modelYLoc && xLoc != modelXLoc)) {
  734. Tile tile = tileArray[zLoc][xLoc][yLoc];
  735. if (tile != null) {
  736. int relativeHeightToModelTile = (heightMap[zLoc][xLoc][yLoc] + heightMap[zLoc][xLoc + 1][yLoc] + heightMap[zLoc][xLoc][yLoc + 1] + heightMap[zLoc][xLoc + 1][yLoc + 1]) / 4 - (heightMap[modelZLoc][modelXLoc][modelYLoc] + heightMap[modelZLoc][modelXLoc + 1][modelYLoc] + heightMap[modelZLoc][modelXLoc][modelYLoc + 1] + heightMap[modelZLoc][modelXLoc + 1][modelYLoc + 1]) / 4;
  737. WallObject wallObject = tile.wallObject;
  738. if (wallObject != null && wallObject.renderable1 != null && wallObject.renderable1.normals != null)
  739. mergeNormals(model, (Model) wallObject.renderable1, (xLoc - modelXLoc) * 128 + (1 - modelXSize) * 64, relativeHeightToModelTile, (yLoc - modelYLoc) * 128 + (1 - modelYSize) * 64, flag);
  740. if (wallObject != null && wallObject.renderable2 != null && wallObject.renderable2.normals != null)
  741. mergeNormals(model, (Model) wallObject.renderable2, (xLoc - modelXLoc) * 128 + (1 - modelXSize) * 64, relativeHeightToModelTile, (yLoc - modelYLoc) * 128 + (1 - modelYSize) * 64, flag);
  742. for (int i = 0; i < tile.gameObjectIndex; i++) {
  743. GameObject gameObject = tile.gameObjects[i];
  744. if (gameObject != null && gameObject.renderable != null && gameObject.renderable.normals != null) {
  745. int tiledObjectXSize = (gameObject.xLocHigh - gameObject.xLocLow) + 1;
  746. int tiledObjectYSize = (gameObject.yLocLow - gameObject.yLocHigh) + 1;
  747. mergeNormals(model, (Model) gameObject.renderable, (gameObject.xLocLow - modelXLoc) * 128 + (tiledObjectXSize - modelXSize) * 64, relativeHeightToModelTile, (gameObject.yLocHigh - modelYLoc) * 128 + (tiledObjectYSize - modelYSize) * 64, flag);
  748. }
  749. }
  750. }
  751. }
  752. }
  753. startX--; //TODO why?
  754. flag = false;
  755. }
  756.  
  757. }
  758.  
  759.  
  760. private void mergeNormals(Model first, Model second, int dx, int dy, int dz, boolean flag) {
  761. anInt488++;
  762. int count = 0;
  763. int[] secondX = second.verticesX;
  764. int secondVertices = second.verticesCount;
  765. for (int vA = 0; vA < first.verticesCount; vA++) {
  766.  
  767. if (first == null || first.vertexNormalsOffsets[vA] == null) {
  768. return;
  769. }
  770. VertexNormal parentNormalA = first.normals[vA];
  771. VertexNormal normalA = first.vertexNormalsOffsets[vA];
  772.  
  773. if (normalA.magnitude != 0) {
  774. int y = first.verticesY[vA] - dy;
  775. if (y <= second.maximumYVertex) {
  776.  
  777. int x = first.verticesX[vA] - dx;
  778. if (x >= second.minimumXVertex && x <= second.maximumXVertex) {
  779.  
  780. int z = first.verticesZ[vA] - dz;
  781. if (z >= second.minimumZVertex && z <= second.maximumZVertex) {
  782. for (int vB = 0; vB < secondVertices; vB++) {
  783. VertexNormal parentNormalB = second.normals[vB];
  784. VertexNormal normalB = second.vertexNormalsOffsets[vB];
  785.  
  786. if (x == secondX[vB] && z == second.verticesZ[vB] && y == second.verticesY[vB] && normalB.magnitude != 0) {
  787. parentNormalA.x += normalB.x;
  788. parentNormalA.y += normalB.y;
  789. parentNormalA.z += normalB.z;
  790. parentNormalA.magnitude += normalB.magnitude;
  791. parentNormalB.x += normalA.x;
  792. parentNormalB.y += normalA.y;
  793. parentNormalB.z += normalA.z;
  794. parentNormalB.magnitude += normalA.magnitude;
  795. count++;
  796. anIntArray486[vA] = anInt488;
  797. anIntArray487[vB] = anInt488;
  798. }
  799. }
  800. }
  801. }
  802. }
  803. }
  804. }
  805.  
  806. if (count < 3 || !flag) {
  807. return;
  808. }
  809.  
  810. for (int k1 = 0; k1 < first.trianglesCount; k1++) {
  811. if (anIntArray486[first.trianglesX[k1]] == anInt488 && anIntArray486[first.trianglesY[k1]] == anInt488
  812. && anIntArray486[first.trianglesZ[k1]] == anInt488) {
  813. first.types[k1] = -1;
  814. }
  815. }
  816.  
  817. for (int l1 = 0; l1 < second.trianglesCount; l1++) {
  818. if (anIntArray487[second.trianglesX[l1]] == anInt488 && anIntArray487[second.trianglesY[l1]] == anInt488
  819. && anIntArray487[second.trianglesZ[l1]] == anInt488) {
  820. second.types[l1] = -1;
  821. }
  822. }
  823. }
  824.  
  825. public void drawTileMinimapSD(int pixels[], int drawIndex, int zLoc, int xLoc, int yLoc) {
  826. int leftOverWidth = 512;// was parameter
  827. Tile tile = tileArray[zLoc][xLoc][yLoc];
  828. if (tile == null)
  829. return;
  830. SimpleTile simpleTile = tile.mySimpleTile;
  831. if (simpleTile != null) {
  832. int tileRGB = simpleTile.colorRGB;
  833. if (tileRGB == 0)
  834. return;
  835. for (int i = 0; i < 4; i++) {
  836. pixels[drawIndex] = tileRGB;
  837. pixels[drawIndex + 1] = tileRGB;
  838. pixels[drawIndex + 2] = tileRGB;
  839. pixels[drawIndex + 3] = tileRGB;
  840. drawIndex += leftOverWidth;
  841. }
  842. return;
  843. }
  844. ShapedTile shapedTile = tile.myShapedTile;
  845.  
  846. if (shapedTile == null) {
  847. return;
  848. }
  849.  
  850. int shape = shapedTile.shape;
  851. int rotation = shapedTile.rotation;
  852. int underlayRGB = shapedTile.colourRGB;
  853. int overlayRGB = shapedTile.colourRGBA;
  854. int shapePoints[] = tileVertices[shape];
  855. int shapePointIndices[] = tileVertexIndices[rotation];
  856. int shapePtr = 0;
  857. if (underlayRGB != 0) {
  858. for (int i = 0; i < 4; i++) {
  859. pixels[drawIndex] = shapePoints[shapePointIndices[shapePtr++]] != 0 ? overlayRGB : underlayRGB;
  860. pixels[drawIndex + 1] = shapePoints[shapePointIndices[shapePtr++]] != 0 ? overlayRGB : underlayRGB;
  861. pixels[drawIndex + 2] = shapePoints[shapePointIndices[shapePtr++]] != 0 ? overlayRGB : underlayRGB;
  862. pixels[drawIndex + 3] = shapePoints[shapePointIndices[shapePtr++]] != 0 ? overlayRGB : underlayRGB;
  863. drawIndex += leftOverWidth;
  864. }
  865. return;
  866. }
  867. for (int i = 0; i < 4; i++) {
  868. if (shapePoints[shapePointIndices[shapePtr++]] != 0)
  869. pixels[drawIndex] = overlayRGB;
  870. if (shapePoints[shapePointIndices[shapePtr++]] != 0)
  871. pixels[drawIndex + 1] = overlayRGB;
  872. if (shapePoints[shapePointIndices[shapePtr++]] != 0)
  873. pixels[drawIndex + 2] = overlayRGB;
  874. if (shapePoints[shapePointIndices[shapePtr++]] != 0)
  875. pixels[drawIndex + 3] = overlayRGB;
  876. drawIndex += leftOverWidth;
  877. }
  878. }
  879. public static void buildVisibilityMap(int i, int j, int viewportWidth, int viewportHeight, int ai[]) {
  880. xMin = 0;
  881. yMin = 0;
  882. SceneGraph.xMax = viewportWidth;
  883. SceneGraph.yMax = viewportHeight;
  884. viewportHalfWidth = viewportWidth / 2;
  885. viewportHalfHeight = viewportHeight / 2;
  886. boolean aflag[][][][] = new boolean[9][32][53][53];
  887. for (int zAngle = 128; zAngle <= 384; zAngle += 32) {
  888. for (int xyAngle = 0; xyAngle < 2048; xyAngle += 64) {
  889. camUpDownY = Model.SINE[zAngle];
  890. camUpDownX = Model.COSINE[zAngle];
  891. camLeftRightY = Model.SINE[xyAngle];
  892. camLeftRightX = Model.COSINE[xyAngle];
  893. int angularZSegment = (zAngle - 128) / 32;
  894. int angularXYSegment = xyAngle / 64;
  895. for (int xRelativeToCamera = -26; xRelativeToCamera <= 26; xRelativeToCamera++) {
  896. for (int yRelativeToCamera = -26; yRelativeToCamera <= 26; yRelativeToCamera++) {
  897. int xRelativeToCameraPos = xRelativeToCamera * 128;
  898. int yRelativeToCameraPos = yRelativeToCamera * 128;
  899. boolean flag2 = false;
  900. for (int k4 = -i; k4 <= j; k4 += 128) {
  901. if (!method311(ai[angularZSegment] + k4, yRelativeToCameraPos, xRelativeToCameraPos))
  902. continue;
  903. flag2 = true;
  904. break;
  905. }
  906. aflag[angularZSegment][angularXYSegment][xRelativeToCamera + 26][yRelativeToCamera + 26] = flag2;
  907. }
  908. }
  909. }
  910. }
  911.  
  912. for (int angularZSegment = 0; angularZSegment < 8; angularZSegment++) {
  913. for (int angularXYSegment = 0; angularXYSegment < 32; angularXYSegment++) {
  914. for (int xRelativeToCamera = -25; xRelativeToCamera < 25; xRelativeToCamera++) {
  915. for (int yRelativeToCamera = -25; yRelativeToCamera < 25; yRelativeToCamera++) {
  916. boolean flag1 = false;
  917. label0:
  918. for (int l3 = -1; l3 <= 1; l3++) {
  919. for (int j4 = -1; j4 <= 1; j4++) {
  920. if (aflag[angularZSegment][angularXYSegment][xRelativeToCamera + l3 + 26][yRelativeToCamera + j4 + 26])
  921. flag1 = true;
  922. else if (aflag[angularZSegment][(angularXYSegment + 1) % 31][xRelativeToCamera + l3 + 26][yRelativeToCamera + j4 + 26])
  923. flag1 = true;
  924. else if (aflag[angularZSegment + 1][angularXYSegment][xRelativeToCamera + l3 + 26][yRelativeToCamera + j4 + 26]) {
  925. flag1 = true;
  926. } else {
  927. if (!aflag[angularZSegment + 1][(angularXYSegment + 1) % 31][xRelativeToCamera + l3 + 26][yRelativeToCamera + j4 + 26])
  928. continue;
  929. flag1 = true;
  930. }
  931. break label0;
  932. }
  933. }
  934. visibilityMap[angularZSegment][angularXYSegment][xRelativeToCamera + 25][yRelativeToCamera + 25] = flag1;
  935. }
  936. }
  937. }
  938. }
  939. }
  940.  
  941.  
  942. private static boolean method311(int i, int j, int k) {
  943. int l = j * camLeftRightY + k * camLeftRightX >> 16;
  944. int i1 = j * camLeftRightX - k * camLeftRightY >> 16;
  945. int j1 = i * camUpDownY + i1 * camUpDownX >> 16;
  946. int k1 = i * camUpDownX - i1 * camUpDownY >> 16;
  947. if (j1 < 50 || j1 > 3500) {
  948. return false;
  949. }
  950. int l1 = viewportHalfWidth + (l * SceneGraph.focalLength) / j1;
  951. int i2 = viewportHalfHeight + (k1 * SceneGraph.focalLength) / j1;
  952. return l1 >= xMin && l1 <= xMax && i2 >= yMin
  953. && i2 <= yMax;
  954. }
  955.  
  956. public void clickTile(int i, int j) {
  957. clicked = true;
  958. clickScreenX = j;
  959. clickScreenY = i;
  960. clickedTileX = -1;
  961. clickedTileY = -1;
  962. }
  963.  
  964. public void render(int i, int j, int k, int l, int i1, int j1) {
  965. if (i < 0)
  966. i = 0;
  967. else if (i >= maxX * 128)
  968. i = maxX * 128 - 1;
  969. if (j < 0)
  970. j = 0;
  971. else if (j >= maxZ * 128)
  972. j = maxZ * 128 - 1;
  973. anInt448++;
  974. camUpDownY = Model.SINE[j1];
  975. camUpDownX = Model.COSINE[j1];
  976. camLeftRightY = Model.SINE[k];
  977. camLeftRightX = Model.COSINE[k];
  978. renderArea = visibilityMap[(j1 - 128) / 32][k / 64];
  979. cameraX2 = i;
  980. cameraY2 = l;
  981. cameraZ2 = j;
  982. screenCenterX = i / 128;
  983. yCameraTile = j / 128;
  984. currentRenderPlane = i1;
  985. cameraLowTileX = screenCenterX - 25;
  986. if (cameraLowTileX < 0)
  987. cameraLowTileX = 0;
  988. cameraLowTileY = yCameraTile - 25;
  989. if (cameraLowTileY < 0)
  990. cameraLowTileY = 0;
  991. cameraHighTileX = screenCenterX + 25;
  992. if (cameraHighTileX > maxX)
  993. cameraHighTileX = maxX;
  994. cameraHighTileY = yCameraTile + 25;
  995. if (cameraHighTileY > maxZ)
  996. cameraHighTileY = maxZ;
  997. occlude();
  998. anInt446 = 0;
  999. for (int k1 = zAnInt442; k1 < numberOfZ; k1++) {
  1000. Tile aclass30_sub3[][] = tileArray[k1];
  1001. for (int i2 = cameraLowTileX; i2 < cameraHighTileX; i2++) {
  1002. for (int k2 = cameraLowTileY; k2 < cameraHighTileY; k2++) {
  1003. Tile class30_sub3 = aclass30_sub3[i2][k2];
  1004. if (class30_sub3 != null)
  1005. if (class30_sub3.logicHeight > i1
  1006. || !renderArea[(i2 - screenCenterX) + 25][(k2 - yCameraTile) + 25]
  1007. && heightMap[k1][i2][k2] - l < 2000) {
  1008. class30_sub3.aBoolean1322 = false;
  1009. class30_sub3.aBoolean1323 = false;
  1010. class30_sub3.anInt1325 = 0;
  1011. } else {
  1012. class30_sub3.aBoolean1322 = true;
  1013. class30_sub3.aBoolean1323 = true;
  1014. class30_sub3.aBoolean1324 = class30_sub3.gameObjectIndex > 0;
  1015. anInt446++;
  1016. }
  1017. }
  1018.  
  1019. }
  1020.  
  1021. }
  1022.  
  1023. for (int l1 = zAnInt442; l1 < numberOfZ; l1++) {
  1024. Tile aclass30_sub3_1[][] = tileArray[l1];
  1025. for (int l2 = -25; l2 <= 0; l2++) {
  1026. int i3 = screenCenterX + l2;
  1027. int k3 = screenCenterX - l2;
  1028. if (i3 >= cameraLowTileX || k3 < cameraHighTileX) {
  1029. for (int i4 = -25; i4 <= 0; i4++) {
  1030. int k4 = yCameraTile + i4;
  1031. int i5 = yCameraTile - i4;
  1032. if (i3 >= cameraLowTileX) {
  1033. if (k4 >= cameraLowTileY) {
  1034. Tile class30_sub3_1 = aclass30_sub3_1[i3][k4];
  1035. if (class30_sub3_1 != null
  1036. && class30_sub3_1.aBoolean1322)
  1037. drawTile(class30_sub3_1, true);
  1038. }
  1039. if (i5 < cameraHighTileY) {
  1040. Tile class30_sub3_2 = aclass30_sub3_1[i3][i5];
  1041. if (class30_sub3_2 != null
  1042. && class30_sub3_2.aBoolean1322)
  1043. drawTile(class30_sub3_2, true);
  1044. }
  1045. }
  1046. if (k3 < cameraHighTileX) {
  1047. if (k4 >= cameraLowTileY) {
  1048. Tile class30_sub3_3 = aclass30_sub3_1[k3][k4];
  1049. if (class30_sub3_3 != null
  1050. && class30_sub3_3.aBoolean1322)
  1051. drawTile(class30_sub3_3, true);
  1052. }
  1053. if (i5 < cameraHighTileY) {
  1054. Tile class30_sub3_4 = aclass30_sub3_1[k3][i5];
  1055. if (class30_sub3_4 != null
  1056. && class30_sub3_4.aBoolean1322)
  1057. drawTile(class30_sub3_4, true);
  1058. }
  1059. }
  1060. if (anInt446 == 0) {
  1061. clicked = false;
  1062. return;
  1063. }
  1064. }
  1065.  
  1066. }
  1067. }
  1068.  
  1069. }
  1070.  
  1071. for (int j2 = zAnInt442; j2 < numberOfZ; j2++) {
  1072. Tile aclass30_sub3_2[][] = tileArray[j2];
  1073. for (int j3 = -25; j3 <= 0; j3++) {
  1074. int l3 = screenCenterX + j3;
  1075. int j4 = screenCenterX - j3;
  1076. if (l3 >= cameraLowTileX || j4 < cameraHighTileX) {
  1077. for (int l4 = -25; l4 <= 0; l4++) {
  1078. int j5 = yCameraTile + l4;
  1079. int k5 = yCameraTile - l4;
  1080. if (l3 >= cameraLowTileX) {
  1081. if (j5 >= cameraLowTileY) {
  1082. Tile class30_sub3_5 = aclass30_sub3_2[l3][j5];
  1083. if (class30_sub3_5 != null
  1084. && class30_sub3_5.aBoolean1322)
  1085. drawTile(class30_sub3_5, false);
  1086. }
  1087. if (k5 < cameraHighTileY) {
  1088. Tile class30_sub3_6 = aclass30_sub3_2[l3][k5];
  1089. if (class30_sub3_6 != null
  1090. && class30_sub3_6.aBoolean1322)
  1091. drawTile(class30_sub3_6, false);
  1092. }
  1093. }
  1094. if (j4 < cameraHighTileX) {
  1095. if (j5 >= cameraLowTileY) {
  1096. Tile class30_sub3_7 = aclass30_sub3_2[j4][j5];
  1097. if (class30_sub3_7 != null
  1098. && class30_sub3_7.aBoolean1322)
  1099. drawTile(class30_sub3_7, false);
  1100. }
  1101. if (k5 < cameraHighTileY) {
  1102. Tile class30_sub3_8 = aclass30_sub3_2[j4][k5];
  1103. if (class30_sub3_8 != null
  1104. && class30_sub3_8.aBoolean1322)
  1105. drawTile(class30_sub3_8, false);
  1106. }
  1107. }
  1108. if (anInt446 == 0) {
  1109. clicked = false;
  1110. return;
  1111. }
  1112. }
  1113.  
  1114. }
  1115. }
  1116.  
  1117. }
  1118. clicked = false;
  1119. }
  1120.  
  1121. private void drawTile(Tile tile, boolean flag) {
  1122. tileDeque.insertHead(tile);
  1123. do {
  1124. Tile currentTile;
  1125. do {
  1126. currentTile = (Tile) tileDeque.popHead();
  1127. if (currentTile == null)
  1128. return;
  1129. } while (!currentTile.aBoolean1323);
  1130. int i = currentTile.anInt1308;
  1131. int j = currentTile.anInt1309;
  1132. int k = currentTile.z1AnInt1307;
  1133. int l = currentTile.renderLevel;
  1134. Tile aclass30_sub3[][] = tileArray[k];
  1135. if (currentTile.aBoolean1322) {
  1136. if (flag) {
  1137. if (k > 0) {
  1138. Tile class30_sub3_2 = tileArray[k - 1][i][j];
  1139. if (class30_sub3_2 != null
  1140. && class30_sub3_2.aBoolean1323)
  1141. continue;
  1142. }
  1143. if (i <= screenCenterX && i > cameraLowTileX) {
  1144. Tile class30_sub3_3 = aclass30_sub3[i - 1][j];
  1145. if (class30_sub3_3 != null
  1146. && class30_sub3_3.aBoolean1323
  1147. && (class30_sub3_3.aBoolean1322 || (currentTile.totalTiledObjectMask & 1) == 0))
  1148. continue;
  1149. }
  1150. if (i >= screenCenterX && i < cameraHighTileX - 1) {
  1151. Tile class30_sub3_4 = aclass30_sub3[i + 1][j];
  1152. if (class30_sub3_4 != null
  1153. && class30_sub3_4.aBoolean1323
  1154. && (class30_sub3_4.aBoolean1322 || (currentTile.totalTiledObjectMask & 4) == 0))
  1155. continue;
  1156. }
  1157. if (j <= yCameraTile && j > cameraLowTileY) {
  1158. Tile class30_sub3_5 = aclass30_sub3[i][j - 1];
  1159. if (class30_sub3_5 != null
  1160. && class30_sub3_5.aBoolean1323
  1161. && (class30_sub3_5.aBoolean1322 || (currentTile.totalTiledObjectMask & 8) == 0))
  1162. continue;
  1163. }
  1164. if (j >= yCameraTile && j < cameraHighTileY - 1) {
  1165. Tile class30_sub3_6 = aclass30_sub3[i][j + 1];
  1166. if (class30_sub3_6 != null
  1167. && class30_sub3_6.aBoolean1323
  1168. && (class30_sub3_6.aBoolean1322 || (currentTile.totalTiledObjectMask & 2) == 0))
  1169. continue;
  1170. }
  1171. } else {
  1172. flag = true;
  1173. }
  1174. currentTile.aBoolean1322 = false;
  1175. if (currentTile.firstFloorTile != null) {
  1176. Tile class30_sub3_7 = currentTile.firstFloorTile;
  1177. if (class30_sub3_7.mySimpleTile != null) {
  1178. if (!method320(0, i, j))
  1179. drawTileUnderlay(class30_sub3_7.mySimpleTile, 0,
  1180. camUpDownY, camUpDownX, camLeftRightY, camLeftRightX, i,
  1181. j);
  1182. } else if (class30_sub3_7.myShapedTile != null
  1183. && !method320(0, i, j))
  1184. drawTileOverlaySD(i, camUpDownY, camLeftRightY,
  1185. class30_sub3_7.myShapedTile, camUpDownX, j,
  1186. camLeftRightX);
  1187. WallObject class10 = class30_sub3_7.wallObject;
  1188. if (class10 != null)
  1189. class10.renderable1.renderAtPoint(0, camUpDownY,
  1190. camUpDownX, camLeftRightY, camLeftRightX, class10.anInt274
  1191. - cameraX2,
  1192. class10.anInt273 - cameraY2, class10.anInt275
  1193. - cameraZ2, class10.uid, class10.getNewUID());
  1194. for (int i2 = 0; i2 < class30_sub3_7.gameObjectIndex; i2++) {
  1195. GameObject class28 = class30_sub3_7.gameObjects[i2];
  1196. if (class28 != null)
  1197. class28.renderable.renderAtPoint(
  1198. class28.turnValue, camUpDownY, camUpDownX,
  1199. camLeftRightY, camLeftRightX, class28.xPos
  1200. - cameraX2, class28.tileHeight
  1201. - cameraY2, class28.yPos
  1202. - cameraZ2, class28.uid, class28.getNewUID());
  1203. }
  1204.  
  1205. }
  1206. boolean flag1 = false;
  1207. if (currentTile.mySimpleTile != null) {
  1208. if (!method320(l, i, j)) {
  1209. flag1 = true;
  1210. drawTileUnderlay(currentTile.mySimpleTile, l, camUpDownY,
  1211. camUpDownX, camLeftRightY, camLeftRightX, i, j);
  1212. }
  1213. } else if (currentTile.myShapedTile != null
  1214. && !method320(l, i, j)) {
  1215. flag1 = true;
  1216. drawTileOverlaySD(i, camUpDownY, camLeftRightY,
  1217. currentTile.myShapedTile, camUpDownX, j, camLeftRightX);
  1218. }
  1219. int j1 = 0;
  1220. int j2 = 0;
  1221. WallObject class10_3 = currentTile.wallObject;
  1222. WallDecoration class26_1 = currentTile.obj2;
  1223. if (class10_3 != null || class26_1 != null) {
  1224. if (screenCenterX == i)
  1225. j1++;
  1226. else if (screenCenterX < i)
  1227. j1 += 2;
  1228. if (yCameraTile == j)
  1229. j1 += 3;
  1230. else if (yCameraTile > j)
  1231. j1 += 6;
  1232. j2 = anIntArray478[j1];
  1233. currentTile.anInt1328 = anIntArray480[j1];
  1234. }
  1235. if (class10_3 != null) {
  1236. if ((class10_3.orientation & anIntArray479[j1]) != 0) {
  1237. if (class10_3.orientation == 16) {
  1238. currentTile.anInt1325 = 3;
  1239. currentTile.anInt1326 = anIntArray481[j1];
  1240. currentTile.anInt1327 = 3 - currentTile.anInt1326;
  1241. } else if (class10_3.orientation == 32) {
  1242. currentTile.anInt1325 = 6;
  1243. currentTile.anInt1326 = anIntArray482[j1];
  1244. currentTile.anInt1327 = 6 - currentTile.anInt1326;
  1245. } else if (class10_3.orientation == 64) {
  1246. currentTile.anInt1325 = 12;
  1247. currentTile.anInt1326 = anIntArray483[j1];
  1248. currentTile.anInt1327 = 12 - currentTile.anInt1326;
  1249. } else {
  1250. currentTile.anInt1325 = 9;
  1251. currentTile.anInt1326 = anIntArray484[j1];
  1252. currentTile.anInt1327 = 9 - currentTile.anInt1326;
  1253. }
  1254. } else {
  1255. currentTile.anInt1325 = 0;
  1256. }
  1257. if ((class10_3.orientation & j2) != 0
  1258. && !method321(l, i, j, class10_3.orientation))
  1259. class10_3.renderable1.renderAtPoint(0, camUpDownY,
  1260. camUpDownX, camLeftRightY, camLeftRightX,
  1261. class10_3.anInt274 - cameraX2,
  1262. class10_3.anInt273 - cameraY2,
  1263. class10_3.anInt275 - cameraZ2, class10_3.uid, class10_3.getNewUID());
  1264. if ((class10_3.orientation1 & j2) != 0
  1265. && !method321(l, i, j, class10_3.orientation1))
  1266. class10_3.renderable2.renderAtPoint(0, camUpDownY,
  1267. camUpDownX, camLeftRightY, camLeftRightX,
  1268. class10_3.anInt274 - cameraX2,
  1269. class10_3.anInt273 - cameraY2,
  1270. class10_3.anInt275 - cameraZ2, class10_3.uid, class10_3.getNewUID());
  1271. }
  1272. if (class26_1 != null
  1273. && !method322(l, i, j,
  1274. class26_1.aClass30_Sub2_Sub4_504.modelBaseY))
  1275. if ((class26_1.anInt502 & j2) != 0)
  1276. class26_1.aClass30_Sub2_Sub4_504.renderAtPoint(
  1277. class26_1.anInt503, camUpDownY, camUpDownX,
  1278. camLeftRightY, camLeftRightX, class26_1.anInt500
  1279. - cameraX2, class26_1.anInt499
  1280. - cameraY2, class26_1.anInt501
  1281. - cameraZ2, class26_1.uid, class26_1.getNewUID());
  1282. else if ((class26_1.anInt502 & 0x300) != 0) {
  1283. int j4 = class26_1.anInt500 - cameraX2;
  1284. int l5 = class26_1.anInt499 - cameraY2;
  1285. int k6 = class26_1.anInt501 - cameraZ2;
  1286. int i8 = class26_1.anInt503;
  1287. int k9;
  1288. if (i8 == 1 || i8 == 2)
  1289. k9 = -j4;
  1290. else
  1291. k9 = j4;
  1292. int k10;
  1293. if (i8 == 2 || i8 == 3)
  1294. k10 = -k6;
  1295. else
  1296. k10 = k6;
  1297. if ((class26_1.anInt502 & 0x100) != 0 && k10 < k9) {
  1298. int i11 = j4 + anIntArray463[i8];
  1299. int k11 = k6 + anIntArray464[i8];
  1300. class26_1.aClass30_Sub2_Sub4_504.renderAtPoint(
  1301. i8 * 512 + 256, camUpDownY, camUpDownX,
  1302. camLeftRightY, camLeftRightX, i11, l5, k11,
  1303. class26_1.uid, class26_1.getNewUID());
  1304. }
  1305. if ((class26_1.anInt502 & 0x200) != 0 && k10 > k9) {
  1306. int j11 = j4 + anIntArray465[i8];
  1307. int l11 = k6 + anIntArray466[i8];
  1308. class26_1.aClass30_Sub2_Sub4_504.renderAtPoint(
  1309. i8 * 512 + 1280 & 0x7ff, camUpDownY,
  1310. camUpDownX, camLeftRightY, camLeftRightX, j11, l5, l11,
  1311. class26_1.uid, class26_1.getNewUID());
  1312. }
  1313. }
  1314. if (flag1) {
  1315. GroundObject class49 = currentTile.groundDecoration;
  1316. if (class49 != null)
  1317. class49.renderable.renderAtPoint(0, camUpDownY,
  1318. camUpDownX, camLeftRightY, camLeftRightX, class49.anInt812
  1319. - cameraX2,
  1320. class49.anInt811 - cameraY2, class49.anInt813
  1321. - cameraZ2, class49.uid, class49.getNewUID());
  1322. Object4 object4_1 = currentTile.obj4;
  1323. if (object4_1 != null && object4_1.anInt52 == 0) {
  1324. if (object4_1.aClass30_Sub2_Sub4_49 != null)
  1325. object4_1.aClass30_Sub2_Sub4_49
  1326. .renderAtPoint(0, camUpDownY, camUpDownX, camLeftRightY,
  1327. camLeftRightX, object4_1.anInt46
  1328. - cameraX2,
  1329. object4_1.anInt45 - cameraY2,
  1330. object4_1.anInt47 - cameraZ2,
  1331. object4_1.uid, object4_1.getNewUID());
  1332. if (object4_1.aClass30_Sub2_Sub4_50 != null)
  1333. object4_1.aClass30_Sub2_Sub4_50
  1334. .renderAtPoint(0, camUpDownY, camUpDownX, camLeftRightY,
  1335. camLeftRightX, object4_1.anInt46
  1336. - cameraX2,
  1337. object4_1.anInt45 - cameraY2,
  1338. object4_1.anInt47 - cameraZ2,
  1339. object4_1.uid, object4_1.getNewUID());
  1340. if (object4_1.aClass30_Sub2_Sub4_48 != null)
  1341. object4_1.aClass30_Sub2_Sub4_48
  1342. .renderAtPoint(0, camUpDownY, camUpDownX, camLeftRightY,
  1343. camLeftRightX, object4_1.anInt46
  1344. - cameraX2,
  1345. object4_1.anInt45 - cameraY2,
  1346. object4_1.anInt47 - cameraZ2,
  1347. object4_1.uid, object4_1.getNewUID());
  1348. }
  1349. }
  1350. int k4 = currentTile.totalTiledObjectMask;
  1351. if (k4 != 0) {
  1352. if (i < screenCenterX && (k4 & 4) != 0) {
  1353. Tile class30_sub3_17 = aclass30_sub3[i + 1][j];
  1354. if (class30_sub3_17 != null
  1355. && class30_sub3_17.aBoolean1323)
  1356. tileDeque.insertHead(class30_sub3_17);
  1357. }
  1358. if (j < yCameraTile && (k4 & 2) != 0) {
  1359. Tile class30_sub3_18 = aclass30_sub3[i][j + 1];
  1360. if (class30_sub3_18 != null
  1361. && class30_sub3_18.aBoolean1323)
  1362. tileDeque.insertHead(class30_sub3_18);
  1363. }
  1364. if (i > screenCenterX && (k4 & 1) != 0) {
  1365. Tile class30_sub3_19 = aclass30_sub3[i - 1][j];
  1366. if (class30_sub3_19 != null
  1367. && class30_sub3_19.aBoolean1323)
  1368. tileDeque.insertHead(class30_sub3_19);
  1369. }
  1370. if (j > yCameraTile && (k4 & 8) != 0) {
  1371. Tile class30_sub3_20 = aclass30_sub3[i][j - 1];
  1372. if (class30_sub3_20 != null
  1373. && class30_sub3_20.aBoolean1323)
  1374. tileDeque.insertHead(class30_sub3_20);
  1375. }
  1376. }
  1377. }
  1378. if (currentTile.anInt1325 != 0) {
  1379. boolean flag2 = true;
  1380. for (int k1 = 0; k1 < currentTile.gameObjectIndex; k1++) {
  1381. if (currentTile.gameObjects[k1].anInt528 == anInt448
  1382. || (currentTile.gameObjectsChanged[k1] & currentTile.anInt1325) != currentTile.anInt1326)
  1383. continue;
  1384. flag2 = false;
  1385. break;
  1386. }
  1387.  
  1388. if (flag2) {
  1389. WallObject class10_1 = currentTile.wallObject;
  1390. if (!method321(l, i, j, class10_1.orientation))
  1391. class10_1.renderable1.renderAtPoint(0, camUpDownY,
  1392. camUpDownX, camLeftRightY, camLeftRightX,
  1393. class10_1.anInt274 - cameraX2,
  1394. class10_1.anInt273 - cameraY2,
  1395. class10_1.anInt275 - cameraZ2, class10_1.uid, class10_1.getNewUID());
  1396. currentTile.anInt1325 = 0;
  1397. }
  1398. }
  1399. if (currentTile.aBoolean1324)
  1400. try {
  1401. int i1 = currentTile.gameObjectIndex;
  1402. currentTile.aBoolean1324 = false;
  1403. int l1 = 0;
  1404. label0:
  1405. for (int k2 = 0; k2 < i1; k2++) {
  1406. GameObject class28_1 = currentTile.gameObjects[k2];
  1407. if (class28_1.anInt528 == anInt448)
  1408. continue;
  1409. for (int k3 = class28_1.xLocLow; k3 <= class28_1.xLocHigh; k3++) {
  1410. for (int l4 = class28_1.yLocHigh; l4 <= class28_1.yLocLow; l4++) {
  1411. Tile class30_sub3_21 = aclass30_sub3[k3][l4];
  1412. if (class30_sub3_21.aBoolean1322) {
  1413. currentTile.aBoolean1324 = true;
  1414. } else {
  1415. if (class30_sub3_21.anInt1325 == 0)
  1416. continue;
  1417. int l6 = 0;
  1418. if (k3 > class28_1.xLocLow)
  1419. l6++;
  1420. if (k3 < class28_1.xLocHigh)
  1421. l6 += 4;
  1422. if (l4 > class28_1.yLocHigh)
  1423. l6 += 8;
  1424. if (l4 < class28_1.yLocLow)
  1425. l6 += 2;
  1426. if ((l6 & class30_sub3_21.anInt1325) != currentTile.anInt1327)
  1427. continue;
  1428. currentTile.aBoolean1324 = true;
  1429. }
  1430. continue label0;
  1431. }
  1432.  
  1433. }
  1434.  
  1435. interactableObjects[l1++] = class28_1;
  1436. int i5 = screenCenterX - class28_1.xLocLow;
  1437. int i6 = class28_1.xLocHigh - screenCenterX;
  1438. if (i6 > i5)
  1439. i5 = i6;
  1440. int i7 = yCameraTile - class28_1.yLocHigh;
  1441. int j8 = class28_1.yLocLow - yCameraTile;
  1442. if (j8 > i7)
  1443. class28_1.anInt527 = i5 + j8;
  1444. else
  1445. class28_1.anInt527 = i5 + i7;
  1446. }
  1447.  
  1448. while (l1 > 0) {
  1449. int i3 = -50;
  1450. int l3 = -1;
  1451. for (int j5 = 0; j5 < l1; j5++) {
  1452. GameObject class28_2 = interactableObjects[j5];
  1453. if (class28_2.anInt528 != anInt448)
  1454. if (class28_2.anInt527 > i3) {
  1455. i3 = class28_2.anInt527;
  1456. l3 = j5;
  1457. } else if (class28_2.anInt527 == i3) {
  1458. int j7 = class28_2.xPos - cameraX2;
  1459. int k8 = class28_2.yPos - cameraZ2;
  1460. int l9 = interactableObjects[l3].xPos
  1461. - cameraX2;
  1462. int l10 = interactableObjects[l3].yPos
  1463. - cameraZ2;
  1464. if (j7 * j7 + k8 * k8 > l9 * l9 + l10 * l10)
  1465. l3 = j5;
  1466. }
  1467. }
  1468.  
  1469. if (l3 == -1)
  1470. break;
  1471. GameObject class28_3 = interactableObjects[l3];
  1472. class28_3.anInt528 = anInt448;
  1473. if (!method323(l, class28_3.xLocLow,
  1474. class28_3.xLocHigh, class28_3.yLocHigh,
  1475. class28_3.yLocLow,
  1476. class28_3.renderable.modelBaseY))
  1477. class28_3.renderable.renderAtPoint(
  1478. class28_3.turnValue, camUpDownY, camUpDownX,
  1479. camLeftRightY, camLeftRightX, class28_3.xPos
  1480. - cameraX2, class28_3.tileHeight
  1481. - cameraY2, class28_3.yPos
  1482. - cameraZ2, class28_3.uid, class28_3.getNewUID());
  1483. for (int k7 = class28_3.xLocLow; k7 <= class28_3.xLocHigh; k7++) {
  1484. for (int l8 = class28_3.yLocHigh; l8 <= class28_3.yLocLow; l8++) {
  1485. Tile class30_sub3_22 = aclass30_sub3[k7][l8];
  1486. if (class30_sub3_22.anInt1325 != 0)
  1487. tileDeque.insertHead(class30_sub3_22);
  1488. else if ((k7 != i || l8 != j)
  1489. && class30_sub3_22.aBoolean1323)
  1490. tileDeque.insertHead(class30_sub3_22);
  1491. }
  1492.  
  1493. }
  1494.  
  1495. }
  1496. if (currentTile.aBoolean1324)
  1497. continue;
  1498. } catch (Exception _ex) {
  1499. currentTile.aBoolean1324 = false;
  1500. }
  1501. if (!currentTile.aBoolean1323 || currentTile.anInt1325 != 0)
  1502. continue;
  1503. if (i <= screenCenterX && i > cameraLowTileX) {
  1504. Tile class30_sub3_8 = aclass30_sub3[i - 1][j];
  1505. if (class30_sub3_8 != null && class30_sub3_8.aBoolean1323)
  1506. continue;
  1507. }
  1508. if (i >= screenCenterX && i < cameraHighTileX - 1) {
  1509. Tile class30_sub3_9 = aclass30_sub3[i + 1][j];
  1510. if (class30_sub3_9 != null && class30_sub3_9.aBoolean1323)
  1511. continue;
  1512. }
  1513. if (j <= yCameraTile && j > cameraLowTileY) {
  1514. Tile class30_sub3_10 = aclass30_sub3[i][j - 1];
  1515. if (class30_sub3_10 != null && class30_sub3_10.aBoolean1323)
  1516. continue;
  1517. }
  1518. if (j >= yCameraTile && j < cameraHighTileY - 1) {
  1519. Tile class30_sub3_11 = aclass30_sub3[i][j + 1];
  1520. if (class30_sub3_11 != null && class30_sub3_11.aBoolean1323)
  1521. continue;
  1522. }
  1523. currentTile.aBoolean1323 = false;
  1524. anInt446--;
  1525. Object4 object4 = currentTile.obj4;
  1526. if (object4 != null && object4.anInt52 != 0) {
  1527. if (object4.aClass30_Sub2_Sub4_49 != null)
  1528. object4.aClass30_Sub2_Sub4_49.renderAtPoint(0, camUpDownY,
  1529. camUpDownX, camLeftRightY, camLeftRightX, object4.anInt46
  1530. - cameraX2, object4.anInt45 - cameraY2
  1531. - object4.anInt52, object4.anInt47
  1532. - cameraZ2, object4.uid, object4.getNewUID());
  1533. if (object4.aClass30_Sub2_Sub4_50 != null)
  1534. object4.aClass30_Sub2_Sub4_50.renderAtPoint(0, camUpDownY,
  1535. camUpDownX, camLeftRightY, camLeftRightX, object4.anInt46
  1536. - cameraX2, object4.anInt45 - cameraY2
  1537. - object4.anInt52, object4.anInt47
  1538. - cameraZ2, object4.uid, object4.getNewUID());
  1539. if (object4.aClass30_Sub2_Sub4_48 != null)
  1540. object4.aClass30_Sub2_Sub4_48.renderAtPoint(0, camUpDownY,
  1541. camUpDownX, camLeftRightY, camLeftRightX, object4.anInt46
  1542. - cameraX2, object4.anInt45 - cameraY2
  1543. - object4.anInt52, object4.anInt47
  1544. - cameraZ2, object4.uid, object4.getNewUID());
  1545. }
  1546. if (currentTile.anInt1328 != 0) {
  1547. WallDecoration class26 = currentTile.obj2;
  1548. if (class26 != null
  1549. && !method322(l, i, j,
  1550. class26.aClass30_Sub2_Sub4_504.modelBaseY))
  1551. if ((class26.anInt502 & currentTile.anInt1328) != 0)
  1552. class26.aClass30_Sub2_Sub4_504.renderAtPoint(
  1553. class26.anInt503, camUpDownY, camUpDownX, camLeftRightY,
  1554. camLeftRightX, class26.anInt500 - cameraX2,
  1555. class26.anInt499 - cameraY2, class26.anInt501
  1556. - cameraZ2, class26.uid, class26.getNewUID());
  1557. else if ((class26.anInt502 & 0x300) != 0) {
  1558. int l2 = class26.anInt500 - cameraX2;
  1559. int j3 = class26.anInt499 - cameraY2;
  1560. int i4 = class26.anInt501 - cameraZ2;
  1561. int k5 = class26.anInt503;
  1562. int j6;
  1563. if (k5 == 1 || k5 == 2)
  1564. j6 = -l2;
  1565. else
  1566. j6 = l2;
  1567. int l7;
  1568. if (k5 == 2 || k5 == 3)
  1569. l7 = -i4;
  1570. else
  1571. l7 = i4;
  1572. if ((class26.anInt502 & 0x100) != 0 && l7 >= j6) {
  1573. int i9 = l2 + anIntArray463[k5];
  1574. int i10 = i4 + anIntArray464[k5];
  1575. class26.aClass30_Sub2_Sub4_504.renderAtPoint(
  1576. k5 * 512 + 256, camUpDownY, camUpDownX,
  1577. camLeftRightY, camLeftRightX, i9, j3, i10,
  1578. class26.uid, class26.getNewUID());
  1579. }
  1580. if ((class26.anInt502 & 0x200) != 0 && l7 <= j6) {
  1581. int j9 = l2 + anIntArray465[k5];
  1582. int j10 = i4 + anIntArray466[k5];
  1583. class26.aClass30_Sub2_Sub4_504.renderAtPoint(
  1584. k5 * 512 + 1280 & 0x7ff, camUpDownY,
  1585. camUpDownX, camLeftRightY, camLeftRightX, j9, j3, j10,
  1586. class26.uid, class26.getNewUID());
  1587. }
  1588. }
  1589. WallObject class10_2 = currentTile.wallObject;
  1590. if (class10_2 != null) {
  1591. if ((class10_2.orientation1 & currentTile.anInt1328) != 0
  1592. && !method321(l, i, j, class10_2.orientation1))
  1593. class10_2.renderable2.renderAtPoint(0, camUpDownY,
  1594. camUpDownX, camLeftRightY, camLeftRightX,
  1595. class10_2.anInt274 - cameraX2,
  1596. class10_2.anInt273 - cameraY2,
  1597. class10_2.anInt275 - cameraZ2, class10_2.uid, class10_2.getNewUID());
  1598. if ((class10_2.orientation & currentTile.anInt1328) != 0
  1599. && !method321(l, i, j, class10_2.orientation))
  1600. class10_2.renderable1.renderAtPoint(0, camUpDownY,
  1601. camUpDownX, camLeftRightY, camLeftRightX,
  1602. class10_2.anInt274 - cameraX2,
  1603. class10_2.anInt273 - cameraY2,
  1604. class10_2.anInt275 - cameraZ2, class10_2.uid, class10_2.getNewUID());
  1605. }
  1606. }
  1607. if (k < numberOfZ - 1) {
  1608. Tile class30_sub3_12 = tileArray[k + 1][i][j];
  1609. if (class30_sub3_12 != null && class30_sub3_12.aBoolean1323)
  1610. tileDeque.insertHead(class30_sub3_12);
  1611. }
  1612. if (i < screenCenterX) {
  1613. Tile class30_sub3_13 = aclass30_sub3[i + 1][j];
  1614. if (class30_sub3_13 != null && class30_sub3_13.aBoolean1323)
  1615. tileDeque.insertHead(class30_sub3_13);
  1616. }
  1617. if (j < yCameraTile) {
  1618. Tile class30_sub3_14 = aclass30_sub3[i][j + 1];
  1619. if (class30_sub3_14 != null && class30_sub3_14.aBoolean1323)
  1620. tileDeque.insertHead(class30_sub3_14);
  1621. }
  1622. if (i > screenCenterX) {
  1623. Tile class30_sub3_15 = aclass30_sub3[i - 1][j];
  1624. if (class30_sub3_15 != null && class30_sub3_15.aBoolean1323)
  1625. tileDeque.insertHead(class30_sub3_15);
  1626. }
  1627. if (j > yCameraTile) {
  1628. Tile class30_sub3_16 = aclass30_sub3[i][j - 1];
  1629. if (class30_sub3_16 != null && class30_sub3_16.aBoolean1323)
  1630. tileDeque.insertHead(class30_sub3_16);
  1631. }
  1632. } while (true);
  1633. }
  1634.  
  1635. private void drawTileUnderlay(SimpleTile simpleTile, int z, int pitchSin, int pitchCos, int yawSin, int yawCos,
  1636. int x, int y) {
  1637. int l1;
  1638. int i2 = l1 = (x << 7) - cameraX2;
  1639. int j2;
  1640. int k2 = j2 = (y << 7) - cameraZ2;
  1641. int l2;
  1642. int i3 = l2 = i2 + 128;
  1643. int j3;
  1644. int k3 = j3 = k2 + 128;
  1645. int l3 = heightMap[z][x][y] - cameraY2;
  1646. int i4 = heightMap[z][x + 1][y] - cameraY2;
  1647. int j4 = heightMap[z][x + 1][y + 1] - cameraY2;
  1648. int k4 = heightMap[z][x][y + 1] - cameraY2;
  1649. int l4 = k2 * yawSin + i2 * yawCos >> 16;
  1650. k2 = k2 * yawCos - i2 * yawSin >> 16;
  1651. i2 = l4;
  1652. l4 = l3 * pitchCos - k2 * pitchSin >> 16;
  1653. k2 = l3 * pitchSin + k2 * pitchCos >> 16;
  1654. l3 = l4;
  1655. if (k2 < 50)
  1656. return;
  1657. l4 = j2 * yawSin + i3 * yawCos >> 16;
  1658. j2 = j2 * yawCos - i3 * yawSin >> 16;
  1659. i3 = l4;
  1660. l4 = i4 * pitchCos - j2 * pitchSin >> 16;
  1661. j2 = i4 * pitchSin + j2 * pitchCos >> 16;
  1662. i4 = l4;
  1663. if (j2 < 50)
  1664. return;
  1665. l4 = k3 * yawSin + l2 * yawCos >> 16;
  1666. k3 = k3 * yawCos - l2 * yawSin >> 16;
  1667. l2 = l4;
  1668. l4 = j4 * pitchCos - k3 * pitchSin >> 16;
  1669. k3 = j4 * pitchSin + k3 * pitchCos >> 16;
  1670. j4 = l4;
  1671. if (k3 < 50)
  1672. return;
  1673. l4 = j3 * yawSin + l1 * yawCos >> 16;
  1674. j3 = j3 * yawCos - l1 * yawSin >> 16;
  1675. l1 = l4;
  1676. l4 = k4 * pitchCos - j3 * pitchSin >> 16;
  1677. j3 = k4 * pitchSin + j3 * pitchCos >> 16;
  1678. k4 = l4;
  1679. if (j3 < 50)
  1680. return;
  1681. int i5 = Rasterizer3D.originViewX + i2 * SceneGraph.focalLength / k2;
  1682. int j5 = Rasterizer3D.originViewY + l3 * SceneGraph.focalLength / k2;
  1683. int k5 = Rasterizer3D.originViewX + i3 * SceneGraph.focalLength / j2;
  1684. int l5 = Rasterizer3D.originViewY + i4 * SceneGraph.focalLength / j2;
  1685. int i6 = Rasterizer3D.originViewX + l2 * SceneGraph.focalLength / k3;
  1686. int j6 = Rasterizer3D.originViewY + j4 * SceneGraph.focalLength / k3;
  1687. int k6 = Rasterizer3D.originViewX + l1 * SceneGraph.focalLength / j3;
  1688. int l6 = Rasterizer3D.originViewY + k4 * SceneGraph.focalLength / j3;
  1689. Rasterizer3D.alpha = 0;
  1690. if ((i6 - k6) * (l5 - l6) - (j6 - l6) * (k5 - k6) > 0) {
  1691. Rasterizer3D.textureOutOfDrawingBounds = i6 < 0 || k6 < 0 || k5 < 0
  1692. || i6 > Rasterizer2D.lastX || k6 > Rasterizer2D.lastX
  1693. || k5 > Rasterizer2D.lastX;
  1694. if (clicked && inBounds(clickScreenX, clickScreenY, j6, l6, l5, i6, k6, k5)) {
  1695. clickedTileX = x;
  1696. clickedTileY = y;
  1697. }
  1698. if (simpleTile.texture == -1) {
  1699. if (simpleTile.centerColor != 0xbc614e)
  1700. Rasterizer3D.drawShadedTriangle(j6, l6, l5, i6, k6, k5, simpleTile.centerColor, simpleTile.eastColor, simpleTile.northColor, k3, j3, j2);
  1701. } else if (!lowMem) {
  1702. if (simpleTile.flat)
  1703. Rasterizer3D.drawTexturedTriangle(j6, l6, l5, i6, k6, k5, simpleTile.centerColor, simpleTile.eastColor, simpleTile.northColor, i2, i3, l1, l3, i4, k4, k2, j2, j3, simpleTile.texture);
  1704. else
  1705. Rasterizer3D.drawTexturedTriangle(j6, l6, l5, i6, k6, k5, simpleTile.centerColor, simpleTile.eastColor, simpleTile.northColor, l2, l1, i3, j4, k4, i4, k3, j3, j2, simpleTile.texture);
  1706. } else {
  1707. int textureColor = TEXTURE_COLORS[simpleTile.texture];
  1708. Rasterizer3D.drawShadedTriangle(j6, l6, l5, i6, k6, k5, light(textureColor, simpleTile.centerColor), light(textureColor, simpleTile.eastColor), light(textureColor, simpleTile.northColor), k3, j3, j2);
  1709. }
  1710. }
  1711. if ((i5 - k5) * (l6 - l5) - (j5 - l5) * (k6 - k5) > 0) {
  1712. Rasterizer3D.textureOutOfDrawingBounds = i5 < 0 || k5 < 0 || k6 < 0
  1713. || i5 > Rasterizer2D.lastX || k5 > Rasterizer2D.lastX
  1714. || k6 > Rasterizer2D.lastX;
  1715. if (clicked
  1716. && inBounds(clickScreenX, clickScreenY, j5, l5, l6, i5, k5, k6)) {
  1717. clickedTileX = x;
  1718. clickedTileY = y;
  1719. }
  1720. if (simpleTile.texture == -1) {
  1721. if (simpleTile.northEastColor != 0xbc614e)
  1722. Rasterizer3D.drawShadedTriangle(j5, l5, l6, i5, k5, k6, simpleTile.northEastColor, simpleTile.northColor, simpleTile.eastColor, k2, j2, j3);
  1723. } else {
  1724. if (!lowMem) {
  1725. Rasterizer3D.drawTexturedTriangle(j5, l5, l6, i5, k5, k6, simpleTile.northEastColor, simpleTile.northColor, simpleTile.eastColor, i2, i3, l1, l3, i4, k4, k2, j2, j3, simpleTile.texture);
  1726. return;
  1727. }
  1728. int j7 = TEXTURE_COLORS[simpleTile.texture];
  1729. Rasterizer3D.drawShadedTriangle(j5, l5, l6, i5, k5, k6, light(j7, simpleTile.northEastColor), light(j7, simpleTile.northColor), light(j7, simpleTile.eastColor), k2, j2, j3);
  1730. }
  1731. }
  1732. }
  1733.  
  1734. private void drawTileOverlaySD(int tileX, int pitchSin, int yawSin, ShapedTile tile, int pitchCos,
  1735. int tileY, int yawCos) {
  1736. int k1 = tile.origVertexX.length;
  1737. for (int l1 = 0; l1 < k1; l1++) {
  1738. int i2 = tile.origVertexX[l1] - cameraX2;
  1739. int k2 = tile.origVertexY[l1] - cameraY2;
  1740. int i3 = tile.origVertexZ[l1] - cameraZ2;
  1741. int k3 = i3 * yawSin + i2 * yawCos >> 16;
  1742. i3 = i3 * yawCos - i2 * yawSin >> 16;
  1743. i2 = k3;
  1744. k3 = k2 * pitchCos - i3 * pitchSin >> 16;
  1745. i3 = k2 * pitchSin + i3 * pitchCos >> 16;
  1746. k2 = k3;
  1747. if (i3 < 50)
  1748. return;
  1749. if (tile.triangleTexture != null) {
  1750. ShapedTile.anIntArray690[l1] = i2;
  1751. ShapedTile.anIntArray691[l1] = k2;
  1752. ShapedTile.anIntArray692[l1] = i3;
  1753. }
  1754. ShapedTile.anIntArray688[l1] = Rasterizer3D.originViewX + (i2 * SceneGraph.focalLength) / i3;
  1755. ShapedTile.anIntArray689[l1] = Rasterizer3D.originViewY + (k2 * SceneGraph.focalLength) / i3;
  1756. }
  1757.  
  1758. Rasterizer3D.alpha = 0;
  1759. k1 = tile.triangleA.length;
  1760. for (int j2 = 0; j2 < k1; j2++) {
  1761. int l2 = tile.triangleA[j2];
  1762. int j3 = tile.triangleB[j2];
  1763. int l3 = tile.triangleC[j2];
  1764. int i4 = ShapedTile.anIntArray688[l2];
  1765. int j4 = ShapedTile.anIntArray688[j3];
  1766. int k4 = ShapedTile.anIntArray688[l3];
  1767. int l4 = ShapedTile.anIntArray689[l2];
  1768. int i5 = ShapedTile.anIntArray689[j3];
  1769. int j5 = ShapedTile.anIntArray689[l3];
  1770. if ((i4 - j4) * (j5 - i5) - (l4 - i5) * (k4 - j4) > 0) {
  1771. Rasterizer3D.textureOutOfDrawingBounds = i4 < 0 || j4 < 0 || k4 < 0
  1772. || i4 > Rasterizer2D.lastX || j4 > Rasterizer2D.lastX
  1773. || k4 > Rasterizer2D.lastX;
  1774. if (clicked && inBounds(clickScreenX, clickScreenY, l4, i5, j5, i4, j4, k4)) {
  1775. clickedTileX = tileX;
  1776. clickedTileY = tileY;
  1777. }
  1778. if (tile.triangleTexture == null || tile.triangleTexture[j2] == -1) {
  1779. if (tile.triangleHslA[j2] != 0xbc614e)
  1780. Rasterizer3D.drawShadedTriangle(l4, i5, j5, i4, j4, k4, tile.triangleHslA[j2], tile.triangleHslB[j2], tile.triangleHslC[j2], tile.depthPoint[l2], tile.depthPoint[j3], tile.depthPoint[l3]);
  1781. } else if (!lowMem) {
  1782. if (tile.flat)
  1783. Rasterizer3D.drawTexturedTriangle(l4, i5, j5, i4, j4, k4, tile.triangleHslA[j2],
  1784. tile.triangleHslB[j2], tile.triangleHslC[j2], ShapedTile.anIntArray690[0],
  1785. ShapedTile.anIntArray690[1], ShapedTile.anIntArray690[3],
  1786. ShapedTile.anIntArray691[0], ShapedTile.anIntArray691[1],
  1787. ShapedTile.anIntArray691[3], ShapedTile.anIntArray692[0],
  1788. ShapedTile.anIntArray692[1], ShapedTile.anIntArray692[3], tile.triangleTexture[j2]);
  1789. else
  1790. Rasterizer3D.drawTexturedTriangle(l4, i5, j5, i4, j4, k4, tile.triangleHslA[j2],
  1791. tile.triangleHslB[j2], tile.triangleHslC[j2], ShapedTile.anIntArray690[l2],
  1792. ShapedTile.anIntArray690[j3], ShapedTile.anIntArray690[l3],
  1793. ShapedTile.anIntArray691[l2], ShapedTile.anIntArray691[j3],
  1794. ShapedTile.anIntArray691[l3], ShapedTile.anIntArray692[l2],
  1795. ShapedTile.anIntArray692[j3], ShapedTile.anIntArray692[l3],
  1796. tile.triangleTexture[j2]);
  1797. } else {
  1798. int k5 = TEXTURE_COLORS[tile.triangleTexture[j2]];
  1799. Rasterizer3D.drawShadedTriangle(l4, i5, j5, i4, j4, k4,
  1800. light(k5, tile.triangleHslA[j2]), light(k5, tile.triangleHslB[j2]),
  1801. light(k5, tile.triangleHslC[j2]), tile.depthPoint[l2],
  1802. tile.depthPoint[j3], tile.depthPoint[l3]);
  1803. }
  1804. }
  1805. }
  1806. }
  1807.  
  1808. private int light(int j, int k) {
  1809. k = 127 - k;
  1810. k = (k * (j & 0x7f)) / 160;
  1811. if (k < 2)
  1812. k = 2;
  1813. else if (k > 126)
  1814. k = 126;
  1815. return (j & 0xff80) + k;
  1816. }
  1817.  
  1818. private boolean inBounds(int i, int j, int k, int l, int i1, int j1,
  1819. int k1, int l1) {
  1820. if (j < k && j < l && j < i1)
  1821. return false;
  1822. if (j > k && j > l && j > i1)
  1823. return false;
  1824. if (i < j1 && i < k1 && i < l1)
  1825. return false;
  1826. if (i > j1 && i > k1 && i > l1)
  1827. return false;
  1828. int i2 = (j - k) * (k1 - j1) - (i - j1) * (l - k);
  1829. int j2 = (j - i1) * (j1 - l1) - (i - l1) * (k - i1);
  1830. int k2 = (j - l) * (l1 - k1) - (i - k1) * (i1 - l);
  1831. return i2 * k2 > 0 && k2 * j2 > 0;
  1832. }
  1833.  
  1834. private void occlude() {
  1835. int j = sceneClusterCounts[currentRenderPlane];
  1836. SceneCluster sceneClusters[] = SceneGraph.sceneClusters[currentRenderPlane];
  1837. anInt475 = 0;
  1838. for (int k = 0; k < j; k++) {
  1839. SceneCluster sceneCluster = sceneClusters[k];
  1840. if (sceneCluster.orientation == 1) {//YZ-plane
  1841. int l = (sceneCluster.startXLoc - screenCenterX) + 25;
  1842. if (l < 0 || l > 50)
  1843. continue;
  1844. int k1 = (sceneCluster.startYLoc - yCameraTile) + 25;
  1845. if (k1 < 0)
  1846. k1 = 0;
  1847. int j2 = (sceneCluster.endYLoc - yCameraTile) + 25;
  1848. if (j2 > 50)
  1849. j2 = 50;
  1850. boolean flag = false;
  1851. while (k1 <= j2)
  1852. if (renderArea[l][k1++]) {
  1853. flag = true;
  1854. break;
  1855. }
  1856. if (!flag)
  1857. continue;
  1858. int j3 = cameraX2 - sceneCluster.startXPos;
  1859. if (j3 > 32) {
  1860. sceneCluster.cullDirection = 1;
  1861. } else {
  1862. if (j3 >= -32)
  1863. continue;
  1864. sceneCluster.cullDirection = 2;
  1865. j3 = -j3;
  1866. }
  1867. sceneCluster.anInt801 = (sceneCluster.startYPos - cameraZ2 << 8) / j3;
  1868. sceneCluster.anInt802 = (sceneCluster.endYPos - cameraZ2 << 8) / j3;
  1869. sceneCluster.anInt803 = (sceneCluster.startZPos - cameraY2 << 8) / j3;
  1870. sceneCluster.anInt804 = (sceneCluster.endZPos - cameraY2 << 8) / j3;
  1871. aClass47Array476[anInt475++] = sceneCluster;
  1872. continue;
  1873. }
  1874. if (sceneCluster.orientation == 2) {
  1875. int i1 = (sceneCluster.startYLoc - yCameraTile) + 25;
  1876. if (i1 < 0 || i1 > 50)
  1877. continue;
  1878. int l1 = (sceneCluster.startXLoc - screenCenterX) + 25;
  1879. if (l1 < 0)
  1880. l1 = 0;
  1881. int k2 = (sceneCluster.endXLoc - screenCenterX) + 25;
  1882. if (k2 > 50)
  1883. k2 = 50;
  1884. boolean flag1 = false;
  1885. while (l1 <= k2)
  1886. if (renderArea[l1++][i1]) {
  1887. flag1 = true;
  1888. break;
  1889. }
  1890. if (!flag1)
  1891. continue;
  1892. int k3 = cameraZ2 - sceneCluster.startYPos;
  1893. if (k3 > 32) {
  1894. sceneCluster.cullDirection = 3;
  1895. } else {
  1896. if (k3 >= -32)
  1897. continue;
  1898. sceneCluster.cullDirection = 4;
  1899. k3 = -k3;
  1900. }
  1901. sceneCluster.anInt799 = (sceneCluster.startXPos - cameraX2 << 8) / k3;
  1902. sceneCluster.anInt800 = (sceneCluster.endXPos - cameraX2 << 8) / k3;
  1903. sceneCluster.anInt803 = (sceneCluster.startZPos - cameraY2 << 8) / k3;
  1904. sceneCluster.anInt804 = (sceneCluster.endZPos - cameraY2 << 8) / k3;
  1905. aClass47Array476[anInt475++] = sceneCluster;
  1906. } else if (sceneCluster.orientation == 4) {
  1907. int j1 = sceneCluster.startZPos - cameraY2;
  1908. if (j1 > 128) {
  1909. int i2 = (sceneCluster.startYLoc - yCameraTile) + 25;
  1910. if (i2 < 0)
  1911. i2 = 0;
  1912. int l2 = (sceneCluster.endYLoc - yCameraTile) + 25;
  1913. if (l2 > 50)
  1914. l2 = 50;
  1915. if (i2 <= l2) {
  1916. int i3 = (sceneCluster.startXLoc - screenCenterX) + 25;
  1917. if (i3 < 0)
  1918. i3 = 0;
  1919. int l3 = (sceneCluster.endXLoc - screenCenterX) + 25;
  1920. if (l3 > 50)
  1921. l3 = 50;
  1922. boolean flag2 = false;
  1923. label0:
  1924. for (int i4 = i3; i4 <= l3; i4++) {
  1925. for (int j4 = i2; j4 <= l2; j4++) {
  1926. if (!renderArea[i4][j4])
  1927. continue;
  1928. flag2 = true;
  1929. break label0;
  1930. }
  1931.  
  1932. }
  1933.  
  1934. if (flag2) {
  1935. sceneCluster.cullDirection = 5;
  1936. sceneCluster.anInt799 = (sceneCluster.startXPos - cameraX2 << 8)
  1937. / j1;
  1938. sceneCluster.anInt800 = (sceneCluster.endXPos - cameraX2 << 8)
  1939. / j1;
  1940. sceneCluster.anInt801 = (sceneCluster.startYPos - cameraZ2 << 8)
  1941. / j1;
  1942. sceneCluster.anInt802 = (sceneCluster.endYPos - cameraZ2 << 8)
  1943. / j1;
  1944. aClass47Array476[anInt475++] = sceneCluster;
  1945. }
  1946. }
  1947. }
  1948. }
  1949. }
  1950.  
  1951. }
  1952.  
  1953. private boolean method320(int i, int j, int k) {
  1954. int l = anIntArrayArrayArray445[i][j][k];
  1955. if (l == -anInt448)
  1956. return false;
  1957. if (l == anInt448)
  1958. return true;
  1959. int i1 = j << 7;
  1960. int j1 = k << 7;
  1961. if (method324(i1 + 1, heightMap[i][j][k], j1 + 1)
  1962. && method324((i1 + 128) - 1,
  1963. heightMap[i][j + 1][k], j1 + 1)
  1964. && method324((i1 + 128) - 1,
  1965. heightMap[i][j + 1][k + 1],
  1966. (j1 + 128) - 1)
  1967. && method324(i1 + 1, heightMap[i][j][k + 1],
  1968. (j1 + 128) - 1)) {
  1969. anIntArrayArrayArray445[i][j][k] = anInt448;
  1970. return true;
  1971. } else {
  1972. anIntArrayArrayArray445[i][j][k] = -anInt448;
  1973. return false;
  1974. }
  1975. }
  1976.  
  1977. private boolean method321(int i, int j, int k, int l) {
  1978. if (!method320(i, j, k))
  1979. return false;
  1980. int i1 = j << 7;
  1981. int j1 = k << 7;
  1982. int k1 = heightMap[i][j][k] - 1;
  1983. int l1 = k1 - 120;
  1984. int i2 = k1 - 230;
  1985. int j2 = k1 - 238;
  1986. if (l < 16) {
  1987. if (l == 1) {
  1988. if (i1 > cameraX2) {
  1989. if (!method324(i1, k1, j1))
  1990. return false;
  1991. if (!method324(i1, k1, j1 + 128))
  1992. return false;
  1993. }
  1994. if (i > 0) {
  1995. if (!method324(i1, l1, j1))
  1996. return false;
  1997. if (!method324(i1, l1, j1 + 128))
  1998. return false;
  1999. }
  2000. return method324(i1, i2, j1) && method324(i1, i2, j1 + 128);
  2001. }
  2002. if (l == 2) {
  2003. if (j1 < cameraZ2) {
  2004. if (!method324(i1, k1, j1 + 128))
  2005. return false;
  2006. if (!method324(i1 + 128, k1, j1 + 128))
  2007. return false;
  2008. }
  2009. if (i > 0) {
  2010. if (!method324(i1, l1, j1 + 128))
  2011. return false;
  2012. if (!method324(i1 + 128, l1, j1 + 128))
  2013. return false;
  2014. }
  2015. return method324(i1, i2, j1 + 128)
  2016. && method324(i1 + 128, i2, j1 + 128);
  2017. }
  2018. if (l == 4) {
  2019. if (i1 < cameraX2) {
  2020. if (!method324(i1 + 128, k1, j1))
  2021. return false;
  2022. if (!method324(i1 + 128, k1, j1 + 128))
  2023. return false;
  2024. }
  2025. if (i > 0) {
  2026. if (!method324(i1 + 128, l1, j1))
  2027. return false;
  2028. if (!method324(i1 + 128, l1, j1 + 128))
  2029. return false;
  2030. }
  2031. return method324(i1 + 128, i2, j1)
  2032. && method324(i1 + 128, i2, j1 + 128);
  2033. }
  2034. if (l == 8) {
  2035. if (j1 > cameraZ2) {
  2036. if (!method324(i1, k1, j1))
  2037. return false;
  2038. if (!method324(i1 + 128, k1, j1))
  2039. return false;
  2040. }
  2041. if (i > 0) {
  2042. if (!method324(i1, l1, j1))
  2043. return false;
  2044. if (!method324(i1 + 128, l1, j1))
  2045. return false;
  2046. }
  2047. return method324(i1, i2, j1) && method324(i1 + 128, i2, j1);
  2048. }
  2049. }
  2050. if (!method324(i1 + 64, j2, j1 + 64))
  2051. return false;
  2052. if (l == 16)
  2053. return method324(i1, i2, j1 + 128);
  2054. if (l == 32)
  2055. return method324(i1 + 128, i2, j1 + 128);
  2056. if (l == 64)
  2057. return method324(i1 + 128, i2, j1);
  2058. if (l == 128) {
  2059. return method324(i1, i2, j1);
  2060. } else {
  2061. System.out.println("Warning unsupported wall type");
  2062. return true;
  2063. }
  2064. }
  2065.  
  2066. private boolean method322(int i, int j, int k, int l) {
  2067. if (!method320(i, j, k))
  2068. return false;
  2069. int i1 = j << 7;
  2070. int j1 = k << 7;
  2071. return method324(i1 + 1, heightMap[i][j][k] - l, j1 + 1)
  2072. && method324((i1 + 128) - 1,
  2073. heightMap[i][j + 1][k] - l, j1 + 1)
  2074. && method324((i1 + 128) - 1,
  2075. heightMap[i][j + 1][k + 1] - l,
  2076. (j1 + 128) - 1)
  2077. && method324(i1 + 1, heightMap[i][j][k + 1] - l,
  2078. (j1 + 128) - 1);
  2079. }
  2080.  
  2081. private boolean method323(int i, int j, int k, int l, int i1, int j1) {
  2082. if (j == k && l == i1) {
  2083. if (!method320(i, j, l))
  2084. return false;
  2085. int k1 = j << 7;
  2086. int i2 = l << 7;
  2087. return method324(k1 + 1, heightMap[i][j][l] - j1,
  2088. i2 + 1)
  2089. && method324((k1 + 128) - 1,
  2090. heightMap[i][j + 1][l] - j1, i2 + 1)
  2091. && method324((k1 + 128) - 1,
  2092. heightMap[i][j + 1][l + 1] - j1,
  2093. (i2 + 128) - 1)
  2094. && method324(k1 + 1, heightMap[i][j][l + 1]
  2095. - j1, (i2 + 128) - 1);
  2096. }
  2097. for (int l1 = j; l1 <= k; l1++) {
  2098. for (int j2 = l; j2 <= i1; j2++)
  2099. if (anIntArrayArrayArray445[i][l1][j2] == -anInt448)
  2100. return false;
  2101.  
  2102. }
  2103.  
  2104. int k2 = (j << 7) + 1;
  2105. int l2 = (l << 7) + 2;
  2106. int i3 = heightMap[i][j][l] - j1;
  2107. if (!method324(k2, i3, l2))
  2108. return false;
  2109. int j3 = (k << 7) - 1;
  2110. if (!method324(j3, i3, l2))
  2111. return false;
  2112. int k3 = (i1 << 7) - 1;
  2113. return method324(k2, i3, k3) && method324(j3, i3, k3);
  2114. }
  2115.  
  2116. private boolean method324(int i, int j, int k) {
  2117. for (int l = 0; l < anInt475; l++) {
  2118. SceneCluster class47 = aClass47Array476[l];
  2119. if (class47.cullDirection == 1) {
  2120. int i1 = class47.startXPos - i;
  2121. if (i1 > 0) {
  2122. int j2 = class47.startYPos + (class47.anInt801 * i1 >> 8);
  2123. int k3 = class47.endYPos + (class47.anInt802 * i1 >> 8);
  2124. int l4 = class47.startZPos + (class47.anInt803 * i1 >> 8);
  2125. int i6 = class47.endZPos + (class47.anInt804 * i1 >> 8);
  2126. if (k >= j2 && k <= k3 && j >= l4 && j <= i6)
  2127. return true;
  2128. }
  2129. } else if (class47.cullDirection == 2) {
  2130. int j1 = i - class47.startXPos;
  2131. if (j1 > 0) {
  2132. int k2 = class47.startYPos + (class47.anInt801 * j1 >> 8);
  2133. int l3 = class47.endYPos + (class47.anInt802 * j1 >> 8);
  2134. int i5 = class47.startZPos + (class47.anInt803 * j1 >> 8);
  2135. int j6 = class47.endZPos + (class47.anInt804 * j1 >> 8);
  2136. if (k >= k2 && k <= l3 && j >= i5 && j <= j6)
  2137. return true;
  2138. }
  2139. } else if (class47.cullDirection == 3) {
  2140. int k1 = class47.startYPos - k;
  2141. if (k1 > 0) {
  2142. int l2 = class47.startXPos + (class47.anInt799 * k1 >> 8);
  2143. int i4 = class47.endXPos + (class47.anInt800 * k1 >> 8);
  2144. int j5 = class47.startZPos + (class47.anInt803 * k1 >> 8);
  2145. int k6 = class47.endZPos + (class47.anInt804 * k1 >> 8);
  2146. if (i >= l2 && i <= i4 && j >= j5 && j <= k6)
  2147. return true;
  2148. }
  2149. } else if (class47.cullDirection == 4) {
  2150. int l1 = k - class47.startYPos;
  2151. if (l1 > 0) {
  2152. int i3 = class47.startXPos + (class47.anInt799 * l1 >> 8);
  2153. int j4 = class47.endXPos + (class47.anInt800 * l1 >> 8);
  2154. int k5 = class47.startZPos + (class47.anInt803 * l1 >> 8);
  2155. int l6 = class47.endZPos + (class47.anInt804 * l1 >> 8);
  2156. if (i >= i3 && i <= j4 && j >= k5 && j <= l6)
  2157. return true;
  2158. }
  2159. } else if (class47.cullDirection == 5) {
  2160. int i2 = j - class47.startZPos;
  2161. if (i2 > 0) {
  2162. int j3 = class47.startXPos + (class47.anInt799 * i2 >> 8);
  2163. int k4 = class47.endXPos + (class47.anInt800 * i2 >> 8);
  2164. int l5 = class47.startYPos + (class47.anInt801 * i2 >> 8);
  2165. int i7 = class47.endYPos + (class47.anInt802 * i2 >> 8);
  2166. if (i >= j3 && i <= k4 && k >= l5 && k <= i7)
  2167. return true;
  2168. }
  2169. }
  2170. }
  2171.  
  2172. return false;
  2173. }
  2174.  
  2175. private boolean aBoolean434;
  2176. public static boolean lowMem = false;
  2177. private final int numberOfZ;
  2178. private final int maxX;
  2179. private final int maxZ;
  2180. private final int[][][] heightMap;
  2181. private final Tile[][][] tileArray;
  2182. private int zAnInt442;
  2183. private int interactableObjectCacheCurrPos;
  2184. private final GameObject[] gameObjectsCache;
  2185. private final int[][][] anIntArrayArrayArray445;
  2186. private static int anInt446;
  2187. private static int currentRenderPlane;
  2188. private static int anInt448;
  2189. private static int cameraLowTileX;
  2190. private static int cameraHighTileX;
  2191. private static int cameraLowTileY;
  2192. private static int cameraHighTileY;
  2193. private static int screenCenterX;
  2194. private static int yCameraTile;
  2195. private static int cameraX2;
  2196. private static int cameraY2;
  2197. private static int cameraZ2;
  2198. private static int camUpDownY;
  2199. private static int camUpDownX;
  2200. private static int camLeftRightY;
  2201. private static int camLeftRightX;
  2202. private static GameObject[] interactableObjects = new GameObject[100];
  2203. private static final int[] anIntArray463 = {53, -53, -53, 53};
  2204. private static final int[] anIntArray464 = {-53, -53, 53, 53};
  2205. private static final int[] anIntArray465 = {-45, 45, 45, -45};
  2206. private static final int[] anIntArray466 = {45, 45, -45, -45};
  2207. private static boolean clicked;
  2208. private static int clickScreenX;
  2209. private static int clickScreenY;
  2210. public static int clickedTileX = -1;
  2211. public static int clickedTileY = -1;
  2212. private static final int cullingClusterPlaneCount;
  2213. private static int[] sceneClusterCounts;
  2214. private static SceneCluster[][] sceneClusters;
  2215. private static int anInt475;
  2216. private static final SceneCluster[] aClass47Array476 = new SceneCluster[500];
  2217. private static NodeList tileDeque = new NodeList();
  2218. private static final int[] anIntArray478 = {19, 55, 38, 155, 255, 110,
  2219. 137, 205, 76};
  2220. private static final int[] anIntArray479 = {160, 192, 80, 96, 0, 144, 80,
  2221. 48, 160};
  2222. private static final int[] anIntArray480 = {76, 8, 137, 4, 0, 1, 38, 2, 19};
  2223. private static final int[] anIntArray481 = {0, 0, 2, 0, 0, 2, 1, 1, 0};
  2224. private static final int[] anIntArray482 = {2, 0, 0, 2, 0, 0, 0, 4, 4};
  2225. private static final int[] anIntArray483 = {0, 4, 4, 8, 0, 0, 8, 0, 0};
  2226. private static final int[] anIntArray484 = {1, 1, 0, 0, 0, 8, 0, 0, 8};
  2227. private static final int[] TEXTURE_COLORS = {41, 39248, 41, 4643, 41, 41,
  2228. 41, 41, 41, 41, 41, 41, 41, 41, 41, 43086, 41, 41, 41, 41, 41, 41,
  2229. 41, 8602, 41, 28992, 41, 41, 41, 41, 41, 5056, 41, 41, 41, 7079,
  2230. 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 3131, 41, 41, 41};
  2231. private final int[] anIntArray486;
  2232. private final int[] anIntArray487;
  2233. private int anInt488;
  2234. private final int[][] tileVertices = {new int[16],
  2235. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
  2236. {1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1},
  2237. {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
  2238. {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1},
  2239. {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
  2240. {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1},
  2241. {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0},
  2242. {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0},
  2243. {1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1},
  2244. {1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0},
  2245. {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1},
  2246. {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}};
  2247. private final int[][] tileVertexIndices = {
  2248. {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
  2249. {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3},
  2250. {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
  2251. {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}};
  2252. private static boolean[][][][] visibilityMap;
  2253. private static boolean[][] renderArea;
  2254. private static int viewportHalfWidth;
  2255. private static int viewportHalfHeight;
  2256. private static int xMin;
  2257. private static int yMin;
  2258. private static int xMax;
  2259. private static int yMax;
  2260. public static int focalLength;
  2261. public static int viewDistance = 9;
  2262. static {
  2263. visibilityMap = new boolean[8][32][(25 * 2) + 1][(25 * 2) + 1];
  2264. focalLength = 512;
  2265. cullingClusterPlaneCount = 4;
  2266. sceneClusterCounts = new int[cullingClusterPlaneCount];
  2267. sceneClusters = new SceneCluster[cullingClusterPlaneCount][500];
  2268. }
  2269.  
  2270.  
  2271. }
  2272.  
Advertisement
Add Comment
Please, Sign In to add comment