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.

some appearance refactoring

+794 -841
+20 -20
src/main/java/com/jagex/runescape/Game.java
··· 1426 1426 processRightClick(-521); 1427 1427 if (lastActiveInvInterface == modifiedWidgetId && mouseInvInterfaceIndex != selectedInventorySlot) { 1428 1428 Widget childInterface = Widget.forId(modifiedWidgetId); 1429 - int moveItemInsetionMode = 0; 1429 + int moveItemInsertionMode = 0; 1430 1430 if (bankInsertMode == 1 && childInterface.contentType == 206) 1431 - moveItemInsetionMode = 1; 1431 + moveItemInsertionMode = 1; 1432 1432 if (childInterface.items[mouseInvInterfaceIndex] <= 0) 1433 - moveItemInsetionMode = 0; 1433 + moveItemInsertionMode = 0; 1434 1434 if (childInterface.itemDeletesDraged) { 1435 1435 int slotStart = selectedInventorySlot; 1436 1436 int slotEnd = mouseInvInterfaceIndex; ··· 1438 1438 childInterface.itemAmounts[slotEnd] = childInterface.itemAmounts[slotStart]; 1439 1439 childInterface.items[slotStart] = -1; 1440 1440 childInterface.itemAmounts[slotStart] = 0; 1441 - } else if (moveItemInsetionMode == 1) { 1441 + } else if (moveItemInsertionMode == 1) { 1442 1442 int slotStart = selectedInventorySlot; 1443 1443 for (int slotPointer = mouseInvInterfaceIndex; slotStart != slotPointer; ) 1444 1444 if (slotStart > slotPointer) { ··· 1454 1454 } 1455 1455 outBuffer.putOpcode(123); 1456 1456 outBuffer.putOffsetShortLE(mouseInvInterfaceIndex); 1457 - outBuffer.putOffsetByte(moveItemInsetionMode); 1457 + outBuffer.putOffsetByte(moveItemInsertionMode); 1458 1458 outBuffer.putOffsetShortBE(modifiedWidgetId); 1459 1459 outBuffer.putShortLE(selectedInventorySlot); 1460 1460 } ··· 5976 5976 chatboxInterface.scrollPosition = chatboxScrollMax - chatboxScroll - 77; 5977 5977 if (super.mouseX > 448 && super.mouseX < 560 && super.mouseY > 332) 5978 5978 scrollInterface(chatboxScrollMax, 0, chatboxInterface, (byte) 102, super.mouseY - 357, -1, super.mouseX - 17, 77, 463); 5979 - int j = chatboxScrollMax - 77 - chatboxInterface.scrollPosition; 5980 - if (j < 0) 5981 - j = 0; 5982 - if (j > chatboxScrollMax - 77) 5983 - j = chatboxScrollMax - 77; 5984 - if (chatboxScroll != j) { 5985 - chatboxScroll = j; 5979 + int currentScroll = chatboxScrollMax - 77 - chatboxInterface.scrollPosition; 5980 + if (currentScroll < 0) 5981 + currentScroll = 0; 5982 + if (currentScroll > chatboxScrollMax - 77) 5983 + currentScroll = chatboxScrollMax - 77; 5984 + if (chatboxScroll != currentScroll) { 5985 + chatboxScroll = currentScroll; 5986 5986 redrawChatbox = true; 5987 5987 } 5988 5988 } ··· 9956 9956 fontBold.drawCenteredStringWaveY(s, drawX, drawY, renderCount, k2); 9957 9957 } 9958 9958 if (spokenEffect[j] == 2) { 9959 - fontBold.drawCeneteredStringWaveXY(s, drawX, drawY + 1, renderCount, 0); 9960 - fontBold.drawCeneteredStringWaveXY(s, drawX, drawY, renderCount, k2); 9959 + fontBold.drawCenteredStringWaveXY(s, drawX, drawY + 1, renderCount, 0); 9960 + fontBold.drawCenteredStringWaveXY(s, drawX, drawY, renderCount, k2); 9961 9961 } 9962 9962 if (spokenEffect[j] == 3) { 9963 9963 fontBold.drawCenteredStringWaveXYMove(s, drawX, drawY + 1, renderCount, 150 - spokenCycle[j], 0 ··· 10331 10331 int l = x * x + y * y; 10332 10332 if (l > 6400) 10333 10333 return; 10334 - int i1 = Model.SINE[k]; 10335 - int j1 = Model.COSINE[k]; 10336 - i1 = (i1 * 256) / (mapZoomOffset + 256); 10337 - j1 = (j1 * 256) / (mapZoomOffset + 256); 10338 - int k1 = y * i1 + x * j1 >> 16; 10339 - int l1 = y * j1 - x * i1 >> 16; 10334 + int sine = Model.SINE[k]; 10335 + int cosine = Model.COSINE[k]; 10336 + sine = (sine * 256) / (mapZoomOffset + 256); 10337 + cosine = (cosine * 256) / (mapZoomOffset + 256); 10338 + int k1 = y * sine + x * cosine >> 16; 10339 + int l1 = y * cosine - x * sine >> 16; 10340 10340 if (l > 2500) { 10341 10341 sprite.drawTo(minimapBackgroundImage, ((94 + k1) - sprite.maxWidth / 2) + 4, 83 - l1 - sprite.maxHeight 10342 10342 / 2 - 4);
+51
src/main/java/com/jagex/runescape/cache/FileOperations.java
··· 1 + package com.jagex.runescape.cache;/* 2 + * Class: FileOperations.java 3 + * Reads a separate file. 4 + * */ 5 + 6 + import java.io.*; 7 + 8 + public class FileOperations { 9 + 10 + public static int TotalRead = 0; 11 + public static int TotalWrite = 0; 12 + public static int CompleteWrite = 0; 13 + 14 + public FileOperations() { 15 + } 16 + 17 + public static final byte[] ReadFile(String s) { 18 + try { 19 + File file = new File(s); 20 + int i = (int) file.length(); 21 + byte[] abyte0 = new byte[i]; 22 + DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new FileInputStream(s))); 23 + datainputstream.readFully(abyte0, 0, i); 24 + datainputstream.close(); 25 + TotalRead++; 26 + return abyte0; 27 + } catch(Exception exception) { 28 + System.out.println((new StringBuilder()).append("Read Error: ").append(s).toString()); 29 + } 30 + return null; 31 + } 32 + 33 + public static final void WriteFile(String s, byte[] abyte0) { 34 + try { 35 + (new File((new File(s)).getParent())).mkdirs(); 36 + FileOutputStream fileoutputstream = new FileOutputStream(s); 37 + fileoutputstream.write(abyte0, 0, abyte0.length); 38 + fileoutputstream.close(); 39 + TotalWrite++; 40 + CompleteWrite++; 41 + } catch(Throwable throwable) { 42 + System.out.println((new StringBuilder()).append("Write Error: ").append(s).toString()); 43 + } 44 + } 45 + 46 + public static boolean FileExists(String file) { 47 + File f = new File(file); 48 + return f.exists(); 49 + } 50 + 51 + }
+3 -4
src/main/java/com/jagex/runescape/cache/def/GameObjectDefinition.java
··· 1 1 package com.jagex.runescape.cache.def; 2 2 3 3 import com.jagex.runescape.cache.Archive; 4 + import com.jagex.runescape.cache.FileOperations; 4 5 import com.jagex.runescape.net.Buffer; 5 6 import com.jagex.runescape.Game; 6 7 import com.jagex.runescape.net.requester.OnDemandRequester; ··· 21 22 public boolean unknown; 22 23 public int translateZ; 23 24 public static Buffer buffer; 24 - public int anInt768 = -992; 25 25 public boolean adjustToTerrain; 26 26 public static Game client; 27 27 public static Model models[] = new Model[4]; 28 28 public static boolean lowMemory; 29 29 public int id = -1; 30 - public boolean aBoolean774 = true; 31 30 public int sizeY; 32 31 public String name = "null"; 33 32 public static int cacheIndex; ··· 41 40 public int translateY; 42 41 public boolean aBoolean786 = true; 43 42 public byte modelLightAmbient; 44 - public int anInt788; 45 43 public int modelTypes[]; 46 44 public String options[]; 47 45 public boolean aBoolean791; 48 46 public int anIntArray792[]; 49 - public byte aByte793 = -113; 50 47 public int anInt794; 51 48 public int anInt795; 52 49 public int modelSizeZ; ··· 145 142 public static void load(Archive archive) { 146 143 buffer = new Buffer(archive.getFile("loc.dat")); 147 144 Buffer buffer = new Buffer(archive.getFile("loc.idx")); 145 + FileOperations.WriteFile("DumpedData/377_OBJECTS.dat", archive.getFile("loc.dat")); 146 + FileOperations.WriteFile("DumpedData/377_OBJECTS.idx", archive.getFile("loc.idx")); 148 147 definitionCount = buffer.getUnsignedShortBE(); 149 148 bufferOffsets = new int[definitionCount]; 150 149 int offset = 2;
+5 -5
src/main/java/com/jagex/runescape/cache/def/ItemDefinition.java
··· 165 165 return null; 166 166 Model primary = Model.getModel(primaryId); 167 167 if (secondaryId != -1) 168 - if (tertiaryId != -1) { 168 + if (tertiaryId == -1) { 169 + Model secondary = Model.getModel(secondaryId); 170 + Model parts[] = { primary, secondary }; 171 + primary = new Model(2, parts); 172 + } else { 169 173 Model secondary = Model.getModel(secondaryId); 170 174 Model tertiary = Model.getModel(tertiaryId); 171 175 Model parts[] = { primary, 172 176 secondary, tertiary }; 173 177 primary = new Model(3, parts); 174 - } else { 175 - Model secondary = Model.getModel(secondaryId); 176 - Model parts[] = { primary, secondary }; 177 - primary = new Model(2, parts); 178 178 } 179 179 if (gender == 0 && maleTranslation != 0) 180 180 primary.translate(0, 0, maleTranslation);
+1 -1
src/main/java/com/jagex/runescape/cache/media/TypeFace.java
··· 229 229 } 230 230 } 231 231 232 - public void drawCeneteredStringWaveXY(String string, int x, int y, int wave, int colour) { 232 + public void drawCenteredStringWaveXY(String string, int x, int y, int wave, int colour) { 233 233 if (string == null) 234 234 return; 235 235 x -= getDisplayedWidth(string) / 2;
+6 -6
src/main/java/com/jagex/runescape/media/renderable/Model.java
··· 379 379 triangleCount += model.triangleCount; 380 380 texturedTriangleCount += model.texturedTriangleCount; 381 381 setDrawType |= model.triangleDrawType != null; 382 - if (model.trianglePriorities != null) { 383 - setPriority = true; 384 - } else { 382 + if (model.trianglePriorities == null) { 385 383 if (trianglePriority == -1) { 386 384 trianglePriority = model.trianglePriority; 387 385 } 388 386 if (trianglePriority != model.trianglePriority) { 389 387 setPriority = true; 390 388 } 389 + } else { 390 + setPriority = true; 391 391 } 392 392 setAlpha |= model.triangleAlphaValues != null; 393 393 setSkins |= model.triangleSkinValues != null; ··· 652 652 texturedTrianglePointsZ = model.texturedTrianglePointsZ; 653 653 } 654 654 655 - public Model(boolean flag, boolean flag1, Model model) { 655 + public Model(boolean adjustToTerrain, boolean nonFlatShading, Model model) { 656 656 vertexCount = model.vertexCount; 657 657 triangleCount = model.triangleCount; 658 658 texturedTriangleCount = model.texturedTriangleCount; 659 - if (flag) { 659 + if (adjustToTerrain) { 660 660 verticesY = new int[vertexCount]; 661 661 System.arraycopy(model.verticesY, 0, verticesY, 0, vertexCount); 662 662 663 663 } else { 664 664 verticesY = model.verticesY; 665 665 } 666 - if (flag1) { 666 + if (nonFlatShading) { 667 667 triangleHSLA = new int[triangleCount]; 668 668 triangleHSLB = new int[triangleCount]; 669 669 triangleHSLC = new int[triangleCount];
+306 -314
src/main/java/com/jagex/runescape/media/renderable/actor/Player.java
··· 1 1 package com.jagex.runescape.media.renderable.actor; 2 2 3 3 import com.jagex.runescape.Game; 4 - import com.jagex.runescape.cache.def.ItemDefinition; 5 4 import com.jagex.runescape.cache.def.ActorDefinition; 5 + import com.jagex.runescape.cache.def.ItemDefinition; 6 6 import com.jagex.runescape.cache.media.AnimationSequence; 7 7 import com.jagex.runescape.cache.media.IdentityKit; 8 8 import com.jagex.runescape.cache.media.SpotAnimation; ··· 14 14 15 15 public class Player extends Actor { 16 16 17 - public int anInt1743; 18 - public int drawHeight; 19 - public int anInt1745; 20 - public Model playerModel; 21 - public int headIcon = -1; 22 - private long cachedModel = -1L; 23 - public int drawHeight2; 24 - public String playerName; 25 - public int[] appearance = new int[12]; 26 - public int combatLevel; 27 - private long appearanceHash; 28 - private int gender; 29 - public int isSkulled = -1; 30 - public ActorDefinition npcDefinition; 31 - public boolean visible = false; 32 - public int skillLevel; 33 - public int[] appearanceColors = new int[5]; 34 - public static Cache modelCache = new Cache(260); 35 - public boolean preventRotation = false; 36 - public int objectAppearanceStartTick; 37 - public int objectAppearanceEndTick; 38 - public int teamId; 39 - public int anInt1768; 40 - public int anInt1769; 41 - public int anInt1770; 42 - public int anInt1771; 17 + public int anInt1743; 18 + public int drawHeight; 19 + public int anInt1745; 20 + public Model playerModel; 21 + public int headIcon = -1; 22 + private long cachedModel = -1L; 23 + public int drawHeight2; 24 + public String playerName; 25 + public int[] appearance = new int[12]; 26 + public int combatLevel; 27 + private long appearanceHash; 28 + private int gender; 29 + public int isSkulled = -1; 30 + public ActorDefinition npcDefinition; 31 + public boolean visible = false; 32 + public int skillLevel; 33 + public int[] appearanceColors = new int[5]; 34 + public static Cache modelCache = new Cache(260); 35 + public boolean preventRotation = false; 36 + public int objectAppearanceStartTick; 37 + public int objectAppearanceEndTick; 38 + public int teamId; 39 + public int anInt1768; 40 + public int anInt1769; 41 + public int anInt1770; 42 + public int anInt1771; 43 43 44 44 45 - public Model getHeadModel() { 46 - if (!visible) 47 - return null; 48 - if (npcDefinition != null) 49 - return npcDefinition.getHeadModel(); 50 - boolean cached = false; 51 - for (int index = 0; index < 12; index++) { 52 - int appearanceId = appearance[index]; 53 - if (appearanceId >= 256 && appearanceId < 512 && !IdentityKit.cache[appearanceId - 256].isHeadModelCached()) 54 - cached = true; 55 - if (appearanceId >= 512 && !ItemDefinition.lookup(appearanceId - 512).headPieceReady(gender)) 56 - cached = true; 57 - } 45 + public Model getHeadModel() { 46 + if(!visible) 47 + return null; 48 + if(npcDefinition != null) 49 + return npcDefinition.getHeadModel(); 50 + boolean cached = false; 51 + for(int index = 0; index < 12; index++) { 52 + int appearanceId = appearance[index]; 53 + if(appearanceId >= 256 && appearanceId < 512 && !IdentityKit.cache[appearanceId - 256].isHeadModelCached()) 54 + cached = true; 55 + if(appearanceId >= 512 && !ItemDefinition.lookup(appearanceId - 512).headPieceReady(gender)) 56 + cached = true; 57 + } 58 58 59 - if (cached) 60 - return null; 61 - Model[] headModels = new Model[12]; 62 - int headModelsOffset = 0; 63 - for (int modelIndex = 0; modelIndex < 12; modelIndex++) { 64 - int appearanceId = appearance[modelIndex]; 65 - if (appearanceId >= 256 && appearanceId < 512) { 66 - Model subModel = IdentityKit.cache[appearanceId - 256].getHeadModel(); 67 - if (subModel != null) 68 - headModels[headModelsOffset++] = subModel; 69 - } 70 - if (appearanceId >= 512) { 71 - Model subModel = ItemDefinition.lookup(appearanceId - 512).asHeadPiece(gender); 72 - if (subModel != null) 73 - headModels[headModelsOffset++] = subModel; 74 - } 75 - } 59 + if(cached) 60 + return null; 61 + Model[] headModels = new Model[12]; 62 + int headModelsOffset = 0; 63 + for(int modelIndex = 0; modelIndex < 12; modelIndex++) { 64 + int appearanceId = appearance[modelIndex]; 65 + if(appearanceId >= 256 && appearanceId < 512) { 66 + Model subModel = IdentityKit.cache[appearanceId - 256].getHeadModel(); 67 + if(subModel != null) 68 + headModels[headModelsOffset++] = subModel; 69 + } 70 + if(appearanceId >= 512) { 71 + Model subModel = ItemDefinition.lookup(appearanceId - 512).asHeadPiece(gender); 72 + if(subModel != null) 73 + headModels[headModelsOffset++] = subModel; 74 + } 75 + } 76 76 77 - Model headModel = new Model(headModelsOffset, headModels); 78 - for (int index = 0; index < 5; index++) 79 - if (appearanceColors[index] != 0) { 80 - headModel.replaceColor(Game.playerColours[index][0], 81 - Game.playerColours[index][appearanceColors[index]]); 82 - if (index == 1) 83 - headModel.replaceColor(Game.SKIN_COLOURS[0], Game.SKIN_COLOURS[appearanceColors[index]]); 84 - } 77 + Model headModel = new Model(headModelsOffset, headModels); 78 + for(int index = 0; index < 5; index++) 79 + if(appearanceColors[index] != 0) { 80 + headModel.replaceColor(Game.playerColours[index][0], Game.playerColours[index][appearanceColors[index]]); 81 + if(index == 1) 82 + headModel.replaceColor(Game.SKIN_COLOURS[0], Game.SKIN_COLOURS[appearanceColors[index]]); 83 + } 85 84 86 - return headModel; 87 - } 85 + return headModel; 86 + } 88 87 89 - public Model getAnimatedModel() { 90 - if (npcDefinition != null) { 91 - int frame = -1; 92 - if (super.emoteAnimation >= 0 && super.animationDelay == 0) 93 - frame = AnimationSequence.animations[super.emoteAnimation].getPrimaryFrame[super.displayedEmoteFrames]; 94 - else if (super.movementAnimation >= 0) 95 - frame = AnimationSequence.animations[super.movementAnimation].getPrimaryFrame[super.displayedMovementFrames]; 96 - Model model = npcDefinition.getChildModel(frame, -1, null); 97 - return model; 98 - } 99 - long hash = appearanceHash; 100 - int primaryFrame = -1; 101 - int secondaryFrame = -1; 102 - int shieldModel = -1; 103 - int weaponModel = -1; 104 - if (super.emoteAnimation >= 0 && super.animationDelay == 0) { 105 - AnimationSequence emote = AnimationSequence.animations[super.emoteAnimation]; 106 - primaryFrame = emote.getPrimaryFrame[super.displayedEmoteFrames]; 107 - if (super.movementAnimation >= 0 && super.movementAnimation != super.idleAnimation) 108 - secondaryFrame = AnimationSequence.animations[super.movementAnimation].getPrimaryFrame[super.displayedMovementFrames]; 109 - if (emote.getPlayerShieldDelta >= 0) { 110 - shieldModel = emote.getPlayerShieldDelta; 111 - hash += shieldModel - appearance[5] << 40; 112 - } 113 - if (emote.getPlayerWeaponDelta >= 0) { 114 - weaponModel = emote.getPlayerWeaponDelta; 115 - hash += weaponModel - appearance[3] << 48; 116 - } 117 - } else if (super.movementAnimation >= 0) 118 - primaryFrame = AnimationSequence.animations[super.movementAnimation].getPrimaryFrame[super.displayedMovementFrames]; 119 - Model model = (Model) modelCache.get(hash); 120 - if (model == null) { 121 - boolean invalid = false; 122 - for (int bodyPart = 0; bodyPart < 12; bodyPart++) { 123 - int appearanceModel = appearance[bodyPart]; 124 - if (weaponModel >= 0 && bodyPart == 3) 125 - appearanceModel = weaponModel; 126 - if (shieldModel >= 0 && bodyPart == 5) 127 - appearanceModel = shieldModel; 128 - if (appearanceModel >= 256 && appearanceModel < 512 && !IdentityKit.cache[appearanceModel - 256].isBodyModelCached()) 129 - invalid = true; 130 - if (appearanceModel >= 512 && !ItemDefinition.lookup(appearanceModel - 512).equipmentReady(gender)) 131 - invalid = true; 132 - } 88 + public Model getAnimatedModel() { 89 + if(npcDefinition != null) { 90 + int frame = -1; 91 + if(super.emoteAnimation >= 0 && super.animationDelay == 0) 92 + frame = AnimationSequence.animations[super.emoteAnimation].getPrimaryFrame[super.displayedEmoteFrames]; 93 + else if(super.movementAnimation >= 0) 94 + frame = AnimationSequence.animations[super.movementAnimation].getPrimaryFrame[super.displayedMovementFrames]; 95 + Model model = npcDefinition.getChildModel(frame, -1, null); 96 + return model; 97 + } 98 + long hash = appearanceHash; 99 + int primaryFrame = -1; 100 + int secondaryFrame = -1; 101 + int shieldModel = -1; 102 + int weaponModel = -1; 103 + if(super.emoteAnimation >= 0 && super.animationDelay == 0) { 104 + AnimationSequence emote = AnimationSequence.animations[super.emoteAnimation]; 105 + primaryFrame = emote.getPrimaryFrame[super.displayedEmoteFrames]; 106 + if(super.movementAnimation >= 0 && super.movementAnimation != super.idleAnimation) 107 + secondaryFrame = AnimationSequence.animations[super.movementAnimation].getPrimaryFrame[super.displayedMovementFrames]; 108 + if(emote.getPlayerShieldDelta >= 0) { 109 + shieldModel = emote.getPlayerShieldDelta; 110 + hash += shieldModel - appearance[5] << 8; 111 + } 112 + if(emote.getPlayerWeaponDelta >= 0) { 113 + weaponModel = emote.getPlayerWeaponDelta; 114 + hash += weaponModel - appearance[3] << 16; 115 + } 116 + } else if(super.movementAnimation >= 0) 117 + primaryFrame = AnimationSequence.animations[super.movementAnimation].getPrimaryFrame[super.displayedMovementFrames]; 118 + Model model = (Model) modelCache.get(hash); 119 + if(model == null) { 120 + boolean invalid = false; 121 + for(int bodyPart = 0; bodyPart < 12; bodyPart++) { 122 + int appearanceModel = appearance[bodyPart]; 123 + if(weaponModel >= 0 && bodyPart == 3) 124 + appearanceModel = weaponModel; 125 + if(shieldModel >= 0 && bodyPart == 5) 126 + appearanceModel = shieldModel; 127 + if(appearanceModel >= 256 && appearanceModel < 512 && !IdentityKit.cache[appearanceModel - 256].isBodyModelCached()) 128 + invalid = true; 129 + if(appearanceModel >= 512 && !ItemDefinition.lookup(appearanceModel - 512).equipmentReady(gender)) 130 + invalid = true; 131 + } 133 132 134 - if (invalid) { 135 - if (cachedModel != -1L) 136 - model = (Model) modelCache.get(cachedModel); 137 - if (model == null) 138 - return null; 139 - } 140 - } 141 - if (model == null) { 142 - Model models[] = new Model[12]; 143 - int count = 0; 144 - for (int index = 0; index < 12; index++) { 145 - int part = appearance[index]; 146 - if (weaponModel >= 0 && index == 3) 147 - part = weaponModel; 148 - if (shieldModel >= 0 && index == 5) 149 - part = shieldModel; 150 - if (part >= 256 && part < 512) { 151 - Model bodyModel = IdentityKit.cache[part - 256] 152 - .getBodyModel(); 153 - if (bodyModel != null) 154 - models[count++] = bodyModel; 155 - } 156 - if (part >= 512) { 157 - Model equipment = ItemDefinition.lookup(part - 512).asEquipment( 158 - gender); 159 - if (equipment != null) 160 - models[count++] = equipment; 161 - } 162 - } 133 + if(invalid) { 134 + if(cachedModel != -1L) 135 + model = (Model) modelCache.get(cachedModel); 136 + if(model == null) 137 + return null; 138 + } 139 + } 140 + if(model == null) { 141 + Model models[] = new Model[12]; 142 + int count = 0; 143 + for(int index = 0; index < 12; index++) { 144 + int part = appearance[index]; 145 + if(weaponModel >= 0 && index == 3) 146 + part = weaponModel; 147 + if(shieldModel >= 0 && index == 5) 148 + part = shieldModel; 149 + if(part >= 256 && part < 512) { 150 + Model bodyModel = IdentityKit.cache[part - 256].getBodyModel(); 151 + if(bodyModel != null) 152 + models[count++] = bodyModel; 153 + } 154 + if(part >= 512) { 155 + Model equipment = ItemDefinition.lookup(part - 512).asEquipment(gender); 156 + if(equipment != null) 157 + models[count++] = equipment; 158 + } 159 + } 163 160 164 - model = new Model(count, models); 165 - for (int part = 0; part < 5; part++) 166 - if (appearanceColors[part] != 0) { 167 - model.replaceColor(Game.playerColours[part][0], 168 - Game.playerColours[part][appearanceColors[part]]); 169 - if (part == 1) 170 - model.replaceColor(Game.SKIN_COLOURS[0], Game.SKIN_COLOURS[appearanceColors[part]]); 171 - } 161 + model = new Model(count, models); 162 + for(int part = 0; part < 5; part++) 163 + if(appearanceColors[part] != 0) { 164 + model.replaceColor(Game.playerColours[part][0], Game.playerColours[part][appearanceColors[part]]); 165 + if(part == 1) 166 + model.replaceColor(Game.SKIN_COLOURS[0], Game.SKIN_COLOURS[appearanceColors[part]]); 167 + } 172 168 173 - model.createBones(); 174 - model.applyLighting(64, 850, -30, -50, -30, true); 175 - modelCache.put(model, hash); 176 - cachedModel = hash; 177 - } 178 - if (preventRotation) 179 - return model; 180 - Model empty = Model.EMPTY_MODEL; 181 - empty.replaceWithModel(model, Animation.exists(primaryFrame) & Animation.exists(secondaryFrame) 182 - ); 183 - if (primaryFrame != -1 && secondaryFrame != -1) 184 - empty.mixAnimationFrames(secondaryFrame, 0, primaryFrame, AnimationSequence.animations[super.emoteAnimation].flowControl); 185 - else if (primaryFrame != -1) 186 - empty.applyTransform(primaryFrame); 187 - empty.calculateDiagonals(); 188 - empty.triangleSkin = null; 189 - empty.vectorSkin = null; 190 - return empty; 191 - } 169 + model.createBones(); 170 + model.applyLighting(64, 850, -30, -50, -30, true); 171 + modelCache.put(model, hash); 172 + cachedModel = hash; 173 + } 174 + if(preventRotation) 175 + return model; 176 + Model empty = Model.EMPTY_MODEL; 177 + empty.replaceWithModel(model, Animation.exists(primaryFrame) & Animation.exists(secondaryFrame)); 178 + if(primaryFrame != -1 && secondaryFrame != -1) 179 + empty.mixAnimationFrames(secondaryFrame, 0, primaryFrame, AnimationSequence.animations[super.emoteAnimation].flowControl); 180 + else if(primaryFrame != -1) 181 + empty.applyTransform(primaryFrame); 182 + empty.calculateDiagonals(); 183 + empty.triangleSkin = null; 184 + empty.vectorSkin = null; 185 + return empty; 186 + } 192 187 193 - @Override 194 - public boolean isVisible() { 195 - return visible; 196 - } 188 + @Override 189 + public boolean isVisible() { 190 + return visible; 191 + } 197 192 198 - @Override 199 - public Model getRotatedModel() { 200 - if (!visible) 201 - return null; 202 - Model appearanceModel = getAnimatedModel(); 203 - if (appearanceModel == null) 204 - return null; 205 - modelHeight = appearanceModel.modelHeight; 206 - appearanceModel.singleTile = true; 207 - if (preventRotation) 208 - return appearanceModel; 209 - if (super.graphic != -1 && super.currentAnimation != -1) { 210 - SpotAnimation spotAnimation = SpotAnimation.cache[super.graphic]; 211 - Model spotAnimationModel = spotAnimation.getModel(); 212 - if (spotAnimationModel != null) { 213 - Model spotAnimationModel2 = new Model(true, 214 - spotAnimationModel, Animation.exists(super.currentAnimation)); 215 - spotAnimationModel2.translate(0, 0, -super.spotGraphicHeight); 216 - spotAnimationModel2.createBones(); 217 - spotAnimationModel2.applyTransform(spotAnimation.sequences.getPrimaryFrame[super.currentAnimation]); 218 - spotAnimationModel2.triangleSkin = null; 219 - spotAnimationModel2.vectorSkin = null; 220 - if (spotAnimation.resizeXY != 128 || spotAnimation.resizeZ != 128) 221 - spotAnimationModel2.scaleT(spotAnimation.resizeZ, spotAnimation.resizeXY, 9, spotAnimation.resizeXY); 222 - spotAnimationModel2.applyLighting(64 + spotAnimation.modelLightFalloff, 850 + spotAnimation.modelLightAmbient, -30, -50, -30, true); 223 - Model[] models = { appearanceModel, spotAnimationModel2 }; 224 - appearanceModel = new Model(models); 225 - } 226 - } 227 - if (playerModel != null) { 228 - if (Game.pulseCycle >= objectAppearanceEndTick) 229 - playerModel = null; 230 - if (Game.pulseCycle >= objectAppearanceStartTick && Game.pulseCycle < objectAppearanceEndTick) { 231 - Model model = playerModel; 232 - model.translate(anInt1743 - super.worldX, anInt1745 - super.worldY, 233 - drawHeight - drawHeight2); 234 - if (super.nextStepOrientation == 512) { 235 - model.rotate90Degrees(); 236 - model.rotate90Degrees(); 237 - model.rotate90Degrees(); 238 - } else if (super.nextStepOrientation == 1024) { 239 - model.rotate90Degrees(); 240 - model.rotate90Degrees(); 241 - } else if (super.nextStepOrientation == 1536) 242 - model.rotate90Degrees(); 243 - Model[] models = { appearanceModel, model }; 244 - appearanceModel = new Model(models); 245 - if (super.nextStepOrientation == 512) 246 - model.rotate90Degrees(); 247 - else if (super.nextStepOrientation == 1024) { 248 - model.rotate90Degrees(); 249 - model.rotate90Degrees(); 250 - } else if (super.nextStepOrientation == 1536) { 251 - model.rotate90Degrees(); 252 - model.rotate90Degrees(); 253 - model.rotate90Degrees(); 254 - } 255 - model.translate(super.worldX - anInt1743, super.worldY - anInt1745, 256 - drawHeight2 - drawHeight); 257 - } 258 - } 259 - appearanceModel.singleTile = true; 260 - return appearanceModel; 261 - } 193 + @Override 194 + public Model getRotatedModel() { 195 + if(!visible) 196 + return null; 197 + Model appearanceModel = getAnimatedModel(); 198 + if(appearanceModel == null) 199 + return null; 200 + modelHeight = appearanceModel.modelHeight; 201 + appearanceModel.singleTile = true; 202 + if(preventRotation) 203 + return appearanceModel; 204 + if(super.graphic != -1 && super.currentAnimation != -1) { 205 + SpotAnimation spotAnimation = SpotAnimation.cache[super.graphic]; 206 + Model spotAnimationModel = spotAnimation.getModel(); 207 + if(spotAnimationModel != null) { 208 + Model spotAnimationModel2 = new Model(true, spotAnimationModel, Animation.exists(super.currentAnimation)); 209 + spotAnimationModel2.translate(0, 0, -super.spotGraphicHeight); 210 + spotAnimationModel2.createBones(); 211 + spotAnimationModel2.applyTransform(spotAnimation.sequences.getPrimaryFrame[super.currentAnimation]); 212 + spotAnimationModel2.triangleSkin = null; 213 + spotAnimationModel2.vectorSkin = null; 214 + if(spotAnimation.resizeXY != 128 || spotAnimation.resizeZ != 128) 215 + spotAnimationModel2.scaleT(spotAnimation.resizeZ, spotAnimation.resizeXY, 9, spotAnimation.resizeXY); 216 + spotAnimationModel2.applyLighting(64 + spotAnimation.modelLightFalloff, 850 + spotAnimation.modelLightAmbient, -30, -50, -30, true); 217 + Model[] models = {appearanceModel, spotAnimationModel2}; 218 + appearanceModel = new Model(models); 219 + } 220 + } 221 + if(playerModel != null) { 222 + if(Game.pulseCycle >= objectAppearanceEndTick) 223 + playerModel = null; 224 + if(Game.pulseCycle >= objectAppearanceStartTick && Game.pulseCycle < objectAppearanceEndTick) { 225 + Model model = playerModel; 226 + model.translate(anInt1743 - super.worldX, anInt1745 - super.worldY, drawHeight - drawHeight2); 227 + if(super.nextStepOrientation == 512) { 228 + model.rotate90Degrees(); 229 + model.rotate90Degrees(); 230 + model.rotate90Degrees(); 231 + } else if(super.nextStepOrientation == 1024) { 232 + model.rotate90Degrees(); 233 + model.rotate90Degrees(); 234 + } else if(super.nextStepOrientation == 1536) 235 + model.rotate90Degrees(); 236 + Model[] models = {appearanceModel, model}; 237 + appearanceModel = new Model(models); 238 + if(super.nextStepOrientation == 512) 239 + model.rotate90Degrees(); 240 + else if(super.nextStepOrientation == 1024) { 241 + model.rotate90Degrees(); 242 + model.rotate90Degrees(); 243 + } else if(super.nextStepOrientation == 1536) { 244 + model.rotate90Degrees(); 245 + model.rotate90Degrees(); 246 + model.rotate90Degrees(); 247 + } 248 + model.translate(super.worldX - anInt1743, super.worldY - anInt1745, drawHeight2 - drawHeight); 249 + } 250 + } 251 + appearanceModel.singleTile = true; 252 + return appearanceModel; 253 + } 262 254 263 - public void updateAppearance(Buffer buffer) { 264 - buffer.currentPosition = 0; 265 - gender = buffer.getUnsignedByte(); 266 - isSkulled = buffer.getByte(); 267 - headIcon = buffer.getByte(); 268 - npcDefinition = null; 269 - teamId = 0; 270 - for (int index = 0; index < 12; index++) { 271 - int upperByte = buffer.getUnsignedByte(); 272 - if (upperByte == 0) { 273 - appearance[index] = 0; 274 - continue; 275 - } 276 - int lowerByte = buffer.getUnsignedByte(); 277 - appearance[index] = (upperByte << 8) + lowerByte; 278 - if (index == 0 && appearance[0] == 65535) { 279 - npcDefinition = ActorDefinition.getDefinition(buffer.getUnsignedShortBE()); 280 - break; 281 - } 282 - if (appearance[index] >= 512 && appearance[index] - 512 < ItemDefinition.count) { 283 - int itemTeam = ItemDefinition.lookup(appearance[index] - 512).team; 284 - if (itemTeam != 0) 285 - teamId = itemTeam; 286 - } 287 - } 255 + public void updateAppearance(Buffer buffer) { 256 + buffer.currentPosition = 0; 257 + gender = buffer.getUnsignedByte(); 258 + isSkulled = buffer.getByte(); 259 + headIcon = buffer.getByte(); 260 + npcDefinition = null; 261 + teamId = 0; 262 + for(int index = 0; index < 12; index++) { 263 + int upperByte = buffer.getUnsignedByte(); 264 + if(upperByte == 0) { 265 + appearance[index] = 0; 266 + continue; 267 + } 268 + int lowerByte = buffer.getUnsignedByte(); 269 + appearance[index] = (upperByte << 8) + lowerByte; 270 + if(index == 0 && appearance[0] == 65535) { 271 + npcDefinition = ActorDefinition.getDefinition(buffer.getUnsignedShortBE()); 272 + break; 273 + } 274 + if(appearance[index] >= 512 && appearance[index] - 512 < ItemDefinition.count) { 275 + int itemTeam = ItemDefinition.lookup(appearance[index] - 512).team; 276 + if(itemTeam != 0) 277 + teamId = itemTeam; 278 + } 279 + } 288 280 289 - for (int l = 0; l < 5; l++) { 290 - int j1 = buffer.getUnsignedByte(); 291 - if (j1 < 0 || j1 >= Game.playerColours[l].length) 292 - j1 = 0; 293 - appearanceColors[l] = j1; 294 - } 281 + for(int l = 0; l < 5; l++) { 282 + int j1 = buffer.getUnsignedByte(); 283 + if(j1 < 0 || j1 >= Game.playerColours[l].length) 284 + j1 = 0; 285 + appearanceColors[l] = j1; 286 + } 295 287 296 - super.idleAnimation = buffer.getUnsignedShortBE(); 297 - if (super.idleAnimation == 65535) 298 - super.idleAnimation = -1; 299 - super.standTurnAnimationId = buffer.getUnsignedShortBE(); 300 - if (super.standTurnAnimationId == 65535) 301 - super.standTurnAnimationId = -1; 302 - super.walkAnimationId = buffer.getUnsignedShortBE(); 303 - if (super.walkAnimationId == 65535) 304 - super.walkAnimationId = -1; 305 - super.turnAroundAnimationId = buffer.getUnsignedShortBE(); 306 - if (super.turnAroundAnimationId == 65535) 307 - super.turnAroundAnimationId = -1; 308 - super.turnRightAnimationId = buffer.getUnsignedShortBE(); 309 - if (super.turnRightAnimationId == 65535) 310 - super.turnRightAnimationId = -1; 311 - super.turnLeftAnimationId = buffer.getUnsignedShortBE(); 312 - if (super.turnLeftAnimationId == 65535) 313 - super.turnLeftAnimationId = -1; 314 - super.runAnimationId = buffer.getUnsignedShortBE(); 315 - if (super.runAnimationId == 65535) 316 - super.runAnimationId = -1; 317 - playerName = TextUtils.formatName(TextUtils.longToName(buffer.getLongBE())); 318 - combatLevel = buffer.getUnsignedByte(); 319 - skillLevel = buffer.getUnsignedShortBE(); 320 - visible = true; 321 - appearanceHash = 0L; 322 - int k1 = appearance[5]; 323 - int i2 = appearance[9]; 324 - appearance[5] = i2; 325 - appearance[9] = k1; 326 - for (int j2 = 0; j2 < 12; j2++) { 327 - appearanceHash <<= 4; 328 - if (appearance[j2] >= 256) 329 - appearanceHash += appearance[j2] - 256; 330 - } 288 + super.idleAnimation = buffer.getUnsignedShortBE(); 289 + if(super.idleAnimation == 65535) 290 + super.idleAnimation = -1; 291 + super.standTurnAnimationId = buffer.getUnsignedShortBE(); 292 + if(super.standTurnAnimationId == 65535) 293 + super.standTurnAnimationId = -1; 294 + super.walkAnimationId = buffer.getUnsignedShortBE(); 295 + if(super.walkAnimationId == 65535) 296 + super.walkAnimationId = -1; 297 + super.turnAroundAnimationId = buffer.getUnsignedShortBE(); 298 + if(super.turnAroundAnimationId == 65535) 299 + super.turnAroundAnimationId = -1; 300 + super.turnRightAnimationId = buffer.getUnsignedShortBE(); 301 + if(super.turnRightAnimationId == 65535) 302 + super.turnRightAnimationId = -1; 303 + super.turnLeftAnimationId = buffer.getUnsignedShortBE(); 304 + if(super.turnLeftAnimationId == 65535) 305 + super.turnLeftAnimationId = -1; 306 + super.runAnimationId = buffer.getUnsignedShortBE(); 307 + if(super.runAnimationId == 65535) 308 + super.runAnimationId = -1; 309 + playerName = TextUtils.formatName(TextUtils.longToName(buffer.getLongBE())); 310 + combatLevel = buffer.getUnsignedByte(); 311 + skillLevel = buffer.getUnsignedShortBE(); 312 + visible = true; 313 + appearanceHash = 0L; 314 + int k1 = appearance[5]; 315 + int i2 = appearance[9]; 316 + appearance[5] = i2; 317 + appearance[9] = k1; 318 + for(int j2 = 0; j2 < 12; j2++) { 319 + appearanceHash <<= 4; 320 + if(appearance[j2] >= 256) 321 + appearanceHash += appearance[j2] - 256; 322 + } 331 323 332 - if (appearance[0] >= 256) 333 - appearanceHash += appearance[0] - 256 >> 4; 334 - if (appearance[1] >= 256) 335 - appearanceHash += appearance[1] - 256 >> 8; 336 - appearance[5] = k1; 337 - appearance[9] = i2; 338 - for (int k2 = 0; k2 < 5; k2++) { 339 - appearanceHash <<= 3; 340 - appearanceHash += appearanceColors[k2]; 341 - } 324 + if(appearance[0] >= 256) 325 + appearanceHash += appearance[0] - 256 >> 4; 326 + if(appearance[1] >= 256) 327 + appearanceHash += appearance[1] - 256 >> 8; 328 + appearance[5] = k1; 329 + appearance[9] = i2; 330 + for(int k2 = 0; k2 < 5; k2++) { 331 + appearanceHash <<= 3; 332 + appearanceHash += appearanceColors[k2]; 333 + } 342 334 343 - appearanceHash <<= 1; 344 - appearanceHash += gender; 345 - } 335 + appearanceHash <<= 1; 336 + appearanceHash += gender; 337 + } 346 338 347 339 348 340 }
+402 -491
src/main/java/com/jagex/runescape/scene/MapRegion.java
··· 1 1 package com.jagex.runescape.scene; 2 2 3 - import com.jagex.runescape.net.Buffer; 4 - import com.jagex.runescape.net.requester.OnDemandRequester; 5 3 import com.jagex.runescape.cache.def.FloorDefinition; 6 4 import com.jagex.runescape.cache.def.GameObjectDefinition; 7 5 import com.jagex.runescape.media.Rasterizer3D; 8 6 import com.jagex.runescape.media.renderable.GameObject; 9 7 import com.jagex.runescape.media.renderable.Model; 10 8 import com.jagex.runescape.media.renderable.Renderable; 9 + import com.jagex.runescape.net.Buffer; 10 + import com.jagex.runescape.net.requester.OnDemandRequester; 11 11 import com.jagex.runescape.scene.util.CollisionMap; 12 12 import com.jagex.runescape.scene.util.TiledUtils; 13 13 ··· 76 76 77 77 /** 78 78 * Perlin noise generator 79 - * @param x The horizontal coordinate to get the noise for 80 - * @param y The vertical coordinate to get the noise for 79 + * 80 + * @param x The horizontal coordinate to get the noise for 81 + * @param y The vertical coordinate to get the noise for 81 82 * @param scale The scale of the coordinate set 82 83 * @return The value of the noise at [<b>x</b>;<b>y</b>] 83 84 */ ··· 96 97 } 97 98 98 99 public int getVisibilityPlaneFor(int x, int y, int plane) { 99 - if ((this.tile_flags[plane][x][y] & 8) != 0) { 100 + if((this.tile_flags[plane][x][y] & 8) != 0) { 100 101 return 0; 101 102 } 102 - if (plane > 0 && (this.tile_flags[1][x][y] & 2) != 0) { 103 + if(plane > 0 && (this.tile_flags[1][x][y] & 2) != 0) { 103 104 return plane - 1; 104 105 } else { 105 106 return plane; 106 107 } 107 108 } 108 109 109 - public static void forceRenderObject(int x, int y, int z, int objectId, int type, int plane, int face, Scene scene, CollisionMap collisionMap, 110 - int[][][] groundArray) { 110 + public static void forceRenderObject(int x, int y, int z, int objectId, int type, int plane, int face, Scene scene, CollisionMap collisionMap, int[][][] groundArray) { 111 111 int vertexHeightSW = groundArray[plane][x][y]; 112 112 int vertexHeightSE = groundArray[plane][x + 1][y]; 113 113 int vertexHeightNE = groundArray[plane][x + 1][y + 1]; ··· 115 115 int drawHeight = vertexHeightSW + vertexHeightSE + vertexHeightNE + vertexHeightNW >> 2; 116 116 GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId); 117 117 int hash = x + (y << 7) + (objectId << 14) + 1073741824; 118 - if (!definition.hasActions) 118 + if(!definition.hasActions) 119 119 hash += -2147483648; 120 120 byte config = (byte) ((face << 6) + type); 121 - if (type == 22) { 121 + if(type == 22) { 122 122 Renderable renderable; 123 - if (definition.animationId == -1 && definition.childrenIds == null) 123 + if(definition.animationId == -1 && definition.childrenIds == null) 124 124 renderable = definition.getGameObjectModel(22, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 125 125 else 126 - renderable = new GameObject(objectId, face, 22, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 127 - true); 126 + renderable = new GameObject(objectId, face, 22, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 128 127 scene.addGroundDecoration(x, y, z, drawHeight, hash, renderable, config); 129 - if (definition.solid && definition.hasActions) 128 + if(definition.solid && definition.hasActions) 130 129 collisionMap.markBlocked(x, y); 131 - } else if (type == 10 || type == 11) { 130 + } else if(type == 10 || type == 11) { 132 131 Renderable renderable; 133 - if (definition.animationId == -1 && definition.childrenIds == null) 132 + if(definition.animationId == -1 && definition.childrenIds == null) 134 133 renderable = definition.getGameObjectModel(10, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 135 134 else 136 - renderable = new GameObject(objectId, face, 10, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 137 - true); 138 - if (renderable != null) { 135 + renderable = new GameObject(objectId, face, 10, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 136 + if(renderable != null) { 139 137 int rotation = 0; 140 - if (type == 11) 138 + if(type == 11) 141 139 rotation += 256; 142 140 int sizeX; 143 141 int sizeY; 144 - if (face == 1 || face == 3) { 142 + if(face == 1 || face == 3) { 145 143 sizeX = definition.sizeY; 146 144 sizeY = definition.sizeX; 147 145 } else { 148 146 sizeX = definition.sizeX; 149 147 sizeY = definition.sizeY; 150 148 } 151 - scene.addEntityB(x, y, z, drawHeight, rotation, sizeY, sizeX, hash, renderable, config 152 - ); 149 + scene.addEntityB(x, y, z, drawHeight, rotation, sizeY, sizeX, hash, renderable, config); 153 150 } 154 - if (definition.solid) 155 - collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x 156 - ); 157 - } else if (type >= 12) { 151 + if(definition.solid) 152 + collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x); 153 + } else if(type >= 12) { 158 154 Renderable renderable; 159 - if (definition.animationId == -1 && definition.childrenIds == null) 155 + if(definition.animationId == -1 && definition.childrenIds == null) 160 156 renderable = definition.getGameObjectModel(type, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 161 157 else 162 - renderable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 163 - true); 158 + renderable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 164 159 scene.addEntityB(x, y, z, drawHeight, 0, 1, 1, hash, renderable, config); 165 - if (definition.solid) 166 - collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x 167 - ); 168 - } else if (type == 0) { 160 + if(definition.solid) 161 + collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x); 162 + } else if(type == 0) { 169 163 Renderable renderable; 170 - if (definition.animationId == -1 && definition.childrenIds == null) 164 + if(definition.animationId == -1 && definition.childrenIds == null) 171 165 renderable = definition.getGameObjectModel(0, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 172 166 else 173 - renderable = new GameObject(objectId, face, 0, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 174 - true); 175 - scene.addWall(x, y, z, drawHeight, POWERS_OF_TWO[face], 0, hash, renderable, null, config 176 - ); 177 - if (definition.solid) 167 + renderable = new GameObject(objectId, face, 0, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 168 + scene.addWall(x, y, z, drawHeight, POWERS_OF_TWO[face], 0, hash, renderable, null, config); 169 + if(definition.solid) 178 170 collisionMap.markWall(x, y, type, face, definition.walkable); 179 - } else if (type == 1) { 171 + } else if(type == 1) { 180 172 Renderable renderable; 181 - if (definition.animationId == -1 && definition.childrenIds == null) 173 + if(definition.animationId == -1 && definition.childrenIds == null) 182 174 renderable = definition.getGameObjectModel(1, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 183 175 else 184 - renderable = new GameObject(objectId, face, 1, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 185 - true); 186 - scene.addWall(x, y, z, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, config 187 - ); 188 - if (definition.solid) 176 + renderable = new GameObject(objectId, face, 1, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 177 + scene.addWall(x, y, z, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, config); 178 + if(definition.solid) 189 179 collisionMap.markWall(x, y, type, face, definition.walkable); 190 - } else if (type == 2) { 180 + } else if(type == 2) { 191 181 int _face = face + 1 & 0x3; 192 182 Renderable renderable; 193 183 Renderable renderable1; 194 - if (definition.animationId == -1 && definition.childrenIds == null) { 184 + if(definition.animationId == -1 && definition.childrenIds == null) { 195 185 renderable = definition.getGameObjectModel(2, 4 + face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 196 186 renderable1 = definition.getGameObjectModel(2, _face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 197 187 } else { 198 - renderable = new GameObject(objectId, 4 + face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 199 - true); 200 - renderable1 = new GameObject(objectId, _face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 201 - true); 188 + renderable = new GameObject(objectId, 4 + face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 189 + renderable1 = new GameObject(objectId, _face, 2, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 202 190 } 203 - scene.addWall(x, y, z, drawHeight, POWERS_OF_TWO[face], POWERS_OF_TWO[_face], hash, renderable, renderable1, config 204 - ); 205 - if (definition.solid) 191 + scene.addWall(x, y, z, drawHeight, POWERS_OF_TWO[face], POWERS_OF_TWO[_face], hash, renderable, renderable1, config); 192 + if(definition.solid) 206 193 collisionMap.markWall(x, y, type, face, definition.walkable); 207 - } else if (type == 3) { 194 + } else if(type == 3) { 208 195 Renderable renderable; 209 - if (definition.animationId == -1 && definition.childrenIds == null) 196 + if(definition.animationId == -1 && definition.childrenIds == null) 210 197 renderable = definition.getGameObjectModel(3, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 211 198 else 212 - renderable = new GameObject(objectId, face, 3, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 213 - true); 214 - scene.addWall(x, y, z, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, config 215 - ); 216 - if (definition.solid) 199 + renderable = new GameObject(objectId, face, 3, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 200 + scene.addWall(x, y, z, drawHeight, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, config); 201 + if(definition.solid) 217 202 collisionMap.markWall(x, y, type, face, definition.walkable); 218 - } else if (type == 9) { 203 + } else if(type == 9) { 219 204 Renderable renderable; 220 - if (definition.animationId == -1 && definition.childrenIds == null) 205 + if(definition.animationId == -1 && definition.childrenIds == null) 221 206 renderable = definition.getGameObjectModel(type, face, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 222 207 else 223 - renderable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 224 - true); 208 + renderable = new GameObject(objectId, face, type, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 225 209 scene.addEntityB(x, y, z, drawHeight, 0, 1, 1, hash, renderable, config); 226 - if (definition.solid) 227 - collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x 228 - ); 210 + if(definition.solid) 211 + collisionMap.markSolidOccupant(y, face, definition.sizeY, definition.sizeX, definition.walkable, x); 229 212 } else { 230 - if (definition.adjustToTerrain) { 231 - if (face == 1) { 213 + if(definition.adjustToTerrain) { 214 + if(face == 1) { 232 215 int temp = vertexHeightNW; 233 216 vertexHeightNW = vertexHeightNE; 234 217 vertexHeightNE = vertexHeightSE; 235 218 vertexHeightSE = vertexHeightSW; 236 219 vertexHeightSW = temp; 237 - } else if (face == 2) { 220 + } else if(face == 2) { 238 221 int temp = vertexHeightNW; 239 222 vertexHeightNW = vertexHeightSE; 240 223 vertexHeightSE = temp; 241 224 temp = vertexHeightNE; 242 225 vertexHeightNE = vertexHeightSW; 243 226 vertexHeightSW = temp; 244 - } else if (face == 3) { 227 + } else if(face == 3) { 245 228 int temp = vertexHeightNW; 246 229 vertexHeightNW = vertexHeightSW; 247 230 vertexHeightSW = vertexHeightSE; ··· 249 232 vertexHeightNE = temp; 250 233 } 251 234 } 252 - if (type == 4) { 235 + if(type == 4) { 253 236 Renderable renderable; 254 - if (definition.animationId == -1 && definition.childrenIds == null) 237 + if(definition.animationId == -1 && definition.childrenIds == null) 255 238 renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 256 239 else 257 - renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 258 - true); 259 - scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face * 512, hash, renderable, config, POWERS_OF_TWO[face] 260 - ); 261 - } else if (type == 5) { 240 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 241 + scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face * 512, hash, renderable, config, POWERS_OF_TWO[face]); 242 + } else if(type == 5) { 262 243 int offsetAmplifier = 16; 263 244 int objectHash = scene.getWallObjectHash(x, y, z); 264 - if (objectHash > 0) 245 + if(objectHash > 0) 265 246 offsetAmplifier = GameObjectDefinition.getDefinition(objectHash >> 14 & 0x7fff).offsetAmplifier; 266 247 Renderable renderable; 267 - if (definition.animationId == -1 && definition.childrenIds == null) 248 + if(definition.animationId == -1 && definition.childrenIds == null) 268 249 renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 269 250 else 270 - renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 271 - true); 272 - 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] 273 - ); 274 - } else if (type == 6) { 251 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 252 + 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]); 253 + } else if(type == 6) { 275 254 Renderable renderable; 276 - if (definition.animationId == -1 && definition.childrenIds == null) 255 + if(definition.animationId == -1 && definition.childrenIds == null) 277 256 renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 278 257 else 279 - renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 280 - true); 281 - scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 256 282 - ); 283 - } else if (type == 7) { 258 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 259 + scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 256); 260 + } else if(type == 7) { 284 261 Renderable renderable; 285 - if (definition.animationId == -1 && definition.childrenIds == null) 262 + if(definition.animationId == -1 && definition.childrenIds == null) 286 263 renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 287 264 else 288 - renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 289 - true); 290 - scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 512 291 - ); 292 - } else if (type == 8) { 265 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 266 + scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 512); 267 + } else if(type == 8) { 293 268 Renderable renderable; 294 - if (definition.animationId == -1 && definition.childrenIds == null) 269 + if(definition.animationId == -1 && definition.childrenIds == null) 295 270 renderable = definition.getGameObjectModel(4, 0, vertexHeightSW, vertexHeightSE, vertexHeightNE, vertexHeightNW, -1); 296 271 else 297 - renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, 298 - true); 299 - scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 768 300 - ); 272 + renderable = new GameObject(objectId, 0, 4, vertexHeightSE, vertexHeightNE, vertexHeightSW, vertexHeightNW, definition.animationId, true); 273 + scene.addWallDecoration(x, y, z, drawHeight, 0, 0, face, hash, renderable, config, 768); 301 274 } 302 275 } 303 276 } 304 277 305 278 public void method166(int i_39_, int i_40_, int i_41_) { 306 - for (int i_42_ = 0; i_42_ < 8; i_42_++) { 307 - for (int i_43_ = 0; i_43_ < 8; i_43_++) 279 + for(int i_42_ = 0; i_42_ < 8; i_42_++) { 280 + for(int i_43_ = 0; i_43_ < 8; i_43_++) 308 281 tile_height[i_39_][i_41_ + i_42_][i_40_ + i_43_] = 0; 309 282 } 310 - if (i_41_ > 0) { 311 - for (int i_44_ = 1; i_44_ < 8; i_44_++) 312 - tile_height[i_39_][i_41_][i_40_ + i_44_] = tile_height[i_39_][i_41_ - 1][i_40_ 313 - + i_44_]; 283 + if(i_41_ > 0) { 284 + for(int i_44_ = 1; i_44_ < 8; i_44_++) 285 + tile_height[i_39_][i_41_][i_40_ + i_44_] = tile_height[i_39_][i_41_ - 1][i_40_ + i_44_]; 314 286 } 315 - if (i_40_ > 0) { 316 - for (int i_45_ = 1; i_45_ < 8; i_45_++) 287 + if(i_40_ > 0) { 288 + for(int i_45_ = 1; i_45_ < 8; i_45_++) 317 289 tile_height[i_39_][i_41_ + i_45_][i_40_] = tile_height[i_39_][i_41_ + i_45_][i_40_ - 1]; 318 290 } 319 - if (i_41_ > 0 && tile_height[i_39_][i_41_ - 1][i_40_] != 0) 291 + if(i_41_ > 0 && tile_height[i_39_][i_41_ - 1][i_40_] != 0) 320 292 tile_height[i_39_][i_41_][i_40_] = tile_height[i_39_][i_41_ - 1][i_40_]; 321 - else if (i_40_ > 0 && tile_height[i_39_][i_41_][i_40_ - 1] != 0) 293 + else if(i_40_ > 0 && tile_height[i_39_][i_41_][i_40_ - 1] != 0) 322 294 tile_height[i_39_][i_41_][i_40_] = tile_height[i_39_][i_41_][i_40_ - 1]; 323 - else if (i_41_ > 0 && i_40_ > 0 && tile_height[i_39_][i_41_ - 1][i_40_ - 1] != 0) 295 + else if(i_41_ > 0 && i_40_ > 0 && tile_height[i_39_][i_41_ - 1][i_40_ - 1] != 0) 324 296 tile_height[i_39_][i_41_][i_40_] = tile_height[i_39_][i_41_ - 1][i_40_ - 1]; 325 297 } 326 298 327 299 public void addTiles(CollisionMap[] collisionMaps, Scene scene, int render_mode) { 328 - for (int tile_y = 0; tile_y < 4; tile_y++) { 329 - for (int tile_x = 0; tile_x < 104; tile_x++) { 330 - for (int tile_z = 0; tile_z < 104; tile_z++) { 331 - if ((tile_flags[tile_y][tile_x][tile_z] & 0x1) == 1) { 300 + for(int tile_y = 0; tile_y < 4; tile_y++) { 301 + for(int tile_x = 0; tile_x < 104; tile_x++) { 302 + for(int tile_z = 0; tile_z < 104; tile_z++) { 303 + if((tile_flags[tile_y][tile_x][tile_z] & 0x1) == 1) { 332 304 int originalPlane = tile_y; 333 - if ((tile_flags[1][tile_x][tile_z] & 0x2) == 2) 305 + if((tile_flags[1][tile_x][tile_z] & 0x2) == 2) 334 306 originalPlane--; 335 - if (originalPlane >= 0) 307 + if(originalPlane >= 0) 336 308 collisionMaps[originalPlane].markBlocked(tile_x, tile_z); 337 309 } 338 310 } 339 311 } 340 312 } 341 313 hue_offset += (int) (Math.random() * 5.0) - 2; 342 - if (hue_offset < -8) 314 + if(hue_offset < -8) 343 315 hue_offset = -8; 344 - if (hue_offset > 8) 316 + if(hue_offset > 8) 345 317 hue_offset = 8; 346 318 lightness_offset += (int) (Math.random() * 5.0) - 2; 347 - if (lightness_offset < -16) 319 + if(lightness_offset < -16) 348 320 lightness_offset = -16; 349 - if (lightness_offset > 16) 321 + if(lightness_offset > 16) 350 322 lightness_offset = 16; 351 - for (int plane = 0; plane < 4; plane++) { 323 + for(int plane = 0; plane < 4; plane++) { 352 324 byte[][] shadowIntensity = object_shadow_data[plane]; 353 325 int light_off = 96; 354 326 char specularDistributionFactor = '\u0300'; ··· 357 329 int directionalLightZ = -50; 358 330 int directionalLightLength = (int) Math.sqrt((directionalLightX * directionalLightX + directionalLightY * directionalLightY + directionalLightZ * directionalLightZ)); 359 331 int specularDistribution = specularDistributionFactor * directionalLightLength >> 8; 360 - for (int y = 1; y < size_z - 1; y++) { 361 - for (int x = 1; x < size_x - 1; x++) { 332 + for(int y = 1; y < size_z - 1; y++) { 333 + for(int x = 1; x < size_x - 1; x++) { 362 334 int xHeightDifference = (tile_height[plane][x + 1][y] - tile_height[plane][x - 1][y]); 363 335 int yHeightDifference = (tile_height[plane][x][y + 1] - tile_height[plane][x][y - 1]); 364 336 int normalizedLength = (int) Math.sqrt((xHeightDifference * xHeightDifference + 65536 + yHeightDifference * yHeightDifference)); ··· 366 338 int normalizedNormalY = 65536 / normalizedLength; 367 339 int normalizedNormalZ = (yHeightDifference << 8) / normalizedLength; 368 340 int directionalLightIntensity = light_off + (directionalLightX * normalizedNormalX + directionalLightY * normalizedNormalY + directionalLightZ * normalizedNormalZ) / specularDistribution; 369 - int weightedShadowIntensity = ((shadowIntensity[x - 1][y] >> 2) + (shadowIntensity[x + 1][y] >> 3) 370 - + (shadowIntensity[x][y - 1] >> 2) + (shadowIntensity[x][y + 1] >> 3) + (shadowIntensity[x][y] >> 1)); 341 + int weightedShadowIntensity = ((shadowIntensity[x - 1][y] >> 2) + (shadowIntensity[x + 1][y] >> 3) + (shadowIntensity[x][y - 1] >> 2) + (shadowIntensity[x][y + 1] >> 3) + (shadowIntensity[x][y] >> 1)); 371 342 tile_lightness[x][y] = directionalLightIntensity - weightedShadowIntensity; 372 343 } 373 344 } 374 - for (int y = 0; y < size_z; y++) { 345 + for(int y = 0; y < size_z; y++) { 375 346 hue_buffer[y] = 0; 376 347 saturation_buffer[y] = 0; 377 348 lightness_buffer[y] = 0; 378 349 huedivider[y] = 0; 379 350 buffer_size[y] = 0; 380 351 } 381 - for (int x = -5; x < size_x + 5; x++) { 382 - for (int y = 0; y < size_z; y++) { 352 + for(int x = -5; x < size_x + 5; x++) { 353 + for(int y = 0; y < size_z; y++) { 383 354 int xPositiveOffset = x + 5; 384 - if (xPositiveOffset >= 0 && xPositiveOffset < size_x) { 355 + if(xPositiveOffset >= 0 && xPositiveOffset < size_x) { 385 356 int floorId = underlayFloorIds[plane][xPositiveOffset][y] & 0xff; 386 - if (floorId > 0) { 357 + if(floorId > 0) { 387 358 FloorDefinition floor = FloorDefinition.cache[floorId - 1]; 388 359 hue_buffer[y] += floor.hue; 389 360 saturation_buffer[y] += floor.saturation; ··· 393 364 } 394 365 } 395 366 int xNegativeOffset = x - 5; 396 - if (xNegativeOffset >= 0 && xNegativeOffset < size_x) { 367 + if(xNegativeOffset >= 0 && xNegativeOffset < size_x) { 397 368 int floorId = underlayFloorIds[plane][xNegativeOffset][y] & 0xff; 398 - if (floorId > 0) { 369 + if(floorId > 0) { 399 370 FloorDefinition floor = FloorDefinition.cache[floorId - 1]; 400 371 hue_buffer[y] -= floor.hue; 401 372 saturation_buffer[y] -= floor.saturation; ··· 405 376 } 406 377 } 407 378 } 408 - if (x >= 1 && x < size_x - 1) { 379 + if(x >= 1 && x < size_x - 1) { 409 380 int i_75_ = 0; 410 381 int i_76_ = 0; 411 382 int i_77_ = 0; 412 383 int i_78_ = 0; 413 384 int i_79_ = 0; 414 - for (int y = -5; y < size_z + 5; y++) { 385 + for(int y = -5; y < size_z + 5; y++) { 415 386 int yPositiveOffset = y + 5; 416 - if (yPositiveOffset >= 0 && yPositiveOffset < size_z) { 387 + if(yPositiveOffset >= 0 && yPositiveOffset < size_z) { 417 388 i_75_ += hue_buffer[yPositiveOffset]; 418 389 i_76_ += saturation_buffer[yPositiveOffset]; 419 390 i_77_ += lightness_buffer[yPositiveOffset]; ··· 421 392 i_79_ += buffer_size[yPositiveOffset]; 422 393 } 423 394 int yNegativeOffset = y - 5; 424 - if (yNegativeOffset >= 0 && yNegativeOffset < size_z) { 395 + if(yNegativeOffset >= 0 && yNegativeOffset < size_z) { 425 396 i_75_ -= hue_buffer[yNegativeOffset]; 426 397 i_76_ -= saturation_buffer[yNegativeOffset]; 427 398 i_77_ -= lightness_buffer[yNegativeOffset]; 428 399 i_78_ -= huedivider[yNegativeOffset]; 429 400 i_79_ -= buffer_size[yNegativeOffset]; 430 401 } 431 - if (y >= 1 432 - && y < size_z - 1 433 - && (!lowMemory || (tile_flags[0][x][y] & 0x2) != 0 || ((tile_flags[plane][x][y] & 0x10) == 0 && (getVisibilityPlaneFor( 434 - x, y, plane) == onBuildTimePlane)))) { 435 - if (plane < setZ) 402 + if(y >= 1 && y < size_z - 1 && (!lowMemory || (tile_flags[0][x][y] & 0x2) != 0 || ((tile_flags[plane][x][y] & 0x10) == 0 && (getVisibilityPlaneFor(x, y, plane) == onBuildTimePlane)))) { 403 + if(plane < setZ) 436 404 setZ = plane; 437 405 int underlayFloorId = (underlayFloorIds[plane][x][y] & 0xff); 438 406 int overlayFloorId = (overlayFloorIds[plane][x][y] & 0xff); 439 - if (underlayFloorId > 0 || overlayFloorId > 0) { 407 + if(underlayFloorId > 0 || overlayFloorId > 0) { 440 408 int vertexSouthWest = tile_height[plane][x][y]; 441 409 int vertexSouthEast = (tile_height[plane][x + 1][y]); 442 410 int vertexNorthEast = (tile_height[plane][x + 1][y + 1]); ··· 447 415 int lightNorthWest = tile_lightness[x][y + 1]; 448 416 int hslBitsetUnmodified = -1; 449 417 int hslBitsetRandomized = -1; 450 - if (underlayFloorId > 0) { 418 + if(underlayFloorId > 0) { 451 419 int hue = i_75_ * 256 / i_78_; 452 420 int saturation = i_76_ / i_79_; 453 421 int lightness = i_77_ / i_79_; 454 422 hslBitsetUnmodified = getHSLBitset(hue, saturation, lightness); 455 423 hue = hue + hue_offset & 0xff; 456 424 lightness += lightness_offset; 457 - if (lightness < 0) 425 + if(lightness < 0) 458 426 lightness = 0; 459 - else if (lightness > 255) 427 + else if(lightness > 255) 460 428 lightness = 255; 461 429 hslBitsetRandomized = getHSLBitset(hue, saturation, lightness); 462 430 } 463 - if (plane > 0) { 431 + if(plane > 0) { 464 432 boolean bool = true; 465 - if (underlayFloorId == 0 && (overlayClippingPaths[plane][x][y]) != 0) 433 + if(underlayFloorId == 0 && (overlayClippingPaths[plane][x][y]) != 0) 466 434 bool = false; 467 - if (overlayFloorId > 0 && !(FloorDefinition.cache[overlayFloorId - 1].occlude)) 435 + if(overlayFloorId > 0 && !(FloorDefinition.cache[overlayFloorId - 1].occlude)) 468 436 bool = false; 469 - if (bool && vertexSouthWest == vertexSouthEast && vertexSouthWest == vertexNorthEast && vertexSouthWest == vertexNorthWest) 437 + if(bool && vertexSouthWest == vertexSouthEast && vertexSouthWest == vertexNorthEast && vertexSouthWest == vertexNorthWest) 470 438 tile_culling_bitmap[plane][x][y] |= 0x924; 471 439 } 472 440 int rgbBitsetRandomized = 0; 473 - if (hslBitsetUnmodified != -1) 441 + if(hslBitsetUnmodified != -1) 474 442 rgbBitsetRandomized = (Rasterizer3D.hsl2rgb[trimHSLLightness(hslBitsetRandomized, 96)]); 475 - if (overlayFloorId == 0) 476 - scene.addTile(plane, x, y, 0, 0, -1, vertexSouthWest, vertexSouthEast, vertexNorthEast, vertexNorthWest, 477 - trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthEast), 478 - trimHSLLightness(hslBitsetUnmodified, lightNorthWest), 0, 0, 0, 0, rgbBitsetRandomized, 0); 443 + if(overlayFloorId == 0) 444 + scene.addTile(plane, x, y, 0, 0, -1, vertexSouthWest, vertexSouthEast, vertexNorthEast, vertexNorthWest, trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthWest), 0, 0, 0, 0, rgbBitsetRandomized, 0); 479 445 else { 480 446 int clippingPath = ((overlayClippingPaths[plane][x][y]) + 1); 481 447 byte clippingPathRotation = (overlayRotations[plane][x][y]); ··· 483 449 int textureid = floor.textureId; 484 450 int hslBitset; 485 451 int rgbBitset; 486 - if (textureid >= 0) { 452 + if(textureid >= 0) { 487 453 rgbBitset = Rasterizer3D.getAverageRgbColorForTexture(textureid); 488 454 hslBitset = -1; 489 455 490 - } else if (floor.rgbColor == 0xff00ff) { 456 + } else if(floor.rgbColor == 0xff00ff) { 491 457 hslBitset = -2; 492 458 textureid = -1; 493 459 rgbBitset = 0; ··· 496 462 rgbBitset = (Rasterizer3D.hsl2rgb[mixLightnessSigned(floor.hslColor2, 96)]); 497 463 498 464 } 499 - scene.addTile(plane, x, y, clippingPath, clippingPathRotation, textureid, vertexSouthWest, vertexSouthEast, vertexNorthEast, 500 - vertexNorthWest, trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, 501 - lightNorthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthWest), mixLightnessSigned(hslBitset, lightSouthWest), 502 - mixLightnessSigned(hslBitset, lightSouthEast), mixLightnessSigned(hslBitset, lightNorthEast), 503 - mixLightnessSigned(hslBitset, lightNorthWest), rgbBitsetRandomized, rgbBitset); 465 + scene.addTile(plane, x, y, clippingPath, clippingPathRotation, textureid, vertexSouthWest, vertexSouthEast, vertexNorthEast, vertexNorthWest, trimHSLLightness(hslBitsetUnmodified, lightSouthWest), trimHSLLightness(hslBitsetUnmodified, lightSouthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthEast), trimHSLLightness(hslBitsetUnmodified, lightNorthWest), mixLightnessSigned(hslBitset, lightSouthWest), mixLightnessSigned(hslBitset, lightSouthEast), mixLightnessSigned(hslBitset, lightNorthEast), mixLightnessSigned(hslBitset, lightNorthWest), rgbBitsetRandomized, rgbBitset); 504 466 } 505 467 } 506 468 } 507 469 } 508 470 } 509 471 } 510 - for (int i_104_ = 1; i_104_ < size_z - 1; i_104_++) { 511 - for (int i_105_ = 1; i_105_ < size_x - 1; i_105_++) 472 + for(int i_104_ = 1; i_104_ < size_z - 1; i_104_++) { 473 + for(int i_105_ = 1; i_105_ < size_x - 1; i_105_++) 512 474 scene.setTileLogicHeight(plane, i_105_, i_104_, getVisibilityPlaneFor(i_105_, i_104_, plane)); 513 475 } 514 476 } 515 477 scene.shadeModels(-10, -50, -50); 516 - for (int y = 0; y < size_x; y++) { 517 - for (int x = 0; x < size_z; x++) { 518 - if ((tile_flags[1][y][x] & 0x2) == 2) 478 + for(int y = 0; y < size_x; y++) { 479 + for(int x = 0; x < size_z; x++) { 480 + if((tile_flags[1][y][x] & 0x2) == 2) 519 481 scene.setBridgeMode(y, x); 520 482 } 521 483 } 522 484 int renderRule1 = 1; 523 485 int renderRule2 = 2; 524 486 int renderRule3 = 4; 525 - for (int currentPlane = 0; currentPlane < 4; currentPlane++) { 526 - if (currentPlane > 0) { 487 + for(int currentPlane = 0; currentPlane < 4; currentPlane++) { 488 + if(currentPlane > 0) { 527 489 renderRule1 <<= 3; 528 490 renderRule2 <<= 3; 529 491 renderRule3 <<= 3; 530 492 } 531 - for (int plane = 0; plane <= currentPlane; plane++) { 532 - for (int y = 0; y <= size_z; y++) { 533 - for (int x = 0; x <= size_x; x++) { 534 - if ((tile_culling_bitmap[plane][x][y] & renderRule1) != 0) { 493 + for(int plane = 0; plane <= currentPlane; plane++) { 494 + for(int y = 0; y <= size_z; y++) { 495 + for(int x = 0; x <= size_x; x++) { 496 + if((tile_culling_bitmap[plane][x][y] & renderRule1) != 0) { 535 497 int lowestOcclussionY = y; 536 498 int higestOcclussionY = y; 537 499 int lowestOcclussionPlane = plane; 538 500 int higestOcclussionPlane = plane; 539 - for (/**/; lowestOcclussionY > 0; lowestOcclussionY--) { 540 - if (((tile_culling_bitmap[plane][x][lowestOcclussionY - 1]) & renderRule1) == 0) 501 + for(/**/; lowestOcclussionY > 0; lowestOcclussionY--) { 502 + if(((tile_culling_bitmap[plane][x][lowestOcclussionY - 1]) & renderRule1) == 0) 541 503 break; 542 504 } 543 - for (/**/; higestOcclussionY < size_z; higestOcclussionY++) { 544 - if (((tile_culling_bitmap[plane][x][higestOcclussionY + 1]) & renderRule1) == 0) 505 + for(/**/; higestOcclussionY < size_z; higestOcclussionY++) { 506 + if(((tile_culling_bitmap[plane][x][higestOcclussionY + 1]) & renderRule1) == 0) 545 507 break; 546 508 } 547 509 while_0_: 548 - for (/**/; lowestOcclussionPlane > 0; lowestOcclussionPlane--) { 549 - for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) { 550 - if (((tile_culling_bitmap[lowestOcclussionPlane - 1][x][occludedY]) & renderRule1) == 0) 510 + for(/**/; lowestOcclussionPlane > 0; lowestOcclussionPlane--) { 511 + for(int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) { 512 + if(((tile_culling_bitmap[lowestOcclussionPlane - 1][x][occludedY]) & renderRule1) == 0) 551 513 break while_0_; 552 514 } 553 515 } 554 516 while_1_: 555 - for (/**/; higestOcclussionPlane < currentPlane; higestOcclussionPlane++) { 556 - for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) { 557 - if (((tile_culling_bitmap[higestOcclussionPlane + 1][x][occludedY]) & renderRule1) == 0) 517 + for(/**/; higestOcclussionPlane < currentPlane; higestOcclussionPlane++) { 518 + for(int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) { 519 + if(((tile_culling_bitmap[higestOcclussionPlane + 1][x][occludedY]) & renderRule1) == 0) 558 520 break while_1_; 559 521 } 560 522 } 561 523 int occlussionSurface = (higestOcclussionPlane + 1 - lowestOcclussionPlane) * (higestOcclussionY - lowestOcclussionY + 1); 562 - if (occlussionSurface >= 8) { 524 + if(occlussionSurface >= 8) { 563 525 int highestOcclussionVertexHeightOffset = 240; 564 526 int highestOcclussionVertexHeight = ((tile_height[higestOcclussionPlane][x][lowestOcclussionY]) - highestOcclussionVertexHeightOffset); 565 527 int lowestOcclussionVertexHeight = (tile_height[lowestOcclussionPlane][x][lowestOcclussionY]); 566 - Scene.createCullingCluster(currentPlane, x * 128, x * 128, higestOcclussionY * 128 + 128, lowestOcclussionY * 128, highestOcclussionVertexHeight, lowestOcclussionVertexHeight, 567 - 1); 568 - for (int occludedPlane = lowestOcclussionPlane; occludedPlane <= higestOcclussionPlane; occludedPlane++) { 569 - for (int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) 528 + Scene.createCullingCluster(currentPlane, x * 128, x * 128, higestOcclussionY * 128 + 128, lowestOcclussionY * 128, highestOcclussionVertexHeight, lowestOcclussionVertexHeight, 1); 529 + for(int occludedPlane = lowestOcclussionPlane; occludedPlane <= higestOcclussionPlane; occludedPlane++) { 530 + for(int occludedY = lowestOcclussionY; occludedY <= higestOcclussionY; occludedY++) 570 531 tile_culling_bitmap[occludedPlane][x][occludedY] &= renderRule1 ^ 0xffffffff; 571 532 } 572 533 } 573 534 } 574 - if ((tile_culling_bitmap[plane][x][y] & renderRule2) != 0) { 535 + if((tile_culling_bitmap[plane][x][y] & renderRule2) != 0) { 575 536 int i_127_ = x; 576 537 int i_128_ = x; 577 538 int i_129_ = plane; 578 539 int i_130_ = plane; 579 - for (/**/; i_127_ > 0; i_127_--) { 580 - if (((tile_culling_bitmap[plane][i_127_ - 1][y]) & renderRule2) == 0) 540 + for(/**/; i_127_ > 0; i_127_--) { 541 + if(((tile_culling_bitmap[plane][i_127_ - 1][y]) & renderRule2) == 0) 581 542 break; 582 543 } 583 - for (/**/; i_128_ < size_x; i_128_++) { 584 - if (((tile_culling_bitmap[plane][i_128_ + 1][y]) & renderRule2) == 0) 544 + for(/**/; i_128_ < size_x; i_128_++) { 545 + if(((tile_culling_bitmap[plane][i_128_ + 1][y]) & renderRule2) == 0) 585 546 break; 586 547 } 587 548 while_2_: 588 - for (/**/; i_129_ > 0; i_129_--) { 589 - for (int i_131_ = i_127_; i_131_ <= i_128_; i_131_++) { 590 - if (((tile_culling_bitmap[i_129_ - 1][i_131_][y]) & renderRule2) == 0) 549 + for(/**/; i_129_ > 0; i_129_--) { 550 + for(int i_131_ = i_127_; i_131_ <= i_128_; i_131_++) { 551 + if(((tile_culling_bitmap[i_129_ - 1][i_131_][y]) & renderRule2) == 0) 591 552 break while_2_; 592 553 } 593 554 } 594 555 while_3_: 595 - for (/**/; i_130_ < currentPlane; i_130_++) { 596 - for (int i_132_ = i_127_; i_132_ <= i_128_; i_132_++) { 597 - if (((tile_culling_bitmap[i_130_ + 1][i_132_][y]) & renderRule2) == 0) 556 + for(/**/; i_130_ < currentPlane; i_130_++) { 557 + for(int i_132_ = i_127_; i_132_ <= i_128_; i_132_++) { 558 + if(((tile_culling_bitmap[i_130_ + 1][i_132_][y]) & renderRule2) == 0) 598 559 break while_3_; 599 560 } 600 561 } 601 562 int i_133_ = (i_130_ + 1 - i_129_) * (i_128_ - i_127_ + 1); 602 - if (i_133_ >= 8) { 563 + if(i_133_ >= 8) { 603 564 int i_134_ = 240; 604 565 int i_135_ = ((tile_height[i_130_][i_127_][y]) - i_134_); 605 566 int i_136_ = (tile_height[i_129_][i_127_][y]); 606 - Scene.createCullingCluster(currentPlane, i_128_ * 128 + 128, i_127_ * 128, y * 128, y * 128, i_135_, i_136_, 607 - 2); 608 - for (int i_137_ = i_129_; i_137_ <= i_130_; i_137_++) { 609 - for (int i_138_ = i_127_; i_138_ <= i_128_; i_138_++) 567 + Scene.createCullingCluster(currentPlane, i_128_ * 128 + 128, i_127_ * 128, y * 128, y * 128, i_135_, i_136_, 2); 568 + for(int i_137_ = i_129_; i_137_ <= i_130_; i_137_++) { 569 + for(int i_138_ = i_127_; i_138_ <= i_128_; i_138_++) 610 570 tile_culling_bitmap[i_137_][i_138_][y] &= renderRule2 ^ 0xffffffff; 611 571 } 612 572 } 613 573 } 614 - if ((tile_culling_bitmap[plane][x][y] & renderRule3) != 0) { 574 + if((tile_culling_bitmap[plane][x][y] & renderRule3) != 0) { 615 575 int i_139_ = x; 616 576 int i_140_ = x; 617 577 int i_141_ = y; 618 578 int i_142_ = y; 619 - for (/**/; i_141_ > 0; i_141_--) { 620 - if (((tile_culling_bitmap[plane][x][i_141_ - 1]) & renderRule3) == 0) 579 + for(/**/; i_141_ > 0; i_141_--) { 580 + if(((tile_culling_bitmap[plane][x][i_141_ - 1]) & renderRule3) == 0) 621 581 break; 622 582 } 623 - for (/**/; i_142_ < size_z; i_142_++) { 624 - if (((tile_culling_bitmap[plane][x][i_142_ + 1]) & renderRule3) == 0) 583 + for(/**/; i_142_ < size_z; i_142_++) { 584 + if(((tile_culling_bitmap[plane][x][i_142_ + 1]) & renderRule3) == 0) 625 585 break; 626 586 } 627 587 while_4_: 628 - for (/**/; i_139_ > 0; i_139_--) { 629 - for (int i_143_ = i_141_; i_143_ <= i_142_; i_143_++) { 630 - if (((tile_culling_bitmap[plane][i_139_ - 1][i_143_]) & renderRule3) == 0) 588 + for(/**/; i_139_ > 0; i_139_--) { 589 + for(int i_143_ = i_141_; i_143_ <= i_142_; i_143_++) { 590 + if(((tile_culling_bitmap[plane][i_139_ - 1][i_143_]) & renderRule3) == 0) 631 591 break while_4_; 632 592 } 633 593 } 634 594 while_5_: 635 - for (/**/; i_140_ < size_x; i_140_++) { 636 - for (int i_144_ = i_141_; i_144_ <= i_142_; i_144_++) { 637 - if (((tile_culling_bitmap[plane][i_140_ + 1][i_144_]) & renderRule3) == 0) 595 + for(/**/; i_140_ < size_x; i_140_++) { 596 + for(int i_144_ = i_141_; i_144_ <= i_142_; i_144_++) { 597 + if(((tile_culling_bitmap[plane][i_140_ + 1][i_144_]) & renderRule3) == 0) 638 598 break while_5_; 639 599 } 640 600 } 641 - if ((i_140_ - i_139_ + 1) * (i_142_ - i_141_ + 1) >= 4) { 601 + if((i_140_ - i_139_ + 1) * (i_142_ - i_141_ + 1) >= 4) { 642 602 int i_145_ = (tile_height[plane][i_139_][i_141_]); 643 - Scene.createCullingCluster(currentPlane, i_140_ * 128 + 128, i_139_ * 128, i_142_ * 128 + 128, i_141_ * 128, i_145_, i_145_, 644 - 4); 645 - for (int i_146_ = i_139_; i_146_ <= i_140_; i_146_++) { 646 - for (int i_147_ = i_141_; i_147_ <= i_142_; i_147_++) 603 + Scene.createCullingCluster(currentPlane, i_140_ * 128 + 128, i_139_ * 128, i_142_ * 128 + 128, i_141_ * 128, i_145_, i_145_, 4); 604 + for(int i_146_ = i_139_; i_146_ <= i_140_; i_146_++) { 605 + for(int i_147_ = i_141_; i_147_ <= i_142_; i_147_++) 647 606 tile_culling_bitmap[plane][i_146_][i_147_] &= renderRule3 ^ 0xffffffff; 648 607 } 649 608 } ··· 654 613 } 655 614 } 656 615 657 - public void method168(int i, int i_148_, boolean bool, byte[] is, int i_149_, int i_150_, int i_151_, 658 - CollisionMap[] class46s, int i_152_, int i_153_) { 659 - if (bool) 616 + public void method168(int i, int i_148_, boolean bool, byte[] is, int i_149_, int i_150_, int i_151_, CollisionMap[] class46s, int i_152_, int i_153_) { 617 + if(bool) 660 618 anInt166 = 476; 661 - for (int i_154_ = 0; i_154_ < 8; i_154_++) { 662 - for (int i_155_ = 0; i_155_ < 8; i_155_++) { 663 - if (i_151_ + i_154_ > 0 && i_151_ + i_154_ < 103 && i_152_ + i_155_ > 0 && i_152_ + i_155_ < 103) 619 + for(int i_154_ = 0; i_154_ < 8; i_154_++) { 620 + for(int i_155_ = 0; i_155_ < 8; i_155_++) { 621 + if(i_151_ + i_154_ > 0 && i_151_ + i_154_ < 103 && i_152_ + i_155_ > 0 && i_152_ + i_155_ < 103) 664 622 class46s[i_149_].clippingData[i_151_ + i_154_][(i_152_ + i_155_)] &= ~0x1000000; 665 623 } 666 624 } 667 625 Buffer class50_sub1_sub2 = new Buffer(is); 668 - for (int i_156_ = 0; i_156_ < 4; i_156_++) { 669 - for (int i_157_ = 0; i_157_ < 64; i_157_++) { 670 - for (int i_158_ = 0; i_158_ < 64; i_158_++) { 671 - if (i_156_ == i_150_ && i_157_ >= i_153_ && i_157_ < i_153_ + 8 && i_158_ >= i_148_ 672 - && i_158_ < i_148_ + 8) 673 - loadTerrainTile(i_151_ 674 - + TiledUtils.getRotatedMapChunkX(i_157_ & 0x7, i_158_ & 0x7, i), 0, i_152_ 675 - + TiledUtils.getRotatedMapChunkY(i_157_ & 0x7, i_158_ & 0x7, i), 0, i_149_, class50_sub1_sub2, i); 626 + for(int i_156_ = 0; i_156_ < 4; i_156_++) { 627 + for(int i_157_ = 0; i_157_ < 64; i_157_++) { 628 + for(int i_158_ = 0; i_158_ < 64; i_158_++) { 629 + if(i_156_ == i_150_ && i_157_ >= i_153_ && i_157_ < i_153_ + 8 && i_158_ >= i_148_ && i_158_ < i_148_ + 8) 630 + loadTerrainTile(i_151_ + TiledUtils.getRotatedMapChunkX(i_157_ & 0x7, i_158_ & 0x7, i), 0, i_152_ + TiledUtils.getRotatedMapChunkY(i_157_ & 0x7, i_158_ & 0x7, i), 0, i_149_, class50_sub1_sub2, i); 676 631 else 677 632 loadTerrainTile(-1, 0, -1, 0, 0, class50_sub1_sub2, 0); 678 633 } ··· 683 638 public static void passiveRequestGameObjectModels(OnDemandRequester onDemandRequester, Buffer buffer) { 684 639 685 640 int gameObjectId = -1; 686 - while (true) { 641 + while(true) { 687 642 int gameObjectIdOffset = buffer.getSmart(); 688 - if (gameObjectIdOffset == 0) 643 + if(gameObjectIdOffset == 0) 689 644 break; 690 645 gameObjectId += gameObjectIdOffset; 691 646 GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(gameObjectId); 692 647 gameObjectDefinition.passiveRequestModels(onDemandRequester); 693 - while (true) { 648 + while(true) { 694 649 int terminate = buffer.getSmart(); 695 - if (terminate == 0) 650 + if(terminate == 0) 696 651 break; 697 652 buffer.getUnsignedByte(); 698 653 } ··· 702 657 703 658 public static boolean method170(int i, int i_163_) { 704 659 GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(i_163_); 705 - if (i == 11) 660 + if(i == 11) 706 661 i = 10; 707 - if (i >= 5 && i <= 8) 662 + if(i >= 5 && i <= 8) 708 663 i = 4; 709 664 return gameObjectDefinition.method432(26261, i); 710 665 } 711 666 712 667 public static int trimHSLLightness(int i, int i_165_) { 713 - if (i == -1) 668 + if(i == -1) 714 669 return 12345678; 715 670 i_165_ = i_165_ * (i & 0x7f) / 128; 716 - if (i_165_ < 2) 671 + if(i_165_ < 2) 717 672 i_165_ = 2; 718 - else if (i_165_ > 126) 673 + else if(i_165_ > 126) 719 674 i_165_ = 126; 720 675 return (i & 0xff80) + i_165_; 721 676 } 722 677 723 - public void method172(int i, CollisionMap[] class46s, Scene class22, boolean bool, byte[] is, int i_166_, int i_167_, 724 - int i_168_, int i_169_, int i_170_, int i_171_) { 725 - Buffer class50_sub1_sub2 = new Buffer(is); 726 - if (!bool) { 727 - int i_172_ = -1; 728 - for (; ; ) { 729 - int i_173_ = class50_sub1_sub2.getSmart(); 730 - if (i_173_ == 0) 678 + public void method172(int i, CollisionMap[] collisionMaps, Scene scene, boolean bool, byte[] blockData, int i_166_, int i_167_, int i_168_, int i_169_, int i_170_, int i_171_) { 679 + Buffer buffer = new Buffer(blockData); 680 + if(!bool) { 681 + int objectId = -1; 682 + for(; ; ) { 683 + int delta_id = buffer.getSmart(); 684 + if(delta_id == 0) 731 685 break; 732 - i_172_ += i_173_; 733 - int i_174_ = 0; 734 - for (; ; ) { 735 - int i_175_ = class50_sub1_sub2.getSmart(); 736 - if (i_175_ == 0) 686 + objectId += delta_id; 687 + int pos = 0; 688 + for(; ; ) { 689 + int delta_pos = buffer.getSmart(); 690 + if(delta_pos == 0) 737 691 break; 738 - i_174_ += i_175_ - 1; 739 - int i_176_ = i_174_ & 0x3f; 740 - int i_177_ = i_174_ >> 6 & 0x3f; 741 - int i_178_ = i_174_ >> 12; 742 - int i_179_ = class50_sub1_sub2.getUnsignedByte(); 743 - int i_180_ = i_179_ >> 2; 744 - int i_181_ = i_179_ & 0x3; 745 - if (i_178_ == i_171_ && i_177_ >= i_168_ && i_177_ < i_168_ + 8 && i_176_ >= i_170_ 746 - && i_176_ < i_170_ + 8) { 747 - GameObjectDefinition class47 = GameObjectDefinition.getDefinition(i_172_); 748 - int i_182_ = (i_169_ + TiledUtils.getRotatedLandscapeChunkX(i_167_, class47.sizeY, i_177_ & 0x7, 749 - i_176_ & 0x7, class47.sizeX)); 750 - int i_183_ = (i_166_ + TiledUtils.getRotatedLandscapeChunkY(i_176_ & 0x7, class47.sizeY, i_167_, class47.sizeX, i_177_ & 0x7 751 - )); 752 - if (i_182_ > 0 && i_183_ > 0 && i_182_ < 103 && i_183_ < 103) { 753 - int i_184_ = i; 754 - if ((tile_flags[1][i_182_][i_183_] & 0x2) == 2) 755 - i_184_--; 756 - CollisionMap class46 = null; 757 - if (i_184_ >= 0) 758 - class46 = class46s[i_184_]; 759 - renderObject(class22, class46, i_183_, i, i_182_, i_181_ + i_167_ & 0x3, i_180_, 760 - i_172_); 692 + pos += delta_pos - 1; 693 + int tile_z = pos & 0x3f; 694 + int tile_x = pos >> 6 & 0x3f; 695 + int tile_y = pos >> 12; 696 + int object_info = buffer.getUnsignedByte(); 697 + int object_type = object_info >> 2; 698 + int object_orientation = object_info & 0x3; 699 + if(tile_y == i_171_ && tile_x >= i_168_ && tile_x < i_168_ + 8 && tile_z >= i_170_ && tile_z < i_170_ + 8) { 700 + GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId); 701 + int i_182_ = (i_169_ + TiledUtils.getRotatedLandscapeChunkX(i_167_, definition.sizeY, tile_x & 0x7, tile_z & 0x7, definition.sizeX)); 702 + int i_183_ = (i_166_ + TiledUtils.getRotatedLandscapeChunkY(tile_z & 0x7, definition.sizeY, i_167_, definition.sizeX, tile_x & 0x7)); 703 + if(i_182_ > 0 && i_183_ > 0 && i_182_ < 103 && i_183_ < 103) { 704 + int logic_y = i; 705 + if((tile_flags[1][i_182_][i_183_] & 0x2) == 2) 706 + logic_y--; 707 + CollisionMap collisionMap = null; 708 + if(logic_y >= 0) 709 + collisionMap = collisionMaps[logic_y]; 710 + renderObject(scene, collisionMap, i_183_, i, i_182_, object_orientation + i_167_ & 0x3, object_type, objectId); 761 711 } 762 712 } 763 713 } ··· 765 715 } 766 716 } 767 717 768 - public void renderObject(Scene scene, CollisionMap collisionMap, int y, int plane, int x, int face, 769 - int type, int objectId) { 770 - if (!lowMemory 771 - || (tile_flags[0][x][y] & 0x2) != 0 772 - || ((tile_flags[plane][x][y] & 0x10) == 0 && getVisibilityPlaneFor(x, y, plane) == onBuildTimePlane)) { 773 - if (plane < setZ) 718 + public void renderObject(Scene scene, CollisionMap collisionMap, int y, int plane, int x, int face, int type, int objectId) { 719 + if(!lowMemory || (tile_flags[0][x][y] & 0x2) != 0 || ((tile_flags[plane][x][y] & 0x10) == 0 && getVisibilityPlaneFor(x, y, plane) == onBuildTimePlane)) { 720 + if(plane < setZ) 774 721 setZ = plane; 775 722 int vertexHeight = tile_height[plane][x][y]; 776 723 int vertexHeightRight = tile_height[plane][x + 1][y]; ··· 779 726 int vertexMix = vertexHeight + vertexHeightRight + vertexHeightTopRight + vertexHeightTop >> 2; 780 727 GameObjectDefinition gameObjectDefinition = GameObjectDefinition.getDefinition(objectId); 781 728 int hash = x + (y << 7) + (objectId << 14) + 1073741824; 782 - if (!gameObjectDefinition.hasActions) 729 + if(!gameObjectDefinition.hasActions) 783 730 hash += -2147483648; 784 731 byte objectConfig = (byte) ((face << 6) + type); 785 - if (type == 22) { 786 - if (!lowMemory || gameObjectDefinition.hasActions || gameObjectDefinition.unknown) { 732 + if(type == 22) { 733 + if(!lowMemory || gameObjectDefinition.hasActions || gameObjectDefinition.unknown) { 787 734 Renderable renderable; 788 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 735 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 789 736 renderable = gameObjectDefinition.getGameObjectModel(22, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 790 737 else 791 - renderable = new GameObject(objectId, face, 22, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 792 - true); 738 + renderable = new GameObject(objectId, face, 22, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 793 739 scene.addGroundDecoration(x, y, plane, vertexMix, hash, renderable, objectConfig); 794 - if (gameObjectDefinition.solid && gameObjectDefinition.hasActions && collisionMap != null) 740 + if(gameObjectDefinition.solid && gameObjectDefinition.hasActions && collisionMap != null) 795 741 collisionMap.markBlocked(x, y); 796 742 } 797 - } else if (type == 10 || type == 11) { 743 + } else if(type == 10 || type == 11) { 798 744 Renderable renderable; 799 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 745 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 800 746 renderable = gameObjectDefinition.getGameObjectModel(10, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 801 747 else 802 - renderable = new GameObject(objectId, face, 10, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 803 - true); 804 - if (renderable != null) { 748 + renderable = new GameObject(objectId, face, 10, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 749 + if(renderable != null) { 805 750 int i_198_ = 0; 806 - if (type == 11) 751 + if(type == 11) 807 752 i_198_ += 256; 808 753 int sizeX; 809 754 int sizeY; 810 - if (face == 1 || face == 3) { 755 + if(face == 1 || face == 3) { 811 756 sizeX = gameObjectDefinition.sizeY; 812 757 sizeY = gameObjectDefinition.sizeX; 813 758 } else { 814 759 sizeX = gameObjectDefinition.sizeX; 815 760 sizeY = gameObjectDefinition.sizeY; 816 761 } 817 - if (scene.addEntityB(x, y, plane, vertexMix, i_198_, sizeY, sizeX, hash, renderable, objectConfig 818 - ) 819 - && gameObjectDefinition.castsShadow) { 762 + if(scene.addEntityB(x, y, plane, vertexMix, i_198_, sizeY, sizeX, hash, renderable, objectConfig) && gameObjectDefinition.castsShadow) { 820 763 Model model; 821 - if (renderable instanceof Model) 764 + if(renderable instanceof Model) 822 765 model = (Model) renderable; 823 766 else 824 767 model = gameObjectDefinition.getGameObjectModel(10, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 825 - if (model != null) { 826 - for (int sizeXCounter = 0; sizeXCounter <= sizeX; sizeXCounter++) { 827 - for (int sizeYCounter = 0; sizeYCounter <= sizeY; sizeYCounter++) { 768 + if(model != null) { 769 + for(int sizeXCounter = 0; sizeXCounter <= sizeX; sizeXCounter++) { 770 + for(int sizeYCounter = 0; sizeYCounter <= sizeY; sizeYCounter++) { 828 771 int shadowIntensity = model.diagonal2DAboveOrigin / 4; 829 - if (shadowIntensity > 30) 772 + if(shadowIntensity > 30) 830 773 shadowIntensity = 30; 831 - if (shadowIntensity > (object_shadow_data[plane][x + sizeXCounter][y + sizeYCounter])) 774 + if(shadowIntensity > (object_shadow_data[plane][x + sizeXCounter][y + sizeYCounter])) 832 775 object_shadow_data[plane][x + sizeXCounter][y + sizeYCounter] = (byte) shadowIntensity; 833 776 } 834 777 } 835 778 } 836 779 } 837 780 } 838 - if (gameObjectDefinition.solid && collisionMap != null) 839 - collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x 840 - ); 841 - } else if (type >= 12) { 781 + if(gameObjectDefinition.solid && collisionMap != null) 782 + collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x); 783 + } else if(type >= 12) { 842 784 Renderable renderable; 843 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 785 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 844 786 renderable = gameObjectDefinition.getGameObjectModel(type, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 845 787 else 846 - renderable = new GameObject(objectId, face, type, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 847 - true); 788 + renderable = new GameObject(objectId, face, type, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 848 789 scene.addEntityB(x, y, plane, vertexMix, 0, 1, 1, hash, renderable, objectConfig); 849 - if (type >= 12 && type <= 17 && type != 13 && plane > 0) 790 + if(type >= 12 && type <= 17 && type != 13 && plane > 0) 850 791 tile_culling_bitmap[plane][x][y] |= 0x924; 851 - if (gameObjectDefinition.solid && collisionMap != null) 852 - collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x 853 - ); 854 - } else if (type == 0) { 792 + if(gameObjectDefinition.solid && collisionMap != null) 793 + collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x); 794 + } else if(type == 0) { 855 795 Renderable renderable; 856 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 796 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 857 797 renderable = gameObjectDefinition.getGameObjectModel(0, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 858 798 else 859 - renderable = new GameObject(objectId, face, 0, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 860 - true); 861 - scene.addWall(x, y, plane, vertexMix, POWERS_OF_TWO[face], 0, hash, renderable, null, objectConfig 862 - ); 863 - if (face == 0) { 864 - if (gameObjectDefinition.castsShadow) { 799 + renderable = new GameObject(objectId, face, 0, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 800 + scene.addWall(x, y, plane, vertexMix, POWERS_OF_TWO[face], 0, hash, renderable, null, objectConfig); 801 + if(face == 0) { 802 + if(gameObjectDefinition.castsShadow) { 865 803 object_shadow_data[plane][x][y] = (byte) 50; 866 804 object_shadow_data[plane][x][y + 1] = (byte) 50; 867 805 } 868 - if (gameObjectDefinition.wall) 806 + if(gameObjectDefinition.wall) 869 807 tile_culling_bitmap[plane][x][y] |= 0x249; 870 - } else if (face == 1) { 871 - if (gameObjectDefinition.castsShadow) { 808 + } else if(face == 1) { 809 + if(gameObjectDefinition.castsShadow) { 872 810 object_shadow_data[plane][x][y + 1] = (byte) 50; 873 811 object_shadow_data[plane][x + 1][y + 1] = (byte) 50; 874 812 } 875 - if (gameObjectDefinition.wall) 813 + if(gameObjectDefinition.wall) 876 814 tile_culling_bitmap[plane][x][y + 1] |= 0x492; 877 - } else if (face == 2) { 878 - if (gameObjectDefinition.castsShadow) { 815 + } else if(face == 2) { 816 + if(gameObjectDefinition.castsShadow) { 879 817 object_shadow_data[plane][x + 1][y] = (byte) 50; 880 818 object_shadow_data[plane][x + 1][y + 1] = (byte) 50; 881 819 } 882 - if (gameObjectDefinition.wall) 820 + if(gameObjectDefinition.wall) 883 821 tile_culling_bitmap[plane][x + 1][y] |= 0x249; 884 - } else if (face == 3) { 885 - if (gameObjectDefinition.castsShadow) { 822 + } else if(face == 3) { 823 + if(gameObjectDefinition.castsShadow) { 886 824 object_shadow_data[plane][x][y] = (byte) 50; 887 825 object_shadow_data[plane][x + 1][y] = (byte) 50; 888 826 } 889 - if (gameObjectDefinition.wall) 827 + if(gameObjectDefinition.wall) 890 828 tile_culling_bitmap[plane][x][y] |= 0x492; 891 829 } 892 - if (gameObjectDefinition.solid && collisionMap != null) 830 + if(gameObjectDefinition.solid && collisionMap != null) 893 831 collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 894 - if (gameObjectDefinition.offsetAmplifier != 16) 832 + if(gameObjectDefinition.offsetAmplifier != 16) 895 833 scene.displaceWallDecoration(x, y, plane, gameObjectDefinition.offsetAmplifier); 896 - } else if (type == 1) { 834 + } else if(type == 1) { 897 835 Renderable renderable; 898 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 836 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 899 837 renderable = gameObjectDefinition.getGameObjectModel(1, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 900 838 else 901 - renderable = new GameObject(objectId, face, 1, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 902 - true); 903 - scene.addWall(x, y, plane, vertexMix, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, objectConfig 904 - ); 905 - if (gameObjectDefinition.castsShadow) { 906 - if (face == 0) 839 + renderable = new GameObject(objectId, face, 1, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 840 + scene.addWall(x, y, plane, vertexMix, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, objectConfig); 841 + if(gameObjectDefinition.castsShadow) { 842 + if(face == 0) 907 843 object_shadow_data[plane][x][y + 1] = (byte) 50; 908 - else if (face == 1) 844 + else if(face == 1) 909 845 object_shadow_data[plane][x + 1][y + 1] = (byte) 50; 910 - else if (face == 2) 846 + else if(face == 2) 911 847 object_shadow_data[plane][x + 1][y] = (byte) 50; 912 - else if (face == 3) 848 + else if(face == 3) 913 849 object_shadow_data[plane][x][y] = (byte) 50; 914 850 } 915 - if (gameObjectDefinition.solid && collisionMap != null) 851 + if(gameObjectDefinition.solid && collisionMap != null) 916 852 collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 917 - } else if (type == 2) { 853 + } else if(type == 2) { 918 854 int i_204_ = face + 1 & 0x3; 919 855 Renderable renderable; 920 856 Renderable renderable1; 921 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) { 857 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) { 922 858 renderable = gameObjectDefinition.getGameObjectModel(2, 4 + face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 923 859 renderable1 = gameObjectDefinition.getGameObjectModel(2, i_204_, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 924 860 } else { 925 - renderable = new GameObject(objectId, 4 + face, 2, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 926 - true); 927 - renderable1 = new GameObject(objectId, i_204_, 2, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 928 - true); 861 + renderable = new GameObject(objectId, 4 + face, 2, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 862 + renderable1 = new GameObject(objectId, i_204_, 2, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 929 863 } 930 - scene.addWall(x, y, plane, vertexMix, POWERS_OF_TWO[face], POWERS_OF_TWO[i_204_], hash, renderable, renderable1, objectConfig 931 - ); 932 - if (gameObjectDefinition.wall) { 933 - if (face == 0) { 864 + scene.addWall(x, y, plane, vertexMix, POWERS_OF_TWO[face], POWERS_OF_TWO[i_204_], hash, renderable, renderable1, objectConfig); 865 + if(gameObjectDefinition.wall) { 866 + if(face == 0) { 934 867 tile_culling_bitmap[plane][x][y] |= 0x249; 935 868 tile_culling_bitmap[plane][x][y + 1] |= 0x492; 936 - } else if (face == 1) { 869 + } else if(face == 1) { 937 870 tile_culling_bitmap[plane][x][y + 1] |= 0x492; 938 871 tile_culling_bitmap[plane][x + 1][y] |= 0x249; 939 - } else if (face == 2) { 872 + } else if(face == 2) { 940 873 tile_culling_bitmap[plane][x + 1][y] |= 0x249; 941 874 tile_culling_bitmap[plane][x][y] |= 0x492; 942 - } else if (face == 3) { 875 + } else if(face == 3) { 943 876 tile_culling_bitmap[plane][x][y] |= 0x492; 944 877 tile_culling_bitmap[plane][x][y] |= 0x249; 945 878 } 946 879 } 947 - if (gameObjectDefinition.solid && collisionMap != null) 880 + if(gameObjectDefinition.solid && collisionMap != null) 948 881 collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 949 - if (gameObjectDefinition.offsetAmplifier != 16) 882 + if(gameObjectDefinition.offsetAmplifier != 16) 950 883 scene.displaceWallDecoration(x, y, plane, gameObjectDefinition.offsetAmplifier); 951 - } else if (type == 3) { 884 + } else if(type == 3) { 952 885 Renderable renderable; 953 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 886 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 954 887 renderable = gameObjectDefinition.getGameObjectModel(3, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 955 888 else 956 - renderable = new GameObject(objectId, face, 3, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 957 - true); 958 - scene.addWall(x, y, plane, vertexMix, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, objectConfig 959 - ); 960 - if (gameObjectDefinition.castsShadow) { 961 - if (face == 0) 889 + renderable = new GameObject(objectId, face, 3, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 890 + scene.addWall(x, y, plane, vertexMix, WALL_CORNER_ORIENTATION[face], 0, hash, renderable, null, objectConfig); 891 + if(gameObjectDefinition.castsShadow) { 892 + if(face == 0) 962 893 object_shadow_data[plane][x][y + 1] = (byte) 50; 963 - else if (face == 1) 894 + else if(face == 1) 964 895 object_shadow_data[plane][x + 1][y + 1] = (byte) 50; 965 - else if (face == 2) 896 + else if(face == 2) 966 897 object_shadow_data[plane][x + 1][y] = (byte) 50; 967 - else if (face == 3) 898 + else if(face == 3) 968 899 object_shadow_data[plane][x][y] = (byte) 50; 969 900 } 970 - if (gameObjectDefinition.solid && collisionMap != null) 901 + if(gameObjectDefinition.solid && collisionMap != null) 971 902 collisionMap.markWall(x, y, type, face, gameObjectDefinition.walkable); 972 - } else if (type == 9) { 903 + } else if(type == 9) { 973 904 Renderable renderable; 974 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 905 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 975 906 renderable = gameObjectDefinition.getGameObjectModel(type, face, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 976 907 else 977 - renderable = new GameObject(objectId, face, type, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 978 - true); 908 + renderable = new GameObject(objectId, face, type, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 979 909 scene.addEntityB(x, y, plane, vertexMix, 0, 1, 1, hash, renderable, objectConfig); 980 - if (gameObjectDefinition.solid && collisionMap != null) 981 - collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x 982 - ); 910 + if(gameObjectDefinition.solid && collisionMap != null) 911 + collisionMap.markSolidOccupant(y, face, gameObjectDefinition.sizeY, gameObjectDefinition.sizeX, gameObjectDefinition.walkable, x); 983 912 } else { 984 - if (gameObjectDefinition.adjustToTerrain) { 985 - if (face == 1) { 913 + if(gameObjectDefinition.adjustToTerrain) { 914 + if(face == 1) { 986 915 int temp = vertexHeightTop; 987 916 vertexHeightTop = vertexHeightTopRight; 988 917 vertexHeightTopRight = vertexHeightRight; 989 918 vertexHeightRight = vertexHeight; 990 919 vertexHeight = temp; 991 - } else if (face == 2) { 920 + } else if(face == 2) { 992 921 int temp = vertexHeightTop; 993 922 vertexHeightTop = vertexHeightRight; 994 923 vertexHeightRight = temp; 995 924 temp = vertexHeightTopRight; 996 925 vertexHeightTopRight = vertexHeight; 997 926 vertexHeight = temp; 998 - } else if (face == 3) { 927 + } else if(face == 3) { 999 928 int temp = vertexHeightTop; 1000 929 vertexHeightTop = vertexHeight; 1001 930 vertexHeight = vertexHeightRight; ··· 1003 932 vertexHeightTopRight = temp; 1004 933 } 1005 934 } 1006 - if (type == 4) { 935 + if(type == 4) { 1007 936 Renderable renderable; 1008 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 937 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1009 938 renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1010 939 else 1011 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1012 - true); 1013 - scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face * 512, hash, renderable, objectConfig, POWERS_OF_TWO[face] 1014 - ); 1015 - } else if (type == 5) { 940 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 941 + scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face * 512, hash, renderable, objectConfig, POWERS_OF_TWO[face]); 942 + } else if(type == 5) { 1016 943 int offset = 16; 1017 944 int i_210_ = scene.getWallObjectHash(x, y, plane); 1018 - if (i_210_ > 0) 945 + if(i_210_ > 0) 1019 946 offset = GameObjectDefinition.getDefinition(i_210_ >> 14 & 0x7fff).offsetAmplifier; 1020 947 Renderable renderable; 1021 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 948 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1022 949 renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1023 950 else 1024 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1025 - true); 1026 - 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] 1027 - ); 1028 - } else if (type == 6) { 951 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 952 + 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]); 953 + } else if(type == 6) { 1029 954 Renderable renderable; 1030 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 955 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1031 956 renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1032 957 else 1033 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1034 - true); 1035 - scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 256 1036 - ); 1037 - } else if (type == 7) { 958 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 959 + scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 256); 960 + } else if(type == 7) { 1038 961 Renderable renderable; 1039 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 962 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1040 963 renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1041 964 else 1042 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1043 - true); 1044 - scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 512 1045 - ); 1046 - } else if (type == 8) { 965 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 966 + scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 512); 967 + } else if(type == 8) { 1047 968 Renderable renderable; 1048 - if (gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 969 + if(gameObjectDefinition.animationId == -1 && gameObjectDefinition.childrenIds == null) 1049 970 renderable = gameObjectDefinition.getGameObjectModel(4, 0, vertexHeight, vertexHeightRight, vertexHeightTopRight, vertexHeightTop, -1); 1050 971 else 1051 - renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, 1052 - true); 1053 - scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 768 1054 - ); 972 + renderable = new GameObject(objectId, 0, 4, vertexHeightRight, vertexHeightTopRight, vertexHeight, vertexHeightTop, gameObjectDefinition.animationId, true); 973 + scene.addWallDecoration(x, y, plane, vertexMix, 0, 0, face, hash, renderable, objectConfig, 768); 1055 974 } 1056 975 } 1057 976 } 1058 977 } 1059 978 1060 979 public void loadTerrainBlock(int blockX, int offsetX, int blockY, int offsetY, byte[] blockData, CollisionMap[] collisionMap) { 1061 - for (int plane = 0; plane < 4; plane++) { 1062 - for (int tileX = 0; tileX < 64; tileX++) { 1063 - for (int tileY = 0; tileY < 64; tileY++) { 1064 - if (blockX + tileX > 0 && blockX + tileX < 103 && blockY + tileY > 0 && blockY + tileY < 103) 980 + for(int plane = 0; plane < 4; plane++) { 981 + for(int tileX = 0; tileX < 64; tileX++) { 982 + for(int tileY = 0; tileY < 64; tileY++) { 983 + if(blockX + tileX > 0 && blockX + tileX < 103 && blockY + tileY > 0 && blockY + tileY < 103) 1065 984 collisionMap[plane].clippingData[blockX + tileX][blockY + tileY] &= ~0x1000000; 1066 985 } 1067 986 } 1068 987 } 1069 988 Buffer stream = new Buffer(blockData); 1070 - for (int plane = 0; plane < 4; plane++) { 1071 - for (int tileX = 0; tileX < 64; tileX++) { 1072 - for (int tileY = 0; tileY < 64; tileY++) 989 + for(int plane = 0; plane < 4; plane++) { 990 + for(int tileX = 0; tileX < 64; tileX++) { 991 + for(int tileY = 0; tileY < 64; tileY++) 1073 992 loadTerrainTile(tileX + blockX, offsetX, tileY + blockY, offsetY, plane, stream, 0); 1074 993 } 1075 994 } ··· 1082 1001 } 1083 1002 1084 1003 public int getHSLBitset(int h, int s, int l) { 1085 - if (l > 179) 1004 + if(l > 179) 1086 1005 s /= 2; 1087 - if (l > 192) 1006 + if(l > 192) 1088 1007 s /= 2; 1089 - if (l > 217) 1008 + if(l > 217) 1090 1009 s /= 2; 1091 - if (l > 243) 1010 + if(l > 243) 1092 1011 s /= 2; 1093 1012 return (h / 4 << 10) + (s / 32 << 7) + l / 2; 1094 1013 } 1095 1014 1096 1015 public static int random_noise_weighed_sum(int x, int y) { 1097 - int v_dist2 = random_noise(x - 1, y - 1) + 1098 - random_noise(x + 1, y - 1) + 1099 - random_noise(x - 1, y + 1) + 1100 - random_noise(x + 1, y + 1); 1101 - int v_dist1 = random_noise(x - 1, y) + 1102 - random_noise(x + 1, y) + 1103 - random_noise(x, y - 1) + 1104 - random_noise(x, y + 1); 1016 + int v_dist2 = random_noise(x - 1, y - 1) + random_noise(x + 1, y - 1) + random_noise(x - 1, y + 1) + random_noise(x + 1, y + 1); 1017 + int v_dist1 = random_noise(x - 1, y) + random_noise(x + 1, y) + random_noise(x, y - 1) + random_noise(x, y + 1); 1105 1018 int v_local = random_noise(x, y); 1106 1019 return v_dist2 / 16 + v_dist1 / 8 + v_local / 4; 1107 1020 } ··· 1109 1022 public void loadObjectBlock(int blockX, int blockY, CollisionMap[] collisionMap, Scene scene, byte[] blockData) { 1110 1023 Buffer stream = new Buffer(blockData); 1111 1024 int objectId = -1; 1112 - while (true) { 1025 + while(true) { 1113 1026 int objectIdOffset = stream.getSmart(); 1114 - if (objectIdOffset == 0) 1027 + if(objectIdOffset == 0) 1115 1028 break; 1116 1029 objectId += objectIdOffset; 1117 1030 int position = 0; 1118 - while (true) { 1031 + while(true) { 1119 1032 int positionOffset = stream.getSmart(); 1120 - if (positionOffset == 0) 1033 + if(positionOffset == 0) 1121 1034 break; 1122 1035 position += positionOffset - 1; 1123 1036 int tileY = position & 0x3f; ··· 1128 1041 int orientation = hash & 0x3; 1129 1042 int x = tileX + blockX; 1130 1043 int y = tileY + blockY; 1131 - if (x > 0 && y > 0 && x < 103 && y < 103) { 1044 + if(x > 0 && y > 0 && x < 103 && y < 103) { 1132 1045 int markingPlane = tilePlane; 1133 - if ((tile_flags[1][x][y] & 0x2) == 2) 1046 + if((tile_flags[1][x][y] & 0x2) == 2) 1134 1047 markingPlane--; 1135 1048 CollisionMap collisionMap_ = null; 1136 - if (markingPlane >= 0) 1049 + if(markingPlane >= 0) 1137 1050 collisionMap_ = collisionMap[markingPlane]; 1138 1051 renderObject(scene, collisionMap_, y, tilePlane, x, orientation, type, objectId); 1139 1052 } ··· 1142 1055 } 1143 1056 1144 1057 public void initiateVertexHeights(int xOffset, int xLength, int yOffset, int yLength) { 1145 - for (int y = yOffset; y <= yOffset + yLength; y++) { 1146 - for (int x = xOffset; x <= xOffset + xLength; x++) { 1147 - if (x >= 0 && x < size_x && y >= 0 && y < size_z) { 1058 + for(int y = yOffset; y <= yOffset + yLength; y++) { 1059 + for(int x = xOffset; x <= xOffset + xLength; x++) { 1060 + if(x >= 0 && x < size_x && y >= 0 && y < size_z) { 1148 1061 object_shadow_data[0][x][y] = (byte) 127; 1149 - if (x == xOffset && x > 0) 1062 + if(x == xOffset && x > 0) 1150 1063 tile_height[0][x][y] = tile_height[0][x - 1][y]; 1151 - if (x == xOffset + xLength && x < size_x - 1) 1064 + if(x == xOffset + xLength && x < size_x - 1) 1152 1065 tile_height[0][x][y] = tile_height[0][x + 1][y]; 1153 - if (y == yOffset && y > 0) 1066 + if(y == yOffset && y > 0) 1154 1067 tile_height[0][x][y] = tile_height[0][x][y - 1]; 1155 - if (y == yOffset + yLength && y < size_z - 1) 1068 + if(y == yOffset + yLength && y < size_z - 1) 1156 1069 tile_height[0][x][y] = tile_height[0][x][y + 1]; 1157 1070 } 1158 1071 } ··· 1164 1077 boolean cached = true; 1165 1078 Buffer objectDataStream = new Buffer(objectData); 1166 1079 int objectId = -1; 1167 - while (true) { 1080 + while(true) { 1168 1081 int objectIdIncrement = objectDataStream.getSmart(); 1169 - if (objectIdIncrement == 0) 1082 + if(objectIdIncrement == 0) 1170 1083 break; 1171 1084 objectId += objectIdIncrement; 1172 1085 int pos = 0; 1173 1086 boolean readSecondValue = false; 1174 - while (true) { 1175 - if (readSecondValue) { 1087 + while(true) { 1088 + if(readSecondValue) { 1176 1089 int secondValue = objectDataStream.getSmart(); 1177 - if (secondValue == 0) 1090 + if(secondValue == 0) 1178 1091 break; 1179 1092 objectDataStream.getUnsignedByte(); 1180 1093 } else { 1181 1094 int positionoffset = objectDataStream.getSmart(); 1182 - if (positionoffset == 0) 1095 + if(positionoffset == 0) 1183 1096 break; 1184 1097 pos += positionoffset - 1; 1185 1098 int regionOffsetY = pos & 0x3f; ··· 1187 1100 int objectType = objectDataStream.getUnsignedByte() >> 2; 1188 1101 int objectX = regionOffsetX + regionX; 1189 1102 int objectY = regionOffsetY + regionY; 1190 - if (objectX > 0 && objectY > 0 && objectX < 103 && objectY < 103) { 1103 + if(objectX > 0 && objectY > 0 && objectX < 103 && objectY < 103) { 1191 1104 GameObjectDefinition definition = GameObjectDefinition.getDefinition(objectId); 1192 - if (objectType != 22 || !lowMemory || definition.hasActions || definition.unknown) { 1105 + if(objectType != 22 || !lowMemory || definition.hasActions || definition.unknown) { 1193 1106 cached &= definition.isModelCached(); 1194 1107 readSecondValue = true; 1195 1108 } ··· 1201 1114 } 1202 1115 1203 1116 public int mixLightnessSigned(int hsl, int lightness) { 1204 - if (hsl == -2) 1117 + if(hsl == -2) 1205 1118 return 12345678; 1206 - if (hsl == -1) { 1207 - if (lightness < 0) 1119 + if(hsl == -1) { 1120 + if(lightness < 0) 1208 1121 lightness = 0; 1209 - else if (lightness > 127) 1122 + else if(lightness > 127) 1210 1123 lightness = 127; 1211 1124 lightness = 127 - lightness; 1212 1125 return lightness; 1213 1126 } 1214 1127 lightness = lightness * (hsl & 0x7f) / 128; 1215 - if (lightness < 2) 1128 + if(lightness < 2) 1216 1129 lightness = 2; 1217 - else if (lightness > 126) 1130 + else if(lightness > 126) 1218 1131 lightness = 126; 1219 1132 return (hsl & 0xff80) + lightness; 1220 1133 } 1221 1134 1222 1135 public void loadTerrainTile(int tileX, int offsetX, int tileY, int offsetY, int tileZ, Buffer stream, int i1) { 1223 - if (tileX >= 0 && tileX < 104 && tileY >= 0 && tileY < 104) { 1136 + if(tileX >= 0 && tileX < 104 && tileY >= 0 && tileY < 104) { 1224 1137 tile_flags[tileZ][tileX][tileY] = (byte) 0; 1225 - for (; ; ) { 1138 + for(; ; ) { 1226 1139 int value = stream.getUnsignedByte(); 1227 - if (value == 0) { 1228 - if (tileZ == 0) 1229 - tile_height[0][tileX][tileY] = -calculateVertexHeight(932731 + tileX + offsetX, 556238 + tileY 1230 - + offsetY) * 8; 1140 + if(value == 0) { 1141 + if(tileZ == 0) 1142 + tile_height[0][tileX][tileY] = -calculateVertexHeight(932731 + tileX + offsetX, 556238 + tileY + offsetY) * 8; 1231 1143 else { 1232 1144 tile_height[tileZ][tileX][tileY] = (tile_height[tileZ - 1][tileX][tileY] - 240); 1233 1145 break; 1234 1146 } 1235 1147 break; 1236 1148 } 1237 - if (value == 1) { 1149 + if(value == 1) { 1238 1150 int height = stream.getUnsignedByte(); 1239 - if (height == 1) 1151 + if(height == 1) 1240 1152 height = 0; 1241 - if (tileZ == 0) 1153 + if(tileZ == 0) 1242 1154 tile_height[0][tileX][tileY] = -height * 8; 1243 1155 else { 1244 1156 tile_height[tileZ][tileX][tileY] = (tile_height[tileZ - 1][tileX][tileY] - height * 8); ··· 1246 1158 } 1247 1159 break; 1248 1160 } 1249 - if (value <= 49) { 1161 + if(value <= 49) { 1250 1162 overlayFloorIds[tileZ][tileX][tileY] = stream.getByte(); 1251 1163 overlayClippingPaths[tileZ][tileX][tileY] = (byte) ((value - 2) / 4); 1252 1164 overlayRotations[tileZ][tileX][tileY] = (byte) (value - 2 + i1 & 0x3); 1253 - } else if (value <= 81) 1165 + } else if(value <= 81) 1254 1166 tile_flags[tileZ][tileX][tileY] = (byte) (value - 49); 1255 1167 else 1256 1168 underlayFloorIds[tileZ][tileX][tileY] = (byte) (value - 81); 1257 1169 } 1258 1170 } else { 1259 - for (; ; ) { 1171 + for(; ; ) { 1260 1172 int value = stream.getUnsignedByte(); 1261 - if (value == 0) 1173 + if(value == 0) 1262 1174 break; 1263 - if (value == 1) { 1175 + if(value == 1) { 1264 1176 stream.getUnsignedByte(); 1265 1177 break; 1266 1178 } 1267 - if (value <= 49) 1179 + if(value <= 49) 1268 1180 stream.getUnsignedByte(); 1269 1181 } 1270 1182 } 1271 1183 } 1272 1184 1273 1185 public static int calculateVertexHeight(int i, int i_281_) { 1274 - int mapHeight = (perlin_noise(i + 45365, i_281_ + 91923, 4) - 128 1275 - + (perlin_noise(i + 10294, i_281_ + 37821, 2) - 128 >> 1) + (perlin_noise(i, i_281_, 1) - 128 >> 2)); 1186 + int mapHeight = (perlin_noise(i + 45365, i_281_ + 91923, 4) - 128 + (perlin_noise(i + 10294, i_281_ + 37821, 2) - 128 >> 1) + (perlin_noise(i, i_281_, 1) - 128 >> 2)); 1276 1187 mapHeight = (int) (mapHeight * 0.3) + 35; 1277 - if (mapHeight < 10) 1188 + if(mapHeight < 10) 1278 1189 mapHeight = 10; 1279 - else if (mapHeight > 60) 1190 + else if(mapHeight > 60) 1280 1191 mapHeight = 60; 1281 1192 return mapHeight; 1282 1193 }