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.

Merge pull request #3 from dope-head/master

Merging changes from @dope-head

author
Promises
committer
GitHub
date (Apr 9, 2018, 2:12 PM +0200) commit dde8e587 parent b862e667
+416 -343
+416 -343
src/com/jagex/runescape/Game.java
··· 436 436 public int anInt1213 = -1; 437 437 public static int BITFIELD_MAX_VALUE[]; 438 438 public int anInt1215; 439 - public int anInt1216; 440 - public int anInt1217; 441 - public int anInt1218; 439 + public int cameraX; 440 + public int cameraZ; 441 + public int cameraY; 442 442 public int anInt1219; 443 443 public int anInt1220; 444 444 public int friendsListAction; ··· 846 846 buf.finishBitAccess(); 847 847 } 848 848 849 + private void processFlamesCycle() { 850 + aBoolean1320 = true; 849 851 852 + try { 853 + long startTime = System.currentTimeMillis(); 854 + int cycle = 0; 855 + int interval = 20; 850 856 851 - public void method17(byte byte0) { 852 - aBoolean1320 = true; 853 - if (byte0 == 4) 854 - byte0 = 0; 855 - else 856 - groundItems = null; 857 - try { 858 - long l = System.currentTimeMillis(); 859 - int i = 0; 860 - int j = 20; 861 857 while (aBoolean1243) { 862 858 anInt1101++; 859 + 863 860 method81((byte) 1); 864 861 method81((byte) 1); 865 862 method98(47); 866 - if (++i > 10) { 867 - long l1 = System.currentTimeMillis(); 868 - int k = (int) (l1 - l) / 10 - j; 869 - j = 40 - k; 870 - if (j < 5) 871 - j = 5; 872 - i = 0; 873 - l = l1; 863 + 864 + if (++cycle > 10) { 865 + long currentTime = System.currentTimeMillis(); 866 + int difference = (int) (currentTime - startTime) / 10 - interval; 867 + interval = 40 - difference; 868 + 869 + if (interval < 5) 870 + interval = 5; 871 + 872 + cycle = 0; 873 + startTime = currentTime; 874 874 } 875 875 try { 876 - Thread.sleep(j); 877 - } catch (Exception _ex) { 878 - } 876 + Thread.sleep(interval); 877 + } catch (Exception ignored) {} 879 878 } 880 - } catch (Exception _ex) { 881 - } 879 + } catch (Exception ignored) {} 880 + 882 881 aBoolean1320 = false; 883 882 } 884 883 ··· 1437 1436 dropClient(); 1438 1437 method100(0); 1439 1438 method67(-37214); 1440 - method85(0); 1439 + processActorOverheadText(); 1441 1440 tickDelta++; 1442 1441 if (crossType != 0) { 1443 1442 crossIndex += 20; ··· 1624 1623 int i = anInt874 * 128 + 64; 1625 1624 int j = anInt875 * 128 + 64; 1626 1625 int k = method110(j, i, (byte) 9, plane) - anInt876; 1627 - if (anInt1216 < i) { 1628 - anInt1216 += anInt877 + ((i - anInt1216) * anInt878) / 1000; 1629 - if (anInt1216 > i) 1630 - anInt1216 = i; 1626 + if (cameraX < i) { 1627 + cameraX += anInt877 + ((i - cameraX) * anInt878) / 1000; 1628 + if (cameraX > i) 1629 + cameraX = i; 1631 1630 } 1632 - if (anInt1216 > i) { 1633 - anInt1216 -= anInt877 + ((anInt1216 - i) * anInt878) / 1000; 1634 - if (anInt1216 < i) 1635 - anInt1216 = i; 1631 + if (cameraX > i) { 1632 + cameraX -= anInt877 + ((cameraX - i) * anInt878) / 1000; 1633 + if (cameraX < i) 1634 + cameraX = i; 1636 1635 } 1637 - if (anInt1217 < k) { 1638 - anInt1217 += anInt877 + ((k - anInt1217) * anInt878) / 1000; 1639 - if (anInt1217 > k) 1640 - anInt1217 = k; 1636 + if (cameraZ < k) { 1637 + cameraZ += anInt877 + ((k - cameraZ) * anInt878) / 1000; 1638 + if (cameraZ > k) 1639 + cameraZ = k; 1641 1640 } 1642 - if (anInt1217 > k) { 1643 - anInt1217 -= anInt877 + ((anInt1217 - k) * anInt878) / 1000; 1644 - if (anInt1217 < k) 1645 - anInt1217 = k; 1641 + if (cameraZ > k) { 1642 + cameraZ -= anInt877 + ((cameraZ - k) * anInt878) / 1000; 1643 + if (cameraZ < k) 1644 + cameraZ = k; 1646 1645 } 1647 - if (anInt1218 < j) { 1648 - anInt1218 += anInt877 + ((j - anInt1218) * anInt878) / 1000; 1649 - if (anInt1218 > j) 1650 - anInt1218 = j; 1646 + if (cameraY < j) { 1647 + cameraY += anInt877 + ((j - cameraY) * anInt878) / 1000; 1648 + if (cameraY > j) 1649 + cameraY = j; 1651 1650 } 1652 - if (anInt1218 > j) { 1653 - anInt1218 -= anInt877 + ((anInt1218 - j) * anInt878) / 1000; 1654 - if (anInt1218 < j) 1655 - anInt1218 = j; 1651 + if (cameraY > j) { 1652 + cameraY -= anInt877 + ((cameraY - j) * anInt878) / 1000; 1653 + if (cameraY < j) 1654 + cameraY = j; 1656 1655 } 1657 1656 i = anInt993 * 128 + 64; 1658 1657 j = anInt994 * 128 + 64; 1659 1658 k = method110(j, i, (byte) 9, plane) - anInt995; 1660 - int l = i - anInt1216; 1661 - int i1 = k - anInt1217; 1662 - int j1 = j - anInt1218; 1659 + int l = i - cameraX; 1660 + int i1 = k - cameraZ; 1661 + int j1 = j - cameraY; 1663 1662 int k1 = (int) Math.sqrt(l * l + j1 * j1); 1664 1663 int l1 = (int) (Math.atan2(i1, k1) * 325.94900000000001D) & 0x7ff; 1665 1664 int j2 = (int) (Math.atan2(l, j1) * -325.94900000000001D) & 0x7ff; ··· 2257 2256 int i4 = anInt993 * 128 + 64; 2258 2257 int l12 = anInt994 * 128 + 64; 2259 2258 int l17 = method110(l12, i4, (byte) 9, plane) - anInt995; 2260 - int k22 = i4 - anInt1216; 2261 - int i25 = l17 - anInt1217; 2262 - int k27 = l12 - anInt1218; 2259 + int k22 = i4 - cameraX; 2260 + int i25 = l17 - cameraZ; 2261 + int k27 = l12 - cameraY; 2263 2262 int i30 = (int) Math.sqrt(k22 * k22 + k27 * k27); 2264 2263 anInt1219 = (int) (Math.atan2(i25, i30) * 325.94900000000001D) & 0x7ff; 2265 2264 anInt1220 = (int) (Math.atan2(k22, k27) * -325.94900000000001D) & 0x7ff; ··· 2994 2993 anInt877 = buffer.getUnsignedByte(); 2995 2994 anInt878 = buffer.getUnsignedByte(); 2996 2995 if (anInt878 >= 100) { 2997 - anInt1216 = anInt874 * 128 + 64; 2998 - anInt1218 = anInt875 * 128 + 64; 2999 - anInt1217 = method110(anInt1218, anInt1216, (byte) 9, plane) - anInt876; 2996 + cameraX = anInt874 * 128 + 64; 2997 + cameraY = anInt875 * 128 + 64; 2998 + cameraZ = method110(cameraY, cameraX, (byte) 9, plane) - anInt876; 3000 2999 } 3001 3000 opcode = -1; 3002 3001 return true; ··· 4875 4874 stores[type] = new Index(type + 1, 0x927c0, SignLink.cacheData, SignLink.cacheIndex[type]); 4876 4875 } 4877 4876 try { 4878 - connectWebServer(); 4877 + requestArchiveCrcs(); 4879 4878 titleArchive = requestArchive(1, "title", archiveHashes[1], 25, "title screen"); 4880 4879 fontSmall = new TypeFace(false, titleArchive, "p11_full"); 4881 4880 fontNormal = new TypeFace(false, titleArchive, "p12_full"); ··· 5895 5894 if (menuOpen && anInt1304 == 2) 5896 5895 redrawChatbox = true; 5897 5896 if (redrawChatbox) { 5898 - drawChatbox(0); 5897 + renderChatbox(); 5899 5898 redrawChatbox = false; 5900 5899 } 5901 5900 if (loadingStage == 2) { 5902 - method87(503); 5901 + renderMinimap(); 5903 5902 aClass18_1157.drawGraphics(550, 4, super.gameGraphics); 5904 5903 } 5905 5904 if (anInt1213 != -1) ··· 6787 6786 } 6788 6787 } 6789 6788 6790 - public void drawChatbox(int i) { 6789 + private void renderChatbox() { 6791 6790 chatboxProducingGraphicsBuffer.createRasterizer(); 6791 + 6792 6792 Rasterizer3D.lineOffsets = chatboxLineOffsets; 6793 + 6793 6794 chatboxBackgroundImage.drawImage(0, 0); 6795 + 6794 6796 if (messagePromptRaised) { 6795 6797 fontBold.drawStringLeft(chatboxInputMessage, 239, 40, 0); 6796 6798 fontBold.drawStringLeft(chatMessage + "*", 239, 60, 128); ··· 6801 6803 fontBold.drawStringLeft("Enter name:", 239, 40, 0); 6802 6804 fontBold.drawStringLeft(inputInputMessage + "*", 239, 60, 128); 6803 6805 } else if (inputType == 3) { 6804 - if (inputInputMessage != aString861) { 6806 + if (!inputInputMessage.equals(aString861)) { 6805 6807 method14(inputInputMessage, 2); 6806 6808 aString861 = inputInputMessage; 6807 6809 } 6808 - TypeFace class50_sub1_sub1_sub2 = fontNormal; 6810 + 6811 + TypeFace typeFace = fontNormal; 6812 + 6809 6813 Rasterizer.setCoordinates(0, 0, 77, 463); 6810 - for (int j = 0; j < anInt862; j++) { 6811 - int l = (18 + j * 14) - anInt865; 6812 - if (l > 0 && l < 110) 6813 - class50_sub1_sub1_sub2.drawStringLeft(aStringArray863[j], 239, l, 0); 6814 + 6815 + for (int i = 0; i < anInt862; i++) { 6816 + int y = (18 + i * 14) - anInt865; 6817 + 6818 + if (y > 0 && y < 110) 6819 + typeFace.drawStringLeft(aStringArray863[i], 239, y, 0); 6814 6820 } 6815 6821 6816 6822 Rasterizer.resetCoordinates(); 6823 + 6817 6824 if (anInt862 > 5) 6818 6825 method56(true, anInt865, 463, 77, anInt862 * 14 + 7, 0); 6826 + 6819 6827 if (inputInputMessage.length() == 0) 6820 - fontBold.drawStringLeft("Enter object name", 239, 40, 255); 6828 + fontBold.drawStringLeft("Enter object name", 239, 40, 255); 6821 6829 else if (anInt862 == 0) 6822 - fontBold.drawStringLeft("No matching objects found, please shorten search", 239, 40, 0 6823 - ); 6824 - class50_sub1_sub1_sub2.drawStringLeft(inputInputMessage + "*", 239, 90, 0); 6830 + fontBold.drawStringLeft("No matching objects found, please shorten search", 239, 40, 0); 6831 + 6832 + typeFace.drawStringLeft(inputInputMessage + "*", 239, 90, 0); 6825 6833 Rasterizer.drawHorizontalLine(0, 77, 479, 0); 6826 6834 } else if (clickToContinueString != null) { 6827 6835 fontBold.drawStringLeft(clickToContinueString, 239, 40, 0); 6828 6836 fontBold.drawStringLeft("Click to continue", 239, 60, 128); 6829 - } else if (backDialogueId != -1) 6830 - method142(0, 0, Widget.forId(backDialogueId), 0, 8); 6831 - else if (dialogueId != -1) { 6837 + } else if (backDialogueId != -1) { 6838 + method142(0, 0, Widget.forId(backDialogueId), 0, 8); 6839 + } else if (dialogueId != -1) { 6832 6840 method142(0, 0, Widget.forId(dialogueId), 0, 8); 6833 6841 } else { 6834 - TypeFace class50_sub1_sub1_sub2_1 = fontNormal; 6835 - int k = 0; 6842 + TypeFace typeFace = fontNormal; 6843 + int line = 0; 6844 + 6836 6845 Rasterizer.setCoordinates(0, 0, 77, 463); 6837 - for (int i1 = 0; i1 < 100; i1++) 6838 - if (chatMessages[i1] != null) { 6839 - int j1 = chatTypes[i1]; 6840 - int k1 = (70 - k * 14) + anInt851; 6841 - String s1 = chatPlayerNames[i1]; 6842 - byte byte0 = 0; 6843 - if (s1 != null && s1.startsWith("@cr1@")) { 6844 - s1 = s1.substring(5); 6845 - byte0 = 1; 6846 - } 6847 - if (s1 != null && s1.startsWith("@cr2@")) { 6848 - s1 = s1.substring(5); 6849 - byte0 = 2; 6850 - } 6851 - if (j1 == 0) { 6852 - if (k1 > 0 && k1 < 110) 6853 - class50_sub1_sub1_sub2_1.drawString(chatMessages[i1], 4, k1, 0); 6854 - k++; 6855 - } 6856 - if ((j1 == 1 || j1 == 2) && (j1 == 1 || publicChatMode == 0 || publicChatMode == 1 && method148(13292, s1))) { 6857 - if (k1 > 0 && k1 < 110) { 6858 - int l1 = 4; 6859 - if (byte0 == 1) { 6860 - moderatorIcon[0].drawImage(l1, k1 - 12); 6861 - l1 += 14; 6862 - } 6863 - if (byte0 == 2) { 6864 - moderatorIcon[1].drawImage(l1, k1 - 12); 6865 - l1 += 14; 6866 - } 6867 - class50_sub1_sub1_sub2_1.drawString(s1 + ":", l1, k1, 0); 6868 - l1 += class50_sub1_sub1_sub2_1.getStringEffectWidth(s1) + 8; 6869 - class50_sub1_sub1_sub2_1.drawString(chatMessages[i1], l1, k1, 255); 6870 - } 6871 - k++; 6872 - } 6873 - if ((j1 == 3 || j1 == 7) && anInt1223 == 0 6874 - && (j1 == 7 || privateChatMode == 0 || privateChatMode == 1 && method148(13292, s1))) { 6875 - if (k1 > 0 && k1 < 110) { 6876 - int i2 = 4; 6877 - class50_sub1_sub1_sub2_1.drawString("From", i2, k1, 0); 6878 - i2 += class50_sub1_sub1_sub2_1.getStringEffectWidth("From "); 6879 - if (byte0 == 1) { 6880 - moderatorIcon[0].drawImage(i2, k1 - 12); 6881 - i2 += 14; 6882 - } 6883 - if (byte0 == 2) { 6884 - moderatorIcon[1].drawImage(i2, k1 - 12); 6885 - i2 += 14; 6886 - } 6887 - class50_sub1_sub1_sub2_1.drawString(s1 + ":", i2, k1, 0); 6888 - i2 += class50_sub1_sub1_sub2_1.getStringEffectWidth(s1) + 8; 6889 - class50_sub1_sub1_sub2_1.drawString(chatMessages[i1], i2, k1, 0x800000); 6890 - } 6891 - k++; 6892 - } 6893 - if (j1 == 4 && (tradeMode == 0 || tradeMode == 1 && method148(13292, s1))) { 6894 - if (k1 > 0 && k1 < 110) 6895 - class50_sub1_sub1_sub2_1.drawString(s1 + " " + chatMessages[i1], 4, k1, 0x800080); 6896 - k++; 6897 - } 6898 - if (j1 == 5 && anInt1223 == 0 && privateChatMode < 2) { 6899 - if (k1 > 0 && k1 < 110) 6900 - class50_sub1_sub1_sub2_1.drawString(chatMessages[i1], 4, k1, 0x800000); 6901 - k++; 6902 - } 6903 - if (j1 == 6 && anInt1223 == 0 && privateChatMode < 2) { 6904 - if (k1 > 0 && k1 < 110) { 6905 - class50_sub1_sub1_sub2_1.drawString("To " + s1 + ":", 4, k1, 0); 6906 - class50_sub1_sub1_sub2_1.drawString(chatMessages[i1], 12 + class50_sub1_sub1_sub2_1.getStringEffectWidth( 6907 - "To " + s1), k1, 0x800000); 6908 - } 6909 - k++; 6910 - } 6911 - if (j1 == 8 && (tradeMode == 0 || tradeMode == 1 && method148(13292, s1))) { 6912 - if (k1 > 0 && k1 < 110) 6913 - class50_sub1_sub1_sub2_1.drawString(s1 + " " + chatMessages[i1], 4, k1, 0x7e3200); 6914 - k++; 6915 - } 6916 - } 6846 + 6847 + for (int i = 0; i < 100; i++) { 6848 + if (chatMessages[i] != null) { 6849 + String name = chatPlayerNames[i]; 6850 + int type = chatTypes[i]; 6851 + int y = (70 - line * 14) + anInt851; 6852 + byte privilege = 0; 6853 + 6854 + if (name != null && name.startsWith("@cr1@")) { 6855 + name = name.substring(5); 6856 + privilege = 1; 6857 + } 6858 + 6859 + if (name != null && name.startsWith("@cr2@")) { 6860 + name = name.substring(5); 6861 + privilege = 2; 6862 + } 6863 + 6864 + if (type == 0) { 6865 + if (y > 0 && y < 110) 6866 + typeFace.drawString(chatMessages[i], 4, y, 0); 6867 + 6868 + line++; 6869 + } 6870 + 6871 + if ((type == 1 || type == 2) && (type == 1 || publicChatMode == 0 || publicChatMode == 1 && method148(13292, name))) { 6872 + if (y > 0 && y < 110) { 6873 + int x = 4; 6874 + 6875 + if (privilege == 1) { 6876 + moderatorIcon[0].drawImage(x, y - 12); 6877 + x += 14; 6878 + } 6879 + 6880 + if (privilege == 2) { 6881 + moderatorIcon[1].drawImage(x, y - 12); 6882 + x += 14; 6883 + } 6884 + 6885 + typeFace.drawString(name + ":", x, y, 0); 6886 + 6887 + x += typeFace.getStringEffectWidth(name) + 8; 6888 + 6889 + typeFace.drawString(chatMessages[i], x, y, 255); 6890 + } 6891 + 6892 + line++; 6893 + } 6894 + 6895 + if ((type == 3 || type == 7) && anInt1223 == 0 6896 + && (type == 7 || privateChatMode == 0 || privateChatMode == 1 && method148(13292, name))) { 6897 + if (y > 0 && y < 110) { 6898 + int x = 4; 6899 + 6900 + typeFace.drawString("From", x, y, 0); 6901 + 6902 + x += typeFace.getStringEffectWidth("From "); 6903 + 6904 + if (privilege == 1) { 6905 + moderatorIcon[0].drawImage(x, y - 12); 6906 + x += 14; 6907 + } 6908 + 6909 + if (privilege == 2) { 6910 + moderatorIcon[1].drawImage(x, y - 12); 6911 + x += 14; 6912 + } 6913 + 6914 + typeFace.drawString(name + ":", x, y, 0); 6915 + 6916 + x += typeFace.getStringEffectWidth(name) + 8; 6917 + 6918 + typeFace.drawString(chatMessages[i], x, y, 0x800000); 6919 + } 6920 + 6921 + line++; 6922 + } 6923 + 6924 + if (type == 4 && (tradeMode == 0 || tradeMode == 1 && method148(13292, name))) { 6925 + if (y > 0 && y < 110) 6926 + typeFace.drawString(name + " " + chatMessages[i], 4, y, 0x800080); 6927 + 6928 + line++; 6929 + } 6930 + 6931 + if (type == 5 && anInt1223 == 0 && privateChatMode < 2) { 6932 + if (y > 0 && y < 110) 6933 + typeFace.drawString(chatMessages[i], 4, y, 0x800000); 6934 + 6935 + line++; 6936 + } 6937 + 6938 + if (type == 6 && anInt1223 == 0 && privateChatMode < 2) { 6939 + if (y > 0 && y < 110) { 6940 + typeFace.drawString("To " + name + ":", 4, y, 0); 6941 + typeFace.drawString(chatMessages[i], 12 + typeFace.getStringEffectWidth("To " + name), y, 0x800000); 6942 + } 6943 + 6944 + line++; 6945 + } 6946 + 6947 + if (type == 8 && (tradeMode == 0 || tradeMode == 1 && method148(13292, name))) { 6948 + if (y > 0 && y < 110) 6949 + typeFace.drawString(name + " " + chatMessages[i], 4, y, 0x7e3200); 6950 + 6951 + line++; 6952 + } 6953 + } 6954 + } 6917 6955 6918 6956 Rasterizer.resetCoordinates(); 6919 - anInt1107 = k * 14 + 7; 6957 + 6958 + anInt1107 = line * 14 + 7; 6959 + 6920 6960 if (anInt1107 < 78) 6921 6961 anInt1107 = 78; 6962 + 6922 6963 method56(true, anInt1107 - anInt851 - 77, 463, 77, anInt1107, 0); 6923 - String s; 6964 + 6965 + String name; 6966 + 6924 6967 if (localPlayer != null && localPlayer.playerName != null) 6925 - s = localPlayer.playerName; 6968 + name = localPlayer.playerName; 6926 6969 else 6927 - s = TextUtils.formatName(username); 6928 - class50_sub1_sub1_sub2_1.drawString(s + ":", 4, 90, 0); 6929 - class50_sub1_sub1_sub2_1.drawString(chatboxInput + "*", 6 + class50_sub1_sub1_sub2_1.getStringEffectWidth(s + ": "), 90, 255 6930 - ); 6970 + name = TextUtils.formatName(username); 6971 + 6972 + typeFace.drawString(name + ":", 4, 90, 0); 6973 + typeFace.drawString(chatboxInput + "*", 6 + typeFace.getStringEffectWidth(name + ": "), 90, 255); 6931 6974 Rasterizer.drawHorizontalLine(0, 77, 479, 0); 6932 6975 } 6976 + 6933 6977 if (menuOpen && anInt1304 == 2) 6934 6978 method128(false); 6979 + 6935 6980 chatboxProducingGraphicsBuffer.drawGraphics(17, 357, super.gameGraphics); 6936 6981 aClass18_1158.createRasterizer(); 6982 + 6937 6983 Rasterizer3D.lineOffsets = anIntArray1002; 6938 - if (i != 0) 6939 - groundItems = null; 6940 6984 } 6941 6985 6942 - public void method85(int i) { 6943 - for (int j = -1; j < localPlayerCount; j++) { 6944 - int k; 6945 - if (j == -1) 6946 - k = thisPlayerId; 6947 - else 6948 - k = playerList[j]; 6949 - Player class50_sub1_sub4_sub3_sub2 = players[k]; 6950 - if (class50_sub1_sub4_sub3_sub2 != null && class50_sub1_sub4_sub3_sub2.textCycle > 0) { 6951 - class50_sub1_sub4_sub3_sub2.textCycle--; 6952 - if (class50_sub1_sub4_sub3_sub2.textCycle == 0) 6953 - class50_sub1_sub4_sub3_sub2.forcedChat = null; 6986 + private void processActorOverheadText() { 6987 + for (int i = -1; i < localPlayerCount; i++) { 6988 + int index = i == -1 ? thisPlayerId : playerList[i]; 6989 + Player player = players[index]; 6990 + 6991 + if (player != null && player.textCycle > 0) { 6992 + player.textCycle--; 6993 + 6994 + if (player.textCycle == 0) 6995 + player.forcedChat = null; 6954 6996 } 6955 6997 } 6956 6998 6957 - packetSize += i; 6958 - for (int l = 0; l < anInt1133; l++) { 6959 - int i1 = anIntArray1134[l]; 6960 - Npc class50_sub1_sub4_sub3_sub1 = npcs[i1]; 6961 - if (class50_sub1_sub4_sub3_sub1 != null && class50_sub1_sub4_sub3_sub1.textCycle > 0) { 6962 - class50_sub1_sub4_sub3_sub1.textCycle--; 6963 - if (class50_sub1_sub4_sub3_sub1.textCycle == 0) 6964 - class50_sub1_sub4_sub3_sub1.forcedChat = null; 6999 + for (int i = 0; i < anInt1133; i++) { 7000 + int index = anIntArray1134[i]; 7001 + Npc npc = npcs[index]; 7002 + 7003 + if (npc != null && npc.textCycle > 0) { 7004 + npc.textCycle--; 7005 + 7006 + if (npc.textCycle == 0) 7007 + npc.forcedChat = null; 6965 7008 } 6966 7009 } 6967 - 6968 7010 } 6969 7011 6970 - public void connectWebServer() { 6971 - int i = 5; 6972 - archiveHashes[8] = 0; 6973 - int k = 0; 7012 + private void requestArchiveCrcs() { 7013 + int reconnectionDelay = 5; 7014 + int attempts = 0; 7015 + archiveHashes[8] = 0; 7016 + 6974 7017 while (archiveHashes[8] == 0) { 6975 - String s = "Unknown problem"; 7018 + String error = "Unknown problem"; 7019 + 6976 7020 drawLoadingText(20, "Connecting to web server"); 7021 + 6977 7022 try { 6978 - DataInputStream datainputstream = openJaggrabStream("crc" + (int) (Math.random() * 99999999D) + "-" + 377); 6979 - Buffer class50_sub1_sub2 = new Buffer(new byte[40]); 6980 - datainputstream.readFully(class50_sub1_sub2.buffer, 0, 40); 6981 - datainputstream.close(); 6982 - for (int i1 = 0; i1 < 9; i1++) 6983 - archiveHashes[i1] = class50_sub1_sub2.getInt(); 7023 + DataInputStream stream = openJaggrabStream("crc" + (int) (Math.random() * 99999999D) + "-" + 377); 7024 + Buffer jaggrab = new Buffer(new byte[40]); 6984 7025 6985 - int j1 = class50_sub1_sub2.getInt(); 6986 - int k1 = 1234; 6987 - for (int l1 = 0; l1 < 9; l1++) 6988 - k1 = (k1 << 1) + archiveHashes[l1]; 7026 + stream.readFully(jaggrab.buffer, 0, 40); 7027 + stream.close(); 7028 + 7029 + for (int i = 0; i < 9; i++) 7030 + archiveHashes[i] = jaggrab.getInt(); 7031 + 7032 + int expectedCrc = jaggrab.getInt(); 7033 + int calculatedCrc = 1234; 7034 + 7035 + for (int i = 0; i < 9; i++) 7036 + calculatedCrc = (calculatedCrc << 1) + archiveHashes[i]; 6989 7037 6990 - if (j1 != k1) { 6991 - s = "checksum problem"; 7038 + if (expectedCrc != calculatedCrc) { 7039 + error = "Checksum problem"; 6992 7040 archiveHashes[8] = 0; 6993 7041 } 6994 7042 } catch (EOFException _ex) { 6995 - s = "EOF problem"; 7043 + error = "EOF problem"; 6996 7044 archiveHashes[8] = 0; 6997 7045 } catch (IOException _ex) { 6998 - s = "Connection problem"; 7046 + error = "Connection problem"; 6999 7047 archiveHashes[8] = 0; 7000 7048 } catch (Exception _ex) { 7001 - s = "logic problem"; 7049 + error = "Logic problem"; 7002 7050 archiveHashes[8] = 0; 7051 + 7003 7052 if (!SignLink.reportError) 7004 7053 return; 7005 7054 } 7055 + 7006 7056 if (archiveHashes[8] == 0) { 7007 - k++; 7008 - for (int l = i; l > 0; l--) { 7009 - if (k >= 10) { 7057 + attempts++; 7058 + 7059 + for (int time = reconnectionDelay; time > 0; time--) { 7060 + if (attempts >= 10) { 7010 7061 drawLoadingText(10, "Game updated - please reload page"); 7011 - l = 10; 7062 + 7063 + time = 10; 7012 7064 } else { 7013 - drawLoadingText(10, s + " - Will retry in " + l + " secs."); 7065 + drawLoadingText(10, error + " - Will retry in " + time + " secs."); 7014 7066 } 7067 + 7015 7068 try { 7016 7069 Thread.sleep(1000L); 7017 - } catch (Exception _ex) { 7018 - } 7070 + } catch (Exception ignored) {} 7019 7071 } 7020 7072 7021 - i *= 2; 7022 - if (i > 60) 7023 - i = 60; 7073 + reconnectionDelay *= 2; 7074 + 7075 + if (reconnectionDelay > 60) 7076 + reconnectionDelay = 60; 7077 + 7024 7078 useJaggrab = !useJaggrab; 7025 7079 } 7026 7080 } 7027 7081 } 7028 7082 7029 - public void method87(int i) { 7083 + private void renderMinimap() { 7030 7084 aClass18_1157.createRasterizer(); 7085 + 7031 7086 if (minimapState == 2) { 7032 - byte abyte0[] = minimapBackgroundImage.pixels; 7033 - int ai[] = Rasterizer.pixels; 7034 - int l2 = abyte0.length; 7035 - for (int j5 = 0; j5 < l2; j5++) 7036 - if (abyte0[j5] == 0) 7037 - ai[j5] = 0; 7087 + byte[] mmBackgroundPixels = minimapBackgroundImage.pixels; 7088 + int[] rasterPixels = Rasterizer.pixels; 7089 + int pixelCount = mmBackgroundPixels.length; 7090 + 7091 + for (int i = 0; i < pixelCount; i++) 7092 + if (mmBackgroundPixels[i] == 0) 7093 + rasterPixels[i] = 0; 7038 7094 7039 7095 minimapCompass.shapeImageToPixels(0, 33, 25, 33, anIntArray1286, 0, cameraHorizontal, 256, 7040 7096 anIntArray1180, 25); 7041 7097 aClass18_1158.createRasterizer(); 7098 + 7042 7099 Rasterizer3D.lineOffsets = anIntArray1002; 7043 7100 return; 7044 7101 } 7045 - int j = cameraHorizontal + anInt916 & 0x7ff; 7046 - int k = 48 + localPlayer.worldX / 32; 7047 - i = 58 / i; 7048 - int i3 = 464 - localPlayer.worldY / 32; 7049 - minimapImage.shapeImageToPixels(5, 151, k, 146, anIntArray920, 25, j, 256 + anInt1233, 7050 - anIntArray1019, i3); 7051 - minimapCompass.shapeImageToPixels(0, 33, 25, 33, anIntArray1286, 0, cameraHorizontal, 256, anIntArray1180, 7052 - 25); 7053 - for (int k5 = 0; k5 < minimapHintCount; k5++) { 7054 - int l = (minimapHintX[k5] * 4 + 2) - localPlayer.worldX / 32; 7055 - int j3 = (minimapHintY[k5] * 4 + 2) - localPlayer.worldY / 32; 7056 - drawOnMinimap(minimapHint[k5], l, j3); 7102 + 7103 + int angle = cameraHorizontal + anInt916 & 0x7ff; 7104 + int centerX = 48 + localPlayer.worldX / 32; 7105 + int centerY = 464 - localPlayer.worldY / 32; 7106 + 7107 + minimapImage.shapeImageToPixels(5, 151, centerX, 146, anIntArray920, 7108 + 25, angle, 256 + anInt1233, anIntArray1019, centerY); 7109 + minimapCompass.shapeImageToPixels(0, 33, 25, 33, anIntArray1286, 7110 + 0, cameraHorizontal, 256, anIntArray1180, 25); 7111 + 7112 + for (int i = 0; i < minimapHintCount; i++) { 7113 + int hintX = (minimapHintX[i] * 4 + 2) - localPlayer.worldX / 32; 7114 + int hintY = (minimapHintY[i] * 4 + 2) - localPlayer.worldY / 32; 7115 + 7116 + drawOnMinimap(minimapHint[i], hintX, hintY); 7057 7117 } 7058 7118 7059 - for (int l5 = 0; l5 < 104; l5++) { 7060 - for (int i6 = 0; i6 < 104; i6++) { 7061 - LinkedList class6 = groundItems[plane][l5][i6]; 7062 - if (class6 != null) { 7063 - int i1 = (l5 * 4 + 2) - localPlayer.worldX / 32; 7064 - int k3 = (i6 * 4 + 2) - localPlayer.worldY / 32; 7065 - drawOnMinimap(mapdotItem, i1, k3); 7119 + for (int x = 0; x < 104; x++) { 7120 + for (int y = 0; y < 104; y++) { 7121 + LinkedList itemList = groundItems[plane][x][y]; 7122 + 7123 + if (itemList != null) { 7124 + int itemX = (x * 4 + 2) - localPlayer.worldX / 32; 7125 + int itemY = (y * 4 + 2) - localPlayer.worldY / 32; 7126 + 7127 + drawOnMinimap(mapdotItem, itemX, itemY); 7066 7128 } 7067 7129 } 7068 7130 7069 7131 } 7070 7132 7071 - for (int j6 = 0; j6 < anInt1133; j6++) { 7072 - Npc class50_sub1_sub4_sub3_sub1 = npcs[anIntArray1134[j6]]; 7073 - if (class50_sub1_sub4_sub3_sub1 != null && class50_sub1_sub4_sub3_sub1.isVisible()) { 7074 - ActorDefinition class37 = class50_sub1_sub4_sub3_sub1.npcDefinition; 7075 - if (class37.childrenIds != null) 7076 - class37 = class37.getChildDefinition(); 7077 - if (class37 != null && class37.minimapVisible && class37.clickable) { 7078 - int j1 = class50_sub1_sub4_sub3_sub1.worldX / 32 7079 - - localPlayer.worldX / 32; 7080 - int l3 = class50_sub1_sub4_sub3_sub1.worldY / 32 7081 - - localPlayer.worldY / 32; 7082 - drawOnMinimap(mapdotActor, j1, l3); 7133 + for (int i = 0; i < anInt1133; i++) { 7134 + Npc npc = npcs[anIntArray1134[i]]; 7135 + 7136 + if (npc != null && npc.isVisible()) { 7137 + ActorDefinition definition = npc.npcDefinition; 7138 + 7139 + if (definition.childrenIds != null) 7140 + definition = definition.getChildDefinition(); 7141 + 7142 + if (definition != null && definition.minimapVisible && definition.clickable) { 7143 + int npcX = npc.worldX / 32 - localPlayer.worldX / 32; 7144 + int npcY = npc.worldY / 32 - localPlayer.worldY / 32; 7145 + 7146 + drawOnMinimap(mapdotActor, npcX, npcY); 7083 7147 } 7084 7148 } 7085 7149 } 7086 7150 7087 - for (int k6 = 0; k6 < localPlayerCount; k6++) { 7088 - Player class50_sub1_sub4_sub3_sub2 = players[playerList[k6]]; 7089 - if (class50_sub1_sub4_sub3_sub2 != null && class50_sub1_sub4_sub3_sub2.isVisible()) { 7090 - int k1 = class50_sub1_sub4_sub3_sub2.worldX / 32 7091 - - localPlayer.worldX / 32; 7092 - int i4 = class50_sub1_sub4_sub3_sub2.worldY / 32 7093 - - localPlayer.worldY / 32; 7094 - boolean flag = false; 7095 - long l6 = TextUtils.nameToLong(class50_sub1_sub4_sub3_sub2.playerName); 7096 - for (int i7 = 0; i7 < friendsCount; i7++) { 7097 - if (l6 != friends[i7] || friendWorlds[i7] == 0) 7151 + for (int i = 0; i < localPlayerCount; i++) { 7152 + Player player = players[playerList[i]]; 7153 + 7154 + if (player != null && player.isVisible()) { 7155 + int playerX = player.worldX / 32 - localPlayer.worldX / 32; 7156 + int playerY = player.worldY / 32 - localPlayer.worldY / 32; 7157 + long name = TextUtils.nameToLong(player.playerName); 7158 + boolean isFriend = false; 7159 + boolean isTeammate = false; 7160 + 7161 + for (int x = 0; x < friendsCount; x++) { 7162 + if (name != friends[x] || friendWorlds[x] == 0) 7098 7163 continue; 7099 - flag = true; 7164 + 7165 + isFriend = true; 7100 7166 break; 7101 7167 } 7102 7168 7103 - boolean flag1 = false; 7104 - if (localPlayer.teamId != 0 && class50_sub1_sub4_sub3_sub2.teamId != 0 7105 - && localPlayer.teamId == class50_sub1_sub4_sub3_sub2.teamId) 7106 - flag1 = true; 7107 - if (flag) 7108 - drawOnMinimap(mapdotFriend, k1, i4); 7109 - else if (flag1) 7110 - drawOnMinimap(mapdotTeammate, k1, i4); 7169 + if (localPlayer.teamId != 0 && player.teamId != 0 && localPlayer.teamId == player.teamId) 7170 + isTeammate = true; 7171 + 7172 + if (isFriend) 7173 + drawOnMinimap(mapdotFriend, playerX, playerY); 7174 + else if (isTeammate) 7175 + drawOnMinimap(mapdotTeammate, playerX, playerY); 7111 7176 else 7112 - drawOnMinimap(mapdotPlayer, k1, i4); 7177 + drawOnMinimap(mapdotPlayer, playerX, playerY); 7113 7178 } 7114 7179 } 7115 7180 7116 7181 if (anInt1197 != 0 && pulseCycle % 20 < 10) { 7117 7182 if (anInt1197 == 1 && anInt1226 >= 0 && anInt1226 < npcs.length) { 7118 - Npc class50_sub1_sub4_sub3_sub1_1 = npcs[anInt1226]; 7119 - if (class50_sub1_sub4_sub3_sub1_1 != null) { 7120 - int l1 = class50_sub1_sub4_sub3_sub1_1.worldX / 32 7121 - - localPlayer.worldX / 32; 7122 - int j4 = class50_sub1_sub4_sub3_sub1_1.worldY / 32 7123 - - localPlayer.worldY / 32; 7124 - drawMinimap(aClass50_Sub1_Sub1_Sub1_1037, l1, j4); 7183 + Npc npc = npcs[anInt1226]; 7184 + 7185 + if (npc != null) { 7186 + int npcX = npc.worldX / 32 - localPlayer.worldX / 32; 7187 + int npcY = npc.worldY / 32 - localPlayer.worldY / 32; 7188 + 7189 + drawMinimap(aClass50_Sub1_Sub1_Sub1_1037, npcX, npcY); 7125 7190 } 7126 7191 } 7192 + 7127 7193 if (anInt1197 == 2) { 7128 - int i2 = ((anInt844 - nextTopLeftTileX) * 4 + 2) - localPlayer.worldX / 32; 7129 - int k4 = ((anInt845 - nextTopRightTileY) * 4 + 2) - localPlayer.worldY / 32; 7130 - drawMinimap(aClass50_Sub1_Sub1_Sub1_1037, i2, k4); 7194 + int hintX = ((anInt844 - nextTopLeftTileX) * 4 + 2) - localPlayer.worldX / 32; 7195 + int hintY = ((anInt845 - nextTopRightTileY) * 4 + 2) - localPlayer.worldY / 32; 7196 + 7197 + drawMinimap(aClass50_Sub1_Sub1_Sub1_1037, hintX, hintY); 7131 7198 } 7199 + 7132 7200 if (anInt1197 == 10 && anInt1151 >= 0 && anInt1151 < players.length) { 7133 - Player class50_sub1_sub4_sub3_sub2_1 = players[anInt1151]; 7134 - if (class50_sub1_sub4_sub3_sub2_1 != null) { 7135 - int j2 = class50_sub1_sub4_sub3_sub2_1.worldX / 32 7136 - - localPlayer.worldX / 32; 7137 - int l4 = class50_sub1_sub4_sub3_sub2_1.worldY / 32 7138 - - localPlayer.worldY / 32; 7139 - drawMinimap(aClass50_Sub1_Sub1_Sub1_1037, j2, l4); 7201 + Player player = players[anInt1151]; 7202 + 7203 + if (player != null) { 7204 + int playerX = player.worldX / 32 - localPlayer.worldX / 32; 7205 + int playerY = player.worldY / 32 - localPlayer.worldY / 32; 7206 + 7207 + drawMinimap(aClass50_Sub1_Sub1_Sub1_1037, playerX, playerY); 7140 7208 } 7141 7209 } 7142 7210 } 7211 + 7143 7212 if (destinationX != 0) { 7144 - int k2 = (destinationX * 4 + 2) - localPlayer.worldX / 32; 7145 - int i5 = (destinationY * 4 + 2) - localPlayer.worldY / 32; 7146 - drawOnMinimap(mapFlagMarker, k2, i5); 7213 + int flagX = (destinationX * 4 + 2) - localPlayer.worldX / 32; 7214 + int flagY = (destinationY * 4 + 2) - localPlayer.worldY / 32; 7215 + 7216 + drawOnMinimap(mapFlagMarker, flagX, flagY); 7147 7217 } 7218 + 7148 7219 Rasterizer.drawFilledRectangle(97, 78, 3, 3, 0xffffff); 7149 7220 aClass18_1158.createRasterizer(); 7221 + 7150 7222 Rasterizer3D.lineOffsets = anIntArray1002; 7151 7223 } 7152 7224 ··· 7510 7582 7511 7583 } 7512 7584 7513 - public void method94(int i, int j, int k, int l, int i1, int j1, byte byte0) { 7514 - int k1 = 2048 - k & 0x7ff; 7515 - int l1 = 2048 - i1 & 0x7ff; 7516 - if (byte0 != -103) 7517 - opcode = -1; 7518 - int i2 = 0; 7519 - int j2 = 0; 7520 - int k2 = l; 7521 - if (k1 != 0) { 7522 - int l2 = Model.SINE[k1]; 7523 - int j3 = Model.COSINE[k1]; 7524 - int l3 = j2 * j3 - k2 * l2 >> 16; 7525 - k2 = j2 * l2 + k2 * j3 >> 16; 7526 - j2 = l3; 7585 + private void setCameraPosition(int x, int y, int z, int pitch, int yaw) { 7586 + int pitchDifference = 2048 - pitch & 0x7ff; 7587 + int yawDifference = 2048 - yaw & 0x7ff; 7588 + int xOffset = 0; 7589 + int zOffset = 0; 7590 + int yOffset = 600 + pitch * 3; 7591 + 7592 + if (pitchDifference != 0) { 7593 + int sine = Model.SINE[pitchDifference]; 7594 + int cosine = Model.COSINE[pitchDifference]; 7595 + int temp = zOffset * cosine - yOffset * sine >> 16; 7596 + yOffset = zOffset * sine + yOffset * cosine >> 16; 7597 + zOffset = temp; 7527 7598 } 7528 - if (l1 != 0) { 7529 - int i3 = Model.SINE[l1]; 7530 - int k3 = Model.COSINE[l1]; 7531 - int i4 = k2 * i3 + i2 * k3 >> 16; 7532 - k2 = k2 * k3 - i2 * i3 >> 16; 7533 - i2 = i4; 7599 + 7600 + if (yawDifference != 0) { 7601 + int sine = Model.SINE[yawDifference]; 7602 + int cosine = Model.COSINE[yawDifference]; 7603 + int temp = yOffset * sine + xOffset * cosine >> 16; 7604 + yOffset = yOffset * cosine - xOffset * sine >> 16; 7605 + xOffset = temp; 7534 7606 } 7535 - anInt1216 = j - i2; 7536 - anInt1217 = i - j2; 7537 - anInt1218 = j1 - k2; 7538 - anInt1219 = k; 7539 - anInt1220 = i1; 7607 + 7608 + cameraX = x - xOffset; 7609 + cameraZ = z - zOffset; 7610 + cameraY = y - yOffset; 7611 + anInt1219 = pitch; 7612 + anInt1220 = yaw; 7540 7613 } 7541 7614 7542 7615 public boolean method95(Widget class13, int i) { ··· 8241 8314 8242 8315 public void run() { 8243 8316 if (aBoolean1314) { 8244 - method17((byte) 4); 8317 + processFlamesCycle(); 8245 8318 } else { 8246 8319 super.run(); 8247 8320 } ··· 8571 8644 outBuffer.putByte((int) (Math.random() * 256D)); 8572 8645 outBuffer.putLength(outBuffer.currentPosition - j); 8573 8646 } 8574 - int k = anInt1216 >> 7; 8575 - int l = anInt1218 >> 7; 8647 + int k = cameraX >> 7; 8648 + int l = cameraY >> 7; 8576 8649 int i1 = localPlayer.worldX >> 7; 8577 8650 int j1 = localPlayer.worldY >> 7; 8578 8651 if ((currentSceneTileFlags[plane][k][l] & 4) != 0) ··· 8637 8710 } 8638 8711 8639 8712 public int method118(int i) { 8640 - int j = method110(anInt1218, anInt1216, (byte) 9, plane); 8713 + int j = method110(cameraY, cameraX, (byte) 9, plane); 8641 8714 while (i >= 0) 8642 8715 opcode = buffer.getUnsignedByte(); 8643 - if (j - anInt1217 < 800 && (currentSceneTileFlags[plane][anInt1216 >> 7][anInt1218 >> 7] & 4) != 0) 8716 + if (j - cameraZ < 800 && (currentSceneTileFlags[plane][cameraX >> 7][cameraY >> 7] & 4) != 0) 8644 8717 return plane; 8645 8718 else 8646 8719 return 3; ··· 10564 10637 return; 10565 10638 } 10566 10639 int i1 = method110(k, i, (byte) 9, plane) - j; 10567 - i -= anInt1216; 10568 - i1 -= anInt1217; 10569 - k -= anInt1218; 10640 + i -= cameraX; 10641 + i1 -= cameraZ; 10642 + k -= cameraY; 10570 10643 int j1 = Model.SINE[anInt1219]; 10571 10644 int k1 = Model.COSINE[anInt1219]; 10572 10645 int l1 = Model.SINE[anInt1220]; ··· 11500 11573 if (aBooleanArray927[4] && anIntArray852[4] + 128 > j) 11501 11574 j = anIntArray852[4] + 128; 11502 11575 int l = cameraHorizontal + anInt1255 & 0x7ff; 11503 - method94(method110(localPlayer.worldY, localPlayer.worldX, (byte) 9, 11504 - plane) - 50, anInt1262, j, 600 + j * 3, l, anInt1263, (byte) -103); 11576 + setCameraPosition(anInt1262, anInt1263, method110(localPlayer.worldY, localPlayer.worldX, (byte) 9, 11577 + plane) - 50, j, l); 11505 11578 } 11506 11579 int k; 11507 11580 if (!oriented) 11508 11581 k = method117((byte) 1); 11509 11582 else 11510 11583 k = method118(-276); 11511 - int i1 = anInt1216; 11512 - int j1 = anInt1217; 11513 - int k1 = anInt1218; 11584 + int i1 = cameraX; 11585 + int j1 = cameraZ; 11586 + int k1 = cameraY; 11514 11587 int l1 = anInt1219; 11515 11588 int i2 = anInt1220; 11516 11589 if (i != 2) ··· 11521 11594 .sin((double) quakeTimes[j2] * ((double) anIntArray991[j2] / 100D)) 11522 11595 * (double) anIntArray852[j2]); 11523 11596 if (j2 == 0) 11524 - anInt1216 += k2; 11597 + cameraX += k2; 11525 11598 if (j2 == 1) 11526 - anInt1217 += k2; 11599 + cameraZ += k2; 11527 11600 if (j2 == 2) 11528 - anInt1218 += k2; 11601 + cameraY += k2; 11529 11602 if (j2 == 3) 11530 11603 anInt1220 = anInt1220 + k2 & 0x7ff; 11531 11604 if (j2 == 4) { ··· 11543 11616 Model.anInt1706 = super.mouseX - 4; 11544 11617 Model.anInt1707 = super.mouseY - 4; 11545 11618 Rasterizer.resetPixels(); 11546 - currentScene.method280(anInt1216, k, 0, anInt1217, anInt1218, anInt1220, anInt1219); 11619 + currentScene.method280(cameraX, k, 0, cameraZ, cameraY, anInt1220, anInt1219); 11547 11620 currentScene.method255(); 11548 11621 method121(false); 11549 11622 method127(true); 11550 11623 method65(l2); 11551 11624 method109(30729); 11552 11625 aClass18_1158.drawGraphics(4, 4, super.gameGraphics); 11553 - anInt1216 = i1; 11554 - anInt1217 = j1; 11555 - anInt1218 = k1; 11626 + cameraX = i1; 11627 + cameraZ = j1; 11628 + cameraY = k1; 11556 11629 anInt1219 = l1; 11557 11630 anInt1220 = i2; 11558 11631 }