A RuneTek3 client (377) that is deobfuscated, converted to Kotlin, and includes QoL improvements.
0

Configure Feed

Select the types of activity you want to include in your feed.

refactoring unknown methods in the region class

+1240 -1258
+21 -22
src/main/java/com/jagex/runescape/Game.java
··· 277 277 private String[] aStringArray1069 = new String[5]; 278 278 private boolean[] aBooleanArray1070 = new boolean[5]; 279 279 private int loadingStage; 280 - private int anInt1072 = 20411; 281 280 private long[] ignores = new long[100]; 282 281 private int anInt1075; 283 282 private int minimapHintCount; ··· 3400 3399 spawnObjectNode.anInt1390--; 3401 3400 if (spawnObjectNode.anInt1390 == 0) { 3402 3401 if (spawnObjectNode.anInt1387 < 0 3403 - || Region.method170(spawnObjectNode.anInt1389, aByte1143, spawnObjectNode.anInt1387)) { 3402 + || Region.method170(spawnObjectNode.anInt1389, spawnObjectNode.anInt1387)) { 3404 3403 method45(spawnObjectNode.anInt1388, spawnObjectNode.anInt1393, spawnObjectNode.anInt1387, 3405 3404 spawnObjectNode.anInt1394, spawnObjectNode.anInt1391, spawnObjectNode.anInt1389, 3406 3405 spawnObjectNode.anInt1392); ··· 3414 3413 && spawnObjectNode.anInt1394 >= 1 3415 3414 && spawnObjectNode.anInt1393 <= 102 3416 3415 && spawnObjectNode.anInt1394 <= 102 3417 - && (spawnObjectNode.anInt1384 < 0 || Region.method170(spawnObjectNode.anInt1386, aByte1143, 3416 + && (spawnObjectNode.anInt1384 < 0 || Region.method170(spawnObjectNode.anInt1386, 3418 3417 spawnObjectNode.anInt1384))) { 3419 3418 method45(spawnObjectNode.anInt1385, spawnObjectNode.anInt1393, spawnObjectNode.anInt1384, 3420 3419 spawnObjectNode.anInt1394, spawnObjectNode.anInt1391, spawnObjectNode.anInt1386, ··· 3868 3867 return; 3869 3868 int l1 = 0; 3870 3869 if (k1 == 0) 3871 - l1 = currentScene.method267(i1, j, l); 3870 + l1 = currentScene.getWallObjectHash(j, l, i1); 3872 3871 if (k1 == 1) 3873 3872 l1 = currentScene.method268(j, (byte) 4, i1, l); 3874 3873 if (k1 == 2) ··· 3901 3900 if (k1 == 3) { 3902 3901 currentScene.method261(j, l, i1); 3903 3902 GameObjectDefinition class47_2 = GameObjectDefinition.getDefinition(i2); 3904 - if (class47_2.solid && class47_2.actionsBoolean) 3903 + if (class47_2.solid && class47_2.hasActions) 3905 3904 currentCollisionMap[i1].unmarkConcealed(j, l); 3906 3905 } 3907 3906 } ··· 3909 3908 int i3 = i1; 3910 3909 if (i3 < 3 && (currentSceneTileFlags[1][j][l] & 2) == 2) 3911 3910 i3++; 3912 - Region.method165(k, i3, j1, l, currentCollisionMap[i1], i, j, 0, i1, currentScene, 3911 + Region.forceRenderObject(j, l, i1, k, j1, i3, i, currentScene, currentCollisionMap[i1], 3913 3912 intGroundArray); 3914 3913 } 3915 3914 } ··· 7555 7554 currentCollisionMap); 7556 7555 } 7557 7556 7558 - for (int k4 = 0; k4 < dataLength; k4++) { 7559 - int i6 = (mapCoordinates[k4] >> 8) * 64 - nextTopLeftTileX; 7560 - int l7 = (mapCoordinates[k4] & 0xff) * 64 - nextTopRightTileY; 7561 - byte[] abyte2 = terrainData[k4]; 7562 - if (abyte2 == null && chunkY < 800) 7563 - region.initiateVertexHeights(i6, 64, l7, 64); 7557 + for (int pointer = 0; pointer < dataLength; pointer++) { 7558 + int offsetX = (mapCoordinates[pointer] >> 8) * 64 - nextTopLeftTileX; 7559 + int offsetY = (mapCoordinates[pointer] & 0xff) * 64 - nextTopRightTileY; 7560 + byte[] data = terrainData[pointer]; 7561 + if (data == null && chunkY < 800) 7562 + region.initiateVertexHeights(offsetX, 64, offsetY, 64); 7564 7563 } 7565 7564 7566 7565 outBuffer.putOpcode(40); 7567 - for (int j6 = 0; j6 < dataLength; j6++) { 7568 - byte[] abyte1 = objectData[j6]; 7569 - if (abyte1 != null) { 7570 - int l8 = (mapCoordinates[j6] >> 8) * 64 - nextTopLeftTileX; 7571 - int k9 = (mapCoordinates[j6] & 0xff) * 64 - nextTopRightTileY; 7572 - region.method179(k9, currentCollisionMap, l8, -571, currentScene, abyte1); 7566 + for (int _region = 0; _region < dataLength; _region++) { 7567 + byte[] data = objectData[_region]; 7568 + if (data != null) { 7569 + int offsetX = (mapCoordinates[_region] >> 8) * 64 - nextTopLeftTileX; 7570 + int offsetY = (mapCoordinates[_region] & 0xff) * 64 - nextTopRightTileY; 7571 + region.loadObjectBlock(offsetX, offsetY, currentCollisionMap, currentScene, data); 7573 7572 } 7574 7573 } 7575 7574 ··· 7597 7596 7598 7597 } 7599 7598 if (!flag) 7600 - region.method166(anInt1072, k3, k6 * 8, l4 * 8); 7599 + region.method166(k3, k6 * 8, l4 * 8); 7601 7600 } 7602 7601 7603 7602 } ··· 10947 10946 if (byte0 != -61) 10948 10947 outBuffer.putByte(175); 10949 10948 if (spawnObjectNode.anInt1392 == 0) 10950 - i = currentScene.method267(spawnObjectNode.anInt1391, spawnObjectNode.anInt1393, spawnObjectNode.anInt1394); 10949 + i = currentScene.getWallObjectHash(spawnObjectNode.anInt1393, spawnObjectNode.anInt1394, spawnObjectNode.anInt1391); 10951 10950 if (spawnObjectNode.anInt1392 == 1) 10952 10951 i = currentScene.method268(spawnObjectNode.anInt1393, (byte) 4, spawnObjectNode.anInt1391, 10953 10952 spawnObjectNode.anInt1394); ··· 11369 11368 blockX = 10; 11370 11369 blockY = 10; 11371 11370 } 11372 - regionsCached &= Region.method181(blockX, blockY, objects, 24515); 11371 + regionsCached &= Region.regionCached(blockX, blockY, objects); 11373 11372 } 11374 11373 } 11375 11374 ··· 11585 11584 } 11586 11585 11587 11586 private void method150(int i, int j, int k, int l, int i1, int j1) { 11588 - int k1 = currentScene.method267(j, k, i); 11587 + int k1 = currentScene.getWallObjectHash(k, i, j); 11589 11588 i1 = 62 / i1; 11590 11589 if (k1 != 0) { 11591 11590 int l1 = currentScene.method271(j, k, i, k1);
+15 -15
src/main/java/com/jagex/runescape/cache/def/GameObjectDefinition.java
··· 12 12 public class GameObjectDefinition { 13 13 14 14 public static int bufferOffsets[]; 15 - public boolean actionsBoolean; 15 + public boolean hasActions; 16 16 public int modelSizeY; 17 17 public int translateX; 18 18 public static Cache animatedModelCache = new Cache(40); ··· 50 50 public int anInt794; 51 51 public int anInt795; 52 52 public int modelSizeZ; 53 - public boolean aBoolean797; 53 + public boolean wall; 54 54 public boolean unknown3; 55 55 public int modifiedModelColors[]; 56 56 public int sizeX; 57 - public int unknown4; 57 + public int offsetAmplifier; 58 58 public int animationId; 59 59 public boolean nonFlatShading; 60 60 public int childrenIds[]; 61 61 public int icon; 62 - public boolean unknown2; 62 + public boolean castsShadow; 63 63 public static int definitionCount; 64 64 public boolean walkable; 65 65 public boolean solid; ··· 106 106 sizeY = 1; 107 107 solid = true; 108 108 walkable = true; 109 - actionsBoolean = false; 109 + hasActions = false; 110 110 adjustToTerrain = false; 111 111 nonFlatShading = false; 112 - aBoolean797 = false; 112 + wall = false; 113 113 animationId = -1; 114 - unknown4 = 16; 114 + offsetAmplifier = 16; 115 115 modelLightFalloff = 0; 116 116 modelLightAmbient = 0; 117 117 options = null; 118 118 icon = -1; 119 119 anInt795 = -1; 120 120 unknown3 = false; 121 - unknown2 = true; 121 + castsShadow = true; 122 122 modelSizeX = 128; 123 123 modelSizeY = 128; 124 124 modelSizeZ = 128; ··· 327 327 case 19: 328 328 i = buf.getUnsignedByte(); 329 329 if (i == 1) 330 - actionsBoolean = true; 330 + hasActions = true; 331 331 break; 332 332 case 21: 333 333 adjustToTerrain = true; ··· 336 336 nonFlatShading = true; 337 337 break; 338 338 case 23: 339 - aBoolean797 = true; 339 + wall = true; 340 340 break; 341 341 case 24: 342 342 animationId = buf.getUnsignedShortBE(); ··· 344 344 animationId = -1; 345 345 break; 346 346 case 28: 347 - unknown4 = buf.getUnsignedByte(); 347 + offsetAmplifier = buf.getUnsignedByte(); 348 348 break; 349 349 case 29: 350 350 modelLightFalloff = buf.getByte(); ··· 372 372 unknown3 = true; 373 373 break; 374 374 case 64: 375 - unknown2 = false; 375 + castsShadow = false; 376 376 break; 377 377 case 65: 378 378 modelSizeX = buf.getUnsignedShortBE(); ··· 435 435 436 436 } 437 437 if (i == -1) { 438 - actionsBoolean = false; 438 + hasActions = false; 439 439 if (modelIds != null && (modelTypes == null || modelTypes[0] == 10)) 440 - actionsBoolean = true; 440 + hasActions = true; 441 441 if (options != null) 442 - actionsBoolean = true; 442 + hasActions = true; 443 443 } 444 444 if (aBoolean791) { 445 445 solid = false;
+1201 -1218
src/main/java/com/jagex/runescape/scene/Region.java
··· 12 12 import com.jagex.runescape.scene.util.TiledUtils; 13 13 14 14 public class Region { 15 - public byte[][][] renderRuleFlags; 16 - public byte aByte139 = 0; 17 - public boolean aBoolean140 = true; 18 - public static int hueRandomizer = (int) (Math.random() * 17.0) - 8; 19 - public byte[][][] overlayRotations; 20 - public static final int[] anIntArray143 = { 0, -1, 0, 1 }; 21 - public int[] blendedHue; 22 - public int[] blendedSaturation; 23 - public int[] blendedLightness; 24 - public int[] blendedHueDivisor; 25 - public int[] blendDirectionTracker; 26 - public int[][][] vertexHeights; 27 - public static int lowestPlane = 99; 28 - public int regionSizeX; 29 - public int regionSizeY; 30 - public byte[][][] overlayClippingPaths; 31 - public static byte aByte154 = -80; 32 - public byte[][][] overlayFloorIds; 33 - public byte aByte156 = 0; 34 - public boolean aBoolean157 = true; 35 - public static final int[] anIntArray158 = { 1, 2, 4, 8 }; 36 - public byte[][][] underlayFloorIds; 37 - public int anInt160 = 20411; 38 - public static final int[] anIntArray161 = { 1, 0, -1, 0 }; 39 - public static int onBuildTimePlane; 40 - public static int lightnessRandomizer = (int) (Math.random() * 33.0) - 16; 41 - public byte[][][] tileShadowIntensity; 42 - public int[][] tileLightingIntensity; 43 - public int anInt166 = 69; 44 - public static final int[] anIntArray167 = { 16, 32, 64, 128 }; 45 - public int[][][] tileCullingBitsets; 46 - public static boolean lowMemory = true; 15 + public byte[][][] renderRuleFlags; 16 + public static int hueRandomizer = (int) (Math.random() * 17.0) - 8; 17 + public byte[][][] overlayRotations; 18 + public static final int[] FACE_OFFSET_X = {1, 0, -1, 0}; 19 + public static final int[] FACE_OFFSET_Y = {0, -1, 0, 1}; 20 + public static final int[] WALL_CORNER_ORIENTATION = {16, 32, 64, 128}; 21 + public static final int[] POWERS_OF_TWO = {1, 2, 4, 8}; 22 + public int[] blendedHue; 23 + public int[] blendedSaturation; 24 + public int[] blendedLightness; 25 + public int[] blendedHueDivisor; 26 + public int[] blendDirectionTracker; 27 + public int[][][] vertexHeights; 28 + public static int lowestPlane = 99; 29 + public int regionSizeX; 30 + public int regionSizeY; 31 + public byte[][][] overlayClippingPaths; 32 + public byte[][][] overlayFloorIds; 33 + public byte[][][] underlayFloorIds; 34 + public int anInt160 = 20411; 35 + public static int onBuildTimePlane; 36 + public static int lightnessRandomizer = (int) (Math.random() * 33.0) - 16; 37 + public byte[][][] tileShadowIntensity; 38 + public int[][] tileLightingIntensity; 39 + public int anInt166 = 69; 40 + public int[][][] tileCullingBitsets; 41 + public static boolean lowMemory = true; 47 42 48 43 49 - public Region(byte[][][] renderRuleFlags, int regionSizeY, int regionSizeX, int[][][] vertexHeights) { 50 - lowestPlane = 99; 51 - this.regionSizeX = regionSizeX; 52 - this.regionSizeY = regionSizeY; 53 - this.vertexHeights = vertexHeights; 54 - this.renderRuleFlags = renderRuleFlags; 55 - underlayFloorIds = new byte[4][this.regionSizeX][this.regionSizeY]; 56 - overlayFloorIds = new byte[4][this.regionSizeX][this.regionSizeY]; 57 - overlayClippingPaths = new byte[4][this.regionSizeX][this.regionSizeY]; 58 - overlayRotations = new byte[4][this.regionSizeX][this.regionSizeY]; 59 - tileCullingBitsets = new int[4][this.regionSizeX + 1][this.regionSizeY + 1]; 60 - tileShadowIntensity = new byte[4][this.regionSizeX + 1][this.regionSizeY + 1]; 61 - tileLightingIntensity = new int[this.regionSizeX + 1][this.regionSizeY + 1]; 62 - blendedHue = new int[this.regionSizeY]; 63 - blendedSaturation = new int[this.regionSizeY]; 64 - blendedLightness = new int[this.regionSizeY]; 65 - blendedHueDivisor = new int[this.regionSizeY]; 66 - blendDirectionTracker = new int[this.regionSizeY]; 44 + public Region(byte[][][] renderRuleFlags, int regionSizeY, int regionSizeX, int[][][] vertexHeights) { 45 + lowestPlane = 99; 46 + this.regionSizeX = regionSizeX; 47 + this.regionSizeY = regionSizeY; 48 + this.vertexHeights = vertexHeights; 49 + this.renderRuleFlags = renderRuleFlags; 50 + underlayFloorIds = new byte[4][this.regionSizeX][this.regionSizeY]; 51 + overlayFloorIds = new byte[4][this.regionSizeX][this.regionSizeY]; 52 + overlayClippingPaths = new byte[4][this.regionSizeX][this.regionSizeY]; 53 + overlayRotations = new byte[4][this.regionSizeX][this.regionSizeY]; 54 + tileCullingBitsets = new int[4][this.regionSizeX + 1][this.regionSizeY + 1]; 55 + tileShadowIntensity = new byte[4][this.regionSizeX + 1][this.regionSizeY + 1]; 56 + tileLightingIntensity = new int[this.regionSizeX + 1][this.regionSizeY + 1]; 57 + blendedHue = new int[this.regionSizeY]; 58 + blendedSaturation = new int[this.regionSizeY]; 59 + blendedLightness = new int[this.regionSizeY]; 60 + blendedHueDivisor = new int[this.regionSizeY]; 61 + blendDirectionTracker = new int[this.regionSizeY]; 67 62 68 - } 63 + } 69 64 70 - public static int calculateNoise(int x, int seed) { 71 - int n = x + seed * 57; 72 - n = n << 13 ^ n; 73 - int noise = n * (n * n * 15731 + 789221) + 1376312589 & 0x7fffffff; 74 - return noise >> 19 & 0xff; 75 - } 65 + public static int calculateNoise(int x, int seed) { 66 + int n = x + seed * 57; 67 + n = n << 13 ^ n; 68 + int noise = n * (n * n * 15731 + 789221) + 1376312589 & 0x7fffffff; 69 + return noise >> 19 & 0xff; 70 + } 76 71 77 - public static int method163(int i, int i_0_, int i_1_) { 78 - int i_2_ = i / i_1_; 79 - int i_3_ = i & i_1_ - 1; 80 - int i_4_ = i_0_ / i_1_; 81 - int i_5_ = i_0_ & i_1_ - 1; 82 - int i_6_ = method178(i_2_, i_4_); 83 - int i_7_ = method178(i_2_ + 1, i_4_); 84 - int i_8_ = method178(i_2_, i_4_ + 1); 85 - int i_9_ = method178(i_2_ + 1, i_4_ + 1); 86 - int i_10_ = method176(i_6_, i_7_, i_3_, i_1_); 87 - int i_11_ = method176(i_8_, i_9_, i_3_, i_1_); 88 - return method176(i_10_, i_11_, i_5_, i_1_); 89 - } 72 + public static int method163(int deltaX, int deltaY, int deltaScale) { 73 + int x = deltaX / deltaScale; 74 + int deltaPrimary = deltaX & deltaScale - 1; 75 + int y = deltaY / deltaScale; 76 + int deltaSecondary = deltaY & deltaScale - 1; 77 + int noiseSW = randomNoiseWeighedSum(x, y); 78 + int noiseSE = randomNoiseWeighedSum(x + 1, y); 79 + int noiseNE = randomNoiseWeighedSum(x, y + 1); 80 + int noiseNW = randomNoiseWeighedSum(x + 1, y + 1); 81 + int interpolationA = interpolate(noiseSW, noiseSE, deltaPrimary, deltaScale); 82 + int interpolationB = interpolate(noiseNE, noiseNW, deltaPrimary, deltaScale); 83 + return interpolate(interpolationA, interpolationB, deltaSecondary, deltaScale); 84 + } 90 85 91 - public int getVisibilityPlaneFor(int i, int i_12_, int i_13_, byte i_14_) { 92 - if (i_14_ == aByte156) { 93 - // boolean bool = false; 94 - } else 95 - return 2; 96 - if ((renderRuleFlags[i_12_][i_13_][i] & 0x8) != 0) 97 - return 0; 98 - if (i_12_ > 0 && (renderRuleFlags[1][i_13_][i] & 0x2) != 0) 99 - return i_12_ - 1; 100 - return i_12_; 101 - } 86 + public int getVisibilityPlaneFor(int x, int y, int plane) { 87 + if ((this.renderRuleFlags[plane][x][y] & 8) != 0) { 88 + return 0; 89 + } 90 + if (plane > 0 && (this.renderRuleFlags[1][x][y] & 2) != 0) { 91 + return plane - 1; 92 + } else { 93 + return plane; 94 + } 95 + } 102 96 103 - public static void method165(int i, int i_15_, int i_16_, int i_17_, CollisionMap class46, int i_18_, int i_19_, 104 - int i_20_, int i_21_, Scene class22, int[][][] is) { 105 - int i_22_ = is[i_15_][i_19_][i_17_]; 106 - int i_23_ = is[i_15_][i_19_ + 1][i_17_]; 107 - int i_24_ = is[i_15_][i_19_ + 1][i_17_ + 1]; 108 - int i_25_ = is[i_15_][i_19_][i_17_ + 1]; 109 - int i_26_ = i_22_ + i_23_ + i_24_ + i_25_ >> 2; 110 - GameObjectDefinition class47 = GameObjectDefinition.getDefinition(i); 111 - if (i_20_ == 0) { 112 - int i_27_ = i_19_ + (i_17_ << 7) + (i << 14) + 1073741824; 113 - if (!class47.actionsBoolean) 114 - i_27_ += -2147483648; 115 - byte i_28_ = (byte) ((i_18_ << 6) + i_16_); 116 - if (i_16_ == 22) { 117 - Renderable class50_sub1_sub4; 118 - if (class47.animationId == -1 && class47.childrenIds == null) 119 - class50_sub1_sub4 = class47.getGameObjectModel(22, i_18_, i_22_, i_23_, i_24_, i_25_, -1); 120 - else 121 - class50_sub1_sub4 = new GameObject(i, i_18_, 22, i_23_, i_24_, i_22_, i_25_, class47.animationId, 97 + public static void forceRenderObject(int x, int y, int z, int objectId, int type, int plane, int face, Scene scene, CollisionMap collisionMap, 98 + int[][][] groundArray) { 99 + int vertexHeightSW = groundArray[plane][x][y]; 100 + int vertexHeightSE = groundArray[plane][x + 1][y]; 101 + int vertexHeightNE = groundArray[plane][x + 1][y + 1]; 102 + int vertexHeightNW = groundArray[plane][x][y + 1]; 103 + int drawHeight = vertexHeightSW + vertexHeightSE + vertexHeightNE + vertexHeightNW >> 2; 104 + GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId); 105 + int hash = x + (y << 7) + (objectId << 14) + 1073741824; 106 + if (!definition.hasActions) 107 + hash += -2147483648; 108 + byte config = (byte) ((face << 6) + type); 109 + if (type == 22) { 110 + Renderable renderable; 111 + if (definition.animationId == -1 && definition.childrenIds == null) 112 + renderable = definition.getGameObjectModel(22, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 113 + else 114 + renderable = new GameObject(objectId, face, 22, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 115 + true); 116 + scene.addGroundDecoration(x, y, z, drawHeight, hash, renderable, config); 117 + if (definition.solid && definition.hasActions) 118 + collisionMap.markBlocked(x, y); 119 + } else if (type == 10 || type == 11) { 120 + Renderable renderable; 121 + if (definition.animationId == -1 && definition.childrenIds == null) 122 + renderable = definition.getGameObjectModel(10, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 123 + else 124 + renderable = new GameObject(objectId, face, 10, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 125 + true); 126 + if (renderable != null) { 127 + int rotation = 0; 128 + if (type == 11) 129 + rotation += 256; 130 + int sizeX; 131 + int sizeY; 132 + if (face == 1 || face == 3) { 133 + sizeX = definition.sizeY; 134 + sizeY = definition.sizeX; 135 + } else { 136 + sizeX = definition.sizeX; 137 + sizeY = definition.sizeY; 138 + } 139 + scene.addEntityB(x, y, z, drawHeight, rotation, sizeY, sizeX, hash, renderable, config 140 + ); 141 + } 142 + if (definition.solid) 143 + collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x, 144 + (byte) 52); 145 + } else if (type >= 12) { 146 + Renderable renderable; 147 + if (definition.animationId == -1 && definition.childrenIds == null) 148 + renderable = definition.getGameObjectModel(type, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 149 + else 150 + renderable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 151 + true); 152 + scene.addEntityB(x, y, z, drawHeight, 0, 1, 1, hash, renderable, config); 153 + if (definition.solid) 154 + collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x, 155 + (byte) 52); 156 + } else if (type == 0) { 157 + Renderable renderable; 158 + if (definition.animationId == -1 && definition.childrenIds == null) 159 + renderable = definition.getGameObjectModel(0, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 160 + else 161 + renderable = new GameObject(objectId, face, 0, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 162 + true); 163 + scene.addWall(x, y, z, drawHeight, POWERS_OF_TWO[face], 0, hash, renderable, null, config 164 + ); 165 + if (definition.solid) 166 + collisionMap.markWall(x, y, type, face, definition.walkable); 167 + } else if (type == 1) { 168 + Renderable renderable; 169 + if (definition.animationId == -1 && definition.childrenIds == null) 170 + renderable = definition.getGameObjectModel(1, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 171 + else 172 + renderable = new GameObject(objectId, face, 1, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 173 + true); 174 + scene.addWall(x, y, z, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, config 175 + ); 176 + if (definition.solid) 177 + collisionMap.markWall(x, y, type, face, definition.walkable); 178 + } else if (type == 2) { 179 + int _face = face + 1 & 0x3; 180 + Renderable renderable; 181 + Renderable renderable1; 182 + if (definition.animationId == -1 && definition.childrenIds == null) { 183 + renderable = definition.getGameObjectModel(2, 4 + face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 184 + renderable1 = definition.getGameObjectModel(2, _face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 185 + } else { 186 + renderable = new GameObject(objectId, 4 + face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 187 + true); 188 + renderable1 = new GameObject(objectId, _face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 189 + true); 190 + } 191 + scene.addWall(x, y, z, drawHeight, POWERS_OF_TWO[face], POWERS_OF_TWO[_face], hash, renderable, renderable1, config 192 + ); 193 + if (definition.solid) 194 + collisionMap.markWall(x, y, type, face, definition.walkable); 195 + } else if (type == 3) { 196 + Renderable renderable; 197 + if (definition.animationId == -1 && definition.childrenIds == null) 198 + renderable = definition.getGameObjectModel(3, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 199 + else 200 + renderable = new GameObject(objectId, face, 3, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 201 + true); 202 + scene.addWall(x, y, z, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, config 203 + ); 204 + if (definition.solid) 205 + collisionMap.markWall(x, y, type, face, definition.walkable); 206 + } else if (type == 9) { 207 + Renderable renderable; 208 + if (definition.animationId == -1 && definition.childrenIds == null) 209 + renderable = definition.getGameObjectModel(type, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 210 + else 211 + renderable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 212 + true); 213 + scene.addEntityB(x, y, z, drawHeight, 0, 1, 1, hash, renderable, config); 214 + if (definition.solid) 215 + collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x, 216 + (byte) 52); 217 + } else { 218 + if (definition.adjustToTerrain) { 219 + if (face == 1) { 220 + int temp = vertexHeightNW; 221 + vertexHeightNW = vertexHeightNE; 222 + vertexHeightNE = vertexHeightSE; 223 + vertexHeightSE = vertexHeightSW; 224 + vertexHeightSW = temp; 225 + } else if (face == 2) { 226 + int temp = vertexHeightNW; 227 + vertexHeightNW = vertexHeightSE; 228 + vertexHeightSE = temp; 229 + temp = vertexHeightNE; 230 + vertexHeightNE = vertexHeightSW; 231 + vertexHeightSW = temp; 232 + } else if (face == 3) { 233 + int temp = vertexHeightNW; 234 + vertexHeightNW = vertexHeightSW; 235 + vertexHeightSW = vertexHeightSE; 236 + vertexHeightSE = vertexHeightNE; 237 + vertexHeightNE = temp; 238 + } 239 + } 240 + if (type == 4) { 241 + Renderable renderable; 242 + if (definition.animationId == -1 && definition.childrenIds == null) 243 + renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 244 + else 245 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 122 246 true); 123 - class22.addGroundDecoration(i_19_, i_17_, i_21_, i_26_, i_27_, class50_sub1_sub4, i_28_); 124 - if (class47.solid && class47.actionsBoolean) 125 - class46.markBlocked(i_19_, i_17_); 126 - } else if (i_16_ == 10 || i_16_ == 11) { 127 - Renderable class50_sub1_sub4; 128 - if (class47.animationId == -1 && class47.childrenIds == null) 129 - class50_sub1_sub4 = class47.getGameObjectModel(10, i_18_, i_22_, i_23_, i_24_, i_25_, -1); 130 - else 131 - class50_sub1_sub4 = new GameObject(i, i_18_, 10, i_23_, i_24_, i_22_, i_25_, class47.animationId, 247 + scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face * 512, hash, renderable, config, POWERS_OF_TWO[face] 248 + ); 249 + } else if (type == 5) { 250 + int offsetAmplifier = 16; 251 + int objectHash = scene.getWallObjectHash(x, y, z); 252 + if (objectHash > 0) 253 + offsetAmplifier = GameObjectDefinition.getDefinition(objectHash >> 14 & 0x7fff).offsetAmplifier; 254 + Renderable renderable; 255 + if (definition.animationId == -1 && definition.childrenIds == null) 256 + renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 257 + else 258 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 132 259 true); 133 - if (class50_sub1_sub4 != null) { 134 - int i_29_ = 0; 135 - if (i_16_ == 11) 136 - i_29_ += 256; 137 - int i_30_; 138 - int i_31_; 139 - if (i_18_ == 1 || i_18_ == 3) { 140 - i_30_ = class47.sizeY; 141 - i_31_ = class47.sizeX; 142 - } else { 143 - i_30_ = class47.sizeX; 144 - i_31_ = class47.sizeY; 145 - } 146 - class22.addEntityB(i_19_, i_17_, i_21_, i_26_, i_29_, i_31_, i_30_, i_27_, class50_sub1_sub4, i_28_ 147 - ); 148 - } 149 - if (class47.solid) 150 - class46.method413(i_17_, i_18_, class47.sizeY, class47.sizeX, class47.walkable, i_19_, 151 - (byte) 52); 152 - } else if (i_16_ >= 12) { 153 - Renderable class50_sub1_sub4; 154 - if (class47.animationId == -1 && class47.childrenIds == null) 155 - class50_sub1_sub4 = class47.getGameObjectModel(i_16_, i_18_, i_22_, i_23_, i_24_, i_25_, -1); 156 - else 157 - class50_sub1_sub4 = new GameObject(i, i_18_, i_16_, i_23_, i_24_, i_22_, i_25_, class47.animationId, 260 + scene.addWallDecoration(x, y, z, drawHeight, FACE_OFFSET_X[face] * offsetAmplifier, FACE_OFFSET_Y[face] * offsetAmplifier, face * 512, hash, renderable, config, POWERS_OF_TWO[face] 261 + ); 262 + } else if (type == 6) { 263 + Renderable renderable; 264 + if (definition.animationId == -1 && definition.childrenIds == null) 265 + renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 266 + else 267 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 158 268 true); 159 - class22.addEntityB(i_19_, i_17_, i_21_, i_26_, 0, 1, 1, i_27_, class50_sub1_sub4, i_28_); 160 - if (class47.solid) 161 - class46.method413(i_17_, i_18_, class47.sizeY, class47.sizeX, class47.walkable, i_19_, 162 - (byte) 52); 163 - } else if (i_16_ == 0) { 164 - Renderable class50_sub1_sub4; 165 - if (class47.animationId == -1 && class47.childrenIds == null) 166 - class50_sub1_sub4 = class47.getGameObjectModel(0, i_18_, i_22_, i_23_, i_24_, i_25_, -1); 167 - else 168 - class50_sub1_sub4 = new GameObject(i, i_18_, 0, i_23_, i_24_, i_22_, i_25_, class47.animationId, 269 + scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 256 270 + ); 271 + } else if (type == 7) { 272 + Renderable renderable; 273 + if (definition.animationId == -1 && definition.childrenIds == null) 274 + renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 275 + else 276 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 169 277 true); 170 - class22.addWall(i_19_, i_17_, i_21_, i_26_, anIntArray158[i_18_], 0, i_27_, class50_sub1_sub4, null, i_28_ 171 - ); 172 - if (class47.solid) 173 - class46.markWall(i_19_, i_17_, i_16_, i_18_, class47.walkable); 174 - } else if (i_16_ == 1) { 175 - Renderable class50_sub1_sub4; 176 - if (class47.animationId == -1 && class47.childrenIds == null) 177 - class50_sub1_sub4 = class47.getGameObjectModel(1, i_18_, i_22_, i_23_, i_24_, i_25_, -1); 178 - else 179 - class50_sub1_sub4 = new GameObject(i, i_18_, 1, i_23_, i_24_, i_22_, i_25_, class47.animationId, 278 + scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 512 279 + ); 280 + } else if (type == 8) { 281 + Renderable renderable; 282 + if (definition.animationId == -1 && definition.childrenIds == null) 283 + renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 284 + else 285 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 180 286 true); 181 - class22.addWall(i_19_, i_17_, i_21_, i_26_, anIntArray167[i_18_], 0, i_27_, class50_sub1_sub4, null, i_28_ 182 - ); 183 - if (class47.solid) 184 - class46.markWall(i_19_, i_17_, i_16_, i_18_, class47.walkable); 185 - } else if (i_16_ == 2) { 186 - int i_32_ = i_18_ + 1 & 0x3; 187 - Renderable class50_sub1_sub4; 188 - Renderable class50_sub1_sub4_33_; 189 - if (class47.animationId == -1 && class47.childrenIds == null) { 190 - class50_sub1_sub4 = class47.getGameObjectModel(2, 4 + i_18_, i_22_, i_23_, i_24_, i_25_, -1); 191 - class50_sub1_sub4_33_ = class47.getGameObjectModel(2, i_32_, i_22_, i_23_, i_24_, i_25_, -1); 192 - } else { 193 - class50_sub1_sub4 = new GameObject(i, 4 + i_18_, 2, i_23_, i_24_, i_22_, i_25_, class47.animationId, 194 - true); 195 - class50_sub1_sub4_33_ = new GameObject(i, i_32_, 2, i_23_, i_24_, i_22_, i_25_, class47.animationId, 196 - true); 197 - } 198 - class22.addWall(i_19_, i_17_, i_21_, i_26_, anIntArray158[i_18_], anIntArray158[i_32_], i_27_, class50_sub1_sub4, class50_sub1_sub4_33_, i_28_ 199 - ); 200 - if (class47.solid) 201 - class46.markWall(i_19_, i_17_, i_16_, i_18_, class47.walkable); 202 - } else if (i_16_ == 3) { 203 - Renderable class50_sub1_sub4; 204 - if (class47.animationId == -1 && class47.childrenIds == null) 205 - class50_sub1_sub4 = class47.getGameObjectModel(3, i_18_, i_22_, i_23_, i_24_, i_25_, -1); 206 - else 207 - class50_sub1_sub4 = new GameObject(i, i_18_, 3, i_23_, i_24_, i_22_, i_25_, class47.animationId, 208 - true); 209 - class22.addWall(i_19_, i_17_, i_21_, i_26_, anIntArray167[i_18_], 0, i_27_, class50_sub1_sub4, null, i_28_ 210 - ); 211 - if (class47.solid) 212 - class46.markWall(i_19_, i_17_, i_16_, i_18_, class47.walkable); 213 - } else if (i_16_ == 9) { 214 - Renderable class50_sub1_sub4; 215 - if (class47.animationId == -1 && class47.childrenIds == null) 216 - class50_sub1_sub4 = class47.getGameObjectModel(i_16_, i_18_, i_22_, i_23_, i_24_, i_25_, -1); 217 - else 218 - class50_sub1_sub4 = new GameObject(i, i_18_, i_16_, i_23_, i_24_, i_22_, i_25_, class47.animationId, 219 - true); 220 - class22.addEntityB(i_19_, i_17_, i_21_, i_26_, 0, 1, 1, i_27_, class50_sub1_sub4, i_28_); 221 - if (class47.solid) 222 - class46.method413(i_17_, i_18_, class47.sizeY, class47.sizeX, class47.walkable, i_19_, 223 - (byte) 52); 224 - } else { 225 - if (class47.adjustToTerrain) { 226 - if (i_18_ == 1) { 227 - int i_34_ = i_25_; 228 - i_25_ = i_24_; 229 - i_24_ = i_23_; 230 - i_23_ = i_22_; 231 - i_22_ = i_34_; 232 - } else if (i_18_ == 2) { 233 - int i_35_ = i_25_; 234 - i_25_ = i_23_; 235 - i_23_ = i_35_; 236 - i_35_ = i_24_; 237 - i_24_ = i_22_; 238 - i_22_ = i_35_; 239 - } else if (i_18_ == 3) { 240 - int i_36_ = i_25_; 241 - i_25_ = i_22_; 242 - i_22_ = i_23_; 243 - i_23_ = i_24_; 244 - i_24_ = i_36_; 245 - } 246 - } 247 - if (i_16_ == 4) { 248 - Renderable class50_sub1_sub4; 249 - if (class47.animationId == -1 && class47.childrenIds == null) 250 - class50_sub1_sub4 = class47.getGameObjectModel(4, 0, i_22_, i_23_, i_24_, i_25_, -1); 251 - else 252 - class50_sub1_sub4 = new GameObject(i, 0, 4, i_23_, i_24_, i_22_, i_25_, class47.animationId, 253 - true); 254 - class22.addWallDecoration(i_19_, i_17_, i_21_, i_26_, 0, 0, i_18_ * 512, i_27_, class50_sub1_sub4, i_28_, anIntArray158[i_18_] 255 - ); 256 - } else if (i_16_ == 5) { 257 - int i_37_ = 16; 258 - int i_38_ = class22.method267(i_21_, i_19_, i_17_); 259 - if (i_38_ > 0) 260 - i_37_ = GameObjectDefinition.getDefinition(i_38_ >> 14 & 0x7fff).unknown4; 261 - Renderable class50_sub1_sub4; 262 - if (class47.animationId == -1 && class47.childrenIds == null) 263 - class50_sub1_sub4 = class47.getGameObjectModel(4, 0, i_22_, i_23_, i_24_, i_25_, -1); 264 - else 265 - class50_sub1_sub4 = new GameObject(i, 0, 4, i_23_, i_24_, i_22_, i_25_, class47.animationId, 266 - true); 267 - class22.addWallDecoration(i_19_, i_17_, i_21_, i_26_, anIntArray161[i_18_] * i_37_, anIntArray143[i_18_] * i_37_, i_18_ * 512, i_27_, class50_sub1_sub4, i_28_, anIntArray158[i_18_] 268 - ); 269 - } else if (i_16_ == 6) { 270 - Renderable class50_sub1_sub4; 271 - if (class47.animationId == -1 && class47.childrenIds == null) 272 - class50_sub1_sub4 = class47.getGameObjectModel(4, 0, i_22_, i_23_, i_24_, i_25_, -1); 273 - else 274 - class50_sub1_sub4 = new GameObject(i, 0, 4, i_23_, i_24_, i_22_, i_25_, class47.animationId, 275 - true); 276 - class22.addWallDecoration(i_19_, i_17_, i_21_, i_26_, 0, 0, i_18_, i_27_, class50_sub1_sub4, i_28_, 256 277 - ); 278 - } else if (i_16_ == 7) { 279 - Renderable class50_sub1_sub4; 280 - if (class47.animationId == -1 && class47.childrenIds == null) 281 - class50_sub1_sub4 = class47.getGameObjectModel(4, 0, i_22_, i_23_, i_24_, i_25_, -1); 282 - else 283 - class50_sub1_sub4 = new GameObject(i, 0, 4, i_23_, i_24_, i_22_, i_25_, class47.animationId, 284 - true); 285 - class22.addWallDecoration(i_19_, i_17_, i_21_, i_26_, 0, 0, i_18_, i_27_, class50_sub1_sub4, i_28_, 512 286 - ); 287 - } else if (i_16_ == 8) { 288 - Renderable class50_sub1_sub4; 289 - if (class47.animationId == -1 && class47.childrenIds == null) 290 - class50_sub1_sub4 = class47.getGameObjectModel(4, 0, i_22_, i_23_, i_24_, i_25_, -1); 291 - else 292 - class50_sub1_sub4 = new GameObject(i, 0, 4, i_23_, i_24_, i_22_, i_25_, class47.animationId, 293 - true); 294 - class22.addWallDecoration(i_19_, i_17_, i_21_, i_26_, 0, 0, i_18_, i_27_, class50_sub1_sub4, i_28_, 768 295 - ); 296 - } 297 - } 298 - } 299 - } 287 + scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 768 288 + ); 289 + } 290 + } 291 + } 300 292 301 - public void method166(int i, int i_39_, int i_40_, int i_41_) { 302 - if (i == anInt160) { 303 - for (int i_42_ = 0; i_42_ < 8; i_42_++) { 304 - for (int i_43_ = 0; i_43_ < 8; i_43_++) 305 - vertexHeights[i_39_][i_41_ + i_42_][i_40_ + i_43_] = 0; 306 - } 307 - if (i_41_ > 0) { 308 - for (int i_44_ = 1; i_44_ < 8; i_44_++) 309 - vertexHeights[i_39_][i_41_][i_40_ + i_44_] = vertexHeights[i_39_][i_41_ - 1][i_40_ 310 - + i_44_]; 311 - } 312 - if (i_40_ > 0) { 313 - for (int i_45_ = 1; i_45_ < 8; i_45_++) 314 - vertexHeights[i_39_][i_41_ + i_45_][i_40_] = vertexHeights[i_39_][i_41_ + i_45_][i_40_ - 1]; 315 - } 316 - if (i_41_ > 0 && vertexHeights[i_39_][i_41_ - 1][i_40_] != 0) 317 - vertexHeights[i_39_][i_41_][i_40_] = vertexHeights[i_39_][i_41_ - 1][i_40_]; 318 - else if (i_40_ > 0 && vertexHeights[i_39_][i_41_][i_40_ - 1] != 0) 319 - vertexHeights[i_39_][i_41_][i_40_] = vertexHeights[i_39_][i_41_][i_40_ - 1]; 320 - else if (i_41_ > 0 && i_40_ > 0 && vertexHeights[i_39_][i_41_ - 1][i_40_ - 1] != 0) 321 - vertexHeights[i_39_][i_41_][i_40_] = vertexHeights[i_39_][i_41_ - 1][i_40_ - 1]; 322 - } 323 - } 293 + public void method166(int i_39_, int i_40_, int i_41_) { 294 + for (int i_42_ = 0; i_42_ < 8; i_42_++) { 295 + for (int i_43_ = 0; i_43_ < 8; i_43_++) 296 + vertexHeights[i_39_][i_41_ + i_42_][i_40_ + i_43_] = 0; 297 + } 298 + if (i_41_ > 0) { 299 + for (int i_44_ = 1; i_44_ < 8; i_44_++) 300 + vertexHeights[i_39_][i_41_][i_40_ + i_44_] = vertexHeights[i_39_][i_41_ - 1][i_40_ 301 + + i_44_]; 302 + } 303 + if (i_40_ > 0) { 304 + for (int i_45_ = 1; i_45_ < 8; i_45_++) 305 + vertexHeights[i_39_][i_41_ + i_45_][i_40_] = vertexHeights[i_39_][i_41_ + i_45_][i_40_ - 1]; 306 + } 307 + if (i_41_ > 0 && vertexHeights[i_39_][i_41_ - 1][i_40_] != 0) 308 + vertexHeights[i_39_][i_41_][i_40_] = vertexHeights[i_39_][i_41_ - 1][i_40_]; 309 + else if (i_40_ > 0 && vertexHeights[i_39_][i_41_][i_40_ - 1] != 0) 310 + vertexHeights[i_39_][i_41_][i_40_] = vertexHeights[i_39_][i_41_][i_40_ - 1]; 311 + else if (i_41_ > 0 && i_40_ > 0 && vertexHeights[i_39_][i_41_ - 1][i_40_ - 1] != 0) 312 + vertexHeights[i_39_][i_41_][i_40_] = vertexHeights[i_39_][i_41_ - 1][i_40_ - 1]; 313 + } 324 314 325 - public void createRegionScene(CollisionMap[] collisionMaps, Scene scene) { 326 - for (int plane = 0; plane < 4; plane++) { 327 - for (int x = 0; x < 104; x++) { 328 - for (int y = 0; y < 104; y++) { 329 - if ((renderRuleFlags[plane][x][y] & 0x1) == 1) { 330 - int originalPlane = plane; 331 - if ((renderRuleFlags[1][x][y] & 0x2) == 2) 332 - originalPlane--; 333 - if (originalPlane >= 0) 334 - collisionMaps[originalPlane].markBlocked(x, y); 335 - } 336 - } 337 - } 338 - } 339 - hueRandomizer += (int) (Math.random() * 5.0) - 2; 340 - if (hueRandomizer < -8) 341 - hueRandomizer = -8; 342 - if (hueRandomizer > 8) 343 - hueRandomizer = 8; 344 - lightnessRandomizer += (int) (Math.random() * 5.0) - 2; 345 - if (lightnessRandomizer < -16) 346 - lightnessRandomizer = -16; 347 - if (lightnessRandomizer > 16) 348 - lightnessRandomizer = 16; 349 - for (int plane = 0; plane < 4; plane++) { 350 - byte[][] shadowIntensity = tileShadowIntensity[plane]; 351 - int directionalLightInitialIntensity = 96; 352 - int specularDistributionFactor = 768; 353 - int directionalLightX = -50; 354 - int directionalLightY = -10; 355 - int directionalLightZ = -50; 356 - int directionalLightLength = (int) Math.sqrt((directionalLightX * directionalLightX + directionalLightY * directionalLightY + directionalLightZ * directionalLightZ)); 357 - int specularDistribution = specularDistributionFactor * directionalLightLength >> 8; 358 - for (int y = 1; y < regionSizeY - 1; y++) { 359 - for (int x = 1; x < regionSizeX - 1; x++) { 360 - int xHeightDifference = (vertexHeights[plane][x + 1][y] - vertexHeights[plane][x - 1][y]); 361 - int yHeightDifference = (vertexHeights[plane][x][y + 1] - vertexHeights[plane][x][y - 1]); 362 - int normalizedLength = (int) Math.sqrt((xHeightDifference * xHeightDifference + 65536 + yHeightDifference * yHeightDifference)); 363 - int normalizedNormalX = (xHeightDifference << 8) / normalizedLength; 364 - int normalizedNormalY = 65536 / normalizedLength; 365 - int normalizedNormalZ = (yHeightDifference << 8) / normalizedLength; 366 - int directionalLightIntensity = directionalLightInitialIntensity + (directionalLightX * normalizedNormalX + directionalLightY * normalizedNormalY + directionalLightZ * normalizedNormalZ) / specularDistribution; 367 - int weightedShadowIntensity = ((shadowIntensity[x - 1][y] >> 2) + (shadowIntensity[x + 1][y] >> 3) 368 - + (shadowIntensity[x][y - 1] >> 2) + (shadowIntensity[x][y + 1] >> 3) + (shadowIntensity[x][y] >> 1)); 369 - tileLightingIntensity[x][y] = directionalLightIntensity - weightedShadowIntensity; 370 - } 371 - } 372 - for (int y = 0; y < regionSizeY; y++) { 373 - blendedHue[y] = 0; 374 - blendedSaturation[y] = 0; 375 - blendedLightness[y] = 0; 376 - blendedHueDivisor[y] = 0; 377 - blendDirectionTracker[y] = 0; 378 - } 379 - for (int x = -5; x < regionSizeX + 5; x++) { 380 - for (int y = 0; y < regionSizeY; y++) { 381 - int xPositiveOffset = x + 5; 382 - if (xPositiveOffset >= 0 && xPositiveOffset < regionSizeX) { 383 - int floorId = underlayFloorIds[plane][xPositiveOffset][y] & 0xff; 384 - if (floorId > 0) { 385 - FloorDefinition floor = FloorDefinition.cache[floorId - 1]; 386 - blendedHue[y] += floor.hue; 387 - blendedSaturation[y] += floor.saturation; 388 - blendedLightness[y] += floor.lightness; 389 - blendedHueDivisor[y] += floor.hueDivisor; 390 - blendDirectionTracker[y]++; 391 - } 392 - } 393 - int xNegativeOffset = x - 5; 394 - if (xNegativeOffset >= 0 && xNegativeOffset < regionSizeX) { 395 - int floorId = underlayFloorIds[plane][xNegativeOffset][y] & 0xff; 396 - if (floorId > 0) { 397 - FloorDefinition floor = FloorDefinition.cache[floorId - 1]; 398 - blendedHue[y] -= floor.hue; 399 - blendedSaturation[y] -= floor.saturation; 400 - blendedLightness[y] -= floor.lightness; 401 - blendedHueDivisor[y] -= floor.hueDivisor; 402 - blendDirectionTracker[y]--; 403 - } 404 - } 405 - } 406 - if (x >= 1 && x < regionSizeX - 1) { 407 - int i_75_ = 0; 408 - int i_76_ = 0; 409 - int i_77_ = 0; 410 - int i_78_ = 0; 411 - int i_79_ = 0; 412 - for (int y = -5; y < regionSizeY + 5; y++) { 413 - int yPositiveOffset = y + 5; 414 - if (yPositiveOffset >= 0 && yPositiveOffset < regionSizeY) { 415 - i_75_ += blendedHue[yPositiveOffset]; 416 - i_76_ += blendedSaturation[yPositiveOffset]; 417 - i_77_ += blendedLightness[yPositiveOffset]; 418 - i_78_ += blendedHueDivisor[yPositiveOffset]; 419 - i_79_ += blendDirectionTracker[yPositiveOffset]; 420 - } 421 - int yNegativeOffset = y - 5; 422 - if (yNegativeOffset >= 0 && yNegativeOffset < regionSizeY) { 423 - i_75_ -= blendedHue[yNegativeOffset]; 424 - i_76_ -= blendedSaturation[yNegativeOffset]; 425 - i_77_ -= blendedLightness[yNegativeOffset]; 426 - i_78_ -= blendedHueDivisor[yNegativeOffset]; 427 - i_79_ -= blendDirectionTracker[yNegativeOffset]; 428 - } 429 - if (y >= 1 430 - && y < regionSizeY - 1 431 - && (!lowMemory || (renderRuleFlags[0][x][y] & 0x2) != 0 || ((renderRuleFlags[plane][x][y] & 0x10) == 0 && (getVisibilityPlaneFor( 432 - y, plane, x, (byte) 0) == onBuildTimePlane)))) { 433 - if (plane < lowestPlane) 434 - lowestPlane = plane; 435 - int underlayFloorId = (underlayFloorIds[plane][x][y] & 0xff); 436 - int overlayFloorId = (overlayFloorIds[plane][x][y] & 0xff); 437 - if (underlayFloorId > 0 || overlayFloorId > 0) { 438 - int vertexSouthWest = vertexHeights[plane][x][y]; 439 - int vertexSouthEast = (vertexHeights[plane][x + 1][y]); 440 - int vertexNorthEast = (vertexHeights[plane][x + 1][y + 1]); 441 - int vertexNorthWest = (vertexHeights[plane][x][y + 1]); 442 - int lightSouthWest = tileLightingIntensity[x][y]; 443 - int lightSouthEast = tileLightingIntensity[x + 1][y]; 444 - int lightNorthEast = tileLightingIntensity[x + 1][y + 1]; 445 - int lightNorthWest = tileLightingIntensity[x][y + 1]; 446 - int hslBitsetUnmodified = -1; 447 - int hslBitsetRandomized = -1; 448 - if (underlayFloorId > 0) { 449 - int hue = i_75_ * 256 / i_78_; 450 - int saturation = i_76_ / i_79_; 451 - int lightness = i_77_ / i_79_; 452 - hslBitsetUnmodified = getHSLBitset(hue, saturation, lightness); 453 - hue = hue + hueRandomizer & 0xff; 454 - lightness += lightnessRandomizer; 455 - if (lightness < 0) 456 - lightness = 0; 457 - else if (lightness > 255) 458 - lightness = 255; 459 - hslBitsetRandomized = getHSLBitset(hue, saturation, lightness); 460 - } 461 - if (plane > 0) { 462 - boolean bool = true; 463 - if (underlayFloorId == 0 && (overlayClippingPaths[plane][x][y]) != 0) 464 - bool = false; 465 - if (overlayFloorId > 0 && !(FloorDefinition.cache[overlayFloorId - 1].occlude)) 466 - bool = false; 467 - if (bool && vertexSouthWest == vertexSouthEast && vertexSouthWest == vertexNorthEast && vertexSouthWest == vertexNorthWest) 468 - tileCullingBitsets[plane][x][y] |= 0x924; 469 - } 470 - int rgbBitsetRandomized = 0; 471 - if (hslBitsetUnmodified != -1) 472 - rgbBitsetRandomized = (Rasterizer3D.getRgbLookupTableId[trimHSLLightness(hslBitsetRandomized, 96)]); 473 - if (overlayFloorId == 0) 474 - scene.renderTile(plane, x, y, 0, 0, -1, vertexSouthWest, vertexSouthEast, vertexNorthEast, vertexNorthWest, 475 - trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthEast), 476 - trimHSLLightness(hslBitsetUnmodified, lightNorthWest), 0, 0, 0, 0, rgbBitsetRandomized, 0); 477 - else { 478 - int clippingPath = ((overlayClippingPaths[plane][x][y]) + 1); 479 - byte clippingPathRotation = (overlayRotations[plane][x][y]); 480 - FloorDefinition floor = FloorDefinition.cache[overlayFloorId - 1]; 481 - int textureid = floor.textureId; 482 - int hslBitset; 483 - int rgbBitset; 484 - if (textureid >= 0) { 485 - rgbBitset = Rasterizer3D.getAverageRgbColorForTexture(textureid, 0); 486 - hslBitset = -1; 487 - } else if (floor.rgbColor == 16711935) { 488 - hslBitset = -2; 489 - textureid = -1; 490 - rgbBitset = (Rasterizer3D.getRgbLookupTableId[method182(floor.hslColor2, 96)]); 491 - } else { 492 - hslBitset = getHSLBitset(floor.hue2, floor.saturation, floor.lightness); 493 - rgbBitset = (Rasterizer3D.getRgbLookupTableId[method182(floor.hslColor2, 96)]); 494 - } 495 - scene.renderTile(plane, x, y, clippingPath, clippingPathRotation, textureid, vertexSouthWest, vertexSouthEast, vertexNorthEast, 496 - vertexNorthWest, trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, 497 - lightNorthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthWest), method182(hslBitset, lightSouthWest), 498 - method182(hslBitset, lightSouthEast), method182(hslBitset, lightNorthEast), 499 - method182(hslBitset, lightNorthWest), rgbBitsetRandomized, rgbBitset); 500 - } 501 - } 502 - } 503 - } 504 - } 505 - } 506 - for (int i_104_ = 1; i_104_ < regionSizeY - 1; i_104_++) { 507 - for (int i_105_ = 1; i_105_ < regionSizeX - 1; i_105_++) 508 - scene.setTileLogicHeight(plane, i_105_, i_104_, getVisibilityPlaneFor(i_104_, plane, i_105_, (byte) 0)); 509 - } 510 - } 511 - scene.shadeModels(-10, -50, -50); 512 - for (int y = 0; y < regionSizeX; y++) { 513 - for (int x = 0; x < regionSizeY; x++) { 514 - if ((renderRuleFlags[1][y][x] & 0x2) == 2) 515 - scene.setBridgeMode(y, x); 516 - } 517 - } 518 - int renderRule1 = 1; 519 - int renderRule2 = 2; 520 - int renderRule3 = 4; 521 - for (int currentPlane = 0; currentPlane < 4; currentPlane++) { 522 - if (currentPlane > 0) { 523 - renderRule1 <<= 3; 524 - renderRule2 <<= 3; 525 - renderRule3 <<= 3; 526 - } 527 - for (int plane = 0; plane <= currentPlane; plane++) { 528 - for (int y = 0; y <= regionSizeY; y++) { 529 - for (int x = 0; x <= regionSizeX; x++) { 530 - if ((tileCullingBitsets[plane][x][y] & renderRule1) != 0) { 531 - int lowestOcclussionY = y; 532 - int higestOcclussionY = y; 533 - int lowestOcclussionPlane = plane; 534 - int higestOcclussionPlane = plane; 535 - for (/**/; lowestOcclussionY > 0; lowestOcclussionY--) { 536 - if (((tileCullingBitsets[plane][x][lowestOcclussionY - 1]) & renderRule1) == 0) 537 - break; 538 - } 539 - for (/**/; higestOcclussionY < regionSizeY; higestOcclussionY++) { 540 - if (((tileCullingBitsets[plane][x][higestOcclussionY + 1]) & renderRule1) == 0) 541 - break; 542 - } 543 - while_0_: for (/**/; lowestOcclussionPlane > 0; lowestOcclussionPlane--) { 544 - for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) { 545 - if (((tileCullingBitsets[lowestOcclussionPlane - 1][x][occludedY]) & renderRule1) == 0) 546 - break while_0_; 547 - } 548 - } 549 - while_1_: for (/**/; higestOcclussionPlane < currentPlane; higestOcclussionPlane++) { 550 - for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) { 551 - if (((tileCullingBitsets[higestOcclussionPlane + 1][x][occludedY]) & renderRule1) == 0) 552 - break while_1_; 553 - } 554 - } 555 - int occlussionSurface = (higestOcclussionPlane + 1 - lowestOcclussionPlane) * (higestOcclussionY - lowestOcclussionY + 1); 556 - if (occlussionSurface >= 8) { 557 - int highestOcclussionVertexHeightOffset = 240; 558 - int highestOcclussionVertexHeight = ((vertexHeights[higestOcclussionPlane][x][lowestOcclussionY]) - highestOcclussionVertexHeightOffset); 559 - int lowestOcclussionVertexHeight = (vertexHeights[lowestOcclussionPlane][x][lowestOcclussionY]); 560 - Scene.createCullingCluster(currentPlane, x * 128, x * 128, higestOcclussionY * 128 + 128, lowestOcclussionY * 128, highestOcclussionVertexHeight, lowestOcclussionVertexHeight, 561 - 1); 562 - for (int occludedPlane = lowestOcclussionPlane; occludedPlane <= higestOcclussionPlane; occludedPlane++) { 563 - for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) 564 - tileCullingBitsets[occludedPlane][x][occludedY] &= renderRule1 ^ 0xffffffff; 565 - } 566 - } 567 - } 568 - if ((tileCullingBitsets[plane][x][y] & renderRule2) != 0) { 569 - int i_127_ = x; 570 - int i_128_ = x; 571 - int i_129_ = plane; 572 - int i_130_ = plane; 573 - for (/**/; i_127_ > 0; i_127_--) { 574 - if (((tileCullingBitsets[plane][i_127_ - 1][y]) & renderRule2) == 0) 575 - break; 576 - } 577 - for (/**/; i_128_ < regionSizeX; i_128_++) { 578 - if (((tileCullingBitsets[plane][i_128_ + 1][y]) & renderRule2) == 0) 579 - break; 580 - } 581 - while_2_: for (/**/; i_129_ > 0; i_129_--) { 582 - for (int i_131_ = i_127_; i_131_ <= i_128_; i_131_++) { 583 - if (((tileCullingBitsets[i_129_ - 1][i_131_][y]) & renderRule2) == 0) 584 - break while_2_; 585 - } 586 - } 587 - while_3_: for (/**/; i_130_ < currentPlane; i_130_++) { 588 - for (int i_132_ = i_127_; i_132_ <= i_128_; i_132_++) { 589 - if (((tileCullingBitsets[i_130_ + 1][i_132_][y]) & renderRule2) == 0) 590 - break while_3_; 591 - } 592 - } 593 - int i_133_ = (i_130_ + 1 - i_129_) * (i_128_ - i_127_ + 1); 594 - if (i_133_ >= 8) { 595 - int i_134_ = 240; 596 - int i_135_ = ((vertexHeights[i_130_][i_127_][y]) - i_134_); 597 - int i_136_ = (vertexHeights[i_129_][i_127_][y]); 598 - Scene.createCullingCluster(currentPlane, i_128_ * 128 + 128, i_127_ * 128, y * 128, y * 128, i_135_, i_136_, 599 - 2); 600 - for (int i_137_ = i_129_; i_137_ <= i_130_; i_137_++) { 601 - for (int i_138_ = i_127_; i_138_ <= i_128_; i_138_++) 602 - tileCullingBitsets[i_137_][i_138_][y] &= renderRule2 ^ 0xffffffff; 603 - } 604 - } 605 - } 606 - if ((tileCullingBitsets[plane][x][y] & renderRule3) != 0) { 607 - int i_139_ = x; 608 - int i_140_ = x; 609 - int i_141_ = y; 610 - int i_142_ = y; 611 - for (/**/; i_141_ > 0; i_141_--) { 612 - if (((tileCullingBitsets[plane][x][i_141_ - 1]) & renderRule3) == 0) 613 - break; 614 - } 615 - for (/**/; i_142_ < regionSizeY; i_142_++) { 616 - if (((tileCullingBitsets[plane][x][i_142_ + 1]) & renderRule3) == 0) 617 - break; 618 - } 619 - while_4_: for (/**/; i_139_ > 0; i_139_--) { 620 - for (int i_143_ = i_141_; i_143_ <= i_142_; i_143_++) { 621 - if (((tileCullingBitsets[plane][i_139_ - 1][i_143_]) & renderRule3) == 0) 622 - break while_4_; 623 - } 624 - } 625 - while_5_: for (/**/; i_140_ < regionSizeX; i_140_++) { 626 - for (int i_144_ = i_141_; i_144_ <= i_142_; i_144_++) { 627 - if (((tileCullingBitsets[plane][i_140_ + 1][i_144_]) & renderRule3) == 0) 628 - break while_5_; 629 - } 630 - } 631 - if ((i_140_ - i_139_ + 1) * (i_142_ - i_141_ + 1) >= 4) { 632 - int i_145_ = (vertexHeights[plane][i_139_][i_141_]); 633 - Scene.createCullingCluster(currentPlane, i_140_ * 128 + 128, i_139_ * 128, i_142_ * 128 + 128, i_141_ * 128, i_145_, i_145_, 634 - 4); 635 - for (int i_146_ = i_139_; i_146_ <= i_140_; i_146_++) { 636 - for (int i_147_ = i_141_; i_147_ <= i_142_; i_147_++) 637 - tileCullingBitsets[plane][i_146_][i_147_] &= renderRule3 ^ 0xffffffff; 638 - } 639 - } 640 - } 641 - } 642 - } 643 - } 644 - } 645 - } 315 + public void createRegionScene(CollisionMap[] collisionMaps, Scene scene) { 316 + for (int plane = 0; plane < 4; plane++) { 317 + for (int x = 0; x < 104; x++) { 318 + for (int y = 0; y < 104; y++) { 319 + if ((renderRuleFlags[plane][x][y] & 0x1) == 1) { 320 + int originalPlane = plane; 321 + if ((renderRuleFlags[1][x][y] & 0x2) == 2) 322 + originalPlane--; 323 + if (originalPlane >= 0) 324 + collisionMaps[originalPlane].markBlocked(x, y); 325 + } 326 + } 327 + } 328 + } 329 + hueRandomizer += (int) (Math.random() * 5.0) - 2; 330 + if (hueRandomizer < -8) 331 + hueRandomizer = -8; 332 + if (hueRandomizer > 8) 333 + hueRandomizer = 8; 334 + lightnessRandomizer += (int) (Math.random() * 5.0) - 2; 335 + if (lightnessRandomizer < -16) 336 + lightnessRandomizer = -16; 337 + if (lightnessRandomizer > 16) 338 + lightnessRandomizer = 16; 339 + for (int plane = 0; plane < 4; plane++) { 340 + byte[][] shadowIntensity = tileShadowIntensity[plane]; 341 + int directionalLightInitialIntensity = 96; 342 + int specularDistributionFactor = 768; 343 + int directionalLightX = -50; 344 + int directionalLightY = -10; 345 + int directionalLightZ = -50; 346 + int directionalLightLength = (int) Math.sqrt((directionalLightX * directionalLightX + directionalLightY * directionalLightY + directionalLightZ * directionalLightZ)); 347 + int specularDistribution = specularDistributionFactor * directionalLightLength >> 8; 348 + for (int y = 1; y < regionSizeY - 1; y++) { 349 + for (int x = 1; x < regionSizeX - 1; x++) { 350 + int xHeightDifference = (vertexHeights[plane][x + 1][y] - vertexHeights[plane][x - 1][y]); 351 + int yHeightDifference = (vertexHeights[plane][x][y + 1] - vertexHeights[plane][x][y - 1]); 352 + int normalizedLength = (int) Math.sqrt((xHeightDifference * xHeightDifference + 65536 + yHeightDifference * yHeightDifference)); 353 + int normalizedNormalX = (xHeightDifference << 8) / normalizedLength; 354 + int normalizedNormalY = 65536 / normalizedLength; 355 + int normalizedNormalZ = (yHeightDifference << 8) / normalizedLength; 356 + int directionalLightIntensity = directionalLightInitialIntensity + (directionalLightX * normalizedNormalX + directionalLightY * normalizedNormalY + directionalLightZ * normalizedNormalZ) / specularDistribution; 357 + int weightedShadowIntensity = ((shadowIntensity[x - 1][y] >> 2) + (shadowIntensity[x + 1][y] >> 3) 358 + + (shadowIntensity[x][y - 1] >> 2) + (shadowIntensity[x][y + 1] >> 3) + (shadowIntensity[x][y] >> 1)); 359 + tileLightingIntensity[x][y] = directionalLightIntensity - weightedShadowIntensity; 360 + } 361 + } 362 + for (int y = 0; y < regionSizeY; y++) { 363 + blendedHue[y] = 0; 364 + blendedSaturation[y] = 0; 365 + blendedLightness[y] = 0; 366 + blendedHueDivisor[y] = 0; 367 + blendDirectionTracker[y] = 0; 368 + } 369 + for (int x = -5; x < regionSizeX + 5; x++) { 370 + for (int y = 0; y < regionSizeY; y++) { 371 + int xPositiveOffset = x + 5; 372 + if (xPositiveOffset >= 0 && xPositiveOffset < regionSizeX) { 373 + int floorId = underlayFloorIds[plane][xPositiveOffset][y] & 0xff; 374 + if (floorId > 0) { 375 + FloorDefinition floor = FloorDefinition.cache[floorId - 1]; 376 + blendedHue[y] += floor.hue; 377 + blendedSaturation[y] += floor.saturation; 378 + blendedLightness[y] += floor.lightness; 379 + blendedHueDivisor[y] += floor.hueDivisor; 380 + blendDirectionTracker[y]++; 381 + } 382 + } 383 + int xNegativeOffset = x - 5; 384 + if (xNegativeOffset >= 0 && xNegativeOffset < regionSizeX) { 385 + int floorId = underlayFloorIds[plane][xNegativeOffset][y] & 0xff; 386 + if (floorId > 0) { 387 + FloorDefinition floor = FloorDefinition.cache[floorId - 1]; 388 + blendedHue[y] -= floor.hue; 389 + blendedSaturation[y] -= floor.saturation; 390 + blendedLightness[y] -= floor.lightness; 391 + blendedHueDivisor[y] -= floor.hueDivisor; 392 + blendDirectionTracker[y]--; 393 + } 394 + } 395 + } 396 + if (x >= 1 && x < regionSizeX - 1) { 397 + int i_75_ = 0; 398 + int i_76_ = 0; 399 + int i_77_ = 0; 400 + int i_78_ = 0; 401 + int i_79_ = 0; 402 + for (int y = -5; y < regionSizeY + 5; y++) { 403 + int yPositiveOffset = y + 5; 404 + if (yPositiveOffset >= 0 && yPositiveOffset < regionSizeY) { 405 + i_75_ += blendedHue[yPositiveOffset]; 406 + i_76_ += blendedSaturation[yPositiveOffset]; 407 + i_77_ += blendedLightness[yPositiveOffset]; 408 + i_78_ += blendedHueDivisor[yPositiveOffset]; 409 + i_79_ += blendDirectionTracker[yPositiveOffset]; 410 + } 411 + int yNegativeOffset = y - 5; 412 + if (yNegativeOffset >= 0 && yNegativeOffset < regionSizeY) { 413 + i_75_ -= blendedHue[yNegativeOffset]; 414 + i_76_ -= blendedSaturation[yNegativeOffset]; 415 + i_77_ -= blendedLightness[yNegativeOffset]; 416 + i_78_ -= blendedHueDivisor[yNegativeOffset]; 417 + i_79_ -= blendDirectionTracker[yNegativeOffset]; 418 + } 419 + if (y >= 1 420 + && y < regionSizeY - 1 421 + && (!lowMemory || (renderRuleFlags[0][x][y] & 0x2) != 0 || ((renderRuleFlags[plane][x][y] & 0x10) == 0 && (getVisibilityPlaneFor( 422 + x, y, plane) == onBuildTimePlane)))) { 423 + if (plane < lowestPlane) 424 + lowestPlane = plane; 425 + int underlayFloorId = (underlayFloorIds[plane][x][y] & 0xff); 426 + int overlayFloorId = (overlayFloorIds[plane][x][y] & 0xff); 427 + if (underlayFloorId > 0 || overlayFloorId > 0) { 428 + int vertexSouthWest = vertexHeights[plane][x][y]; 429 + int vertexSouthEast = (vertexHeights[plane][x + 1][y]); 430 + int vertexNorthEast = (vertexHeights[plane][x + 1][y + 1]); 431 + int vertexNorthWest = (vertexHeights[plane][x][y + 1]); 432 + int lightSouthWest = tileLightingIntensity[x][y]; 433 + int lightSouthEast = tileLightingIntensity[x + 1][y]; 434 + int lightNorthEast = tileLightingIntensity[x + 1][y + 1]; 435 + int lightNorthWest = tileLightingIntensity[x][y + 1]; 436 + int hslBitsetUnmodified = -1; 437 + int hslBitsetRandomized = -1; 438 + if (underlayFloorId > 0) { 439 + int hue = i_75_ * 256 / i_78_; 440 + int saturation = i_76_ / i_79_; 441 + int lightness = i_77_ / i_79_; 442 + hslBitsetUnmodified = getHSLBitset(hue, saturation, lightness); 443 + hue = hue + hueRandomizer & 0xff; 444 + lightness += lightnessRandomizer; 445 + if (lightness < 0) 446 + lightness = 0; 447 + else if (lightness > 255) 448 + lightness = 255; 449 + hslBitsetRandomized = getHSLBitset(hue, saturation, lightness); 450 + } 451 + if (plane > 0) { 452 + boolean bool = true; 453 + if (underlayFloorId == 0 && (overlayClippingPaths[plane][x][y]) != 0) 454 + bool = false; 455 + if (overlayFloorId > 0 && !(FloorDefinition.cache[overlayFloorId - 1].occlude)) 456 + bool = false; 457 + if (bool && vertexSouthWest == vertexSouthEast && vertexSouthWest == vertexNorthEast && vertexSouthWest == vertexNorthWest) 458 + tileCullingBitsets[plane][x][y] |= 0x924; 459 + } 460 + int rgbBitsetRandomized = 0; 461 + if (hslBitsetUnmodified != -1) 462 + rgbBitsetRandomized = (Rasterizer3D.getRgbLookupTableId[trimHSLLightness(hslBitsetRandomized, 96)]); 463 + if (overlayFloorId == 0) 464 + scene.renderTile(plane, x, y, 0, 0, -1, vertexSouthWest, vertexSouthEast, vertexNorthEast, vertexNorthWest, 465 + trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthEast), 466 + trimHSLLightness(hslBitsetUnmodified, lightNorthWest), 0, 0, 0, 0, rgbBitsetRandomized, 0); 467 + else { 468 + int clippingPath = ((overlayClippingPaths[plane][x][y]) + 1); 469 + byte clippingPathRotation = (overlayRotations[plane][x][y]); 470 + FloorDefinition floor = FloorDefinition.cache[overlayFloorId - 1]; 471 + int textureid = floor.textureId; 472 + int hslBitset; 473 + int rgbBitset; 474 + if (textureid >= 0) { 475 + rgbBitset = Rasterizer3D.getAverageRgbColorForTexture(textureid, 0); 476 + hslBitset = -1; 477 + } else if (floor.rgbColor == 16711935) { 478 + hslBitset = -2; 479 + textureid = -1; 480 + rgbBitset = (Rasterizer3D.getRgbLookupTableId[mixLightnessSigned(floor.hslColor2, 96)]); 481 + } else { 482 + hslBitset = getHSLBitset(floor.hue2, floor.saturation, floor.lightness); 483 + rgbBitset = (Rasterizer3D.getRgbLookupTableId[mixLightnessSigned(floor.hslColor2, 96)]); 484 + } 485 + scene.renderTile(plane, x, y, clippingPath, clippingPathRotation, textureid, vertexSouthWest, vertexSouthEast, vertexNorthEast, 486 + vertexNorthWest, trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, 487 + lightNorthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthWest), mixLightnessSigned(hslBitset, lightSouthWest), 488 + mixLightnessSigned(hslBitset, lightSouthEast), mixLightnessSigned(hslBitset, lightNorthEast), 489 + mixLightnessSigned(hslBitset, lightNorthWest), rgbBitsetRandomized, rgbBitset); 490 + } 491 + } 492 + } 493 + } 494 + } 495 + } 496 + for (int i_104_ = 1; i_104_ < regionSizeY - 1; i_104_++) { 497 + for (int i_105_ = 1; i_105_ < regionSizeX - 1; i_105_++) 498 + scene.setTileLogicHeight(plane, i_105_, i_104_, getVisibilityPlaneFor(i_105_, i_104_, plane)); 499 + } 500 + } 501 + scene.shadeModels(-10, -50, -50); 502 + for (int y = 0; y < regionSizeX; y++) { 503 + for (int x = 0; x < regionSizeY; x++) { 504 + if ((renderRuleFlags[1][y][x] & 0x2) == 2) 505 + scene.setBridgeMode(y, x); 506 + } 507 + } 508 + int renderRule1 = 1; 509 + int renderRule2 = 2; 510 + int renderRule3 = 4; 511 + for (int currentPlane = 0; currentPlane < 4; currentPlane++) { 512 + if (currentPlane > 0) { 513 + renderRule1 <<= 3; 514 + renderRule2 <<= 3; 515 + renderRule3 <<= 3; 516 + } 517 + for (int plane = 0; plane <= currentPlane; plane++) { 518 + for (int y = 0; y <= regionSizeY; y++) { 519 + for (int x = 0; x <= regionSizeX; x++) { 520 + if ((tileCullingBitsets[plane][x][y] & renderRule1) != 0) { 521 + int lowestOcclussionY = y; 522 + int higestOcclussionY = y; 523 + int lowestOcclussionPlane = plane; 524 + int higestOcclussionPlane = plane; 525 + for (/**/; lowestOcclussionY > 0; lowestOcclussionY--) { 526 + if (((tileCullingBitsets[plane][x][lowestOcclussionY - 1]) & renderRule1) == 0) 527 + break; 528 + } 529 + for (/**/; higestOcclussionY < regionSizeY; higestOcclussionY++) { 530 + if (((tileCullingBitsets[plane][x][higestOcclussionY + 1]) & renderRule1) == 0) 531 + break; 532 + } 533 + while_0_: 534 + for (/**/; lowestOcclussionPlane > 0; lowestOcclussionPlane--) { 535 + for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) { 536 + if (((tileCullingBitsets[lowestOcclussionPlane - 1][x][occludedY]) & renderRule1) == 0) 537 + break while_0_; 538 + } 539 + } 540 + while_1_: 541 + for (/**/; higestOcclussionPlane < currentPlane; higestOcclussionPlane++) { 542 + for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) { 543 + if (((tileCullingBitsets[higestOcclussionPlane + 1][x][occludedY]) & renderRule1) == 0) 544 + break while_1_; 545 + } 546 + } 547 + int occlussionSurface = (higestOcclussionPlane + 1 - lowestOcclussionPlane) * (higestOcclussionY - lowestOcclussionY + 1); 548 + if (occlussionSurface >= 8) { 549 + int highestOcclussionVertexHeightOffset = 240; 550 + int highestOcclussionVertexHeight = ((vertexHeights[higestOcclussionPlane][x][lowestOcclussionY]) - highestOcclussionVertexHeightOffset); 551 + int lowestOcclussionVertexHeight = (vertexHeights[lowestOcclussionPlane][x][lowestOcclussionY]); 552 + Scene.createCullingCluster(currentPlane, x * 128, x * 128, higestOcclussionY * 128 + 128, lowestOcclussionY * 128, highestOcclussionVertexHeight, lowestOcclussionVertexHeight, 553 + 1); 554 + for (int occludedPlane = lowestOcclussionPlane; occludedPlane <= higestOcclussionPlane; occludedPlane++) { 555 + for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) 556 + tileCullingBitsets[occludedPlane][x][occludedY] &= renderRule1 ^ 0xffffffff; 557 + } 558 + } 559 + } 560 + if ((tileCullingBitsets[plane][x][y] & renderRule2) != 0) { 561 + int i_127_ = x; 562 + int i_128_ = x; 563 + int i_129_ = plane; 564 + int i_130_ = plane; 565 + for (/**/; i_127_ > 0; i_127_--) { 566 + if (((tileCullingBitsets[plane][i_127_ - 1][y]) & renderRule2) == 0) 567 + break; 568 + } 569 + for (/**/; i_128_ < regionSizeX; i_128_++) { 570 + if (((tileCullingBitsets[plane][i_128_ + 1][y]) & renderRule2) == 0) 571 + break; 572 + } 573 + while_2_: 574 + for (/**/; i_129_ > 0; i_129_--) { 575 + for (int i_131_ = i_127_; i_131_ <= i_128_; i_131_++) { 576 + if (((tileCullingBitsets[i_129_ - 1][i_131_][y]) & renderRule2) == 0) 577 + break while_2_; 578 + } 579 + } 580 + while_3_: 581 + for (/**/; i_130_ < currentPlane; i_130_++) { 582 + for (int i_132_ = i_127_; i_132_ <= i_128_; i_132_++) { 583 + if (((tileCullingBitsets[i_130_ + 1][i_132_][y]) & renderRule2) == 0) 584 + break while_3_; 585 + } 586 + } 587 + int i_133_ = (i_130_ + 1 - i_129_) * (i_128_ - i_127_ + 1); 588 + if (i_133_ >= 8) { 589 + int i_134_ = 240; 590 + int i_135_ = ((vertexHeights[i_130_][i_127_][y]) - i_134_); 591 + int i_136_ = (vertexHeights[i_129_][i_127_][y]); 592 + Scene.createCullingCluster(currentPlane, i_128_ * 128 + 128, i_127_ * 128, y * 128, y * 128, i_135_, i_136_, 593 + 2); 594 + for (int i_137_ = i_129_; i_137_ <= i_130_; i_137_++) { 595 + for (int i_138_ = i_127_; i_138_ <= i_128_; i_138_++) 596 + tileCullingBitsets[i_137_][i_138_][y] &= renderRule2 ^ 0xffffffff; 597 + } 598 + } 599 + } 600 + if ((tileCullingBitsets[plane][x][y] & renderRule3) != 0) { 601 + int i_139_ = x; 602 + int i_140_ = x; 603 + int i_141_ = y; 604 + int i_142_ = y; 605 + for (/**/; i_141_ > 0; i_141_--) { 606 + if (((tileCullingBitsets[plane][x][i_141_ - 1]) & renderRule3) == 0) 607 + break; 608 + } 609 + for (/**/; i_142_ < regionSizeY; i_142_++) { 610 + if (((tileCullingBitsets[plane][x][i_142_ + 1]) & renderRule3) == 0) 611 + break; 612 + } 613 + while_4_: 614 + for (/**/; i_139_ > 0; i_139_--) { 615 + for (int i_143_ = i_141_; i_143_ <= i_142_; i_143_++) { 616 + if (((tileCullingBitsets[plane][i_139_ - 1][i_143_]) & renderRule3) == 0) 617 + break while_4_; 618 + } 619 + } 620 + while_5_: 621 + for (/**/; i_140_ < regionSizeX; i_140_++) { 622 + for (int i_144_ = i_141_; i_144_ <= i_142_; i_144_++) { 623 + if (((tileCullingBitsets[plane][i_140_ + 1][i_144_]) & renderRule3) == 0) 624 + break while_5_; 625 + } 626 + } 627 + if ((i_140_ - i_139_ + 1) * (i_142_ - i_141_ + 1) >= 4) { 628 + int i_145_ = (vertexHeights[plane][i_139_][i_141_]); 629 + Scene.createCullingCluster(currentPlane, i_140_ * 128 + 128, i_139_ * 128, i_142_ * 128 + 128, i_141_ * 128, i_145_, i_145_, 630 + 4); 631 + for (int i_146_ = i_139_; i_146_ <= i_140_; i_146_++) { 632 + for (int i_147_ = i_141_; i_147_ <= i_142_; i_147_++) 633 + tileCullingBitsets[plane][i_146_][i_147_] &= renderRule3 ^ 0xffffffff; 634 + } 635 + } 636 + } 637 + } 638 + } 639 + } 640 + } 641 + } 646 642 647 - public void method168(int i, int i_148_, boolean bool, byte[] is, int i_149_, int i_150_, int i_151_, 643 + public void method168(int i, int i_148_, boolean bool, byte[] is, int i_149_, int i_150_, int i_151_, 648 644 CollisionMap[] class46s, int i_152_, int i_153_) { 649 - if (bool) 650 - anInt166 = 476; 651 - for (int i_154_ = 0; i_154_ < 8; i_154_++) { 652 - for (int i_155_ = 0; i_155_ < 8; i_155_++) { 653 - if (i_151_ + i_154_ > 0 && i_151_ + i_154_ < 103 && i_152_ + i_155_ > 0 && i_152_ + i_155_ < 103) 654 - class46s[i_149_].clippingData[i_151_ + i_154_][(i_152_ + i_155_)] &= ~0x1000000; 655 - } 656 - } 657 - Buffer class50_sub1_sub2 = new Buffer(is); 658 - for (int i_156_ = 0; i_156_ < 4; i_156_++) { 659 - for (int i_157_ = 0; i_157_ < 64; i_157_++) { 660 - for (int i_158_ = 0; i_158_ < 64; i_158_++) { 661 - if (i_156_ == i_150_ && i_157_ >= i_153_ && i_157_ < i_153_ + 8 && i_158_ >= i_148_ 662 - && i_158_ < i_148_ + 8) 663 - loadTerrainTile(i_151_ 664 - + TiledUtils.getRotatedMapChunkX(i_157_ & 0x7, i_158_ & 0x7, i), 0, i_152_ 665 - + TiledUtils.getRotatedMapChunkY(i_157_ & 0x7, i_158_ & 0x7, i), 0, i_149_, class50_sub1_sub2, i); 666 - else 667 - loadTerrainTile(-1, 0, -1, 0, 0, class50_sub1_sub2, 0); 668 - } 669 - } 670 - } 671 - } 645 + if (bool) 646 + anInt166 = 476; 647 + for (int i_154_ = 0; i_154_ < 8; i_154_++) { 648 + for (int i_155_ = 0; i_155_ < 8; i_155_++) { 649 + if (i_151_ + i_154_ > 0 && i_151_ + i_154_ < 103 && i_152_ + i_155_ > 0 && i_152_ + i_155_ < 103) 650 + class46s[i_149_].clippingData[i_151_ + i_154_][(i_152_ + i_155_)] &= ~0x1000000; 651 + } 652 + } 653 + Buffer class50_sub1_sub2 = new Buffer(is); 654 + for (int i_156_ = 0; i_156_ < 4; i_156_++) { 655 + for (int i_157_ = 0; i_157_ < 64; i_157_++) { 656 + for (int i_158_ = 0; i_158_ < 64; i_158_++) { 657 + if (i_156_ == i_150_ && i_157_ >= i_153_ && i_157_ < i_153_ + 8 && i_158_ >= i_148_ 658 + && i_158_ < i_148_ + 8) 659 + loadTerrainTile(i_151_ 660 + + TiledUtils.getRotatedMapChunkX(i_157_ & 0x7, i_158_ & 0x7, i), 0, i_152_ 661 + + TiledUtils.getRotatedMapChunkY(i_157_ & 0x7, i_158_ & 0x7, i), 0, i_149_, class50_sub1_sub2, i); 662 + else 663 + loadTerrainTile(-1, 0, -1, 0, 0, class50_sub1_sub2, 0); 664 + } 665 + } 666 + } 667 + } 672 668 673 - public static void passiveRequestGameObjectModels(OnDemandRequester onDemandRequester, Buffer buffer) { 669 + public static void passiveRequestGameObjectModels(OnDemandRequester onDemandRequester, Buffer buffer) { 674 670 675 - int gameObjectId = -1; 676 - while (true) { 677 - int gameObjectIdOffset = buffer.getSmart(); 678 - if (gameObjectIdOffset == 0) 679 - break; 680 - gameObjectId += gameObjectIdOffset; 681 - GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(gameObjectId); 682 - gameObjectDefinition.passiveRequestModels(onDemandRequester); 683 - while (true) { 684 - int terminate = buffer.getSmart(); 685 - if (terminate == 0) 686 - break; 687 - buffer.getUnsignedByte(); 688 - } 671 + int gameObjectId = -1; 672 + while (true) { 673 + int gameObjectIdOffset = buffer.getSmart(); 674 + if (gameObjectIdOffset == 0) 675 + break; 676 + gameObjectId += gameObjectIdOffset; 677 + GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(gameObjectId); 678 + gameObjectDefinition.passiveRequestModels(onDemandRequester); 679 + while (true) { 680 + int terminate = buffer.getSmart(); 681 + if (terminate == 0) 682 + break; 683 + buffer.getUnsignedByte(); 684 + } 689 685 690 - } 691 - } 686 + } 687 + } 692 688 693 - public static boolean method170(int i, byte i_162_, int i_163_) { 694 - GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(i_163_); 695 - if (i_162_ != aByte154) { 696 - for (int i_164_ = 1; i_164_ > 0; i_164_++) { 697 - /* empty */ 698 - } 699 - } 700 - if (i == 11) 701 - i = 10; 702 - if (i >= 5 && i <= 8) 703 - i = 4; 704 - return gameObjectDefinition.method432(26261, i); 705 - } 689 + public static boolean method170(int i, int i_163_) { 690 + GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(i_163_); 691 + if (i == 11) 692 + i = 10; 693 + if (i >= 5 && i <= 8) 694 + i = 4; 695 + return gameObjectDefinition.method432(26261, i); 696 + } 706 697 707 - public static int trimHSLLightness(int i, int i_165_) { 708 - if (i == -1) 709 - return 12345678; 710 - i_165_ = i_165_ * (i & 0x7f) / 128; 711 - if (i_165_ < 2) 712 - i_165_ = 2; 713 - else if (i_165_ > 126) 714 - i_165_ = 126; 715 - return (i & 0xff80) + i_165_; 716 - } 698 + public static int trimHSLLightness(int i, int i_165_) { 699 + if (i == -1) 700 + return 12345678; 701 + i_165_ = i_165_ * (i & 0x7f) / 128; 702 + if (i_165_ < 2) 703 + i_165_ = 2; 704 + else if (i_165_ > 126) 705 + i_165_ = 126; 706 + return (i & 0xff80) + i_165_; 707 + } 717 708 718 - public void method172(int i, CollisionMap[] class46s, Scene class22, boolean bool, byte[] is, int i_166_, int i_167_, 719 - int i_168_, int i_169_, int i_170_, int i_171_) { 720 - Buffer class50_sub1_sub2 = new Buffer(is); 721 - if (!bool) { 722 - int i_172_ = -1; 723 - for (;;) { 724 - int i_173_ = class50_sub1_sub2.getSmart(); 725 - if (i_173_ == 0) 726 - break; 727 - i_172_ += i_173_; 728 - int i_174_ = 0; 729 - for (;;) { 730 - int i_175_ = class50_sub1_sub2.getSmart(); 731 - if (i_175_ == 0) 732 - break; 733 - i_174_ += i_175_ - 1; 734 - int i_176_ = i_174_ & 0x3f; 735 - int i_177_ = i_174_ >> 6 & 0x3f; 736 - int i_178_ = i_174_ >> 12; 737 - int i_179_ = class50_sub1_sub2.getUnsignedByte(); 738 - int i_180_ = i_179_ >> 2; 739 - int i_181_ = i_179_ & 0x3; 740 - if (i_178_ == i_171_ && i_177_ >= i_168_ && i_177_ < i_168_ + 8 && i_176_ >= i_170_ 741 - && i_176_ < i_170_ + 8) { 742 - GameObjectDefinition class47 = GameObjectDefinition.getDefinition(i_172_); 743 - int i_182_ = (i_169_ + TiledUtils.getRotatedLandscapeChunkX(i_167_, class47.sizeY, i_177_ & 0x7, 744 - i_176_ & 0x7, class47.sizeX)); 745 - int i_183_ = (i_166_ + TiledUtils.getRotatedLandscapeChunkY(i_176_ & 0x7, class47.sizeY, i_167_, class47.sizeX, i_177_ & 0x7 746 - )); 747 - if (i_182_ > 0 && i_183_ > 0 && i_182_ < 103 && i_183_ < 103) { 748 - int i_184_ = i; 749 - if ((renderRuleFlags[1][i_182_][i_183_] & 0x2) == 2) 750 - i_184_--; 751 - CollisionMap class46 = null; 752 - if (i_184_ >= 0) 753 - class46 = class46s[i_184_]; 754 - renderObject(class22, class46, i_183_, i, i_182_, aByte139, i_181_ + i_167_ & 0x3, i_180_, 755 - i_172_); 756 - } 757 - } 758 - } 759 - } 760 - } 761 - } 709 + public void method172(int i, CollisionMap[] class46s, Scene class22, boolean bool, byte[] is, int i_166_, int i_167_, 710 + int i_168_, int i_169_, int i_170_, int i_171_) { 711 + Buffer class50_sub1_sub2 = new Buffer(is); 712 + if (!bool) { 713 + int i_172_ = -1; 714 + for (; ; ) { 715 + int i_173_ = class50_sub1_sub2.getSmart(); 716 + if (i_173_ == 0) 717 + break; 718 + i_172_ += i_173_; 719 + int i_174_ = 0; 720 + for (; ; ) { 721 + int i_175_ = class50_sub1_sub2.getSmart(); 722 + if (i_175_ == 0) 723 + break; 724 + i_174_ += i_175_ - 1; 725 + int i_176_ = i_174_ & 0x3f; 726 + int i_177_ = i_174_ >> 6 & 0x3f; 727 + int i_178_ = i_174_ >> 12; 728 + int i_179_ = class50_sub1_sub2.getUnsignedByte(); 729 + int i_180_ = i_179_ >> 2; 730 + int i_181_ = i_179_ & 0x3; 731 + if (i_178_ == i_171_ && i_177_ >= i_168_ && i_177_ < i_168_ + 8 && i_176_ >= i_170_ 732 + && i_176_ < i_170_ + 8) { 733 + GameObjectDefinition class47 = GameObjectDefinition.getDefinition(i_172_); 734 + int i_182_ = (i_169_ + TiledUtils.getRotatedLandscapeChunkX(i_167_, class47.sizeY, i_177_ & 0x7, 735 + i_176_ & 0x7, class47.sizeX)); 736 + int i_183_ = (i_166_ + TiledUtils.getRotatedLandscapeChunkY(i_176_ & 0x7, class47.sizeY, i_167_, class47.sizeX, i_177_ & 0x7 737 + )); 738 + if (i_182_ > 0 && i_183_ > 0 && i_182_ < 103 && i_183_ < 103) { 739 + int i_184_ = i; 740 + if ((renderRuleFlags[1][i_182_][i_183_] & 0x2) == 2) 741 + i_184_--; 742 + CollisionMap class46 = null; 743 + if (i_184_ >= 0) 744 + class46 = class46s[i_184_]; 745 + renderObject(class22, class46, i_183_, i, i_182_, i_181_ + i_167_ & 0x3, i_180_, 746 + i_172_); 747 + } 748 + } 749 + } 750 + } 751 + } 752 + } 762 753 763 - public void renderObject(Scene scene, CollisionMap collisionMap, int y, int plane, int x, byte i_187_, int face, 764 - int type, int objectId) { 765 - if (!lowMemory 766 - || (renderRuleFlags[0][x][y] & 0x2) != 0 767 - || ((renderRuleFlags[plane][x][y] & 0x10) == 0 && getVisibilityPlaneFor(y, plane, x, (byte) 0) == onBuildTimePlane)) { 768 - if (plane < lowestPlane) 769 - lowestPlane = plane; 770 - int vertexHeight = vertexHeights[plane][x][y]; 771 - int vertexHeightRight = vertexHeights[plane][x + 1][y]; 772 - int vertexHeightTopRight = vertexHeights[plane][x + 1][y + 1]; 773 - int vertexHeightTop = vertexHeights[plane][x][y + 1]; 774 - int vertexMix = vertexHeight + vertexHeightRight + vertexHeightTopRight + vertexHeightTop >> 2; 775 - GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(objectId); 776 - int hash = x + (y << 7) + (objectId << 14) + 1073741824; 777 - if (!gameObjectDefinition.actionsBoolean) 778 - hash += -2147483648; 779 - byte objectConfig = (byte) ((face << 6) + type); 780 - if (type == 22) { 781 - if (!lowMemory || gameObjectDefinition.actionsBoolean || gameObjectDefinition.unknown) { 782 - Renderable renderable; 783 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 784 - renderable = gameObjectDefinition.getGameObjectModel(22, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 785 - else 786 - renderable = new GameObject(objectId, face, 22, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 754 + public void renderObject(Scene scene, CollisionMap collisionMap, int y, int plane, int x, int face, 755 + int type, int objectId) { 756 + if (!lowMemory 757 + || (renderRuleFlags[0][x][y] & 0x2) != 0 758 + || ((renderRuleFlags[plane][x][y] & 0x10) == 0 && getVisibilityPlaneFor(x, y, plane) == onBuildTimePlane)) { 759 + if (plane < lowestPlane) 760 + lowestPlane = plane; 761 + int vertexHeight = vertexHeights[plane][x][y]; 762 + int vertexHeightRight = vertexHeights[plane][x + 1][y]; 763 + int vertexHeightTopRight = vertexHeights[plane][x + 1][y + 1]; 764 + int vertexHeightTop = vertexHeights[plane][x][y + 1]; 765 + int vertexMix = vertexHeight + vertexHeightRight + vertexHeightTopRight + vertexHeightTop >> 2; 766 + GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(objectId); 767 + int hash = x + (y << 7) + (objectId << 14) + 1073741824; 768 + if (!gameObjectDefinition.hasActions) 769 + hash += -2147483648; 770 + byte objectConfig = (byte) ((face << 6) + type); 771 + if (type == 22) { 772 + if (!lowMemory || gameObjectDefinition.hasActions || gameObjectDefinition.unknown) { 773 + Renderable renderable; 774 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 775 + renderable = gameObjectDefinition.getGameObjectModel(22, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 776 + else 777 + renderable = new GameObject(objectId, face, 22, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 787 778 true); 788 - scene.addGroundDecoration(x, y, plane, vertexMix, hash, renderable, objectConfig); 789 - if (gameObjectDefinition.solid && gameObjectDefinition.actionsBoolean && collisionMap != null) 790 - collisionMap.markBlocked(x, y); 791 - } 792 - } else if (type == 10 || type == 11) { 793 - Renderable renderable; 794 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 795 - renderable = gameObjectDefinition.getGameObjectModel(10, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 796 - else 797 - renderable = new GameObject(objectId, face, 10, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 779 + scene.addGroundDecoration(x, y, plane, vertexMix, hash, renderable, objectConfig); 780 + if (gameObjectDefinition.solid && gameObjectDefinition.hasActions && collisionMap != null) 781 + collisionMap.markBlocked(x, y); 782 + } 783 + } else if (type == 10 || type == 11) { 784 + Renderable renderable; 785 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 786 + renderable = gameObjectDefinition.getGameObjectModel(10, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 787 + else 788 + renderable = new GameObject(objectId, face, 10, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 798 789 true); 799 - if (renderable != null) { 800 - int i_198_ = 0; 801 - if (type == 11) 802 - i_198_ += 256; 803 - int sizeX; 804 - int sizeY; 805 - if (face == 1 || face == 3) { 806 - sizeX = gameObjectDefinition.sizeY; 807 - sizeY = gameObjectDefinition.sizeX; 808 - } else { 809 - sizeX = gameObjectDefinition.sizeX; 810 - sizeY = gameObjectDefinition.sizeY; 811 - } 812 - if (scene.addEntityB(x, y, plane, vertexMix, i_198_, sizeY, sizeX, hash, renderable, objectConfig 813 - ) 814 - && gameObjectDefinition.unknown2) { 815 - Model model; 816 - if (renderable instanceof Model) 817 - model = (Model) renderable; 818 - else 819 - model = gameObjectDefinition.getGameObjectModel(10, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 820 - if (model != null) { 821 - for (int sizeXCounter = 0; sizeXCounter <= sizeX; sizeXCounter++) { 822 - for (int sizeYCounter = 0; sizeYCounter <= sizeY; sizeYCounter++) { 823 - int shadowIntensity = model.diagonal2DAboveOrigin / 4; 824 - if (shadowIntensity > 30) 825 - shadowIntensity = 30; 826 - if (shadowIntensity > (tileShadowIntensity[plane][x + sizeXCounter][y + sizeYCounter])) 827 - tileShadowIntensity[plane][x + sizeXCounter][y + sizeYCounter] = (byte) shadowIntensity; 828 - } 829 - } 830 - } 831 - } 832 - } 833 - if (gameObjectDefinition.solid && collisionMap != null) 834 - collisionMap.method413(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x, 835 - (byte) 52); 836 - } else if (type >= 12) { 837 - Renderable renderable; 838 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 839 - renderable = gameObjectDefinition.getGameObjectModel(type, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 840 - else 841 - renderable = new GameObject(objectId, face, type, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 790 + if (renderable != null) { 791 + int i_198_ = 0; 792 + if (type == 11) 793 + i_198_ += 256; 794 + int sizeX; 795 + int sizeY; 796 + if (face == 1 || face == 3) { 797 + sizeX = gameObjectDefinition.sizeY; 798 + sizeY = gameObjectDefinition.sizeX; 799 + } else { 800 + sizeX = gameObjectDefinition.sizeX; 801 + sizeY = gameObjectDefinition.sizeY; 802 + } 803 + if (scene.addEntityB(x, y, plane, vertexMix, i_198_, sizeY, sizeX, hash, renderable, objectConfig 804 + ) 805 + && gameObjectDefinition.castsShadow) { 806 + Model model; 807 + if (renderable instanceof Model) 808 + model = (Model) renderable; 809 + else 810 + model = gameObjectDefinition.getGameObjectModel(10, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 811 + if (model != null) { 812 + for (int sizeXCounter = 0; sizeXCounter <= sizeX; sizeXCounter++) { 813 + for (int sizeYCounter = 0; sizeYCounter <= sizeY; sizeYCounter++) { 814 + int shadowIntensity = model.diagonal2DAboveOrigin / 4; 815 + if (shadowIntensity > 30) 816 + shadowIntensity = 30; 817 + if (shadowIntensity > (tileShadowIntensity[plane][x + sizeXCounter][y + sizeYCounter])) 818 + tileShadowIntensity[plane][x + sizeXCounter][y + sizeYCounter] = (byte) shadowIntensity; 819 + } 820 + } 821 + } 822 + } 823 + } 824 + if (gameObjectDefinition.solid && collisionMap != null) 825 + collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x, 826 + (byte) 52); 827 + } else if (type >= 12) { 828 + Renderable renderable; 829 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 830 + renderable = gameObjectDefinition.getGameObjectModel(type, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 831 + else 832 + renderable = new GameObject(objectId, face, type, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 842 833 true); 843 - scene.addEntityB(x, y, plane, vertexMix, 0, 1, 1, hash, renderable, objectConfig); 844 - if (type >= 12 && type <= 17 && type != 13 && plane > 0) 845 - tileCullingBitsets[plane][x][y] |= 0x924; 846 - if (gameObjectDefinition.solid && collisionMap != null) 847 - collisionMap.method413(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x, 848 - (byte) 52); 849 - } else if (type == 0) { 850 - Renderable renderable; 851 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 852 - renderable = gameObjectDefinition.getGameObjectModel(0, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 853 - else 854 - renderable = new GameObject(objectId, face, 0, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 834 + scene.addEntityB(x, y, plane, vertexMix, 0, 1, 1, hash, renderable, objectConfig); 835 + if (type >= 12 && type <= 17 && type != 13 && plane > 0) 836 + tileCullingBitsets[plane][x][y] |= 0x924; 837 + if (gameObjectDefinition.solid && collisionMap != null) 838 + collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x, 839 + (byte) 52); 840 + } else if (type == 0) { 841 + Renderable renderable; 842 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 843 + renderable = gameObjectDefinition.getGameObjectModel(0, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 844 + else 845 + renderable = new GameObject(objectId, face, 0, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 855 846 true); 856 - scene.addWall(x, y, plane, vertexMix, anIntArray158[face], 0, hash, renderable, null, objectConfig 857 - ); 858 - if (face == 0) { 859 - if (gameObjectDefinition.unknown2) { 860 - tileShadowIntensity[plane][x][y] = (byte) 50; 861 - tileShadowIntensity[plane][x][y + 1] = (byte) 50; 862 - } 863 - if (gameObjectDefinition.aBoolean797) 864 - tileCullingBitsets[plane][x][y] |= 0x249; 865 - } else if (face == 1) { 866 - if (gameObjectDefinition.unknown2) { 867 - tileShadowIntensity[plane][x][y + 1] = (byte) 50; 868 - tileShadowIntensity[plane][x + 1][y + 1] = (byte) 50; 869 - } 870 - if (gameObjectDefinition.aBoolean797) 871 - tileCullingBitsets[plane][x][y + 1] |= 0x492; 872 - } else if (face == 2) { 873 - if (gameObjectDefinition.unknown2) { 874 - tileShadowIntensity[plane][x + 1][y] = (byte) 50; 875 - tileShadowIntensity[plane][x + 1][y + 1] = (byte) 50; 876 - } 877 - if (gameObjectDefinition.aBoolean797) 878 - tileCullingBitsets[plane][x + 1][y] |= 0x249; 879 - } else if (face == 3) { 880 - if (gameObjectDefinition.unknown2) { 881 - tileShadowIntensity[plane][x][y] = (byte) 50; 882 - tileShadowIntensity[plane][x + 1][y] = (byte) 50; 883 - } 884 - if (gameObjectDefinition.aBoolean797) 885 - tileCullingBitsets[plane][x][y] |= 0x492; 886 - } 887 - if (gameObjectDefinition.solid && collisionMap != null) 888 - collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 889 - if (gameObjectDefinition.unknown4 != 16) 890 - scene.displaceWallDecoration(x, y, plane, gameObjectDefinition.unknown4); 891 - } else if (type == 1) { 892 - Renderable renderable; 893 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 894 - renderable = gameObjectDefinition.getGameObjectModel(1, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 895 - else 896 - renderable = new GameObject(objectId, face, 1, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 847 + scene.addWall(x, y, plane, vertexMix, POWERS_OF_TWO[face], 0, hash, renderable, null, objectConfig 848 + ); 849 + if (face == 0) { 850 + if (gameObjectDefinition.castsShadow) { 851 + tileShadowIntensity[plane][x][y] = (byte) 50; 852 + tileShadowIntensity[plane][x][y + 1] = (byte) 50; 853 + } 854 + if (gameObjectDefinition.wall) 855 + tileCullingBitsets[plane][x][y] |= 0x249; 856 + } else if (face == 1) { 857 + if (gameObjectDefinition.castsShadow) { 858 + tileShadowIntensity[plane][x][y + 1] = (byte) 50; 859 + tileShadowIntensity[plane][x + 1][y + 1] = (byte) 50; 860 + } 861 + if (gameObjectDefinition.wall) 862 + tileCullingBitsets[plane][x][y + 1] |= 0x492; 863 + } else if (face == 2) { 864 + if (gameObjectDefinition.castsShadow) { 865 + tileShadowIntensity[plane][x + 1][y] = (byte) 50; 866 + tileShadowIntensity[plane][x + 1][y + 1] = (byte) 50; 867 + } 868 + if (gameObjectDefinition.wall) 869 + tileCullingBitsets[plane][x + 1][y] |= 0x249; 870 + } else if (face == 3) { 871 + if (gameObjectDefinition.castsShadow) { 872 + tileShadowIntensity[plane][x][y] = (byte) 50; 873 + tileShadowIntensity[plane][x + 1][y] = (byte) 50; 874 + } 875 + if (gameObjectDefinition.wall) 876 + tileCullingBitsets[plane][x][y] |= 0x492; 877 + } 878 + if (gameObjectDefinition.solid && collisionMap != null) 879 + collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 880 + if (gameObjectDefinition.offsetAmplifier != 16) 881 + scene.displaceWallDecoration(x, y, plane, gameObjectDefinition.offsetAmplifier); 882 + } else if (type == 1) { 883 + Renderable renderable; 884 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 885 + renderable = gameObjectDefinition.getGameObjectModel(1, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 886 + else 887 + renderable = new GameObject(objectId, face, 1, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 897 888 true); 898 - scene.addWall(x, y, plane, vertexMix, anIntArray167[face], 0, hash, renderable, null, objectConfig 899 - ); 900 - if (gameObjectDefinition.unknown2) { 901 - if (face == 0) 902 - tileShadowIntensity[plane][x][y + 1] = (byte) 50; 903 - else if (face == 1) 904 - tileShadowIntensity[plane][x + 1][y + 1] = (byte) 50; 905 - else if (face == 2) 906 - tileShadowIntensity[plane][x + 1][y] = (byte) 50; 907 - else if (face == 3) 908 - tileShadowIntensity[plane][x][y] = (byte) 50; 909 - } 910 - if (gameObjectDefinition.solid && collisionMap != null) 911 - collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 912 - } else if (type == 2) { 913 - int i_204_ = face + 1 & 0x3; 914 - Renderable renderable; 915 - Renderable renderable1; 916 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) { 917 - renderable = gameObjectDefinition.getGameObjectModel(2, 4 + face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 918 - renderable1 = gameObjectDefinition.getGameObjectModel(2, i_204_, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 919 - } else { 920 - renderable = new GameObject(objectId, 4 + face, 2, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 889 + scene.addWall(x, y, plane, vertexMix, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, objectConfig 890 + ); 891 + if (gameObjectDefinition.castsShadow) { 892 + if (face == 0) 893 + tileShadowIntensity[plane][x][y + 1] = (byte) 50; 894 + else if (face == 1) 895 + tileShadowIntensity[plane][x + 1][y + 1] = (byte) 50; 896 + else if (face == 2) 897 + tileShadowIntensity[plane][x + 1][y] = (byte) 50; 898 + else if (face == 3) 899 + tileShadowIntensity[plane][x][y] = (byte) 50; 900 + } 901 + if (gameObjectDefinition.solid && collisionMap != null) 902 + collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 903 + } else if (type == 2) { 904 + int i_204_ = face + 1 & 0x3; 905 + Renderable renderable; 906 + Renderable renderable1; 907 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) { 908 + renderable = gameObjectDefinition.getGameObjectModel(2, 4 + face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 909 + renderable1 = gameObjectDefinition.getGameObjectModel(2, i_204_, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 910 + } else { 911 + renderable = new GameObject(objectId, 4 + face, 2, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 921 912 true); 922 - renderable1 = new GameObject(objectId, i_204_, 2, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 913 + renderable1 = new GameObject(objectId, i_204_, 2, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 923 914 true); 924 - } 925 - scene.addWall(x, y, plane, vertexMix, anIntArray158[face], anIntArray158[i_204_], hash, renderable, renderable1, objectConfig 926 - ); 927 - if (gameObjectDefinition.aBoolean797) { 928 - if (face == 0) { 929 - tileCullingBitsets[plane][x][y] |= 0x249; 930 - tileCullingBitsets[plane][x][y + 1] |= 0x492; 931 - } else if (face == 1) { 932 - tileCullingBitsets[plane][x][y + 1] |= 0x492; 933 - tileCullingBitsets[plane][x + 1][y] |= 0x249; 934 - } else if (face == 2) { 935 - tileCullingBitsets[plane][x + 1][y] |= 0x249; 936 - tileCullingBitsets[plane][x][y] |= 0x492; 937 - } else if (face == 3) { 938 - tileCullingBitsets[plane][x][y] |= 0x492; 939 - tileCullingBitsets[plane][x][y] |= 0x249; 940 - } 941 - } 942 - if (gameObjectDefinition.solid && collisionMap != null) 943 - collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 944 - if (gameObjectDefinition.unknown4 != 16) 945 - scene.displaceWallDecoration(x, y, plane, gameObjectDefinition.unknown4); 946 - } else if (type == 3) { 947 - Renderable renderable; 948 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 949 - renderable = gameObjectDefinition.getGameObjectModel(3, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 950 - else 951 - renderable = new GameObject(objectId, face, 3, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 915 + } 916 + scene.addWall(x, y, plane, vertexMix, POWERS_OF_TWO[face], POWERS_OF_TWO[i_204_], hash, renderable, renderable1, objectConfig 917 + ); 918 + if (gameObjectDefinition.wall) { 919 + if (face == 0) { 920 + tileCullingBitsets[plane][x][y] |= 0x249; 921 + tileCullingBitsets[plane][x][y + 1] |= 0x492; 922 + } else if (face == 1) { 923 + tileCullingBitsets[plane][x][y + 1] |= 0x492; 924 + tileCullingBitsets[plane][x + 1][y] |= 0x249; 925 + } else if (face == 2) { 926 + tileCullingBitsets[plane][x + 1][y] |= 0x249; 927 + tileCullingBitsets[plane][x][y] |= 0x492; 928 + } else if (face == 3) { 929 + tileCullingBitsets[plane][x][y] |= 0x492; 930 + tileCullingBitsets[plane][x][y] |= 0x249; 931 + } 932 + } 933 + if (gameObjectDefinition.solid && collisionMap != null) 934 + collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 935 + if (gameObjectDefinition.offsetAmplifier != 16) 936 + scene.displaceWallDecoration(x, y, plane, gameObjectDefinition.offsetAmplifier); 937 + } else if (type == 3) { 938 + Renderable renderable; 939 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 940 + renderable = gameObjectDefinition.getGameObjectModel(3, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 941 + else 942 + renderable = new GameObject(objectId, face, 3, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 952 943 true); 953 - scene.addWall(x, y, plane, vertexMix, anIntArray167[face], 0, hash, renderable, null, objectConfig 954 - ); 955 - if (gameObjectDefinition.unknown2) { 956 - if (face == 0) 957 - tileShadowIntensity[plane][x][y + 1] = (byte) 50; 958 - else if (face == 1) 959 - tileShadowIntensity[plane][x + 1][y + 1] = (byte) 50; 960 - else if (face == 2) 961 - tileShadowIntensity[plane][x + 1][y] = (byte) 50; 962 - else if (face == 3) 963 - tileShadowIntensity[plane][x][y] = (byte) 50; 964 - } 965 - if (gameObjectDefinition.solid && collisionMap != null) 966 - collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 967 - } else if (type == 9) { 968 - Renderable renderable; 969 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 970 - renderable = gameObjectDefinition.getGameObjectModel(type, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 971 - else 972 - renderable = new GameObject(objectId, face, type, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 944 + scene.addWall(x, y, plane, vertexMix, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, objectConfig 945 + ); 946 + if (gameObjectDefinition.castsShadow) { 947 + if (face == 0) 948 + tileShadowIntensity[plane][x][y + 1] = (byte) 50; 949 + else if (face == 1) 950 + tileShadowIntensity[plane][x + 1][y + 1] = (byte) 50; 951 + else if (face == 2) 952 + tileShadowIntensity[plane][x + 1][y] = (byte) 50; 953 + else if (face == 3) 954 + tileShadowIntensity[plane][x][y] = (byte) 50; 955 + } 956 + if (gameObjectDefinition.solid && collisionMap != null) 957 + collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 958 + } else if (type == 9) { 959 + Renderable renderable; 960 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 961 + renderable = gameObjectDefinition.getGameObjectModel(type, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 962 + else 963 + renderable = new GameObject(objectId, face, type, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 973 964 true); 974 - scene.addEntityB(x, y, plane, vertexMix, 0, 1, 1, hash, renderable, objectConfig); 975 - if (gameObjectDefinition.solid && collisionMap != null) 976 - collisionMap.method413(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x, 977 - (byte) 52); 978 - } else { 979 - if (gameObjectDefinition.adjustToTerrain) { 980 - if (face == 1) { 981 - int i_206_ = vertexHeightTop; 982 - vertexHeightTop = vertexHeightTopRight; 983 - vertexHeightTopRight = vertexHeightRight; 984 - vertexHeightRight = vertexHeight; 985 - vertexHeight = i_206_; 986 - } else if (face == 2) { 987 - int i_207_ = vertexHeightTop; 988 - vertexHeightTop = vertexHeightRight; 989 - vertexHeightRight = i_207_; 990 - i_207_ = vertexHeightTopRight; 991 - vertexHeightTopRight = vertexHeight; 992 - vertexHeight = i_207_; 993 - } else if (face == 3) { 994 - int i_208_ = vertexHeightTop; 995 - vertexHeightTop = vertexHeight; 996 - vertexHeight = vertexHeightRight; 997 - vertexHeightRight = vertexHeightTopRight; 998 - vertexHeightTopRight = i_208_; 999 - } 1000 - } 1001 - if (type == 4) { 1002 - Renderable renderable; 1003 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1004 - renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1005 - else 1006 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 965 + scene.addEntityB(x, y, plane, vertexMix, 0, 1, 1, hash, renderable, objectConfig); 966 + if (gameObjectDefinition.solid && collisionMap != null) 967 + collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x, 968 + (byte) 52); 969 + } else { 970 + if (gameObjectDefinition.adjustToTerrain) { 971 + if (face == 1) { 972 + int temp = vertexHeightTop; 973 + vertexHeightTop = vertexHeightTopRight; 974 + vertexHeightTopRight = vertexHeightRight; 975 + vertexHeightRight = vertexHeight; 976 + vertexHeight = temp; 977 + } else if (face == 2) { 978 + int temp = vertexHeightTop; 979 + vertexHeightTop = vertexHeightRight; 980 + vertexHeightRight = temp; 981 + temp = vertexHeightTopRight; 982 + vertexHeightTopRight = vertexHeight; 983 + vertexHeight = temp; 984 + } else if (face == 3) { 985 + int temp = vertexHeightTop; 986 + vertexHeightTop = vertexHeight; 987 + vertexHeight = vertexHeightRight; 988 + vertexHeightRight = vertexHeightTopRight; 989 + vertexHeightTopRight = temp; 990 + } 991 + } 992 + if (type == 4) { 993 + Renderable renderable; 994 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 995 + renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 996 + else 997 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1007 998 true); 1008 - scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face * 512, hash, renderable, objectConfig, anIntArray158[face] 1009 - ); 1010 - } else if (type == 5) { 1011 - int offset = 16; 1012 - int i_210_ = scene.method267(plane, x, y); 1013 - if (i_210_ > 0) 1014 - offset = GameObjectDefinition.getDefinition(i_210_ >> 14 & 0x7fff).unknown4; 1015 - Renderable renderable; 1016 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1017 - renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1018 - else 1019 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 999 + scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face * 512, hash, renderable, objectConfig, POWERS_OF_TWO[face] 1000 + ); 1001 + } else if (type == 5) { 1002 + int offset = 16; 1003 + int i_210_ = scene.getWallObjectHash(x, y, plane); 1004 + if (i_210_ > 0) 1005 + offset = GameObjectDefinition.getDefinition(i_210_ >> 14 & 0x7fff).offsetAmplifier; 1006 + Renderable renderable; 1007 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1008 + renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1009 + else 1010 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1020 1011 true); 1021 - scene.addWallDecoration(x, y, plane, vertexMix, anIntArray161[face] * offset, anIntArray143[face] * offset, face * 512, hash, renderable, objectConfig, anIntArray158[face] 1022 - ); 1023 - } else if (type == 6) { 1024 - Renderable renderable; 1025 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1026 - renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1027 - else 1028 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1012 + scene.addWallDecoration(x, y, plane, vertexMix, FACE_OFFSET_X[face] * offset, FACE_OFFSET_Y[face] * offset, face * 512, hash, renderable, objectConfig, POWERS_OF_TWO[face] 1013 + ); 1014 + } else if (type == 6) { 1015 + Renderable renderable; 1016 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1017 + renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1018 + else 1019 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1029 1020 true); 1030 - scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 256 1031 - ); 1032 - } else if (type == 7) { 1033 - Renderable renderable; 1034 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1035 - renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1036 - else 1037 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1021 + scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 256 1022 + ); 1023 + } else if (type == 7) { 1024 + Renderable renderable; 1025 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1026 + renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1027 + else 1028 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1038 1029 true); 1039 - scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 512 1040 - ); 1041 - } else if (type == 8) { 1042 - Renderable renderable; 1043 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1044 - renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1045 - else 1046 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1030 + scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 512 1031 + ); 1032 + } else if (type == 8) { 1033 + Renderable renderable; 1034 + if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1035 + renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1036 + else 1037 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1047 1038 true); 1048 - scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 768 1049 - ); 1050 - } 1051 - } 1052 - } 1053 - } 1039 + scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 768 1040 + ); 1041 + } 1042 + } 1043 + } 1044 + } 1054 1045 1055 - public void loadTerrainBlock(int blockX, int offsetX, int blockY, int offsetY, byte[] blockData, CollisionMap[] collisionMap) { 1056 - for (int plane = 0; plane < 4; plane++) { 1057 - for (int tileX = 0; tileX < 64; tileX++) { 1058 - for (int tileY = 0; tileY < 64; tileY++) { 1059 - if (blockX + tileX > 0 && blockX + tileX < 103 && blockY + tileY > 0 && blockY + tileY < 103) 1060 - collisionMap[plane].clippingData[blockX + tileX][blockY + tileY] &= ~0x1000000; 1061 - } 1062 - } 1063 - } 1064 - Buffer stream = new Buffer(blockData); 1065 - for (int plane = 0; plane < 4; plane++) { 1066 - for (int tileX = 0; tileX < 64; tileX++) { 1067 - for (int tileY = 0; tileY < 64; tileY++) 1068 - loadTerrainTile(tileX + blockX, offsetX, tileY + blockY, offsetY, plane, stream, 0); 1069 - } 1070 - } 1071 - } 1046 + public void loadTerrainBlock(int blockX, int offsetX, int blockY, int offsetY, byte[] blockData, CollisionMap[] collisionMap) { 1047 + for (int plane = 0; plane < 4; plane++) { 1048 + for (int tileX = 0; tileX < 64; tileX++) { 1049 + for (int tileY = 0; tileY < 64; tileY++) { 1050 + if (blockX + tileX > 0 && blockX + tileX < 103 && blockY + tileY > 0 && blockY + tileY < 103) 1051 + collisionMap[plane].clippingData[blockX + tileX][blockY + tileY] &= ~0x1000000; 1052 + } 1053 + } 1054 + } 1055 + Buffer stream = new Buffer(blockData); 1056 + for (int plane = 0; plane < 4; plane++) { 1057 + for (int tileX = 0; tileX < 64; tileX++) { 1058 + for (int tileY = 0; tileY < 64; tileY++) 1059 + loadTerrainTile(tileX + blockX, offsetX, tileY + blockY, offsetY, plane, stream, 0); 1060 + } 1061 + } 1062 + } 1072 1063 1073 1064 1065 + public static int interpolate(int a, int b, int delta, int deltaScale) { 1066 + int f = (65536 - Rasterizer3D.COSINE[delta * 1024 / deltaScale] >> 1); 1067 + return (a * (65536 - f) >> 16) + (b * f >> 16); 1068 + } 1074 1069 1075 - 1076 - 1077 - public static int method176(int i, int i_226_, int i_227_, int i_228_) { 1078 - int i_229_ = (65536 - Rasterizer3D.COSINE[i_227_ * 1024 / i_228_] >> 1); 1079 - return (i * (65536 - i_229_) >> 16) + (i_226_ * i_229_ >> 16); 1080 - } 1070 + public int getHSLBitset(int h, int s, int l) { 1071 + if (l > 179) 1072 + s /= 2; 1073 + if (l > 192) 1074 + s /= 2; 1075 + if (l > 217) 1076 + s /= 2; 1077 + if (l > 243) 1078 + s /= 2; 1079 + return (h / 4 << 10) + (s / 32 << 7) + l / 2; 1080 + } 1081 1081 1082 - public int getHSLBitset(int i, int i_230_, int i_231_) { 1083 - if (i_231_ > 179) 1084 - i_230_ /= 2; 1085 - if (i_231_ > 192) 1086 - i_230_ /= 2; 1087 - if (i_231_ > 217) 1088 - i_230_ /= 2; 1089 - if (i_231_ > 243) 1090 - i_230_ /= 2; 1091 - int i_232_ = (i / 4 << 10) + (i_230_ / 32 << 7) + i_231_ / 2; 1092 - return i_232_; 1093 - } 1082 + public static int randomNoiseWeighedSum(int x, int y) { 1083 + int vDist2 = (calculateNoise(x - 1, y - 1) + calculateNoise(x + 1, y - 1) + calculateNoise(x - 1, y + 1) + calculateNoise( 1084 + x + 1, y + 1)); 1085 + int vDist1 = (calculateNoise(x - 1, y) + calculateNoise(x + 1, y) + calculateNoise(x, y - 1) + calculateNoise(x, 1086 + y + 1)); 1087 + int vLocal = calculateNoise(x, y); 1088 + return vDist2 / 16 + vDist1 / 8 + vLocal / 4; 1089 + } 1094 1090 1095 - public static int method178(int i, int i_233_) { 1096 - int i_234_ = (calculateNoise(i - 1, i_233_ - 1) + calculateNoise(i + 1, i_233_ - 1) + calculateNoise(i - 1, i_233_ + 1) + calculateNoise( 1097 - i + 1, i_233_ + 1)); 1098 - int i_235_ = (calculateNoise(i - 1, i_233_) + calculateNoise(i + 1, i_233_) + calculateNoise(i, i_233_ - 1) + calculateNoise(i, 1099 - i_233_ + 1)); 1100 - int i_236_ = calculateNoise(i, i_233_); 1101 - return i_234_ / 16 + i_235_ / 8 + i_236_ / 4; 1102 - } 1103 - 1104 - public void method179(int i, CollisionMap[] class46s, int i_237_, int i_238_, Scene class22, byte[] is) { 1105 - if (i_238_ < 0) { 1106 - Buffer class50_sub1_sub2 = new Buffer(is); 1107 - int i_239_ = -1; 1108 - for (;;) { 1109 - int i_240_ = class50_sub1_sub2.getSmart(); 1110 - if (i_240_ == 0) 1111 - break; 1112 - i_239_ += i_240_; 1113 - int i_241_ = 0; 1114 - for (;;) { 1115 - int i_242_ = class50_sub1_sub2.getSmart(); 1116 - if (i_242_ == 0) 1117 - break; 1118 - i_241_ += i_242_ - 1; 1119 - int i_243_ = i_241_ & 0x3f; 1120 - int i_244_ = i_241_ >> 6 & 0x3f; 1121 - int i_245_ = i_241_ >> 12; 1122 - int i_246_ = class50_sub1_sub2.getUnsignedByte(); 1123 - int i_247_ = i_246_ >> 2; 1124 - int i_248_ = i_246_ & 0x3; 1125 - int i_249_ = i_244_ + i_237_; 1126 - int i_250_ = i_243_ + i; 1127 - if (i_249_ > 0 && i_250_ > 0 && i_249_ < 103 && i_250_ < 103) { 1128 - int i_251_ = i_245_; 1129 - if ((renderRuleFlags[1][i_249_][i_250_] & 0x2) == 2) 1130 - i_251_--; 1131 - CollisionMap class46 = null; 1132 - if (i_251_ >= 0) 1133 - class46 = class46s[i_251_]; 1134 - renderObject(class22, class46, i_250_, i_245_, i_249_, aByte139, i_248_, i_247_, i_239_); 1135 - } 1136 - } 1137 - } 1138 - } 1139 - } 1091 + public void loadObjectBlock(int blockX, int blockY, CollisionMap[] collisionMap, Scene scene, byte[] blockData) { 1092 + Buffer stream = new Buffer(blockData); 1093 + int objectId = -1; 1094 + while (true) { 1095 + int objectIdOffset = stream.getSmart(); 1096 + if (objectIdOffset == 0) 1097 + break; 1098 + objectId += objectIdOffset; 1099 + int position = 0; 1100 + while (true) { 1101 + int positionOffset = stream.getSmart(); 1102 + if (positionOffset == 0) 1103 + break; 1104 + position += positionOffset - 1; 1105 + int tileY = position & 0x3f; 1106 + int tileX = position >> 6 & 0x3f; 1107 + int tilePlane = position >> 12; 1108 + int hash = stream.getUnsignedByte(); 1109 + int type = hash >> 2; 1110 + int orientation = hash & 0x3; 1111 + int x = tileX + blockX; 1112 + int y = tileY + blockY; 1113 + if (x > 0 && y > 0 && x < 103 && y < 103) { 1114 + int markingPlane = tilePlane; 1115 + if ((renderRuleFlags[1][x][y] & 0x2) == 2) 1116 + markingPlane--; 1117 + CollisionMap collisionMap_ = null; 1118 + if (markingPlane >= 0) 1119 + collisionMap_ = collisionMap[markingPlane]; 1120 + renderObject(scene, collisionMap_, y, tilePlane, x, orientation, type, objectId); 1121 + } 1122 + } 1123 + } 1124 + } 1140 1125 1141 - public void initiateVertexHeights(int xOffset, int xLength, int yOffset, int yLength) { 1142 - for (int y = yOffset; y <= yOffset + yLength; y++) { 1143 - for (int x = xOffset; x <= xOffset + xLength; x++) { 1144 - if (x >= 0 && x < regionSizeX && y >= 0 && y < regionSizeY) { 1145 - tileShadowIntensity[0][x][y] = (byte) 127; 1146 - if (x == xOffset && x > 0) 1147 - vertexHeights[0][x][y] = vertexHeights[0][x - 1][y]; 1148 - if (x == xOffset + xLength && x < regionSizeX - 1) 1149 - vertexHeights[0][x][y] = vertexHeights[0][x + 1][y]; 1150 - if (y == yOffset && y > 0) 1151 - vertexHeights[0][x][y] = vertexHeights[0][x][y - 1]; 1152 - if (y == yOffset + yLength && y < regionSizeY - 1) 1153 - vertexHeights[0][x][y] = vertexHeights[0][x][y + 1]; 1154 - } 1155 - } 1156 - } 1126 + public void initiateVertexHeights(int xOffset, int xLength, int yOffset, int yLength) { 1127 + for (int y = yOffset; y <= yOffset + yLength; y++) { 1128 + for (int x = xOffset; x <= xOffset + xLength; x++) { 1129 + if (x >= 0 && x < regionSizeX && y >= 0 && y < regionSizeY) { 1130 + tileShadowIntensity[0][x][y] = (byte) 127; 1131 + if (x == xOffset && x > 0) 1132 + vertexHeights[0][x][y] = vertexHeights[0][x - 1][y]; 1133 + if (x == xOffset + xLength && x < regionSizeX - 1) 1134 + vertexHeights[0][x][y] = vertexHeights[0][x + 1][y]; 1135 + if (y == yOffset && y > 0) 1136 + vertexHeights[0][x][y] = vertexHeights[0][x][y - 1]; 1137 + if (y == yOffset + yLength && y < regionSizeY - 1) 1138 + vertexHeights[0][x][y] = vertexHeights[0][x][y + 1]; 1139 + } 1140 + } 1141 + } 1157 1142 1158 - } 1143 + } 1159 1144 1160 - public static boolean method181(int i, int i_258_, byte[] is, int i_259_) { 1161 - boolean bool = true; 1162 - Buffer class50_sub1_sub2 = new Buffer(is); 1163 - if (i_259_ != 24515) 1164 - throw new NullPointerException(); 1165 - int i_260_ = -1; 1166 - for (;;) { 1167 - int i_261_ = class50_sub1_sub2.getSmart(); 1168 - if (i_261_ == 0) 1169 - break; 1170 - i_260_ += i_261_; 1171 - int i_262_ = 0; 1172 - boolean bool_263_ = false; 1173 - for (;;) { 1174 - if (bool_263_) { 1175 - int i_264_ = class50_sub1_sub2.getSmart(); 1176 - if (i_264_ == 0) 1177 - break; 1178 - class50_sub1_sub2.getUnsignedByte(); 1179 - } else { 1180 - int i_265_ = class50_sub1_sub2.getSmart(); 1181 - if (i_265_ == 0) 1182 - break; 1183 - i_262_ += i_265_ - 1; 1184 - int i_266_ = i_262_ & 0x3f; 1185 - int i_267_ = i_262_ >> 6 & 0x3f; 1186 - int i_268_ = class50_sub1_sub2.getUnsignedByte() >> 2; 1187 - int i_269_ = i_267_ + i; 1188 - int i_270_ = i_266_ + i_258_; 1189 - if (i_269_ > 0 && i_270_ > 0 && i_269_ < 103 && i_270_ < 103) { 1190 - GameObjectDefinition class47 = GameObjectDefinition.getDefinition(i_260_); 1191 - if (i_268_ != 22 || !lowMemory || class47.actionsBoolean || class47.unknown) { 1192 - bool &= class47.isModelCached(); 1193 - bool_263_ = true; 1194 - } 1195 - } 1196 - } 1197 - } 1198 - } 1199 - return bool; 1200 - } 1145 + public static boolean regionCached(int regionX, int regionY, byte[] objectData) { 1146 + boolean cached = true; 1147 + Buffer objectDataStream = new Buffer(objectData); 1148 + int objectId = -1; 1149 + while (true) { 1150 + int objectIdIncrement = objectDataStream.getSmart(); 1151 + if (objectIdIncrement == 0) 1152 + break; 1153 + objectId += objectIdIncrement; 1154 + int pos = 0; 1155 + boolean readSecondValue = false; 1156 + while (true) { 1157 + if (readSecondValue) { 1158 + int secondValue = objectDataStream.getSmart(); 1159 + if (secondValue == 0) 1160 + break; 1161 + objectDataStream.getUnsignedByte(); 1162 + } else { 1163 + int positionoffset = objectDataStream.getSmart(); 1164 + if (positionoffset == 0) 1165 + break; 1166 + pos += positionoffset - 1; 1167 + int regionOffsetY = pos & 0x3f; 1168 + int regionOffsetX = pos >> 6 & 0x3f; 1169 + int objectType = objectDataStream.getUnsignedByte() >> 2; 1170 + int objectX = regionOffsetX + regionX; 1171 + int objectY = regionOffsetY + regionY; 1172 + if (objectX > 0 && objectY > 0 && objectX < 103 && objectY < 103) { 1173 + GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId); 1174 + if (objectType != 22 || !lowMemory || definition.hasActions || definition.unknown) { 1175 + cached &= definition.isModelCached(); 1176 + readSecondValue = true; 1177 + } 1178 + } 1179 + } 1180 + } 1181 + } 1182 + return cached; 1183 + } 1201 1184 1202 - public int method182(int i, int i_271_) { 1203 - if (i == -2) 1204 - return 12345678; 1205 - if (i == -1) { 1206 - if (i_271_ < 0) 1207 - i_271_ = 0; 1208 - else if (i_271_ > 127) 1209 - i_271_ = 127; 1210 - i_271_ = 127 - i_271_; 1211 - return i_271_; 1212 - } 1213 - i_271_ = i_271_ * (i & 0x7f) / 128; 1214 - if (i_271_ < 2) 1215 - i_271_ = 2; 1216 - else if (i_271_ > 126) 1217 - i_271_ = 126; 1218 - return (i & 0xff80) + i_271_; 1219 - } 1185 + public int mixLightnessSigned(int hsl, int lightness) { 1186 + if (hsl == -2) 1187 + return 12345678; 1188 + if (hsl == -1) { 1189 + if (lightness < 0) 1190 + lightness = 0; 1191 + else if (lightness > 127) 1192 + lightness = 127; 1193 + lightness = 127 - lightness; 1194 + return lightness; 1195 + } 1196 + lightness = lightness * (hsl & 0x7f) / 128; 1197 + if (lightness < 2) 1198 + lightness = 2; 1199 + else if (lightness > 126) 1200 + lightness = 126; 1201 + return (hsl & 0xff80) + lightness; 1202 + } 1220 1203 1221 - public void loadTerrainTile(int tileX, int offsetX, int tileY, int offsetY, int tileZ, Buffer stream, int i1) { 1222 - if (tileX >= 0 && tileX < 104 && tileY >= 0 && tileY < 104) { 1223 - renderRuleFlags[tileZ][tileX][tileY] = (byte) 0; 1224 - for (;;) { 1225 - int value = stream.getUnsignedByte(); 1226 - if (value == 0) { 1227 - if (tileZ == 0) 1228 - vertexHeights[0][tileX][tileY] = -calculateVertexHeight(932731 + tileX + offsetX, 556238 + tileY 1229 - + offsetY) * 8; 1230 - else { 1231 - vertexHeights[tileZ][tileX][tileY] = (vertexHeights[tileZ - 1][tileX][tileY] - 240); 1232 - break; 1233 - } 1234 - break; 1235 - } 1236 - if (value == 1) { 1237 - int height = stream.getUnsignedByte(); 1238 - if (height == 1) 1239 - height = 0; 1240 - if (tileZ == 0) 1241 - vertexHeights[0][tileX][tileY] = -height * 8; 1242 - else { 1243 - vertexHeights[tileZ][tileX][tileY] = (vertexHeights[tileZ - 1][tileX][tileY] - height * 8); 1244 - break; 1245 - } 1246 - break; 1247 - } 1248 - if (value <= 49) { 1249 - overlayFloorIds[tileZ][tileX][tileY] = stream.getByte(); 1250 - overlayClippingPaths[tileZ][tileX][tileY] = (byte) ((value - 2) / 4); 1251 - overlayRotations[tileZ][tileX][tileY] = (byte) (value - 2 + i1 & 0x3); 1252 - } else if (value <= 81) 1253 - renderRuleFlags[tileZ][tileX][tileY] = (byte) (value - 49); 1254 - else 1255 - underlayFloorIds[tileZ][tileX][tileY] = (byte) (value - 81); 1256 - } 1257 - } else { 1258 - for (;;) { 1259 - int value = stream.getUnsignedByte(); 1260 - if (value == 0) 1261 - break; 1262 - if (value == 1) { 1263 - stream.getUnsignedByte(); 1264 - break; 1265 - } 1266 - if (value <= 49) 1267 - stream.getUnsignedByte(); 1268 - } 1269 - } 1270 - } 1204 + public void loadTerrainTile(int tileX, int offsetX, int tileY, int offsetY, int tileZ, Buffer stream, int i1) { 1205 + if (tileX >= 0 && tileX < 104 && tileY >= 0 && tileY < 104) { 1206 + renderRuleFlags[tileZ][tileX][tileY] = (byte) 0; 1207 + for (; ; ) { 1208 + int value = stream.getUnsignedByte(); 1209 + if (value == 0) { 1210 + if (tileZ == 0) 1211 + vertexHeights[0][tileX][tileY] = -calculateVertexHeight(932731 + tileX + offsetX, 556238 + tileY 1212 + + offsetY) * 8; 1213 + else { 1214 + vertexHeights[tileZ][tileX][tileY] = (vertexHeights[tileZ - 1][tileX][tileY] - 240); 1215 + break; 1216 + } 1217 + break; 1218 + } 1219 + if (value == 1) { 1220 + int height = stream.getUnsignedByte(); 1221 + if (height == 1) 1222 + height = 0; 1223 + if (tileZ == 0) 1224 + vertexHeights[0][tileX][tileY] = -height * 8; 1225 + else { 1226 + vertexHeights[tileZ][tileX][tileY] = (vertexHeights[tileZ - 1][tileX][tileY] - height * 8); 1227 + break; 1228 + } 1229 + break; 1230 + } 1231 + if (value <= 49) { 1232 + overlayFloorIds[tileZ][tileX][tileY] = stream.getByte(); 1233 + overlayClippingPaths[tileZ][tileX][tileY] = (byte) ((value - 2) / 4); 1234 + overlayRotations[tileZ][tileX][tileY] = (byte) (value - 2 + i1 & 0x3); 1235 + } else if (value <= 81) 1236 + renderRuleFlags[tileZ][tileX][tileY] = (byte) (value - 49); 1237 + else 1238 + underlayFloorIds[tileZ][tileX][tileY] = (byte) (value - 81); 1239 + } 1240 + } else { 1241 + for (; ; ) { 1242 + int value = stream.getUnsignedByte(); 1243 + if (value == 0) 1244 + break; 1245 + if (value == 1) { 1246 + stream.getUnsignedByte(); 1247 + break; 1248 + } 1249 + if (value <= 49) 1250 + stream.getUnsignedByte(); 1251 + } 1252 + } 1253 + } 1271 1254 1272 - public static int calculateVertexHeight(int i, int i_281_) { 1273 - int mapHeight = (method163(i + 45365, i_281_ + 91923, 4) - 128 1274 - + (method163(i + 10294, i_281_ + 37821, 2) - 128 >> 1) + (method163(i, i_281_, 1) - 128 >> 2)); 1275 - mapHeight = (int) (mapHeight * 0.3) + 35; 1276 - if (mapHeight < 10) 1277 - mapHeight = 10; 1278 - else if (mapHeight > 60) 1279 - mapHeight = 60; 1280 - return mapHeight; 1281 - } 1255 + public static int calculateVertexHeight(int i, int i_281_) { 1256 + int mapHeight = (method163(i + 45365, i_281_ + 91923, 4) - 128 1257 + + (method163(i + 10294, i_281_ + 37821, 2) - 128 >> 1) + (method163(i, i_281_, 1) - 128 >> 2)); 1258 + mapHeight = (int) (mapHeight * 0.3) + 35; 1259 + if (mapHeight < 10) 1260 + mapHeight = 10; 1261 + else if (mapHeight > 60) 1262 + mapHeight = 60; 1263 + return mapHeight; 1264 + } 1282 1265 }
+2 -2
src/main/java/com/jagex/runescape/scene/Scene.java
··· 580 580 } 581 581 } 582 582 583 - public int method267(int i, int j, int k) { 584 - SceneTile sceneTile = groundArray[i][j][k]; 583 + public int getWallObjectHash(int x, int y, int z) { 584 + SceneTile sceneTile = groundArray[z][x][y]; 585 585 if (sceneTile == null || sceneTile.wall == null) { 586 586 return 0; 587 587 } else {
+1 -1
src/main/java/com/jagex/runescape/scene/util/CollisionMap.java
··· 153 153 } 154 154 } 155 155 156 - public void method413(int y, int orient, int h, int w, boolean impenetrable, int x, byte byte0) { 156 + public void markSolidOccupant(int y, int orient, int h, int w, boolean impenetrable, int x, byte byte0) { 157 157 int occupied = 256; 158 158 if (impenetrable) 159 159 occupied += 0x20000;