mirror of
https://github.com/2006-Scape/2006RebottedClient.git
synced 2026-07-02 16:49:02 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
# Project exclude paths
|
||||||
|
/target/
|
||||||
Generated
+19
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="masterDetails">
|
||||||
|
<states>
|
||||||
|
<state key="ProjectJDKs.UI">
|
||||||
|
<settings>
|
||||||
|
<last-edited>1.8</last-edited>
|
||||||
|
<splitter-proportions>
|
||||||
|
<option name="proportions">
|
||||||
|
<list>
|
||||||
|
<option value="0.2" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</splitter-proportions>
|
||||||
|
</settings>
|
||||||
|
</state>
|
||||||
|
</states>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="2006RebottedClient" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+14
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+124
@@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4" />
|
||||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
|||||||
|
#149 item defs
|
||||||
|
#149 npc defs
|
||||||
|
#149 object defs
|
||||||
|
#149 varbits
|
||||||
|
#149 gfx
|
||||||
|
#149 models
|
||||||
|
#149 anims
|
||||||
|
#149 maps
|
||||||
|
#149 idk
|
||||||
|
- Freyr
|
||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 4.7 MiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
м+и
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.rebotted.client</groupId>
|
||||||
|
<artifactId>client</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.insubstantial</groupId>
|
||||||
|
<artifactId>substance</artifactId>
|
||||||
|
<version>7.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.pushing-pixels</groupId>
|
||||||
|
<artifactId>radiance-trident</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-compress</artifactId>
|
||||||
|
<version>1.13</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.tukaani</groupId>
|
||||||
|
<artifactId>xz</artifactId>
|
||||||
|
<version>1.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.fxml</include>
|
||||||
|
<include>**/*.css</include>
|
||||||
|
<include>**/*.png</include>
|
||||||
|
<include>rebotted.colorschemes</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,846 @@
|
|||||||
|
package net.rebotted.cache.graphics;
|
||||||
|
import java.awt.Color;
|
||||||
|
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.cache.graphics.GameFont;
|
||||||
|
import org.rebotted.cache.graphics.Sprite;
|
||||||
|
import org.rebotted.draw.Rasterizer2D;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public class RSFont extends Rasterizer2D {
|
||||||
|
|
||||||
|
public int baseCharacterHeight = 0;
|
||||||
|
public int anInt4142;
|
||||||
|
public int anInt4144;
|
||||||
|
public int[] characterDrawYOffsets;
|
||||||
|
public int[] characterHeights;
|
||||||
|
public int[] characterDrawXOffsets;
|
||||||
|
public int[] characterWidths;
|
||||||
|
public int[] iconWidths;
|
||||||
|
public byte[] aByteArray4151;
|
||||||
|
public byte[][] fontPixels;
|
||||||
|
public int[] characterScreenWidths;
|
||||||
|
public static Sprite[] chatImages;
|
||||||
|
public static Sprite[] clanImages;
|
||||||
|
public static String aRSString_4135;
|
||||||
|
public static String startTransparency;
|
||||||
|
public static String startDefaultShadow;
|
||||||
|
public static String endShadow = "/shad";
|
||||||
|
public static String endEffect;
|
||||||
|
public static String aRSString_4143;
|
||||||
|
public static String endStrikethrough = "/str";
|
||||||
|
public static String aRSString_4147;
|
||||||
|
public static String startColor;
|
||||||
|
public static String lineBreak;
|
||||||
|
public static String startStrikethrough;
|
||||||
|
public static String endColor;
|
||||||
|
public static String startImage;
|
||||||
|
public static String startClanImage;
|
||||||
|
public static String endUnderline;
|
||||||
|
public static String defaultStrikethrough;
|
||||||
|
public static String startShadow;
|
||||||
|
public static String startEffect;
|
||||||
|
public static String aRSString_4162;
|
||||||
|
public static String aRSString_4163;
|
||||||
|
public static String endTransparency;
|
||||||
|
public static String aRSString_4165;
|
||||||
|
public static String startUnderline;
|
||||||
|
public static String startDefaultUnderline;
|
||||||
|
public static String aRSString_4169;
|
||||||
|
public static String[] splitTextStrings;
|
||||||
|
public static int defaultColor;
|
||||||
|
public static int textShadowColor;
|
||||||
|
public static int strikethroughColor;
|
||||||
|
public static int defaultTransparency;
|
||||||
|
public static int anInt4175;
|
||||||
|
public static int underlineColor;
|
||||||
|
public static int defaultShadow;
|
||||||
|
public static int anInt4178;
|
||||||
|
public static int transparency;
|
||||||
|
public static int textColor;
|
||||||
|
|
||||||
|
public RSFont(boolean TypeFont, String s, FileArchive archive) {
|
||||||
|
fontPixels = new byte[256][];
|
||||||
|
characterWidths = new int[256];
|
||||||
|
characterHeights = new int[256];
|
||||||
|
characterDrawXOffsets = new int[256];
|
||||||
|
characterDrawYOffsets = new int[256];
|
||||||
|
characterScreenWidths = new int[256];
|
||||||
|
Buffer stream = new Buffer(archive.readFile(s + ".dat"));
|
||||||
|
Buffer stream_1 = new Buffer(archive.readFile("index.dat"));
|
||||||
|
stream_1.currentPosition = stream.readUShort() + 4;
|
||||||
|
int k = stream_1.readUnsignedByte();
|
||||||
|
if (k > 0) {
|
||||||
|
stream_1.currentPosition += 3 * (k - 1);
|
||||||
|
}
|
||||||
|
for (int l = 0; l < 256; l++) {
|
||||||
|
characterDrawXOffsets[l] = stream_1.readUnsignedByte();
|
||||||
|
characterDrawYOffsets[l] = stream_1.readUnsignedByte();
|
||||||
|
int i1 = characterWidths[l] = stream_1.readUShort();
|
||||||
|
int j1 = characterHeights[l] = stream_1.readUShort();
|
||||||
|
int k1 = stream_1.readUnsignedByte();
|
||||||
|
int l1 = i1 * j1;
|
||||||
|
fontPixels[l] = new byte[l1];
|
||||||
|
if (k1 == 0) {
|
||||||
|
for (int i2 = 0; i2 < l1; i2++) {
|
||||||
|
fontPixels[l][i2] = stream.readSignedByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (k1 == 1) {
|
||||||
|
for (int j2 = 0; j2 < i1; j2++) {
|
||||||
|
for (int l2 = 0; l2 < j1; l2++) {
|
||||||
|
fontPixels[l][j2 + l2 * i1] = stream.readSignedByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (j1 > baseCharacterHeight && l < 128) {
|
||||||
|
baseCharacterHeight = j1;
|
||||||
|
}
|
||||||
|
characterDrawXOffsets[l] = 1;
|
||||||
|
characterScreenWidths[l] = i1 + 2;
|
||||||
|
int k2 = 0;
|
||||||
|
for (int i3 = j1 / 7; i3 < j1; i3++) {
|
||||||
|
k2 += fontPixels[l][i3 * i1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k2 <= j1 / 7) {
|
||||||
|
characterScreenWidths[l]--;
|
||||||
|
characterDrawXOffsets[l] = 0;
|
||||||
|
}
|
||||||
|
k2 = 0;
|
||||||
|
for (int j3 = j1 / 7; j3 < j1; j3++) {
|
||||||
|
k2 += fontPixels[l][(i1 - 1) + j3 * i1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k2 <= j1 / 7) {
|
||||||
|
characterScreenWidths[l]--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TypeFont) {
|
||||||
|
characterScreenWidths[32] = characterScreenWidths[73];
|
||||||
|
} else {
|
||||||
|
characterScreenWidths[32] = characterScreenWidths[105];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawStringMoveY(String string, int drawX, int drawY, int color,
|
||||||
|
int shadow, int randomMod, int randomMod2) {
|
||||||
|
if (string != null) {
|
||||||
|
setColorAndShadow(color, shadow);
|
||||||
|
double d = 7.0 - (double) randomMod2 / 8.0;
|
||||||
|
if (d < 0.0) {
|
||||||
|
d = 0.0;
|
||||||
|
}
|
||||||
|
int[] yOffset = new int[string.length()];
|
||||||
|
for (int index = 0; index < string.length(); index++) {
|
||||||
|
yOffset[index] = (int) (Math.sin((double) index / 1.5 + (double) randomMod) * d);
|
||||||
|
}
|
||||||
|
drawBaseStringMoveXY(string, drawX - getTextWidth(string) / 2, drawY, null, yOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCharacterWidth(int i) {
|
||||||
|
return characterScreenWidths[i & 0xff];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrans(int i, int j, int k) {
|
||||||
|
textShadowColor = defaultShadow = i;
|
||||||
|
textColor = defaultColor = j;
|
||||||
|
transparency = defaultTransparency = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCenteredString(String s, int i, int j) {
|
||||||
|
if(s != null)
|
||||||
|
drawBasicString(s, i - getTextWidth(s) / 2, j);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultTextEffectValues(int color, int shadow, int trans) {
|
||||||
|
strikethroughColor = -1;
|
||||||
|
underlineColor = -1;
|
||||||
|
textShadowColor = defaultShadow = shadow;
|
||||||
|
textColor = defaultColor = color;
|
||||||
|
transparency = defaultTransparency = trans;
|
||||||
|
anInt4178 = 0;
|
||||||
|
anInt4175 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int method1014(byte[][] is, byte[][] is_27_, int[] is_28_,
|
||||||
|
int[] is_29_, int[] is_30_, int i,
|
||||||
|
int i_31_) {
|
||||||
|
int i_32_ = is_28_[i];
|
||||||
|
int i_33_ = i_32_ + is_30_[i];
|
||||||
|
int i_34_ = is_28_[i_31_];
|
||||||
|
int i_35_ = i_34_ + is_30_[i_31_];
|
||||||
|
int i_36_ = i_32_;
|
||||||
|
if (i_34_ > i_32_) {
|
||||||
|
i_36_ = i_34_;
|
||||||
|
}
|
||||||
|
int i_37_ = i_33_;
|
||||||
|
if (i_35_ < i_33_) {
|
||||||
|
i_37_ = i_35_;
|
||||||
|
}
|
||||||
|
int i_38_ = is_29_[i];
|
||||||
|
if (is_29_[i_31_] < i_38_) {
|
||||||
|
i_38_ = is_29_[i_31_];
|
||||||
|
}
|
||||||
|
byte[] is_39_ = is_27_[i];
|
||||||
|
byte[] is_40_ = is[i_31_];
|
||||||
|
int i_41_ = i_36_ - i_32_;
|
||||||
|
int i_42_ = i_36_ - i_34_;
|
||||||
|
for (int i_43_ = i_36_; i_43_ < i_37_; i_43_++) {
|
||||||
|
int i_44_ = is_39_[i_41_++] + is_40_[i_42_++];
|
||||||
|
if (i_44_ < i_38_) {
|
||||||
|
i_38_ = i_44_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -i_38_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCenteredStringMoveXY(String string, int drawX, int drawY, int color,
|
||||||
|
int shadow, int randomMod) {
|
||||||
|
if (string != null) {
|
||||||
|
setColorAndShadow(color, shadow);
|
||||||
|
int[] xMods = new int[string.length()];
|
||||||
|
int[] yMods = new int[string.length()];
|
||||||
|
for (int index = 0; index < string.length(); index++) {
|
||||||
|
xMods[index] = (int) (Math.sin((double) index / 5.0 + (double) randomMod / 5.0) * 5.0);
|
||||||
|
yMods[index] = (int) (Math.sin((double) index / 3.0 + (double) randomMod / 5.0) * 5.0);
|
||||||
|
}
|
||||||
|
drawBaseStringMoveXY(string, drawX - getTextWidth(string) / 2, drawY, xMods,
|
||||||
|
yMods);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCenteredStringMoveY(String class100, int drawX, int drawY, int color,
|
||||||
|
int shadow, int i_54_) {
|
||||||
|
if (class100 != null) {
|
||||||
|
setColorAndShadow(color, shadow);
|
||||||
|
int[] yOffset = new int[class100.length()];
|
||||||
|
for (int index = 0; index < class100.length(); index++) {
|
||||||
|
yOffset[index] = (int) (Math.sin((double) index / 2.0 + (double) i_54_ / 5.0) * 5.0);
|
||||||
|
}
|
||||||
|
drawBaseStringMoveXY(class100, drawX - getTextWidth(class100) / 2, drawY, null,
|
||||||
|
yOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unpackImages(Sprite[] icons, Sprite[] clan) {
|
||||||
|
chatImages = icons;
|
||||||
|
clanImages = clan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawBasicString(String string, int drawX, int drawY) {
|
||||||
|
drawY -= baseCharacterHeight;
|
||||||
|
int startIndex = -1;
|
||||||
|
string = handleOldSyntax(string);
|
||||||
|
for (int currentCharacter = 0; currentCharacter < string.length(); currentCharacter++) {
|
||||||
|
int character = string.charAt(currentCharacter);
|
||||||
|
if (character > 255) {
|
||||||
|
character = 32;
|
||||||
|
}
|
||||||
|
if (character == 60) {
|
||||||
|
startIndex = currentCharacter;
|
||||||
|
} else {
|
||||||
|
if (character == 62 && startIndex != -1) {
|
||||||
|
String effectString = string.substring(startIndex + 1, currentCharacter);
|
||||||
|
startIndex = -1;
|
||||||
|
if (effectString.equals(startEffect)) {
|
||||||
|
character = 60;
|
||||||
|
} else if (effectString.equals(endEffect)) {
|
||||||
|
character = 62;
|
||||||
|
} else if (effectString.equals(aRSString_4135)) {
|
||||||
|
character = 160;
|
||||||
|
} else if (effectString.equals(aRSString_4162)) {
|
||||||
|
character = 173;
|
||||||
|
} else if (effectString.equals(aRSString_4165)) {
|
||||||
|
character = 215;
|
||||||
|
} else if (effectString.equals(aRSString_4147)) {
|
||||||
|
character = 128;
|
||||||
|
} else if (effectString.equals(aRSString_4163)) {
|
||||||
|
character = 169;
|
||||||
|
} else if (effectString.equals(aRSString_4169)) {
|
||||||
|
character = 174;
|
||||||
|
} else {
|
||||||
|
if (effectString.startsWith(startImage)) {
|
||||||
|
try {
|
||||||
|
int imageId = Integer.valueOf(effectString.substring(4));
|
||||||
|
Sprite chatImageId = chatImages[imageId];
|
||||||
|
int iconModY = chatImageId.getMaxHeight();
|
||||||
|
if (transparency == 256) {
|
||||||
|
chatImageId.method346(drawX, (drawY + baseCharacterHeight - iconModY));
|
||||||
|
} else {
|
||||||
|
chatImageId.drawSprite(drawX,(drawY + baseCharacterHeight - iconModY), transparency);
|
||||||
|
}
|
||||||
|
drawX += chatImageId.getMaxWidth();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
} else if (effectString.startsWith(startClanImage)) {
|
||||||
|
try {
|
||||||
|
int imageId = Integer.valueOf(effectString
|
||||||
|
.substring(5));
|
||||||
|
Sprite icon = clanImages[imageId];
|
||||||
|
int iconModY = icon.getMyHeight() + icon.getOffsetY()
|
||||||
|
+ 1;
|
||||||
|
if (transparency == 256) {
|
||||||
|
icon.drawSprite(drawX, (drawY
|
||||||
|
+ baseCharacterHeight - iconModY));
|
||||||
|
} else {
|
||||||
|
icon.drawSprite(drawX, (drawY
|
||||||
|
+ baseCharacterHeight - iconModY),
|
||||||
|
transparency);
|
||||||
|
}
|
||||||
|
drawX += 11;
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setTextEffects(effectString);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (startIndex == -1) {
|
||||||
|
int width = characterWidths[character];
|
||||||
|
int height = characterHeights[character];
|
||||||
|
if (character != 32) {
|
||||||
|
if (transparency == 256) {
|
||||||
|
if (textShadowColor != -1) {
|
||||||
|
drawCharacter(character,
|
||||||
|
drawX + characterDrawXOffsets[character] + 1,
|
||||||
|
drawY + characterDrawYOffsets[character] + 1,
|
||||||
|
width, height, textShadowColor, true);
|
||||||
|
}
|
||||||
|
drawCharacter(character, drawX + characterDrawXOffsets[character],
|
||||||
|
drawY + characterDrawYOffsets[character], width,
|
||||||
|
height, textColor, false);
|
||||||
|
} else {
|
||||||
|
if (textShadowColor != -1) {
|
||||||
|
drawTransparentCharacter(character,
|
||||||
|
drawX + characterDrawXOffsets[character] + 1,
|
||||||
|
drawY + characterDrawYOffsets[character] + 1,
|
||||||
|
width, height, textShadowColor, transparency,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
drawTransparentCharacter(character, drawX + characterDrawXOffsets[character],
|
||||||
|
drawY + characterDrawYOffsets[character], width,
|
||||||
|
height, textColor, transparency, false);
|
||||||
|
}
|
||||||
|
} else if (anInt4178 > 0) {
|
||||||
|
anInt4175 += anInt4178;
|
||||||
|
drawX += anInt4175 >> 8;
|
||||||
|
anInt4175 &= 0xff;
|
||||||
|
}
|
||||||
|
int lineWidth = characterScreenWidths[character];
|
||||||
|
if (strikethroughColor != -1) {
|
||||||
|
GameFont.drawHorizontalLine(drawX, drawY + (int) ((double) baseCharacterHeight * 0.69999999999999996D), lineWidth, strikethroughColor);
|
||||||
|
}
|
||||||
|
if (underlineColor != -1) {
|
||||||
|
GameFont.drawHorizontalLine(drawX, drawY + baseCharacterHeight, lineWidth, underlineColor);
|
||||||
|
}
|
||||||
|
drawX += lineWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawRAString(String string, int drawX, int drawY, int color,
|
||||||
|
int shadow) {
|
||||||
|
if (string != null) {
|
||||||
|
setColorAndShadow(color, shadow);
|
||||||
|
drawBasicString(string, drawX - getTextWidth(string), drawY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawBaseStringMoveXY(String string, int drawX, int drawY, int[] xModifier,
|
||||||
|
int[] yModifier) {
|
||||||
|
drawY -= baseCharacterHeight;
|
||||||
|
int startIndex = -1;
|
||||||
|
int modifierOffset = 0;
|
||||||
|
for (int currentCharacter = 0; currentCharacter < string.length(); currentCharacter++) {
|
||||||
|
int character = string.charAt(currentCharacter);
|
||||||
|
if (character == 60) {
|
||||||
|
startIndex = currentCharacter;
|
||||||
|
} else {
|
||||||
|
if (character == 62 && startIndex != -1) {
|
||||||
|
String effectString = string.substring(startIndex + 1, currentCharacter);
|
||||||
|
startIndex = -1;
|
||||||
|
if (effectString.equals(startEffect)) {
|
||||||
|
character = 60;
|
||||||
|
} else if (effectString.equals(endEffect)) {
|
||||||
|
character = 62;
|
||||||
|
} else if (effectString.equals(aRSString_4135)) {
|
||||||
|
character = 160;
|
||||||
|
} else if (effectString.equals(aRSString_4162)) {
|
||||||
|
character = 173;
|
||||||
|
} else if (effectString.equals(aRSString_4165)) {
|
||||||
|
character = 215;
|
||||||
|
} else if (effectString.equals(aRSString_4147)) {
|
||||||
|
character = 128;
|
||||||
|
} else if (effectString.equals(aRSString_4163)) {
|
||||||
|
character = 169;
|
||||||
|
} else if (effectString.equals(aRSString_4169)) {
|
||||||
|
character = 174;
|
||||||
|
} else {
|
||||||
|
if (effectString.startsWith(startImage)) {
|
||||||
|
try {
|
||||||
|
int xModI;
|
||||||
|
if (xModifier != null) {
|
||||||
|
xModI = xModifier[modifierOffset];
|
||||||
|
} else {
|
||||||
|
xModI = 0;
|
||||||
|
}
|
||||||
|
int yMod;
|
||||||
|
if (yModifier != null) {
|
||||||
|
yMod = yModifier[modifierOffset];
|
||||||
|
} else {
|
||||||
|
yMod = 0;
|
||||||
|
}
|
||||||
|
modifierOffset++;
|
||||||
|
int iconId = Integer.valueOf(effectString.substring(4));
|
||||||
|
Sprite class92 = chatImages[iconId];
|
||||||
|
int iconOffsetY = class92.getMaxHeight();
|
||||||
|
if (transparency == 256) {
|
||||||
|
class92.drawSprite(drawX + xModI,
|
||||||
|
(drawY + baseCharacterHeight - iconOffsetY + yMod));
|
||||||
|
} else {
|
||||||
|
class92.drawSprite(drawX + xModI,
|
||||||
|
(drawY + baseCharacterHeight - iconOffsetY + yMod),
|
||||||
|
transparency);
|
||||||
|
}
|
||||||
|
drawX += class92.getMaxWidth();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setTextEffects(effectString);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (startIndex == -1) {
|
||||||
|
int width = characterWidths[character];
|
||||||
|
int height = characterHeights[character];
|
||||||
|
int xOff;
|
||||||
|
if (xModifier != null) {
|
||||||
|
xOff = xModifier[modifierOffset];
|
||||||
|
} else {
|
||||||
|
xOff = 0;
|
||||||
|
}
|
||||||
|
int yOff;
|
||||||
|
if (yModifier != null) {
|
||||||
|
yOff = yModifier[modifierOffset];
|
||||||
|
} else {
|
||||||
|
yOff = 0;
|
||||||
|
}
|
||||||
|
modifierOffset++;
|
||||||
|
if (character != 32) {
|
||||||
|
if (transparency == 256) {
|
||||||
|
if (textShadowColor != -1) {
|
||||||
|
drawCharacter(character,
|
||||||
|
(drawX + characterDrawXOffsets[character] + 1 + xOff),
|
||||||
|
(drawY + characterDrawYOffsets[character] + 1 + yOff),
|
||||||
|
width, height, textShadowColor, true);
|
||||||
|
}
|
||||||
|
drawCharacter(character,
|
||||||
|
drawX + characterDrawXOffsets[character] + xOff,
|
||||||
|
drawY + characterDrawYOffsets[character] + yOff,
|
||||||
|
width, height, textColor, false);
|
||||||
|
} else {
|
||||||
|
if (textShadowColor != -1) {
|
||||||
|
drawTransparentCharacter(character,
|
||||||
|
(drawX + characterDrawXOffsets[character] + 1 + xOff),
|
||||||
|
(drawY + characterDrawYOffsets[character] + 1 + yOff),
|
||||||
|
width, height, textShadowColor,
|
||||||
|
transparency, true);
|
||||||
|
}
|
||||||
|
drawTransparentCharacter(character,
|
||||||
|
drawX + characterDrawXOffsets[character] + xOff,
|
||||||
|
drawY + characterDrawYOffsets[character] + yOff,
|
||||||
|
width, height, textColor, transparency,
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
} else if (anInt4178 > 0) {
|
||||||
|
anInt4175 += anInt4178;
|
||||||
|
drawX += anInt4175 >> 8;
|
||||||
|
anInt4175 &= 0xff;
|
||||||
|
}
|
||||||
|
int i_109_ = characterScreenWidths[character];
|
||||||
|
if (strikethroughColor != -1) {
|
||||||
|
GameFont.drawHorizontalLine(drawX, drawY + (int) ((double) baseCharacterHeight * 0.7), i_109_, strikethroughColor);
|
||||||
|
}
|
||||||
|
if (underlineColor != -1) {
|
||||||
|
GameFont.drawHorizontalLine(drawX, drawY + baseCharacterHeight, i_109_, underlineColor);
|
||||||
|
}
|
||||||
|
drawX += i_109_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextEffects(String string) {
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
if (string.startsWith(startColor)) {
|
||||||
|
String color = string.substring(4);
|
||||||
|
textColor = color.length() < 6 ? Color.decode(color).getRGB() : Integer.parseInt(color, 16);
|
||||||
|
} else if (string.equals(endColor)) {
|
||||||
|
textColor = defaultColor;
|
||||||
|
} else if (string.startsWith(startTransparency)) {
|
||||||
|
transparency = Integer.valueOf(string.substring(6));
|
||||||
|
} else if (string.equals(endTransparency)) {
|
||||||
|
transparency = defaultTransparency;
|
||||||
|
} else if (string.startsWith(startStrikethrough)) {
|
||||||
|
strikethroughColor = Integer.valueOf(string.substring(4));
|
||||||
|
} else if (string.equals(defaultStrikethrough)) {
|
||||||
|
strikethroughColor = 8388608;
|
||||||
|
} else if (string.equals(endStrikethrough)) {
|
||||||
|
strikethroughColor = -1;
|
||||||
|
} else if (string.startsWith(startUnderline)) {
|
||||||
|
underlineColor = Integer.valueOf(string.substring(2));
|
||||||
|
} else if (string.equals(startDefaultUnderline)) {
|
||||||
|
underlineColor = 0;
|
||||||
|
} else if (string.equals(endUnderline)) {
|
||||||
|
underlineColor = -1;
|
||||||
|
} else if (string.startsWith(startShadow)) {
|
||||||
|
textShadowColor = Integer.valueOf(string.substring(5));
|
||||||
|
} else if (string.equals(startDefaultShadow)) {
|
||||||
|
textShadowColor = 0;
|
||||||
|
} else if (string.equals(endShadow)) {
|
||||||
|
textShadowColor = defaultShadow;
|
||||||
|
} else {
|
||||||
|
if (!string.equals(lineBreak)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setDefaultTextEffectValues(defaultColor, defaultShadow, defaultTransparency);
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} while (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColorAndShadow(int color, int shadow) {
|
||||||
|
strikethroughColor = -1;
|
||||||
|
underlineColor = -1;
|
||||||
|
textShadowColor = defaultShadow = shadow;
|
||||||
|
textColor = defaultColor = color;
|
||||||
|
transparency = defaultTransparency = 256;
|
||||||
|
anInt4178 = 0;
|
||||||
|
anInt4175 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextWidth(String string) {
|
||||||
|
if (string == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int startIndex = -1;
|
||||||
|
int finalWidth = 0;
|
||||||
|
for (int currentCharacter = 0; currentCharacter < string.length(); currentCharacter++) {
|
||||||
|
int character = string.charAt(currentCharacter);
|
||||||
|
if (character > 255) {
|
||||||
|
character = 32;
|
||||||
|
}
|
||||||
|
if (character == 60) {
|
||||||
|
startIndex = currentCharacter;
|
||||||
|
} else {
|
||||||
|
if (character == 62 && startIndex != -1) {
|
||||||
|
String effectString = string.substring(startIndex + 1, currentCharacter);
|
||||||
|
startIndex = -1;
|
||||||
|
if (effectString.equals(startEffect)) {
|
||||||
|
character = 60;
|
||||||
|
} else if (effectString.equals(endEffect)) {
|
||||||
|
character = 62;
|
||||||
|
} else if (effectString.equals(aRSString_4135)) {
|
||||||
|
character = 160;
|
||||||
|
} else if (effectString.equals(aRSString_4162)) {
|
||||||
|
character = 173;
|
||||||
|
} else if (effectString.equals(aRSString_4165)) {
|
||||||
|
character = 215;
|
||||||
|
} else if (effectString.equals(aRSString_4147)) {
|
||||||
|
character = 128;
|
||||||
|
} else if (effectString.equals(aRSString_4163)) {
|
||||||
|
character = 169;
|
||||||
|
} else if (effectString.equals(aRSString_4169)) {
|
||||||
|
character = 174;
|
||||||
|
} else {
|
||||||
|
if (effectString.startsWith(startImage)) {
|
||||||
|
try {//<img=
|
||||||
|
int iconId = Integer.valueOf(effectString.substring(4));
|
||||||
|
finalWidth += chatImages[iconId].getMaxWidth();
|
||||||
|
} catch (Exception exception) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (startIndex == -1) {
|
||||||
|
finalWidth += characterScreenWidths[character];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return finalWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawBasicString(String string, int drawX, int drawY, int color,
|
||||||
|
int shadow) {
|
||||||
|
if (string != null) {
|
||||||
|
setColorAndShadow(color, shadow);
|
||||||
|
drawBasicString(string, drawX, drawY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCenteredString(String string, int drawX, int drawY, int color,
|
||||||
|
int shadow) {
|
||||||
|
if (string != null) {
|
||||||
|
setColorAndShadow(color, shadow);
|
||||||
|
string = handleOldSyntax(string);
|
||||||
|
drawBasicString(string, drawX - getTextWidth(string) / 2, drawY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void nullLoader() {
|
||||||
|
startEffect = null;
|
||||||
|
endEffect = null;
|
||||||
|
aRSString_4135 = null;
|
||||||
|
aRSString_4162 = null;
|
||||||
|
aRSString_4165 = null;
|
||||||
|
aRSString_4147 = null;
|
||||||
|
aRSString_4163 = null;
|
||||||
|
aRSString_4169 = null;
|
||||||
|
startImage = null;
|
||||||
|
lineBreak = null;
|
||||||
|
startColor = null;
|
||||||
|
endColor = null;
|
||||||
|
startTransparency = null;
|
||||||
|
endTransparency = null;
|
||||||
|
startUnderline = null;
|
||||||
|
startDefaultUnderline = null;
|
||||||
|
endUnderline = null;
|
||||||
|
startShadow = null;
|
||||||
|
startDefaultShadow = null;
|
||||||
|
endShadow = null;
|
||||||
|
startStrikethrough = null;
|
||||||
|
defaultStrikethrough = null;
|
||||||
|
endStrikethrough = null;
|
||||||
|
aRSString_4143 = null;
|
||||||
|
splitTextStrings = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createTransparentCharacterPixels(int[] is, byte[] is_0_, int i, int i_1_,
|
||||||
|
int i_2_, int i_3_, int i_4_, int i_5_,
|
||||||
|
int i_6_, int i_7_) {
|
||||||
|
i = ((i & 0xff00ff) * i_7_ & ~0xff00ff) + ((i & 0xff00) * i_7_ & 0xff0000) >> 8;
|
||||||
|
i_7_ = 256 - i_7_;
|
||||||
|
for (int i_8_ = -i_4_; i_8_ < 0; i_8_++) {
|
||||||
|
for (int i_9_ = -i_3_; i_9_ < 0; i_9_++) {
|
||||||
|
if (is_0_[i_1_++] != 0) {
|
||||||
|
int i_10_ = is[i_2_];
|
||||||
|
is[i_2_++] = ((((i_10_ & 0xff00ff) * i_7_ & ~0xff00ff) + ((i_10_ & 0xff00) * i_7_ & 0xff0000)) >> 8) + i;
|
||||||
|
} else {
|
||||||
|
i_2_++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i_2_ += i_5_;
|
||||||
|
i_1_ += i_6_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawTransparentCharacter(int i, int i_11_, int i_12_, int i_13_, int i_14_,
|
||||||
|
int i_15_, int i_16_, boolean bool) {
|
||||||
|
int i_17_ = i_11_ + i_12_ * Rasterizer2D.width;
|
||||||
|
int i_18_ = Rasterizer2D.width - i_13_;
|
||||||
|
int i_19_ = 0;
|
||||||
|
int i_20_ = 0;
|
||||||
|
if (i_12_ < Rasterizer2D.topY) {
|
||||||
|
int i_21_ = Rasterizer2D.topY - i_12_;
|
||||||
|
i_14_ -= i_21_;
|
||||||
|
i_12_ = Rasterizer2D.topY;
|
||||||
|
i_20_ += i_21_ * i_13_;
|
||||||
|
i_17_ += i_21_ * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (i_12_ + i_14_ > Rasterizer2D.bottomY) {
|
||||||
|
i_14_ -= i_12_ + i_14_ - Rasterizer2D.bottomY;
|
||||||
|
}
|
||||||
|
if (i_11_ < Rasterizer2D.leftX) {
|
||||||
|
int i_22_ = Rasterizer2D.leftX - i_11_;
|
||||||
|
i_13_ -= i_22_;
|
||||||
|
i_11_ = Rasterizer2D.leftX;
|
||||||
|
i_20_ += i_22_;
|
||||||
|
i_17_ += i_22_;
|
||||||
|
i_19_ += i_22_;
|
||||||
|
i_18_ += i_22_;
|
||||||
|
}
|
||||||
|
if (i_11_ + i_13_ > Rasterizer2D.bottomX) {
|
||||||
|
int i_23_ = i_11_ + i_13_ - Rasterizer2D.bottomX;
|
||||||
|
i_13_ -= i_23_;
|
||||||
|
i_19_ += i_23_;
|
||||||
|
i_18_ += i_23_;
|
||||||
|
}
|
||||||
|
if (i_13_ > 0 && i_14_ > 0) {
|
||||||
|
createTransparentCharacterPixels(Rasterizer2D.pixels, fontPixels[i], i_15_ ,i_20_, i_17_, i_13_, i_14_, i_18_, i_19_, i_16_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createCharacterPixels(int[] is, byte[] is_24_, int i, int i_25_,
|
||||||
|
int i_26_, int i_27_, int i_28_, int i_29_,
|
||||||
|
int i_30_) {
|
||||||
|
int i_31_ = -(i_27_ >> 2);
|
||||||
|
i_27_ = -(i_27_ & 0x3);
|
||||||
|
for (int i_32_ = -i_28_; i_32_ < 0; i_32_++) {
|
||||||
|
for (int i_33_ = i_31_; i_33_ < 0; i_33_++) {
|
||||||
|
if (is_24_[i_25_++] != 0) {
|
||||||
|
is[i_26_++] = i;
|
||||||
|
} else {
|
||||||
|
i_26_++;
|
||||||
|
}
|
||||||
|
if (is_24_[i_25_++] != 0) {
|
||||||
|
is[i_26_++] = i;
|
||||||
|
} else {
|
||||||
|
i_26_++;
|
||||||
|
}
|
||||||
|
if (is_24_[i_25_++] != 0) {
|
||||||
|
is[i_26_++] = i;
|
||||||
|
} else {
|
||||||
|
i_26_++;
|
||||||
|
}
|
||||||
|
if (is_24_[i_25_++] != 0) {
|
||||||
|
is[i_26_++] = i;
|
||||||
|
} else {
|
||||||
|
i_26_++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i_34_ = i_27_; i_34_ < 0; i_34_++) {
|
||||||
|
if (is_24_[i_25_++] != 0) {
|
||||||
|
is[i_26_++] = i;
|
||||||
|
} else {
|
||||||
|
i_26_++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i_26_ += i_29_;
|
||||||
|
i_25_ += i_30_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String handleOldSyntax(String text) {
|
||||||
|
text = text.replaceAll("@red@", "<col=ff0000>");
|
||||||
|
text = text.replaceAll("@gre@", "<col=65280>");
|
||||||
|
text = text.replaceAll("@blu@", "<col=255>");
|
||||||
|
text = text.replaceAll("@yel@", "<col=ffff00>");
|
||||||
|
text = text.replaceAll("@cya@", "<col=65535>");
|
||||||
|
text = text.replaceAll("@mag@", "<col=ff00ff>");
|
||||||
|
text = text.replaceAll("@whi@", "<col=ffffff>");
|
||||||
|
text = text.replaceAll("@lre@", "<col=ff9040>");
|
||||||
|
text = text.replaceAll("@dre@", "<col=800000>");
|
||||||
|
text = text.replaceAll("@bla@", "<col=0>");
|
||||||
|
text = text.replaceAll("@or1@", "<col=ffb000>");
|
||||||
|
text = text.replaceAll("@or2@", "<col=ff7000>");
|
||||||
|
text = text.replaceAll("@or3@", "<col=ff3000>");
|
||||||
|
text = text.replaceAll("@gr1@", "<col=c0ff00>");
|
||||||
|
text = text.replaceAll("@gr2@", "<col=80ff00>");
|
||||||
|
text = text.replaceAll("@gr3@", "<col=40ff00>");
|
||||||
|
text = text.replaceAll("@RED@", "<col=ffff00>");
|
||||||
|
text = text.replaceAll("@GRE@", "<col=65280>");
|
||||||
|
text = text.replaceAll("@BLU@", "<col=255>");
|
||||||
|
text = text.replaceAll("@YEL@", "<col=ff0000>");
|
||||||
|
text = text.replaceAll("@CYA@", "<col=65535>");
|
||||||
|
text = text.replaceAll("@MAG@", "<col=ff00ff>");
|
||||||
|
text = text.replaceAll("@WHI@", "<col=ffffff>");
|
||||||
|
text = text.replaceAll("@LRE@", "<col=ff9040>");
|
||||||
|
text = text.replaceAll("@DRE@", "<col=800000>");
|
||||||
|
text = text.replaceAll("@BLA@", "<col=0>");
|
||||||
|
text = text.replaceAll("@OR1@", "<col=ffb000>");
|
||||||
|
text = text.replaceAll("@OR2@", "<col=ff7000>");
|
||||||
|
text = text.replaceAll("@OR3@", "<col=ff3000>");
|
||||||
|
text = text.replaceAll("@GR1@", "<col=c0ff00>");
|
||||||
|
text = text.replaceAll("@GR2@", "<col=80ff00>");
|
||||||
|
text = text.replaceAll("@GR3@", "<col=40ff00>");
|
||||||
|
text = text.replaceAll("@cr1@", "<img=0>");
|
||||||
|
text = text.replaceAll("@cr2@", "<img=2>");
|
||||||
|
text = text.replaceAll("@cr3@", "<img=3>");
|
||||||
|
text = text.replaceAll("@cr4@", "<img=4>");
|
||||||
|
text = text.replaceAll("@cr5@", "<img=5>");
|
||||||
|
text = text.replaceAll("@cr6@", "<img=6>");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCharacter(int character, int i_35_, int i_36_, int i_37_, int i_38_,
|
||||||
|
int i_39_, boolean bool) {
|
||||||
|
int i_40_ = i_35_ + i_36_ * Rasterizer2D.width;
|
||||||
|
int i_41_ = Rasterizer2D.width - i_37_;
|
||||||
|
int i_42_ = 0;
|
||||||
|
int i_43_ = 0;
|
||||||
|
if (i_36_ < Rasterizer2D.topY) {
|
||||||
|
int i_44_ = Rasterizer2D.topY - i_36_;
|
||||||
|
i_38_ -= i_44_;
|
||||||
|
i_36_ = Rasterizer2D.topY;
|
||||||
|
i_43_ += i_44_ * i_37_;
|
||||||
|
i_40_ += i_44_ * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (i_36_ + i_38_ > Rasterizer2D.bottomY) {
|
||||||
|
i_38_ -= i_36_ + i_38_ - Rasterizer2D.bottomY;
|
||||||
|
}
|
||||||
|
if (i_35_ < Rasterizer2D.leftX) {
|
||||||
|
int i_45_ = Rasterizer2D.leftX - i_35_;
|
||||||
|
i_37_ -= i_45_;
|
||||||
|
i_35_ = Rasterizer2D.leftX;
|
||||||
|
i_43_ += i_45_;
|
||||||
|
i_40_ += i_45_;
|
||||||
|
i_42_ += i_45_;
|
||||||
|
i_41_ += i_45_;
|
||||||
|
}
|
||||||
|
if (i_35_ + i_37_ > Rasterizer2D.bottomX) {
|
||||||
|
int i_46_ = i_35_ + i_37_ - Rasterizer2D.bottomX;
|
||||||
|
i_37_ -= i_46_;
|
||||||
|
i_42_ += i_46_;
|
||||||
|
i_41_ += i_46_;
|
||||||
|
}
|
||||||
|
if (i_37_ > 0 && i_38_ > 0) {
|
||||||
|
createCharacterPixels(Rasterizer2D.pixels, fontPixels[character],
|
||||||
|
i_39_, i_43_, i_40_, i_37_, i_38_, i_41_, i_42_);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
startTransparency = "trans=";
|
||||||
|
startStrikethrough = "str=";
|
||||||
|
startDefaultShadow = "shad";
|
||||||
|
startColor = "col=";
|
||||||
|
lineBreak = "br";
|
||||||
|
defaultStrikethrough = "str";
|
||||||
|
endUnderline = "/u";
|
||||||
|
startImage = "img=";
|
||||||
|
startClanImage = "clan=";
|
||||||
|
startShadow = "shad=";
|
||||||
|
startUnderline = "u=";
|
||||||
|
endColor = "/col";
|
||||||
|
startDefaultUnderline = "u";
|
||||||
|
endTransparency = "/trans";
|
||||||
|
aRSString_4143 = Integer.toString(100);
|
||||||
|
aRSString_4135 = "nbsp";
|
||||||
|
aRSString_4169 = "reg";
|
||||||
|
aRSString_4165 = "times";
|
||||||
|
aRSString_4162 = "shy";
|
||||||
|
aRSString_4163 = "copy";
|
||||||
|
endEffect = "gt";
|
||||||
|
aRSString_4147 = "euro";
|
||||||
|
startEffect = "lt";
|
||||||
|
defaultTransparency = 256;
|
||||||
|
defaultShadow = -1;
|
||||||
|
anInt4175 = 0;
|
||||||
|
textShadowColor = -1;
|
||||||
|
textColor = 0;
|
||||||
|
defaultColor = 0;
|
||||||
|
strikethroughColor = -1;
|
||||||
|
splitTextStrings = new String[100];
|
||||||
|
underlineColor = -1;
|
||||||
|
anInt4178 = 0;
|
||||||
|
transparency = 256;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package net.rebotted.net.protocol;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class containing protocol-related constants.
|
||||||
|
* @author SeVen
|
||||||
|
*/
|
||||||
|
public class ProtocolConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signifies a connection to the game server.
|
||||||
|
*/
|
||||||
|
public static final int GAME_SEVER_OPCODE = 14;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The algorithm to encrypt to the login block.
|
||||||
|
*/
|
||||||
|
public static final int LOGIN_BLOCK_ENCRYPTION_KEY = (0x24 + 0x1 + 0x1 + 0x2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The magic number.
|
||||||
|
*/
|
||||||
|
public static final int MAGIC_NUMBER_OPCODE = 0xFF;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signifies a new connection.
|
||||||
|
*/
|
||||||
|
public static final int NEW_CONNECTION_OPCODE = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signifies the return of an existing connection.
|
||||||
|
*/
|
||||||
|
public static final int RECONNECTION_OPCODE = 18;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signifies the client's protocol revision.
|
||||||
|
*/
|
||||||
|
public static final int PROTOCOL_REVISION = 317;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package net.rebotted.scene.graphic;
|
||||||
|
import org.rebotted.draw.Rasterizer2D;
|
||||||
|
import org.rebotted.draw.Rasterizer3D;
|
||||||
|
|
||||||
|
public class Fog {
|
||||||
|
/**
|
||||||
|
* Grabs distance from player.
|
||||||
|
*/
|
||||||
|
private float fogDistance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the fog color.
|
||||||
|
*/
|
||||||
|
public static int setColor = 0xA7C5C7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fogStartDistance
|
||||||
|
* @param fogEndDistance
|
||||||
|
* @param fogIntensity
|
||||||
|
*/
|
||||||
|
public void renderFog(boolean belowGround, int fogStartDistance, int fogEndDistance, int fogIntensity) {
|
||||||
|
getColor(setColor);
|
||||||
|
int pos = Rasterizer3D.scanOffsets[0];
|
||||||
|
int src, dst, alpha;
|
||||||
|
int fogBegin = (int) (fogStartDistance + fogDistance);
|
||||||
|
int fogEnd = (int) (fogEndDistance + fogDistance);
|
||||||
|
for (int y = 0; y < Rasterizer2D.bottomY; y++) {
|
||||||
|
for (int x = 0; x < Rasterizer2D.lastX; x++) {
|
||||||
|
if (Rasterizer2D.depthBuffer[pos] >= fogEnd) {
|
||||||
|
Rasterizer2D.pixels[pos] = setColor;
|
||||||
|
} else if (Rasterizer2D.depthBuffer[pos] >= fogBegin) {
|
||||||
|
alpha = (int)(Rasterizer2D.depthBuffer[pos] - fogBegin) / fogIntensity;
|
||||||
|
src = ((setColor & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((setColor & 0xff00) * alpha >> 8 & 0xff00);
|
||||||
|
alpha = 256 - alpha;
|
||||||
|
dst = Rasterizer2D.pixels[pos];
|
||||||
|
dst = ((dst & 0xff00ff) * alpha >> 8 & 0xff00ff) + ((dst & 0xff00) * alpha >> 8 & 0xff00);
|
||||||
|
Rasterizer2D.pixels[pos] = src + dst;
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
pos += Rasterizer2D.width - Rasterizer2D.lastX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fogDistance
|
||||||
|
*/
|
||||||
|
public void setFogDistance(float fogDistance) {
|
||||||
|
this.fogDistance = fogDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fogColor
|
||||||
|
*/
|
||||||
|
public void getColor(int fogColor) {
|
||||||
|
setColor = fogColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,160 @@
|
|||||||
|
package org.rebotted;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main configuration for the Client
|
||||||
|
*
|
||||||
|
* @author Freyr
|
||||||
|
*/
|
||||||
|
public final class Configuration {
|
||||||
|
|
||||||
|
private Configuration() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final BigInteger RSA_MODULUS = new BigInteger(
|
||||||
|
"91553247461173033466542043374346300088148707506479543786501537350363031301992107112953015516557748875487935404852620239974482067336878286174236183516364787082711186740254168914127361643305190640280157664988536979163450791820893999053469529344247707567448479470137716627440246788713008490213212272520901741443");
|
||||||
|
|
||||||
|
public static final BigInteger RSA_EXPONENT = new BigInteger("65537");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends client-related debug messages to the client output stream
|
||||||
|
*/
|
||||||
|
public static boolean client_debug = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The address of the server that the client will be connecting to
|
||||||
|
*/
|
||||||
|
public static String server_address = "2006rebotted.hopto.org";
|
||||||
|
|
||||||
|
public static final String CACHE_DIRECTORY = "./Cache/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The port of the server that the client will be connecting to
|
||||||
|
*/
|
||||||
|
public static int server_port = 43594;
|
||||||
|
|
||||||
|
public static boolean useJaggrab = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles a security feature called RSA to prevent packet sniffers
|
||||||
|
*/
|
||||||
|
public static final boolean ENABLE_RSA = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The url that the users will get redirected to after clicking "New User"
|
||||||
|
*/
|
||||||
|
public static final String REGISTER_ACCOUNT = "www.google.com";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A string which indicates the Client's name.
|
||||||
|
*/
|
||||||
|
public static final String CLIENT_NAME = "2006Rebotted";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps map region images when new regions are loaded.
|
||||||
|
*/
|
||||||
|
public static boolean dumpMapRegions = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays debug messages on loginscreen and in-game
|
||||||
|
*/
|
||||||
|
public static boolean clientData = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the use of music played through the client
|
||||||
|
*/
|
||||||
|
public static boolean enableMusic = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the ability for a player to see roofs in-game
|
||||||
|
*/
|
||||||
|
public static boolean enableRoofs = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for change worlds button on login screen
|
||||||
|
*/
|
||||||
|
public static boolean worldSwitch = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables extra frames in-between animations to give the animation a smooth
|
||||||
|
* look
|
||||||
|
*/
|
||||||
|
public static boolean enableTweening = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to repack indexes Index 1 = Models Index 2 = Animations Index 3 =
|
||||||
|
* Sounds/Music Index 4 = Maps
|
||||||
|
*/
|
||||||
|
public static boolean repackIndexOne = false, repackIndexTwo = false, repackIndexThree = false,
|
||||||
|
repackIndexFour = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump Indexes Index 1 = Models Index 2 = Animations Index 3 = Sounds/Music
|
||||||
|
* Index 4 = Maps
|
||||||
|
*/
|
||||||
|
public static boolean dumpIndexOne = false, dumpIndexTwo = false, dumpIndexThree = false, dumpIndexFour = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the ids of items, objects, and npcs on right click
|
||||||
|
*/
|
||||||
|
public static boolean enableIds = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to merge all the OS Buddy XP Drops so the counter doesn't get too
|
||||||
|
* big if you are training a lot of different skills
|
||||||
|
*/
|
||||||
|
public static boolean xp_merge = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables fog effects
|
||||||
|
*/
|
||||||
|
public static boolean enableFog = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* newDamage enables or disables fake constitution.
|
||||||
|
*/
|
||||||
|
public static boolean newDamage = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* npcBits can be changed to what your server's bits are set to.
|
||||||
|
*/
|
||||||
|
public static final int npcBits = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the use of run energy
|
||||||
|
*/
|
||||||
|
public static boolean runEnergy = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays health above entities heads
|
||||||
|
*/
|
||||||
|
public static boolean hpAboveHeads = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays names above entities
|
||||||
|
*/
|
||||||
|
public static boolean namesAboveHeads = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays OS Buddy orbs on HUD
|
||||||
|
*/
|
||||||
|
public static boolean enableOrbs = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables/Disables Revision 554 hitmarks
|
||||||
|
*/
|
||||||
|
public static boolean hitmarks554 = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables/Disables Revision 554 health bar
|
||||||
|
*/
|
||||||
|
public static boolean hpBar554 = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the HUD to display 10 X the amount of hitpoints
|
||||||
|
*/
|
||||||
|
public static boolean tenXHp = false;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,641 @@
|
|||||||
|
package org.rebotted;
|
||||||
|
|
||||||
|
import org.rebotted.cache.graphics.Widget;
|
||||||
|
import org.rebotted.draw.ProducingGraphicsBuffer;
|
||||||
|
import org.rebotted.ui.BotFrame;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.applet.Applet;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
public class GameApplet extends Applet implements Runnable, MouseListener,
|
||||||
|
MouseMotionListener, MouseWheelListener, KeyListener, FocusListener,
|
||||||
|
WindowListener {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
public static int anInt34;
|
||||||
|
private static Client instance;
|
||||||
|
public final int LEFT = 0;
|
||||||
|
public final int RIGHT = 1;
|
||||||
|
public final int DRAG = 2;
|
||||||
|
public final int RELEASED = 3;
|
||||||
|
public final int MOVE = 4;
|
||||||
|
final int[] keyArray = new int[128];
|
||||||
|
private final long[] aLongArray7 = new long[10];
|
||||||
|
private final int[] charQueue = new int[128];
|
||||||
|
public int mouseX;
|
||||||
|
public int mouseY;
|
||||||
|
public long aLong29;
|
||||||
|
public int clickMode3;
|
||||||
|
public int saveClickX;
|
||||||
|
public int saveClickY;
|
||||||
|
public boolean isLoading;
|
||||||
|
public boolean isApplet;
|
||||||
|
public boolean resized;
|
||||||
|
public int clickType;
|
||||||
|
public int releasedX;
|
||||||
|
public int releasedY;
|
||||||
|
public boolean mouseWheelDown;
|
||||||
|
public int mouseWheelX;
|
||||||
|
public int mouseWheelY;
|
||||||
|
protected int rotationGliding;
|
||||||
|
int minDelay;
|
||||||
|
int fps;
|
||||||
|
boolean shouldDebug;
|
||||||
|
int myWidth;
|
||||||
|
int myHeight;
|
||||||
|
Graphics graphics;
|
||||||
|
ProducingGraphicsBuffer fullGameScreen;
|
||||||
|
boolean awtFocus;
|
||||||
|
int idleTime;
|
||||||
|
int clickMode2;
|
||||||
|
int clickMode1;
|
||||||
|
private int anInt4;
|
||||||
|
private int delayTime;
|
||||||
|
private boolean shouldClearScreen;
|
||||||
|
private int clickX;
|
||||||
|
private int clickY;
|
||||||
|
private int readIndex;
|
||||||
|
private int writeIndex;
|
||||||
|
|
||||||
|
GameApplet() {
|
||||||
|
delayTime = 20;
|
||||||
|
minDelay = 1;
|
||||||
|
shouldDebug = false;
|
||||||
|
shouldClearScreen = true;
|
||||||
|
awtFocus = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshFrameSize(boolean undecorated, int width, int height,
|
||||||
|
boolean resizable, boolean full) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
Client.botFrame.setResizable(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean appletClient() {
|
||||||
|
return isApplet == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void initClientFrame(int w, int h) {
|
||||||
|
isApplet = true;
|
||||||
|
myWidth = w;
|
||||||
|
myHeight = h;
|
||||||
|
graphics = getGameComponent().getGraphics();
|
||||||
|
fullGameScreen = new ProducingGraphicsBuffer(myWidth, myHeight);
|
||||||
|
startRunnable(this, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean badZoomPosition() {
|
||||||
|
return (mouseX > 0 && mouseY > 340 && mouseX < 510 && mouseY < 500) ||
|
||||||
|
(mouseY > 210 && mouseY < 473 && mouseX > 514 && mouseX < 762);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
getGameComponent().addMouseListener(this);
|
||||||
|
getGameComponent().addMouseMotionListener(this);
|
||||||
|
getGameComponent().addKeyListener(this);
|
||||||
|
getGameComponent().addFocusListener(this);
|
||||||
|
getGameComponent().addMouseWheelListener(this);
|
||||||
|
if (Client.botFrame != null) {
|
||||||
|
Client.botFrame.addWindowListener(this);
|
||||||
|
}
|
||||||
|
drawLoadingText(0, "Loading...");
|
||||||
|
startUp();
|
||||||
|
int i = 0;
|
||||||
|
int j = 256;
|
||||||
|
int k = 1;
|
||||||
|
int l = 0;
|
||||||
|
int i1 = 0;
|
||||||
|
for (int j1 = 0; j1 < 10; j1++) {
|
||||||
|
aLongArray7[j1] = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
if (anInt4 < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (anInt4 > 0) {
|
||||||
|
anInt4--;
|
||||||
|
if (anInt4 == 0) {
|
||||||
|
exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int k1 = j;
|
||||||
|
int i2 = k;
|
||||||
|
j = 300;
|
||||||
|
k = 1;
|
||||||
|
long l2 = System.currentTimeMillis();
|
||||||
|
if (aLongArray7[i] == 0L) {
|
||||||
|
j = k1;
|
||||||
|
k = i2;
|
||||||
|
} else if (l2 > aLongArray7[i]) {
|
||||||
|
j = (int) ((long) (2560 * delayTime) / (l2 - aLongArray7[i]));
|
||||||
|
}
|
||||||
|
if (j < 25) {
|
||||||
|
j = 25;
|
||||||
|
}
|
||||||
|
if (j > 256) {
|
||||||
|
j = 256;
|
||||||
|
k = (int) ((long) delayTime - (l2 - aLongArray7[i]) / 10L);
|
||||||
|
}
|
||||||
|
if (k > delayTime) {
|
||||||
|
k = delayTime;
|
||||||
|
}
|
||||||
|
aLongArray7[i] = l2;
|
||||||
|
i = (i + 1) % 10;
|
||||||
|
if (k > 1) {
|
||||||
|
for (int j2 = 0; j2 < 10; j2++) {
|
||||||
|
if (aLongArray7[j2] != 0L) {
|
||||||
|
aLongArray7[j2] += k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (k < minDelay) {
|
||||||
|
k = minDelay;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(k);
|
||||||
|
} catch (InterruptedException interruptedexception) {
|
||||||
|
i1++;
|
||||||
|
}
|
||||||
|
for (; l < 256; l += j) {
|
||||||
|
clickMode3 = clickMode1;
|
||||||
|
saveClickX = clickX;
|
||||||
|
saveClickY = clickY;
|
||||||
|
clickMode1 = 0;
|
||||||
|
processGameLoop();
|
||||||
|
readIndex = writeIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
l &= 0xff;
|
||||||
|
if (delayTime > 0) {
|
||||||
|
fps = (1000 * j) / (delayTime * 256);
|
||||||
|
}
|
||||||
|
processDrawing();
|
||||||
|
if (shouldDebug) {
|
||||||
|
System.out.println((new StringBuilder()).append("ntime:")
|
||||||
|
.append(l2).toString());
|
||||||
|
for (int k2 = 0; k2 < 10; k2++) {
|
||||||
|
int i3 = ((i - k2 - 1) + 20) % 10;
|
||||||
|
System.out.println((new StringBuilder()).append("otim")
|
||||||
|
.append(i3).append(":").append(aLongArray7[i3])
|
||||||
|
.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println((new StringBuilder()).append("fps:")
|
||||||
|
.append(fps).append(" ratio:").append(j)
|
||||||
|
.append(" count:").append(l).toString());
|
||||||
|
System.out.println((new StringBuilder()).append("del:")
|
||||||
|
.append(k).append(" deltime:").append(delayTime)
|
||||||
|
.append(" mindel:").append(minDelay).toString());
|
||||||
|
System.out.println((new StringBuilder()).append("intex:")
|
||||||
|
.append(i1).append(" opos:").append(i).toString());
|
||||||
|
shouldDebug = false;
|
||||||
|
i1 = 0;
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
if (anInt4 == -1) {
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exit() {
|
||||||
|
anInt4 = -2;
|
||||||
|
cleanUpForQuit();
|
||||||
|
if (Client.botFrame != null) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
System.exit(0);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final void method4(int i) {
|
||||||
|
delayTime = 1000 / i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void start() {
|
||||||
|
if (anInt4 >= 0) {
|
||||||
|
anInt4 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void stop() {
|
||||||
|
if (anInt4 >= 0) {
|
||||||
|
anInt4 = 4000 / delayTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void destroy() {
|
||||||
|
anInt4 = -1;
|
||||||
|
try {
|
||||||
|
Thread.sleep(5000L);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
}
|
||||||
|
if (anInt4 == -1) {
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void update(Graphics g) {
|
||||||
|
if (graphics == null) {
|
||||||
|
graphics = g;
|
||||||
|
}
|
||||||
|
shouldClearScreen = true;
|
||||||
|
raiseWelcomeScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void paint(Graphics g) {
|
||||||
|
if (graphics == null) {
|
||||||
|
graphics = g;
|
||||||
|
}
|
||||||
|
shouldClearScreen = true;
|
||||||
|
raiseWelcomeScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseWheelMoved(MouseWheelEvent event) {
|
||||||
|
int rotation = event.getWheelRotation();
|
||||||
|
handleInterfaceScrolling(event);
|
||||||
|
if (mouseX > 0 && mouseX < 512 && mouseY > Client.frameHeight - 165
|
||||||
|
&& mouseY < Client.frameHeight - 25) {
|
||||||
|
int scrollPos = Client.anInt1089;
|
||||||
|
scrollPos -= rotation * 30;
|
||||||
|
if (scrollPos < 0)
|
||||||
|
scrollPos = 0;
|
||||||
|
if (scrollPos > Client.anInt1211 - 110)
|
||||||
|
scrollPos = Client.anInt1211 - 110;
|
||||||
|
if (Client.anInt1089 != scrollPos) {
|
||||||
|
Client.anInt1089 = scrollPos;
|
||||||
|
Client.updateChatbox = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleInterfaceScrolling(MouseWheelEvent event) {
|
||||||
|
int rotation = event.getWheelRotation();
|
||||||
|
int positionX = 0;
|
||||||
|
int positionY = 0;
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
int offsetX = 0;
|
||||||
|
int offsetY = 0;
|
||||||
|
int childID = 0;
|
||||||
|
int tabInterfaceID = Client.tabInterfaceIDs[Client.tabId];
|
||||||
|
if (tabInterfaceID != -1) {
|
||||||
|
Widget tab = Widget.interfaceCache[tabInterfaceID];
|
||||||
|
offsetX = Client.frameMode == Client.ScreenMode.FIXED ? Client.frameWidth - 218
|
||||||
|
: (Client.frameMode == Client.ScreenMode.FIXED ? 28
|
||||||
|
: Client.frameWidth - 197);
|
||||||
|
offsetY = Client.frameMode == Client.ScreenMode.FIXED ? Client.frameHeight - 298
|
||||||
|
: (Client.frameMode == Client.ScreenMode.FIXED ? 37
|
||||||
|
: Client.frameHeight
|
||||||
|
- (Client.frameWidth >= 1000 ? 37 : 74) - 267);
|
||||||
|
for (int index = 0; index < tab.children.length; index++) {
|
||||||
|
if (Widget.interfaceCache[tab.children[index]].scrollMax > 0) {
|
||||||
|
childID = index;
|
||||||
|
positionX = tab.childX[index];
|
||||||
|
positionY = tab.childY[index];
|
||||||
|
width = Widget.interfaceCache[tab.children[index]].width;
|
||||||
|
height = Widget.interfaceCache[tab.children[index]].height;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mouseX > offsetX + positionX && mouseY > offsetY + positionY
|
||||||
|
&& mouseX < offsetX + positionX + width
|
||||||
|
&& mouseY < offsetY + positionY + height) {
|
||||||
|
Widget.interfaceCache[tab.children[childID]].scrollPosition += rotation * 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Client.openInterfaceId != -1) {
|
||||||
|
Widget rsi = Widget.interfaceCache[Client.openInterfaceId];
|
||||||
|
offsetX = Client.frameMode == Client.ScreenMode.FIXED ? 4
|
||||||
|
: (Client.frameWidth / 2) - 356;
|
||||||
|
offsetY = Client.frameMode == Client.ScreenMode.FIXED ? 4
|
||||||
|
: (Client.frameHeight / 2) - 230;
|
||||||
|
for (int index = 0; index < rsi.children.length; index++) {
|
||||||
|
if (Widget.interfaceCache[rsi.children[index]].scrollMax > 0) {
|
||||||
|
childID = index;
|
||||||
|
positionX = rsi.childX[index];
|
||||||
|
positionY = rsi.childY[index];
|
||||||
|
width = Widget.interfaceCache[rsi.children[index]].width;
|
||||||
|
height = Widget.interfaceCache[rsi.children[index]].height;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mouseX > offsetX + positionX && mouseY > offsetY + positionY
|
||||||
|
&& mouseX < offsetX + positionX + width
|
||||||
|
&& mouseY < offsetY + positionY + height) {
|
||||||
|
Widget.interfaceCache[rsi.children[childID]].scrollPosition += rotation * 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void mousePressed(MouseEvent e) {
|
||||||
|
int x = e.getX();
|
||||||
|
int y = e.getY();
|
||||||
|
int type = e.getButton();
|
||||||
|
if (Client.botFrame != null) {
|
||||||
|
Insets insets = Client.botFrame.getInsets();
|
||||||
|
x -= insets.left;// 4
|
||||||
|
y -= insets.top;// 22
|
||||||
|
}
|
||||||
|
idleTime = 0;
|
||||||
|
clickX = x;
|
||||||
|
clickY = y;
|
||||||
|
aLong29 = System.currentTimeMillis();
|
||||||
|
if (type == 2) {
|
||||||
|
mouseWheelDown = true;
|
||||||
|
mouseWheelX = x;
|
||||||
|
mouseWheelY = y;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.isMetaDown()) {
|
||||||
|
clickType = RIGHT;
|
||||||
|
clickMode1 = 2;
|
||||||
|
clickMode2 = 2;
|
||||||
|
} else {
|
||||||
|
clickType = LEFT;
|
||||||
|
clickMode1 = 1;
|
||||||
|
clickMode2 = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void mouseReleased(MouseEvent e) {
|
||||||
|
int x = e.getX();
|
||||||
|
int y = e.getY();
|
||||||
|
if (Client.botFrame != null) {
|
||||||
|
Insets insets = Client.botFrame.getInsets();
|
||||||
|
x -= insets.left;// 4
|
||||||
|
y -= insets.top;// 22
|
||||||
|
}
|
||||||
|
releasedX = x;
|
||||||
|
releasedY = y;
|
||||||
|
idleTime = 0;
|
||||||
|
clickMode2 = 0;
|
||||||
|
clickType = RELEASED;
|
||||||
|
mouseWheelDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void mouseClicked(MouseEvent mouseevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void mouseEntered(MouseEvent mouseevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void mouseExited(MouseEvent mouseevent) {
|
||||||
|
idleTime = 0;
|
||||||
|
mouseX = -1;
|
||||||
|
mouseY = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void mouseDragged(MouseEvent e) {
|
||||||
|
int x = e.getX();
|
||||||
|
int y = e.getY();
|
||||||
|
if (Client.botFrame != null) {
|
||||||
|
Insets insets = Client.botFrame.getInsets();
|
||||||
|
x -= insets.left;// 4
|
||||||
|
y -= insets.top;// 22
|
||||||
|
}
|
||||||
|
if (mouseWheelDown) {
|
||||||
|
y = mouseWheelX - e.getX();
|
||||||
|
int k = mouseWheelY - e.getY();
|
||||||
|
mouseWheelDragged(y, -k);
|
||||||
|
mouseWheelX = e.getX();
|
||||||
|
mouseWheelY = e.getY();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
idleTime = 0;
|
||||||
|
mouseX = x;
|
||||||
|
mouseY = y;
|
||||||
|
clickType = DRAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mouseWheelDragged(int param1, int param2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void mouseMoved(MouseEvent mouseevent) {
|
||||||
|
int x = mouseevent.getX();
|
||||||
|
int y = mouseevent.getY();
|
||||||
|
if (Client.botFrame != null) {
|
||||||
|
Insets insets = Client.botFrame.getInsets();
|
||||||
|
x -= insets.left;// 4
|
||||||
|
y -= insets.top;// 22
|
||||||
|
}
|
||||||
|
idleTime = 0;
|
||||||
|
mouseX = x;
|
||||||
|
mouseY = y;
|
||||||
|
clickType = MOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void keyPressed(KeyEvent keyevent) {
|
||||||
|
idleTime = 0;
|
||||||
|
int i = keyevent.getKeyCode();
|
||||||
|
int j = keyevent.getKeyChar();
|
||||||
|
if (i == KeyEvent.VK_F1) {
|
||||||
|
Client.setTab(3);
|
||||||
|
} else if (i == KeyEvent.VK_ESCAPE) {
|
||||||
|
Client.setTab(10);
|
||||||
|
} else if (i == KeyEvent.VK_F2) {
|
||||||
|
Client.setTab(4);
|
||||||
|
} else if (i == KeyEvent.VK_F3) {
|
||||||
|
Client.setTab(5);
|
||||||
|
} else if (i == KeyEvent.VK_F4) {
|
||||||
|
Client.setTab(6);
|
||||||
|
} else if (i == KeyEvent.VK_F5) {
|
||||||
|
Client.setTab(0);
|
||||||
|
}
|
||||||
|
if (j < 30)
|
||||||
|
j = 0;
|
||||||
|
if (i == 37)
|
||||||
|
j = 1;
|
||||||
|
if (i == 39)
|
||||||
|
j = 2;
|
||||||
|
if (i == 38)
|
||||||
|
j = 3;
|
||||||
|
if (i == 40)
|
||||||
|
j = 4;
|
||||||
|
if (i == 17)
|
||||||
|
j = 5;
|
||||||
|
if (i == 8)
|
||||||
|
j = 8;
|
||||||
|
if (i == 127)
|
||||||
|
j = 8;
|
||||||
|
if (i == 9)
|
||||||
|
j = 9;
|
||||||
|
if (i == 10)
|
||||||
|
j = 10;
|
||||||
|
if (i >= 112 && i <= 123)
|
||||||
|
j = (1008 + i) - 112;
|
||||||
|
if (i == 36)
|
||||||
|
j = 1000;
|
||||||
|
if (i == 35)
|
||||||
|
j = 1001;
|
||||||
|
if (i == 33)
|
||||||
|
j = 1002;
|
||||||
|
if (i == 34)
|
||||||
|
j = 1003;
|
||||||
|
if (j > 0 && j < 128)
|
||||||
|
keyArray[j] = 1;
|
||||||
|
if (j > 4) {
|
||||||
|
charQueue[writeIndex] = j;
|
||||||
|
writeIndex = writeIndex + 1 & 0x7f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void keyReleased(KeyEvent keyevent) {
|
||||||
|
idleTime = 0;
|
||||||
|
int i = keyevent.getKeyCode();
|
||||||
|
char c = keyevent.getKeyChar();
|
||||||
|
if (c < '\036')
|
||||||
|
c = '\0';
|
||||||
|
if (i == 37)
|
||||||
|
c = '\001';
|
||||||
|
if (i == 39)
|
||||||
|
c = '\002';
|
||||||
|
if (i == 38)
|
||||||
|
c = '\003';
|
||||||
|
if (i == 40)
|
||||||
|
c = '\004';
|
||||||
|
if (i == 17)
|
||||||
|
c = '\005';
|
||||||
|
if (i == 8)
|
||||||
|
c = '\b';
|
||||||
|
if (i == 127)
|
||||||
|
c = '\b';
|
||||||
|
if (i == 9)
|
||||||
|
c = '\t';
|
||||||
|
if (i == 10)
|
||||||
|
c = '\n';
|
||||||
|
if (c > 0 && c < '\200')
|
||||||
|
keyArray[c] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void keyTyped(KeyEvent keyevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
final int readChar(int dummy) {
|
||||||
|
while (dummy >= 0) {
|
||||||
|
for (int j = 1; j > 0; j++)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
int k = -1;
|
||||||
|
if (writeIndex != readIndex) {
|
||||||
|
k = charQueue[readIndex];
|
||||||
|
readIndex = readIndex + 1 & 0x7f;
|
||||||
|
}
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void focusGained(FocusEvent focusevent) {
|
||||||
|
awtFocus = true;
|
||||||
|
shouldClearScreen = true;
|
||||||
|
raiseWelcomeScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void focusLost(FocusEvent focusevent) {
|
||||||
|
awtFocus = false;
|
||||||
|
for (int i = 0; i < 128; i++) {
|
||||||
|
keyArray[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void windowActivated(WindowEvent windowevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void windowClosed(WindowEvent windowevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void windowClosing(WindowEvent windowevent) {
|
||||||
|
destroy();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void windowDeactivated(WindowEvent windowevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void windowDeiconified(WindowEvent windowevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void windowIconified(WindowEvent windowevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void windowOpened(WindowEvent windowevent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void startUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void processGameLoop() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void cleanUpForQuit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void processDrawing() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void raiseWelcomeScreen() {
|
||||||
|
}
|
||||||
|
|
||||||
|
Component getGameComponent() {
|
||||||
|
if (!isApplet) {
|
||||||
|
return Client.botFrame;
|
||||||
|
} else {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startRunnable(Runnable runnable, int i) {
|
||||||
|
Thread thread = new Thread(runnable);
|
||||||
|
thread.start();
|
||||||
|
thread.setPriority(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawLoadingText(int percentage, String loadingText) {
|
||||||
|
while (graphics == null) {
|
||||||
|
graphics = (isApplet ? this : Client.botFrame).getGraphics();
|
||||||
|
try {
|
||||||
|
getGameComponent().repaint();
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Font font = new Font("Helvetica", 1, 13);
|
||||||
|
FontMetrics fontmetrics = getGameComponent().getFontMetrics(font);
|
||||||
|
Font font1 = new Font("Helvetica", 0, 13);
|
||||||
|
FontMetrics fontmetrics1 = getGameComponent().getFontMetrics(font1);
|
||||||
|
if (shouldClearScreen) {
|
||||||
|
graphics.setColor(Color.black);
|
||||||
|
graphics.fillRect(0, 0, Client.frameWidth, Client.frameHeight);
|
||||||
|
shouldClearScreen = false;
|
||||||
|
}
|
||||||
|
Color color = new Color(140, 17, 17);
|
||||||
|
int y = Client.frameHeight / 2 - 18;
|
||||||
|
graphics.setColor(color);
|
||||||
|
graphics.drawRect(Client.frameWidth / 2 - 152, y, 304, 34);
|
||||||
|
graphics.fillRect(Client.frameWidth / 2 - 150, y + 2, percentage * 3, 30);
|
||||||
|
graphics.setColor(Color.black);
|
||||||
|
graphics.fillRect((Client.frameWidth / 2 - 150) + percentage * 3, y + 2,
|
||||||
|
300 - percentage * 3, 30);
|
||||||
|
graphics.setFont(font);
|
||||||
|
graphics.setColor(Color.white);
|
||||||
|
graphics.drawString(loadingText,
|
||||||
|
(Client.frameWidth - fontmetrics.stringWidth(loadingText)) / 2,
|
||||||
|
y + 22);
|
||||||
|
graphics.drawString("",
|
||||||
|
(Client.frameWidth - fontmetrics1.stringWidth("")) / 2, y - 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+101
@@ -0,0 +1,101 @@
|
|||||||
|
package org.rebotted.cache;
|
||||||
|
|
||||||
|
import org.rebotted.cache.bzip.BZip2Decompressor;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class FileArchive {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The buffer containing the decompressed data in this Archive.
|
||||||
|
*/
|
||||||
|
private final byte[] buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amount of entries in this Archive.
|
||||||
|
*/
|
||||||
|
private final int entries;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifiers (i.e. hashed names) of each of the entries in this Archive.
|
||||||
|
*/
|
||||||
|
private final int[] identifiers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The raw (i.e. decompressed) sizes of each of the entries in this Archive.
|
||||||
|
*/
|
||||||
|
private final int[] extractedSizes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The compressed sizes of each of the entries in this Archive.
|
||||||
|
*/
|
||||||
|
private final int[] sizes;
|
||||||
|
private final int[] indices;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not this Archive was compressed as a whole: if false, decompression will be performed on each of the
|
||||||
|
* individual entries.
|
||||||
|
*/
|
||||||
|
private final boolean extracted;
|
||||||
|
|
||||||
|
public FileArchive(byte data[]) {
|
||||||
|
Buffer buffer = new Buffer(data);
|
||||||
|
|
||||||
|
int decompressedLength = buffer.readTriByte();
|
||||||
|
int compressedLength = buffer.readTriByte();
|
||||||
|
|
||||||
|
if (compressedLength != decompressedLength) {
|
||||||
|
|
||||||
|
byte output[] = new byte[decompressedLength];
|
||||||
|
|
||||||
|
BZip2Decompressor.decompress(output, decompressedLength, data, compressedLength, 6);
|
||||||
|
|
||||||
|
this.buffer = output;
|
||||||
|
|
||||||
|
buffer = new Buffer(this.buffer);
|
||||||
|
extracted = true;
|
||||||
|
} else {
|
||||||
|
this.buffer = data;
|
||||||
|
extracted = false;
|
||||||
|
}
|
||||||
|
entries = buffer.readUShort();
|
||||||
|
identifiers = new int[entries];
|
||||||
|
extractedSizes = new int[entries];
|
||||||
|
sizes = new int[entries];
|
||||||
|
indices = new int[entries];
|
||||||
|
int offset = buffer.currentPosition + entries * 10;
|
||||||
|
for (int file = 0; file < entries; file++) {
|
||||||
|
identifiers[file] = buffer.readInt();
|
||||||
|
extractedSizes[file] = buffer.readTriByte();
|
||||||
|
sizes[file] = buffer.readTriByte();
|
||||||
|
indices[file] = offset;
|
||||||
|
offset += sizes[file];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] readFile(String name) {
|
||||||
|
byte output[] = null;
|
||||||
|
int hash = 0;
|
||||||
|
name = name.toUpperCase();
|
||||||
|
for (int index = 0; index < name.length(); index++) {
|
||||||
|
hash = (hash * 61 + name.charAt(index)) - 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int file = 0; file < entries; file++) {
|
||||||
|
if (identifiers[file] == hash) {
|
||||||
|
if (output == null) {
|
||||||
|
output = new byte[extractedSizes[file]];
|
||||||
|
}
|
||||||
|
if (!extracted) {
|
||||||
|
BZip2Decompressor.decompress(output, extractedSizes[file], this.buffer,
|
||||||
|
sizes[file], indices[file]);
|
||||||
|
} else {
|
||||||
|
System.arraycopy(this.buffer, indices[file], output,
|
||||||
|
0, extractedSizes[file]);
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+239
@@ -0,0 +1,239 @@
|
|||||||
|
package org.rebotted.cache;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public final class FileStore {
|
||||||
|
|
||||||
|
public static enum Store {
|
||||||
|
|
||||||
|
ARCHIVE(0),
|
||||||
|
|
||||||
|
MODEL(1),
|
||||||
|
|
||||||
|
ANIMATION(2),
|
||||||
|
|
||||||
|
MUSIC(3),
|
||||||
|
|
||||||
|
MAP(4);
|
||||||
|
|
||||||
|
private int index;
|
||||||
|
|
||||||
|
private Store(int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return this.index;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final byte[] buffer = new byte[520];
|
||||||
|
private final RandomAccessFile dataFile;
|
||||||
|
private final RandomAccessFile indexFile;
|
||||||
|
private final int storeIndex;
|
||||||
|
|
||||||
|
public FileStore(RandomAccessFile data, RandomAccessFile index, int storeIndex) {
|
||||||
|
this.storeIndex = storeIndex;
|
||||||
|
dataFile = data;
|
||||||
|
indexFile = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized byte[] decompress(int id) {
|
||||||
|
try {
|
||||||
|
seek(indexFile, id * 6);
|
||||||
|
for (int in = 0, read = 0; read < 6; read += in) {
|
||||||
|
in = indexFile.read(buffer, read, 6 - read);
|
||||||
|
|
||||||
|
if (in == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int size = ((buffer[0] & 0xff) << 16) + ((buffer[1] & 0xff) << 8) + (buffer[2] & 0xff);
|
||||||
|
int sector = ((buffer[3] & 0xff) << 16) + ((buffer[4] & 0xff) << 8) + (buffer[5] & 0xff);
|
||||||
|
|
||||||
|
if (sector <= 0 || (long) sector > dataFile.length() / 520L) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte buf[] = new byte[size];
|
||||||
|
|
||||||
|
int totalRead = 0;
|
||||||
|
|
||||||
|
for (int part = 0; totalRead < size; part++) {
|
||||||
|
|
||||||
|
if (sector == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
seek(dataFile, sector * 520);
|
||||||
|
|
||||||
|
int unread = size - totalRead;
|
||||||
|
|
||||||
|
if (unread > 512) {
|
||||||
|
unread = 512;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int in = 0, read = 0; read < unread + 8; read += in) {
|
||||||
|
in = dataFile.read(buffer, read, (unread + 8) - read);
|
||||||
|
|
||||||
|
if (in == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int currentIndex = ((buffer[0] & 0xff) << 8) + (buffer[1] & 0xff);
|
||||||
|
int currentPart = ((buffer[2] & 0xff) << 8) + (buffer[3] & 0xff);
|
||||||
|
int nextSector = ((buffer[4] & 0xff) << 16) + ((buffer[5] & 0xff) << 8) + (buffer[6] & 0xff);
|
||||||
|
int currentFile = buffer[7] & 0xff;
|
||||||
|
|
||||||
|
if (currentIndex != id || currentPart != part || currentFile != storeIndex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextSector < 0 || (long) nextSector > dataFile.length() / 520L) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < unread; i++) {
|
||||||
|
buf[totalRead++] = buffer[i + 8];
|
||||||
|
}
|
||||||
|
|
||||||
|
sector = nextSector;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
} catch (IOException _ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean writeFile(int length, byte data[], int index) {
|
||||||
|
return writeFile(data, index, length, true) ? true : writeFile(data, index, length, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized boolean writeFile(byte bytes[], int position, int length, boolean exists) {
|
||||||
|
try {
|
||||||
|
int sector;
|
||||||
|
if (exists) {
|
||||||
|
|
||||||
|
seek(indexFile, position * 6);
|
||||||
|
|
||||||
|
for (int in = 0, read = 0; read < 6; read += in) {
|
||||||
|
in = indexFile.read(buffer, read, 6 - read);
|
||||||
|
|
||||||
|
if (in == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
sector = ((buffer[3] & 0xff) << 16) + ((buffer[4] & 0xff) << 8) + (buffer[5] & 0xff);
|
||||||
|
|
||||||
|
if (sector <= 0 || (long) sector > dataFile.length() / 520L) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sector = (int) ((dataFile.length() + 519L) / 520L);
|
||||||
|
if (sector == 0) {
|
||||||
|
sector = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buffer[0] = (byte) (length >> 16);
|
||||||
|
buffer[1] = (byte) (length >> 8);
|
||||||
|
buffer[2] = (byte) length;
|
||||||
|
buffer[3] = (byte) (sector >> 16);
|
||||||
|
buffer[4] = (byte) (sector >> 8);
|
||||||
|
buffer[5] = (byte) sector;
|
||||||
|
seek(indexFile, position * 6);
|
||||||
|
indexFile.write(buffer, 0, 6);
|
||||||
|
|
||||||
|
for (int part = 0, written = 0; written < length; part++) {
|
||||||
|
|
||||||
|
int nextSector = 0;
|
||||||
|
|
||||||
|
if (exists) {
|
||||||
|
seek(dataFile, sector * 520);
|
||||||
|
|
||||||
|
int read = 0;
|
||||||
|
|
||||||
|
for (int in = 0; read < 8; read += in) {
|
||||||
|
|
||||||
|
in = dataFile.read(buffer, read, 8 - read);
|
||||||
|
|
||||||
|
if (in == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (read == 8) {
|
||||||
|
int currentIndex = ((buffer[0] & 0xff) << 8) + (buffer[1] & 0xff);
|
||||||
|
int currentPart = ((buffer[2] & 0xff) << 8) + (buffer[3] & 0xff);
|
||||||
|
nextSector = ((buffer[4] & 0xff) << 16) + ((buffer[5] & 0xff) << 8) + (buffer[6] & 0xff);
|
||||||
|
int currentFile = buffer[7] & 0xff;
|
||||||
|
|
||||||
|
if (currentIndex != position || currentPart != part || currentFile != storeIndex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextSector < 0 || (long) nextSector > dataFile.length() / 520L) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nextSector == 0) {
|
||||||
|
exists = false;
|
||||||
|
nextSector = (int) ((dataFile.length() + 519L) / 520L);
|
||||||
|
|
||||||
|
if (nextSector == 0) {
|
||||||
|
nextSector++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextSector == sector) {
|
||||||
|
nextSector++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length - written <= 512) {
|
||||||
|
nextSector = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[0] = (byte) (position >> 8);
|
||||||
|
buffer[1] = (byte) position;
|
||||||
|
buffer[2] = (byte) (part >> 8);
|
||||||
|
buffer[3] = (byte) part;
|
||||||
|
buffer[4] = (byte) (nextSector >> 16);
|
||||||
|
buffer[5] = (byte) (nextSector >> 8);
|
||||||
|
buffer[6] = (byte) nextSector;
|
||||||
|
buffer[7] = (byte) storeIndex;
|
||||||
|
seek(dataFile, sector * 520);
|
||||||
|
dataFile.write(buffer, 0, 8);
|
||||||
|
|
||||||
|
int unwritten = length - written;
|
||||||
|
|
||||||
|
if (unwritten > 512) {
|
||||||
|
unwritten = 512;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataFile.write(bytes, written, unwritten);
|
||||||
|
written += unwritten;
|
||||||
|
sector = nextSector;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (IOException ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void seek(RandomAccessFile file, int position) throws IOException {
|
||||||
|
try {
|
||||||
|
file.seek(position);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package org.rebotted.cache.anim;
|
||||||
|
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class Animation {
|
||||||
|
|
||||||
|
public static void init(FileArchive streamLoader) {
|
||||||
|
Buffer buffer = new Buffer(streamLoader.readFile("seq.dat"));
|
||||||
|
|
||||||
|
int length = buffer.readUShort();
|
||||||
|
|
||||||
|
if (animations == null) {
|
||||||
|
animations = new Animation[length];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
if (animations[i] == null) {
|
||||||
|
animations[i] = new Animation();
|
||||||
|
}
|
||||||
|
|
||||||
|
animations[i].decode(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Loaded: " + length + " Animations");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int duration(int index) {
|
||||||
|
int duration = durations[index];
|
||||||
|
if (duration == 0) {
|
||||||
|
Frame frame = Frame.method531(primaryFrames[index]);
|
||||||
|
if (frame != null) {
|
||||||
|
duration = durations[index] = frame.duration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duration == 0) {
|
||||||
|
duration = 1;
|
||||||
|
}
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decode(Buffer stream) {
|
||||||
|
int opcode;
|
||||||
|
while ((opcode = stream.readUnsignedByte()) != 0) {
|
||||||
|
|
||||||
|
if (opcode == 1) {
|
||||||
|
frameCount = stream.readUShort();
|
||||||
|
primaryFrames = new int[frameCount];
|
||||||
|
secondaryFrames = new int[frameCount];
|
||||||
|
durations = new int[frameCount];
|
||||||
|
for (int i = 0; i < frameCount; i++) {
|
||||||
|
primaryFrames[i] = stream.readInt();
|
||||||
|
secondaryFrames[i] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < frameCount; i++) {
|
||||||
|
durations[i] = stream.readUnsignedByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (opcode == 2) {
|
||||||
|
loopOffset = stream.readUShort();
|
||||||
|
} else if (opcode == 3) {
|
||||||
|
int length = stream.readUnsignedByte();
|
||||||
|
interleaveOrder = new int[length + 1];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
interleaveOrder[i] = stream.readUnsignedByte();
|
||||||
|
}
|
||||||
|
interleaveOrder[length] = 9999999;
|
||||||
|
} else if (opcode == 4) {
|
||||||
|
stretches = true;
|
||||||
|
} else if (opcode == 5) {
|
||||||
|
forcedPriority = stream.readUnsignedByte();
|
||||||
|
} else if (opcode == 6) {
|
||||||
|
rightHand = stream.readUShort();
|
||||||
|
} else if (opcode == 7) {
|
||||||
|
leftHand = stream.readUShort();
|
||||||
|
} else if (opcode == 8) {
|
||||||
|
maximumLoops = stream.readUnsignedByte();
|
||||||
|
} else if (opcode == 9) {
|
||||||
|
animatingPrecedence = stream.readUnsignedByte();
|
||||||
|
} else if (opcode == 10) {
|
||||||
|
priority = stream.readUnsignedByte();
|
||||||
|
} else if (opcode == 11) {
|
||||||
|
replayMode = stream.readUnsignedByte();
|
||||||
|
} else if (opcode == 12) {
|
||||||
|
stream.readInt();
|
||||||
|
} else {
|
||||||
|
System.out.println("Error unrecognised seq config code: " + opcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (frameCount == 0) {
|
||||||
|
frameCount = 1;
|
||||||
|
primaryFrames = new int[1];
|
||||||
|
primaryFrames[0] = -1;
|
||||||
|
secondaryFrames = new int[1];
|
||||||
|
secondaryFrames[0] = -1;
|
||||||
|
durations = new int[1];
|
||||||
|
durations[0] = -1;
|
||||||
|
}
|
||||||
|
if (animatingPrecedence == -1)
|
||||||
|
if (interleaveOrder != null) {
|
||||||
|
animatingPrecedence = 2;
|
||||||
|
} else {
|
||||||
|
animatingPrecedence = 0;
|
||||||
|
}
|
||||||
|
if (priority == -1) {
|
||||||
|
if (interleaveOrder != null) {
|
||||||
|
priority = 2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
priority = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Animation() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Animation animations[];
|
||||||
|
public int frameCount;
|
||||||
|
public int primaryFrames[];
|
||||||
|
public int secondaryFrames[];
|
||||||
|
public int[] durations;
|
||||||
|
public int loopOffset = -1;
|
||||||
|
public int interleaveOrder[];
|
||||||
|
public boolean stretches;
|
||||||
|
public int forcedPriority = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes shield
|
||||||
|
*/
|
||||||
|
public int rightHand = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes weapon
|
||||||
|
*/
|
||||||
|
public int leftHand = -1;
|
||||||
|
public int maximumLoops = 99;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops character from moving.
|
||||||
|
*/
|
||||||
|
public int animatingPrecedence = -1;
|
||||||
|
public int priority = -1;
|
||||||
|
public int replayMode = 1;
|
||||||
|
public static int anInt367;
|
||||||
|
|
||||||
|
}
|
||||||
+123
@@ -0,0 +1,123 @@
|
|||||||
|
package org.rebotted.cache.anim;
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class Frame {
|
||||||
|
|
||||||
|
public static Frame[][] animationlist;
|
||||||
|
|
||||||
|
public static void load(int file, byte[] array) {
|
||||||
|
try {
|
||||||
|
final Buffer ay = new Buffer(array);
|
||||||
|
final FrameBase b2 = new FrameBase(ay);
|
||||||
|
final int n = ay.readUShort();;
|
||||||
|
animationlist[file] = new Frame[n * 3];
|
||||||
|
final int[] array2 = new int[500];
|
||||||
|
final int[] array3 = new int[500];
|
||||||
|
final int[] array4 = new int[500];
|
||||||
|
final int[] array5 = new int[500];
|
||||||
|
for (int j = 0; j < n; ++j) {
|
||||||
|
final int k = ay.readUShort();;
|
||||||
|
final Frame[] array6 = animationlist[file];
|
||||||
|
final int n2 = k;
|
||||||
|
final Frame q = new Frame();
|
||||||
|
array6[n2] = q;
|
||||||
|
final Frame q2 = q;
|
||||||
|
q.base = b2;
|
||||||
|
final int f = ay.readUnsignedByte();
|
||||||
|
int c2 = 0;
|
||||||
|
int n3 = -1;
|
||||||
|
for (int l = 0; l < f; ++l) {
|
||||||
|
final int f2;
|
||||||
|
if ((f2 = ay.readUnsignedByte()) > 0) {
|
||||||
|
if (b2.transformationType[l] != 0) {
|
||||||
|
for (int n4 = l - 1; n4 > n3; --n4) {
|
||||||
|
if (b2.transformationType[n4] == 0) {
|
||||||
|
array2[c2] = n4;
|
||||||
|
array3[c2] = 0;
|
||||||
|
array5[c2] = (array4[c2] = 0);
|
||||||
|
++c2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array2[c2] = l;
|
||||||
|
int n4 = 0;
|
||||||
|
if (b2.transformationType[l] == 3) {
|
||||||
|
n4 = 128;
|
||||||
|
}
|
||||||
|
if ((f2 & 0x1) != 0x0) {
|
||||||
|
array3[c2] = ay.readShort2();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
array3[c2] = n4;
|
||||||
|
}
|
||||||
|
if ((f2 & 0x2) != 0x0) {
|
||||||
|
array4[c2] = ay.readShort2();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
array4[c2] = n4;
|
||||||
|
}
|
||||||
|
if ((f2 & 0x4) != 0x0) {
|
||||||
|
array5[c2] = ay.readShort2();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
array5[c2] = n4;
|
||||||
|
}
|
||||||
|
n3 = l;
|
||||||
|
++c2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
q2.transformationCount = c2;
|
||||||
|
q2.transformationIndices = new int[c2];
|
||||||
|
q2.transformX = new int[c2];
|
||||||
|
q2.transformY = new int[c2];
|
||||||
|
q2.transformZ = new int[c2];
|
||||||
|
for (int l = 0; l < c2; ++l) {
|
||||||
|
q2.transformationIndices[l] = array2[l];
|
||||||
|
q2.transformX[l] = array3[l];
|
||||||
|
q2.transformY[l] = array4[l];
|
||||||
|
q2.transformZ[l] = array5[l];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
//ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Frame method531(int frame) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
int file = frame >> 16;
|
||||||
|
int k = frame & 0xffff;
|
||||||
|
|
||||||
|
if (animationlist[file].length == 0) {
|
||||||
|
Client.instance.resourceProvider.provide(1, file);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return animationlist[file][k];
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean noAnimationInProgress(int frame) {
|
||||||
|
return frame == -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
animationlist = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int duration;
|
||||||
|
public FrameBase base;
|
||||||
|
public int transformationCount;
|
||||||
|
public int transformationIndices[];
|
||||||
|
public int transformX[];
|
||||||
|
public int transformY[];
|
||||||
|
public int transformZ[];
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package org.rebotted.cache.anim;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class FrameBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of each transformation.
|
||||||
|
*/
|
||||||
|
public final int[] transformationType;
|
||||||
|
|
||||||
|
public final int[][] skinList;
|
||||||
|
|
||||||
|
public FrameBase(Buffer stream) {
|
||||||
|
int count = stream.readUShort();
|
||||||
|
|
||||||
|
transformationType = new int[count];
|
||||||
|
skinList = new int[count][];
|
||||||
|
|
||||||
|
for (int index = 0; index < count; index++) {
|
||||||
|
transformationType[index] = stream.readUShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int label = 0; label < count; label++) {
|
||||||
|
skinList[label] = new int[stream.readUShort()];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int label = 0; label < count; label++) {
|
||||||
|
for (int index = 0; index < skinList[label].length; index++) {
|
||||||
|
skinList[label][index] = stream.readUShort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package org.rebotted.cache.anim;
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.collection.ReferenceCache;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class Graphic {
|
||||||
|
|
||||||
|
public static void init(FileArchive archive) {
|
||||||
|
Buffer buffer = new Buffer(archive.readFile("spotanim.dat"));
|
||||||
|
final int length = buffer.readUShort();
|
||||||
|
if (cache == null) {
|
||||||
|
cache = new Graphic[length];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
if (cache[i] == null) {
|
||||||
|
cache[i] = new Graphic();
|
||||||
|
}
|
||||||
|
cache[i].id = i;
|
||||||
|
cache[i].decode(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Loaded: "+length+" Graphics");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decode(Buffer buffer) {
|
||||||
|
while(true) {
|
||||||
|
int opcode = buffer.readUnsignedByte();
|
||||||
|
|
||||||
|
if (opcode == 0) {
|
||||||
|
return;
|
||||||
|
} else if (opcode == 1) {
|
||||||
|
modelId = buffer.readUShort();
|
||||||
|
} else if (opcode == 2) {
|
||||||
|
animationId = buffer.readUShort();
|
||||||
|
if (Animation.animations != null) {
|
||||||
|
animationSequence = Animation.animations[animationId];
|
||||||
|
}
|
||||||
|
} else if (opcode == 4) {
|
||||||
|
resizeXY = buffer.readUShort();
|
||||||
|
} else if (opcode == 5) {
|
||||||
|
resizeZ = buffer.readUShort();
|
||||||
|
} else if (opcode == 6) {
|
||||||
|
rotation = buffer.readUShort();
|
||||||
|
} else if (opcode == 7) {
|
||||||
|
modelBrightness = buffer.readUShort();
|
||||||
|
} else if (opcode == 8) {
|
||||||
|
modelShadow = buffer.readUShort();
|
||||||
|
} else if (opcode == 40) {
|
||||||
|
int length = buffer.readUnsignedByte();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
originalModelColours[i] = buffer.readUShort();
|
||||||
|
modifiedModelColours[i] = buffer.readUShort();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("Error unrecognised spotanim config code: "
|
||||||
|
+ opcode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getModel() {
|
||||||
|
Model model = (Model) models.get(id);
|
||||||
|
if (model != null)
|
||||||
|
return model;
|
||||||
|
model = Model.getModel(modelId);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
if (originalModelColours[0] != 0)
|
||||||
|
model.recolor(originalModelColours[i], modifiedModelColours[i]);
|
||||||
|
|
||||||
|
models.put(model, id);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Graphic() {
|
||||||
|
animationId = -1;
|
||||||
|
originalModelColours = new int[6];
|
||||||
|
modifiedModelColours = new int[6];
|
||||||
|
resizeXY = 128;
|
||||||
|
resizeZ = 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Graphic cache[];
|
||||||
|
private int id;
|
||||||
|
private int modelId;
|
||||||
|
private int animationId;
|
||||||
|
public Animation animationSequence;
|
||||||
|
private final int[] originalModelColours;
|
||||||
|
private final int[] modifiedModelColours;
|
||||||
|
public int resizeXY;
|
||||||
|
public int resizeZ;
|
||||||
|
public int rotation;
|
||||||
|
public int modelBrightness;
|
||||||
|
public int modelShadow;
|
||||||
|
public static ReferenceCache models = new ReferenceCache(30);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package org.rebotted.cache.bzip;
|
||||||
|
|
||||||
|
final class BZip2DecompressionState {
|
||||||
|
|
||||||
|
byte compressed[];
|
||||||
|
int nextIn;
|
||||||
|
int decompressedLength;
|
||||||
|
int totalInLo32;
|
||||||
|
int totalInHi32;
|
||||||
|
byte decompressed[];
|
||||||
|
int nextOut;
|
||||||
|
int length;
|
||||||
|
int totalOutLo32;
|
||||||
|
int totalOutHigh32;
|
||||||
|
byte aByte573;
|
||||||
|
int anInt574;
|
||||||
|
boolean aBoolean575;
|
||||||
|
int bsBuff;
|
||||||
|
int bsLive;
|
||||||
|
int anInt578;
|
||||||
|
int currentBlock;
|
||||||
|
int randomised;
|
||||||
|
int anInt581;
|
||||||
|
int anInt582;
|
||||||
|
final int[] unzftab;
|
||||||
|
int anInt584;
|
||||||
|
final int[] cftab;
|
||||||
|
public static int tt[];
|
||||||
|
int nInUse;
|
||||||
|
final boolean[] inUse;
|
||||||
|
final boolean[] inUse16;
|
||||||
|
final byte[] seqToUnseq;
|
||||||
|
final byte[] mtfa;
|
||||||
|
final int[] mtfbase;
|
||||||
|
final byte[] selector;
|
||||||
|
final byte[] selectorMtf;
|
||||||
|
final byte[][] len;
|
||||||
|
final int[][] limit;
|
||||||
|
final int[][] base;
|
||||||
|
final int[][] perm;
|
||||||
|
final int[] minLens;
|
||||||
|
int anInt601;
|
||||||
|
|
||||||
|
BZip2DecompressionState() {
|
||||||
|
unzftab = new int[256];
|
||||||
|
cftab = new int[257];
|
||||||
|
inUse = new boolean[256];
|
||||||
|
inUse16 = new boolean[16];
|
||||||
|
seqToUnseq = new byte[256];
|
||||||
|
mtfa = new byte[4096];
|
||||||
|
mtfbase = new int[16];
|
||||||
|
selector = new byte[18002];
|
||||||
|
selectorMtf = new byte[18002];
|
||||||
|
len = new byte[6][258];
|
||||||
|
limit = new int[6][258];
|
||||||
|
base = new int[6][258];
|
||||||
|
perm = new int[6][258];
|
||||||
|
minLens = new int[6];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,500 @@
|
|||||||
|
package org.rebotted.cache.bzip;
|
||||||
|
|
||||||
|
public final class BZip2Decompressor {
|
||||||
|
|
||||||
|
public static int decompress(byte output[], int length, byte compressed[], int decompressedLength, int minLen) {
|
||||||
|
synchronized (state) {
|
||||||
|
state.compressed = compressed;
|
||||||
|
state.nextIn = minLen;
|
||||||
|
state.decompressed = output;
|
||||||
|
state.nextOut = 0;
|
||||||
|
state.decompressedLength = decompressedLength;
|
||||||
|
state.length = length;
|
||||||
|
state.bsLive = 0;
|
||||||
|
state.bsBuff = 0;
|
||||||
|
state.totalInLo32 = 0;
|
||||||
|
state.totalInHi32 = 0;
|
||||||
|
state.totalOutLo32 = 0;
|
||||||
|
state.totalOutHigh32 = 0;
|
||||||
|
state.currentBlock = 0;
|
||||||
|
decompress(state);
|
||||||
|
length -= state.length;
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void method226(BZip2DecompressionState state) {
|
||||||
|
byte byte4 = state.aByte573;
|
||||||
|
int i = state.anInt574;
|
||||||
|
int j = state.anInt584;
|
||||||
|
int k = state.anInt582;
|
||||||
|
int ai[] = BZip2DecompressionState.tt;
|
||||||
|
int l = state.anInt581;
|
||||||
|
byte abyte0[] = state.decompressed;
|
||||||
|
int i1 = state.nextOut;
|
||||||
|
int j1 = state.length;
|
||||||
|
int k1 = j1;
|
||||||
|
int l1 = state.anInt601 + 1;
|
||||||
|
label0: do {
|
||||||
|
if (i > 0) {
|
||||||
|
do {
|
||||||
|
if (j1 == 0)
|
||||||
|
break label0;
|
||||||
|
if (i == 1)
|
||||||
|
break;
|
||||||
|
abyte0[i1] = byte4;
|
||||||
|
i--;
|
||||||
|
i1++;
|
||||||
|
j1--;
|
||||||
|
} while (true);
|
||||||
|
if (j1 == 0) {
|
||||||
|
i = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
abyte0[i1] = byte4;
|
||||||
|
i1++;
|
||||||
|
j1--;
|
||||||
|
}
|
||||||
|
boolean flag = true;
|
||||||
|
while (flag) {
|
||||||
|
flag = false;
|
||||||
|
if (j == l1) {
|
||||||
|
i = 0;
|
||||||
|
break label0;
|
||||||
|
}
|
||||||
|
byte4 = (byte) k;
|
||||||
|
l = ai[l];
|
||||||
|
byte byte0 = (byte) (l & 0xff);
|
||||||
|
l >>= 8;
|
||||||
|
j++;
|
||||||
|
if (byte0 != k) {
|
||||||
|
k = byte0;
|
||||||
|
if (j1 == 0) {
|
||||||
|
i = 1;
|
||||||
|
} else {
|
||||||
|
abyte0[i1] = byte4;
|
||||||
|
i1++;
|
||||||
|
j1--;
|
||||||
|
flag = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break label0;
|
||||||
|
}
|
||||||
|
if (j != l1)
|
||||||
|
continue;
|
||||||
|
if (j1 == 0) {
|
||||||
|
i = 1;
|
||||||
|
break label0;
|
||||||
|
}
|
||||||
|
abyte0[i1] = byte4;
|
||||||
|
i1++;
|
||||||
|
j1--;
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
i = 2;
|
||||||
|
l = ai[l];
|
||||||
|
byte byte1 = (byte) (l & 0xff);
|
||||||
|
l >>= 8;
|
||||||
|
if (++j != l1)
|
||||||
|
if (byte1 != k) {
|
||||||
|
k = byte1;
|
||||||
|
} else {
|
||||||
|
i = 3;
|
||||||
|
l = ai[l];
|
||||||
|
byte byte2 = (byte) (l & 0xff);
|
||||||
|
l >>= 8;
|
||||||
|
if (++j != l1)
|
||||||
|
if (byte2 != k) {
|
||||||
|
k = byte2;
|
||||||
|
} else {
|
||||||
|
l = ai[l];
|
||||||
|
byte byte3 = (byte) (l & 0xff);
|
||||||
|
l >>= 8;
|
||||||
|
j++;
|
||||||
|
i = (byte3 & 0xff) + 4;
|
||||||
|
l = ai[l];
|
||||||
|
k = (byte) (l & 0xff);
|
||||||
|
l >>= 8;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
int i2 = state.totalOutLo32;
|
||||||
|
state.totalOutLo32 += k1 - j1;
|
||||||
|
if (state.totalOutLo32 < i2)
|
||||||
|
state.totalOutHigh32++;
|
||||||
|
state.aByte573 = byte4;
|
||||||
|
state.anInt574 = i;
|
||||||
|
state.anInt584 = j;
|
||||||
|
state.anInt582 = k;
|
||||||
|
BZip2DecompressionState.tt = ai;
|
||||||
|
state.anInt581 = l;
|
||||||
|
state.decompressed = abyte0;
|
||||||
|
state.nextOut = i1;
|
||||||
|
state.length = j1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void decompress(BZip2DecompressionState state) {
|
||||||
|
int gMinLen = 0;
|
||||||
|
int gLimit[] = null;
|
||||||
|
int gBase[] = null;
|
||||||
|
int gPerm[] = null;
|
||||||
|
state.anInt578 = 1;
|
||||||
|
if (BZip2DecompressionState.tt == null)
|
||||||
|
BZip2DecompressionState.tt = new int[state.anInt578 * 0x186a0];
|
||||||
|
boolean flag19 = true;
|
||||||
|
while (flag19) {
|
||||||
|
byte uc = getUnsignedChar(state);
|
||||||
|
if (uc == 23)
|
||||||
|
return;
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
state.currentBlock++;
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
uc = getBit(state);
|
||||||
|
state.aBoolean575 = uc != 0;
|
||||||
|
state.randomised = 0;
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
state.randomised = state.randomised << 8 | uc & 0xff;
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
state.randomised = state.randomised << 8 | uc & 0xff;
|
||||||
|
uc = getUnsignedChar(state);
|
||||||
|
state.randomised = state.randomised << 8 | uc & 0xff;
|
||||||
|
for (int j = 0; j < 16; j++) {
|
||||||
|
byte bit = getBit(state);
|
||||||
|
state.inUse16[j] = bit == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = 0; k < 256; k++)
|
||||||
|
state.inUse[k] = false;
|
||||||
|
|
||||||
|
for (int l = 0; l < 16; l++)
|
||||||
|
if (state.inUse16[l]) {
|
||||||
|
for (int i3 = 0; i3 < 16; i3++) {
|
||||||
|
byte byte2 = getBit(state);
|
||||||
|
if (byte2 == 1)
|
||||||
|
state.inUse[l * 16 + i3] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
makeMaps(state);
|
||||||
|
int alphabetSize = state.nInUse + 2;
|
||||||
|
/*
|
||||||
|
* number of different Huffman tables in use
|
||||||
|
*/
|
||||||
|
int huffmanTableCount = getBits(3, state);
|
||||||
|
/*
|
||||||
|
* number of times that the Huffman tables are swapped (each 50 bytes)
|
||||||
|
*/
|
||||||
|
int swapCount = getBits(15, state);
|
||||||
|
for (int i1 = 0; i1 < swapCount; i1++) {
|
||||||
|
int count = 0;
|
||||||
|
do {
|
||||||
|
byte byte3 = getBit(state);
|
||||||
|
if (byte3 == 0)
|
||||||
|
break;
|
||||||
|
count++;
|
||||||
|
} while (true);
|
||||||
|
state.selectorMtf[i1] = (byte) count;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte pos[] = new byte[6];
|
||||||
|
for (byte v = 0; v < huffmanTableCount; v++)
|
||||||
|
pos[v] = v;
|
||||||
|
|
||||||
|
for (int j1 = 0; j1 < swapCount; j1++) {
|
||||||
|
byte v = state.selectorMtf[j1];
|
||||||
|
byte tmp = pos[v];
|
||||||
|
for (; v > 0; v--)
|
||||||
|
pos[v] = pos[v - 1];
|
||||||
|
|
||||||
|
pos[0] = tmp;
|
||||||
|
state.selector[j1] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k3 = 0; k3 < huffmanTableCount; k3++) {
|
||||||
|
int l6 = getBits(5, state);
|
||||||
|
for (int k1 = 0; k1 < alphabetSize; k1++) {
|
||||||
|
do {
|
||||||
|
byte byte4 = getBit(state);
|
||||||
|
if (byte4 == 0)
|
||||||
|
break;
|
||||||
|
byte4 = getBit(state);
|
||||||
|
if (byte4 == 0)
|
||||||
|
l6++;
|
||||||
|
else
|
||||||
|
l6--;
|
||||||
|
} while (true);
|
||||||
|
state.len[k3][k1] = (byte) l6;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int l3 = 0; l3 < huffmanTableCount; l3++) {
|
||||||
|
byte byte8 = 32;
|
||||||
|
int i = 0;
|
||||||
|
for (int l1 = 0; l1 < alphabetSize; l1++) {
|
||||||
|
if (state.len[l3][l1] > i)
|
||||||
|
i = state.len[l3][l1];
|
||||||
|
if (state.len[l3][l1] < byte8)
|
||||||
|
byte8 = state.len[l3][l1];
|
||||||
|
}
|
||||||
|
|
||||||
|
createDecodeTables(state.limit[l3], state.base[l3], state.perm[l3], state.len[l3], byte8, i, alphabetSize);
|
||||||
|
state.minLens[l3] = byte8;
|
||||||
|
}
|
||||||
|
|
||||||
|
int l4 = state.nInUse + 1;
|
||||||
|
int i5 = -1;
|
||||||
|
int j5 = 0;
|
||||||
|
for (int i2 = 0; i2 <= 255; i2++)
|
||||||
|
state.unzftab[i2] = 0;
|
||||||
|
|
||||||
|
int j9 = 4095;
|
||||||
|
for (int l8 = 15; l8 >= 0; l8--) {
|
||||||
|
for (int i9 = 15; i9 >= 0; i9--) {
|
||||||
|
state.mtfa[j9] = (byte) (l8 * 16 + i9);
|
||||||
|
j9--;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.mtfbase[l8] = j9 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i6 = 0;
|
||||||
|
if (j5 == 0) {
|
||||||
|
i5++;
|
||||||
|
j5 = 50;
|
||||||
|
byte byte12 = state.selector[i5];
|
||||||
|
gMinLen = state.minLens[byte12];
|
||||||
|
gLimit = state.limit[byte12];
|
||||||
|
gPerm = state.perm[byte12];
|
||||||
|
gBase = state.base[byte12];
|
||||||
|
}
|
||||||
|
j5--;
|
||||||
|
int i7 = gMinLen;
|
||||||
|
int l7;
|
||||||
|
byte byte9;
|
||||||
|
for (l7 = getBits(i7, state); l7 > gLimit[i7]; l7 = l7 << 1 | byte9) {
|
||||||
|
i7++;
|
||||||
|
byte9 = getBit(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k5 = gPerm[l7 - gBase[i7]]; k5 != l4;)
|
||||||
|
if (k5 == 0 || k5 == 1) {
|
||||||
|
int j6 = -1;
|
||||||
|
int k6 = 1;
|
||||||
|
do {
|
||||||
|
if (k5 == 0)
|
||||||
|
j6 += k6;
|
||||||
|
else if (k5 == 1)
|
||||||
|
j6 += 2 * k6;
|
||||||
|
k6 *= 2;
|
||||||
|
if (j5 == 0) {
|
||||||
|
i5++;
|
||||||
|
j5 = 50;
|
||||||
|
byte byte13 = state.selector[i5];
|
||||||
|
gMinLen = state.minLens[byte13];
|
||||||
|
gLimit = state.limit[byte13];
|
||||||
|
gPerm = state.perm[byte13];
|
||||||
|
gBase = state.base[byte13];
|
||||||
|
}
|
||||||
|
j5--;
|
||||||
|
int j7 = gMinLen;
|
||||||
|
int i8;
|
||||||
|
byte byte10;
|
||||||
|
for (i8 = getBits(j7, state); i8 > gLimit[j7]; i8 = i8 << 1 | byte10) {
|
||||||
|
j7++;
|
||||||
|
byte10 = getBit(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
k5 = gPerm[i8 - gBase[j7]];
|
||||||
|
} while (k5 == 0 || k5 == 1);
|
||||||
|
j6++;
|
||||||
|
byte byte5 = state.seqToUnseq[state.mtfa[state.mtfbase[0]] & 0xff];
|
||||||
|
state.unzftab[byte5 & 0xff] += j6;
|
||||||
|
for (; j6 > 0; j6--) {
|
||||||
|
BZip2DecompressionState.tt[i6] = byte5 & 0xff;
|
||||||
|
i6++;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
int j11 = k5 - 1;
|
||||||
|
byte byte6;
|
||||||
|
if (j11 < 16) {
|
||||||
|
int j10 = state.mtfbase[0];
|
||||||
|
byte6 = state.mtfa[j10 + j11];
|
||||||
|
for (; j11 > 3; j11 -= 4) {
|
||||||
|
int k11 = j10 + j11;
|
||||||
|
state.mtfa[k11] = state.mtfa[k11 - 1];
|
||||||
|
state.mtfa[k11 - 1] = state.mtfa[k11 - 2];
|
||||||
|
state.mtfa[k11 - 2] = state.mtfa[k11 - 3];
|
||||||
|
state.mtfa[k11 - 3] = state.mtfa[k11 - 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; j11 > 0; j11--)
|
||||||
|
state.mtfa[j10 + j11] = state.mtfa[(j10 + j11) - 1];
|
||||||
|
|
||||||
|
state.mtfa[j10] = byte6;
|
||||||
|
} else {
|
||||||
|
int l10 = j11 / 16;
|
||||||
|
int i11 = j11 % 16;
|
||||||
|
int k10 = state.mtfbase[l10] + i11;
|
||||||
|
byte6 = state.mtfa[k10];
|
||||||
|
for (; k10 > state.mtfbase[l10]; k10--)
|
||||||
|
state.mtfa[k10] = state.mtfa[k10 - 1];
|
||||||
|
|
||||||
|
state.mtfbase[l10]++;
|
||||||
|
for (; l10 > 0; l10--) {
|
||||||
|
state.mtfbase[l10]--;
|
||||||
|
state.mtfa[state.mtfbase[l10]] = state.mtfa[(state.mtfbase[l10 - 1] + 16) - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
state.mtfbase[0]--;
|
||||||
|
state.mtfa[state.mtfbase[0]] = byte6;
|
||||||
|
if (state.mtfbase[0] == 0) {
|
||||||
|
int i10 = 4095;
|
||||||
|
for (int k9 = 15; k9 >= 0; k9--) {
|
||||||
|
for (int l9 = 15; l9 >= 0; l9--) {
|
||||||
|
state.mtfa[i10] = state.mtfa[state.mtfbase[k9] + l9];
|
||||||
|
i10--;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.mtfbase[k9] = i10 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state.unzftab[state.seqToUnseq[byte6 & 0xff] & 0xff]++;
|
||||||
|
BZip2DecompressionState.tt[i6] = state.seqToUnseq[byte6 & 0xff] & 0xff;
|
||||||
|
i6++;
|
||||||
|
if (j5 == 0) {
|
||||||
|
i5++;
|
||||||
|
j5 = 50;
|
||||||
|
byte byte14 = state.selector[i5];
|
||||||
|
gMinLen = state.minLens[byte14];
|
||||||
|
gLimit = state.limit[byte14];
|
||||||
|
gPerm = state.perm[byte14];
|
||||||
|
gBase = state.base[byte14];
|
||||||
|
}
|
||||||
|
j5--;
|
||||||
|
int k7 = gMinLen;
|
||||||
|
int j8;
|
||||||
|
byte byte11;
|
||||||
|
for (j8 = getBits(k7, state); j8 > gLimit[k7]; j8 = j8 << 1 | byte11) {
|
||||||
|
k7++;
|
||||||
|
byte11 = getBit(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
k5 = gPerm[j8 - gBase[k7]];
|
||||||
|
}
|
||||||
|
|
||||||
|
state.anInt574 = 0;
|
||||||
|
state.aByte573 = 0;
|
||||||
|
state.cftab[0] = 0;
|
||||||
|
for (int j2 = 1; j2 <= 256; j2++)
|
||||||
|
state.cftab[j2] = state.unzftab[j2 - 1];
|
||||||
|
|
||||||
|
for (int k2 = 1; k2 <= 256; k2++)
|
||||||
|
state.cftab[k2] += state.cftab[k2 - 1];
|
||||||
|
|
||||||
|
for (int l2 = 0; l2 < i6; l2++) {
|
||||||
|
byte byte7 = (byte) (BZip2DecompressionState.tt[l2] & 0xff);
|
||||||
|
BZip2DecompressionState.tt[state.cftab[byte7 & 0xff]] |= l2 << 8;
|
||||||
|
state.cftab[byte7 & 0xff]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.anInt581 = BZip2DecompressionState.tt[state.randomised] >> 8;
|
||||||
|
state.anInt584 = 0;
|
||||||
|
state.anInt581 = BZip2DecompressionState.tt[state.anInt581];
|
||||||
|
state.anInt582 = (byte) (state.anInt581 & 0xff);
|
||||||
|
state.anInt581 >>= 8;
|
||||||
|
state.anInt584++;
|
||||||
|
state.anInt601 = i6;
|
||||||
|
method226(state);
|
||||||
|
flag19 = state.anInt584 == state.anInt601 + 1 && state.anInt574 == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte getUnsignedChar(BZip2DecompressionState state) {
|
||||||
|
return (byte) getBits(8, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte getBit(BZip2DecompressionState state) {
|
||||||
|
return (byte) getBits(1, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getBits(int i, BZip2DecompressionState state) {
|
||||||
|
int j;
|
||||||
|
do {
|
||||||
|
if (state.bsLive >= i) {
|
||||||
|
int k = state.bsBuff >> state.bsLive - i & (1 << i) - 1;
|
||||||
|
state.bsLive -= i;
|
||||||
|
j = k;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
state.bsBuff = state.bsBuff << 8 | state.compressed[state.nextIn] & 0xff;
|
||||||
|
state.bsLive += 8;
|
||||||
|
state.nextIn++;
|
||||||
|
state.decompressedLength--;
|
||||||
|
state.totalInLo32++;
|
||||||
|
if (state.totalInLo32 == 0)
|
||||||
|
state.totalInHi32++;
|
||||||
|
} while (true);
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void makeMaps(BZip2DecompressionState state) {
|
||||||
|
state.nInUse = 0;
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
if (state.inUse[i]) {
|
||||||
|
state.seqToUnseq[state.nInUse] = (byte) i;
|
||||||
|
state.nInUse++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createDecodeTables(int limit[], int base[], int perm[], byte length[], int i, int maxLength, int alphabetSize) {
|
||||||
|
int pp = 0;
|
||||||
|
for (int i1 = i; i1 <= maxLength; i1++) {
|
||||||
|
for (int l2 = 0; l2 < alphabetSize; l2++) {
|
||||||
|
if (length[l2] == i1) {
|
||||||
|
perm[pp] = l2;
|
||||||
|
pp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j1 = 0; j1 < 23; j1++)
|
||||||
|
base[j1] = 0;
|
||||||
|
|
||||||
|
for (int k1 = 0; k1 < alphabetSize; k1++)
|
||||||
|
base[length[k1] + 1]++;
|
||||||
|
|
||||||
|
for (int l1 = 1; l1 < 23; l1++)
|
||||||
|
base[l1] += base[l1 - 1];
|
||||||
|
|
||||||
|
for (int i2 = 0; i2 < 23; i2++)
|
||||||
|
limit[i2] = 0;
|
||||||
|
|
||||||
|
int vec = 0;
|
||||||
|
for (int j2 = i; j2 <= maxLength; j2++) {
|
||||||
|
vec += base[j2 + 1] - base[j2];
|
||||||
|
limit[j2] = vec - 1;
|
||||||
|
vec <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k2 = i + 1; k2 <= maxLength; k2++)
|
||||||
|
base[k2] = (limit[k2 - 1] + 1 << 1) - base[k2];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final BZip2DecompressionState state = new BZip2DecompressionState();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package org.rebotted.cache.config;
|
||||||
|
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class Varbit {
|
||||||
|
|
||||||
|
public static Varbit varbits[];
|
||||||
|
public int setting = -1;
|
||||||
|
public int low = -1;
|
||||||
|
public int high = -1;
|
||||||
|
private boolean aBoolean651;
|
||||||
|
|
||||||
|
public static void init(FileArchive streamLoader) {
|
||||||
|
Buffer datBuf = new Buffer(streamLoader.readFile("varbit.dat"));
|
||||||
|
|
||||||
|
final int size = datBuf.readUShort();
|
||||||
|
|
||||||
|
if (varbits == null) {
|
||||||
|
varbits = new Varbit[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < size; index++) {
|
||||||
|
|
||||||
|
if (varbits[index] == null) {
|
||||||
|
varbits[index] = new Varbit();
|
||||||
|
}
|
||||||
|
|
||||||
|
varbits[index].decode(datBuf);
|
||||||
|
|
||||||
|
if (varbits[index].aBoolean651) {
|
||||||
|
Varp.variables[varbits[index].setting].aBoolean713 = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (datBuf.currentPosition != datBuf.payload.length) {
|
||||||
|
System.out.println("varbit load mismatch");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* private void decode(Buffer stream) {
|
||||||
|
setting = stream.readUShort();
|
||||||
|
low = stream.readUnsignedByte();
|
||||||
|
high = stream.readUnsignedByte();
|
||||||
|
|
||||||
|
}*/
|
||||||
|
private void decode(Buffer stream) {
|
||||||
|
do {
|
||||||
|
int j = stream.readUnsignedByte();
|
||||||
|
if (j == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (j == 1) {
|
||||||
|
setting = stream.readUShort();
|
||||||
|
low = stream.readUnsignedByte();
|
||||||
|
high = stream.readUnsignedByte();
|
||||||
|
} else if (j == 10) {
|
||||||
|
stream.readString();
|
||||||
|
} else if (j == 2) {
|
||||||
|
aBoolean651 = true;
|
||||||
|
} else if (j == 3) {
|
||||||
|
stream.readDWord();
|
||||||
|
} else if (j == 4) {
|
||||||
|
stream.readDWord();
|
||||||
|
} else {
|
||||||
|
System.out.println("Error unrecognised config code: " + j);
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Varbit() {
|
||||||
|
aBoolean651 = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSetting() {
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLow() {
|
||||||
|
return low;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHigh() {
|
||||||
|
return high;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+108
@@ -0,0 +1,108 @@
|
|||||||
|
package org.rebotted.cache.config;
|
||||||
|
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Varps are used for inteface configuration ids and their functions, out of the current 725 config ids, only 9 or so of them are used.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public final class Varp {
|
||||||
|
|
||||||
|
public static Varp[] variables;
|
||||||
|
|
||||||
|
private static int currentIndex;
|
||||||
|
private static int[] configIds;
|
||||||
|
public int actionId;
|
||||||
|
public boolean aBoolean713;
|
||||||
|
|
||||||
|
private Varp() {
|
||||||
|
aBoolean713 = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(FileArchive archive) {
|
||||||
|
Buffer buffer = new Buffer(archive.readFile("varp.dat"));
|
||||||
|
|
||||||
|
currentIndex = 0;
|
||||||
|
|
||||||
|
int length = buffer.readUShort();
|
||||||
|
|
||||||
|
if (variables == null) {
|
||||||
|
variables = new Varp[length];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configIds == null) {
|
||||||
|
configIds = new int[length];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < length; index++) {
|
||||||
|
if (variables[index] == null) {
|
||||||
|
variables[index] = new Varp();
|
||||||
|
}
|
||||||
|
|
||||||
|
variables[index].decode(buffer, index);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer.currentPosition != buffer.payload.length) {
|
||||||
|
System.out.println("varptype load mismatch");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decode(Buffer buffer, int index) {
|
||||||
|
do {
|
||||||
|
int opcode = buffer.readUnsignedByte();
|
||||||
|
|
||||||
|
if (opcode == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opcode == 1) {
|
||||||
|
buffer.readUnsignedByte();
|
||||||
|
} else if (opcode == 2) {
|
||||||
|
buffer.readUnsignedByte();
|
||||||
|
} else if (opcode == 3) {
|
||||||
|
configIds[currentIndex++] = index;
|
||||||
|
} else if (opcode == 4) {
|
||||||
|
} else if (opcode == 5) {
|
||||||
|
actionId = buffer.readUShort();
|
||||||
|
} else if (opcode == 6) {
|
||||||
|
} else if (opcode == 7) {
|
||||||
|
buffer.readInt();
|
||||||
|
} else if (opcode == 8) {
|
||||||
|
aBoolean713 = true;
|
||||||
|
} else if (opcode == 10) {
|
||||||
|
buffer.readString();
|
||||||
|
} else if (opcode == 11) {
|
||||||
|
aBoolean713 = true;
|
||||||
|
} else if (opcode == 12) {
|
||||||
|
buffer.readInt();
|
||||||
|
} else if (opcode == 13) {
|
||||||
|
} else {
|
||||||
|
System.out.println("Error unrecognised config code: " + opcode);
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Varp[] getVariables() {
|
||||||
|
return variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getCurrentIndex() {
|
||||||
|
return currentIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int[] getConfigIds() {
|
||||||
|
return configIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getActionId() {
|
||||||
|
return actionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isaBoolean713() {
|
||||||
|
return aBoolean713;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package org.rebotted.cache.def;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class FileOperations {
|
||||||
|
|
||||||
|
public FileOperations() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final byte[] ReadFile(String s) {
|
||||||
|
try {
|
||||||
|
File file = new File(s);
|
||||||
|
int i = (int) file.length();
|
||||||
|
byte abyte0[] = new byte[i];
|
||||||
|
DataInputStream datainputstream = new DataInputStream(
|
||||||
|
new BufferedInputStream(new FileInputStream(s)));
|
||||||
|
datainputstream.readFully(abyte0, 0, i);
|
||||||
|
datainputstream.close();
|
||||||
|
TotalRead++;
|
||||||
|
return abyte0;
|
||||||
|
} catch (Exception exception) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final void WriteFile(String s, byte abyte0[]) {
|
||||||
|
try {
|
||||||
|
(new File((new File(s)).getParent())).mkdirs();
|
||||||
|
FileOutputStream fileoutputstream = new FileOutputStream(s);
|
||||||
|
fileoutputstream.write(abyte0, 0, abyte0.length);
|
||||||
|
fileoutputstream.close();
|
||||||
|
TotalWrite++;
|
||||||
|
CompleteWrite++;
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
System.out.println((new StringBuilder()).append("Write Error: ")
|
||||||
|
.append(s).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean FileExists(String file) {
|
||||||
|
File f = new File(file);
|
||||||
|
return f.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int TotalRead = 0;
|
||||||
|
public static int TotalWrite = 0;
|
||||||
|
public static int CompleteWrite = 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
package org.rebotted.cache.def;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
|
||||||
|
|
||||||
|
public class FloorDefinition {
|
||||||
|
|
||||||
|
public static FloorDefinition[] overlays;
|
||||||
|
public static FloorDefinition[] underlays;
|
||||||
|
|
||||||
|
public int texture;
|
||||||
|
public int rgb;
|
||||||
|
public boolean occlude;
|
||||||
|
public int anotherRgb;
|
||||||
|
|
||||||
|
public int hue;
|
||||||
|
public int saturation;
|
||||||
|
public int luminance;
|
||||||
|
|
||||||
|
public int anotherHue;
|
||||||
|
public int anotherSaturation;
|
||||||
|
public int anotherLuminance;
|
||||||
|
|
||||||
|
public int blendHue;
|
||||||
|
public int blendHueMultiplier;
|
||||||
|
public int hsl16;
|
||||||
|
|
||||||
|
private FloorDefinition() {
|
||||||
|
texture = -1;
|
||||||
|
occlude = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unpackConfig(FileArchive streamLoader) {
|
||||||
|
ByteBuffer buffer = ByteBuffer.wrap(streamLoader.readFile("flo.dat"));
|
||||||
|
int underlayAmount = buffer.getShort();
|
||||||
|
System.out.println("Underlay Floors Loaded: "+underlayAmount);
|
||||||
|
underlays = new FloorDefinition[underlayAmount];
|
||||||
|
for (int i = 0; i < underlayAmount; i++) {
|
||||||
|
if (underlays[i] == null) {
|
||||||
|
underlays[i] = new FloorDefinition();
|
||||||
|
}
|
||||||
|
underlays[i].readValuesUnderlay(buffer);
|
||||||
|
underlays[i].generateHsl();
|
||||||
|
}
|
||||||
|
int overlayAmount = buffer.getShort();
|
||||||
|
System.out.println("Overlay Floors Loaded: "+overlayAmount);
|
||||||
|
overlays = new FloorDefinition[overlayAmount];
|
||||||
|
for (int i = 0; i < overlayAmount; i++) {
|
||||||
|
if (overlays[i] == null) {
|
||||||
|
overlays[i] = new FloorDefinition();
|
||||||
|
}
|
||||||
|
overlays[i].readValuesOverlay(buffer);
|
||||||
|
overlays[i].generateHsl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateHsl() {
|
||||||
|
if (anotherRgb != -1) {
|
||||||
|
rgbToHsl(anotherRgb);
|
||||||
|
anotherHue = hue;
|
||||||
|
anotherSaturation = saturation;
|
||||||
|
anotherLuminance = luminance;
|
||||||
|
}
|
||||||
|
rgbToHsl(rgb);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readValuesUnderlay(ByteBuffer buffer) {
|
||||||
|
for (;;) {
|
||||||
|
int opcode = buffer.get();
|
||||||
|
if (opcode == 0) {
|
||||||
|
break;
|
||||||
|
} else if (opcode == 1) {
|
||||||
|
rgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
|
||||||
|
} else {
|
||||||
|
System.out.println("Error unrecognised underlay code: " + opcode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readValuesOverlay(ByteBuffer buffer) {
|
||||||
|
for (;;) {
|
||||||
|
int opcode = buffer.get();
|
||||||
|
if (opcode == 0) {
|
||||||
|
break;
|
||||||
|
} else if (opcode == 1) {
|
||||||
|
rgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
|
||||||
|
} else if (opcode == 2) {
|
||||||
|
texture = buffer.get() & 0xff;
|
||||||
|
} else if (opcode == 5) {
|
||||||
|
occlude = false;
|
||||||
|
} else if (opcode == 7) {
|
||||||
|
anotherRgb = ((buffer.get() & 0xff) << 16) + ((buffer.get() & 0xff) << 8) + (buffer.get() & 0xff);
|
||||||
|
} else {
|
||||||
|
System.out.println("Error unrecognised overlay code: " + opcode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rgbToHsl(int rgb) {
|
||||||
|
double r = (rgb >> 16 & 0xff) / 256.0;
|
||||||
|
double g = (rgb >> 8 & 0xff) / 256.0;
|
||||||
|
double b = (rgb & 0xff) / 256.0;
|
||||||
|
double min = r;
|
||||||
|
if (g < min) {
|
||||||
|
min = g;
|
||||||
|
}
|
||||||
|
if (b < min) {
|
||||||
|
min = b;
|
||||||
|
}
|
||||||
|
double max = r;
|
||||||
|
if (g > max) {
|
||||||
|
max = g;
|
||||||
|
}
|
||||||
|
if (b > max) {
|
||||||
|
max = b;
|
||||||
|
}
|
||||||
|
double h = 0.0;
|
||||||
|
double s = 0.0;
|
||||||
|
double l = (min + max) / 2.0;
|
||||||
|
if (min != max) {
|
||||||
|
if (l < 0.5) {
|
||||||
|
s = (max - min) / (max + min);
|
||||||
|
}
|
||||||
|
if (l >= 0.5) {
|
||||||
|
s = (max - min) / (2.0 - max - min);
|
||||||
|
}
|
||||||
|
if (r == max) {
|
||||||
|
h = (g - b) / (max - min);
|
||||||
|
} else if (g == max) {
|
||||||
|
h = 2.0 + (b - r) / (max - min);
|
||||||
|
} else if (b == max) {
|
||||||
|
h = 4.0 + (r - g) / (max - min);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h /= 6.0;
|
||||||
|
hue = (int) (h * 256.0);
|
||||||
|
saturation = (int) (s * 256.0);
|
||||||
|
luminance = (int) (l * 256.0);
|
||||||
|
if (saturation < 0) {
|
||||||
|
saturation = 0;
|
||||||
|
} else if (saturation > 255) {
|
||||||
|
saturation = 255;
|
||||||
|
}
|
||||||
|
if (luminance < 0) {
|
||||||
|
luminance = 0;
|
||||||
|
} else if (luminance > 255) {
|
||||||
|
luminance = 255;
|
||||||
|
}
|
||||||
|
if (l > 0.5) {
|
||||||
|
blendHueMultiplier = (int) ((1.0 - l) * s * 512.0);
|
||||||
|
} else {
|
||||||
|
blendHueMultiplier = (int) (l * s * 512.0);
|
||||||
|
}
|
||||||
|
if (blendHueMultiplier < 1) {
|
||||||
|
blendHueMultiplier = 1;
|
||||||
|
}
|
||||||
|
blendHue = (int) (h * blendHueMultiplier);
|
||||||
|
hsl16 = hsl24to16(hue, saturation, luminance);
|
||||||
|
}
|
||||||
|
|
||||||
|
final static int hsl24to16(int h, int s, int l) {
|
||||||
|
if (l > 179) {
|
||||||
|
s /= 2;
|
||||||
|
}
|
||||||
|
if (l > 192) {
|
||||||
|
s /= 2;
|
||||||
|
}
|
||||||
|
if (l > 217) {
|
||||||
|
s /= 2;
|
||||||
|
}
|
||||||
|
if (l > 243) {
|
||||||
|
s /= 2;
|
||||||
|
}
|
||||||
|
return (h / 4 << 10) + (s / 32 << 7) + l / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,556 @@
|
|||||||
|
package org.rebotted.cache.def;
|
||||||
|
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.cache.graphics.Sprite;
|
||||||
|
import org.rebotted.collection.ReferenceCache;
|
||||||
|
import org.rebotted.draw.Rasterizer2D;
|
||||||
|
import org.rebotted.draw.Rasterizer3D;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class ItemDefinition {
|
||||||
|
|
||||||
|
public static void init(FileArchive archive) {
|
||||||
|
dataBuf = new Buffer(archive.readFile("obj.dat"));
|
||||||
|
Buffer idxBuf = new Buffer(archive.readFile("obj.idx"));
|
||||||
|
|
||||||
|
itemCount = idxBuf.readUShort();
|
||||||
|
streamIndices = new int[itemCount];
|
||||||
|
|
||||||
|
int offset = 2;
|
||||||
|
|
||||||
|
for (int i = 0; i < itemCount; i++) {
|
||||||
|
streamIndices[i] = offset;
|
||||||
|
offset += idxBuf.readUShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
cache = new ItemDefinition[10];
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
cache[i] = new ItemDefinition();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Loaded: " + itemCount + " Items");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decode(Buffer buffer) {
|
||||||
|
do {
|
||||||
|
int opcode = buffer.readUnsignedByte();
|
||||||
|
|
||||||
|
if (opcode == 0) {
|
||||||
|
return;
|
||||||
|
} else if (opcode == 1) {
|
||||||
|
inventoryModel = buffer.readUShort();
|
||||||
|
} else if (opcode == 2) {
|
||||||
|
name = buffer.readString();
|
||||||
|
} else if (opcode == 3) {
|
||||||
|
description = buffer.readString();
|
||||||
|
} else if (opcode == 4) {
|
||||||
|
modelZoom = buffer.readUShort();
|
||||||
|
} else if (opcode == 5) {
|
||||||
|
rotationY = buffer.readUShort();
|
||||||
|
} else if (opcode == 6) {
|
||||||
|
rotationX = buffer.readUShort();
|
||||||
|
} else if (opcode == 7) {
|
||||||
|
translateX = buffer.readUShort();
|
||||||
|
if (translateX > 32767)
|
||||||
|
translateX -= 0x10000;
|
||||||
|
} else if (opcode == 8) {
|
||||||
|
translateYZ = buffer.readUShort();
|
||||||
|
if (translateYZ > 32767)
|
||||||
|
translateYZ -= 0x10000;
|
||||||
|
} else if (opcode == 10) {
|
||||||
|
buffer.readUShort();
|
||||||
|
} else if (opcode == 11) {
|
||||||
|
stackable = true;
|
||||||
|
} else if (opcode == 12) {
|
||||||
|
value = buffer.readInt();
|
||||||
|
} else if (opcode == 16) {
|
||||||
|
members = true;
|
||||||
|
} else if (opcode == 23) {
|
||||||
|
equippedMaleModel1 = buffer.readUShort();
|
||||||
|
equippedMaleModelTranslationY = buffer.readSignedByte();
|
||||||
|
} else if (opcode == 24) {
|
||||||
|
equippedMaleModel2 = buffer.readUShort();
|
||||||
|
} else if (opcode == 25) {
|
||||||
|
equippedFemaleModel1 = buffer.readUShort();
|
||||||
|
equippedFemaleModelTranslationY = buffer.readSignedByte();
|
||||||
|
} else if (opcode == 26) {
|
||||||
|
equippedFemaleModel2 = buffer.readUShort();
|
||||||
|
} else if (opcode >= 30 && opcode < 35) {
|
||||||
|
if (groundActions == null) {
|
||||||
|
groundActions = new String[5];
|
||||||
|
}
|
||||||
|
groundActions[opcode - 30] = buffer.readString();
|
||||||
|
if (groundActions[opcode - 30].equalsIgnoreCase("hidden")) {
|
||||||
|
groundActions[opcode - 30] = null;
|
||||||
|
}
|
||||||
|
} else if (opcode >= 35 && opcode < 40) {
|
||||||
|
if (actions == null) {
|
||||||
|
actions = new String[5];
|
||||||
|
}
|
||||||
|
actions[opcode - 35] = buffer.readString();
|
||||||
|
} else if (opcode == 40) {
|
||||||
|
|
||||||
|
int colors = buffer.readUnsignedByte();
|
||||||
|
modifiedModelColors = new int[colors];
|
||||||
|
originalModelColors = new int[colors];
|
||||||
|
for (int i = 0; i < colors; i++) {
|
||||||
|
modifiedModelColors[i] = buffer.readUShort();
|
||||||
|
originalModelColors[i] = buffer.readUShort();
|
||||||
|
}
|
||||||
|
} else if (opcode == 78) {
|
||||||
|
equippedMaleModel3 = buffer.readUShort();
|
||||||
|
} else if (opcode == 79) {
|
||||||
|
equippedFemaleModel3 = buffer.readUShort();
|
||||||
|
} else if (opcode == 90) {
|
||||||
|
equippedMaleModelDialogue1 = buffer.readUShort();
|
||||||
|
} else if (opcode == 91) {
|
||||||
|
equippedFemaleModelDialogue1 = buffer.readUShort();
|
||||||
|
} else if (opcode == 92) {
|
||||||
|
equippedMaleModelDialogue2 = buffer.readUShort();
|
||||||
|
} else if (opcode == 93) {
|
||||||
|
equippedFemaleModelDialogue2 = buffer.readUShort();
|
||||||
|
} else if (opcode == 95) {
|
||||||
|
rotationZ = buffer.readUShort();
|
||||||
|
} else if (opcode == 97) {
|
||||||
|
unnotedItemId = buffer.readUShort();
|
||||||
|
} else if (opcode == 98) {
|
||||||
|
notedItemId = buffer.readUShort();
|
||||||
|
} else if (opcode >= 100 && opcode < 110) {
|
||||||
|
if (stackVariantId == null) {
|
||||||
|
stackVariantId = new int[10];
|
||||||
|
stackVariantSize = new int[10];
|
||||||
|
}
|
||||||
|
stackVariantId[opcode - 100] = buffer.readUShort();
|
||||||
|
stackVariantSize[opcode - 100] = buffer.readUShort();
|
||||||
|
} else if (opcode == 110) {
|
||||||
|
modelScaleX = buffer.readUShort();
|
||||||
|
} else if (opcode == 111) {
|
||||||
|
modelScaleY = buffer.readUShort();
|
||||||
|
} else if (opcode == 112) {
|
||||||
|
modelScaleZ = buffer.readUShort();
|
||||||
|
} else if (opcode == 113) {
|
||||||
|
lightIntensity = buffer.readSignedByte();
|
||||||
|
} else if (opcode == 114) {
|
||||||
|
lightMag = buffer.readSignedByte() * 5;
|
||||||
|
} else if (opcode == 115) {
|
||||||
|
team = buffer.readUnsignedByte();
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getChatEquipModel(int gender) {
|
||||||
|
int dialogueModel = equippedMaleModelDialogue1;
|
||||||
|
int dialogueHatModel = equippedMaleModelDialogue2;
|
||||||
|
if (gender == 1) {
|
||||||
|
dialogueModel = equippedFemaleModelDialogue1;
|
||||||
|
dialogueHatModel = equippedFemaleModelDialogue2;
|
||||||
|
}
|
||||||
|
if (dialogueModel == -1)
|
||||||
|
return null;
|
||||||
|
Model dialogueModel_ = Model.getModel(dialogueModel);
|
||||||
|
if (dialogueHatModel != -1) {
|
||||||
|
Model hatModel_ = Model.getModel(dialogueHatModel);
|
||||||
|
Model models[] = { dialogueModel_, hatModel_ };
|
||||||
|
dialogueModel_ = new Model(2, models);
|
||||||
|
}
|
||||||
|
if (modifiedModelColors != null) {
|
||||||
|
for (int i1 = 0; i1 < modifiedModelColors.length; i1++)
|
||||||
|
dialogueModel_.recolor(modifiedModelColors[i1], originalModelColors[i1]);
|
||||||
|
|
||||||
|
}
|
||||||
|
return dialogueModel_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEquippedModelCached(int gender) {
|
||||||
|
int primaryModel = equippedMaleModel1;
|
||||||
|
int secondaryModel = equippedMaleModel2;
|
||||||
|
int emblem = equippedMaleModel3;
|
||||||
|
if (gender == 1) {
|
||||||
|
primaryModel = equippedFemaleModel1;
|
||||||
|
secondaryModel = equippedFemaleModel2;
|
||||||
|
emblem = equippedFemaleModel3;
|
||||||
|
}
|
||||||
|
if (primaryModel == -1)
|
||||||
|
return true;
|
||||||
|
boolean cached = true;
|
||||||
|
if (!Model.isCached(primaryModel))
|
||||||
|
cached = false;
|
||||||
|
if (secondaryModel != -1 && !Model.isCached(secondaryModel))
|
||||||
|
cached = false;
|
||||||
|
if (emblem != -1 && !Model.isCached(emblem))
|
||||||
|
cached = false;
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getEquippedModel(int gender) {
|
||||||
|
int primaryModel = equippedMaleModel1;
|
||||||
|
int secondaryModel = equippedMaleModel2;
|
||||||
|
int emblem = equippedMaleModel3;
|
||||||
|
if (gender == 1) {
|
||||||
|
primaryModel = equippedFemaleModel1;
|
||||||
|
secondaryModel = equippedFemaleModel2;
|
||||||
|
emblem = equippedFemaleModel3;
|
||||||
|
}
|
||||||
|
if (primaryModel == -1)
|
||||||
|
return null;
|
||||||
|
Model primaryModel_ = Model.getModel(primaryModel);
|
||||||
|
if (secondaryModel != -1)
|
||||||
|
if (emblem != -1) {
|
||||||
|
Model secondaryModel_ = Model.getModel(secondaryModel);
|
||||||
|
Model emblemModel = Model.getModel(emblem);
|
||||||
|
Model models[] = { primaryModel_, secondaryModel_, emblemModel };
|
||||||
|
primaryModel_ = new Model(3, models);
|
||||||
|
} else {
|
||||||
|
Model model_2 = Model.getModel(secondaryModel);
|
||||||
|
Model models[] = { primaryModel_, model_2 };
|
||||||
|
primaryModel_ = new Model(2, models);
|
||||||
|
}
|
||||||
|
if (gender == 0 && equippedMaleModelTranslationY != 0)
|
||||||
|
primaryModel_.translate(0, equippedMaleModelTranslationY, 0);
|
||||||
|
if (gender == 1 && equippedFemaleModelTranslationY != 0)
|
||||||
|
primaryModel_.translate(0, equippedFemaleModelTranslationY, 0);
|
||||||
|
if (modifiedModelColors != null) {
|
||||||
|
for (int i1 = 0; i1 < modifiedModelColors.length; i1++)
|
||||||
|
primaryModel_.recolor(modifiedModelColors[i1], originalModelColors[i1]);
|
||||||
|
|
||||||
|
}
|
||||||
|
return primaryModel_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDefaults() {
|
||||||
|
inventoryModel = 0;
|
||||||
|
name = "Dwarf Remains";
|
||||||
|
description = null;
|
||||||
|
modifiedModelColors = null;
|
||||||
|
originalModelColors = null;
|
||||||
|
modelZoom = 2000;
|
||||||
|
rotationY = 0;
|
||||||
|
rotationX = 0;
|
||||||
|
rotationZ = 0;
|
||||||
|
translateX = 0;
|
||||||
|
translateYZ = 0;
|
||||||
|
stackable = false;
|
||||||
|
value = 1;
|
||||||
|
members = false;
|
||||||
|
groundActions = null;
|
||||||
|
actions = null;
|
||||||
|
equippedMaleModel1 = -1;
|
||||||
|
equippedMaleModel2 = -1;
|
||||||
|
equippedMaleModelTranslationY = 0;
|
||||||
|
equippedFemaleModel1 = -1;
|
||||||
|
equippedFemaleModel2 = -1;
|
||||||
|
equippedFemaleModelTranslationY = 0;
|
||||||
|
equippedMaleModel3 = -1;
|
||||||
|
equippedFemaleModel3 = -1;
|
||||||
|
equippedMaleModelDialogue1 = -1;
|
||||||
|
equippedMaleModelDialogue2 = -1;
|
||||||
|
equippedFemaleModelDialogue1 = -1;
|
||||||
|
equippedFemaleModelDialogue2 = -1;
|
||||||
|
stackVariantId = null;
|
||||||
|
stackVariantSize = null;
|
||||||
|
unnotedItemId = -1;
|
||||||
|
notedItemId = -1;
|
||||||
|
modelScaleX = 128;
|
||||||
|
modelScaleY = 128;
|
||||||
|
modelScaleZ = 128;
|
||||||
|
lightIntensity = 0;
|
||||||
|
lightMag = 0;
|
||||||
|
team = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemDefinition lookup(int itemId) {
|
||||||
|
for (int count = 0; count < 10; count++) {
|
||||||
|
if (cache[count].id == itemId) {
|
||||||
|
return cache[count];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheIndex = (cacheIndex + 1) % 10;
|
||||||
|
ItemDefinition itemDef = cache[cacheIndex];
|
||||||
|
dataBuf.currentPosition = streamIndices[itemId];
|
||||||
|
itemDef.id = itemId;
|
||||||
|
itemDef.setDefaults();
|
||||||
|
itemDef.decode(dataBuf);
|
||||||
|
|
||||||
|
if (itemDef.notedItemId != -1) {
|
||||||
|
itemDef.toNote();
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemDef;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toNote() {
|
||||||
|
ItemDefinition itemDef = lookup(notedItemId);
|
||||||
|
inventoryModel = itemDef.inventoryModel;
|
||||||
|
modelZoom = itemDef.modelZoom;
|
||||||
|
rotationY = itemDef.rotationY;
|
||||||
|
rotationX = itemDef.rotationX;
|
||||||
|
|
||||||
|
rotationZ = itemDef.rotationZ;
|
||||||
|
translateX = itemDef.translateX;
|
||||||
|
translateYZ = itemDef.translateYZ;
|
||||||
|
modifiedModelColors = itemDef.modifiedModelColors;
|
||||||
|
originalModelColors = itemDef.originalModelColors;
|
||||||
|
ItemDefinition itemDef_1 = lookup(unnotedItemId);
|
||||||
|
name = itemDef_1.name;
|
||||||
|
members = itemDef_1.members;
|
||||||
|
value = itemDef_1.value;
|
||||||
|
String s = "a";
|
||||||
|
char c = itemDef_1.name.charAt(0);
|
||||||
|
if (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
|
||||||
|
s = "an";
|
||||||
|
description = ("Swap this note at any bank for " + s + " " + itemDef_1.name + ".");
|
||||||
|
stackable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Sprite getSprite(int itemId, int stackSize, int outlineColor) {
|
||||||
|
if (outlineColor == 0) {
|
||||||
|
Sprite sprite = (Sprite) sprites.get(itemId);
|
||||||
|
if (sprite != null && sprite.getMaxHeight() != stackSize && sprite.getMaxHeight() != -1) {
|
||||||
|
|
||||||
|
sprite.unlink();
|
||||||
|
sprite = null;
|
||||||
|
}
|
||||||
|
if (sprite != null)
|
||||||
|
return sprite;
|
||||||
|
}
|
||||||
|
ItemDefinition itemDef = lookup(itemId);
|
||||||
|
if (itemDef.stackVariantId == null)
|
||||||
|
stackSize = -1;
|
||||||
|
if (stackSize > 1) {
|
||||||
|
int stack_item_id = -1;
|
||||||
|
for (int j1 = 0; j1 < 10; j1++)
|
||||||
|
if (stackSize >= itemDef.stackVariantSize[j1] && itemDef.stackVariantSize[j1] != 0)
|
||||||
|
stack_item_id = itemDef.stackVariantId[j1];
|
||||||
|
|
||||||
|
if (stack_item_id != -1)
|
||||||
|
itemDef = lookup(stack_item_id);
|
||||||
|
}
|
||||||
|
Model model = itemDef.getModel(1);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
Sprite sprite = null;
|
||||||
|
if (itemDef.notedItemId != -1) {
|
||||||
|
sprite = getSprite(itemDef.unnotedItemId, 10, -1);
|
||||||
|
if (sprite == null)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Sprite enabledSprite = new Sprite(32, 32);
|
||||||
|
int centerX = Rasterizer3D.originViewX;
|
||||||
|
int centerY = Rasterizer3D.originViewY;
|
||||||
|
int lineOffsets[] = Rasterizer3D.scanOffsets;
|
||||||
|
int pixels[] = Rasterizer2D.pixels;
|
||||||
|
float depthBuffer[] = Rasterizer2D.depthBuffer;
|
||||||
|
int width = Rasterizer2D.width;
|
||||||
|
int height = Rasterizer2D.height;
|
||||||
|
int vp_left = Rasterizer2D.leftX;
|
||||||
|
int vp_right = Rasterizer2D.bottomX;
|
||||||
|
int vp_top = Rasterizer2D.topY;
|
||||||
|
int vp_bottom = Rasterizer2D.bottomY;
|
||||||
|
Rasterizer3D.aBoolean1464 = false;
|
||||||
|
Rasterizer2D.initDrawingArea(32, 32, enabledSprite.getMyPixels(), new float[32 * 32]);
|
||||||
|
Rasterizer2D.drawBox(0, 0, 32, 32, 0);
|
||||||
|
Rasterizer3D.useViewport();
|
||||||
|
int k3 = itemDef.modelZoom;
|
||||||
|
if (outlineColor == -1)
|
||||||
|
k3 = (int) ((double) k3 * 1.5D);
|
||||||
|
if (outlineColor > 0)
|
||||||
|
k3 = (int) ((double) k3 * 1.04D);
|
||||||
|
int l3 = Rasterizer3D.anIntArray1470[itemDef.rotationY] * k3 >> 16;
|
||||||
|
int i4 = Rasterizer3D.COSINE[itemDef.rotationY] * k3 >> 16;
|
||||||
|
model.method482(itemDef.rotationX, itemDef.rotationZ, itemDef.rotationY, itemDef.translateX,
|
||||||
|
l3 + model.modelBaseY / 2 + itemDef.translateYZ, i4 + itemDef.translateYZ);
|
||||||
|
for (int i5 = 31; i5 >= 0; i5--) {
|
||||||
|
for (int j4 = 31; j4 >= 0; j4--)
|
||||||
|
if (enabledSprite.getMyPixels()[i5 + j4 * 32] == 0)
|
||||||
|
if (i5 > 0 && enabledSprite.getMyPixels()[(i5 - 1) + j4 * 32] > 1)
|
||||||
|
enabledSprite.getMyPixels()[i5 + j4 * 32] = 1;
|
||||||
|
else if (j4 > 0 && enabledSprite.getMyPixels()[i5 + (j4 - 1) * 32] > 1)
|
||||||
|
enabledSprite.getMyPixels()[i5 + j4 * 32] = 1;
|
||||||
|
else if (i5 < 31 && enabledSprite.getMyPixels()[i5 + 1 + j4 * 32] > 1)
|
||||||
|
enabledSprite.getMyPixels()[i5 + j4 * 32] = 1;
|
||||||
|
else if (j4 < 31 && enabledSprite.getMyPixels()[i5 + (j4 + 1) * 32] > 1)
|
||||||
|
enabledSprite.getMyPixels()[i5 + j4 * 32] = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outlineColor > 0) {
|
||||||
|
for (int j5 = 31; j5 >= 0; j5--) {
|
||||||
|
for (int k4 = 31; k4 >= 0; k4--)
|
||||||
|
if (enabledSprite.getMyPixels()[j5 + k4 * 32] == 0)
|
||||||
|
if (j5 > 0 && enabledSprite.getMyPixels()[(j5 - 1) + k4 * 32] == 1)
|
||||||
|
enabledSprite.getMyPixels()[j5 + k4 * 32] = outlineColor;
|
||||||
|
else if (k4 > 0 && enabledSprite.getMyPixels()[j5 + (k4 - 1) * 32] == 1)
|
||||||
|
enabledSprite.getMyPixels()[j5 + k4 * 32] = outlineColor;
|
||||||
|
else if (j5 < 31 && enabledSprite.getMyPixels()[j5 + 1 + k4 * 32] == 1)
|
||||||
|
enabledSprite.getMyPixels()[j5 + k4 * 32] = outlineColor;
|
||||||
|
else if (k4 < 31 && enabledSprite.getMyPixels()[j5 + (k4 + 1) * 32] == 1)
|
||||||
|
enabledSprite.getMyPixels()[j5 + k4 * 32] = outlineColor;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (outlineColor == 0) {
|
||||||
|
for (int k5 = 31; k5 >= 0; k5--) {
|
||||||
|
for (int l4 = 31; l4 >= 0; l4--)
|
||||||
|
if (enabledSprite.getMyPixels()[k5 + l4 * 32] == 0 && k5 > 0 && l4 > 0
|
||||||
|
&& enabledSprite.getMyPixels()[(k5 - 1) + (l4 - 1) * 32] > 0)
|
||||||
|
enabledSprite.getMyPixels()[k5 + l4 * 32] = 0x302020;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (itemDef.notedItemId != -1) {
|
||||||
|
int old_w = sprite.getMaxWidth();
|
||||||
|
int old_h = sprite.getMaxHeight();
|
||||||
|
sprite.setMaxWidth(32);
|
||||||
|
sprite.setMaxHeight(32);
|
||||||
|
sprite.drawSprite(0, 0);
|
||||||
|
sprite.setMaxWidth(old_w);
|
||||||
|
sprite.setMaxHeight(old_h);
|
||||||
|
}
|
||||||
|
if (outlineColor == 0)
|
||||||
|
sprites.put(enabledSprite, itemId);
|
||||||
|
Rasterizer2D.initDrawingArea(height, width, pixels, depthBuffer);
|
||||||
|
Rasterizer2D.setDrawingArea(vp_bottom, vp_left, vp_right, vp_top);
|
||||||
|
Rasterizer3D.originViewX = centerX;
|
||||||
|
Rasterizer3D.originViewY = centerY;
|
||||||
|
Rasterizer3D.scanOffsets = lineOffsets;
|
||||||
|
Rasterizer3D.aBoolean1464 = true;
|
||||||
|
if (itemDef.stackable)
|
||||||
|
enabledSprite.setMaxWidth(33);
|
||||||
|
else
|
||||||
|
enabledSprite.setMaxWidth(32);
|
||||||
|
enabledSprite.setMaxHeight(stackSize);
|
||||||
|
return enabledSprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getModel(int stack_size) {
|
||||||
|
if (stackVariantId != null && stack_size > 1) {
|
||||||
|
int stack_item_id = -1;
|
||||||
|
for (int k = 0; k < 10; k++)
|
||||||
|
if (stack_size >= stackVariantSize[k] && stackVariantSize[k] != 0)
|
||||||
|
stack_item_id = stackVariantId[k];
|
||||||
|
|
||||||
|
if (stack_item_id != -1)
|
||||||
|
return lookup(stack_item_id).getModel(1);
|
||||||
|
}
|
||||||
|
Model model = (Model) models.get(id);
|
||||||
|
if (model != null)
|
||||||
|
return model;
|
||||||
|
model = Model.getModel(inventoryModel);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
if (modelScaleX != 128 || modelScaleY != 128 || modelScaleZ != 128)
|
||||||
|
model.scale(modelScaleX, modelScaleZ, modelScaleY);
|
||||||
|
if (modifiedModelColors != null) {
|
||||||
|
for (int l = 0; l < modifiedModelColors.length; l++)
|
||||||
|
model.recolor(modifiedModelColors[l], originalModelColors[l]);
|
||||||
|
|
||||||
|
}
|
||||||
|
model.light(64 + lightIntensity, 768 + lightMag, -50, -10, -50, true);
|
||||||
|
model.fits_on_single_square = true;
|
||||||
|
models.put(model, id);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getUnshadedModel(int stack_size) {
|
||||||
|
if (stackVariantId != null && stack_size > 1) {
|
||||||
|
int stack_item_id = -1;
|
||||||
|
for (int count = 0; count < 10; count++)
|
||||||
|
if (stack_size >= stackVariantSize[count] && stackVariantSize[count] != 0)
|
||||||
|
stack_item_id = stackVariantId[count];
|
||||||
|
|
||||||
|
if (stack_item_id != -1)
|
||||||
|
return lookup(stack_item_id).getUnshadedModel(1);
|
||||||
|
}
|
||||||
|
Model model = Model.getModel(inventoryModel);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
if (modifiedModelColors != null) {
|
||||||
|
for (int colorPtr = 0; colorPtr < modifiedModelColors.length; colorPtr++)
|
||||||
|
model.recolor(modifiedModelColors[colorPtr], originalModelColors[colorPtr]);
|
||||||
|
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
models = null;
|
||||||
|
sprites = null;
|
||||||
|
streamIndices = null;
|
||||||
|
cache = null;
|
||||||
|
dataBuf = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDialogueModelCached(int gender) {
|
||||||
|
int model_1 = equippedMaleModelDialogue1;
|
||||||
|
int model_2 = equippedMaleModelDialogue2;
|
||||||
|
if (gender == 1) {
|
||||||
|
model_1 = equippedFemaleModelDialogue1;
|
||||||
|
model_2 = equippedFemaleModelDialogue2;
|
||||||
|
}
|
||||||
|
if (model_1 == -1)
|
||||||
|
return true;
|
||||||
|
boolean cached = true;
|
||||||
|
if (!Model.isCached(model_1))
|
||||||
|
cached = false;
|
||||||
|
if (model_2 != -1 && !Model.isCached(model_2))
|
||||||
|
cached = false;
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemDefinition() {
|
||||||
|
id = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte equippedFemaleModelTranslationY;
|
||||||
|
public int value;
|
||||||
|
public int[] modifiedModelColors;
|
||||||
|
public int id;
|
||||||
|
public static ReferenceCache sprites = new ReferenceCache(100);
|
||||||
|
public static ReferenceCache models = new ReferenceCache(50);
|
||||||
|
public int[] originalModelColors;
|
||||||
|
public boolean members;
|
||||||
|
private int equippedFemaleModel3;
|
||||||
|
private int notedItemId;
|
||||||
|
public int equippedFemaleModel2;
|
||||||
|
public int equippedMaleModel1;
|
||||||
|
private int equippedMaleModelDialogue2;
|
||||||
|
private int modelScaleX;
|
||||||
|
public String groundActions[];
|
||||||
|
public int translateX;
|
||||||
|
public String name;
|
||||||
|
private static ItemDefinition[] cache;
|
||||||
|
private int equippedFemaleModelDialogue2;
|
||||||
|
public int inventoryModel;
|
||||||
|
public int equippedMaleModelDialogue1;
|
||||||
|
public boolean stackable;
|
||||||
|
public String description;
|
||||||
|
public int unnotedItemId;
|
||||||
|
private static int cacheIndex;
|
||||||
|
public int modelZoom;
|
||||||
|
public static boolean isMembers = true;
|
||||||
|
private static Buffer dataBuf;
|
||||||
|
private int lightMag;
|
||||||
|
private int equippedMaleModel3;
|
||||||
|
public int equippedMaleModel2;
|
||||||
|
public String actions[];
|
||||||
|
public int rotationY;
|
||||||
|
private int modelScaleZ;
|
||||||
|
private int modelScaleY;
|
||||||
|
public int[] stackVariantId;
|
||||||
|
public int translateYZ;//
|
||||||
|
private static int[] streamIndices;
|
||||||
|
private int lightIntensity;
|
||||||
|
public int equippedFemaleModelDialogue1;
|
||||||
|
public int rotationX;
|
||||||
|
public int equippedFemaleModel1;
|
||||||
|
public int[] stackVariantSize;
|
||||||
|
public int team;
|
||||||
|
public static int itemCount;
|
||||||
|
public int rotationZ;
|
||||||
|
private byte equippedMaleModelTranslationY;
|
||||||
|
}
|
||||||
@@ -0,0 +1,544 @@
|
|||||||
|
package org.rebotted.cache.def;
|
||||||
|
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.cache.anim.Frame;
|
||||||
|
import org.rebotted.cache.config.Varbit;
|
||||||
|
import org.rebotted.collection.ReferenceCache;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refactored reference:
|
||||||
|
* http://www.rune-server.org/runescape-development/rs2-client/downloads/575183-almost-fully-refactored-317-client.html
|
||||||
|
*/
|
||||||
|
public final class NpcDefinition {
|
||||||
|
|
||||||
|
public int turn90CCWAnimIndex;
|
||||||
|
public static int anInt56;
|
||||||
|
public int varBitID;
|
||||||
|
public int turn180AnimIndex;
|
||||||
|
public int settingId;
|
||||||
|
public static Buffer dataBuf;
|
||||||
|
public int combatLevel;
|
||||||
|
public final int anInt64;
|
||||||
|
public String name;
|
||||||
|
public String actions[];
|
||||||
|
public int walkAnim;
|
||||||
|
public byte size;
|
||||||
|
public int[] recolourTarget;
|
||||||
|
public static int[] offsets;
|
||||||
|
public int[] aditionalModels;
|
||||||
|
public int headIcon;
|
||||||
|
public int[] recolourOriginal;
|
||||||
|
public int standAnim;
|
||||||
|
public long interfaceType;
|
||||||
|
public int degreesToTurn;
|
||||||
|
public static NpcDefinition[] cache;
|
||||||
|
public static Client clientInstance;
|
||||||
|
public int turn90CWAnimIndex;
|
||||||
|
public boolean clickable;
|
||||||
|
public int lightModifier;
|
||||||
|
public int scaleY;
|
||||||
|
public boolean drawMinimapDot;
|
||||||
|
public int childrenIDs[];
|
||||||
|
public byte description[];
|
||||||
|
public int scaleXZ;
|
||||||
|
public int shadowModifier;
|
||||||
|
public boolean priorityRender;
|
||||||
|
public int[] modelId;
|
||||||
|
public static ReferenceCache modelCache = new ReferenceCache(30);
|
||||||
|
|
||||||
|
public int id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lookup an NpcDefinition by its id
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
public static NpcDefinition lookup(int id) {
|
||||||
|
for (int index = 0; index < 20; index++)
|
||||||
|
if (cache[index].interfaceType == (long) id)
|
||||||
|
return cache[index];
|
||||||
|
|
||||||
|
anInt56 = (anInt56 + 1) % 20;
|
||||||
|
NpcDefinition definition = cache[anInt56] = new NpcDefinition();
|
||||||
|
dataBuf.currentPosition = offsets[id];
|
||||||
|
definition.interfaceType = id;
|
||||||
|
definition.id = id;
|
||||||
|
definition.readValues(dataBuf);
|
||||||
|
switch(id) {
|
||||||
|
//Pets
|
||||||
|
case 495: //Venenatis pet
|
||||||
|
case 2055: //Chaos ele pet
|
||||||
|
case 5536: //Vetion pet
|
||||||
|
case 5537: //Vetion pet
|
||||||
|
case 497: //Callisto pet
|
||||||
|
case 5561: //Scorpia pet
|
||||||
|
case 6626:
|
||||||
|
case 6627:
|
||||||
|
case 6628:
|
||||||
|
case 6629:
|
||||||
|
case 6630:
|
||||||
|
case 6631:
|
||||||
|
case 6632:
|
||||||
|
case 6633:
|
||||||
|
case 6634:
|
||||||
|
case 6635:
|
||||||
|
definition.actions = new String[] {"Pick-up", null, null, null, null, null, null};
|
||||||
|
|
||||||
|
//Fix "slide" anim issue
|
||||||
|
definition.fixSlide();
|
||||||
|
|
||||||
|
//Callisto size adjust
|
||||||
|
if(id == 497) {
|
||||||
|
definition.scaleXZ = 45;
|
||||||
|
definition.size = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2054:
|
||||||
|
case 6504:
|
||||||
|
case 6609:
|
||||||
|
//Fix "slide" anim issue
|
||||||
|
definition.fixSlide();
|
||||||
|
|
||||||
|
//Callisto size adjust
|
||||||
|
if(id == 6609) {
|
||||||
|
definition.size = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 995:
|
||||||
|
definition.recolourOriginal = new int[2];
|
||||||
|
definition.recolourTarget = new int[2];
|
||||||
|
definition.recolourOriginal[0] = 528;
|
||||||
|
definition.recolourTarget[0] = 926;
|
||||||
|
break;
|
||||||
|
case 7456:
|
||||||
|
definition.actions = new String[] {"Repairs", null, null, null, null, null, null};
|
||||||
|
break;
|
||||||
|
case 1274:
|
||||||
|
definition.combatLevel = 35;
|
||||||
|
break;
|
||||||
|
case 2660:
|
||||||
|
definition.combatLevel = 0;
|
||||||
|
definition.actions = new String[] {"Trade", null, null, null, null, null, null};
|
||||||
|
definition.name = "Pker";
|
||||||
|
break;
|
||||||
|
case 6477:
|
||||||
|
definition.combatLevel = 210;
|
||||||
|
break;
|
||||||
|
case 6471:
|
||||||
|
definition.combatLevel = 131;
|
||||||
|
break;
|
||||||
|
case 5816:
|
||||||
|
definition.combatLevel = 38;
|
||||||
|
break;
|
||||||
|
case 100:
|
||||||
|
definition.drawMinimapDot = true;
|
||||||
|
break;
|
||||||
|
case 1306:
|
||||||
|
definition.actions = new String[] {"Make-over", null, null, null, null, null, null};
|
||||||
|
break;
|
||||||
|
case 3309:
|
||||||
|
definition.name = "Mage";
|
||||||
|
definition.actions = new String[] {"Trade", null, "Equipment", "Runes", null, null, null};
|
||||||
|
break;
|
||||||
|
case 1158:
|
||||||
|
definition.name = "@or1@Maxed bot";
|
||||||
|
definition.combatLevel = 126;
|
||||||
|
definition.actions = new String[] {null, "Attack", null, null, null, null, null};
|
||||||
|
definition.modelId[5] = 268; //platelegs rune
|
||||||
|
definition.modelId[0] = 18954; //Str cape
|
||||||
|
definition.modelId[1] = 21873; //Head - neitznot
|
||||||
|
definition.modelId[8] = 15413; //Shield rune defender
|
||||||
|
definition.modelId[7] = 5409; // weapon whip
|
||||||
|
definition.modelId[4] = 13307; //Gloves barrows
|
||||||
|
definition.modelId[6] = 3704; // boots climbing
|
||||||
|
definition.modelId[9] = 290; //amulet glory
|
||||||
|
break;
|
||||||
|
case 1200:
|
||||||
|
definition.copy(lookup(1158));
|
||||||
|
definition.modelId[7] = 539; // weapon dds
|
||||||
|
break;
|
||||||
|
case 4096:
|
||||||
|
definition.name = "@or1@Archer bot";
|
||||||
|
definition.combatLevel = 90;
|
||||||
|
definition.actions = new String[] {null, "Attack", null, null, null, null, null};
|
||||||
|
definition.modelId[0] = 20423; //cape avas
|
||||||
|
definition.modelId[1] = 21873; //Head - neitznot
|
||||||
|
definition.modelId[7] = 31237; // weapon crossbow
|
||||||
|
definition.modelId[4] = 13307; //Gloves barrows
|
||||||
|
definition.modelId[6] = 3704; // boots climbing
|
||||||
|
definition.modelId[5] = 20139; //platelegs zammy hides
|
||||||
|
definition.modelId[2] = 20157; //platebody zammy hides
|
||||||
|
definition.standAnim = 7220;
|
||||||
|
definition.walkAnim = 7223;
|
||||||
|
definition.turn180AnimIndex = 7220;
|
||||||
|
definition.turn90CCWAnimIndex = 7220;
|
||||||
|
definition.turn90CWAnimIndex = 7220;
|
||||||
|
break;
|
||||||
|
case 1576:
|
||||||
|
definition.actions = new String[] {"Trade", null, "Equipment", "Ammunition", null, null, null};
|
||||||
|
break;
|
||||||
|
case 3343:
|
||||||
|
definition.actions = new String[] {"Trade", null, "Heal", null, null, null, null};
|
||||||
|
break;
|
||||||
|
case 506:
|
||||||
|
case 526:
|
||||||
|
definition.actions = new String[] {"Trade", null, null, null, null, null, null};
|
||||||
|
break;
|
||||||
|
case 315:
|
||||||
|
definition.actions = new String[] {"Talk-to", null, "Trade", "Sell Emblems", "Request Skull", null, null};
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copy(NpcDefinition copy) {
|
||||||
|
size = copy.size;
|
||||||
|
degreesToTurn = copy.degreesToTurn;
|
||||||
|
walkAnim = copy.walkAnim;
|
||||||
|
turn180AnimIndex = copy.turn180AnimIndex;
|
||||||
|
turn90CWAnimIndex = copy.turn90CWAnimIndex;
|
||||||
|
turn90CCWAnimIndex = copy.turn90CCWAnimIndex;
|
||||||
|
varBitID = copy.varBitID;
|
||||||
|
settingId = copy.settingId;
|
||||||
|
combatLevel = copy.combatLevel;
|
||||||
|
name = copy.name;
|
||||||
|
description = copy.description;
|
||||||
|
headIcon = copy.headIcon;
|
||||||
|
clickable = copy.clickable;
|
||||||
|
lightModifier = copy.lightModifier;
|
||||||
|
scaleY = copy.scaleY;
|
||||||
|
scaleXZ = copy.scaleXZ;
|
||||||
|
drawMinimapDot = copy.drawMinimapDot;
|
||||||
|
shadowModifier = copy.shadowModifier;
|
||||||
|
actions = new String[copy.actions.length];
|
||||||
|
for(int i = 0; i < actions.length; i++) {
|
||||||
|
actions[i] = copy.actions[i];
|
||||||
|
}
|
||||||
|
modelId = new int[copy.modelId.length];
|
||||||
|
for(int i = 0; i < modelId.length; i++) {
|
||||||
|
modelId[i] = copy.modelId[i];
|
||||||
|
}
|
||||||
|
priorityRender = copy.priorityRender;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixSlide() {
|
||||||
|
//Fix "slide" anim issue
|
||||||
|
turn180AnimIndex = walkAnim;
|
||||||
|
turn90CCWAnimIndex = walkAnim;
|
||||||
|
turn90CWAnimIndex = walkAnim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model model() {
|
||||||
|
if (childrenIDs != null) {
|
||||||
|
NpcDefinition entityDef = morph();
|
||||||
|
if (entityDef == null)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return entityDef.model();
|
||||||
|
}
|
||||||
|
if (aditionalModels == null)
|
||||||
|
return null;
|
||||||
|
boolean flag1 = false;
|
||||||
|
for (int index = 0; index < aditionalModels.length; index++)
|
||||||
|
if (!Model.isCached(aditionalModels[index]))
|
||||||
|
flag1 = true;
|
||||||
|
|
||||||
|
if (flag1)
|
||||||
|
return null;
|
||||||
|
Model models[] = new Model[aditionalModels.length];
|
||||||
|
for (int index = 0; index < aditionalModels.length; index++)
|
||||||
|
models[index] = Model.getModel(aditionalModels[index]);
|
||||||
|
|
||||||
|
Model model;
|
||||||
|
if (models.length == 1)
|
||||||
|
model = models[0];
|
||||||
|
else
|
||||||
|
model = new Model(models.length, models);
|
||||||
|
if (recolourOriginal != null) {
|
||||||
|
for (int index = 0; index < recolourOriginal.length; index++)
|
||||||
|
model.recolor(recolourOriginal[index], recolourTarget[index]);
|
||||||
|
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NpcDefinition morph() {
|
||||||
|
int child = -1;
|
||||||
|
if (varBitID != -1) {
|
||||||
|
Varbit varBit = Varbit.varbits[varBitID];
|
||||||
|
int variable = varBit.getSetting();
|
||||||
|
int low = varBit.getLow();
|
||||||
|
int high = varBit.getHigh();
|
||||||
|
int mask = Client.BIT_MASKS[high - low];
|
||||||
|
child = clientInstance.settings[variable] >> low & mask;
|
||||||
|
} else if (settingId != -1)
|
||||||
|
child = clientInstance.settings[settingId];
|
||||||
|
if (child < 0 || child >= childrenIDs.length
|
||||||
|
|| childrenIDs[child] == -1)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return lookup(childrenIDs[child]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(FileArchive archive) {
|
||||||
|
dataBuf = new Buffer(archive.readFile("npc.dat"));
|
||||||
|
Buffer idxBuf = new Buffer(archive.readFile("npc.idx"));
|
||||||
|
|
||||||
|
int size = idxBuf.readUShort();
|
||||||
|
|
||||||
|
offsets = new int[size];
|
||||||
|
|
||||||
|
int offset = 2;
|
||||||
|
|
||||||
|
for (int count = 0; count < size; count++) {
|
||||||
|
offsets[count] = offset;
|
||||||
|
offset += idxBuf.readUShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
cache = new NpcDefinition[20];
|
||||||
|
|
||||||
|
for (int count = 0; count < 20; count++) {
|
||||||
|
cache[count] = new NpcDefinition();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Loaded: " + size + " Npcs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
modelCache = null;
|
||||||
|
offsets = null;
|
||||||
|
cache = null;
|
||||||
|
dataBuf = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model method164(int j, int somethingCurrentAnimsFrameNumber, int ai[], int nextFrame, int idk,
|
||||||
|
int idk2) {
|
||||||
|
if (childrenIDs != null) {
|
||||||
|
NpcDefinition entityDef = morph();
|
||||||
|
if (entityDef == null)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return entityDef.method164(j, somethingCurrentAnimsFrameNumber, ai, nextFrame, idk, idk2);
|
||||||
|
}
|
||||||
|
Model model = (Model) modelCache.get(interfaceType);
|
||||||
|
if (model == null) {
|
||||||
|
boolean flag = false;
|
||||||
|
for (int i1 = 0; i1 < modelId.length; i1++)
|
||||||
|
if (!Model.isCached(modelId[i1]))
|
||||||
|
flag = true;
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
return null;
|
||||||
|
Model models[] = new Model[modelId.length];
|
||||||
|
for (int j1 = 0; j1 < modelId.length; j1++)
|
||||||
|
models[j1] = Model.getModel(modelId[j1]);
|
||||||
|
|
||||||
|
if (models.length == 1)
|
||||||
|
model = models[0];
|
||||||
|
else
|
||||||
|
model = new Model(models.length, models);
|
||||||
|
if (recolourOriginal != null) {
|
||||||
|
for (int k1 = 0; k1 < recolourOriginal.length; k1++)
|
||||||
|
model.recolor(recolourOriginal[k1], recolourTarget[k1]);
|
||||||
|
|
||||||
|
}
|
||||||
|
model.skin();
|
||||||
|
model.scale(132, 132, 132);
|
||||||
|
model.light(84 + lightModifier, 1000 + shadowModifier, -90, -580,
|
||||||
|
-90, true);
|
||||||
|
modelCache.put(model, interfaceType);
|
||||||
|
}
|
||||||
|
Model empty = Model.EMPTY_MODEL;
|
||||||
|
empty.method464(model,
|
||||||
|
Frame.noAnimationInProgress(somethingCurrentAnimsFrameNumber) & Frame.noAnimationInProgress(j)
|
||||||
|
& Frame.noAnimationInProgress(nextFrame));
|
||||||
|
if (somethingCurrentAnimsFrameNumber != -1 && j != -1)
|
||||||
|
empty.applyAnimationFrames(ai, j, somethingCurrentAnimsFrameNumber);
|
||||||
|
else if (somethingCurrentAnimsFrameNumber != -1 && nextFrame != -1)
|
||||||
|
empty.applyAnimationFrame(somethingCurrentAnimsFrameNumber, nextFrame, idk, idk2);
|
||||||
|
else if (somethingCurrentAnimsFrameNumber != -1)
|
||||||
|
empty.applyTransform(somethingCurrentAnimsFrameNumber);
|
||||||
|
if (scaleXZ != 128 || scaleY != 128)
|
||||||
|
empty.scale(scaleXZ, scaleXZ, scaleY);
|
||||||
|
empty.calculateDistances();
|
||||||
|
empty.faceGroups = null;
|
||||||
|
empty.vertexGroups = null;
|
||||||
|
if (size == 1)
|
||||||
|
empty.fits_on_single_square = true;
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getAnimatedModel(int primaryFrame, int secondaryFrame,
|
||||||
|
int interleaveOrder[]) {
|
||||||
|
if (childrenIDs != null) {
|
||||||
|
NpcDefinition definition = morph();
|
||||||
|
if (definition == null)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return definition.getAnimatedModel(primaryFrame,
|
||||||
|
secondaryFrame, interleaveOrder);
|
||||||
|
}
|
||||||
|
Model model = (Model) modelCache.get(interfaceType);
|
||||||
|
if (model == null) {
|
||||||
|
boolean flag = false;
|
||||||
|
for (int index = 0; index < modelId.length; index++)
|
||||||
|
if (!Model.isCached(modelId[index]))
|
||||||
|
flag = true;
|
||||||
|
if (flag) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Model models[] = new Model[modelId.length];
|
||||||
|
for (int index = 0; index < modelId.length; index++)
|
||||||
|
models[index] = Model.getModel(modelId[index]);
|
||||||
|
|
||||||
|
if (models.length == 1)
|
||||||
|
model = models[0];
|
||||||
|
else
|
||||||
|
model = new Model(models.length, models);
|
||||||
|
if (recolourOriginal != null) {
|
||||||
|
for (int index = 0; index < recolourOriginal.length; index++)
|
||||||
|
model.recolor(recolourOriginal[index],
|
||||||
|
recolourTarget[index]);
|
||||||
|
|
||||||
|
}
|
||||||
|
model.skin();
|
||||||
|
model.light(64 + lightModifier, 850 + shadowModifier, -30, -50,
|
||||||
|
-30, true);
|
||||||
|
modelCache.put(model, interfaceType);
|
||||||
|
}
|
||||||
|
Model model_1 = Model.EMPTY_MODEL;
|
||||||
|
model_1.method464(model, Frame.noAnimationInProgress(secondaryFrame)
|
||||||
|
& Frame.noAnimationInProgress(primaryFrame));
|
||||||
|
if (secondaryFrame != -1 && primaryFrame != -1)
|
||||||
|
model_1.applyAnimationFrames(interleaveOrder, primaryFrame, secondaryFrame);
|
||||||
|
else if (secondaryFrame != -1)
|
||||||
|
model_1.applyTransform(secondaryFrame);
|
||||||
|
if (scaleXZ != 128 || scaleY != 128)
|
||||||
|
model_1.scale(scaleXZ, scaleXZ, scaleY);
|
||||||
|
model_1.calculateDistances();
|
||||||
|
model_1.faceGroups = null;
|
||||||
|
model_1.vertexGroups = null;
|
||||||
|
if (size == 1)
|
||||||
|
model_1.fits_on_single_square = true;
|
||||||
|
return model_1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readValues(Buffer stream) {
|
||||||
|
do {
|
||||||
|
int opcode = stream.readUnsignedByte();
|
||||||
|
|
||||||
|
if (opcode == 0)
|
||||||
|
return;
|
||||||
|
if (opcode == 1) {
|
||||||
|
int j = stream.readUnsignedByte();
|
||||||
|
modelId = new int[j];
|
||||||
|
for (int j1 = 0; j1 < j; j1++)
|
||||||
|
modelId[j1] = stream.readUShort();
|
||||||
|
|
||||||
|
} else if (opcode == 2)
|
||||||
|
name = stream.readString();
|
||||||
|
else if (opcode == 3)
|
||||||
|
description = stream.readBytes();
|
||||||
|
else if (opcode == 12)
|
||||||
|
size = stream.readSignedByte();
|
||||||
|
else if (opcode == 13)
|
||||||
|
standAnim = stream.readUShort();
|
||||||
|
else if (opcode == 14)
|
||||||
|
walkAnim = stream.readUShort();
|
||||||
|
else if (opcode == 17) {
|
||||||
|
walkAnim = stream.readUShort();
|
||||||
|
turn180AnimIndex = stream.readUShort();
|
||||||
|
turn90CWAnimIndex = stream.readUShort();
|
||||||
|
turn90CCWAnimIndex = stream.readUShort();
|
||||||
|
} else if (opcode >= 30 && opcode < 40) {
|
||||||
|
if (actions == null)
|
||||||
|
actions = new String[5];
|
||||||
|
actions[opcode - 30] = stream.readString();
|
||||||
|
if (actions[opcode - 30].equalsIgnoreCase("hidden"))
|
||||||
|
actions[opcode - 30] = null;
|
||||||
|
} else if (opcode == 40) {
|
||||||
|
int colours = stream.readUnsignedByte();
|
||||||
|
recolourOriginal = new int[colours];
|
||||||
|
recolourTarget = new int[colours];
|
||||||
|
for (int k1 = 0; k1 < colours; k1++) {
|
||||||
|
recolourOriginal[k1] = stream.readUShort();
|
||||||
|
recolourTarget[k1] = stream.readUShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (opcode == 60) {
|
||||||
|
int additionalModelLen = stream.readUnsignedByte();
|
||||||
|
aditionalModels = new int[additionalModelLen];
|
||||||
|
for (int l1 = 0; l1 < additionalModelLen; l1++)
|
||||||
|
aditionalModels[l1] = stream.readUShort();
|
||||||
|
|
||||||
|
} else if (opcode == 90)
|
||||||
|
stream.readUShort();
|
||||||
|
else if (opcode == 91)
|
||||||
|
stream.readUShort();
|
||||||
|
else if (opcode == 92)
|
||||||
|
stream.readUShort();
|
||||||
|
else if (opcode == 93)
|
||||||
|
drawMinimapDot = false;
|
||||||
|
else if (opcode == 95)
|
||||||
|
combatLevel = stream.readUShort();
|
||||||
|
else if (opcode == 97)
|
||||||
|
scaleXZ = stream.readUShort();
|
||||||
|
else if (opcode == 98)
|
||||||
|
scaleY = stream.readUShort();
|
||||||
|
else if (opcode == 99)
|
||||||
|
priorityRender = true;
|
||||||
|
else if (opcode == 100)
|
||||||
|
lightModifier = stream.readSignedByte();
|
||||||
|
else if (opcode == 101)
|
||||||
|
shadowModifier = stream.readSignedByte() * 5;
|
||||||
|
else if (opcode == 102)
|
||||||
|
headIcon = stream.readUShort();
|
||||||
|
else if (opcode == 103)
|
||||||
|
degreesToTurn = stream.readUShort();
|
||||||
|
else if (opcode == 106) {
|
||||||
|
varBitID = stream.readUShort();
|
||||||
|
if (varBitID == 65535)
|
||||||
|
varBitID = -1;
|
||||||
|
settingId = stream.readUShort();
|
||||||
|
if (settingId == 65535)
|
||||||
|
settingId = -1;
|
||||||
|
int childCount = stream.readUnsignedByte();
|
||||||
|
childrenIDs = new int[childCount + 1];
|
||||||
|
for (int i2 = 0; i2 <= childCount; i2++) {
|
||||||
|
childrenIDs[i2] = stream.readUShort();
|
||||||
|
if (childrenIDs[i2] == 65535)
|
||||||
|
childrenIDs[i2] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (opcode == 107)
|
||||||
|
clickable = false;
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NpcDefinition() {
|
||||||
|
turn90CCWAnimIndex = -1;
|
||||||
|
varBitID = -1;
|
||||||
|
turn180AnimIndex = -1;
|
||||||
|
settingId = -1;
|
||||||
|
combatLevel = -1;
|
||||||
|
anInt64 = 1834;
|
||||||
|
walkAnim = -1;
|
||||||
|
size = 1;
|
||||||
|
headIcon = -1;
|
||||||
|
standAnim = -1;
|
||||||
|
interfaceType = -1L;
|
||||||
|
degreesToTurn = 32;
|
||||||
|
turn90CWAnimIndex = -1;
|
||||||
|
clickable = true;
|
||||||
|
scaleY = 128;
|
||||||
|
drawMinimapDot = true;
|
||||||
|
scaleXZ = 128;
|
||||||
|
priorityRender = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,505 @@
|
|||||||
|
package org.rebotted.cache.def;
|
||||||
|
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.cache.anim.Frame;
|
||||||
|
import org.rebotted.cache.config.Varbit;
|
||||||
|
import org.rebotted.collection.ReferenceCache;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
import org.rebotted.net.requester.ResourceProvider;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public final class ObjectDefBack {
|
||||||
|
|
||||||
|
public static final Model[] aModelArray741s = new Model[4];
|
||||||
|
public static boolean lowMemory;
|
||||||
|
public static Buffer dataBuf;
|
||||||
|
public static int[] streamIndices;
|
||||||
|
public static Client clientInstance;
|
||||||
|
public static int cacheIndex;
|
||||||
|
public static ReferenceCache models = new ReferenceCache(30);
|
||||||
|
public static ObjectDefinition[] cache;
|
||||||
|
public static ReferenceCache baseModels = new ReferenceCache(500);
|
||||||
|
private static int totalObjects;
|
||||||
|
public boolean obstructsGround;
|
||||||
|
public byte ambientLighting;
|
||||||
|
public int translateX;
|
||||||
|
public String name;
|
||||||
|
public int scaleZ;
|
||||||
|
public byte lightDiffusion;
|
||||||
|
public int objectSizeX;
|
||||||
|
public int translateY;
|
||||||
|
public int minimapFunction;
|
||||||
|
public int[] originalModelColors;
|
||||||
|
public int scaleX;
|
||||||
|
public int varp;
|
||||||
|
public boolean inverted;
|
||||||
|
public int type;
|
||||||
|
public boolean impenetrable;
|
||||||
|
public int mapscene;
|
||||||
|
public int[] childrenIDs;
|
||||||
|
public int supportItems;
|
||||||
|
public int objectSizeY;
|
||||||
|
public boolean contouredGround;
|
||||||
|
public boolean occludes;
|
||||||
|
public boolean hollow;
|
||||||
|
public boolean solid;
|
||||||
|
public int surroundings;
|
||||||
|
public boolean delayShading;
|
||||||
|
public int scaleY;
|
||||||
|
public int[] modelIds;
|
||||||
|
public int varbit;
|
||||||
|
public int decorDisplacement;
|
||||||
|
public int[] modelTypes;
|
||||||
|
public byte[] description;
|
||||||
|
public boolean isInteractive;
|
||||||
|
public boolean castsShadow;
|
||||||
|
public int animation;
|
||||||
|
public int translateZ;
|
||||||
|
public int[] modifiedModelColors;
|
||||||
|
public String[] interactions;
|
||||||
|
private short[] originalTexture;
|
||||||
|
private short[] modifiedTexture;
|
||||||
|
|
||||||
|
|
||||||
|
public static void init(FileArchive streamLoader) throws IOException {
|
||||||
|
dataBuf = new Buffer(streamLoader.readFile("loc.dat"));
|
||||||
|
Buffer idxBuf = new Buffer(streamLoader.readFile("loc.idx"));
|
||||||
|
totalObjects = idxBuf.readUShort();
|
||||||
|
streamIndices = new int[totalObjects];
|
||||||
|
int offset = 2;
|
||||||
|
for (int index = 0; index < totalObjects; index++) {
|
||||||
|
streamIndices[index] = offset;
|
||||||
|
offset += idxBuf.readUShort();
|
||||||
|
}
|
||||||
|
cache = new ObjectDefinition[20];
|
||||||
|
for (int index = 0; index < 20; index++) {
|
||||||
|
cache[index] = new ObjectDefinition();
|
||||||
|
}
|
||||||
|
|
||||||
|
// for(int i = 0; i < totalObjects; i++) {
|
||||||
|
// ObjectDefinition def = ObjectDefinition.lookup(i);
|
||||||
|
//
|
||||||
|
// if (def == null || def.name == null) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// System.out.println(i + " " + def.name);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
System.out.println("Loaded: " + totalObjects + " Objects");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void dumpNames() throws Exception {
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter("./Cache/object_names.txt"));
|
||||||
|
for (int i = 0; i < totalObjects; i++) {
|
||||||
|
ObjectDefinition def = lookup(i);
|
||||||
|
String name = def == null ? "null" : def.name;
|
||||||
|
writer.write("ID: " + i + ", name: " + name + "");
|
||||||
|
writer.newLine();
|
||||||
|
}
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ObjectDefinition lookup(int id) {
|
||||||
|
if (id > streamIndices.length) {
|
||||||
|
id = streamIndices.length - 1;
|
||||||
|
}
|
||||||
|
for (int index = 0; index < 20; index++) {
|
||||||
|
if (cache[index].type == id) {
|
||||||
|
return cache[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheIndex = (cacheIndex + 1) % 20;
|
||||||
|
ObjectDefinition def = cache[cacheIndex];
|
||||||
|
dataBuf.currentPosition = streamIndices[id];
|
||||||
|
def.type = id;
|
||||||
|
def.reset();
|
||||||
|
//def.decode(dataBuf);
|
||||||
|
|
||||||
|
//Disable delayed shading.
|
||||||
|
//Cheap fix for: edgeville ditch, raids, wintertodt fire etc
|
||||||
|
//Fixes black square on the model
|
||||||
|
def.delayShading = false;
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
baseModels = null;
|
||||||
|
models = null;
|
||||||
|
streamIndices = null;
|
||||||
|
cache = null;
|
||||||
|
dataBuf = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decode(Buffer stream) {
|
||||||
|
while (true) {
|
||||||
|
int flag = -1;
|
||||||
|
|
||||||
|
int type = stream.readUnsignedByte();
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
break;
|
||||||
|
} else if (type == 1) {
|
||||||
|
int length = stream.readUnsignedByte();
|
||||||
|
if (length > 0) {
|
||||||
|
if (modelIds == null || lowMemory) {
|
||||||
|
modelTypes = new int[length];
|
||||||
|
modelIds = new int[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
modelIds[i] = stream.readUShort();
|
||||||
|
modelTypes[i] = stream.readUnsignedByte();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stream.currentPosition += length * 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (type == 2) {
|
||||||
|
name = stream.readString();
|
||||||
|
} else if (type == 3) {
|
||||||
|
description = stream.readBytes();
|
||||||
|
} else if (type == 5) {
|
||||||
|
int len = stream.readUnsignedByte();
|
||||||
|
if (len > 0) {
|
||||||
|
if (modelIds == null || lowMemory) {
|
||||||
|
modelTypes = null;
|
||||||
|
modelIds = new int[len];
|
||||||
|
for (int l1 = 0; l1 < len; l1++)
|
||||||
|
modelIds[l1] = stream.readUShort();
|
||||||
|
} else {
|
||||||
|
stream.currentPosition += len * 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (type == 14) {
|
||||||
|
objectSizeX = stream.readUnsignedByte();
|
||||||
|
} else if (type == 15) {
|
||||||
|
objectSizeY = stream.readUnsignedByte();
|
||||||
|
} else if (type == 17) {
|
||||||
|
solid = false;
|
||||||
|
} else if (type == 18) {
|
||||||
|
impenetrable = false;
|
||||||
|
} else if (type == 19) {
|
||||||
|
isInteractive = (stream.readUnsignedByte() == 1);
|
||||||
|
} else if (type == 21) {
|
||||||
|
contouredGround = true;
|
||||||
|
} else if (type == 22) {
|
||||||
|
delayShading = false;
|
||||||
|
} else if (type == 23) {
|
||||||
|
occludes = true;
|
||||||
|
} else if (type == 24) {
|
||||||
|
animation = stream.readUShort();
|
||||||
|
if (animation == 65535)
|
||||||
|
animation = -1;
|
||||||
|
} else if (type == 28) {
|
||||||
|
decorDisplacement = stream.readUnsignedByte();
|
||||||
|
} else if (type == 29) {
|
||||||
|
ambientLighting = stream.readSignedByte();
|
||||||
|
} else if (type == 39) {
|
||||||
|
lightDiffusion = stream.readSignedByte();
|
||||||
|
} else if (type >= 30 && type < 39) {
|
||||||
|
if (interactions == null) {
|
||||||
|
interactions = new String[5];
|
||||||
|
}
|
||||||
|
if(type - 30 < 6) {
|
||||||
|
interactions[type - 30] = stream.readString();
|
||||||
|
if (interactions[type - 30].equalsIgnoreCase("hidden")) {
|
||||||
|
interactions[type - 30] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (type == 40) {
|
||||||
|
int i1 = stream.readUnsignedByte();
|
||||||
|
modifiedModelColors = new int[i1];
|
||||||
|
originalModelColors = new int[i1];
|
||||||
|
for (int i2 = 0; i2 < i1; i2++) {
|
||||||
|
modifiedModelColors[i2] = stream.readUShort();
|
||||||
|
originalModelColors[i2] = stream.readUShort();
|
||||||
|
}
|
||||||
|
} else if (type == 60) {
|
||||||
|
minimapFunction = stream.readUShort();
|
||||||
|
} else if (type == 62) {
|
||||||
|
inverted = true;
|
||||||
|
} else if (type == 64) {
|
||||||
|
castsShadow = false;
|
||||||
|
} else if (type == 65) {
|
||||||
|
scaleX = stream.readUShort();
|
||||||
|
} else if (type == 66) {
|
||||||
|
scaleY = stream.readUShort();
|
||||||
|
} else if (type == 67) {
|
||||||
|
scaleZ = stream.readUShort();
|
||||||
|
} else if (type == 68) {
|
||||||
|
mapscene = stream.readUShort();
|
||||||
|
} else if (type == 69) {
|
||||||
|
surroundings = stream.readUnsignedByte();
|
||||||
|
} else if (type == 70) {
|
||||||
|
translateX = stream.readSignedWord();
|
||||||
|
} else if (type == 71) {
|
||||||
|
translateY = stream.readSignedWord();
|
||||||
|
} else if (type == 72) {
|
||||||
|
translateZ = stream.readSignedWord();
|
||||||
|
} else if (type == 73) {
|
||||||
|
obstructsGround = true;
|
||||||
|
} else if (type == 74) {
|
||||||
|
hollow = true;
|
||||||
|
} else if(type == 75) {
|
||||||
|
supportItems = dataBuf.readUnsignedByte();
|
||||||
|
} else if (type == 77) {
|
||||||
|
varp = stream.readUShort();
|
||||||
|
if (varp == 65535) {
|
||||||
|
varp = -1;
|
||||||
|
}
|
||||||
|
varbit = stream.readUShort();
|
||||||
|
if (varbit == 65535) {
|
||||||
|
varbit = -1;
|
||||||
|
}
|
||||||
|
int length = stream.readUnsignedByte();
|
||||||
|
childrenIDs = new int[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
childrenIDs[i] = stream.readUShort();
|
||||||
|
if (childrenIDs[i] == 65535) {
|
||||||
|
childrenIDs[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag == -1 && name != "null" && name != null) {
|
||||||
|
isInteractive = modelIds != null
|
||||||
|
&& (modelTypes == null || modelTypes[0] == 10);
|
||||||
|
if (interactions != null)
|
||||||
|
isInteractive = true;
|
||||||
|
}
|
||||||
|
if (hollow) {
|
||||||
|
solid = false;
|
||||||
|
impenetrable = false;
|
||||||
|
}
|
||||||
|
if (supportItems == -1)
|
||||||
|
supportItems = solid ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void reset() {
|
||||||
|
modelIds = null;
|
||||||
|
modelTypes = null;
|
||||||
|
name = null;
|
||||||
|
description = null;
|
||||||
|
modifiedModelColors = null;
|
||||||
|
originalModelColors = null;
|
||||||
|
objectSizeX = 1;
|
||||||
|
objectSizeY = 1;
|
||||||
|
solid = true;
|
||||||
|
impenetrable = true;
|
||||||
|
isInteractive = false;
|
||||||
|
contouredGround = false;
|
||||||
|
delayShading = false;
|
||||||
|
occludes = false;
|
||||||
|
animation = -1;
|
||||||
|
decorDisplacement = 16;
|
||||||
|
ambientLighting = 0;
|
||||||
|
lightDiffusion = 0;
|
||||||
|
interactions = null;
|
||||||
|
minimapFunction = -1;
|
||||||
|
mapscene = -1;
|
||||||
|
inverted = false;
|
||||||
|
castsShadow = true;
|
||||||
|
scaleX = 128;
|
||||||
|
scaleY = 128;
|
||||||
|
scaleZ = 128;
|
||||||
|
surroundings = 0;
|
||||||
|
translateX = 0;
|
||||||
|
translateY = 0;
|
||||||
|
translateZ = 0;
|
||||||
|
obstructsGround = false;
|
||||||
|
hollow = false;
|
||||||
|
supportItems = -1;
|
||||||
|
varbit = -1;
|
||||||
|
varp = -1;
|
||||||
|
childrenIDs = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadModels(ResourceProvider archive) {
|
||||||
|
if (modelIds == null)
|
||||||
|
return;
|
||||||
|
for (int index = 0; index < modelIds.length; index++)
|
||||||
|
archive.loadExtra(modelIds[index] & 0xffff, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean method577(int i) {
|
||||||
|
if (modelTypes == null) {
|
||||||
|
if (modelIds == null)
|
||||||
|
return true;
|
||||||
|
if (i != 10)
|
||||||
|
return true;
|
||||||
|
boolean flag1 = true;
|
||||||
|
for (int k = 0; k < modelIds.length; k++)
|
||||||
|
flag1 &= Model.isCached(modelIds[k] & 0xffff);
|
||||||
|
|
||||||
|
return flag1;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < modelTypes.length; j++)
|
||||||
|
if (modelTypes[j] == i)
|
||||||
|
return Model.isCached(modelIds[j] & 0xffff);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model modelAt(int type, int orientation, int aY, int bY, int cY, int dY, int frameId) {
|
||||||
|
Model model = model(type, frameId, orientation);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
if (contouredGround || delayShading)
|
||||||
|
model = new Model(contouredGround, delayShading, model);
|
||||||
|
if (contouredGround) {
|
||||||
|
int y = (aY + bY + cY + dY) / 4;
|
||||||
|
for (int vertex = 0; vertex < model.numVertices; vertex++) {
|
||||||
|
int x = model.vertexX[vertex];
|
||||||
|
int z = model.vertexZ[vertex];
|
||||||
|
int l2 = aY + ((bY - aY) * (x + 64)) / 128;
|
||||||
|
int i3 = dY + ((cY - dY) * (x + 64)) / 128;
|
||||||
|
int j3 = l2 + ((i3 - l2) * (z + 64)) / 128;
|
||||||
|
model.vertexY[vertex] += j3 - y;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.computeSphericalBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean method579() {
|
||||||
|
if (modelIds == null)
|
||||||
|
return true;
|
||||||
|
boolean flag1 = true;
|
||||||
|
for (int i = 0; i < modelIds.length; i++)
|
||||||
|
flag1 &= Model.isCached(modelIds[i] & 0xffff);
|
||||||
|
return flag1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectDefinition method580() {
|
||||||
|
int i = -1;
|
||||||
|
if (varbit != -1) {
|
||||||
|
Varbit varBit = Varbit.varbits[varbit];
|
||||||
|
int j = varBit.getSetting();
|
||||||
|
int k = varBit.getLow();
|
||||||
|
int l = varBit.getHigh();
|
||||||
|
int i1 = Client.BIT_MASKS[l - k];
|
||||||
|
i = clientInstance.settings[j] >> k & i1;
|
||||||
|
} else if (varp != -1)
|
||||||
|
i = clientInstance.settings[varp];
|
||||||
|
if (i < 0 || i >= childrenIDs.length || childrenIDs[i] == -1)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return lookup(childrenIDs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model model(int j, int k, int l) {
|
||||||
|
Model model = null;
|
||||||
|
long l1;
|
||||||
|
if (modelTypes == null) {
|
||||||
|
if (j != 10)
|
||||||
|
return null;
|
||||||
|
l1 = (long) ((type << 6) + l) + ((long) (k + 1) << 32);
|
||||||
|
Model model_1 = (Model) models.get(l1);
|
||||||
|
if (model_1 != null) {
|
||||||
|
return model_1;
|
||||||
|
}
|
||||||
|
if (modelIds == null)
|
||||||
|
return null;
|
||||||
|
boolean flag1 = inverted ^ (l > 3);
|
||||||
|
int k1 = modelIds.length;
|
||||||
|
for (int i2 = 0; i2 < k1; i2++) {
|
||||||
|
int l2 = modelIds[i2];
|
||||||
|
if (flag1)
|
||||||
|
l2 += 0x10000;
|
||||||
|
model = (Model) baseModels.get(l2);
|
||||||
|
if (model == null) {
|
||||||
|
model = Model.getModel(l2 & 0xffff);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
if (flag1)
|
||||||
|
model.method477();
|
||||||
|
baseModels.put(model, l2);
|
||||||
|
}
|
||||||
|
if (k1 > 1)
|
||||||
|
aModelArray741s[i2] = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k1 > 1)
|
||||||
|
model = new Model(k1, aModelArray741s);
|
||||||
|
} else {
|
||||||
|
int i1 = -1;
|
||||||
|
for (int j1 = 0; j1 < modelTypes.length; j1++) {
|
||||||
|
if (modelTypes[j1] != j)
|
||||||
|
continue;
|
||||||
|
i1 = j1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i1 == -1)
|
||||||
|
return null;
|
||||||
|
l1 = (long) ((type << 8) + (i1 << 3) + l) + ((long) (k + 1) << 32);
|
||||||
|
Model model_2 = (Model) models.get(l1);
|
||||||
|
if (model_2 != null) {
|
||||||
|
return model_2;
|
||||||
|
}
|
||||||
|
if (modelIds == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int j2 = modelIds[i1];
|
||||||
|
boolean flag3 = inverted ^ (l > 3);
|
||||||
|
if (flag3)
|
||||||
|
j2 += 0x10000;
|
||||||
|
model = (Model) baseModels.get(j2);
|
||||||
|
if (model == null) {
|
||||||
|
model = Model.getModel(j2 & 0xffff);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
if (flag3)
|
||||||
|
model.method477();
|
||||||
|
baseModels.put(model, j2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean flag;
|
||||||
|
flag = scaleX != 128 || scaleY != 128 || scaleZ != 128;
|
||||||
|
boolean flag2;
|
||||||
|
flag2 = translateX != 0 || translateY != 0 || translateZ != 0;
|
||||||
|
Model model_3 = new Model(modifiedModelColors == null,
|
||||||
|
Frame.noAnimationInProgress(k), l == 0 && k == -1 && !flag
|
||||||
|
&& !flag2, model);
|
||||||
|
if (k != -1) {
|
||||||
|
model_3.skin();
|
||||||
|
model_3.applyTransform(k);
|
||||||
|
model_3.faceGroups = null;
|
||||||
|
model_3.vertexGroups = null;
|
||||||
|
}
|
||||||
|
while (l-- > 0)
|
||||||
|
model_3.rotate90Degrees();
|
||||||
|
if (modifiedModelColors != null) {
|
||||||
|
for (int k2 = 0; k2 < modifiedModelColors.length; k2++)
|
||||||
|
model_3.recolor(modifiedModelColors[k2],
|
||||||
|
originalModelColors[k2]);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* if (modifiedTexture != null) {
|
||||||
|
for (int k2 = 0; k2 < modifiedTexture.length; k2++)
|
||||||
|
model_3.retexture(modifiedTexture[k2], originalTexture[k2],
|
||||||
|
-1);
|
||||||
|
}*/
|
||||||
|
if (flag)
|
||||||
|
model_3.scale(scaleX, scaleZ, scaleY);
|
||||||
|
if (flag2)
|
||||||
|
model_3.translate(translateX, translateY, translateZ);
|
||||||
|
// model_3.light(84, 1500, -90, -280, -70, !delayShading);
|
||||||
|
model_3.light(64 + ambientLighting, 1300 + (lightDiffusion * 5), -90, -280, -70, !delayShading);
|
||||||
|
if (supportItems == 1)
|
||||||
|
model_3.itemDropHeight = model_3.modelBaseY;
|
||||||
|
models.put(model_3, l1);
|
||||||
|
return model_3;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,523 @@
|
|||||||
|
package org.rebotted.cache.def;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.cache.anim.Frame;
|
||||||
|
import org.rebotted.cache.config.Varbit;
|
||||||
|
import org.rebotted.collection.ReferenceCache;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
import org.rebotted.net.requester.ResourceProvider;
|
||||||
|
|
||||||
|
public final class ObjectDefinition {
|
||||||
|
|
||||||
|
public static void init(FileArchive streamLoader) throws IOException {
|
||||||
|
dataBuf = new Buffer(streamLoader.readFile("loc.dat"));
|
||||||
|
Buffer idxBuf = new Buffer(streamLoader.readFile("loc.idx"));
|
||||||
|
totalObjects = idxBuf.readUShort();
|
||||||
|
streamIndices = new int[totalObjects];
|
||||||
|
int offset = 2;
|
||||||
|
for (int index = 0; index < totalObjects; index++) {
|
||||||
|
streamIndices[index] = offset;
|
||||||
|
offset += idxBuf.readUShort();
|
||||||
|
}
|
||||||
|
cache = new ObjectDefinition[20];
|
||||||
|
for (int index = 0; index < 20; index++) {
|
||||||
|
cache[index] = new ObjectDefinition();
|
||||||
|
}
|
||||||
|
|
||||||
|
// for(int i = 0; i < totalObjects; i++) {
|
||||||
|
// ObjectDefinition def = ObjectDefinition.lookup(i);
|
||||||
|
//
|
||||||
|
// if (def == null || def.name == null) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// System.out.println(i + " " + def.name);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
System.out.println("Loaded: " + totalObjects + " Objects");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decode(Buffer stream, int id) {
|
||||||
|
try {
|
||||||
|
while (true) {
|
||||||
|
int flag = -1;
|
||||||
|
|
||||||
|
int type = stream.readUnsignedByte();
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
break;
|
||||||
|
} else if (type == 1) {
|
||||||
|
int length = stream.readUnsignedByte();
|
||||||
|
if (length > 0) {
|
||||||
|
if (modelIds == null || lowMemory) {
|
||||||
|
modelTypes = new int[length];
|
||||||
|
modelIds = new int[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
modelIds[i] = stream.readUShort();
|
||||||
|
modelTypes[i] = stream.readUnsignedByte();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stream.currentPosition += length * 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (type == 2) {
|
||||||
|
name = stream.readString();
|
||||||
|
} else if (type == 3) {
|
||||||
|
description = stream.readBytes();
|
||||||
|
} else if (type == 5) {
|
||||||
|
int len = stream.readUnsignedByte();
|
||||||
|
if (len > 0) {
|
||||||
|
if (modelIds == null || lowMemory) {
|
||||||
|
modelTypes = null;
|
||||||
|
modelIds = new int[len];
|
||||||
|
for (int l1 = 0; l1 < len; l1++)
|
||||||
|
modelIds[l1] = stream.readUShort();
|
||||||
|
} else {
|
||||||
|
stream.currentPosition += len * 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (type == 14) {
|
||||||
|
objectSizeX = stream.readUnsignedByte();
|
||||||
|
} else if (type == 15) {
|
||||||
|
objectSizeY = stream.readUnsignedByte();
|
||||||
|
} else if (type == 17) {
|
||||||
|
solid = false;
|
||||||
|
} else if (type == 18) {
|
||||||
|
impenetrable = false;
|
||||||
|
} else if (type == 19) {
|
||||||
|
isInteractive = (stream.readUnsignedByte() == 1);
|
||||||
|
} else if (type == 21) {
|
||||||
|
contouredGround = true;
|
||||||
|
} else if (type == 22) {
|
||||||
|
delayShading = false;
|
||||||
|
} else if (type == 23) {
|
||||||
|
occludes = true;
|
||||||
|
} else if (type == 24) {
|
||||||
|
animation = stream.readUShort();
|
||||||
|
if (animation == 65535)
|
||||||
|
animation = -1;
|
||||||
|
} else if (type == 28) {
|
||||||
|
decorDisplacement = stream.readUnsignedByte();
|
||||||
|
} else if (type == 29) {
|
||||||
|
ambientLighting = stream.readSignedByte();
|
||||||
|
} else if (type == 39) {
|
||||||
|
lightDiffusion = stream.readSignedByte();
|
||||||
|
} else if (type >= 30 && type < 39) {
|
||||||
|
if (interactions == null) {
|
||||||
|
interactions = new String[5];
|
||||||
|
}
|
||||||
|
interactions[type - 30] = stream.readString();
|
||||||
|
if (interactions[type - 30].equalsIgnoreCase("hidden")) {
|
||||||
|
interactions[type - 30] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (type == 40) {
|
||||||
|
int i1 = stream.readUnsignedByte();
|
||||||
|
modifiedModelColors = new int[i1];
|
||||||
|
originalModelColors = new int[i1];
|
||||||
|
for (int i2 = 0; i2 < i1; i2++) {
|
||||||
|
modifiedModelColors[i2] = stream.readUShort();
|
||||||
|
originalModelColors[i2] = stream.readUShort();
|
||||||
|
}
|
||||||
|
} else if (type == 60) {
|
||||||
|
minimapFunction = stream.readUShort();
|
||||||
|
} else if (type == 62) {
|
||||||
|
inverted = true;
|
||||||
|
} else if (type == 64) {
|
||||||
|
castsShadow = false;
|
||||||
|
} else if (type == 65) {
|
||||||
|
scaleX = stream.readUShort();
|
||||||
|
} else if (type == 66) {
|
||||||
|
scaleY = stream.readUShort();
|
||||||
|
} else if (type == 67) {
|
||||||
|
scaleZ = stream.readUShort();
|
||||||
|
} else if (type == 68) {
|
||||||
|
mapscene = stream.readUShort();
|
||||||
|
} else if (type == 69) {
|
||||||
|
surroundings = stream.readUnsignedByte();
|
||||||
|
} else if (type == 70) {
|
||||||
|
translateX = stream.readSignedWord();
|
||||||
|
} else if (type == 71) {
|
||||||
|
translateY = stream.readSignedWord();
|
||||||
|
} else if (type == 72) {
|
||||||
|
translateZ = stream.readSignedWord();
|
||||||
|
} else if (type == 73) {
|
||||||
|
obstructsGround = true;
|
||||||
|
} else if (type == 74) {
|
||||||
|
hollow = true;
|
||||||
|
} else if (type == 75) {
|
||||||
|
supportItems = dataBuf.readUnsignedByte();
|
||||||
|
} else if (type == 77) {
|
||||||
|
varp = stream.readUShort();
|
||||||
|
if (varp == 65535) {
|
||||||
|
varp = -1;
|
||||||
|
}
|
||||||
|
varbit = stream.readUShort();
|
||||||
|
if (varbit == 65535) {
|
||||||
|
varbit = -1;
|
||||||
|
}
|
||||||
|
int length = stream.readUnsignedByte();
|
||||||
|
childrenIDs = new int[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
childrenIDs[i] = stream.readUShort();
|
||||||
|
if (childrenIDs[i] == 65535) {
|
||||||
|
childrenIDs[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag == -1 && name != "null" && name != null) {
|
||||||
|
isInteractive = modelIds != null
|
||||||
|
&& (modelTypes == null || modelTypes[0] == 10);
|
||||||
|
if (interactions != null)
|
||||||
|
isInteractive = true;
|
||||||
|
}
|
||||||
|
if (hollow) {
|
||||||
|
solid = false;
|
||||||
|
impenetrable = false;
|
||||||
|
}
|
||||||
|
if (supportItems == -1)
|
||||||
|
supportItems = solid ? 1 : 0;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("ERROR LOADING: "+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean obstructsGround;
|
||||||
|
public byte ambientLighting;
|
||||||
|
public int translateX;
|
||||||
|
public String name;
|
||||||
|
public int scaleZ;
|
||||||
|
public static final Model[] aModelArray741s = new Model[4];
|
||||||
|
public byte lightDiffusion;
|
||||||
|
public int objectSizeX;
|
||||||
|
public int translateY;
|
||||||
|
public int minimapFunction;
|
||||||
|
public int[] originalModelColors;
|
||||||
|
public int scaleX;
|
||||||
|
public int varp;
|
||||||
|
public boolean inverted;
|
||||||
|
public static boolean lowMemory;
|
||||||
|
public static Buffer dataBuf;
|
||||||
|
public int type;
|
||||||
|
public static int[] streamIndices;
|
||||||
|
public boolean impenetrable;
|
||||||
|
public int mapscene;
|
||||||
|
public int childrenIDs[];
|
||||||
|
public int supportItems;
|
||||||
|
public int objectSizeY;
|
||||||
|
public boolean contouredGround;
|
||||||
|
public boolean occludes;
|
||||||
|
public static Client clientInstance;
|
||||||
|
public boolean hollow;
|
||||||
|
public boolean solid;
|
||||||
|
public int surroundings;
|
||||||
|
public boolean delayShading;
|
||||||
|
public static int cacheIndex;
|
||||||
|
public int scaleY;
|
||||||
|
public int[] modelIds;
|
||||||
|
public int varbit;
|
||||||
|
public int decorDisplacement;
|
||||||
|
public int[] modelTypes;
|
||||||
|
public byte[] description;
|
||||||
|
public boolean isInteractive;
|
||||||
|
public boolean castsShadow;
|
||||||
|
public static ReferenceCache models = new ReferenceCache(30);
|
||||||
|
public int animation;
|
||||||
|
public static ObjectDefinition[] cache;
|
||||||
|
public int translateZ;
|
||||||
|
public int[] modifiedModelColors;
|
||||||
|
public static ReferenceCache baseModels = new ReferenceCache(500);
|
||||||
|
public String interactions[];
|
||||||
|
|
||||||
|
private short[] originalTexture;
|
||||||
|
private short[] modifiedTexture;
|
||||||
|
|
||||||
|
public ObjectDefinition() {
|
||||||
|
type = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void dumpNames() throws Exception {
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter("./Cache/object_names.txt"));
|
||||||
|
for(int i = 0; i < totalObjects; i++) {
|
||||||
|
ObjectDefinition def = lookup(i);
|
||||||
|
String name = def == null ? "null" : def.name;
|
||||||
|
writer.write("ID: "+i+", name: "+name+"");
|
||||||
|
writer.newLine();
|
||||||
|
}
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ObjectDefinition lookup(int id) {
|
||||||
|
if (id > streamIndices.length) {
|
||||||
|
id = streamIndices.length - 1;
|
||||||
|
}
|
||||||
|
switch (id) {
|
||||||
|
case 9251:
|
||||||
|
id = 5790;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (int index = 0; index < 20; index++) {
|
||||||
|
if (cache[index].type == id) {
|
||||||
|
return cache[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheIndex = (cacheIndex + 1) % 20;
|
||||||
|
ObjectDefinition def = cache[cacheIndex];
|
||||||
|
dataBuf.currentPosition = streamIndices[id];
|
||||||
|
def.type = id;
|
||||||
|
def.reset();
|
||||||
|
def.decode(dataBuf, id);
|
||||||
|
switch (id) {
|
||||||
|
case 6:
|
||||||
|
def.interactions[1] = "Load";
|
||||||
|
def.interactions[2] = "Pick-up";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Disable delayed shading.
|
||||||
|
//Cheap fix for: edgeville ditch, raids, wintertodt fire etc
|
||||||
|
//Fixes black square on the model
|
||||||
|
def.delayShading = false;
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
modelIds = null;
|
||||||
|
modelTypes = null;
|
||||||
|
name = null;
|
||||||
|
description = null;
|
||||||
|
modifiedModelColors = null;
|
||||||
|
originalModelColors = null;
|
||||||
|
objectSizeX = 1;
|
||||||
|
objectSizeY = 1;
|
||||||
|
solid = true;
|
||||||
|
impenetrable = true;
|
||||||
|
isInteractive = false;
|
||||||
|
contouredGround = false;
|
||||||
|
delayShading = false;
|
||||||
|
occludes = false;
|
||||||
|
animation = -1;
|
||||||
|
decorDisplacement = 16;
|
||||||
|
ambientLighting = 0;
|
||||||
|
lightDiffusion = 0;
|
||||||
|
interactions = null;
|
||||||
|
minimapFunction = -1;
|
||||||
|
mapscene = -1;
|
||||||
|
inverted = false;
|
||||||
|
castsShadow = true;
|
||||||
|
scaleX = 128;
|
||||||
|
scaleY = 128;
|
||||||
|
scaleZ = 128;
|
||||||
|
surroundings = 0;
|
||||||
|
translateX = 0;
|
||||||
|
translateY = 0;
|
||||||
|
translateZ = 0;
|
||||||
|
obstructsGround = false;
|
||||||
|
hollow = false;
|
||||||
|
supportItems = -1;
|
||||||
|
varbit = -1;
|
||||||
|
varp = -1;
|
||||||
|
childrenIDs = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadModels(ResourceProvider archive) {
|
||||||
|
if (modelIds == null)
|
||||||
|
return;
|
||||||
|
for (int index = 0; index < modelIds.length; index++)
|
||||||
|
archive.loadExtra(modelIds[index] & 0xffff, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear() {
|
||||||
|
baseModels = null;
|
||||||
|
models = null;
|
||||||
|
streamIndices = null;
|
||||||
|
cache = null;
|
||||||
|
dataBuf = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int totalObjects;
|
||||||
|
|
||||||
|
public boolean method577(int i) {
|
||||||
|
if (modelTypes == null) {
|
||||||
|
if (modelIds == null)
|
||||||
|
return true;
|
||||||
|
if (i != 10)
|
||||||
|
return true;
|
||||||
|
boolean flag1 = true;
|
||||||
|
for (int k = 0; k < modelIds.length; k++)
|
||||||
|
flag1 &= Model.isCached(modelIds[k] & 0xffff);
|
||||||
|
|
||||||
|
return flag1;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < modelTypes.length; j++)
|
||||||
|
if (modelTypes[j] == i)
|
||||||
|
return Model.isCached(modelIds[j] & 0xffff);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model modelAt(int type, int orientation, int aY, int bY, int cY, int dY, int frameId) {
|
||||||
|
Model model = model(type, frameId, orientation);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
if (contouredGround || delayShading)
|
||||||
|
model = new Model(contouredGround, delayShading, model);
|
||||||
|
if (contouredGround) {
|
||||||
|
int y = (aY + bY + cY + dY) / 4;
|
||||||
|
for (int vertex = 0; vertex < model.numVertices; vertex++) {
|
||||||
|
int x = model.vertexX[vertex];
|
||||||
|
int z = model.vertexZ[vertex];
|
||||||
|
int l2 = aY + ((bY - aY) * (x + 64)) / 128;
|
||||||
|
int i3 = dY + ((cY - dY) * (x + 64)) / 128;
|
||||||
|
int j3 = l2 + ((i3 - l2) * (z + 64)) / 128;
|
||||||
|
model.vertexY[vertex] += j3 - y;
|
||||||
|
}
|
||||||
|
|
||||||
|
model.computeSphericalBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean method579() {
|
||||||
|
if (modelIds == null)
|
||||||
|
return true;
|
||||||
|
boolean flag1 = true;
|
||||||
|
for (int i = 0; i < modelIds.length; i++) {
|
||||||
|
flag1 &= Model.isCached(modelIds[i] & 0xffff);
|
||||||
|
}
|
||||||
|
return flag1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectDefinition method580() {
|
||||||
|
int i = -1;
|
||||||
|
if (varbit != -1) {
|
||||||
|
Varbit varBit = Varbit.varbits[varbit];
|
||||||
|
int j = varBit.getSetting();
|
||||||
|
int k = varBit.getLow();
|
||||||
|
int l = varBit.getHigh();
|
||||||
|
int i1 = Client.BIT_MASKS[l - k];
|
||||||
|
i = clientInstance.settings[j] >> k & i1;
|
||||||
|
} else if (varp != -1)
|
||||||
|
i = clientInstance.settings[varp];
|
||||||
|
if (i < 0 || i >= childrenIDs.length || childrenIDs[i] == -1)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return lookup(childrenIDs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model model(int j, int k, int l) {
|
||||||
|
Model model = null;
|
||||||
|
long l1;
|
||||||
|
if (modelTypes == null) {
|
||||||
|
if (j != 10)
|
||||||
|
return null;
|
||||||
|
l1 = (long) ((type << 6) + l) + ((long) (k + 1) << 32);
|
||||||
|
Model model_1 = (Model) models.get(l1);
|
||||||
|
if (model_1 != null) {
|
||||||
|
return model_1;
|
||||||
|
}
|
||||||
|
if (modelIds == null)
|
||||||
|
return null;
|
||||||
|
boolean flag1 = inverted ^ (l > 3);
|
||||||
|
int k1 = modelIds.length;
|
||||||
|
for (int i2 = 0; i2 < k1; i2++) {
|
||||||
|
int l2 = modelIds[i2];
|
||||||
|
if (flag1)
|
||||||
|
l2 += 0x10000;
|
||||||
|
model = (Model) baseModels.get(l2);
|
||||||
|
if (model == null) {
|
||||||
|
model = Model.getModel(l2 & 0xffff);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
if (flag1)
|
||||||
|
model.method477();
|
||||||
|
baseModels.put(model, l2);
|
||||||
|
}
|
||||||
|
if (k1 > 1)
|
||||||
|
aModelArray741s[i2] = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k1 > 1)
|
||||||
|
model = new Model(k1, aModelArray741s);
|
||||||
|
} else {
|
||||||
|
int i1 = -1;
|
||||||
|
for (int j1 = 0; j1 < modelTypes.length; j1++) {
|
||||||
|
if (modelTypes[j1] != j)
|
||||||
|
continue;
|
||||||
|
i1 = j1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i1 == -1)
|
||||||
|
return null;
|
||||||
|
l1 = (long) ((type << 8) + (i1 << 3) + l) + ((long) (k + 1) << 32);
|
||||||
|
Model model_2 = (Model) models.get(l1);
|
||||||
|
if (model_2 != null) {
|
||||||
|
return model_2;
|
||||||
|
}
|
||||||
|
if(modelIds == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int j2 = modelIds[i1];
|
||||||
|
boolean flag3 = inverted ^ (l > 3);
|
||||||
|
if (flag3)
|
||||||
|
j2 += 0x10000;
|
||||||
|
model = (Model) baseModels.get(j2);
|
||||||
|
if (model == null) {
|
||||||
|
model = Model.getModel(j2 & 0xffff);
|
||||||
|
if (model == null)
|
||||||
|
return null;
|
||||||
|
if (flag3)
|
||||||
|
model.method477();
|
||||||
|
baseModels.put(model, j2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean flag;
|
||||||
|
flag = scaleX != 128 || scaleY != 128 || scaleZ != 128;
|
||||||
|
boolean flag2;
|
||||||
|
flag2 = translateX != 0 || translateY != 0 || translateZ != 0;
|
||||||
|
Model model_3 = new Model(modifiedModelColors == null,
|
||||||
|
Frame.noAnimationInProgress(k), l == 0 && k == -1 && !flag
|
||||||
|
&& !flag2, model);
|
||||||
|
if (k != -1) {
|
||||||
|
model_3.skin();
|
||||||
|
model_3.applyTransform(k);
|
||||||
|
model_3.faceGroups = null;
|
||||||
|
model_3.vertexGroups = null;
|
||||||
|
}
|
||||||
|
while (l-- > 0)
|
||||||
|
model_3.rotate90Degrees();
|
||||||
|
if (modifiedModelColors != null) {
|
||||||
|
for (int k2 = 0; k2 < modifiedModelColors.length; k2++)
|
||||||
|
model_3.recolor(modifiedModelColors[k2],
|
||||||
|
originalModelColors[k2]);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* if (modifiedTexture != null) {
|
||||||
|
for (int k2 = 0; k2 < modifiedTexture.length; k2++)
|
||||||
|
model_3.retexture(modifiedTexture[k2], originalTexture[k2],
|
||||||
|
-1);
|
||||||
|
}*/
|
||||||
|
if (flag)
|
||||||
|
model_3.scale(scaleX, scaleZ, scaleY);
|
||||||
|
if (flag2)
|
||||||
|
model_3.translate(translateX, translateY, translateZ);
|
||||||
|
// model_3.light(84, 1500, -90, -280, -70, !delayShading);
|
||||||
|
model_3.light(64 + ambientLighting, 1300 + (lightDiffusion * 5), -90, -280, -70, !delayShading);
|
||||||
|
if (supportItems == 1)
|
||||||
|
model_3.itemDropHeight = model_3.modelBaseY;
|
||||||
|
models.put(model_3, l1);
|
||||||
|
return model_3;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,415 @@
|
|||||||
|
package org.rebotted.cache.graphics;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.draw.Rasterizer2D;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class GameFont extends Rasterizer2D {
|
||||||
|
|
||||||
|
public GameFont(boolean flag, String s, FileArchive streamLoader) {
|
||||||
|
aByteArrayArray1491 = new byte[256][];
|
||||||
|
anIntArray1492 = new int[256];
|
||||||
|
anIntArray1493 = new int[256];
|
||||||
|
anIntArray1494 = new int[256];
|
||||||
|
anIntArray1495 = new int[256];
|
||||||
|
anIntArray1496 = new int[256];
|
||||||
|
aRandom1498 = new Random();
|
||||||
|
aBoolean1499 = false;
|
||||||
|
Buffer stream = new Buffer(streamLoader.readFile(s + ".dat"));
|
||||||
|
Buffer stream_1 = new Buffer(streamLoader.readFile("index.dat"));
|
||||||
|
stream_1.currentPosition = stream.readUShort() + 4;
|
||||||
|
int k = stream_1.readUnsignedByte();
|
||||||
|
if(k > 0)
|
||||||
|
stream_1.currentPosition += 3 * (k - 1);
|
||||||
|
for(int l = 0; l < 256; l++) {
|
||||||
|
anIntArray1494[l] = stream_1.readUnsignedByte();
|
||||||
|
anIntArray1495[l] = stream_1.readUnsignedByte();
|
||||||
|
int i1 = anIntArray1492[l] = stream_1.readUShort();
|
||||||
|
int j1 = anIntArray1493[l] = stream_1.readUShort();
|
||||||
|
int k1 = stream_1.readUnsignedByte();
|
||||||
|
int l1 = i1 * j1;
|
||||||
|
aByteArrayArray1491[l] = new byte[l1];
|
||||||
|
if(k1 == 0) {
|
||||||
|
for(int i2 = 0; i2 < l1; i2++)
|
||||||
|
aByteArrayArray1491[l][i2] = stream.readSignedByte();
|
||||||
|
|
||||||
|
} else if(k1 == 1) {
|
||||||
|
for(int j2 = 0; j2 < i1; j2++) {
|
||||||
|
for(int l2 = 0; l2 < j1; l2++)
|
||||||
|
aByteArrayArray1491[l][j2 + l2 * i1] = stream.readSignedByte();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(j1 > verticalSpace && l < 128)
|
||||||
|
verticalSpace = j1;
|
||||||
|
anIntArray1494[l] = 1;
|
||||||
|
anIntArray1496[l] = i1 + 2;
|
||||||
|
int k2 = 0;
|
||||||
|
for(int i3 = j1 / 7; i3 < j1; i3++)
|
||||||
|
k2 += aByteArrayArray1491[l][i3 * i1];
|
||||||
|
if(k2 <= j1 / 7) {
|
||||||
|
anIntArray1496[l]--;
|
||||||
|
anIntArray1494[l] = 0;
|
||||||
|
}
|
||||||
|
k2 = 0;
|
||||||
|
for(int j3 = j1 / 7; j3 < j1; j3++)
|
||||||
|
k2 += aByteArrayArray1491[l][(i1 - 1) + j3 * i1];
|
||||||
|
if(k2 <= j1 / 7)
|
||||||
|
anIntArray1496[l]--;
|
||||||
|
}
|
||||||
|
if(flag) {
|
||||||
|
anIntArray1496[32] = anIntArray1496[73];
|
||||||
|
} else {
|
||||||
|
anIntArray1496[32] = anIntArray1496[105];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method380(String s, int i, int j, int k) {
|
||||||
|
render(j, s, k, i - method384(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawText(int i, String s, int k, int l) {
|
||||||
|
render(i, s, k, l - method384(s) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method382(int i, int j, String s, int l, boolean flag) {
|
||||||
|
drawTextWithPotentialShadow(flag, j - getTextWidth(s) / 2, i, s, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawChatInput(int i, int j, String s, int l, boolean flag) {
|
||||||
|
drawTextWithPotentialShadow(flag, j, i, s, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextWidth(String s) {
|
||||||
|
if(s == null)
|
||||||
|
return 0;
|
||||||
|
int j = 0;
|
||||||
|
for(int k = 0; k < s.length(); k++)
|
||||||
|
if(s.charAt(k) == '@' && k + 4 < s.length() && s.charAt(k + 4) == '@')
|
||||||
|
k += 4;
|
||||||
|
else
|
||||||
|
j += anIntArray1496[s.charAt(k)];
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int method384(String s) {
|
||||||
|
if(s == null)
|
||||||
|
return 0;
|
||||||
|
int j = 0;
|
||||||
|
for(int k = 0; k < s.length(); k++)
|
||||||
|
j += anIntArray1496[s.charAt(k)];
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render(int i, String s, int j, int l) {
|
||||||
|
if(s == null)
|
||||||
|
return;
|
||||||
|
j -= verticalSpace;
|
||||||
|
for(int i1 = 0; i1 < s.length(); i1++) {
|
||||||
|
char c = s.charAt(i1);
|
||||||
|
if(c != ' ')
|
||||||
|
method392(aByteArrayArray1491[c], l + anIntArray1494[c], j + anIntArray1495[c], anIntArray1492[c], anIntArray1493[c], i);
|
||||||
|
l += anIntArray1496[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void wave(int i, String s, int j, int k, int l) {
|
||||||
|
if(s == null)
|
||||||
|
return;
|
||||||
|
j -= method384(s) / 2;
|
||||||
|
l -= verticalSpace;
|
||||||
|
for(int i1 = 0; i1 < s.length(); i1++) {
|
||||||
|
char c = s.charAt(i1);
|
||||||
|
if(c != ' ')
|
||||||
|
method392(aByteArrayArray1491[c], j + anIntArray1494[c], l + anIntArray1495[c] + (int)(Math.sin((double)i1 / 2D + (double)k / 5D) * 5D), anIntArray1492[c], anIntArray1493[c], i);
|
||||||
|
j += anIntArray1496[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void wave2(int i, String s, int j, int k, int l) {
|
||||||
|
if(s == null)
|
||||||
|
return;
|
||||||
|
i -= method384(s) / 2;
|
||||||
|
k -= verticalSpace;
|
||||||
|
for(int i1 = 0; i1 < s.length(); i1++) {
|
||||||
|
char c = s.charAt(i1);
|
||||||
|
if(c != ' ')
|
||||||
|
method392(aByteArrayArray1491[c], i + anIntArray1494[c] + (int)(Math.sin((double)i1 / 5D + (double)j / 5D) * 5D), k + anIntArray1495[c] + (int)(Math.sin((double)i1 / 3D + (double)j / 5D) * 5D), anIntArray1492[c], anIntArray1493[c], l);
|
||||||
|
i += anIntArray1496[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shake(int i, String s, int j, int k, int l, int i1) {
|
||||||
|
if(s == null)
|
||||||
|
return;
|
||||||
|
double d = 7D - (double)i / 8D;
|
||||||
|
if(d < 0.0D)
|
||||||
|
d = 0.0D;
|
||||||
|
l -= method384(s) / 2;
|
||||||
|
k -= verticalSpace;
|
||||||
|
for(int k1 = 0; k1 < s.length(); k1++) {
|
||||||
|
char c = s.charAt(k1);
|
||||||
|
if(c != ' ')
|
||||||
|
method392(aByteArrayArray1491[c], l + anIntArray1494[c], k + anIntArray1495[c] + (int)(Math.sin((double)k1 / 1.5D + (double)j) * d), anIntArray1492[c], anIntArray1493[c], i1);
|
||||||
|
l += anIntArray1496[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawTextWithPotentialShadow(boolean flag1, int i, int j, String s, int k) {
|
||||||
|
aBoolean1499 = false;
|
||||||
|
int l = i;
|
||||||
|
if(s == null)
|
||||||
|
return;
|
||||||
|
k -= verticalSpace;
|
||||||
|
for(int i1 = 0; i1 < s.length(); i1++)
|
||||||
|
if(s.charAt(i1) == '@' && i1 + 4 < s.length() && s.charAt(i1 + 4) == '@') {
|
||||||
|
int j1 = getColorByName(s.substring(i1 + 1, i1 + 4));
|
||||||
|
if(j1 != -1)
|
||||||
|
j = j1;
|
||||||
|
i1 += 4;
|
||||||
|
} else {
|
||||||
|
char c = s.charAt(i1);
|
||||||
|
if(c != ' ') {
|
||||||
|
if(flag1)
|
||||||
|
method392(aByteArrayArray1491[c], i + anIntArray1494[c] + 1, k + anIntArray1495[c] + 1, anIntArray1492[c], anIntArray1493[c], 0);
|
||||||
|
method392(aByteArrayArray1491[c], i + anIntArray1494[c], k + anIntArray1495[c], anIntArray1492[c], anIntArray1493[c], j);
|
||||||
|
}
|
||||||
|
i += anIntArray1496[c];
|
||||||
|
}
|
||||||
|
if(aBoolean1499)
|
||||||
|
Rasterizer2D.drawHorizontalLine(l, k + (int)((double)verticalSpace * 0.69999999999999996D), i - l, 0x800000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method390(int i, int j, String s, int k, int i1) {
|
||||||
|
if(s == null)
|
||||||
|
return;
|
||||||
|
aRandom1498.setSeed(k);
|
||||||
|
int j1 = 192 + (aRandom1498.nextInt() & 0x1f);
|
||||||
|
i1 -= verticalSpace;
|
||||||
|
for(int k1 = 0; k1 < s.length(); k1++) {
|
||||||
|
if(s.charAt(k1) == '@' && k1 + 4 < s.length() && s.charAt(k1 + 4) == '@') {
|
||||||
|
int l1 = getColorByName(s.substring(k1 + 1, k1 + 4));
|
||||||
|
if(l1 != -1)
|
||||||
|
j = l1;
|
||||||
|
k1 += 4;
|
||||||
|
} else {
|
||||||
|
char c = s.charAt(k1);
|
||||||
|
if(c >= anIntArray1494.length) {
|
||||||
|
c = ' ';
|
||||||
|
}
|
||||||
|
if(c != ' ') {
|
||||||
|
method394(192, i + anIntArray1494[c] + 1, aByteArrayArray1491[c], anIntArray1492[c], i1 + anIntArray1495[c] + 1, anIntArray1493[c], 0);
|
||||||
|
method394(j1, i + anIntArray1494[c], aByteArrayArray1491[c], anIntArray1492[c], i1 + anIntArray1495[c], anIntArray1493[c], j);
|
||||||
|
}
|
||||||
|
i += anIntArray1496[c];
|
||||||
|
if((aRandom1498.nextInt() & 3) == 0)
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getColorByName(String s) {
|
||||||
|
if(s.equals("369"))//color code, use as @###@
|
||||||
|
return 0x336699;//hex code
|
||||||
|
if(s.equals("mon"))
|
||||||
|
return 0x00ff80;
|
||||||
|
if(s.equals("red"))
|
||||||
|
return 0xff0000;
|
||||||
|
if(s.equals("gre"))
|
||||||
|
return 65280;
|
||||||
|
if(s.equals("blu"))
|
||||||
|
return 255;
|
||||||
|
if(s.equals("yel"))
|
||||||
|
return 0xffff00;
|
||||||
|
if(s.equals("cya"))
|
||||||
|
return 65535;
|
||||||
|
if(s.equals("mag"))
|
||||||
|
return 0xff00ff;
|
||||||
|
if(s.equals("whi"))
|
||||||
|
return 0xffffff;
|
||||||
|
if(s.equals("bla"))
|
||||||
|
return 0;
|
||||||
|
if(s.equals("lre"))
|
||||||
|
return 0xff9040;
|
||||||
|
if(s.equals("dre"))
|
||||||
|
return 0x800000;
|
||||||
|
if(s.equals("dbl"))
|
||||||
|
return 128;
|
||||||
|
if(s.equals("or1"))
|
||||||
|
return 0xffb000;
|
||||||
|
if(s.equals("or2"))
|
||||||
|
return 0xff7000;
|
||||||
|
if(s.equals("or3"))
|
||||||
|
return 0xff3000;
|
||||||
|
if(s.equals("gr1"))
|
||||||
|
return 0xc0ff00;
|
||||||
|
if(s.equals("gr2"))
|
||||||
|
return 0x80ff00;
|
||||||
|
if(s.equals("gr3"))
|
||||||
|
return 0x40ff00;
|
||||||
|
if(s.equals("str"))
|
||||||
|
aBoolean1499 = true;
|
||||||
|
if(s.equals("end"))
|
||||||
|
aBoolean1499 = false;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method392(byte abyte0[], int i, int j, int k, int l, int i1) {
|
||||||
|
int j1 = i + j * width;
|
||||||
|
int k1 = width - k;
|
||||||
|
int l1 = 0;
|
||||||
|
int i2 = 0;
|
||||||
|
if (j < topY) {
|
||||||
|
int j2 = topY - j;
|
||||||
|
l -= j2;
|
||||||
|
j = topY;
|
||||||
|
i2 += j2 * k;
|
||||||
|
j1 += j2 * width;
|
||||||
|
}
|
||||||
|
if (j + l >= bottomY)
|
||||||
|
l -= ((j + l) - bottomY);
|
||||||
|
if (i < leftX) {
|
||||||
|
int k2 = leftX - i;
|
||||||
|
k -= k2;
|
||||||
|
i = leftX;
|
||||||
|
i2 += k2;
|
||||||
|
j1 += k2;
|
||||||
|
l1 += k2;
|
||||||
|
k1 += k2;
|
||||||
|
}
|
||||||
|
if (i + k >= bottomX) {
|
||||||
|
int l2 = ((i + k) - bottomX);
|
||||||
|
k -= l2;
|
||||||
|
l1 += l2;
|
||||||
|
k1 += l2;
|
||||||
|
}
|
||||||
|
if (!(k <= 0 || l <= 0)) {
|
||||||
|
method393(pixels, abyte0, i1, i2, j1, k, l, k1, l1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method393(int ai[], byte abyte0[], int i, int j, int k, int l, int i1, int j1, int k1) {
|
||||||
|
int l1 = -(l >> 2);
|
||||||
|
l = -(l & 3);
|
||||||
|
for(int i2 = -i1; i2 < 0; i2++) {
|
||||||
|
for(int j2 = l1; j2 < 0; j2++) {
|
||||||
|
if(abyte0[j++] != 0)
|
||||||
|
ai[k++] = i;
|
||||||
|
else
|
||||||
|
k++;
|
||||||
|
if(abyte0[j++] != 0)
|
||||||
|
ai[k++] = i;
|
||||||
|
else
|
||||||
|
k++;
|
||||||
|
if(abyte0[j++] != 0)
|
||||||
|
ai[k++] = i;
|
||||||
|
else
|
||||||
|
k++;
|
||||||
|
if(abyte0[j++] != 0)
|
||||||
|
ai[k++] = i;
|
||||||
|
else
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
for(int k2 = l; k2 < 0; k2++)
|
||||||
|
if(abyte0[j++] != 0)
|
||||||
|
ai[k++] = i;
|
||||||
|
else
|
||||||
|
k++;
|
||||||
|
|
||||||
|
k += j1;
|
||||||
|
j += k1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method394(int i, int j, byte abyte0[], int k, int l, int i1,
|
||||||
|
int j1) {
|
||||||
|
int k1 = j + l * width;
|
||||||
|
int l1 = width - k;
|
||||||
|
int i2 = 0;
|
||||||
|
int j2 = 0;
|
||||||
|
if (l < topY) {
|
||||||
|
int k2 = topY - l;
|
||||||
|
i1 -= k2;
|
||||||
|
l = topY;
|
||||||
|
j2 += k2 * k;
|
||||||
|
k1 += k2 * width;
|
||||||
|
}
|
||||||
|
if (l + i1 >= bottomY)
|
||||||
|
i1 -= ((l + i1) - bottomY);
|
||||||
|
if (j < leftX) {
|
||||||
|
int l2 = leftX - j;
|
||||||
|
k -= l2;
|
||||||
|
j = leftX;
|
||||||
|
j2 += l2;
|
||||||
|
k1 += l2;
|
||||||
|
i2 += l2;
|
||||||
|
l1 += l2;
|
||||||
|
}
|
||||||
|
if (j + k >= bottomX) {
|
||||||
|
int i3 = ((j + k) - bottomX);
|
||||||
|
k -= i3;
|
||||||
|
i2 += i3;
|
||||||
|
l1 += i3;
|
||||||
|
}
|
||||||
|
if (k <= 0 || i1 <= 0)
|
||||||
|
return;
|
||||||
|
method395(abyte0, i1, k1, pixels, j2, k, i2, l1, j1, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method395(byte abyte0[], int i, int j, int ai[], int l, int i1, int j1, int k1, int l1, int i2) {
|
||||||
|
l1 = ((l1 & 0xff00ff) * i2 & 0xff00ff00) + ((l1 & 0xff00) * i2 & 0xff0000) >> 8;
|
||||||
|
i2 = 256 - i2;
|
||||||
|
for(int j2 = -i; j2 < 0; j2++) {
|
||||||
|
for(int k2 = -i1; k2 < 0; k2++)
|
||||||
|
if(abyte0[l++] != 0) {
|
||||||
|
int l2 = ai[j];
|
||||||
|
ai[j++] = (((l2 & 0xff00ff) * i2 & 0xff00ff00) + ((l2 & 0xff00) * i2 & 0xff0000) >> 8) + l1;
|
||||||
|
} else {
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
j += k1;
|
||||||
|
l += j1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void drawAlphaFilledPixels(int xPos, int yPos,
|
||||||
|
int pixelWidth, int pixelHeight, int color, int alpha) {// method586
|
||||||
|
if (xPos < leftX) {
|
||||||
|
pixelWidth -= leftX - xPos;
|
||||||
|
xPos = leftX;
|
||||||
|
}
|
||||||
|
if (yPos < topY) {
|
||||||
|
pixelHeight -= topY - yPos;
|
||||||
|
yPos = topY;
|
||||||
|
}
|
||||||
|
if (xPos + pixelWidth > bottomX)
|
||||||
|
pixelWidth = bottomX - xPos;
|
||||||
|
if (yPos + pixelHeight > bottomY)
|
||||||
|
pixelHeight = bottomY - yPos;
|
||||||
|
color = ((color & 0xff00ff) * alpha >> 8 & 0xff00ff)
|
||||||
|
+ ((color & 0xff00) * alpha >> 8 & 0xff00);
|
||||||
|
int k1 = 256 - alpha;
|
||||||
|
int l1 = width - pixelWidth;
|
||||||
|
int i2 = xPos + yPos * width;
|
||||||
|
for (int j2 = 0; j2 < pixelHeight; j2++) {
|
||||||
|
for (int k2 = -pixelWidth; k2 < 0; k2++) {
|
||||||
|
int l2 = pixels[i2];
|
||||||
|
l2 = ((l2 & 0xff00ff) * k1 >> 8 & 0xff00ff)
|
||||||
|
+ ((l2 & 0xff00) * k1 >> 8 & 0xff00);
|
||||||
|
pixels[i2++] = color + l2;
|
||||||
|
}
|
||||||
|
i2 += l1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[][] aByteArrayArray1491;
|
||||||
|
public int[] anIntArray1492;
|
||||||
|
public int[] anIntArray1493;
|
||||||
|
public int[] anIntArray1494;
|
||||||
|
public int[] anIntArray1495;
|
||||||
|
public int[] anIntArray1496;
|
||||||
|
public int verticalSpace;
|
||||||
|
public Random aRandom1498;
|
||||||
|
public boolean aBoolean1499;
|
||||||
|
}
|
||||||
@@ -0,0 +1,239 @@
|
|||||||
|
package org.rebotted.cache.graphics;
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.draw.Rasterizer2D;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class IndexedImage extends Rasterizer2D {
|
||||||
|
|
||||||
|
public byte palettePixels[];
|
||||||
|
public final int[] palette;
|
||||||
|
public int width;
|
||||||
|
public int height;
|
||||||
|
public int drawOffsetX;
|
||||||
|
public int drawOffsetY;
|
||||||
|
public int resizeWidth;
|
||||||
|
private int resizeHeight;
|
||||||
|
|
||||||
|
public IndexedImage(FileArchive archive, String s, int i) {
|
||||||
|
Buffer image = new Buffer(archive.readFile(s + ".dat"));
|
||||||
|
Buffer meta = new Buffer(archive.readFile("index.dat"));
|
||||||
|
meta.currentPosition = image.readUShort();
|
||||||
|
resizeWidth = meta.readUShort();
|
||||||
|
resizeHeight = meta.readUShort();
|
||||||
|
|
||||||
|
int colorLength = meta.readUnsignedByte();
|
||||||
|
palette = new int[colorLength];
|
||||||
|
|
||||||
|
for(int index = 0; index < colorLength - 1; index++) {
|
||||||
|
palette[index + 1] = meta.readTriByte();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int l = 0; l < i; l++) {
|
||||||
|
meta.currentPosition += 2;
|
||||||
|
image.currentPosition += meta.readUShort() * meta.readUShort();
|
||||||
|
meta.currentPosition++;
|
||||||
|
}
|
||||||
|
drawOffsetX = meta.readUnsignedByte();
|
||||||
|
drawOffsetY = meta.readUnsignedByte();
|
||||||
|
width = meta.readUShort();
|
||||||
|
height = meta.readUShort();
|
||||||
|
int type = meta.readUnsignedByte();
|
||||||
|
int pixels = width * height;
|
||||||
|
palettePixels = new byte[pixels];
|
||||||
|
|
||||||
|
if(type == 0) {
|
||||||
|
for(int index = 0; index < pixels; index++) {
|
||||||
|
palettePixels[index] = image.readSignedByte();
|
||||||
|
}
|
||||||
|
} else if(type == 1) {
|
||||||
|
for(int x = 0; x < width; x++) {
|
||||||
|
for(int y = 0; y < height; y++) {
|
||||||
|
palettePixels[x + y * width] = image.readSignedByte();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void downscale() {
|
||||||
|
resizeWidth /= 2;
|
||||||
|
resizeHeight /= 2;
|
||||||
|
byte raster[] = new byte[resizeWidth * resizeHeight];
|
||||||
|
int sourceIndex = 0;
|
||||||
|
for(int y = 0; y < height; y ++) {
|
||||||
|
for(int x = 0; x < width; x++) {
|
||||||
|
raster[(x + drawOffsetX >> 1) + (y + drawOffsetY >> 1) * resizeWidth] = raster[sourceIndex++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.palettePixels = raster;
|
||||||
|
width = resizeWidth;
|
||||||
|
height = resizeHeight;
|
||||||
|
drawOffsetX = 0;
|
||||||
|
drawOffsetY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resize() {
|
||||||
|
if(width == resizeWidth && height == resizeHeight) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte raster[] = new byte[resizeWidth * resizeHeight];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for(int y = 0; y < height; y++) {
|
||||||
|
for(int x = 0; x < width; x++) {
|
||||||
|
raster[x + drawOffsetX + (y + drawOffsetY) * resizeWidth] = raster[i++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.palettePixels = raster;
|
||||||
|
width = resizeWidth;
|
||||||
|
height = resizeHeight;
|
||||||
|
drawOffsetX = 0;
|
||||||
|
drawOffsetY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flipHorizontally() {
|
||||||
|
byte raster[] = new byte[width * height];
|
||||||
|
int pixel = 0;
|
||||||
|
for(int y = 0; y < height; y++) {
|
||||||
|
for(int x = width - 1; x >= 0; x--) {
|
||||||
|
raster[pixel++] = raster[x + y * width];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.palettePixels = raster;
|
||||||
|
drawOffsetX = resizeWidth - width - drawOffsetX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flipVertically() {
|
||||||
|
byte raster[] = new byte[width * height];
|
||||||
|
int pixel = 0;
|
||||||
|
for(int y = height - 1; y >= 0; y--) {
|
||||||
|
for(int x = 0; x < width; x++) {
|
||||||
|
raster[pixel++] = raster[x + y * width];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.palettePixels = raster;
|
||||||
|
drawOffsetY = resizeHeight - height - drawOffsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void offsetColor(int redOffset, int greenOffset, int blueOffset) {
|
||||||
|
for(int index = 0; index < palette.length; index++) {
|
||||||
|
int red = palette[index] >> 16 & 0xff;
|
||||||
|
red += redOffset;
|
||||||
|
|
||||||
|
if(red < 0) {
|
||||||
|
red = 0;
|
||||||
|
} else if(red > 255) {
|
||||||
|
red = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
int green = palette[index] >> 8 & 0xff;
|
||||||
|
|
||||||
|
green += greenOffset;
|
||||||
|
if(green < 0) {
|
||||||
|
green = 0;
|
||||||
|
} else if(green > 255) {
|
||||||
|
green = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
int blue = palette[index] & 0xff;
|
||||||
|
|
||||||
|
blue += blueOffset;
|
||||||
|
if(blue < 0) {
|
||||||
|
blue = 0;
|
||||||
|
} else if(blue > 255) {
|
||||||
|
blue = 255;
|
||||||
|
}
|
||||||
|
palette[index] = (red << 16) + (green << 8) + blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(int x, int y) {
|
||||||
|
x += drawOffsetX;
|
||||||
|
y += drawOffsetY;
|
||||||
|
int destOffset = x + y * Rasterizer2D.width;
|
||||||
|
int sourceOffset = 0;
|
||||||
|
int height = this.height;
|
||||||
|
int width = this.width;
|
||||||
|
int destStep = Rasterizer2D.width - width;
|
||||||
|
int sourceStep = 0;
|
||||||
|
|
||||||
|
if(y < Rasterizer2D.topY) {
|
||||||
|
int dy = Rasterizer2D.topY - y;
|
||||||
|
height -= dy;
|
||||||
|
y = Rasterizer2D.topY;
|
||||||
|
sourceOffset += dy * width;
|
||||||
|
destOffset += dy * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(y + height > Rasterizer2D.bottomY) {
|
||||||
|
height -= (y + height) - Rasterizer2D.bottomY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(x < Rasterizer2D.leftX) {
|
||||||
|
int k2 = Rasterizer2D.leftX - x;
|
||||||
|
width -= k2;
|
||||||
|
x = Rasterizer2D.leftX;
|
||||||
|
sourceOffset += k2;
|
||||||
|
destOffset += k2;
|
||||||
|
sourceStep += k2;
|
||||||
|
destStep += k2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(x + width > Rasterizer2D.bottomX) {
|
||||||
|
int dx = (x + width) - Rasterizer2D.bottomX;
|
||||||
|
width -= dx;
|
||||||
|
sourceStep += dx;
|
||||||
|
destStep += dx;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(width <= 0 || height <= 0)) {
|
||||||
|
draw(height, Rasterizer2D.pixels, palettePixels, destStep, destOffset, width, sourceOffset, palette, sourceStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void draw(int i, int raster[], byte image[], int destStep, int destIndex, int width, int sourceIndex, int ai1[], int sourceStep) {
|
||||||
|
int minX = -(width >> 2);
|
||||||
|
width = -(width & 3);
|
||||||
|
for(int y = -i; y < 0; y++) {
|
||||||
|
for(int x = minX; x < 0; x++) {
|
||||||
|
|
||||||
|
byte pixel = image[sourceIndex++];
|
||||||
|
|
||||||
|
if(pixel != 0) {
|
||||||
|
raster[destIndex++] = ai1[pixel & 0xff];
|
||||||
|
} else {
|
||||||
|
destIndex++;
|
||||||
|
}
|
||||||
|
pixel = image[sourceIndex++];
|
||||||
|
if(pixel != 0) {
|
||||||
|
raster[destIndex++] = ai1[pixel & 0xff];
|
||||||
|
} else {
|
||||||
|
destIndex++;
|
||||||
|
}
|
||||||
|
pixel = image[sourceIndex++];
|
||||||
|
if(pixel != 0) {
|
||||||
|
raster[destIndex++] = ai1[pixel & 0xff];
|
||||||
|
} else {
|
||||||
|
destIndex++;
|
||||||
|
}
|
||||||
|
pixel = image[sourceIndex++];
|
||||||
|
if(pixel != 0) {
|
||||||
|
raster[destIndex++] = ai1[pixel & 0xff];
|
||||||
|
} else {
|
||||||
|
destIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int x = width; x < 0; x++) {
|
||||||
|
byte pixel = image[sourceIndex++];
|
||||||
|
if(pixel != 0) {
|
||||||
|
raster[destIndex++] = ai1[pixel & 0xff];
|
||||||
|
} else {
|
||||||
|
destIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
destIndex += destStep;
|
||||||
|
sourceIndex += sourceStep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,944 @@
|
|||||||
|
package org.rebotted.cache.graphics;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.PixelGrabber;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.draw.Rasterizer2D;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
import org.rebotted.util.FileUtils;
|
||||||
|
|
||||||
|
public final class Sprite extends Rasterizer2D {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private int myPixels[];
|
||||||
|
private int myWidth;
|
||||||
|
private int myHeight;
|
||||||
|
private int offsetX;
|
||||||
|
private int offsetY;
|
||||||
|
private int maxWidth;
|
||||||
|
private int maxHeight;
|
||||||
|
|
||||||
|
public Sprite() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite(int i, int j) {
|
||||||
|
myPixels = new int[i * j];
|
||||||
|
myWidth = maxWidth = i;
|
||||||
|
myHeight = maxHeight = j;
|
||||||
|
offsetX = offsetY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite(Sprite sprite, int width, int height) {
|
||||||
|
this.myWidth = width;
|
||||||
|
this.myHeight = height;
|
||||||
|
this.maxWidth = width;
|
||||||
|
this.maxHeight = height;
|
||||||
|
offsetX = 0;
|
||||||
|
offsetY = 0;
|
||||||
|
|
||||||
|
myPixels = new int[width * height];
|
||||||
|
|
||||||
|
System.arraycopy(sprite.myPixels, 0, myPixels, 0, myPixels.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite(byte data[], Component component) {
|
||||||
|
try {
|
||||||
|
Image image = Toolkit.getDefaultToolkit().createImage(data);
|
||||||
|
MediaTracker mediatracker = new MediaTracker(component);
|
||||||
|
mediatracker.addImage(image, 0);
|
||||||
|
mediatracker.waitForAll();
|
||||||
|
myWidth = image.getWidth(component);
|
||||||
|
myHeight = image.getHeight(component);
|
||||||
|
maxWidth = myWidth;
|
||||||
|
maxHeight = myHeight;
|
||||||
|
offsetX = 0;
|
||||||
|
offsetY = 0;
|
||||||
|
myPixels = new int[myWidth * myHeight];
|
||||||
|
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, myWidth, myHeight, myPixels, 0, myWidth);
|
||||||
|
pixelgrabber.grabPixels();
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
System.out.println("Error converting jpg");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite(String img, int width, int height) {
|
||||||
|
try {
|
||||||
|
Image image = Toolkit.getDefaultToolkit().createImage(FileUtils.readFile(img));
|
||||||
|
myWidth = width;
|
||||||
|
myHeight = height;
|
||||||
|
maxWidth = myWidth;
|
||||||
|
maxHeight = myHeight;
|
||||||
|
offsetX = 0;
|
||||||
|
offsetY = 0;
|
||||||
|
myPixels = new int[myWidth * myHeight];
|
||||||
|
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, myWidth, myHeight, myPixels, 0, myWidth);
|
||||||
|
pixelgrabber.grabPixels();
|
||||||
|
image = null;
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
System.out.println(_ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawHoverSprite(int x, int y, int offsetX, int offsetY, Sprite hover) {
|
||||||
|
this.drawSprite(x, y);
|
||||||
|
if (Client.instance.mouseX >= offsetX + x && Client.instance.mouseX <= offsetX + x + this.myWidth
|
||||||
|
&& Client.instance.mouseY >= offsetY + y && Client.instance.mouseY <= offsetY + y + this.myHeight) {
|
||||||
|
hover.drawSprite(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw24BitSprite(int x, int y) {
|
||||||
|
int alpha = 256;
|
||||||
|
x += this.offsetX;// offsetX
|
||||||
|
y += this.offsetY;// offsetY
|
||||||
|
int destOffset = x + y * Rasterizer2D.width;
|
||||||
|
int srcOffset = 0;
|
||||||
|
int height = this.myHeight;
|
||||||
|
int width = this.myWidth;
|
||||||
|
int destStep = Rasterizer2D.width - width;
|
||||||
|
int srcStep = 0;
|
||||||
|
if (y < Rasterizer2D.topY) {
|
||||||
|
int trimHeight = Rasterizer2D.topY - y;
|
||||||
|
height -= trimHeight;
|
||||||
|
y = Rasterizer2D.topY;
|
||||||
|
srcOffset += trimHeight * width;
|
||||||
|
destOffset += trimHeight * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (y + height > Rasterizer2D.bottomY) {
|
||||||
|
height -= (y + height) - Rasterizer2D.bottomY;
|
||||||
|
}
|
||||||
|
if (x < Rasterizer2D.leftX) {
|
||||||
|
int trimLeft = Rasterizer2D.leftX - x;
|
||||||
|
width -= trimLeft;
|
||||||
|
x = Rasterizer2D.leftX;
|
||||||
|
srcOffset += trimLeft;
|
||||||
|
destOffset += trimLeft;
|
||||||
|
srcStep += trimLeft;
|
||||||
|
destStep += trimLeft;
|
||||||
|
}
|
||||||
|
if (x + width > Rasterizer2D.bottomX) {
|
||||||
|
int trimRight = (x + width) - Rasterizer2D.bottomX;
|
||||||
|
width -= trimRight;
|
||||||
|
srcStep += trimRight;
|
||||||
|
destStep += trimRight;
|
||||||
|
}
|
||||||
|
if (!((width <= 0) || (height <= 0))) {
|
||||||
|
set24BitPixels(width, height, Rasterizer2D.pixels, myPixels, alpha, destOffset, srcOffset, destStep, srcStep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawTransparentSprite(int x, int y, int opacity) {
|
||||||
|
int k = opacity;// was parameter
|
||||||
|
x += offsetX;
|
||||||
|
y += offsetY;
|
||||||
|
int i1 = x + y * Rasterizer2D.width;
|
||||||
|
int j1 = 0;
|
||||||
|
int k1 = myHeight;
|
||||||
|
int l1 = myWidth;
|
||||||
|
int i2 = Rasterizer2D.width - l1;
|
||||||
|
int j2 = 0;
|
||||||
|
if (y < Rasterizer2D.topY) {
|
||||||
|
int k2 = Rasterizer2D.topY - y;
|
||||||
|
k1 -= k2;
|
||||||
|
y = Rasterizer2D.topY;
|
||||||
|
j1 += k2 * l1;
|
||||||
|
i1 += k2 * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (y + k1 > Rasterizer2D.bottomY)
|
||||||
|
k1 -= (y + k1) - Rasterizer2D.bottomY;
|
||||||
|
if (x < Rasterizer2D.leftX) {
|
||||||
|
int l2 = Rasterizer2D.leftX - x;
|
||||||
|
l1 -= l2;
|
||||||
|
x = Rasterizer2D.leftX;
|
||||||
|
j1 += l2;
|
||||||
|
i1 += l2;
|
||||||
|
j2 += l2;
|
||||||
|
i2 += l2;
|
||||||
|
}
|
||||||
|
if (x + l1 > Rasterizer2D.bottomX) {
|
||||||
|
int i3 = (x + l1) - Rasterizer2D.bottomX;
|
||||||
|
l1 -= i3;
|
||||||
|
j2 += i3;
|
||||||
|
i2 += i3;
|
||||||
|
}
|
||||||
|
if (!(l1 <= 0 || k1 <= 0)) {
|
||||||
|
method351(j1, l1, Rasterizer2D.pixels, myPixels, j2, k1, i2, k, i1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void set24BitPixels(int width, int height, int destPixels[], int srcPixels[], int srcAlpha, int destOffset, int srcOffset, int destStep, int srcStep) {
|
||||||
|
int srcColor;
|
||||||
|
int destAlpha;
|
||||||
|
for (int loop = -height; loop < 0; loop++) {
|
||||||
|
for (int loop2 = -width; loop2 < 0; loop2++) {
|
||||||
|
srcAlpha = ((this.myPixels[srcOffset] >> 24) & 255);
|
||||||
|
destAlpha = 256 - srcAlpha;
|
||||||
|
srcColor = srcPixels[srcOffset++];
|
||||||
|
if (srcColor != 0 && srcColor != 0xffffff) {
|
||||||
|
int destColor = destPixels[destOffset];
|
||||||
|
destPixels[destOffset++] = ((srcColor & 0xff00ff) * srcAlpha + (destColor & 0xff00ff) * destAlpha & 0xff00ff00) + ((srcColor & 0xff00) * srcAlpha + (destColor & 0xff00) * destAlpha & 0xff0000) >> 8;
|
||||||
|
} else {
|
||||||
|
destOffset++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
destOffset += destStep;
|
||||||
|
srcOffset += srcStep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTransparency(int transRed, int transGreen, int transBlue) {
|
||||||
|
for (int index = 0; index < myPixels.length; index++)
|
||||||
|
if (((myPixels[index] >> 16) & 255) == transRed && ((myPixels[index] >> 8) & 255) == transGreen && (myPixels[index] & 255) == transBlue)
|
||||||
|
myPixels[index] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite(FileArchive archive, String name, int i) {
|
||||||
|
Buffer dataBuffer = new Buffer(archive.readFile(name + ".dat"));
|
||||||
|
Buffer indexBuffer = new Buffer(archive.readFile("index.dat"));
|
||||||
|
|
||||||
|
indexBuffer.currentPosition = dataBuffer.readUShort();
|
||||||
|
|
||||||
|
maxWidth = indexBuffer.readUShort();
|
||||||
|
maxHeight = indexBuffer.readUShort();
|
||||||
|
int pixelCount = indexBuffer.readUnsignedByte();
|
||||||
|
int raster[] = new int[pixelCount];
|
||||||
|
|
||||||
|
for (int pixel = 0; pixel < pixelCount - 1; pixel++) {
|
||||||
|
raster[pixel + 1] = indexBuffer.readTriByte();
|
||||||
|
if (raster[pixel + 1] == 0)
|
||||||
|
raster[pixel + 1] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < i; index++) {
|
||||||
|
indexBuffer.currentPosition += 2;
|
||||||
|
dataBuffer.currentPosition += indexBuffer.readUShort() * indexBuffer.readUShort();
|
||||||
|
indexBuffer.currentPosition++;
|
||||||
|
}
|
||||||
|
|
||||||
|
offsetX = indexBuffer.readUnsignedByte();
|
||||||
|
offsetY = indexBuffer.readUnsignedByte();
|
||||||
|
myWidth = indexBuffer.readUShort();
|
||||||
|
myHeight = indexBuffer.readUShort();
|
||||||
|
|
||||||
|
int type = indexBuffer.readUnsignedByte();
|
||||||
|
|
||||||
|
int spriteSize = myWidth * myHeight;
|
||||||
|
|
||||||
|
myPixels = new int[spriteSize];
|
||||||
|
if (type == 0) {
|
||||||
|
for (int pixel = 0; pixel < spriteSize; pixel++) {
|
||||||
|
myPixels[pixel] = raster[dataBuffer.readUnsignedByte()];
|
||||||
|
}
|
||||||
|
setTransparency(255, 0, 255);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (type == 1) {
|
||||||
|
for (int x = 0; x < myWidth; x++) {
|
||||||
|
for (int y = 0; y < myHeight; y++) {
|
||||||
|
myPixels[x + y * myWidth] = raster[dataBuffer.readUnsignedByte()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
setTransparency(255, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
Rasterizer2D.initDrawingArea(myHeight, myWidth, myPixels, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method344(int i, int j, int k) {
|
||||||
|
for (int i1 = 0; i1 < myPixels.length; i1++) {
|
||||||
|
int j1 = myPixels[i1];
|
||||||
|
if (j1 != 0) {
|
||||||
|
int k1 = j1 >> 16 & 0xff;
|
||||||
|
k1 += i;
|
||||||
|
if (k1 < 1)
|
||||||
|
k1 = 1;
|
||||||
|
else if (k1 > 255)
|
||||||
|
k1 = 255;
|
||||||
|
int l1 = j1 >> 8 & 0xff;
|
||||||
|
l1 += j;
|
||||||
|
if (l1 < 1)
|
||||||
|
l1 = 1;
|
||||||
|
else if (l1 > 255)
|
||||||
|
l1 = 255;
|
||||||
|
int i2 = j1 & 0xff;
|
||||||
|
i2 += k;
|
||||||
|
if (i2 < 1)
|
||||||
|
i2 = 1;
|
||||||
|
else if (i2 > 255)
|
||||||
|
i2 = 255;
|
||||||
|
myPixels[i1] = (k1 << 16) + (l1 << 8) + i2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method345() {
|
||||||
|
int ai[] = new int[maxWidth * maxHeight];
|
||||||
|
for (int j = 0; j < myHeight; j++) {
|
||||||
|
System.arraycopy(myPixels, j * myWidth, ai, j + offsetY * maxWidth + offsetX, myWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
myPixels = ai;
|
||||||
|
myWidth = maxWidth;
|
||||||
|
myHeight = maxHeight;
|
||||||
|
offsetX = 0;
|
||||||
|
offsetY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method346(int x, int y) {
|
||||||
|
x += offsetX;
|
||||||
|
y += offsetY;
|
||||||
|
int l = x + y * Rasterizer2D.width;
|
||||||
|
int i1 = 0;
|
||||||
|
int height = myHeight;
|
||||||
|
int width = myWidth;
|
||||||
|
int l1 = Rasterizer2D.width - width;
|
||||||
|
int i2 = 0;
|
||||||
|
if (y < Rasterizer2D.topY) {
|
||||||
|
int j2 = Rasterizer2D.topY - y;
|
||||||
|
height -= j2;
|
||||||
|
y = Rasterizer2D.topY;
|
||||||
|
i1 += j2 * width;
|
||||||
|
l += j2 * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (y + height > Rasterizer2D.bottomY)
|
||||||
|
height -= (y + height) - Rasterizer2D.bottomY;
|
||||||
|
if (x < Rasterizer2D.leftX) {
|
||||||
|
int k2 = Rasterizer2D.leftX - x;
|
||||||
|
width -= k2;
|
||||||
|
x = Rasterizer2D.leftX;
|
||||||
|
i1 += k2;
|
||||||
|
l += k2;
|
||||||
|
i2 += k2;
|
||||||
|
l1 += k2;
|
||||||
|
}
|
||||||
|
if (x + width > Rasterizer2D.bottomX) {
|
||||||
|
int l2 = (x + width) - Rasterizer2D.bottomX;
|
||||||
|
width -= l2;
|
||||||
|
i2 += l2;
|
||||||
|
l1 += l2;
|
||||||
|
}
|
||||||
|
if (width <= 0 || height <= 0) {
|
||||||
|
} else {
|
||||||
|
method347(l, width, height, i2, i1, l1, myPixels, Rasterizer2D.pixels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method347(int i, int j, int k, int l, int i1, int k1, int ai[], int ai1[]) {
|
||||||
|
int l1 = -(j >> 2);
|
||||||
|
j = -(j & 3);
|
||||||
|
for (int i2 = -k; i2 < 0; i2++) {
|
||||||
|
for (int j2 = l1; j2 < 0; j2++) {
|
||||||
|
ai1[i++] = ai[i1++];
|
||||||
|
ai1[i++] = ai[i1++];
|
||||||
|
ai1[i++] = ai[i1++];
|
||||||
|
ai1[i++] = ai[i1++];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k2 = j; k2 < 0; k2++)
|
||||||
|
ai1[i++] = ai[i1++];
|
||||||
|
|
||||||
|
i += k1;
|
||||||
|
i1 += l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawSprite1(int i, int j) {
|
||||||
|
drawSprite1(i, j, 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawSprite1(int i, int j, int k) {
|
||||||
|
i += offsetX;
|
||||||
|
j += offsetY;
|
||||||
|
int i1 = i + j * Rasterizer2D.width;
|
||||||
|
int j1 = 0;
|
||||||
|
int k1 = myHeight;
|
||||||
|
int l1 = myWidth;
|
||||||
|
int i2 = Rasterizer2D.width - l1;
|
||||||
|
int j2 = 0;
|
||||||
|
if (j < Rasterizer2D.topY) {
|
||||||
|
int k2 = Rasterizer2D.topY - j;
|
||||||
|
k1 -= k2;
|
||||||
|
j = Rasterizer2D.topY;
|
||||||
|
j1 += k2 * l1;
|
||||||
|
i1 += k2 * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (j + k1 > Rasterizer2D.bottomY)
|
||||||
|
k1 -= (j + k1) - Rasterizer2D.bottomY;
|
||||||
|
if (i < Rasterizer2D.leftX) {
|
||||||
|
int l2 = Rasterizer2D.leftX - i;
|
||||||
|
l1 -= l2;
|
||||||
|
i = Rasterizer2D.leftX;
|
||||||
|
j1 += l2;
|
||||||
|
i1 += l2;
|
||||||
|
j2 += l2;
|
||||||
|
i2 += l2;
|
||||||
|
}
|
||||||
|
if (i + l1 > Rasterizer2D.bottomX) {
|
||||||
|
int i3 = (i + l1) - Rasterizer2D.bottomX;
|
||||||
|
l1 -= i3;
|
||||||
|
j2 += i3;
|
||||||
|
i2 += i3;
|
||||||
|
}
|
||||||
|
if (!(l1 <= 0 || k1 <= 0)) {
|
||||||
|
method351(j1, l1, Rasterizer2D.pixels, myPixels, j2, k1, i2, k, i1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawSprite(int x, int y)
|
||||||
|
{
|
||||||
|
x += offsetX;
|
||||||
|
y += offsetY;
|
||||||
|
int rasterClip = x + y * Rasterizer2D.width;
|
||||||
|
int imageClip = 0;
|
||||||
|
int height = myHeight;
|
||||||
|
int width = myWidth;
|
||||||
|
int rasterOffset = Rasterizer2D.width - width;
|
||||||
|
int imageOffset = 0;
|
||||||
|
if(y < Rasterizer2D.topY)
|
||||||
|
{
|
||||||
|
int dy = Rasterizer2D.topY - y;
|
||||||
|
height -= dy;
|
||||||
|
y = Rasterizer2D.topY;
|
||||||
|
imageClip += dy * width;
|
||||||
|
rasterClip += dy * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if(y + height > Rasterizer2D.bottomY)
|
||||||
|
height -= (y + height) - Rasterizer2D.bottomY;
|
||||||
|
if(x < Rasterizer2D.leftX)
|
||||||
|
{
|
||||||
|
int dx = Rasterizer2D.leftX - x;
|
||||||
|
width -= dx;
|
||||||
|
x = Rasterizer2D.leftX;
|
||||||
|
imageClip += dx;
|
||||||
|
rasterClip += dx;
|
||||||
|
imageOffset += dx;
|
||||||
|
rasterOffset += dx;
|
||||||
|
}
|
||||||
|
if(x + width > Rasterizer2D.bottomX)
|
||||||
|
{
|
||||||
|
int dx = (x + width) - Rasterizer2D.bottomX;
|
||||||
|
width -= dx;
|
||||||
|
imageOffset += dx;
|
||||||
|
rasterOffset += dx;
|
||||||
|
}
|
||||||
|
if(!(width <= 0 || height <= 0))
|
||||||
|
{
|
||||||
|
method349(Rasterizer2D.pixels, myPixels, imageClip, rasterClip, width, height, rasterOffset, imageOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawSprite(int i, int k, int color) {
|
||||||
|
int tempWidth = myWidth + 2;
|
||||||
|
int tempHeight = myHeight + 2;
|
||||||
|
int[] tempArray = new int[tempWidth * tempHeight];
|
||||||
|
for (int x = 0; x < myWidth; x++) {
|
||||||
|
for (int y = 0; y < myHeight; y++) {
|
||||||
|
if (myPixels[x + y * myWidth] != 0)
|
||||||
|
tempArray[(x + 1) + (y + 1) * tempWidth] = myPixels[x + y * myWidth];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int x = 0; x < tempWidth; x++) {
|
||||||
|
for (int y = 0; y < tempHeight; y++) {
|
||||||
|
if (tempArray[(x) + (y) * tempWidth] == 0) {
|
||||||
|
if (x < tempWidth - 1 && tempArray[(x + 1) + ((y) * tempWidth)] > 0 && tempArray[(x + 1) + ((y) * tempWidth)] != 0xffffff) {
|
||||||
|
tempArray[(x) + (y) * tempWidth] = color;
|
||||||
|
}
|
||||||
|
if (x > 0 && tempArray[(x - 1) + ((y) * tempWidth)] > 0 && tempArray[(x - 1) + ((y) * tempWidth)] != 0xffffff) {
|
||||||
|
tempArray[(x) + (y) * tempWidth] = color;
|
||||||
|
}
|
||||||
|
if (y < tempHeight - 1 && tempArray[(x) + ((y + 1) * tempWidth)] > 0 && tempArray[(x) + ((y + 1) * tempWidth)] != 0xffffff) {
|
||||||
|
tempArray[(x) + (y) * tempWidth] = color;
|
||||||
|
}
|
||||||
|
if (y > 0 && tempArray[(x) + ((y - 1) * tempWidth)] > 0 && tempArray[(x) + ((y - 1) * tempWidth)] != 0xffffff) {
|
||||||
|
tempArray[(x) + (y) * tempWidth] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i--;
|
||||||
|
k--;
|
||||||
|
i += offsetX;
|
||||||
|
k += offsetY;
|
||||||
|
int l = i + k * Rasterizer2D.width;
|
||||||
|
int i1 = 0;
|
||||||
|
int j1 = tempHeight;
|
||||||
|
int k1 = tempWidth;
|
||||||
|
int l1 = Rasterizer2D.width - k1;
|
||||||
|
int i2 = 0;
|
||||||
|
if (k < Rasterizer2D.topY) {
|
||||||
|
int j2 = Rasterizer2D.topY - k;
|
||||||
|
j1 -= j2;
|
||||||
|
k = Rasterizer2D.topY;
|
||||||
|
i1 += j2 * k1;
|
||||||
|
l += j2 * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (k + j1 > Rasterizer2D.bottomY) {
|
||||||
|
j1 -= (k + j1) - Rasterizer2D.bottomY;
|
||||||
|
}
|
||||||
|
if (i < Rasterizer2D.leftX) {
|
||||||
|
int k2 = Rasterizer2D.leftX - i;
|
||||||
|
k1 -= k2;
|
||||||
|
i = Rasterizer2D.leftX;
|
||||||
|
i1 += k2;
|
||||||
|
l += k2;
|
||||||
|
i2 += k2;
|
||||||
|
l1 += k2;
|
||||||
|
}
|
||||||
|
if (i + k1 > Rasterizer2D.bottomX) {
|
||||||
|
int l2 = (i + k1) - Rasterizer2D.bottomX;
|
||||||
|
k1 -= l2;
|
||||||
|
i2 += l2;
|
||||||
|
l1 += l2;
|
||||||
|
}
|
||||||
|
if (!(k1 <= 0 || j1 <= 0)) {
|
||||||
|
method349(Rasterizer2D.pixels, tempArray, i1, l, k1, j1, l1, i2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawSprite2(int i, int j) {
|
||||||
|
int k = 225;// was parameter
|
||||||
|
i += offsetX;
|
||||||
|
j += offsetY;
|
||||||
|
int i1 = i + j * Rasterizer2D.width;
|
||||||
|
int j1 = 0;
|
||||||
|
int k1 = myHeight;
|
||||||
|
int l1 = myWidth;
|
||||||
|
int i2 = Rasterizer2D.width - l1;
|
||||||
|
int j2 = 0;
|
||||||
|
if (j < Rasterizer2D.topY) {
|
||||||
|
int k2 = Rasterizer2D.topY - j;
|
||||||
|
k1 -= k2;
|
||||||
|
j = Rasterizer2D.topY;
|
||||||
|
j1 += k2 * l1;
|
||||||
|
i1 += k2 * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (j + k1 > Rasterizer2D.bottomY)
|
||||||
|
k1 -= (j + k1) - Rasterizer2D.bottomY;
|
||||||
|
if (i < Rasterizer2D.leftX) {
|
||||||
|
int l2 = Rasterizer2D.leftX - i;
|
||||||
|
l1 -= l2;
|
||||||
|
i = Rasterizer2D.leftX;
|
||||||
|
j1 += l2;
|
||||||
|
i1 += l2;
|
||||||
|
j2 += l2;
|
||||||
|
i2 += l2;
|
||||||
|
}
|
||||||
|
if (i + l1 > Rasterizer2D.bottomX) {
|
||||||
|
int i3 = (i + l1) - Rasterizer2D.bottomX;
|
||||||
|
l1 -= i3;
|
||||||
|
j2 += i3;
|
||||||
|
i2 += i3;
|
||||||
|
}
|
||||||
|
if (!(l1 <= 0 || k1 <= 0)) {
|
||||||
|
method351(j1, l1, Rasterizer2D.pixels, myPixels, j2, k1, i2, k, i1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method349(int ai[], int ai1[], int j, int k, int l, int i1, int j1, int k1) {
|
||||||
|
int i;// was parameter
|
||||||
|
int l1 = -(l >> 2);
|
||||||
|
l = -(l & 3);
|
||||||
|
for (int i2 = -i1; i2 < 0; i2++) {
|
||||||
|
for (int j2 = l1; j2 < 0; j2++) {
|
||||||
|
i = ai1[j++];
|
||||||
|
if (i != 0 && i != -1) {
|
||||||
|
ai[k++] = i;
|
||||||
|
} else {
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
i = ai1[j++];
|
||||||
|
if (i != 0 && i != -1) {
|
||||||
|
ai[k++] = i;
|
||||||
|
} else {
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
i = ai1[j++];
|
||||||
|
if (i != 0 && i != -1) {
|
||||||
|
ai[k++] = i;
|
||||||
|
} else {
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
i = ai1[j++];
|
||||||
|
if (i != 0 && i != -1) {
|
||||||
|
ai[k++] = i;
|
||||||
|
} else {
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k2 = l; k2 < 0; k2++) {
|
||||||
|
i = ai1[j++];
|
||||||
|
if (i != 0 && i != -1) {
|
||||||
|
ai[k++] = i;
|
||||||
|
} else {
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
k += j1;
|
||||||
|
j += k1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method351(int i, int j, int ai[], int ai1[], int l, int i1, int j1, int k1, int l1) {
|
||||||
|
int k;// was parameter
|
||||||
|
int j2 = 256 - k1;
|
||||||
|
for (int k2 = -i1; k2 < 0; k2++) {
|
||||||
|
for (int l2 = -j; l2 < 0; l2++) {
|
||||||
|
k = ai1[i++];
|
||||||
|
if (k != 0) {
|
||||||
|
int i3 = ai[l1];
|
||||||
|
ai[l1++] = ((k & 0xff00ff) * k1 + (i3 & 0xff00ff) * j2 & 0xff00ff00) + ((k & 0xff00) * k1 + (i3 & 0xff00) * j2 & 0xff0000) >> 8;
|
||||||
|
} else {
|
||||||
|
l1++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
l1 += j1;
|
||||||
|
i += l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rotate(int i, int j, int ai[], int k, int ai1[], int i1, int j1, int k1, int l1, int i2) {
|
||||||
|
try {
|
||||||
|
int j2 = -l1 / 2;
|
||||||
|
int k2 = -i / 2;
|
||||||
|
int l2 = (int) (Math.sin((double) j / 326.11000000000001D) * 65536D);
|
||||||
|
int i3 = (int) (Math.cos((double) j / 326.11000000000001D) * 65536D);
|
||||||
|
l2 = l2 * k >> 8;
|
||||||
|
i3 = i3 * k >> 8;
|
||||||
|
int j3 = (i2 << 16) + (k2 * l2 + j2 * i3);
|
||||||
|
int k3 = (i1 << 16) + (k2 * i3 - j2 * l2);
|
||||||
|
int l3 = k1 + j1 * Rasterizer2D.width;
|
||||||
|
for (j1 = 0; j1 < i; j1++) {
|
||||||
|
int i4 = ai1[j1];
|
||||||
|
int j4 = l3 + i4;
|
||||||
|
int k4 = j3 + i3 * i4;
|
||||||
|
int l4 = k3 - l2 * i4;
|
||||||
|
for (k1 = -ai[j1]; k1 < 0; k1++) {
|
||||||
|
int x1 = k4 >> 16;
|
||||||
|
int y1 = l4 >> 16;
|
||||||
|
int x2 = x1 + 1;
|
||||||
|
int y2 = y1 + 1;
|
||||||
|
int c1 = myPixels[x1 + y1 * myWidth];
|
||||||
|
int c2 = myPixels[x2 + y1 * myWidth];
|
||||||
|
int c3 = myPixels[x1 + y2 * myWidth];
|
||||||
|
int c4 = myPixels[x2 + y2 * myWidth];
|
||||||
|
int u1 = (k4 >> 8) - (x1 << 8);
|
||||||
|
int v1 = (l4 >> 8) - (y1 << 8);
|
||||||
|
int u2 = (x2 << 8) - (k4 >> 8);
|
||||||
|
int v2 = (y2 << 8) - (l4 >> 8);
|
||||||
|
int a1 = u2 * v2;
|
||||||
|
int a2 = u1 * v2;
|
||||||
|
int a3 = u2 * v1;
|
||||||
|
int a4 = u1 * v1;
|
||||||
|
int r = (c1 >> 16 & 0xff) * a1 + (c2 >> 16 & 0xff) * a2 + (c3 >> 16 & 0xff) * a3 + (c4 >> 16 & 0xff) * a4 & 0xff0000;
|
||||||
|
int g = (c1 >> 8 & 0xff) * a1 + (c2 >> 8 & 0xff) * a2 + (c3 >> 8 & 0xff) * a3 + (c4 >> 8 & 0xff) * a4 >> 8 & 0xff00;
|
||||||
|
int b = (c1 & 0xff) * a1 + (c2 & 0xff) * a2 + (c3 & 0xff) * a3 + (c4 & 0xff) * a4 >> 16;
|
||||||
|
Rasterizer2D.pixels[j4++] = r | g | b;
|
||||||
|
k4 += i3;
|
||||||
|
l4 -= l2;
|
||||||
|
}
|
||||||
|
|
||||||
|
j3 += l2;
|
||||||
|
k3 += i3;
|
||||||
|
l3 += Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method353(int i, double d, int l1) {
|
||||||
|
// all of the following were parameters
|
||||||
|
int j = 15;
|
||||||
|
int k = 20;
|
||||||
|
int l = 15;
|
||||||
|
int j1 = 256;
|
||||||
|
int k1 = 20;
|
||||||
|
// all of the previous were parameters
|
||||||
|
try {
|
||||||
|
int i2 = -k / 2;
|
||||||
|
int j2 = -k1 / 2;
|
||||||
|
int k2 = (int) (Math.sin(d) * 65536D);
|
||||||
|
int l2 = (int) (Math.cos(d) * 65536D);
|
||||||
|
k2 = k2 * j1 >> 8;
|
||||||
|
l2 = l2 * j1 >> 8;
|
||||||
|
int i3 = (l << 16) + (j2 * k2 + i2 * l2);
|
||||||
|
int j3 = (j << 16) + (j2 * l2 - i2 * k2);
|
||||||
|
int k3 = l1 + i * Rasterizer2D.width;
|
||||||
|
for (i = 0; i < k1; i++) {
|
||||||
|
int l3 = k3;
|
||||||
|
int i4 = i3;
|
||||||
|
int j4 = j3;
|
||||||
|
for (l1 = -k; l1 < 0; l1++) {
|
||||||
|
int k4 = myPixels[(i4 >> 16) + (j4 >> 16) * myWidth];
|
||||||
|
if (k4 != 0)
|
||||||
|
Rasterizer2D.pixels[l3++] = k4;
|
||||||
|
else
|
||||||
|
l3++;
|
||||||
|
i4 += l2;
|
||||||
|
j4 -= k2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i3 += k2;
|
||||||
|
j3 += l2;
|
||||||
|
k3 += Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite(byte spriteData[]) {
|
||||||
|
try {
|
||||||
|
Image image = Toolkit.getDefaultToolkit().createImage(spriteData);
|
||||||
|
ImageIcon sprite = new ImageIcon(image);
|
||||||
|
myWidth = sprite.getIconWidth();
|
||||||
|
myHeight = sprite.getIconHeight();
|
||||||
|
maxWidth = myWidth;
|
||||||
|
maxHeight = myHeight;
|
||||||
|
offsetX = 0;
|
||||||
|
offsetY = 0;
|
||||||
|
myPixels = new int[myWidth * myHeight];
|
||||||
|
PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, myWidth, myHeight, myPixels, 0, myWidth);
|
||||||
|
pixelgrabber.grabPixels();
|
||||||
|
image = null;
|
||||||
|
setTransparency(255, 0, 255);
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
System.out.println(_ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method354(IndexedImage background, int i, int j) {
|
||||||
|
j += offsetX;
|
||||||
|
i += offsetY;
|
||||||
|
int k = j + i * Rasterizer2D.width;
|
||||||
|
int l = 0;
|
||||||
|
int i1 = myHeight;
|
||||||
|
int j1 = myWidth;
|
||||||
|
int k1 = Rasterizer2D.width - j1;
|
||||||
|
int l1 = 0;
|
||||||
|
if (i < Rasterizer2D.topY) {
|
||||||
|
int i2 = Rasterizer2D.topY - i;
|
||||||
|
i1 -= i2;
|
||||||
|
i = Rasterizer2D.topY;
|
||||||
|
l += i2 * j1;
|
||||||
|
k += i2 * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (i + i1 > Rasterizer2D.bottomY)
|
||||||
|
i1 -= (i + i1) - Rasterizer2D.bottomY;
|
||||||
|
if (j < Rasterizer2D.leftX) {
|
||||||
|
int j2 = Rasterizer2D.leftX - j;
|
||||||
|
j1 -= j2;
|
||||||
|
j = Rasterizer2D.leftX;
|
||||||
|
l += j2;
|
||||||
|
k += j2;
|
||||||
|
l1 += j2;
|
||||||
|
k1 += j2;
|
||||||
|
}
|
||||||
|
if (j + j1 > Rasterizer2D.bottomX) {
|
||||||
|
int k2 = (j + j1) - Rasterizer2D.bottomX;
|
||||||
|
j1 -= k2;
|
||||||
|
l1 += k2;
|
||||||
|
k1 += k2;
|
||||||
|
}
|
||||||
|
if (!(j1 <= 0 || i1 <= 0)) {
|
||||||
|
method355(myPixels, j1, background.palettePixels, i1, Rasterizer2D.pixels, 0, k1, k, l1, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawARGBSprite(int xPos, int yPos) {
|
||||||
|
drawARGBSprite(xPos, yPos, 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawARGBSprite(int xPos, int yPos, int alpha) {
|
||||||
|
int alphaValue = alpha;
|
||||||
|
xPos += offsetX;
|
||||||
|
yPos += offsetY;
|
||||||
|
int i1 = xPos + yPos * Rasterizer2D.width;
|
||||||
|
int j1 = 0;
|
||||||
|
int spriteHeight = myHeight;
|
||||||
|
int spriteWidth = myWidth;
|
||||||
|
int i2 = Rasterizer2D.width - spriteWidth;
|
||||||
|
int j2 = 0;
|
||||||
|
if (yPos < Rasterizer2D.topY) {
|
||||||
|
int k2 = Rasterizer2D.topY - yPos;
|
||||||
|
spriteHeight -= k2;
|
||||||
|
yPos = Rasterizer2D.topY;
|
||||||
|
j1 += k2 * spriteWidth;
|
||||||
|
i1 += k2 * Rasterizer2D.width;
|
||||||
|
}
|
||||||
|
if (yPos + spriteHeight > Rasterizer2D.bottomY)
|
||||||
|
spriteHeight -= (yPos + spriteHeight) - Rasterizer2D.bottomY;
|
||||||
|
if (xPos < Rasterizer2D.leftX) {
|
||||||
|
int l2 = Rasterizer2D.leftX - xPos;
|
||||||
|
spriteWidth -= l2;
|
||||||
|
xPos = Rasterizer2D.leftX;
|
||||||
|
j1 += l2;
|
||||||
|
i1 += l2;
|
||||||
|
j2 += l2;
|
||||||
|
i2 += l2;
|
||||||
|
}
|
||||||
|
if (xPos + spriteWidth > Rasterizer2D.bottomX) {
|
||||||
|
int i3 = (xPos + spriteWidth) - Rasterizer2D.bottomX;
|
||||||
|
spriteWidth -= i3;
|
||||||
|
j2 += i3;
|
||||||
|
i2 += i3;
|
||||||
|
}
|
||||||
|
if (!(spriteWidth <= 0 || spriteHeight <= 0)) {
|
||||||
|
renderARGBPixels(spriteWidth, spriteHeight, myPixels, Rasterizer2D.pixels, i1, alphaValue, j1, j2, i2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderARGBPixels(int spriteWidth, int spriteHeight, int spritePixels[], int renderAreaPixels[], int pixel, int alphaValue, int i, int l, int j1) {
|
||||||
|
int pixelColor;
|
||||||
|
int alphaLevel;
|
||||||
|
int alpha = alphaValue;
|
||||||
|
for (int height = -spriteHeight; height < 0; height++) {
|
||||||
|
for (int width = -spriteWidth; width < 0; width++) {
|
||||||
|
alphaValue = ((myPixels[i] >> 24) & (alpha - 1));
|
||||||
|
alphaLevel = 256 - alphaValue;
|
||||||
|
if (alphaLevel > 256) {
|
||||||
|
alphaValue = 0;
|
||||||
|
}
|
||||||
|
if (alpha == 0) {
|
||||||
|
alphaLevel = 256;
|
||||||
|
alphaValue = 0;
|
||||||
|
}
|
||||||
|
pixelColor = spritePixels[i++];
|
||||||
|
if (pixelColor != 0) {
|
||||||
|
int pixelValue = renderAreaPixels[pixel];
|
||||||
|
renderAreaPixels[pixel++] = ((pixelColor & 0xff00ff) * alphaValue + (pixelValue & 0xff00ff) * alphaLevel & 0xff00ff00) + ((pixelColor & 0xff00) * alphaValue + (pixelValue & 0xff00) * alphaLevel & 0xff0000) >> 8;
|
||||||
|
} else {
|
||||||
|
pixel++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pixel += j1;
|
||||||
|
i += l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method355(int ai[], int i, byte abyte0[], int j, int ai1[], int k, int l, int i1, int j1, int k1) {
|
||||||
|
int l1 = -(i >> 2);
|
||||||
|
i = -(i & 3);
|
||||||
|
for (int j2 = -j; j2 < 0; j2++) {
|
||||||
|
for (int k2 = l1; k2 < 0; k2++) {
|
||||||
|
k = ai[k1++];
|
||||||
|
if (k != 0 && abyte0[i1] == 0)
|
||||||
|
ai1[i1++] = k;
|
||||||
|
else
|
||||||
|
i1++;
|
||||||
|
k = ai[k1++];
|
||||||
|
if (k != 0 && abyte0[i1] == 0)
|
||||||
|
ai1[i1++] = k;
|
||||||
|
else
|
||||||
|
i1++;
|
||||||
|
k = ai[k1++];
|
||||||
|
if (k != 0 && abyte0[i1] == 0)
|
||||||
|
ai1[i1++] = k;
|
||||||
|
else
|
||||||
|
i1++;
|
||||||
|
k = ai[k1++];
|
||||||
|
if (k != 0 && abyte0[i1] == 0)
|
||||||
|
ai1[i1++] = k;
|
||||||
|
else
|
||||||
|
i1++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int l2 = i; l2 < 0; l2++) {
|
||||||
|
k = ai[k1++];
|
||||||
|
if (k != 0 && abyte0[i1] == 0)
|
||||||
|
ai1[i1++] = k;
|
||||||
|
else
|
||||||
|
i1++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i1 += l;
|
||||||
|
k1 += j1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getMyPixels() {
|
||||||
|
return myPixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMyPixels(int[] myPixels) {
|
||||||
|
this.myPixels = myPixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMyWidth() {
|
||||||
|
return myWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMyWidth(int myWidth) {
|
||||||
|
this.myWidth = myWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMyHeight() {
|
||||||
|
return myHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMyHeight(int myHeight) {
|
||||||
|
this.myHeight = myHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOffsetX() {
|
||||||
|
return offsetX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffsetX(int offsetX) {
|
||||||
|
this.offsetX = offsetX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOffsetY() {
|
||||||
|
return offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffsetY(int offsetY) {
|
||||||
|
this.offsetY = offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxWidth() {
|
||||||
|
return maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxWidth(int maxWidth) {
|
||||||
|
this.maxWidth = maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxHeight() {
|
||||||
|
return maxHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxHeight(int maxHeight) {
|
||||||
|
this.maxHeight = maxHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
package org.rebotted.cache.graphics;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
|
||||||
|
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
import org.rebotted.sign.SignLink;
|
||||||
|
import org.rebotted.util.FileUtils;
|
||||||
|
|
||||||
|
public final class SpriteCache {
|
||||||
|
|
||||||
|
private static Sprite[] sprites;
|
||||||
|
|
||||||
|
private static int totalSprites;
|
||||||
|
|
||||||
|
public static void load() {
|
||||||
|
Buffer data = new Buffer(FileUtils.readFile(SignLink.findcachedir() + "main_file_sprites.dat"));
|
||||||
|
|
||||||
|
try (DataInputStream dataFile = new DataInputStream(new XZCompressorInputStream(new ByteArrayInputStream(data.payload)))) {
|
||||||
|
|
||||||
|
int totalSprites = dataFile.readInt();
|
||||||
|
|
||||||
|
sprites = new Sprite[totalSprites];
|
||||||
|
|
||||||
|
for (int index = 0; index < totalSprites; index++) {
|
||||||
|
sprites[index] = SpriteCache.decode(dataFile);
|
||||||
|
|
||||||
|
sprites[index].setTransparency(255, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Sprites Loaded: " + totalSprites);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Sprite decode(DataInputStream dat) throws IOException {
|
||||||
|
|
||||||
|
Sprite sprite = new Sprite();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
|
||||||
|
byte opcode = dat.readByte();
|
||||||
|
|
||||||
|
if (opcode == 0) {
|
||||||
|
return sprite;
|
||||||
|
} else if (opcode == 1) {
|
||||||
|
sprite.setId(dat.readShort());
|
||||||
|
} else if (opcode == 2) {
|
||||||
|
sprite.setName(dat.readUTF());
|
||||||
|
} else if (opcode == 3) {
|
||||||
|
sprite.setMyWidth(dat.readShort());
|
||||||
|
} else if (opcode == 4) {
|
||||||
|
sprite.setMyHeight(dat.readShort());
|
||||||
|
} else if (opcode == 5) {
|
||||||
|
sprite.setOffsetX(dat.readShort());
|
||||||
|
} else if (opcode == 6) {
|
||||||
|
sprite.setOffsetY(dat.readShort());
|
||||||
|
} else if (opcode == 7) {
|
||||||
|
|
||||||
|
int indexLength = dat.readInt();
|
||||||
|
|
||||||
|
int[] pixels = new int[indexLength];
|
||||||
|
|
||||||
|
for (int i = 0; i < pixels.length; i++) {
|
||||||
|
pixels[i] = dat.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
sprite.setMyPixels(pixels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite[] getSprites() {
|
||||||
|
return sprites;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Sprite lookup(int id) {
|
||||||
|
if (id < 0 || id > sprites.length) {
|
||||||
|
throw new IllegalArgumentException(String.format("Invalid id: %d while trying to lookup a sprite.", id));
|
||||||
|
}
|
||||||
|
return sprites[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(int id, Sprite sprite) {
|
||||||
|
if (id < 0 || id > sprites.length) {
|
||||||
|
throw new IllegalArgumentException(String.format("Invalid id: %d while trying to lookup a sprite.", id));
|
||||||
|
}
|
||||||
|
sprites[id] = sprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int totalSprites() {
|
||||||
|
return totalSprites;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+2077
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,133 @@
|
|||||||
|
package org.rebotted.cache.idk;
|
||||||
|
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
public final class IdentityKit {
|
||||||
|
|
||||||
|
public static int length;
|
||||||
|
public static IdentityKit kits[];
|
||||||
|
public int bodyPartId;
|
||||||
|
private int[] bodyModels;
|
||||||
|
private final int[] originalColors;
|
||||||
|
private final int[] replacementColors;
|
||||||
|
private final int[] headModels = { -1, -1, -1, -1, -1 };
|
||||||
|
public boolean validStyle;
|
||||||
|
|
||||||
|
private IdentityKit() {
|
||||||
|
bodyPartId = -1;
|
||||||
|
originalColors = new int[6];
|
||||||
|
replacementColors = new int[6];
|
||||||
|
validStyle = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(FileArchive archive) {
|
||||||
|
Buffer buffer = new Buffer(archive.readFile("idk.dat"));
|
||||||
|
|
||||||
|
length = buffer.readUShort();
|
||||||
|
if (kits == null) {
|
||||||
|
kits = new IdentityKit[length];
|
||||||
|
}
|
||||||
|
for (int id = 0; id < length; id++) {
|
||||||
|
if (kits[id] == null) {
|
||||||
|
kits[id] = new IdentityKit();
|
||||||
|
}
|
||||||
|
kits[id].decode(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decode(Buffer buffer) {
|
||||||
|
while(true) {
|
||||||
|
|
||||||
|
int opcode = buffer.readUnsignedByte();
|
||||||
|
|
||||||
|
if (opcode == 0) {
|
||||||
|
return;
|
||||||
|
} else if (opcode == 1) {
|
||||||
|
bodyPartId = buffer.readUnsignedByte();
|
||||||
|
} else if (opcode == 2) {
|
||||||
|
int count = buffer.readUnsignedByte();
|
||||||
|
bodyModels = new int[count];
|
||||||
|
for (int part = 0; part < count; part++) {
|
||||||
|
bodyModels[part] = buffer.readUShort();
|
||||||
|
}
|
||||||
|
} else if (opcode == 3) {
|
||||||
|
validStyle = true;
|
||||||
|
} else if (opcode >= 40 && opcode < 50) {
|
||||||
|
originalColors[opcode - 40] = buffer.readUShort();
|
||||||
|
} else if (opcode >= 50 && opcode < 60) {
|
||||||
|
replacementColors[opcode - 50] = buffer.readUShort();
|
||||||
|
} else if (opcode >= 60 && opcode < 70) {
|
||||||
|
headModels[opcode - 60] = buffer.readUShort();
|
||||||
|
} else {
|
||||||
|
System.out.println("Error unrecognised config code: " + opcode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean bodyLoaded() {
|
||||||
|
if (bodyModels == null)
|
||||||
|
return true;
|
||||||
|
boolean ready = true;
|
||||||
|
for (int part = 0; part < bodyModels.length; part++)
|
||||||
|
if (!Model.isCached(bodyModels[part]))
|
||||||
|
ready = false;
|
||||||
|
|
||||||
|
return ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model bodyModel() {
|
||||||
|
if (bodyModels == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Model models[] = new Model[bodyModels.length];
|
||||||
|
for (int part = 0; part < bodyModels.length; part++) {
|
||||||
|
models[part] = Model.getModel(bodyModels[part]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Model model;
|
||||||
|
if (models.length == 1) {
|
||||||
|
model = models[0];
|
||||||
|
} else {
|
||||||
|
model = new Model(models.length, models);
|
||||||
|
}
|
||||||
|
for (int part = 0; part < 6; part++) {
|
||||||
|
if (originalColors[part] == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
model.recolor(originalColors[part], replacementColors[part]);
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean headLoaded() {
|
||||||
|
boolean ready = true;
|
||||||
|
for (int part = 0; part < 5; part++) {
|
||||||
|
if (headModels[part] != -1 && !Model.isCached(headModels[part])) {
|
||||||
|
ready = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model headModel() {
|
||||||
|
Model models[] = new Model[5];
|
||||||
|
int count = 0;
|
||||||
|
for (int part = 0; part < 5; part++) {
|
||||||
|
if (headModels[part] != -1) {
|
||||||
|
models[count++] = Model.getModel(headModels[part]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Model model = new Model(count, models);
|
||||||
|
for (int part = 0; part < 6; part++) {
|
||||||
|
if (originalColors[part] == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
model.recolor(originalColors[part], replacementColors[part]);
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.rebotted.collection;
|
||||||
|
|
||||||
|
public class Cacheable extends Linkable {
|
||||||
|
|
||||||
|
public Cacheable nextCacheable;
|
||||||
|
public Cacheable previousCacheable;
|
||||||
|
|
||||||
|
public final void unlinkCacheable() {
|
||||||
|
if (previousCacheable == null) {
|
||||||
|
} else {
|
||||||
|
previousCacheable.nextCacheable = nextCacheable;
|
||||||
|
nextCacheable.previousCacheable = previousCacheable;
|
||||||
|
nextCacheable = null;
|
||||||
|
previousCacheable = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package org.rebotted.collection;
|
||||||
|
|
||||||
|
public final class Deque {
|
||||||
|
|
||||||
|
private final Linkable head;
|
||||||
|
private Linkable current;
|
||||||
|
|
||||||
|
public Deque() {
|
||||||
|
head = new Linkable();
|
||||||
|
head.previous = head;
|
||||||
|
head.next = head;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertHead(Linkable linkable) {
|
||||||
|
if (linkable.next != null)
|
||||||
|
linkable.unlink();
|
||||||
|
linkable.next = head.next;
|
||||||
|
linkable.previous = head;
|
||||||
|
linkable.next.previous = linkable;
|
||||||
|
linkable.previous.next = linkable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertTail(Linkable linkable) {
|
||||||
|
if (linkable.next != null)
|
||||||
|
linkable.unlink();
|
||||||
|
linkable.next = head;
|
||||||
|
linkable.previous = head.previous;
|
||||||
|
linkable.next.previous = linkable;
|
||||||
|
linkable.previous.next = linkable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Linkable popHead() {
|
||||||
|
Linkable node = head.previous;
|
||||||
|
if (node == head) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
node.unlink();
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Linkable reverseGetFirst() {
|
||||||
|
Linkable node = head.previous;
|
||||||
|
if (node == head) {
|
||||||
|
current = null;
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
current = node.previous;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Linkable getFirst() {
|
||||||
|
Linkable node = head.next;
|
||||||
|
if (node == head) {
|
||||||
|
current = null;
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
current = node.next;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Linkable reverseGetNext() {
|
||||||
|
Linkable node = current;
|
||||||
|
if (node == head) {
|
||||||
|
current = null;
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
current = node.previous;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Linkable getNext() {
|
||||||
|
Linkable node = current;
|
||||||
|
if (node == head) {
|
||||||
|
current = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
current = node.next;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
if (head.previous == head)
|
||||||
|
return;
|
||||||
|
do {
|
||||||
|
Linkable node = head.previous;
|
||||||
|
if (node == head)
|
||||||
|
return;
|
||||||
|
node.unlink();
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package org.rebotted.collection;
|
||||||
|
|
||||||
|
import org.rebotted.sign.SignLink;
|
||||||
|
|
||||||
|
final class HashTable {
|
||||||
|
|
||||||
|
private final int bucketCount;
|
||||||
|
private final Linkable[] buckets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the HashTable with the specified size.
|
||||||
|
*/
|
||||||
|
public HashTable() {
|
||||||
|
int size = 1024;// was parameter
|
||||||
|
bucketCount = size;
|
||||||
|
buckets = new Linkable[size];
|
||||||
|
for (int index = 0; index < size; index++) {
|
||||||
|
Linkable node = buckets[index] = new Linkable();
|
||||||
|
node.previous = node;
|
||||||
|
node.next = node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Linkable} with the specified {@code key} from this
|
||||||
|
* HashTable.
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* The key.
|
||||||
|
* @return The Linkable, or {@code null} if this HashTable does not contain
|
||||||
|
* an associated for the specified key.
|
||||||
|
*/
|
||||||
|
public Linkable get(long key) {
|
||||||
|
Linkable linkable = buckets[(int) (key & (long) (bucketCount - 1))];
|
||||||
|
for (Linkable next = linkable.previous; next != linkable; next = next.previous)
|
||||||
|
if (next.key == key)
|
||||||
|
return next;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Associates the specified {@link Linkable} with the specified {@code key}.
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* The key.
|
||||||
|
* @param linkable
|
||||||
|
* The Linkable.
|
||||||
|
*/
|
||||||
|
public void put(Linkable linkable, long key) {
|
||||||
|
try {
|
||||||
|
if (linkable.next != null)
|
||||||
|
linkable.unlink();
|
||||||
|
Linkable current = buckets[(int) (key & (long) (bucketCount - 1))];
|
||||||
|
linkable.next = current.next;
|
||||||
|
linkable.previous = current;
|
||||||
|
linkable.next.previous = linkable;
|
||||||
|
linkable.previous.next = linkable;
|
||||||
|
linkable.key = key;
|
||||||
|
return;
|
||||||
|
} catch (RuntimeException runtimeexception) {
|
||||||
|
SignLink.reporterror("91499, " + linkable + ", " + key + ", "
|
||||||
|
+ (byte) 7 + ", " + runtimeexception.toString());
|
||||||
|
}
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.rebotted.collection;
|
||||||
|
|
||||||
|
public class Linkable {
|
||||||
|
|
||||||
|
public long key;
|
||||||
|
public Linkable previous;
|
||||||
|
public Linkable next;
|
||||||
|
|
||||||
|
public final void unlink() {
|
||||||
|
if (next == null) {
|
||||||
|
} else {
|
||||||
|
next.previous = previous;
|
||||||
|
previous.next = next;
|
||||||
|
previous = null;
|
||||||
|
next = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package org.rebotted.collection;
|
||||||
|
|
||||||
|
public final class Queue {
|
||||||
|
|
||||||
|
private final Cacheable head;
|
||||||
|
private Cacheable current;
|
||||||
|
|
||||||
|
public Queue() {
|
||||||
|
head = new Cacheable();
|
||||||
|
head.nextCacheable = head;
|
||||||
|
head.previousCacheable = head;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertHead(Cacheable node) {
|
||||||
|
if (node.previousCacheable != null)
|
||||||
|
node.unlinkCacheable();
|
||||||
|
node.previousCacheable = head.previousCacheable;
|
||||||
|
node.nextCacheable = head;
|
||||||
|
node.previousCacheable.nextCacheable = node;
|
||||||
|
node.nextCacheable.previousCacheable = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cacheable popTail() {
|
||||||
|
Cacheable next = head.nextCacheable;
|
||||||
|
if (next == head) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
next.unlinkCacheable();
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cacheable reverseGetFirst() {
|
||||||
|
Cacheable nodeSub = head.nextCacheable;
|
||||||
|
if (nodeSub == head) {
|
||||||
|
current = null;
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
current = nodeSub.nextCacheable;
|
||||||
|
return nodeSub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cacheable reverseGetNext() {
|
||||||
|
Cacheable next = current;
|
||||||
|
if (next == head) {
|
||||||
|
current = null;
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
current = next.nextCacheable;
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
int count = 0;
|
||||||
|
for (Cacheable nodeSub = head.nextCacheable; nodeSub != head; nodeSub = nodeSub.nextCacheable)
|
||||||
|
count++;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package org.rebotted.collection;
|
||||||
|
import org.rebotted.sign.SignLink;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A least-recently used cache of references, backed by a {@link HashTable} and a {@link Queue}.
|
||||||
|
*/
|
||||||
|
public final class ReferenceCache {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The empty cacheable.
|
||||||
|
*/
|
||||||
|
private final Cacheable empty;
|
||||||
|
/**
|
||||||
|
* The capacity of this cache.
|
||||||
|
*/
|
||||||
|
private final int capacity;
|
||||||
|
/**
|
||||||
|
* The amount of unused slots in this cache.
|
||||||
|
*/
|
||||||
|
private int spaceLeft;
|
||||||
|
/**
|
||||||
|
* The HashTable backing this cache.
|
||||||
|
*/
|
||||||
|
private final HashTable table;
|
||||||
|
/**
|
||||||
|
* The queue of references, used for LRU behaviour.
|
||||||
|
*/
|
||||||
|
private final Queue references;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the ReferenceCache.
|
||||||
|
*
|
||||||
|
* @param capacity The capacity of this cache.
|
||||||
|
*/
|
||||||
|
public ReferenceCache(int i) {
|
||||||
|
empty = new Cacheable();
|
||||||
|
references = new Queue();
|
||||||
|
capacity = i;
|
||||||
|
spaceLeft = i;
|
||||||
|
table = new HashTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link Cacheable} with the specified key.
|
||||||
|
*
|
||||||
|
* @param key The key.
|
||||||
|
* @return The Cacheable.
|
||||||
|
*/
|
||||||
|
public Cacheable get(long key) {
|
||||||
|
Cacheable cacheable = (Cacheable) table.get(key);
|
||||||
|
if (cacheable != null) {
|
||||||
|
references.insertHead(cacheable);
|
||||||
|
}
|
||||||
|
return cacheable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(Cacheable node, long key) {
|
||||||
|
try {
|
||||||
|
if (spaceLeft == 0) {
|
||||||
|
Cacheable front = references.popTail();
|
||||||
|
front.unlink();
|
||||||
|
front.unlinkCacheable();
|
||||||
|
if (front == empty) {
|
||||||
|
front = references.popTail();
|
||||||
|
front.unlink();
|
||||||
|
front.unlinkCacheable();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
spaceLeft--;
|
||||||
|
}
|
||||||
|
table.put(node, key);
|
||||||
|
references.insertHead(node);
|
||||||
|
return;
|
||||||
|
} catch (RuntimeException runtimeexception) {
|
||||||
|
SignLink.reporterror("47547, " + node + ", " + key + ", " + (byte) 2 + ", " + runtimeexception.toString());
|
||||||
|
}
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the contents of this ReferenceCache.
|
||||||
|
*/
|
||||||
|
public void clear() {
|
||||||
|
do {
|
||||||
|
Cacheable front = references.popTail();
|
||||||
|
if (front != null) {
|
||||||
|
front.unlink();
|
||||||
|
front.unlinkCacheable();
|
||||||
|
} else {
|
||||||
|
spaceLeft = capacity;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.rebotted.draw;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.DataBufferInt;
|
||||||
|
|
||||||
|
public final class ProducingGraphicsBuffer {
|
||||||
|
|
||||||
|
public final int[] canvasRaster;
|
||||||
|
public final int canvasWidth;
|
||||||
|
public final int canvasHeight;
|
||||||
|
private final BufferedImage bufferedImage;
|
||||||
|
private float[] depthbuffer;
|
||||||
|
|
||||||
|
public ProducingGraphicsBuffer(int canvasWidth, int canvasHeight) {
|
||||||
|
this.canvasWidth = canvasWidth;
|
||||||
|
this.canvasHeight = canvasHeight;
|
||||||
|
depthbuffer = new float [canvasWidth * canvasHeight];
|
||||||
|
bufferedImage = new BufferedImage(canvasWidth, canvasHeight, BufferedImage.TYPE_INT_RGB);
|
||||||
|
canvasRaster = ((DataBufferInt) bufferedImage.getRaster().getDataBuffer()).getData();
|
||||||
|
initDrawingArea();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawGraphics(int x, Graphics graphics, int y) {
|
||||||
|
graphics.drawImage(bufferedImage, y, x, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initDrawingArea() {
|
||||||
|
Rasterizer2D.initDrawingArea(canvasHeight, canvasWidth, canvasRaster, depthbuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,341 @@
|
|||||||
|
package org.rebotted.draw;
|
||||||
|
import org.rebotted.collection.Cacheable;
|
||||||
|
|
||||||
|
public class Rasterizer2D extends Cacheable {
|
||||||
|
/**
|
||||||
|
* Sets the Rasterizer2D in the upper left corner with height, width and pixels set.
|
||||||
|
* @param height The height of the drawingArea.
|
||||||
|
* @param width The width of the drawingArea.
|
||||||
|
* @param pixels The array of pixels (RGBColours) in the drawingArea.
|
||||||
|
* @param depth An array of fog depths.
|
||||||
|
*/
|
||||||
|
public static void initDrawingArea(int height, int width, int pixels[], float depth[]) {
|
||||||
|
depthBuffer = depth;
|
||||||
|
Rasterizer2D.pixels = pixels;
|
||||||
|
Rasterizer2D.width = width;
|
||||||
|
Rasterizer2D.height = height;
|
||||||
|
setDrawingArea(height, 0, width, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a transparent box with a gradient that changes from top to bottom.
|
||||||
|
* @param leftX The left edge X-Coordinate of the box.
|
||||||
|
* @param topY The top edge Y-Coordinate of the box.
|
||||||
|
* @param width The width of the box.
|
||||||
|
* @param height The height of the box.
|
||||||
|
* @param topColour The top rgbColour of the gradient.
|
||||||
|
* @param bottomColour The bottom rgbColour of the gradient.
|
||||||
|
* @param opacity The opacity value ranging from 0 to 256.
|
||||||
|
*/
|
||||||
|
public static void drawTransparentGradientBox(int leftX, int topY, int width, int height, int topColour, int bottomColour, int opacity) {
|
||||||
|
int gradientProgress = 0;
|
||||||
|
int progressPerPixel = 0x10000 / height;
|
||||||
|
if(leftX < Rasterizer2D.leftX) {
|
||||||
|
width -= Rasterizer2D.leftX - leftX;
|
||||||
|
leftX = Rasterizer2D.leftX;
|
||||||
|
}
|
||||||
|
if(topY < Rasterizer2D.topY) {
|
||||||
|
gradientProgress += (Rasterizer2D.topY - topY) * progressPerPixel;
|
||||||
|
height -= Rasterizer2D.topY - topY;
|
||||||
|
topY = Rasterizer2D.topY;
|
||||||
|
}
|
||||||
|
if(leftX + width > bottomX)
|
||||||
|
width = bottomX - leftX;
|
||||||
|
if(topY + height > bottomY)
|
||||||
|
height = bottomY - topY;
|
||||||
|
int leftOver = Rasterizer2D.width - width;
|
||||||
|
int transparency = 256 - opacity;
|
||||||
|
int pixelIndex = leftX + topY * Rasterizer2D.width;
|
||||||
|
for(int rowIndex = 0; rowIndex < height; rowIndex++) {
|
||||||
|
int gradient = 0x10000 - gradientProgress >> 8;
|
||||||
|
int inverseGradient = gradientProgress >> 8;
|
||||||
|
int gradientColour = ((topColour & 0xff00ff) * gradient + (bottomColour & 0xff00ff) * inverseGradient & 0xff00ff00) + ((topColour & 0xff00) * gradient + (bottomColour & 0xff00) * inverseGradient & 0xff0000) >>> 8;
|
||||||
|
int transparentPixel = ((gradientColour & 0xff00ff) * opacity >> 8 & 0xff00ff) + ((gradientColour & 0xff00) * opacity >> 8 & 0xff00);
|
||||||
|
for(int columnIndex = 0; columnIndex < width; columnIndex++) {
|
||||||
|
int backgroundPixel = pixels[pixelIndex];
|
||||||
|
backgroundPixel = ((backgroundPixel & 0xff00ff) * transparency >> 8 & 0xff00ff) + ((backgroundPixel & 0xff00) * transparency >> 8 & 0xff00);
|
||||||
|
pixels[pixelIndex++] = transparentPixel + backgroundPixel;
|
||||||
|
}
|
||||||
|
pixelIndex += leftOver;
|
||||||
|
gradientProgress += progressPerPixel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the drawingArea to the default size and position.
|
||||||
|
* Position: Upper left corner.
|
||||||
|
* Size: As specified before.
|
||||||
|
*/
|
||||||
|
public static void defaultDrawingAreaSize() {
|
||||||
|
leftX = 0;
|
||||||
|
topY = 0;
|
||||||
|
bottomX = width;
|
||||||
|
bottomY = height;
|
||||||
|
lastX = bottomX;
|
||||||
|
viewportCenterX = bottomX / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the drawingArea based on the coordinates of the edges.
|
||||||
|
* @param bottomY The bottom edge Y-Coordinate.
|
||||||
|
* @param leftX The left edge X-Coordinate.
|
||||||
|
* @param rightX The right edge X-Coordinate.
|
||||||
|
* @param topY The top edge Y-Coordinate.
|
||||||
|
*/
|
||||||
|
public static void setDrawingArea(int bottomY, int leftX, int rightX, int topY) {
|
||||||
|
if(leftX < 0) {
|
||||||
|
leftX = 0;
|
||||||
|
}
|
||||||
|
if(topY < 0) {
|
||||||
|
topY = 0;
|
||||||
|
}
|
||||||
|
if(rightX > width) {
|
||||||
|
rightX = width;
|
||||||
|
}
|
||||||
|
if(bottomY > height) {
|
||||||
|
bottomY = height;
|
||||||
|
}
|
||||||
|
Rasterizer2D.leftX = leftX;
|
||||||
|
Rasterizer2D.topY = topY;
|
||||||
|
bottomX = rightX;
|
||||||
|
Rasterizer2D.bottomY = bottomY;
|
||||||
|
lastX = bottomX;
|
||||||
|
viewportCenterX = bottomX / 2;
|
||||||
|
viewportCenterY = Rasterizer2D.bottomY / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the drawingArea by setting every pixel to 0 (black).
|
||||||
|
*/
|
||||||
|
public static void clear() {
|
||||||
|
int i = width * height;
|
||||||
|
for(int j = 0; j < i; j++) {
|
||||||
|
pixels[j] = 0;
|
||||||
|
depthBuffer[j] = Float.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a box filled with a certain colour.
|
||||||
|
* @param leftX The left edge X-Coordinate of the box.
|
||||||
|
* @param topY The top edge Y-Coordinate of the box.
|
||||||
|
* @param width The width of the box.
|
||||||
|
* @param height The height of the box.
|
||||||
|
* @param rgbColour The RGBColour of the box.
|
||||||
|
*/
|
||||||
|
public static void drawBox(int leftX, int topY, int width, int height, int rgbColour) {
|
||||||
|
if (leftX < Rasterizer2D.leftX) {
|
||||||
|
width -= Rasterizer2D.leftX - leftX;
|
||||||
|
leftX = Rasterizer2D.leftX;
|
||||||
|
}
|
||||||
|
if (topY < Rasterizer2D.topY) {
|
||||||
|
height -= Rasterizer2D.topY - topY;
|
||||||
|
topY = Rasterizer2D.topY;
|
||||||
|
}
|
||||||
|
if (leftX + width > bottomX)
|
||||||
|
width = bottomX - leftX;
|
||||||
|
if (topY + height > bottomY)
|
||||||
|
height = bottomY - topY;
|
||||||
|
int leftOver = Rasterizer2D.width - width;
|
||||||
|
int pixelIndex = leftX + topY * Rasterizer2D.width;
|
||||||
|
for (int rowIndex = 0; rowIndex < height; rowIndex++) {
|
||||||
|
for (int columnIndex = 0; columnIndex < width; columnIndex++)
|
||||||
|
pixels[pixelIndex++] = rgbColour;
|
||||||
|
pixelIndex += leftOver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a transparent box.
|
||||||
|
* @param leftX The left edge X-Coordinate of the box.
|
||||||
|
* @param topY The top edge Y-Coordinate of the box.
|
||||||
|
* @param width The box width.
|
||||||
|
* @param height The box height.
|
||||||
|
* @param rgbColour The box colour.
|
||||||
|
* @param opacity The opacity value ranging from 0 to 256.
|
||||||
|
*/
|
||||||
|
public static void drawTransparentBox(int leftX, int topY, int width, int height, int rgbColour, int opacity){
|
||||||
|
if(leftX < Rasterizer2D.leftX){
|
||||||
|
width -= Rasterizer2D.leftX - leftX;
|
||||||
|
leftX = Rasterizer2D.leftX;
|
||||||
|
}
|
||||||
|
if(topY < Rasterizer2D.topY){
|
||||||
|
height -= Rasterizer2D.topY - topY;
|
||||||
|
topY = Rasterizer2D.topY;
|
||||||
|
}
|
||||||
|
if(leftX + width > bottomX)
|
||||||
|
width = bottomX - leftX;
|
||||||
|
if(topY + height > bottomY)
|
||||||
|
height = bottomY - topY;
|
||||||
|
int transparency = 256 - opacity;
|
||||||
|
int red = (rgbColour >> 16 & 0xff) * opacity;
|
||||||
|
int green = (rgbColour >> 8 & 0xff) * opacity;
|
||||||
|
int blue = (rgbColour & 0xff) * opacity;
|
||||||
|
int leftOver = Rasterizer2D.width - width;
|
||||||
|
int pixelIndex = leftX + topY * Rasterizer2D.width;
|
||||||
|
for(int rowIndex = 0; rowIndex < height; rowIndex++){
|
||||||
|
for(int columnIndex = 0; columnIndex < width; columnIndex++){
|
||||||
|
int otherRed = (pixels[pixelIndex] >> 16 & 0xff) * transparency;
|
||||||
|
int otherGreen = (pixels[pixelIndex] >> 8 & 0xff) * transparency;
|
||||||
|
int otherBlue = (pixels[pixelIndex] & 0xff) * transparency;
|
||||||
|
int transparentColour = ((red + otherRed >> 8) << 16) + ((green + otherGreen >> 8) << 8) + (blue + otherBlue >> 8);
|
||||||
|
pixels[pixelIndex++] = transparentColour;
|
||||||
|
}
|
||||||
|
pixelIndex += leftOver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a 1 pixel thick box outline in a certain colour.
|
||||||
|
* @param leftX The left edge X-Coordinate.
|
||||||
|
* @param topY The top edge Y-Coordinate.
|
||||||
|
* @param width The width.
|
||||||
|
* @param height The height.
|
||||||
|
* @param rgbColour The RGB-Colour.
|
||||||
|
*/
|
||||||
|
public static void drawBoxOutline(int leftX, int topY, int width, int height, int rgbColour){
|
||||||
|
drawHorizontalLine(leftX, topY, width, rgbColour);
|
||||||
|
drawHorizontalLine(leftX, (topY + height) - 1, width, rgbColour);
|
||||||
|
drawVerticalLine(leftX, topY, height, rgbColour);
|
||||||
|
drawVerticalLine((leftX + width) - 1, topY, height, rgbColour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a coloured horizontal line in the drawingArea.
|
||||||
|
* @param xPosition The start X-Position of the line.
|
||||||
|
* @param yPosition The Y-Position of the line.
|
||||||
|
* @param width The width of the line.
|
||||||
|
* @param rgbColour The colour of the line.
|
||||||
|
*/
|
||||||
|
public static void drawHorizontalLine(int xPosition, int yPosition, int width, int rgbColour){
|
||||||
|
if(yPosition < topY || yPosition >= bottomY)
|
||||||
|
return;
|
||||||
|
if(xPosition < leftX){
|
||||||
|
width -= leftX - xPosition;
|
||||||
|
xPosition = leftX;
|
||||||
|
}
|
||||||
|
if(xPosition + width > bottomX)
|
||||||
|
width = bottomX - xPosition;
|
||||||
|
int pixelIndex = xPosition + yPosition * Rasterizer2D.width;
|
||||||
|
for(int i = 0; i < width; i++)
|
||||||
|
pixels[pixelIndex + i] = rgbColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a coloured vertical line in the drawingArea.
|
||||||
|
* @param xPosition The X-Position of the line.
|
||||||
|
* @param yPosition The start Y-Position of the line.
|
||||||
|
* @param height The height of the line.
|
||||||
|
* @param rgbColour The colour of the line.
|
||||||
|
*/
|
||||||
|
public static void drawVerticalLine(int xPosition, int yPosition, int height, int rgbColour){
|
||||||
|
if(xPosition < leftX || xPosition >= bottomX)
|
||||||
|
return;
|
||||||
|
if(yPosition < topY){
|
||||||
|
height -= topY - yPosition;
|
||||||
|
yPosition = topY;
|
||||||
|
}
|
||||||
|
if(yPosition + height > bottomY)
|
||||||
|
height = bottomY - yPosition;
|
||||||
|
int pixelIndex = xPosition + yPosition * width;
|
||||||
|
for(int rowIndex = 0; rowIndex < height; rowIndex++)
|
||||||
|
pixels[pixelIndex + rowIndex * width] = rgbColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a 1 pixel thick transparent box outline in a certain colour.
|
||||||
|
* @param leftX The left edge X-Coordinate
|
||||||
|
* @param topY The top edge Y-Coordinate.
|
||||||
|
* @param width The width.
|
||||||
|
* @param height The height.
|
||||||
|
* @param rgbColour The RGB-Colour.
|
||||||
|
* @param opacity The opacity value ranging from 0 to 256.
|
||||||
|
*/
|
||||||
|
public static void drawTransparentBoxOutline(int leftX, int topY, int width, int height, int rgbColour, int opacity) {
|
||||||
|
drawTransparentHorizontalLine(leftX, topY, width, rgbColour, opacity);
|
||||||
|
drawTransparentHorizontalLine(leftX, topY + height - 1, width, rgbColour, opacity);
|
||||||
|
if(height >= 3) {
|
||||||
|
drawTransparentVerticalLine(leftX, topY + 1, height - 2, rgbColour, opacity);
|
||||||
|
drawTransparentVerticalLine(leftX + width - 1, topY + 1, height - 2, rgbColour, opacity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a transparent coloured horizontal line in the drawingArea.
|
||||||
|
* @param xPosition The start X-Position of the line.
|
||||||
|
* @param yPosition The Y-Position of the line.
|
||||||
|
* @param width The width of the line.
|
||||||
|
* @param rgbColour The colour of the line.
|
||||||
|
* @param opacity The opacity value ranging from 0 to 256.
|
||||||
|
*/
|
||||||
|
public static void drawTransparentHorizontalLine(int xPosition, int yPosition, int width, int rgbColour, int opacity) {
|
||||||
|
if(yPosition < topY || yPosition >= bottomY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(xPosition < leftX) {
|
||||||
|
width -= leftX - xPosition;
|
||||||
|
xPosition = leftX;
|
||||||
|
}
|
||||||
|
if(xPosition + width > bottomX) {
|
||||||
|
width = bottomX - xPosition;
|
||||||
|
}
|
||||||
|
final int transparency = 256 - opacity;
|
||||||
|
final int red = (rgbColour >> 16 & 0xff) * opacity;
|
||||||
|
final int green = (rgbColour >> 8 & 0xff) * opacity;
|
||||||
|
final int blue = (rgbColour & 0xff) * opacity;
|
||||||
|
int pixelIndex = xPosition + yPosition * Rasterizer2D.width;
|
||||||
|
for(int i = 0; i < width; i++) {
|
||||||
|
final int otherRed = (pixels[pixelIndex] >> 16 & 0xff) * transparency;
|
||||||
|
final int otherGreen = (pixels[pixelIndex] >> 8 & 0xff) * transparency;
|
||||||
|
final int otherBlue = (pixels[pixelIndex] & 0xff) * transparency;
|
||||||
|
final int transparentColour = (red + otherRed >> 8 << 16) + (green + otherGreen >> 8 << 8) + (blue + otherBlue >> 8);
|
||||||
|
pixels[pixelIndex++] = transparentColour;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a transparent coloured vertical line in the drawingArea.
|
||||||
|
* @param xPosition The X-Position of the line.
|
||||||
|
* @param yPosition The start Y-Position of the line.
|
||||||
|
* @param height The height of the line.
|
||||||
|
* @param rgbColour The colour of the line.
|
||||||
|
* @param opacity The opacity value ranging from 0 to 256.
|
||||||
|
*/
|
||||||
|
public static void drawTransparentVerticalLine(int xPosition, int yPosition, int height, int rgbColour, int opacity) {
|
||||||
|
if(xPosition < leftX || xPosition >= bottomX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(yPosition < topY) {
|
||||||
|
height -= topY - yPosition;
|
||||||
|
yPosition = topY;
|
||||||
|
}
|
||||||
|
if(yPosition + height > bottomY) {
|
||||||
|
height = bottomY - yPosition;
|
||||||
|
}
|
||||||
|
final int transparency = 256 - opacity;
|
||||||
|
final int red = (rgbColour >> 16 & 0xff) * opacity;
|
||||||
|
final int green = (rgbColour >> 8 & 0xff) * opacity;
|
||||||
|
final int blue = (rgbColour & 0xff) * opacity;
|
||||||
|
int pixelIndex = xPosition + yPosition * width;
|
||||||
|
for(int i = 0; i < height; i++) {
|
||||||
|
final int otherRed = (pixels[pixelIndex] >> 16 & 0xff) * transparency;
|
||||||
|
final int otherGreen = (pixels[pixelIndex] >> 8 & 0xff) * transparency;
|
||||||
|
final int otherBlue = (pixels[pixelIndex] & 0xff) * transparency;
|
||||||
|
final int transparentColour = (red + otherRed >> 8 << 16) + (green + otherGreen >> 8 << 8) + (blue + otherBlue >> 8);
|
||||||
|
pixels[pixelIndex] = transparentColour;
|
||||||
|
pixelIndex += width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static float depthBuffer[];
|
||||||
|
public static int pixels[];
|
||||||
|
public static int width;
|
||||||
|
public static int height;
|
||||||
|
public static int topY;
|
||||||
|
public static int bottomY;
|
||||||
|
public static int leftX;
|
||||||
|
public static int bottomX;
|
||||||
|
public static int lastX;
|
||||||
|
public static int viewportCenterX;
|
||||||
|
public static int viewportCenterY;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
|||||||
|
package org.rebotted.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ObjectGenre = 2
|
||||||
|
*/
|
||||||
|
public final class GameObject {
|
||||||
|
|
||||||
|
public int zLoc;
|
||||||
|
public int tileHeight;
|
||||||
|
public int xPos;
|
||||||
|
public int yPos;
|
||||||
|
public Renderable renderable;
|
||||||
|
public int turnValue;
|
||||||
|
public int xLocLow;
|
||||||
|
public int xLocHigh;
|
||||||
|
public int yLocHigh;
|
||||||
|
public int yLocLow;
|
||||||
|
public int anInt527;
|
||||||
|
public int anInt528;
|
||||||
|
public int uid;
|
||||||
|
/**
|
||||||
|
* mask = (byte)((objectRotation << 6) + objectType);
|
||||||
|
*/
|
||||||
|
public byte mask;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package org.rebotted.entity;
|
||||||
|
|
||||||
|
public final class GroundItemTile {
|
||||||
|
|
||||||
|
public int zPos;
|
||||||
|
public int xPos;
|
||||||
|
public int yPos;
|
||||||
|
public Renderable topNode;
|
||||||
|
public Renderable lowerNode;
|
||||||
|
public Renderable middleNode;
|
||||||
|
public int uid;
|
||||||
|
public int itemDropHeight;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.rebotted.entity;
|
||||||
|
|
||||||
|
import org.rebotted.cache.def.ItemDefinition;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
|
||||||
|
public final class Item extends Renderable {
|
||||||
|
|
||||||
|
public final Model getRotatedModel() {
|
||||||
|
ItemDefinition itemDef = ItemDefinition.lookup(ID);
|
||||||
|
return itemDef.getModel(itemCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ID;
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
public int itemCount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,473 @@
|
|||||||
|
package org.rebotted.entity;
|
||||||
|
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.Configuration;
|
||||||
|
import org.rebotted.cache.anim.Animation;
|
||||||
|
import org.rebotted.cache.anim.Graphic;
|
||||||
|
|
||||||
|
public class Mob extends Renderable {
|
||||||
|
|
||||||
|
public final int[] pathX;
|
||||||
|
public final int[] pathY;
|
||||||
|
public int interactingEntity;
|
||||||
|
public int anInt1503;
|
||||||
|
public int degreesToTurn;
|
||||||
|
public int runAnimIndex;
|
||||||
|
public String spokenText;
|
||||||
|
public int height;
|
||||||
|
public int nextStepOrientation;
|
||||||
|
public int idleAnimation;
|
||||||
|
public int standTurnAnimIndex;
|
||||||
|
public int textColour;
|
||||||
|
public final int[] hitDamages;
|
||||||
|
public final int[] hitMarkTypes;
|
||||||
|
public final int[] hitsLoopCycle;
|
||||||
|
public int movementAnimation;
|
||||||
|
public int displayedMovementFrames;
|
||||||
|
public int anInt1519;
|
||||||
|
public int graphic;
|
||||||
|
public int currentAnimation;
|
||||||
|
public int anInt1522;
|
||||||
|
public int graphicDelay;
|
||||||
|
public int graphicHeight;
|
||||||
|
public int remainingPath;
|
||||||
|
public int emoteAnimation;
|
||||||
|
public int displayedEmoteFrames;
|
||||||
|
public int emoteTimeRemaining;
|
||||||
|
public int animationDelay;
|
||||||
|
public int currentAnimationLoops;
|
||||||
|
public int textEffect;
|
||||||
|
public int loopCycleStatus;
|
||||||
|
public int currentHealth;
|
||||||
|
public int maxHealth;
|
||||||
|
public int textCycle;
|
||||||
|
public int time;
|
||||||
|
public int faceX;
|
||||||
|
public int faceY;
|
||||||
|
public int size;
|
||||||
|
public boolean animationStretches;
|
||||||
|
public int anInt1542;
|
||||||
|
public int initialX;
|
||||||
|
public int destinationX;
|
||||||
|
public int initialY;
|
||||||
|
public int destinationY;
|
||||||
|
public int startForceMovement;
|
||||||
|
public int endForceMovement;
|
||||||
|
public int direction;
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
public int orientation;
|
||||||
|
public final boolean[] pathRun;
|
||||||
|
public int walkAnimIndex;
|
||||||
|
public int turn180AnimIndex;
|
||||||
|
public int turn90CWAnimIndex;
|
||||||
|
public int turn90CCWAnimIndex;
|
||||||
|
|
||||||
|
public int nextAnimationFrame;
|
||||||
|
public int nextGraphicsAnimationFrame;
|
||||||
|
public int nextIdleAnimationFrame;
|
||||||
|
public int nextSpotAnimFrame;
|
||||||
|
|
||||||
|
public Mob() {
|
||||||
|
pathX = new int[10];
|
||||||
|
pathY = new int[10];
|
||||||
|
interactingEntity = -1;
|
||||||
|
degreesToTurn = 32;
|
||||||
|
runAnimIndex = -1;
|
||||||
|
height = 200;
|
||||||
|
idleAnimation = -1;
|
||||||
|
standTurnAnimIndex = -1;
|
||||||
|
hitDamages = new int[4];
|
||||||
|
hitMarkTypes = new int[4];
|
||||||
|
hitsLoopCycle = new int[4];
|
||||||
|
movementAnimation = -1;
|
||||||
|
graphic = -1;
|
||||||
|
emoteAnimation = -1;
|
||||||
|
loopCycleStatus = -1000;
|
||||||
|
textCycle = 100;
|
||||||
|
size = 1;
|
||||||
|
animationStretches = false;
|
||||||
|
pathRun = new boolean[10];
|
||||||
|
walkAnimIndex = -1;
|
||||||
|
turn180AnimIndex = -1;
|
||||||
|
turn90CWAnimIndex = -1;
|
||||||
|
turn90CCWAnimIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setPos(int x, int y, boolean flag) {
|
||||||
|
if (emoteAnimation != -1 && Animation.animations[emoteAnimation].priority == 1)
|
||||||
|
emoteAnimation = -1;
|
||||||
|
|
||||||
|
if (!flag) {
|
||||||
|
int dx = x - pathX[0];
|
||||||
|
int dy = y - pathY[0];
|
||||||
|
if (dx >= -8 && dx <= 8 && dy >= -8 && dy <= 8) {
|
||||||
|
if (remainingPath < 9)
|
||||||
|
remainingPath++;
|
||||||
|
for (int i1 = remainingPath; i1 > 0; i1--) {
|
||||||
|
pathX[i1] = pathX[i1 - 1];
|
||||||
|
pathY[i1] = pathY[i1 - 1];
|
||||||
|
pathRun[i1] = pathRun[i1 - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
pathX[0] = x;
|
||||||
|
pathY[0] = y;
|
||||||
|
pathRun[0] = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remainingPath = 0;
|
||||||
|
anInt1542 = 0;
|
||||||
|
anInt1503 = 0;
|
||||||
|
pathX[0] = x;
|
||||||
|
pathY[0] = y;
|
||||||
|
this.x = pathX[0] * 128 + size * 64;
|
||||||
|
this.y = pathY[0] * 128 + size * 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void resetPath() {
|
||||||
|
remainingPath = 0;
|
||||||
|
anInt1542 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void updateHitData(int hitType, int hitDamage, int currentTime) {
|
||||||
|
for (int hitPtr = 0; hitPtr < 4; hitPtr++)
|
||||||
|
if (hitsLoopCycle[hitPtr] <= currentTime) {
|
||||||
|
hitDamages[hitPtr] = hitDamage;
|
||||||
|
hitMarkTypes[hitPtr] = hitType;
|
||||||
|
hitsLoopCycle[hitPtr] = currentTime + 70;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void nextPreForcedStep() {
|
||||||
|
int remaining = startForceMovement - Client.tick;
|
||||||
|
int tempX = initialX * 128 + size * 64;
|
||||||
|
int tempY = initialY * 128 + size * 64;
|
||||||
|
x += (tempX - x) / remaining;
|
||||||
|
y += (tempY - y) / remaining;
|
||||||
|
|
||||||
|
anInt1503 = 0;
|
||||||
|
|
||||||
|
if (direction == 0) {
|
||||||
|
nextStepOrientation = 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction == 1) {
|
||||||
|
nextStepOrientation = 1536;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction == 2) {
|
||||||
|
nextStepOrientation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction == 3) {
|
||||||
|
nextStepOrientation = 512;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void nextForcedMovementStep() {
|
||||||
|
if (endForceMovement == Client.tick || emoteAnimation == -1
|
||||||
|
|| animationDelay != 0
|
||||||
|
|| emoteTimeRemaining
|
||||||
|
+ 1 > Animation.animations[emoteAnimation]
|
||||||
|
.duration(displayedEmoteFrames)) {
|
||||||
|
int remaining = endForceMovement - startForceMovement;
|
||||||
|
int elapsed = Client.tick - startForceMovement;
|
||||||
|
int initialX = this.initialX * 128 + size * 64;
|
||||||
|
int initialY = this.initialY * 128 + size * 64;
|
||||||
|
int endX = destinationX * 128 + size * 64;
|
||||||
|
int endY = destinationY * 128 + size * 64;
|
||||||
|
x = (initialX * (remaining - elapsed) + endX * elapsed) / remaining;
|
||||||
|
y = (initialY * (remaining - elapsed) + endY * elapsed) / remaining;
|
||||||
|
}
|
||||||
|
anInt1503 = 0;
|
||||||
|
|
||||||
|
if (direction == 0) {
|
||||||
|
nextStepOrientation = 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction == 1) {
|
||||||
|
nextStepOrientation = 1536;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction == 2) {
|
||||||
|
nextStepOrientation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction == 3) {
|
||||||
|
nextStepOrientation = 512;
|
||||||
|
}
|
||||||
|
|
||||||
|
orientation = nextStepOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void nextStep() {
|
||||||
|
movementAnimation = idleAnimation;
|
||||||
|
|
||||||
|
if (remainingPath == 0) {
|
||||||
|
anInt1503 = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(emoteAnimation > Animation.animations.length) {
|
||||||
|
emoteAnimation = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (emoteAnimation != -1 && animationDelay == 0) {
|
||||||
|
Animation animation = Animation.animations[emoteAnimation];
|
||||||
|
if (anInt1542 > 0 && animation.animatingPrecedence == 0) {
|
||||||
|
anInt1503++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (anInt1542 <= 0 && animation.priority == 0) {
|
||||||
|
anInt1503++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int tempX = x;
|
||||||
|
int tempY = y;
|
||||||
|
int nextX = pathX[remainingPath - 1] * 128 + size * 64;
|
||||||
|
int nextY = pathY[remainingPath - 1] * 128 + size * 64;
|
||||||
|
if (nextX - tempX > 256 || nextX - tempX < -256 || nextY - tempY > 256 || nextY - tempY < -256) {
|
||||||
|
x = nextX;
|
||||||
|
y = nextY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (tempX < nextX) {
|
||||||
|
if (tempY < nextY) {
|
||||||
|
nextStepOrientation = 1280;
|
||||||
|
} else if (tempY > nextY) {
|
||||||
|
nextStepOrientation = 1792;
|
||||||
|
} else {
|
||||||
|
nextStepOrientation = 1536;
|
||||||
|
}
|
||||||
|
} else if (tempX > nextX) {
|
||||||
|
if (tempY < nextY) {
|
||||||
|
nextStepOrientation = 768;
|
||||||
|
} else if (tempY > nextY) {
|
||||||
|
nextStepOrientation = 256;
|
||||||
|
} else {
|
||||||
|
nextStepOrientation = 512;
|
||||||
|
}
|
||||||
|
} else if (tempY < nextY) {
|
||||||
|
nextStepOrientation = 1024;
|
||||||
|
} else {
|
||||||
|
nextStepOrientation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rotation = nextStepOrientation - orientation & 0x7ff;
|
||||||
|
|
||||||
|
if (rotation > 1024) {
|
||||||
|
rotation -= 2048;
|
||||||
|
}
|
||||||
|
|
||||||
|
int animation = turn180AnimIndex;
|
||||||
|
|
||||||
|
if (rotation >= -256 && rotation <= 256) {
|
||||||
|
animation = walkAnimIndex;
|
||||||
|
} else if (rotation >= 256 && rotation < 768) {
|
||||||
|
animation = turn90CCWAnimIndex;
|
||||||
|
} else if (rotation >= -768 && rotation <= -256) {
|
||||||
|
animation = turn90CWAnimIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (animation == -1) {
|
||||||
|
animation = walkAnimIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
movementAnimation = animation;
|
||||||
|
|
||||||
|
int positionDelta = 4;
|
||||||
|
|
||||||
|
if (orientation != nextStepOrientation && interactingEntity == -1
|
||||||
|
&& degreesToTurn != 0) {
|
||||||
|
positionDelta = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainingPath > 2) {
|
||||||
|
positionDelta = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainingPath > 3) {
|
||||||
|
positionDelta = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anInt1503 > 0 && remainingPath > 1) {
|
||||||
|
positionDelta = 8;
|
||||||
|
anInt1503--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathRun[remainingPath - 1]) {
|
||||||
|
positionDelta <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (positionDelta >= 8 && movementAnimation == walkAnimIndex
|
||||||
|
&& runAnimIndex != -1) {
|
||||||
|
movementAnimation = runAnimIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempX < nextX) {
|
||||||
|
x += positionDelta;
|
||||||
|
if (x > nextX) {
|
||||||
|
x = nextX;
|
||||||
|
}
|
||||||
|
} else if (tempX > nextX) {
|
||||||
|
x -= positionDelta;
|
||||||
|
if (x < nextX) {
|
||||||
|
x = nextX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tempY < nextY) {
|
||||||
|
y += positionDelta;
|
||||||
|
if (y > nextY) {
|
||||||
|
y = nextY;
|
||||||
|
}
|
||||||
|
} else if (tempY > nextY) {
|
||||||
|
y -= positionDelta;
|
||||||
|
|
||||||
|
if (y < nextY) {
|
||||||
|
y = nextY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (x == nextX && y == nextY) {
|
||||||
|
remainingPath--;
|
||||||
|
|
||||||
|
if (anInt1542 > 0) {
|
||||||
|
anInt1542--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void moveInDir(boolean run, int direction) {
|
||||||
|
int x = pathX[0];
|
||||||
|
int y = pathY[0];
|
||||||
|
if (direction == 0) {
|
||||||
|
x--;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if (direction == 1)
|
||||||
|
y++;
|
||||||
|
if (direction == 2) {
|
||||||
|
x++;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
if (direction == 3)
|
||||||
|
x--;
|
||||||
|
if (direction == 4)
|
||||||
|
x++;
|
||||||
|
if (direction == 5) {
|
||||||
|
x--;
|
||||||
|
y--;
|
||||||
|
}
|
||||||
|
if (direction == 6)
|
||||||
|
y--;
|
||||||
|
if (direction == 7) {
|
||||||
|
x++;
|
||||||
|
y--;
|
||||||
|
}
|
||||||
|
if (emoteAnimation != -1 && Animation.animations[emoteAnimation].priority == 1)
|
||||||
|
emoteAnimation = -1;
|
||||||
|
if (remainingPath < 9)
|
||||||
|
remainingPath++;
|
||||||
|
for (int l = remainingPath; l > 0; l--) {
|
||||||
|
pathX[l] = pathX[l - 1];
|
||||||
|
pathY[l] = pathY[l - 1];
|
||||||
|
pathRun[l] = pathRun[l - 1];
|
||||||
|
}
|
||||||
|
pathX[0] = x;
|
||||||
|
pathY[0] = y;
|
||||||
|
pathRun[0] = run;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAnimation() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (movementAnimation > 13798) {
|
||||||
|
movementAnimation = -1;
|
||||||
|
}
|
||||||
|
animationStretches = false;
|
||||||
|
if (movementAnimation != -1) {
|
||||||
|
Animation animation = Animation.animations[movementAnimation];
|
||||||
|
anInt1519++;
|
||||||
|
if (displayedMovementFrames < animation.frameCount && anInt1519 > animation.duration(displayedMovementFrames)) {
|
||||||
|
anInt1519 = 1;
|
||||||
|
displayedMovementFrames++;
|
||||||
|
nextIdleAnimationFrame++;
|
||||||
|
}
|
||||||
|
nextIdleAnimationFrame = displayedMovementFrames + 1;
|
||||||
|
if (nextIdleAnimationFrame >= animation.frameCount) {
|
||||||
|
if (nextIdleAnimationFrame >= animation.frameCount) {
|
||||||
|
nextIdleAnimationFrame = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (displayedMovementFrames >= animation.frameCount) {
|
||||||
|
anInt1519 = 1;
|
||||||
|
displayedMovementFrames = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (graphic != -1 && Client.tick >= graphicDelay) {
|
||||||
|
if (currentAnimation < 0)
|
||||||
|
currentAnimation = 0;
|
||||||
|
Animation animation_1 = Graphic.cache[graphic].animationSequence;
|
||||||
|
|
||||||
|
for (anInt1522++; currentAnimation < animation_1.frameCount && anInt1522 > animation_1.duration(currentAnimation); currentAnimation++)
|
||||||
|
anInt1522 -= animation_1.duration(currentAnimation);
|
||||||
|
|
||||||
|
|
||||||
|
if (currentAnimation >= animation_1.frameCount && (currentAnimation < 0 || currentAnimation >= animation_1.frameCount)) {
|
||||||
|
graphic = -1;
|
||||||
|
}
|
||||||
|
if (Configuration.enableTweening) {
|
||||||
|
nextIdleAnimationFrame = displayedMovementFrames + 1;
|
||||||
|
}
|
||||||
|
if (nextSpotAnimFrame >= animation_1.frameCount) {
|
||||||
|
nextSpotAnimFrame = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (emoteAnimation != -1 && animationDelay <= 1) {
|
||||||
|
Animation animation_2 = Animation.animations[emoteAnimation];
|
||||||
|
if (animation_2.animatingPrecedence == 1 && anInt1542 > 0 && startForceMovement <= Client.tick && endForceMovement < Client.tick) {
|
||||||
|
animationDelay = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (emoteAnimation != -1 && animationDelay == 0) {
|
||||||
|
Animation animation_3 = Animation.animations[emoteAnimation];
|
||||||
|
for (emoteTimeRemaining++; displayedEmoteFrames < animation_3.frameCount && emoteTimeRemaining > animation_3.duration(displayedEmoteFrames); displayedEmoteFrames++)
|
||||||
|
emoteTimeRemaining -= animation_3.duration(displayedEmoteFrames);
|
||||||
|
|
||||||
|
if (displayedEmoteFrames >= animation_3.frameCount) {
|
||||||
|
displayedEmoteFrames -= animation_3.loopOffset;
|
||||||
|
currentAnimationLoops++;
|
||||||
|
if (currentAnimationLoops >= animation_3.maximumLoops)
|
||||||
|
emoteAnimation = -1;
|
||||||
|
if (displayedEmoteFrames < 0 || displayedEmoteFrames >= animation_3.frameCount)
|
||||||
|
emoteAnimation = -1;
|
||||||
|
}
|
||||||
|
if (Configuration.enableTweening) {
|
||||||
|
nextAnimationFrame = displayedEmoteFrames + 1;
|
||||||
|
}
|
||||||
|
if (nextAnimationFrame >= animation_3.frameCount) {
|
||||||
|
nextAnimationFrame = -1;
|
||||||
|
}
|
||||||
|
animationStretches = animation_3.stretches;
|
||||||
|
}
|
||||||
|
if (animationDelay > 0)
|
||||||
|
animationDelay--;
|
||||||
|
|
||||||
|
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int entScreenX;
|
||||||
|
public int entScreenY;
|
||||||
|
public int index = -1;
|
||||||
|
|
||||||
|
public boolean isVisible() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package org.rebotted.entity;
|
||||||
|
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.cache.anim.Animation;
|
||||||
|
import org.rebotted.cache.anim.Frame;
|
||||||
|
import org.rebotted.cache.anim.Graphic;
|
||||||
|
import org.rebotted.cache.def.NpcDefinition;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
|
||||||
|
public final class Npc extends Mob {
|
||||||
|
|
||||||
|
public NpcDefinition desc;
|
||||||
|
public int headIcon = -1;
|
||||||
|
public int ownerIndex = -1;
|
||||||
|
|
||||||
|
public boolean showActions() {
|
||||||
|
if(ownerIndex == -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return (Client.instance.localPlayerIndex == ownerIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeadIcon() {
|
||||||
|
if(headIcon == -1) {
|
||||||
|
if(desc != null) {
|
||||||
|
return desc.headIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return headIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Model getAnimatedModel() {
|
||||||
|
if (super.emoteAnimation >= 0 && super.animationDelay == 0) {
|
||||||
|
int emote = Animation.animations[super.emoteAnimation].primaryFrames[super.displayedEmoteFrames];
|
||||||
|
int movement = -1;
|
||||||
|
if (super.movementAnimation >= 0 && super.movementAnimation != super.idleAnimation)
|
||||||
|
movement = Animation.animations[super.movementAnimation].primaryFrames[super.displayedMovementFrames];
|
||||||
|
return desc.getAnimatedModel(movement, emote,
|
||||||
|
Animation.animations[super.emoteAnimation].interleaveOrder);
|
||||||
|
}
|
||||||
|
int movement = -1;
|
||||||
|
if (super.movementAnimation >= 0) {
|
||||||
|
movement = Animation.animations[super.movementAnimation].primaryFrames[super.displayedMovementFrames];
|
||||||
|
}
|
||||||
|
return desc.getAnimatedModel(-1, movement, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getRotatedModel() {
|
||||||
|
if (desc == null)
|
||||||
|
return null;
|
||||||
|
Model animatedModel = getAnimatedModel();
|
||||||
|
if (animatedModel == null)
|
||||||
|
return null;
|
||||||
|
super.height = animatedModel.modelBaseY;
|
||||||
|
if (super.graphic != -1 && super.currentAnimation != -1) {
|
||||||
|
Graphic spotAnim = Graphic.cache[super.graphic];
|
||||||
|
Model graphicModel = spotAnim.getModel();
|
||||||
|
if (graphicModel != null) {
|
||||||
|
int frame = spotAnim.animationSequence.primaryFrames[super.currentAnimation];
|
||||||
|
Model model = new Model(true, Frame.noAnimationInProgress(frame),
|
||||||
|
false, graphicModel);
|
||||||
|
model.translate(0, -super.graphicHeight, 0);
|
||||||
|
model.skin();
|
||||||
|
model.applyTransform(frame);
|
||||||
|
model.faceGroups = null;
|
||||||
|
model.vertexGroups = null;
|
||||||
|
if (spotAnim.resizeXY != 128 || spotAnim.resizeZ != 128)
|
||||||
|
model.scale(spotAnim.resizeXY, spotAnim.resizeXY,
|
||||||
|
spotAnim.resizeZ);
|
||||||
|
model.light(64 + spotAnim.modelBrightness,
|
||||||
|
850 + spotAnim.modelShadow, -30, -50, -30, true);
|
||||||
|
Model models[] = { animatedModel, model };
|
||||||
|
animatedModel = new Model(models);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (desc.size == 1)
|
||||||
|
animatedModel.fits_on_single_square = true;
|
||||||
|
return animatedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisible() {
|
||||||
|
return desc != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,459 @@
|
|||||||
|
package org.rebotted.entity;
|
||||||
|
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.Configuration;
|
||||||
|
import org.rebotted.cache.anim.Animation;
|
||||||
|
import org.rebotted.cache.anim.Frame;
|
||||||
|
import org.rebotted.cache.anim.Graphic;
|
||||||
|
import org.rebotted.cache.def.ItemDefinition;
|
||||||
|
import org.rebotted.cache.def.NpcDefinition;
|
||||||
|
import org.rebotted.cache.idk.IdentityKit;
|
||||||
|
import org.rebotted.collection.ReferenceCache;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
import org.rebotted.util.StringUtils;
|
||||||
|
|
||||||
|
public final class Player extends Mob {
|
||||||
|
|
||||||
|
private long cachedModel = -1L;
|
||||||
|
public NpcDefinition npcDefinition;
|
||||||
|
public boolean aBoolean1699;
|
||||||
|
public final int[] appearanceColors = new int[5];
|
||||||
|
public int team;
|
||||||
|
private int gender;
|
||||||
|
public String name;
|
||||||
|
public static ReferenceCache models = new ReferenceCache(260);
|
||||||
|
public int combatLevel;
|
||||||
|
public int headIcon;
|
||||||
|
public int skullIcon;
|
||||||
|
public int hintIcon;
|
||||||
|
public int objectModelStart;
|
||||||
|
public int objectModelStop;
|
||||||
|
public int anInt1709;
|
||||||
|
public boolean visible;
|
||||||
|
public int objectXPos;
|
||||||
|
public int objectCenterHeight;
|
||||||
|
public int objectYPos;
|
||||||
|
public Model playerModel;
|
||||||
|
public final int[] equipment = new int[12];
|
||||||
|
private long appearanceOffset ;
|
||||||
|
public int objectAnInt1719LesserXLoc;
|
||||||
|
public int objectAnInt1720LesserYLoc;
|
||||||
|
public int objectAnInt1721GreaterXLoc;
|
||||||
|
public int objectAnInt1722GreaterYLoc;
|
||||||
|
public int skill;
|
||||||
|
public String clanName = "None";
|
||||||
|
public int privelage;
|
||||||
|
|
||||||
|
public Model getRotatedModel() {
|
||||||
|
|
||||||
|
if (!visible) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Model animatedModel = getAnimatedModel();
|
||||||
|
|
||||||
|
if (animatedModel == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.height = animatedModel.modelBaseY;
|
||||||
|
animatedModel.fits_on_single_square = true;
|
||||||
|
|
||||||
|
if (aBoolean1699) {
|
||||||
|
return animatedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (super.graphic != -1 && super.currentAnimation != -1) {
|
||||||
|
Graphic spotAnim = Graphic.cache[super.graphic];
|
||||||
|
|
||||||
|
Model spotAnimationModel = spotAnim.getModel();
|
||||||
|
|
||||||
|
if (spotAnimationModel != null) {
|
||||||
|
Model model_3 = new Model(true, Frame.noAnimationInProgress(super.currentAnimation), false, spotAnimationModel );
|
||||||
|
int nextFrame = spotAnim.animationSequence.primaryFrames[super.nextGraphicsAnimationFrame];
|
||||||
|
int cycle1 = spotAnim.animationSequence.durations[super.currentAnimation];
|
||||||
|
int cycle2 = super.anInt1522;
|
||||||
|
model_3.translate(0, -super.graphicHeight, 0);
|
||||||
|
model_3.skin();
|
||||||
|
model_3.applyAnimationFrame(spotAnim.animationSequence.primaryFrames[super.currentAnimation], nextFrame,
|
||||||
|
cycle1, cycle2);
|
||||||
|
model_3.faceGroups = null;
|
||||||
|
model_3.vertexGroups = null;
|
||||||
|
if (spotAnim.resizeXY != 128 || spotAnim.resizeZ != 128)
|
||||||
|
model_3.scale(spotAnim.resizeXY, spotAnim.resizeXY, spotAnim.resizeZ);
|
||||||
|
model_3.light(64 + spotAnim.modelBrightness, 850 + spotAnim.modelShadow, -30, -50, -30, true);
|
||||||
|
Model models [] = { animatedModel, model_3 };
|
||||||
|
animatedModel = new Model(models );
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (playerModel != null) {
|
||||||
|
if (Client.tick >= objectModelStop)
|
||||||
|
playerModel = null;
|
||||||
|
if (Client.tick >= objectModelStart && Client.tick < objectModelStop) {
|
||||||
|
Model model_1 = playerModel;
|
||||||
|
model_1.translate(objectXPos - super.x, objectCenterHeight - anInt1709, objectYPos - super.y);
|
||||||
|
if (super.nextStepOrientation == 512) {
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
} else if (super.nextStepOrientation == 1024) {
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
} else if (super.nextStepOrientation == 1536)
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
Model models[] = { animatedModel, model_1 };
|
||||||
|
animatedModel = new Model(models);
|
||||||
|
if (super.nextStepOrientation == 512)
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
else if (super.nextStepOrientation == 1024) {
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
} else if (super.nextStepOrientation == 1536) {
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
}
|
||||||
|
model_1.translate(super.x - objectXPos, anInt1709 - objectCenterHeight, super.y - objectYPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
animatedModel.fits_on_single_square = true;
|
||||||
|
return animatedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAppearance(Buffer buffer) {
|
||||||
|
buffer.currentPosition = 0;
|
||||||
|
gender = buffer.readUnsignedByte();
|
||||||
|
headIcon = buffer.readUnsignedByte();
|
||||||
|
skullIcon = buffer.readUnsignedByte();
|
||||||
|
npcDefinition = null;
|
||||||
|
team = 0;
|
||||||
|
|
||||||
|
for (int bodyPart = 0; bodyPart < 12; bodyPart++) {
|
||||||
|
|
||||||
|
int reset = buffer.readUnsignedByte();
|
||||||
|
|
||||||
|
if (reset == 0) {
|
||||||
|
equipment[bodyPart] = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int id = buffer.readUnsignedByte();
|
||||||
|
|
||||||
|
equipment[bodyPart] = (reset << 8) + id;
|
||||||
|
|
||||||
|
if (bodyPart == 0 && equipment[0] == 65535) {
|
||||||
|
npcDefinition = NpcDefinition.lookup(buffer.readUShort());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equipment[bodyPart] >= 512 && equipment[bodyPart] - 512 < ItemDefinition.itemCount) {
|
||||||
|
int team = ItemDefinition.lookup(equipment[bodyPart] - 512).team;
|
||||||
|
|
||||||
|
if (team != 0) {
|
||||||
|
this.team = team;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int part = 0; part < 5; part++) {
|
||||||
|
int color = buffer.readUnsignedByte();
|
||||||
|
if (color < 0 || color >= Client.PLAYER_BODY_RECOLOURS[part].length) {
|
||||||
|
color = 0;
|
||||||
|
}
|
||||||
|
appearanceColors[part] = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.idleAnimation = buffer.readUShort();
|
||||||
|
if (super.idleAnimation == 65535) {
|
||||||
|
super.idleAnimation = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.standTurnAnimIndex = buffer.readUShort();
|
||||||
|
if (super.standTurnAnimIndex == 65535) {
|
||||||
|
super.standTurnAnimIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.walkAnimIndex = buffer.readUShort();
|
||||||
|
if (super.walkAnimIndex == 65535) {
|
||||||
|
super.walkAnimIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.turn180AnimIndex = buffer.readUShort();
|
||||||
|
if (super.turn180AnimIndex == 65535) {
|
||||||
|
super.turn180AnimIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.turn90CWAnimIndex = buffer.readUShort();
|
||||||
|
if (super.turn90CWAnimIndex == 65535) {
|
||||||
|
super.turn90CWAnimIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.turn90CCWAnimIndex = buffer.readUShort();
|
||||||
|
if (super.turn90CCWAnimIndex == 65535) {
|
||||||
|
super.turn90CCWAnimIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.runAnimIndex = buffer.readUShort();
|
||||||
|
if (super.runAnimIndex == 65535) {
|
||||||
|
super.runAnimIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = StringUtils.formatUsername(StringUtils.decodeBase37(buffer.readLong()));
|
||||||
|
combatLevel = buffer.readUnsignedByte();
|
||||||
|
skill = buffer.readUShort();
|
||||||
|
visible = true;
|
||||||
|
appearanceOffset = 0L;
|
||||||
|
|
||||||
|
for (int index = 0; index < 12; index++) {
|
||||||
|
appearanceOffset <<= 4;
|
||||||
|
|
||||||
|
if (equipment[index] >= 256) {
|
||||||
|
appearanceOffset += equipment[index] - 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equipment[0] >= 256) {
|
||||||
|
appearanceOffset += equipment[0] - 256 >> 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equipment[1] >= 256) {
|
||||||
|
appearanceOffset += equipment[1] - 256 >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int index = 0; index < 5; index++) {
|
||||||
|
appearanceOffset <<= 3;
|
||||||
|
appearanceOffset += appearanceColors[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
appearanceOffset <<= 1;
|
||||||
|
appearanceOffset += gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getAnimatedModel() {
|
||||||
|
if (npcDefinition != null) {
|
||||||
|
int currentFrame = -1;
|
||||||
|
int nextFrame = -1;
|
||||||
|
int cycle1 = 0;
|
||||||
|
int cycle2 = 0;
|
||||||
|
|
||||||
|
if (super.emoteAnimation >= 0 && super.animationDelay == 0) {
|
||||||
|
Animation animation = Animation.animations[super.emoteAnimation];
|
||||||
|
currentFrame = animation.primaryFrames[super.displayedEmoteFrames];
|
||||||
|
if (Configuration.enableTweening && super.nextAnimationFrame != -1) {
|
||||||
|
nextFrame = animation.primaryFrames[super.nextAnimationFrame];
|
||||||
|
cycle1 = animation.durations[super.displayedEmoteFrames];
|
||||||
|
cycle2 = super.emoteTimeRemaining;
|
||||||
|
}
|
||||||
|
} else if (super.movementAnimation >= 0) {
|
||||||
|
Animation animation = Animation.animations[super.movementAnimation];
|
||||||
|
currentFrame = animation.primaryFrames[super.displayedMovementFrames];
|
||||||
|
if (Configuration.enableTweening && super.nextIdleAnimationFrame != -1) {
|
||||||
|
nextFrame = animation.primaryFrames[super.nextIdleAnimationFrame];
|
||||||
|
cycle1 = animation.durations[super.displayedMovementFrames];
|
||||||
|
cycle2 = super.anInt1519;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Model model = npcDefinition.method164(-1, currentFrame, null, nextFrame, cycle1, cycle2);
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long l = appearanceOffset ;
|
||||||
|
int currentFrame = -1;
|
||||||
|
int nextFrame = -1;
|
||||||
|
int cycle1 = 0;
|
||||||
|
int cycle2 = 0;
|
||||||
|
int i1 = -1;
|
||||||
|
int j1 = -1;
|
||||||
|
int k1 = -1;
|
||||||
|
if (super.emoteAnimation >= 0 && super.animationDelay == 0) {
|
||||||
|
Animation animation = Animation.animations[super.emoteAnimation];
|
||||||
|
currentFrame = animation.primaryFrames[super.displayedEmoteFrames];
|
||||||
|
if (Configuration.enableTweening && super.nextAnimationFrame != -1) {
|
||||||
|
nextFrame = animation.primaryFrames[super.nextAnimationFrame];
|
||||||
|
cycle1 = animation.durations[super.displayedEmoteFrames];
|
||||||
|
cycle2 = super.emoteTimeRemaining;
|
||||||
|
}
|
||||||
|
if (super.movementAnimation >= 0 && super.movementAnimation != super.idleAnimation)
|
||||||
|
i1 = Animation.animations[super.movementAnimation].primaryFrames[super.displayedMovementFrames];
|
||||||
|
if (animation.rightHand >= 0) {
|
||||||
|
j1 = animation.rightHand;
|
||||||
|
l += j1 - equipment[5] << 40;
|
||||||
|
}
|
||||||
|
if (animation.leftHand >= 0) {
|
||||||
|
k1 = animation.leftHand;
|
||||||
|
l += k1 - equipment[3] << 48;
|
||||||
|
}
|
||||||
|
} else if (super.movementAnimation >= 0) {
|
||||||
|
Animation animation = Animation.animations[super.movementAnimation];
|
||||||
|
currentFrame = animation.primaryFrames[super.displayedMovementFrames];
|
||||||
|
|
||||||
|
/** DISABLED BECAUSE IT CAUSES FLICKERING WITH SOME GFXS **/
|
||||||
|
/*if (Configuration.enableTweening && super.nextIdleAnimationFrame != -1) {
|
||||||
|
nextFrame = animation.primaryFrames[super.nextIdleAnimationFrame];
|
||||||
|
cycle1 = animation.durations[super.displayedMovementFrames];
|
||||||
|
cycle2 = super.anInt1519;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
Model model_1 = (Model) models.get(l);
|
||||||
|
if (model_1 == null) {
|
||||||
|
boolean flag = false;
|
||||||
|
for (int i2 = 0; i2 < 12; i2++) {
|
||||||
|
int k2 = equipment[i2];
|
||||||
|
if (k1 >= 0 && i2 == 3)
|
||||||
|
k2 = k1;
|
||||||
|
if (j1 >= 0 && i2 == 5)
|
||||||
|
k2 = j1;
|
||||||
|
if (k2 >= 256 && k2 < 512 && !IdentityKit.kits[k2 - 256].bodyLoaded())
|
||||||
|
flag = true;
|
||||||
|
if (k2 >= 512 && !ItemDefinition.lookup(k2 - 512).isEquippedModelCached(gender))
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
if (cachedModel != -1L)
|
||||||
|
model_1 = (Model) models.get(cachedModel );
|
||||||
|
if (model_1 == null)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (model_1 == null) {
|
||||||
|
Model aclass30_sub2_sub4_sub6s[] = new Model[14];
|
||||||
|
int j2 = 0;
|
||||||
|
for (int l2 = 0; l2 < 12; l2++) {
|
||||||
|
int i3 = equipment[l2];
|
||||||
|
if (k1 >= 0 && l2 == 3)
|
||||||
|
i3 = k1;
|
||||||
|
if (j1 >= 0 && l2 == 5)
|
||||||
|
i3 = j1;
|
||||||
|
if (i3 >= 256 && i3 < 512) {
|
||||||
|
Model model_3 = IdentityKit.kits[i3 - 256].bodyModel();
|
||||||
|
if (model_3 != null)
|
||||||
|
aclass30_sub2_sub4_sub6s[j2++] = model_3;
|
||||||
|
}
|
||||||
|
if (i3 >= 512) {
|
||||||
|
Model model_4 = ItemDefinition.lookup(i3 - 512).getEquippedModel(gender);
|
||||||
|
if (model_4 != null)
|
||||||
|
aclass30_sub2_sub4_sub6s[j2++] = model_4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model_1 = new Model(j2, aclass30_sub2_sub4_sub6s);
|
||||||
|
for (int j3 = 0; j3 < 5; j3++)
|
||||||
|
if (appearanceColors[j3] != 0) {
|
||||||
|
model_1.recolor(Client.PLAYER_BODY_RECOLOURS[j3][0],
|
||||||
|
Client.PLAYER_BODY_RECOLOURS[j3][appearanceColors[j3]]);
|
||||||
|
if (j3 == 1)
|
||||||
|
model_1.recolor(Client.anIntArray1204[0], Client.anIntArray1204[appearanceColors[j3]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
model_1.skin();
|
||||||
|
model_1.scale(132, 132, 132);
|
||||||
|
model_1.light(64, 850, -30, -50, -30, true);
|
||||||
|
models.put(model_1, l);
|
||||||
|
cachedModel = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aBoolean1699) {
|
||||||
|
return model_1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Model emptyModel = Model.EMPTY_MODEL;
|
||||||
|
|
||||||
|
emptyModel.method464(model_1, Frame.noAnimationInProgress(currentFrame) & Frame.noAnimationInProgress(i1));
|
||||||
|
if (currentFrame != -1 && i1 != -1) {
|
||||||
|
emptyModel.applyAnimationFrames(Animation.animations[super.emoteAnimation].interleaveOrder, i1, currentFrame);
|
||||||
|
} else if(currentFrame != -1) {
|
||||||
|
//emptyModel.apply(currentFrame);
|
||||||
|
emptyModel.applyAnimationFrame(currentFrame, nextFrame, cycle1, cycle2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*else if (currentFrame != -1 && nextFrame != -1) {
|
||||||
|
emptyModel.applyAnimationFrame(currentFrame, nextFrame, cycle1, cycle2);
|
||||||
|
} else {
|
||||||
|
emptyModel.apply(currentFrame);
|
||||||
|
}*/
|
||||||
|
emptyModel.calculateDistances();
|
||||||
|
emptyModel.faceGroups = null;
|
||||||
|
emptyModel.vertexGroups = null;
|
||||||
|
return emptyModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getHeadModel() {
|
||||||
|
if (!visible) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (npcDefinition != null) {
|
||||||
|
return npcDefinition.model();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean cached = false;
|
||||||
|
|
||||||
|
for (int index = 0; index < 12; index++) {
|
||||||
|
int appearanceId = equipment[index];
|
||||||
|
|
||||||
|
if (appearanceId >= 256 && appearanceId < 512 && !IdentityKit.kits[appearanceId - 256].headLoaded()) {
|
||||||
|
cached = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appearanceId >= 512 && !ItemDefinition.lookup(appearanceId - 512).isDialogueModelCached(gender)) {
|
||||||
|
cached = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cached) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Model headModels[] = new Model[12];
|
||||||
|
|
||||||
|
int headModelsOffset = 0;
|
||||||
|
|
||||||
|
for (int modelIndex = 0; modelIndex < 12; modelIndex ++) {
|
||||||
|
int appearanceId = equipment[modelIndex ];
|
||||||
|
|
||||||
|
if (appearanceId >= 256 && appearanceId < 512) {
|
||||||
|
|
||||||
|
Model subModel = IdentityKit.kits[appearanceId - 256].headModel();
|
||||||
|
|
||||||
|
if (subModel != null) {
|
||||||
|
headModels[headModelsOffset ++] = subModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (appearanceId >= 512) {
|
||||||
|
Model subModel = ItemDefinition.lookup(appearanceId - 512).getChatEquipModel(gender);
|
||||||
|
|
||||||
|
if (subModel != null) {
|
||||||
|
headModels[headModelsOffset ++] = subModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Model headModel = new Model(headModelsOffset , headModels);
|
||||||
|
|
||||||
|
for (int index = 0; index < 5; index ++) {
|
||||||
|
if (appearanceColors[index ] != 0) {
|
||||||
|
headModel.recolor(Client.PLAYER_BODY_RECOLOURS[index ][0],
|
||||||
|
Client.PLAYER_BODY_RECOLOURS[index ][appearanceColors[index ]]);
|
||||||
|
if (index == 1) {
|
||||||
|
headModel.recolor(Client.anIntArray1204[0], Client.anIntArray1204[appearanceColors[index ]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return headModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisible() {
|
||||||
|
return visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package org.rebotted.entity;
|
||||||
|
import org.rebotted.collection.Cacheable;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
import org.rebotted.entity.model.VertexNormal;
|
||||||
|
|
||||||
|
public class Renderable extends Cacheable {
|
||||||
|
|
||||||
|
public int modelBaseY;
|
||||||
|
public VertexNormal vertexNormals[];
|
||||||
|
|
||||||
|
public void renderAtPoint(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) {
|
||||||
|
Model model = getRotatedModel();
|
||||||
|
if(model != null) {
|
||||||
|
modelBaseY = model.modelBaseY;
|
||||||
|
model.renderAtPoint(i, j, k, l, i1, j1, k1, l1, i2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getRotatedModel() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Renderable() {
|
||||||
|
modelBaseY = 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
|||||||
|
package org.rebotted.entity.model;
|
||||||
|
|
||||||
|
final class ModelHeader
|
||||||
|
{
|
||||||
|
|
||||||
|
public ModelHeader()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte aByteArray368[];
|
||||||
|
public int anInt369;
|
||||||
|
public int anInt370;
|
||||||
|
public int anInt371;
|
||||||
|
public int anInt372;
|
||||||
|
public int anInt373;
|
||||||
|
public int anInt374;
|
||||||
|
public int anInt375;
|
||||||
|
public int anInt376;
|
||||||
|
public int anInt377;
|
||||||
|
public int anInt378;
|
||||||
|
public int anInt379;
|
||||||
|
public int anInt380;
|
||||||
|
public int anInt381;
|
||||||
|
public int anInt382;
|
||||||
|
public int anInt383;
|
||||||
|
public int anInt384;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package org.rebotted.entity.model;
|
||||||
|
|
||||||
|
public final class VertexNormal {
|
||||||
|
|
||||||
|
public int normalX;
|
||||||
|
public int normalY;
|
||||||
|
public int normalZ;
|
||||||
|
public int magnitude;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,386 @@
|
|||||||
|
package org.rebotted.io;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import org.rebotted.Configuration;
|
||||||
|
import org.rebotted.collection.Cacheable;
|
||||||
|
import org.rebotted.net.IsaacCipher;
|
||||||
|
import org.rebotted.sign.SignLink;
|
||||||
|
|
||||||
|
public final class Buffer extends Cacheable {
|
||||||
|
|
||||||
|
public byte payload[];
|
||||||
|
public int currentPosition;
|
||||||
|
public int bitPosition;
|
||||||
|
private static final int[] BIT_MASKS = { 0, 1, 3, 7, 15, 31, 63, 127, 255,
|
||||||
|
511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff,
|
||||||
|
0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff,
|
||||||
|
0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff,
|
||||||
|
0x7fffffff, -1 };
|
||||||
|
|
||||||
|
public IsaacCipher encryption;
|
||||||
|
|
||||||
|
public static Buffer create() {
|
||||||
|
Buffer buffer = new Buffer();
|
||||||
|
buffer.currentPosition = 0;
|
||||||
|
buffer.payload = new byte[5000];
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int readUTriByte(int i) {
|
||||||
|
currentPosition += 3;
|
||||||
|
return (0xff & payload[currentPosition - 3] << 16)
|
||||||
|
+ (0xff & payload[currentPosition - 2] << 8)
|
||||||
|
+ (0xff & payload[currentPosition - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Buffer() {}
|
||||||
|
|
||||||
|
public Buffer(byte[] payload) {
|
||||||
|
this.payload = payload;
|
||||||
|
currentPosition = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readUSmart2() {
|
||||||
|
int baseVal = 0;
|
||||||
|
int lastVal = 0;
|
||||||
|
while ((lastVal = readUSmart()) == 32767) {
|
||||||
|
baseVal += 32767;
|
||||||
|
}
|
||||||
|
return baseVal + lastVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String readNewString() {
|
||||||
|
int i = currentPosition;
|
||||||
|
while (payload[currentPosition++] != 0)
|
||||||
|
;
|
||||||
|
return new String(payload, i, currentPosition - i - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeOpcode(int opcode) {
|
||||||
|
payload[currentPosition++] = (byte) (opcode + encryption.getNextKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeByte(int value) {
|
||||||
|
payload[currentPosition++] = (byte) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeShort(int value) {
|
||||||
|
payload[currentPosition++] = (byte) (value >> 8);
|
||||||
|
payload[currentPosition++] = (byte) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeTriByte(int value) {
|
||||||
|
payload[currentPosition++] = (byte) (value >> 16);
|
||||||
|
payload[currentPosition++] = (byte) (value >> 8);
|
||||||
|
payload[currentPosition++] = (byte) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeInt(int value) {
|
||||||
|
payload[currentPosition++] = (byte) (value >> 24);
|
||||||
|
payload[currentPosition++] = (byte) (value >> 16);
|
||||||
|
payload[currentPosition++] = (byte) (value >> 8);
|
||||||
|
payload[currentPosition++] = (byte) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeLEInt(int value) {
|
||||||
|
payload[currentPosition++] = (byte) value;
|
||||||
|
payload[currentPosition++] = (byte) (value >> 8);
|
||||||
|
payload[currentPosition++] = (byte) (value >> 16);
|
||||||
|
payload[currentPosition++] = (byte) (value >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeLong(long value) {
|
||||||
|
try {
|
||||||
|
payload[currentPosition++] = (byte) (int) (value >> 56);
|
||||||
|
payload[currentPosition++] = (byte) (int) (value >> 48);
|
||||||
|
payload[currentPosition++] = (byte) (int) (value >> 40);
|
||||||
|
payload[currentPosition++] = (byte) (int) (value >> 32);
|
||||||
|
payload[currentPosition++] = (byte) (int) (value >> 24);
|
||||||
|
payload[currentPosition++] = (byte) (int) (value >> 16);
|
||||||
|
payload[currentPosition++] = (byte) (int) (value >> 8);
|
||||||
|
payload[currentPosition++] = (byte) (int) value;
|
||||||
|
} catch (RuntimeException runtimeexception) {
|
||||||
|
SignLink.reporterror("14395, " + 5 + ", " + value + ", "
|
||||||
|
+ runtimeexception.toString());
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeString(String text) {
|
||||||
|
System.arraycopy(text.getBytes(), 0, payload, currentPosition,
|
||||||
|
text.length());
|
||||||
|
currentPosition += text.length();
|
||||||
|
payload[currentPosition++] = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeBytes(byte data[], int offset, int length) {
|
||||||
|
for (int index = length; index < length + offset; index++)
|
||||||
|
payload[currentPosition++] = data[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeBytes(int value) {
|
||||||
|
payload[currentPosition - value - 1] = (byte) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readUnsignedByte() {
|
||||||
|
return payload[currentPosition++] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readShort2() {
|
||||||
|
currentPosition += 2;
|
||||||
|
int i = ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] & 0xff);
|
||||||
|
if(i > 32767)
|
||||||
|
i -= 65537;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
public byte readSignedByte() {
|
||||||
|
return payload[currentPosition++];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readUShort() {
|
||||||
|
currentPosition += 2;
|
||||||
|
return ((payload[currentPosition - 2] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 1] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readShort() {
|
||||||
|
currentPosition += 2;
|
||||||
|
int value = ((payload[currentPosition - 2] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 1] & 0xff);
|
||||||
|
|
||||||
|
if (value > 32767) {
|
||||||
|
value -= 0x10000;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readTriByte() {
|
||||||
|
currentPosition += 3;
|
||||||
|
return ((payload[currentPosition - 3] & 0xff) << 16)
|
||||||
|
+ ((payload[currentPosition - 2] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 1] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readInt() {
|
||||||
|
currentPosition += 4;
|
||||||
|
return ((payload[currentPosition - 4] & 0xff) << 24)
|
||||||
|
+ ((payload[currentPosition - 3] & 0xff) << 16)
|
||||||
|
+ ((payload[currentPosition - 2] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 1] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readDWord() {
|
||||||
|
currentPosition += 4;
|
||||||
|
return ((payload[currentPosition - 4] & 0xff) << 24) + ((payload[currentPosition - 3] & 0xff) << 16) + ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public long readLong() {
|
||||||
|
long msi = (long) readInt() & 0xffffffffL;
|
||||||
|
long lsi = (long) readInt() & 0xffffffffL;
|
||||||
|
return (msi << 32) + lsi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String readString() {
|
||||||
|
int index = currentPosition;
|
||||||
|
while (payload[currentPosition++] != 10)
|
||||||
|
;
|
||||||
|
return new String(payload, index, currentPosition - index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] readBytes() {
|
||||||
|
int index = currentPosition;
|
||||||
|
while (payload[currentPosition++] != 10)
|
||||||
|
;
|
||||||
|
byte data[] = new byte[currentPosition - index - 1];
|
||||||
|
System.arraycopy(payload, index, data, index - index, currentPosition - 1 - index);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readBytes(int offset, int length, byte data[]) {
|
||||||
|
for (int index = length; index < length + offset; index++)
|
||||||
|
data[index] = payload[currentPosition++];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initBitAccess() {
|
||||||
|
bitPosition = currentPosition * 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readBits(int amount) {
|
||||||
|
int byteOffset = bitPosition >> 3;
|
||||||
|
int bitOffset = 8 - (bitPosition & 7);
|
||||||
|
int value = 0;
|
||||||
|
bitPosition += amount;
|
||||||
|
for (; amount > bitOffset; bitOffset = 8) {
|
||||||
|
value += (payload[byteOffset++] & BIT_MASKS[bitOffset]) << amount
|
||||||
|
- bitOffset;
|
||||||
|
amount -= bitOffset;
|
||||||
|
}
|
||||||
|
if (amount == bitOffset)
|
||||||
|
value += payload[byteOffset] & BIT_MASKS[bitOffset];
|
||||||
|
else
|
||||||
|
value += payload[byteOffset] >> bitOffset - amount
|
||||||
|
& BIT_MASKS[amount];
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableBitAccess() {
|
||||||
|
currentPosition = (bitPosition + 7) / 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readSmart() {
|
||||||
|
int value = payload[currentPosition] & 0xff;
|
||||||
|
if (value < 128)
|
||||||
|
return readUnsignedByte() - 64;
|
||||||
|
else
|
||||||
|
return readUShort() - 49152;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readUSmart() {
|
||||||
|
int value = payload[currentPosition] & 0xff;
|
||||||
|
if (value < 128)
|
||||||
|
return readUnsignedByte();
|
||||||
|
else
|
||||||
|
return readUShort() - 32768;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void encodeRSA(BigInteger exponent, BigInteger modulus) {
|
||||||
|
int length = currentPosition;
|
||||||
|
currentPosition = 0;
|
||||||
|
byte buffer[] = new byte[length];
|
||||||
|
readBytes(length, 0, buffer);
|
||||||
|
|
||||||
|
byte rsa[] = buffer;
|
||||||
|
|
||||||
|
if (Configuration.ENABLE_RSA) {
|
||||||
|
rsa = new BigInteger(buffer).modPow(exponent, modulus)
|
||||||
|
.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
currentPosition = 0;
|
||||||
|
writeByte(rsa.length);
|
||||||
|
writeBytes(rsa, rsa.length, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeNegatedByte(int value) {
|
||||||
|
payload[currentPosition++] = (byte) (-value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeByteS(int value) {
|
||||||
|
payload[currentPosition++] = (byte) (128 - value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readUByteA() {
|
||||||
|
return payload[currentPosition++] - 128 & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readNegUByte() {
|
||||||
|
return -payload[currentPosition++] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readUByteS() {
|
||||||
|
return 128 - payload[currentPosition++] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte readNegByte() {
|
||||||
|
return (byte) -payload[currentPosition++];
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte readByteS() {
|
||||||
|
return (byte) (128 - payload[currentPosition++]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeLEShort(int value) {
|
||||||
|
payload[currentPosition++] = (byte) value;
|
||||||
|
payload[currentPosition++] = (byte) (value >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeShortA(int value) {
|
||||||
|
payload[currentPosition++] = (byte) (value >> 8);
|
||||||
|
payload[currentPosition++] = (byte) (value + 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeLEShortA(int value) {
|
||||||
|
payload[currentPosition++] = (byte) (value + 128);
|
||||||
|
payload[currentPosition++] = (byte) (value >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readLEUShort() {
|
||||||
|
currentPosition += 2;
|
||||||
|
return ((payload[currentPosition - 1] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 2] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readUShortA() {
|
||||||
|
currentPosition += 2;
|
||||||
|
return ((payload[currentPosition - 2] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 1] - 128 & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readLEUShortA() {
|
||||||
|
currentPosition += 2;
|
||||||
|
return ((payload[currentPosition - 1] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 2] - 128 & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readLEShort() {
|
||||||
|
currentPosition += 2;
|
||||||
|
int value = ((payload[currentPosition - 1] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 2] & 0xff);
|
||||||
|
|
||||||
|
if (value > 32767) {
|
||||||
|
value -= 0x10000;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readLEShortA() {
|
||||||
|
currentPosition += 2;
|
||||||
|
int value = ((payload[currentPosition - 1] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 2] - 128 & 0xff);
|
||||||
|
if (value > 32767)
|
||||||
|
value -= 0x10000;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readSignedWord() {
|
||||||
|
currentPosition += 2;
|
||||||
|
int i = ((payload[currentPosition - 2] & 0xff) << 8) + (payload[currentPosition - 1] & 0xff);
|
||||||
|
if (i > 32767) {
|
||||||
|
i -= 0x10000;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readMEInt() { // V1
|
||||||
|
currentPosition += 4;
|
||||||
|
return ((payload[currentPosition - 2] & 0xff) << 24)
|
||||||
|
+ ((payload[currentPosition - 1] & 0xff) << 16)
|
||||||
|
+ ((payload[currentPosition - 4] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 3] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int readIMEInt() { // V2
|
||||||
|
currentPosition += 4;
|
||||||
|
return ((payload[currentPosition - 3] & 0xff) << 24)
|
||||||
|
+ ((payload[currentPosition - 4] & 0xff) << 16)
|
||||||
|
+ ((payload[currentPosition - 1] & 0xff) << 8)
|
||||||
|
+ (payload[currentPosition - 2] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeReverseDataA(byte data[], int length, int offset) {
|
||||||
|
for (int index = (length + offset) - 1; index >= length; index--) {
|
||||||
|
payload[currentPosition++] = (byte) (data[index] + 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readReverseData(byte data[], int offset, int length) {
|
||||||
|
for (int index = (length + offset) - 1; index >= length; index--) {
|
||||||
|
data[index] = payload[currentPosition++];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
package org.rebotted.net;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import org.rebotted.GameApplet;
|
||||||
|
|
||||||
|
public final class BufferedConnection implements Runnable {
|
||||||
|
|
||||||
|
public BufferedConnection(GameApplet RSApplet_, Socket socket1)
|
||||||
|
throws IOException {
|
||||||
|
closed = false;
|
||||||
|
isWriter = false;
|
||||||
|
hasIOError = false;
|
||||||
|
rsApplet = RSApplet_;
|
||||||
|
socket = socket1;
|
||||||
|
socket.setSoTimeout(30000);
|
||||||
|
socket.setTcpNoDelay(true);
|
||||||
|
inputStream = socket.getInputStream();
|
||||||
|
outputStream = socket.getOutputStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
closed = true;
|
||||||
|
try {
|
||||||
|
if (inputStream != null)
|
||||||
|
inputStream.close();
|
||||||
|
if (outputStream != null)
|
||||||
|
outputStream.close();
|
||||||
|
if (socket != null)
|
||||||
|
socket.close();
|
||||||
|
} catch (IOException _ex) {
|
||||||
|
System.out.println("Error closing stream");
|
||||||
|
}
|
||||||
|
isWriter = false;
|
||||||
|
synchronized (this) {
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
buffer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int read() throws IOException {
|
||||||
|
if (closed)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return inputStream.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int available() throws IOException {
|
||||||
|
if (closed)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return inputStream.available();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flushInputStream(byte abyte0[], int j) throws IOException {
|
||||||
|
int i = 0;// was parameter
|
||||||
|
if (closed)
|
||||||
|
return;
|
||||||
|
int k;
|
||||||
|
for (; j > 0; j -= k) {
|
||||||
|
k = inputStream.read(abyte0, i, j);
|
||||||
|
if (k <= 0)
|
||||||
|
throw new IOException("EOF");
|
||||||
|
i += k;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void queueBytes(int i, byte abyte0[]) throws IOException {
|
||||||
|
if (closed)
|
||||||
|
return;
|
||||||
|
if (hasIOError) {
|
||||||
|
hasIOError = false;
|
||||||
|
throw new IOException("Error in writer thread");
|
||||||
|
}
|
||||||
|
if (buffer == null)
|
||||||
|
buffer = new byte[5000];
|
||||||
|
synchronized (this) {
|
||||||
|
for (int l = 0; l < i; l++) {
|
||||||
|
buffer[buffIndex] = abyte0[l];
|
||||||
|
buffIndex = (buffIndex + 1) % 5000;
|
||||||
|
if (buffIndex == (writeIndex + 4900) % 5000)
|
||||||
|
throw new IOException("buffer overflow");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isWriter) {
|
||||||
|
isWriter = true;
|
||||||
|
rsApplet.startRunnable(this, 3);
|
||||||
|
}
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
while (isWriter) {
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
synchronized (this) {
|
||||||
|
if (buffIndex == writeIndex)
|
||||||
|
try {
|
||||||
|
wait();
|
||||||
|
} catch (InterruptedException _ex) {
|
||||||
|
}
|
||||||
|
if (!isWriter)
|
||||||
|
return;
|
||||||
|
j = writeIndex;
|
||||||
|
if (buffIndex >= writeIndex)
|
||||||
|
i = buffIndex - writeIndex;
|
||||||
|
else
|
||||||
|
i = 5000 - writeIndex;
|
||||||
|
}
|
||||||
|
if (i > 0) {
|
||||||
|
try {
|
||||||
|
outputStream.write(buffer, j, i);
|
||||||
|
} catch (IOException _ex) {
|
||||||
|
hasIOError = true;
|
||||||
|
}
|
||||||
|
writeIndex = (writeIndex + i) % 5000;
|
||||||
|
try {
|
||||||
|
if (buffIndex == writeIndex)
|
||||||
|
outputStream.flush();
|
||||||
|
} catch (IOException _ex) {
|
||||||
|
hasIOError = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printDebug() {
|
||||||
|
System.out.println("dummy:" + closed);
|
||||||
|
System.out.println("tcycl:" + writeIndex);
|
||||||
|
System.out.println("tnum:" + buffIndex);
|
||||||
|
System.out.println("writer:" + isWriter);
|
||||||
|
System.out.println("ioerror:" + hasIOError);
|
||||||
|
try {
|
||||||
|
System.out.println("available:" + available());
|
||||||
|
} catch (IOException _ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private InputStream inputStream;
|
||||||
|
private OutputStream outputStream;
|
||||||
|
private final Socket socket;
|
||||||
|
private boolean closed;
|
||||||
|
private final GameApplet rsApplet;
|
||||||
|
private byte[] buffer;
|
||||||
|
private int writeIndex;
|
||||||
|
private int buffIndex;
|
||||||
|
private boolean isWriter;
|
||||||
|
private boolean hasIOError;
|
||||||
|
}
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
package org.rebotted.net;
|
||||||
|
|
||||||
|
public final class IsaacCipher {
|
||||||
|
|
||||||
|
public IsaacCipher(int seed[]) {
|
||||||
|
memory = new int[256];
|
||||||
|
results = new int[256];
|
||||||
|
System.arraycopy(seed, 0, results, 0, seed.length);
|
||||||
|
initializeKeySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNextKey() {
|
||||||
|
if (count-- == 0) {
|
||||||
|
isaac();
|
||||||
|
count = 255;
|
||||||
|
}
|
||||||
|
return results[count];
|
||||||
|
}
|
||||||
|
|
||||||
|
private void isaac() {
|
||||||
|
lastResult += ++counter;
|
||||||
|
for (int i = 0; i < 256; i++) {
|
||||||
|
int j = memory[i];
|
||||||
|
if ((i & 3) == 0)
|
||||||
|
accumulator ^= accumulator << 13;
|
||||||
|
else if ((i & 3) == 1)
|
||||||
|
accumulator ^= accumulator >>> 6;
|
||||||
|
else if ((i & 3) == 2)
|
||||||
|
accumulator ^= accumulator << 2;
|
||||||
|
else if ((i & 3) == 3)
|
||||||
|
accumulator ^= accumulator >>> 16;
|
||||||
|
accumulator += memory[i + 128 & 0xff];
|
||||||
|
int k;
|
||||||
|
memory[i] = k = memory[(j & 0x3fc) >> 2] + accumulator + lastResult;
|
||||||
|
results[i] = lastResult = memory[(k >> 8 & 0x3fc) >> 2] + j;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeKeySet() {
|
||||||
|
int i1;
|
||||||
|
int j1;
|
||||||
|
int k1;
|
||||||
|
int l1;
|
||||||
|
int i2;
|
||||||
|
int j2;
|
||||||
|
int k2;
|
||||||
|
int l = i1 = j1 = k1 = l1 = i2 = j2 = k2 = 0x9e3779b9;
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
l ^= i1 << 11;
|
||||||
|
k1 += l;
|
||||||
|
i1 += j1;
|
||||||
|
i1 ^= j1 >>> 2;
|
||||||
|
l1 += i1;
|
||||||
|
j1 += k1;
|
||||||
|
j1 ^= k1 << 8;
|
||||||
|
i2 += j1;
|
||||||
|
k1 += l1;
|
||||||
|
k1 ^= l1 >>> 16;
|
||||||
|
j2 += k1;
|
||||||
|
l1 += i2;
|
||||||
|
l1 ^= i2 << 10;
|
||||||
|
k2 += l1;
|
||||||
|
i2 += j2;
|
||||||
|
i2 ^= j2 >>> 4;
|
||||||
|
l += i2;
|
||||||
|
j2 += k2;
|
||||||
|
j2 ^= k2 << 8;
|
||||||
|
i1 += j2;
|
||||||
|
k2 += l;
|
||||||
|
k2 ^= l >>> 9;
|
||||||
|
j1 += k2;
|
||||||
|
l += i1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < 256; j += 8) {
|
||||||
|
l += results[j];
|
||||||
|
i1 += results[j + 1];
|
||||||
|
j1 += results[j + 2];
|
||||||
|
k1 += results[j + 3];
|
||||||
|
l1 += results[j + 4];
|
||||||
|
i2 += results[j + 5];
|
||||||
|
j2 += results[j + 6];
|
||||||
|
k2 += results[j + 7];
|
||||||
|
l ^= i1 << 11;
|
||||||
|
k1 += l;
|
||||||
|
i1 += j1;
|
||||||
|
i1 ^= j1 >>> 2;
|
||||||
|
l1 += i1;
|
||||||
|
j1 += k1;
|
||||||
|
j1 ^= k1 << 8;
|
||||||
|
i2 += j1;
|
||||||
|
k1 += l1;
|
||||||
|
k1 ^= l1 >>> 16;
|
||||||
|
j2 += k1;
|
||||||
|
l1 += i2;
|
||||||
|
l1 ^= i2 << 10;
|
||||||
|
k2 += l1;
|
||||||
|
i2 += j2;
|
||||||
|
i2 ^= j2 >>> 4;
|
||||||
|
l += i2;
|
||||||
|
j2 += k2;
|
||||||
|
j2 ^= k2 << 8;
|
||||||
|
i1 += j2;
|
||||||
|
k2 += l;
|
||||||
|
k2 ^= l >>> 9;
|
||||||
|
j1 += k2;
|
||||||
|
l += i1;
|
||||||
|
memory[j] = l;
|
||||||
|
memory[j + 1] = i1;
|
||||||
|
memory[j + 2] = j1;
|
||||||
|
memory[j + 3] = k1;
|
||||||
|
memory[j + 4] = l1;
|
||||||
|
memory[j + 5] = i2;
|
||||||
|
memory[j + 6] = j2;
|
||||||
|
memory[j + 7] = k2;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = 0; k < 256; k += 8) {
|
||||||
|
l += memory[k];
|
||||||
|
i1 += memory[k + 1];
|
||||||
|
j1 += memory[k + 2];
|
||||||
|
k1 += memory[k + 3];
|
||||||
|
l1 += memory[k + 4];
|
||||||
|
i2 += memory[k + 5];
|
||||||
|
j2 += memory[k + 6];
|
||||||
|
k2 += memory[k + 7];
|
||||||
|
l ^= i1 << 11;
|
||||||
|
k1 += l;
|
||||||
|
i1 += j1;
|
||||||
|
i1 ^= j1 >>> 2;
|
||||||
|
l1 += i1;
|
||||||
|
j1 += k1;
|
||||||
|
j1 ^= k1 << 8;
|
||||||
|
i2 += j1;
|
||||||
|
k1 += l1;
|
||||||
|
k1 ^= l1 >>> 16;
|
||||||
|
j2 += k1;
|
||||||
|
l1 += i2;
|
||||||
|
l1 ^= i2 << 10;
|
||||||
|
k2 += l1;
|
||||||
|
i2 += j2;
|
||||||
|
i2 ^= j2 >>> 4;
|
||||||
|
l += i2;
|
||||||
|
j2 += k2;
|
||||||
|
j2 ^= k2 << 8;
|
||||||
|
i1 += j2;
|
||||||
|
k2 += l;
|
||||||
|
k2 ^= l >>> 9;
|
||||||
|
j1 += k2;
|
||||||
|
l += i1;
|
||||||
|
memory[k] = l;
|
||||||
|
memory[k + 1] = i1;
|
||||||
|
memory[k + 2] = j1;
|
||||||
|
memory[k + 3] = k1;
|
||||||
|
memory[k + 4] = l1;
|
||||||
|
memory[k + 5] = i2;
|
||||||
|
memory[k + 6] = j2;
|
||||||
|
memory[k + 7] = k2;
|
||||||
|
}
|
||||||
|
|
||||||
|
isaac();
|
||||||
|
count = 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int count;
|
||||||
|
private final int[] results;
|
||||||
|
private final int[] memory;
|
||||||
|
private int accumulator;
|
||||||
|
private int lastResult;
|
||||||
|
private int counter;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.rebotted.net.requester;
|
||||||
|
|
||||||
|
public abstract class Provider {
|
||||||
|
|
||||||
|
public abstract void provide(int file);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package org.rebotted.net.requester;
|
||||||
|
|
||||||
|
import org.rebotted.collection.Cacheable;
|
||||||
|
|
||||||
|
public final class Resource extends Cacheable {
|
||||||
|
|
||||||
|
public int dataType;
|
||||||
|
public byte buffer[];
|
||||||
|
public int ID;
|
||||||
|
boolean incomplete;
|
||||||
|
int loopCycle;
|
||||||
|
|
||||||
|
public Resource() {
|
||||||
|
incomplete = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,625 @@
|
|||||||
|
package org.rebotted.net.requester;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.cache.FileArchive;
|
||||||
|
import org.rebotted.cache.FileStore;
|
||||||
|
import org.rebotted.collection.Deque;
|
||||||
|
import org.rebotted.collection.Queue;
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
import org.rebotted.sign.SignLink;
|
||||||
|
import org.rebotted.util.CacheUtils;
|
||||||
|
|
||||||
|
public final class ResourceProvider extends Provider implements Runnable {
|
||||||
|
|
||||||
|
private int totalFiles;
|
||||||
|
private final Deque requested;
|
||||||
|
private int maximumPriority;
|
||||||
|
public String loadingMessage;
|
||||||
|
private int deadTime;
|
||||||
|
private long lastRequestTime;
|
||||||
|
private int[] landscapes;
|
||||||
|
private final byte[] payload;
|
||||||
|
public int tick;
|
||||||
|
private final byte[][] fileStatus;
|
||||||
|
private Client clientInstance;
|
||||||
|
private final Deque extras;
|
||||||
|
private int completedSize;
|
||||||
|
private int remainingData;
|
||||||
|
private int[] musicPriorities;
|
||||||
|
public int errors;
|
||||||
|
private int[] mapFiles;
|
||||||
|
private int filesLoaded;
|
||||||
|
private boolean running;
|
||||||
|
private OutputStream outputStream;
|
||||||
|
private int[] membersArea;
|
||||||
|
private boolean expectingData;
|
||||||
|
private final Deque complete;
|
||||||
|
private final byte[] gzipInputBuffer;
|
||||||
|
private int[] anIntArray1360;
|
||||||
|
private final Queue requests;
|
||||||
|
private InputStream inputStream;
|
||||||
|
private Socket socket;
|
||||||
|
private final int[][] versions;
|
||||||
|
private int uncompletedCount;
|
||||||
|
private int completedCount;
|
||||||
|
private final Deque unrequested;
|
||||||
|
private Resource current;
|
||||||
|
private final Deque mandatoryRequests;
|
||||||
|
private int[] areas;
|
||||||
|
private byte[] modelIndices;
|
||||||
|
private int idleTime;
|
||||||
|
|
||||||
|
public ResourceProvider() {
|
||||||
|
requested = new Deque();
|
||||||
|
loadingMessage = "";
|
||||||
|
payload = new byte[500];
|
||||||
|
fileStatus = new byte[4][];
|
||||||
|
extras = new Deque();
|
||||||
|
running = true;
|
||||||
|
expectingData = false;
|
||||||
|
complete = new Deque();
|
||||||
|
gzipInputBuffer = new byte[0x71868];
|
||||||
|
requests = new Queue();
|
||||||
|
versions = new int[4][];
|
||||||
|
unrequested = new Deque();
|
||||||
|
mandatoryRequests = new Deque();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void respond() {
|
||||||
|
try {
|
||||||
|
int available = inputStream.available();
|
||||||
|
if (remainingData == 0 && available >= 6) {
|
||||||
|
expectingData = true;
|
||||||
|
for (int skip = 0; skip < 6; skip += inputStream.read(payload, skip, 6 - skip))
|
||||||
|
;
|
||||||
|
int type = payload[0] & 0xff;
|
||||||
|
int file = ((payload[1] & 0xff) << 8) + (payload[2] & 0xff);
|
||||||
|
int length = ((payload[3] & 0xff) << 8) + (payload[4] & 0xff);
|
||||||
|
int sector = payload[5] & 0xff;
|
||||||
|
current = null;
|
||||||
|
for (Resource resource = (Resource) requested.reverseGetFirst(); resource != null; resource = (Resource) requested.reverseGetNext()) {
|
||||||
|
if (resource.dataType == type && resource.ID == file)
|
||||||
|
current = resource;
|
||||||
|
if (current != null)
|
||||||
|
resource.loopCycle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current != null) {
|
||||||
|
idleTime = 0;
|
||||||
|
if (length == 0) {
|
||||||
|
SignLink.reporterror("Rej: " + type + "," + file);
|
||||||
|
current.buffer = null;
|
||||||
|
if (current.incomplete)
|
||||||
|
synchronized (complete) {
|
||||||
|
complete.insertHead(current);
|
||||||
|
} else {
|
||||||
|
current.unlink();
|
||||||
|
}
|
||||||
|
current = null;
|
||||||
|
} else {
|
||||||
|
if (current.buffer == null && sector == 0)
|
||||||
|
current.buffer = new byte[length];
|
||||||
|
if (current.buffer == null && sector != 0)
|
||||||
|
throw new IOException("missing start of file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
completedSize = sector * 500;
|
||||||
|
remainingData = 500;
|
||||||
|
if (remainingData > length - sector * 500)
|
||||||
|
remainingData = length - sector * 500;
|
||||||
|
}
|
||||||
|
if (remainingData > 0 && available >= remainingData) {
|
||||||
|
expectingData = true;
|
||||||
|
byte data[] = payload;
|
||||||
|
int read = 0;
|
||||||
|
if (current != null) {
|
||||||
|
data = current.buffer;
|
||||||
|
read = completedSize;
|
||||||
|
}
|
||||||
|
for (int skip = 0; skip < remainingData; skip += inputStream.read(data, skip + read, remainingData - skip));
|
||||||
|
if (remainingData + completedSize >= data.length && current != null) {
|
||||||
|
if (clientInstance.indices[0] != null)
|
||||||
|
clientInstance.indices[current.dataType + 1].writeFile(data.length, data, current.ID);
|
||||||
|
if (!current.incomplete && current.dataType == 3) {
|
||||||
|
current.incomplete = true;
|
||||||
|
current.dataType = 93;
|
||||||
|
}
|
||||||
|
if (current.incomplete)
|
||||||
|
synchronized (complete) {
|
||||||
|
complete.insertHead(current);
|
||||||
|
} else {
|
||||||
|
current.unlink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remainingData = 0;
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
try {
|
||||||
|
socket.close();
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
_ex.printStackTrace();
|
||||||
|
}
|
||||||
|
socket = null;
|
||||||
|
inputStream = null;
|
||||||
|
outputStream = null;
|
||||||
|
remainingData = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int mapAmount = 0;
|
||||||
|
|
||||||
|
public int[] file_amounts = new int[4];
|
||||||
|
|
||||||
|
private final String crcNames[] = {"model_crc", "anim_crc", "midi_crc", "map_crc"};
|
||||||
|
private final int[][] crcs = new int[crcNames.length][];
|
||||||
|
|
||||||
|
public void initialize(FileArchive archive, Client client) {
|
||||||
|
for(int i = 0; i < crcNames.length; i++) {
|
||||||
|
byte[] crc_file = archive.readFile(crcNames[i]);
|
||||||
|
int length = 0;
|
||||||
|
|
||||||
|
if(crc_file != null) {
|
||||||
|
length = crc_file.length / 4;
|
||||||
|
Buffer crcStream = new Buffer(crc_file);
|
||||||
|
crcs[i] = new int[length];
|
||||||
|
fileStatus[i] = new byte[length];
|
||||||
|
for(int ptr = 0; ptr < length; ptr++) {
|
||||||
|
crcs[i][ptr] = crcStream.readInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
byte[] data = archive.readFile("map_index");
|
||||||
|
Buffer stream = new Buffer(data);
|
||||||
|
int j1 = stream.readUShort();//mapData.length / 6;
|
||||||
|
areas = new int[j1];
|
||||||
|
mapFiles = new int[j1];
|
||||||
|
landscapes = new int[j1];
|
||||||
|
membersArea = new int[j1];
|
||||||
|
file_amounts[3] = j1;
|
||||||
|
for (int i2 = 0; i2 < j1; i2++) {
|
||||||
|
areas[i2] = stream.readUShort();
|
||||||
|
mapFiles[i2] = stream.readUShort();
|
||||||
|
landscapes[i2] = stream.readUShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Map Amount: " + file_amounts[3] + "");
|
||||||
|
|
||||||
|
data = archive.readFile("midi_index");
|
||||||
|
stream = new Buffer(data);
|
||||||
|
j1 = data.length;
|
||||||
|
file_amounts[2] = j1;
|
||||||
|
musicPriorities = new int[j1];
|
||||||
|
for (int k2 = 0; k2 < j1; k2++)
|
||||||
|
musicPriorities[k2] = stream.readUnsignedByte();
|
||||||
|
System.out.println("Sounds Amount: " + file_amounts[2] + "");
|
||||||
|
|
||||||
|
|
||||||
|
//For some reason, model_index = anim_index and vice versa
|
||||||
|
data = archive.readFile("model_index");
|
||||||
|
file_amounts[1] = data.length;
|
||||||
|
|
||||||
|
data = archive.readFile("anim_index");
|
||||||
|
file_amounts[0] = data.length;
|
||||||
|
System.out.println("Model amount: "+file_amounts[0]);
|
||||||
|
|
||||||
|
clientInstance = client;
|
||||||
|
running = true;
|
||||||
|
clientInstance.startRunnable(this, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void initialize1(FileArchive archive, Client client) {
|
||||||
|
byte[] mapData = archive.readFile("map_index");
|
||||||
|
Buffer stream2 = new Buffer(mapData);
|
||||||
|
int j1 = mapData.length / 6;
|
||||||
|
areas = new int[j1];
|
||||||
|
mapFiles = new int[j1];
|
||||||
|
landscapes = new int[j1];
|
||||||
|
for (int i2 = 0; i2 < j1; i2++) {
|
||||||
|
areas[i2] = stream2.readUShort();
|
||||||
|
mapFiles[i2] = stream2.readUShort();
|
||||||
|
landscapes[i2] = stream2.readUShort();
|
||||||
|
mapAmount++;
|
||||||
|
}
|
||||||
|
System.out.println("Map Amount: " + mapAmount + "");
|
||||||
|
mapData = archive.readFile("midi_index");
|
||||||
|
stream2 = new Buffer(mapData);
|
||||||
|
j1 = mapData.length;
|
||||||
|
musicPriorities = new int[j1];
|
||||||
|
for (int k2 = 0; k2 < j1; k2++)
|
||||||
|
musicPriorities[k2] = stream2.readUnsignedByte();
|
||||||
|
|
||||||
|
clientInstance = client;
|
||||||
|
running = true;
|
||||||
|
clientInstance.startRunnable(this, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int remaining() {
|
||||||
|
synchronized (requests) {
|
||||||
|
return requests.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disable() {
|
||||||
|
running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void preloadMaps(boolean members) {
|
||||||
|
for (int area = 0; area < areas.length; area++) {
|
||||||
|
if (members || membersArea[area] != 0) {
|
||||||
|
requestExtra((byte) 2, 3, landscapes[area]);
|
||||||
|
requestExtra((byte) 2, 3, mapFiles[area]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersionCount(int index) {
|
||||||
|
return versions[index].length;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void request(Resource resource) {
|
||||||
|
try {
|
||||||
|
if (socket == null) {
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
if (currentTime - lastRequestTime < 4000L)
|
||||||
|
return;
|
||||||
|
lastRequestTime = currentTime;
|
||||||
|
socket = clientInstance.openSocket(43594 + Client.portOffset);
|
||||||
|
inputStream = socket.getInputStream();
|
||||||
|
outputStream = socket.getOutputStream();
|
||||||
|
outputStream.write(15);
|
||||||
|
for (int index = 0; index < 8; index++)
|
||||||
|
inputStream.read();
|
||||||
|
|
||||||
|
idleTime = 0;
|
||||||
|
}
|
||||||
|
payload[0] = (byte) resource.dataType;
|
||||||
|
payload[1] = (byte) (resource.ID >> 8);
|
||||||
|
payload[2] = (byte) resource.ID;
|
||||||
|
if (resource.incomplete)
|
||||||
|
payload[3] = 2;
|
||||||
|
else if (!Client.loggedIn)
|
||||||
|
payload[3] = 1;
|
||||||
|
else
|
||||||
|
payload[3] = 0;
|
||||||
|
outputStream.write(payload, 0, 4);
|
||||||
|
deadTime = 0;
|
||||||
|
errors = -10000;
|
||||||
|
return;
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
socket.close();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
socket = null;
|
||||||
|
inputStream = null;
|
||||||
|
outputStream = null;
|
||||||
|
remainingData = 0;
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAnimCount() {
|
||||||
|
return anIntArray1360.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getModelCount() {
|
||||||
|
return 29191;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void provide(int file) {
|
||||||
|
provide(0, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void provide(int type, int file) {
|
||||||
|
synchronized (requests) {
|
||||||
|
for (Resource resource = (Resource) requests.reverseGetFirst(); resource != null; resource = (Resource) requests.reverseGetNext())
|
||||||
|
if (resource.dataType == type && resource.ID == file)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Resource resource = new Resource();
|
||||||
|
resource.dataType = type;
|
||||||
|
resource.ID = file;
|
||||||
|
resource.incomplete = true;
|
||||||
|
synchronized (mandatoryRequests) {
|
||||||
|
mandatoryRequests.insertHead(resource);
|
||||||
|
}
|
||||||
|
requests.insertHead(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getModelIndex(int i) {
|
||||||
|
return modelIndices[i] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
while (running) {
|
||||||
|
tick++;
|
||||||
|
int sleepTime = 20;
|
||||||
|
if (maximumPriority == 0 && clientInstance.indices[0] != null)
|
||||||
|
sleepTime = 50;
|
||||||
|
try {
|
||||||
|
Thread.sleep(sleepTime);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
expectingData = true;
|
||||||
|
for (int index = 0; index < 100; index++) {
|
||||||
|
if (!expectingData)
|
||||||
|
break;
|
||||||
|
expectingData = false;
|
||||||
|
loadMandatory();
|
||||||
|
requestMandatory();
|
||||||
|
if (uncompletedCount == 0 && index >= 5)
|
||||||
|
break;
|
||||||
|
loadExtra();
|
||||||
|
if (inputStream != null)
|
||||||
|
respond();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean idle = false;
|
||||||
|
for (Resource resource = (Resource) requested.reverseGetFirst(); resource != null; resource = (Resource) requested.reverseGetNext())
|
||||||
|
if (resource.incomplete) {
|
||||||
|
idle = true;
|
||||||
|
resource.loopCycle++;
|
||||||
|
if (resource.loopCycle > 50) {
|
||||||
|
resource.loopCycle = 0;
|
||||||
|
request(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!idle) {
|
||||||
|
for (Resource resource = (Resource) requested.reverseGetFirst(); resource != null; resource = (Resource) requested.reverseGetNext()) {
|
||||||
|
idle = true;
|
||||||
|
resource.loopCycle++;
|
||||||
|
if (resource.loopCycle > 50) {
|
||||||
|
resource.loopCycle = 0;
|
||||||
|
request(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (idle) {
|
||||||
|
idleTime++;
|
||||||
|
if (idleTime > 750) {
|
||||||
|
try {
|
||||||
|
socket.close();
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
socket = null;
|
||||||
|
inputStream = null;
|
||||||
|
outputStream = null;
|
||||||
|
remainingData = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
idleTime = 0;
|
||||||
|
loadingMessage = "";
|
||||||
|
}
|
||||||
|
if (Client.loggedIn && socket != null && outputStream != null && (maximumPriority > 0 || clientInstance.indices[0] == null)) {
|
||||||
|
deadTime++;
|
||||||
|
if (deadTime > 500) {
|
||||||
|
deadTime = 0;
|
||||||
|
payload[0] = 0;
|
||||||
|
payload[1] = 0;
|
||||||
|
payload[2] = 0;
|
||||||
|
payload[3] = 10;
|
||||||
|
try {
|
||||||
|
outputStream.write(payload, 0, 4);
|
||||||
|
} catch (IOException _ex) {
|
||||||
|
idleTime = 5000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception exception) {
|
||||||
|
SignLink.reporterror("od_ex " + exception.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadExtra(int type, int file) {
|
||||||
|
if (clientInstance.indices[0] == null){
|
||||||
|
return;
|
||||||
|
} else if (maximumPriority == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Resource resource = new Resource();
|
||||||
|
resource.dataType = file;
|
||||||
|
resource.ID = type;
|
||||||
|
resource.incomplete = false;
|
||||||
|
synchronized (extras) {
|
||||||
|
extras.insertHead(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resource next() {
|
||||||
|
Resource resource;
|
||||||
|
synchronized (complete) {
|
||||||
|
resource = (Resource) complete.popHead();
|
||||||
|
}
|
||||||
|
if (resource == null)
|
||||||
|
return null;
|
||||||
|
synchronized (requests) {
|
||||||
|
resource.unlinkCacheable();
|
||||||
|
}
|
||||||
|
if (resource.buffer == null)
|
||||||
|
return resource;
|
||||||
|
int read = 0;
|
||||||
|
try {
|
||||||
|
GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(resource.buffer));
|
||||||
|
do {
|
||||||
|
if (read == gzipInputBuffer.length)
|
||||||
|
throw new RuntimeException("buffer overflow!");
|
||||||
|
int in = gis.read(gzipInputBuffer, read, gzipInputBuffer.length - read);
|
||||||
|
if (in == -1)
|
||||||
|
break;
|
||||||
|
read += in;
|
||||||
|
} while (true);
|
||||||
|
} catch (IOException _ex) {
|
||||||
|
System.out.println("Failed to unzip model [" + resource.ID + "] type = " + resource.dataType);
|
||||||
|
_ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
resource.buffer = new byte[read];
|
||||||
|
System.arraycopy(gzipInputBuffer, 0, resource.buffer, 0, read);
|
||||||
|
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int resolve(int regionX, int regionY, int type) {
|
||||||
|
int code = (type << 8) + regionY;
|
||||||
|
for (int area = 0; area < areas.length; area++) {
|
||||||
|
if (areas[area] == code) {
|
||||||
|
if (regionX == 0) {
|
||||||
|
return mapFiles[area] > 3535 ? -1 : mapFiles[area];
|
||||||
|
} else {
|
||||||
|
return landscapes[area] > 3535 ? -1 : landscapes[area];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestExtra(byte priority, int type, int file) {
|
||||||
|
if (clientInstance.indices[0] == null)
|
||||||
|
return;
|
||||||
|
if (versions[type][file] == 0)
|
||||||
|
return;
|
||||||
|
clientInstance.indices[type + 1].decompress(file);
|
||||||
|
fileStatus[type][file] = priority;
|
||||||
|
if (priority > maximumPriority)
|
||||||
|
maximumPriority = priority;
|
||||||
|
totalFiles++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean landscapePresent(int landscape) {
|
||||||
|
for (int index = 0; index < areas.length; index++)
|
||||||
|
if (landscapes[index] == landscape)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestMandatory() {
|
||||||
|
uncompletedCount = 0;
|
||||||
|
completedCount = 0;
|
||||||
|
for (Resource resource = (Resource) requested.reverseGetFirst(); resource != null; resource = (Resource) requested.reverseGetNext())
|
||||||
|
if (resource.incomplete) {
|
||||||
|
uncompletedCount++;
|
||||||
|
System.out.println("Error: model is incomplete or missing [ type = " + resource.dataType + "] [id = " + resource.ID + "]");
|
||||||
|
} else
|
||||||
|
completedCount++;
|
||||||
|
|
||||||
|
while (uncompletedCount < 10) {
|
||||||
|
try {
|
||||||
|
Resource request = (Resource) unrequested.popHead();
|
||||||
|
if (request == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fileStatus[request.dataType][request.ID] != 0) {
|
||||||
|
filesLoaded++;
|
||||||
|
}
|
||||||
|
fileStatus[request.dataType][request.ID] = 0;
|
||||||
|
requested.insertHead(request);
|
||||||
|
uncompletedCount++;
|
||||||
|
request(request);
|
||||||
|
expectingData = true;
|
||||||
|
System.out.println("Error: file is missing [ type = " + request.dataType + "] [id = " + request.ID + "]");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearExtras() {
|
||||||
|
synchronized (extras) {
|
||||||
|
extras.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadMandatory() {
|
||||||
|
Resource resource;
|
||||||
|
synchronized (mandatoryRequests) {
|
||||||
|
resource = (Resource) mandatoryRequests.popHead();
|
||||||
|
}
|
||||||
|
while (resource != null) {
|
||||||
|
expectingData = true;
|
||||||
|
byte data[] = null;
|
||||||
|
if (clientInstance.indices[0] != null)
|
||||||
|
data = clientInstance.indices[resource.dataType + 1].decompress(resource.ID);
|
||||||
|
synchronized (mandatoryRequests) {
|
||||||
|
if (data == null) {
|
||||||
|
unrequested.insertHead(resource);
|
||||||
|
} else {
|
||||||
|
resource.buffer = data;
|
||||||
|
synchronized (complete) {
|
||||||
|
complete.insertHead(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resource = (Resource) mandatoryRequests.popHead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadExtra() {
|
||||||
|
while (uncompletedCount == 0 && completedCount < 10) {
|
||||||
|
if (maximumPriority == 0)
|
||||||
|
break;
|
||||||
|
Resource resource;
|
||||||
|
synchronized (extras) {
|
||||||
|
resource = (Resource) extras.popHead();
|
||||||
|
}
|
||||||
|
while (resource != null) {
|
||||||
|
if (fileStatus[resource.dataType][resource.ID] != 0) {
|
||||||
|
fileStatus[resource.dataType][resource.ID] = 0;
|
||||||
|
requested.insertHead(resource);
|
||||||
|
request(resource);
|
||||||
|
expectingData = true;
|
||||||
|
if (filesLoaded < totalFiles)
|
||||||
|
filesLoaded++;
|
||||||
|
loadingMessage = "Loading extra files - " + (filesLoaded * 100) / totalFiles + "%";
|
||||||
|
completedCount++;
|
||||||
|
if (completedCount == 10)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
synchronized (extras) {
|
||||||
|
resource = (Resource) extras.popHead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int type = 0; type < 4; type++) {
|
||||||
|
byte data[] = fileStatus[type];
|
||||||
|
int size = data.length;
|
||||||
|
for (int file = 0; file < size; file++)
|
||||||
|
if (data[file] == maximumPriority) {
|
||||||
|
data[file] = 0;
|
||||||
|
Resource newResource = new Resource();
|
||||||
|
newResource.dataType = type;
|
||||||
|
newResource.ID = file;
|
||||||
|
newResource.incomplete = false;
|
||||||
|
requested.insertHead(newResource);
|
||||||
|
request(newResource);
|
||||||
|
expectingData = true;
|
||||||
|
if (filesLoaded < totalFiles)
|
||||||
|
filesLoaded++;
|
||||||
|
loadingMessage = "Loading extra files - " + (filesLoaded * 100) / totalFiles + "%";
|
||||||
|
completedCount++;
|
||||||
|
if (completedCount == 10)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maximumPriority--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean highPriorityMusic(int file) {
|
||||||
|
return musicPriorities[file] == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package org.rebotted.scene;
|
||||||
|
import org.rebotted.Configuration;
|
||||||
|
import org.rebotted.cache.anim.Frame;
|
||||||
|
import org.rebotted.cache.anim.Graphic;
|
||||||
|
import org.rebotted.entity.Renderable;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
|
||||||
|
public final class AnimableObject extends Renderable {
|
||||||
|
|
||||||
|
public final int anInt1560;
|
||||||
|
public final int anInt1561;
|
||||||
|
public final int anInt1562;
|
||||||
|
public final int anInt1563;
|
||||||
|
public final int anInt1564;
|
||||||
|
public boolean aBoolean1567;
|
||||||
|
private final Graphic graphic;
|
||||||
|
private int anInt1569;
|
||||||
|
private int anInt1570;
|
||||||
|
private int nextAnimFrameId;
|
||||||
|
|
||||||
|
public AnimableObject(int i, int j, int l, int i1, int j1, int k1, int l1) {
|
||||||
|
aBoolean1567 = false;
|
||||||
|
graphic = Graphic.cache[i1];
|
||||||
|
anInt1560 = i;
|
||||||
|
anInt1561 = l1;
|
||||||
|
anInt1562 = k1;
|
||||||
|
anInt1563 = j1;
|
||||||
|
anInt1564 = j + l;
|
||||||
|
aBoolean1567 = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getRotatedModel() {
|
||||||
|
Model model = graphic.getModel();
|
||||||
|
if(model == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int j = graphic.animationSequence.primaryFrames[anInt1569];
|
||||||
|
Model model_1 = new Model(true, Frame.noAnimationInProgress(j), false, model);
|
||||||
|
System.out.println(Configuration.enableTweening);
|
||||||
|
if(!aBoolean1567) {
|
||||||
|
|
||||||
|
model_1.skin();
|
||||||
|
if(Configuration.enableTweening && nextAnimFrameId != -1) {
|
||||||
|
model_1.applyAnimationFrame(j, graphic.animationSequence.primaryFrames[nextAnimFrameId], anInt1570, graphic.animationSequence.durations[anInt1569]);
|
||||||
|
} else {
|
||||||
|
model_1.applyTransform(j);
|
||||||
|
}
|
||||||
|
model_1.faceGroups = null;
|
||||||
|
model_1.vertexGroups = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(graphic.resizeXY != 128 || graphic.resizeZ != 128) {
|
||||||
|
model_1.scale(graphic.resizeXY, graphic.resizeXY, graphic.resizeZ);
|
||||||
|
}
|
||||||
|
if(graphic.rotation != 0) {
|
||||||
|
if(graphic.rotation == 90) {
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
}
|
||||||
|
if(graphic.rotation == 180) {
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
}
|
||||||
|
if(graphic.rotation == 270) {
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
model_1.rotate90Degrees();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model_1.light(64 + graphic.modelBrightness, 850 + graphic.modelShadow, -30, -50, -30, true);
|
||||||
|
return model_1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method454(int i) {
|
||||||
|
for(anInt1570 += i; anInt1570 > graphic.animationSequence.duration(anInt1569);) {
|
||||||
|
anInt1570 -= graphic.animationSequence.duration(anInt1569) + 1;
|
||||||
|
anInt1569++;
|
||||||
|
if(anInt1569 >= graphic.animationSequence.frameCount && (anInt1569 < 0 || anInt1569 >= graphic.animationSequence.frameCount)) {
|
||||||
|
anInt1569 = 0;
|
||||||
|
aBoolean1567 = true;
|
||||||
|
}
|
||||||
|
if (Configuration.enableTweening) {
|
||||||
|
nextAnimFrameId = anInt1569 + 1;
|
||||||
|
}
|
||||||
|
if (nextAnimFrameId >= graphic.animationSequence.frameCount) {
|
||||||
|
nextAnimFrameId = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,511 @@
|
|||||||
|
package org.rebotted.scene;
|
||||||
|
|
||||||
|
public final class CollisionMap {
|
||||||
|
|
||||||
|
private static final int BLOCKED_TILE = 0x200000;
|
||||||
|
//private static final int OBJECT_TILE = 0x100;
|
||||||
|
|
||||||
|
private final int xOffset;
|
||||||
|
private final int yOffset;
|
||||||
|
private final int width;
|
||||||
|
private final int height;
|
||||||
|
public final int[][] adjacencies;
|
||||||
|
|
||||||
|
public CollisionMap() {
|
||||||
|
xOffset = 0;
|
||||||
|
yOffset = 0;
|
||||||
|
width = 104;
|
||||||
|
height = 104;
|
||||||
|
adjacencies = new int[width][height];
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
if (x == 0 || y == 0 || x == width - 1
|
||||||
|
|| y == height - 1)
|
||||||
|
adjacencies[x][y] = 0xffffff;
|
||||||
|
else
|
||||||
|
adjacencies[x][y] = 0x1000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method211(int y, int orientation, int x, int group, boolean flag) {
|
||||||
|
x -= xOffset;
|
||||||
|
y -= yOffset;
|
||||||
|
if (group == 0) {
|
||||||
|
if (orientation == 0) {
|
||||||
|
flag(x, y, 128);
|
||||||
|
flag(x - 1, y, 8);
|
||||||
|
}
|
||||||
|
if (orientation == 1) {
|
||||||
|
flag(x, y, 2);
|
||||||
|
flag(x, y + 1, 32);
|
||||||
|
}
|
||||||
|
if (orientation == 2) {
|
||||||
|
flag(x, y, 8);
|
||||||
|
flag(x + 1, y, 128);
|
||||||
|
}
|
||||||
|
if (orientation == 3) {
|
||||||
|
flag(x, y, 32);
|
||||||
|
flag(x, y - 1, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group == 1 || group == 3) {
|
||||||
|
if (orientation == 0) {
|
||||||
|
flag(x, y, 1);
|
||||||
|
flag(x - 1, y + 1, 16);
|
||||||
|
}
|
||||||
|
if (orientation == 1) {
|
||||||
|
flag(x, y, 4);
|
||||||
|
flag(x + 1, y + 1, 64);
|
||||||
|
}
|
||||||
|
if (orientation == 2) {
|
||||||
|
flag(x, y, 16);
|
||||||
|
flag(x + 1, y - 1, 1);
|
||||||
|
}
|
||||||
|
if (orientation == 3) {
|
||||||
|
flag(x, y, 64);
|
||||||
|
flag(x - 1, y - 1, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group == 2) {
|
||||||
|
if (orientation == 0) {
|
||||||
|
flag(x, y, 130);
|
||||||
|
flag(x - 1, y, 8);
|
||||||
|
flag(x, y + 1, 32);
|
||||||
|
}
|
||||||
|
if (orientation == 1) {
|
||||||
|
flag(x, y, 10);
|
||||||
|
flag(x, y + 1, 32);
|
||||||
|
flag(x + 1, y, 128);
|
||||||
|
}
|
||||||
|
if (orientation == 2) {
|
||||||
|
flag(x, y, 40);
|
||||||
|
flag(x + 1, y, 128);
|
||||||
|
flag(x, y - 1, 2);
|
||||||
|
}
|
||||||
|
if (orientation == 3) {
|
||||||
|
flag(x, y, 160);
|
||||||
|
flag(x, y - 1, 2);
|
||||||
|
flag(x - 1, y, 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
if (group == 0) {
|
||||||
|
if (orientation == 0) {
|
||||||
|
flag(x, y, 0x10000);
|
||||||
|
flag(x - 1, y, 4096);
|
||||||
|
}
|
||||||
|
if (orientation == 1) {
|
||||||
|
flag(x, y, 1024);
|
||||||
|
flag(x, y + 1, 16384);
|
||||||
|
}
|
||||||
|
if (orientation == 2) {
|
||||||
|
flag(x, y, 4096);
|
||||||
|
flag(x + 1, y, 0x10000);
|
||||||
|
}
|
||||||
|
if (orientation == 3) {
|
||||||
|
flag(x, y, 16384);
|
||||||
|
flag(x, y - 1, 1024);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group == 1 || group == 3) {
|
||||||
|
if (orientation == 0) {
|
||||||
|
flag(x, y, 512);
|
||||||
|
flag(x - 1, y + 1, 8192);
|
||||||
|
}
|
||||||
|
if (orientation == 1) {
|
||||||
|
flag(x, y, 2048);
|
||||||
|
flag(x + 1, y + 1, 32768);
|
||||||
|
}
|
||||||
|
if (orientation == 2) {
|
||||||
|
flag(x, y, 8192);
|
||||||
|
flag(x + 1, y - 1, 512);
|
||||||
|
}
|
||||||
|
if (orientation == 3) {
|
||||||
|
flag(x, y, 32768);
|
||||||
|
flag(x - 1, y - 1, 2048);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group == 2) {
|
||||||
|
if (orientation == 0) {
|
||||||
|
flag(x, y, 0x10400);
|
||||||
|
flag(x - 1, y, 4096);
|
||||||
|
flag(x, y + 1, 16384);
|
||||||
|
}
|
||||||
|
if (orientation == 1) {
|
||||||
|
flag(x, y, 5120);
|
||||||
|
flag(x, y + 1, 16384);
|
||||||
|
flag(x + 1, y, 0x10000);
|
||||||
|
}
|
||||||
|
if (orientation == 2) {
|
||||||
|
flag(x, y, 20480);
|
||||||
|
flag(x + 1, y, 0x10000);
|
||||||
|
flag(x, y - 1, 1024);
|
||||||
|
}
|
||||||
|
if (orientation == 3) {
|
||||||
|
flag(x, y, 0x14000);
|
||||||
|
flag(x, y - 1, 1024);
|
||||||
|
flag(x - 1, y, 4096);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void method212(boolean flag, int j, int k, int l, int i1, int j1) {
|
||||||
|
int k1 = 256;
|
||||||
|
if (flag)
|
||||||
|
k1 += 0x20000;
|
||||||
|
l -= xOffset;
|
||||||
|
i1 -= yOffset;
|
||||||
|
if (j1 == 1 || j1 == 3) {
|
||||||
|
int l1 = j;
|
||||||
|
j = k;
|
||||||
|
k = l1;
|
||||||
|
}
|
||||||
|
for (int i2 = l; i2 < l + j; i2++)
|
||||||
|
if (i2 >= 0 && i2 < width) {
|
||||||
|
for (int j2 = i1; j2 < i1 + k; j2++)
|
||||||
|
if (j2 >= 0 && j2 < height)
|
||||||
|
flag(i2, j2, k1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void block(int x, int y) {
|
||||||
|
x -= xOffset;
|
||||||
|
y -= yOffset;
|
||||||
|
adjacencies[x][y] |= BLOCKED_TILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void flag(int x, int y, int value) {
|
||||||
|
adjacencies[x][y] |= value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeObject(int i, int j, boolean flag, int k, int l) {
|
||||||
|
k -= xOffset;
|
||||||
|
l -= yOffset;
|
||||||
|
if (j == 0) {
|
||||||
|
if (i == 0) {
|
||||||
|
method217(128, k, l);
|
||||||
|
method217(8, k - 1, l);
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
method217(2, k, l);
|
||||||
|
method217(32, k, l + 1);
|
||||||
|
}
|
||||||
|
if (i == 2) {
|
||||||
|
method217(8, k, l);
|
||||||
|
method217(128, k + 1, l);
|
||||||
|
}
|
||||||
|
if (i == 3) {
|
||||||
|
method217(32, k, l);
|
||||||
|
method217(2, k, l - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == 1 || j == 3) {
|
||||||
|
if (i == 0) {
|
||||||
|
method217(1, k, l);
|
||||||
|
method217(16, k - 1, l + 1);
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
method217(4, k, l);
|
||||||
|
method217(64, k + 1, l + 1);
|
||||||
|
}
|
||||||
|
if (i == 2) {
|
||||||
|
method217(16, k, l);
|
||||||
|
method217(1, k + 1, l - 1);
|
||||||
|
}
|
||||||
|
if (i == 3) {
|
||||||
|
method217(64, k, l);
|
||||||
|
method217(4, k - 1, l - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == 2) {
|
||||||
|
if (i == 0) {
|
||||||
|
method217(130, k, l);
|
||||||
|
method217(8, k - 1, l);
|
||||||
|
method217(32, k, l + 1);
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
method217(10, k, l);
|
||||||
|
method217(32, k, l + 1);
|
||||||
|
method217(128, k + 1, l);
|
||||||
|
}
|
||||||
|
if (i == 2) {
|
||||||
|
method217(40, k, l);
|
||||||
|
method217(128, k + 1, l);
|
||||||
|
method217(2, k, l - 1);
|
||||||
|
}
|
||||||
|
if (i == 3) {
|
||||||
|
method217(160, k, l);
|
||||||
|
method217(2, k, l - 1);
|
||||||
|
method217(8, k - 1, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag) {
|
||||||
|
if (j == 0) {
|
||||||
|
if (i == 0) {
|
||||||
|
method217(0x10000, k, l);
|
||||||
|
method217(4096, k - 1, l);
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
method217(1024, k, l);
|
||||||
|
method217(16384, k, l + 1);
|
||||||
|
}
|
||||||
|
if (i == 2) {
|
||||||
|
method217(4096, k, l);
|
||||||
|
method217(0x10000, k + 1, l);
|
||||||
|
}
|
||||||
|
if (i == 3) {
|
||||||
|
method217(16384, k, l);
|
||||||
|
method217(1024, k, l - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == 1 || j == 3) {
|
||||||
|
if (i == 0) {
|
||||||
|
method217(512, k, l);
|
||||||
|
method217(8192, k - 1, l + 1);
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
method217(2048, k, l);
|
||||||
|
method217(32768, k + 1, l + 1);
|
||||||
|
}
|
||||||
|
if (i == 2) {
|
||||||
|
method217(8192, k, l);
|
||||||
|
method217(512, k + 1, l - 1);
|
||||||
|
}
|
||||||
|
if (i == 3) {
|
||||||
|
method217(32768, k, l);
|
||||||
|
method217(2048, k - 1, l - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == 2) {
|
||||||
|
if (i == 0) {
|
||||||
|
method217(0x10400, k, l);
|
||||||
|
method217(4096, k - 1, l);
|
||||||
|
method217(16384, k, l + 1);
|
||||||
|
}
|
||||||
|
if (i == 1) {
|
||||||
|
method217(5120, k, l);
|
||||||
|
method217(16384, k, l + 1);
|
||||||
|
method217(0x10000, k + 1, l);
|
||||||
|
}
|
||||||
|
if (i == 2) {
|
||||||
|
method217(20480, k, l);
|
||||||
|
method217(0x10000, k + 1, l);
|
||||||
|
method217(1024, k, l - 1);
|
||||||
|
}
|
||||||
|
if (i == 3) {
|
||||||
|
method217(0x14000, k, l);
|
||||||
|
method217(1024, k, l - 1);
|
||||||
|
method217(4096, k - 1, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeObject(int i, int j, int k, int l, int i1, boolean flag) {
|
||||||
|
int j1 = 256;
|
||||||
|
if (flag)
|
||||||
|
j1 += 0x20000;
|
||||||
|
k -= xOffset;
|
||||||
|
l -= yOffset;
|
||||||
|
if (i == 1 || i == 3) {
|
||||||
|
int k1 = j;
|
||||||
|
j = i1;
|
||||||
|
i1 = k1;
|
||||||
|
}
|
||||||
|
for (int l1 = k; l1 < k + j; l1++)
|
||||||
|
if (l1 >= 0 && l1 < width) {
|
||||||
|
for (int i2 = l; i2 < l + i1; i2++)
|
||||||
|
if (i2 >= 0 && i2 < height)
|
||||||
|
method217(j1, l1, i2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void method217(int i, int j, int k) {
|
||||||
|
adjacencies[j][k] &= 0xffffff - i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFloorDecoration(int j, int k) {
|
||||||
|
k -= xOffset;
|
||||||
|
j -= yOffset;
|
||||||
|
adjacencies[k][j] &= 0xdfffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean method219(int i, int j, int k, int i1, int j1, int k1) {
|
||||||
|
if (j == i && k == k1)
|
||||||
|
return true;
|
||||||
|
j -= xOffset;
|
||||||
|
k -= yOffset;
|
||||||
|
i -= xOffset;
|
||||||
|
k1 -= yOffset;
|
||||||
|
if (j1 == 0)
|
||||||
|
if (i1 == 0) {
|
||||||
|
if (j == i - 1 && k == k1)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 + 1
|
||||||
|
&& (adjacencies[j][k] & 0x1280120) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 - 1
|
||||||
|
&& (adjacencies[j][k] & 0x1280102) == 0)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 1) {
|
||||||
|
if (j == i && k == k1 + 1)
|
||||||
|
return true;
|
||||||
|
if (j == i - 1 && k == k1
|
||||||
|
&& (adjacencies[j][k] & 0x1280108) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i + 1 && k == k1
|
||||||
|
&& (adjacencies[j][k] & 0x1280180) == 0)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 2) {
|
||||||
|
if (j == i + 1 && k == k1)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 + 1
|
||||||
|
&& (adjacencies[j][k] & 0x1280120) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 - 1
|
||||||
|
&& (adjacencies[j][k] & 0x1280102) == 0)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 3) {
|
||||||
|
if (j == i && k == k1 - 1)
|
||||||
|
return true;
|
||||||
|
if (j == i - 1 && k == k1
|
||||||
|
&& (adjacencies[j][k] & 0x1280108) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i + 1 && k == k1
|
||||||
|
&& (adjacencies[j][k] & 0x1280180) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (j1 == 2)
|
||||||
|
if (i1 == 0) {
|
||||||
|
if (j == i - 1 && k == k1)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 + 1)
|
||||||
|
return true;
|
||||||
|
if (j == i + 1 && k == k1
|
||||||
|
&& (adjacencies[j][k] & 0x1280180) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 - 1
|
||||||
|
&& (adjacencies[j][k] & 0x1280102) == 0)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 1) {
|
||||||
|
if (j == i - 1 && k == k1
|
||||||
|
&& (adjacencies[j][k] & 0x1280108) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 + 1)
|
||||||
|
return true;
|
||||||
|
if (j == i + 1 && k == k1)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 - 1
|
||||||
|
&& (adjacencies[j][k] & 0x1280102) == 0)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 2) {
|
||||||
|
if (j == i - 1 && k == k1
|
||||||
|
&& (adjacencies[j][k] & 0x1280108) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 + 1
|
||||||
|
&& (adjacencies[j][k] & 0x1280120) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i + 1 && k == k1)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 - 1)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 3) {
|
||||||
|
if (j == i - 1 && k == k1)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 + 1
|
||||||
|
&& (adjacencies[j][k] & 0x1280120) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i + 1 && k == k1
|
||||||
|
&& (adjacencies[j][k] & 0x1280180) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 - 1)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (j1 == 9) {
|
||||||
|
if (j == i && k == k1 + 1 && (adjacencies[j][k] & 0x20) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i && k == k1 - 1 && (adjacencies[j][k] & 2) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i - 1 && k == k1 && (adjacencies[j][k] & 8) == 0)
|
||||||
|
return true;
|
||||||
|
if (j == i + 1 && k == k1 && (adjacencies[j][k] & 0x80) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean method220(int i, int j, int k, int l, int i1, int j1) {
|
||||||
|
if (j1 == i && k == j)
|
||||||
|
return true;
|
||||||
|
j1 -= xOffset;
|
||||||
|
k -= yOffset;
|
||||||
|
i -= xOffset;
|
||||||
|
j -= yOffset;
|
||||||
|
if (l == 6 || l == 7) {
|
||||||
|
if (l == 7)
|
||||||
|
i1 = i1 + 2 & 3;
|
||||||
|
if (i1 == 0) {
|
||||||
|
if (j1 == i + 1 && k == j && (adjacencies[j1][k] & 0x80) == 0)
|
||||||
|
return true;
|
||||||
|
if (j1 == i && k == j - 1 && (adjacencies[j1][k] & 2) == 0)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 1) {
|
||||||
|
if (j1 == i - 1 && k == j && (adjacencies[j1][k] & 8) == 0)
|
||||||
|
return true;
|
||||||
|
if (j1 == i && k == j - 1 && (adjacencies[j1][k] & 2) == 0)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 2) {
|
||||||
|
if (j1 == i - 1 && k == j && (adjacencies[j1][k] & 8) == 0)
|
||||||
|
return true;
|
||||||
|
if (j1 == i && k == j + 1 && (adjacencies[j1][k] & 0x20) == 0)
|
||||||
|
return true;
|
||||||
|
} else if (i1 == 3) {
|
||||||
|
if (j1 == i + 1 && k == j && (adjacencies[j1][k] & 0x80) == 0)
|
||||||
|
return true;
|
||||||
|
if (j1 == i && k == j + 1 && (adjacencies[j1][k] & 0x20) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (l == 8) {
|
||||||
|
if (j1 == i && k == j + 1 && (adjacencies[j1][k] & 0x20) == 0)
|
||||||
|
return true;
|
||||||
|
if (j1 == i && k == j - 1 && (adjacencies[j1][k] & 2) == 0)
|
||||||
|
return true;
|
||||||
|
if (j1 == i - 1 && k == j && (adjacencies[j1][k] & 8) == 0)
|
||||||
|
return true;
|
||||||
|
if (j1 == i + 1 && k == j && (adjacencies[j1][k] & 0x80) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean method221(int i, int j, int k, int l, int i1, int j1, int k1) {
|
||||||
|
int l1 = (j + j1) - 1;
|
||||||
|
int i2 = (i + l) - 1;
|
||||||
|
if (k >= j && k <= l1 && k1 >= i && k1 <= i2)
|
||||||
|
return true;
|
||||||
|
if (k == j - 1 && k1 >= i && k1 <= i2
|
||||||
|
&& (adjacencies[k - xOffset][k1 - yOffset] & 8) == 0
|
||||||
|
&& (i1 & 8) == 0)
|
||||||
|
return true;
|
||||||
|
if (k == l1 + 1 && k1 >= i && k1 <= i2
|
||||||
|
&& (adjacencies[k - xOffset][k1 - yOffset] & 0x80) == 0
|
||||||
|
&& (i1 & 2) == 0)
|
||||||
|
return true;
|
||||||
|
return k1 == i - 1 && k >= j && k <= l1
|
||||||
|
&& (adjacencies[k - xOffset][k1 - yOffset] & 2) == 0
|
||||||
|
&& (i1 & 4) == 0 || k1 == i2 + 1 && k >= j && k <= l1
|
||||||
|
&& (adjacencies[k - xOffset][k1 - yOffset] & 0x20) == 0
|
||||||
|
&& (i1 & 1) == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,111 @@
|
|||||||
|
package org.rebotted.scene;
|
||||||
|
import org.rebotted.cache.anim.Frame;
|
||||||
|
import org.rebotted.cache.anim.Graphic;
|
||||||
|
import org.rebotted.entity.Renderable;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
|
||||||
|
public final class Projectile extends Renderable {
|
||||||
|
|
||||||
|
public final int startCycle;
|
||||||
|
public final int stopCycle;
|
||||||
|
private double xIncrement;
|
||||||
|
private double yIncrement;
|
||||||
|
private double diagonalIncrement;
|
||||||
|
private double heightIncrement;
|
||||||
|
private double aDouble1578;
|
||||||
|
private boolean started;
|
||||||
|
private final int projectileX;
|
||||||
|
private final int projectileY;
|
||||||
|
private final int startHeight;
|
||||||
|
public final int endHeight;
|
||||||
|
public double xPos;
|
||||||
|
public double yPos;
|
||||||
|
public double cnterHeight;
|
||||||
|
private final int initialSlope;
|
||||||
|
private final int initialDistance;
|
||||||
|
public final int target;
|
||||||
|
private final Graphic projectileGFX;
|
||||||
|
private int gfxStage;
|
||||||
|
private int gfxTickOfCurrentStage;
|
||||||
|
public int turnValue;
|
||||||
|
private int tiltAngle;
|
||||||
|
public final int projectileZ;
|
||||||
|
|
||||||
|
public void calculateIncrements(int currentCycle, int targetY, int targetCenterHeight, int targetX) {
|
||||||
|
if(!started) {
|
||||||
|
double xToGo = targetX - projectileX;
|
||||||
|
double yToGo = targetY - projectileY;
|
||||||
|
double distanceToGo = Math.sqrt(xToGo * xToGo + yToGo * yToGo);
|
||||||
|
xPos = (double) projectileX + (xToGo * (double) initialDistance) / distanceToGo;
|
||||||
|
yPos = (double) projectileY + (yToGo * (double) initialDistance) / distanceToGo;
|
||||||
|
cnterHeight = startHeight;
|
||||||
|
}
|
||||||
|
double cyclesLeft = (stopCycle + 1) - currentCycle;
|
||||||
|
xIncrement = ((double)targetX - xPos) / cyclesLeft;
|
||||||
|
yIncrement = ((double)targetY - yPos) / cyclesLeft;
|
||||||
|
diagonalIncrement = Math.sqrt(xIncrement * xIncrement + yIncrement * yIncrement);
|
||||||
|
if(!started) {
|
||||||
|
heightIncrement = -diagonalIncrement * Math.tan((double) initialSlope * 0.02454369D);
|
||||||
|
}
|
||||||
|
aDouble1578 = (2D * ((double)targetCenterHeight - cnterHeight - heightIncrement * cyclesLeft)) / (cyclesLeft * cyclesLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getRotatedModel() {
|
||||||
|
Model modelGfx = projectileGFX.getModel();
|
||||||
|
if(modelGfx == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int frameNumber = -1;
|
||||||
|
if(projectileGFX.animationSequence != null) {
|
||||||
|
frameNumber = projectileGFX.animationSequence.primaryFrames[gfxStage];
|
||||||
|
}
|
||||||
|
Model projectileModel = new Model(true, Frame.noAnimationInProgress(frameNumber), false, modelGfx);
|
||||||
|
if(frameNumber != -1) {
|
||||||
|
projectileModel.skin();
|
||||||
|
projectileModel.applyTransform(frameNumber);
|
||||||
|
projectileModel.faceGroups = null;
|
||||||
|
projectileModel.vertexGroups = null;
|
||||||
|
}
|
||||||
|
if(projectileGFX.resizeXY != 128 || projectileGFX.resizeZ != 128) {
|
||||||
|
projectileModel.scale(projectileGFX.resizeXY, projectileGFX.resizeXY, projectileGFX.resizeZ);
|
||||||
|
}
|
||||||
|
projectileModel.leanOverX(tiltAngle);
|
||||||
|
projectileModel.light(64 + projectileGFX.modelBrightness, 850 + projectileGFX.modelShadow, -30, -50, -30, true);
|
||||||
|
return projectileModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Projectile(int initialSlope, int endHeight, int creationCycle, int destructionCycle, int initialDistance, int startZ, int startHeight, int y, int x, int target, int gfxMoving) {
|
||||||
|
projectileGFX = Graphic.cache[gfxMoving];
|
||||||
|
projectileZ = startZ;
|
||||||
|
projectileX = x;
|
||||||
|
projectileY = y;
|
||||||
|
this.startHeight = startHeight;
|
||||||
|
startCycle = creationCycle;
|
||||||
|
stopCycle = destructionCycle;
|
||||||
|
this.initialSlope = initialSlope;
|
||||||
|
this.initialDistance = initialDistance;
|
||||||
|
this.target = target;
|
||||||
|
this.endHeight = endHeight;
|
||||||
|
started = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void progressCycles(int cyclesMissed) {
|
||||||
|
started = true;
|
||||||
|
xPos += xIncrement * (double)cyclesMissed;
|
||||||
|
yPos += yIncrement * (double)cyclesMissed;
|
||||||
|
cnterHeight += heightIncrement * (double)cyclesMissed + 0.5D * aDouble1578 * (double)cyclesMissed * (double)cyclesMissed;
|
||||||
|
heightIncrement += aDouble1578 * (double)cyclesMissed;
|
||||||
|
//noinspection SuspiciousNameCombination
|
||||||
|
turnValue = (int)(Math.atan2(xIncrement, yIncrement) * 325.94900000000001D) + 1024 & 0x7ff;
|
||||||
|
tiltAngle = (int)(Math.atan2(heightIncrement, diagonalIncrement) * 325.94900000000001D) & 0x7ff;
|
||||||
|
if(projectileGFX.animationSequence != null) {
|
||||||
|
for(gfxTickOfCurrentStage += cyclesMissed; gfxTickOfCurrentStage > projectileGFX.animationSequence.duration(gfxStage);) {
|
||||||
|
gfxTickOfCurrentStage -= projectileGFX.animationSequence.duration(gfxStage) + 1;
|
||||||
|
gfxStage++;
|
||||||
|
if(gfxStage >= projectileGFX.animationSequence.frameCount) {
|
||||||
|
gfxStage = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.rebotted.scene;
|
||||||
|
|
||||||
|
public final class SceneCluster {
|
||||||
|
|
||||||
|
public int startXLoc;
|
||||||
|
public int endXLoc;
|
||||||
|
public int startYLoc;
|
||||||
|
public int endYLoc;
|
||||||
|
public int orientation;
|
||||||
|
public int startXPos;
|
||||||
|
public int endXPos;
|
||||||
|
public int startYPos;
|
||||||
|
public int endYPos;
|
||||||
|
public int startZPos;
|
||||||
|
public int endZPos;
|
||||||
|
public int cullDirection;
|
||||||
|
public int anInt799;
|
||||||
|
public int anInt800;
|
||||||
|
public int anInt801;
|
||||||
|
public int anInt802;
|
||||||
|
public int anInt803;
|
||||||
|
public int anInt804;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,105 @@
|
|||||||
|
package org.rebotted.scene;
|
||||||
|
import org.rebotted.Client;
|
||||||
|
import org.rebotted.cache.anim.Animation;
|
||||||
|
import org.rebotted.cache.config.Varbit;
|
||||||
|
import org.rebotted.cache.def.ObjectDefinition;
|
||||||
|
import org.rebotted.entity.Renderable;
|
||||||
|
import org.rebotted.entity.model.Model;
|
||||||
|
|
||||||
|
public final class SceneObject extends Renderable {
|
||||||
|
|
||||||
|
private int anInt1599;
|
||||||
|
private final int[] anIntArray1600;
|
||||||
|
private final int anInt1601;
|
||||||
|
private final int anInt1602;
|
||||||
|
private final int anInt1603;
|
||||||
|
private final int anInt1604;
|
||||||
|
private final int anInt1605;
|
||||||
|
private final int anInt1606;
|
||||||
|
private Animation aAnimation_1607;
|
||||||
|
private int anInt1608;
|
||||||
|
public static Client clientInstance;
|
||||||
|
private final int anInt1610;
|
||||||
|
private final int anInt1611;
|
||||||
|
private final int anInt1612;
|
||||||
|
|
||||||
|
private ObjectDefinition method457() {
|
||||||
|
int i = -1;
|
||||||
|
if (anInt1601 != -1) {
|
||||||
|
try {
|
||||||
|
Varbit varBit = Varbit.varbits[anInt1601];
|
||||||
|
int k = varBit.getSetting();
|
||||||
|
int l = varBit.getLow();
|
||||||
|
int i1 = varBit.getHigh();
|
||||||
|
int j1 = Client.BIT_MASKS[i1 - l];
|
||||||
|
i = clientInstance.settings[k] >> l & j1;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
|
} else if (anInt1602 != -1) {
|
||||||
|
i = clientInstance.settings[anInt1602];
|
||||||
|
}
|
||||||
|
if (i < 0 || i >= anIntArray1600.length || anIntArray1600[i] == -1) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return ObjectDefinition.lookup(anIntArray1600[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getRotatedModel() {
|
||||||
|
int j = -1;
|
||||||
|
if (aAnimation_1607 != null) {
|
||||||
|
int k = Client.tick - anInt1608;
|
||||||
|
if (k > 100 && aAnimation_1607.loopOffset > 0) {
|
||||||
|
k = 100;
|
||||||
|
}
|
||||||
|
while (k > aAnimation_1607.duration(anInt1599)) {
|
||||||
|
k -= aAnimation_1607.duration(anInt1599);
|
||||||
|
anInt1599++;
|
||||||
|
if (anInt1599 < aAnimation_1607.frameCount)
|
||||||
|
continue;
|
||||||
|
anInt1599 -= aAnimation_1607.loopOffset;
|
||||||
|
if (anInt1599 >= 0 && anInt1599 < aAnimation_1607.frameCount)
|
||||||
|
continue;
|
||||||
|
aAnimation_1607 = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
anInt1608 = Client.tick - k;
|
||||||
|
if (aAnimation_1607 != null) {
|
||||||
|
j = aAnimation_1607.primaryFrames[anInt1599];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ObjectDefinition class46;
|
||||||
|
if (anIntArray1600 != null)
|
||||||
|
class46 = method457();
|
||||||
|
else
|
||||||
|
class46 = ObjectDefinition.lookup(anInt1610);
|
||||||
|
if (class46 == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return class46.modelAt(anInt1611, anInt1612, anInt1603, anInt1604, anInt1605, anInt1606, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SceneObject(int i, int j, int k, int l, int i1, int j1, int k1, int l1, boolean flag) {
|
||||||
|
anInt1610 = i;
|
||||||
|
anInt1611 = k;
|
||||||
|
anInt1612 = j;
|
||||||
|
anInt1603 = j1;
|
||||||
|
anInt1604 = l;
|
||||||
|
anInt1605 = i1;
|
||||||
|
anInt1606 = k1;
|
||||||
|
if (l1 != -1) {
|
||||||
|
aAnimation_1607 = Animation.animations[l1];
|
||||||
|
anInt1599 = 0;
|
||||||
|
anInt1608 = Client.tick;
|
||||||
|
if (flag && aAnimation_1607.loopOffset != -1) {
|
||||||
|
anInt1599 = (int) (Math.random() * (double) aAnimation_1607.frameCount);
|
||||||
|
anInt1608 -= (int) (Math.random() * (double) aAnimation_1607.duration(anInt1599));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ObjectDefinition objectDef = ObjectDefinition.lookup(anInt1610);
|
||||||
|
anInt1601 = objectDef.varbit;
|
||||||
|
anInt1602 = objectDef.varp;
|
||||||
|
anIntArray1600 = objectDef.childrenIDs;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.rebotted.scene.object;
|
||||||
|
import org.rebotted.entity.Renderable;
|
||||||
|
|
||||||
|
public final class GroundDecoration
|
||||||
|
{
|
||||||
|
|
||||||
|
public GroundDecoration()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public int zPos;
|
||||||
|
public int xPos;
|
||||||
|
public int yPos;
|
||||||
|
public Renderable renderable;
|
||||||
|
public int uid;
|
||||||
|
public byte mask;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package org.rebotted.scene.object;
|
||||||
|
import org.rebotted.collection.Linkable;
|
||||||
|
|
||||||
|
public final class SpawnedObject extends Linkable {
|
||||||
|
|
||||||
|
public SpawnedObject()
|
||||||
|
{
|
||||||
|
getLongetivity = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int id;
|
||||||
|
public int orientation;
|
||||||
|
public int type;
|
||||||
|
public int getLongetivity;
|
||||||
|
public int plane;
|
||||||
|
public int group;
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
public int getPreviousId;
|
||||||
|
public int previousOrientation;
|
||||||
|
public int previousType;
|
||||||
|
public int delay;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.rebotted.scene.object;
|
||||||
|
|
||||||
|
import org.rebotted.entity.Renderable;
|
||||||
|
|
||||||
|
public final class WallDecoration {
|
||||||
|
|
||||||
|
public int zPos;
|
||||||
|
public int xPos;
|
||||||
|
public int yPos;
|
||||||
|
public int orientation;
|
||||||
|
public int orientation2;
|
||||||
|
public Renderable renderable;
|
||||||
|
public int uid;
|
||||||
|
public byte mask;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package org.rebotted.scene.object;
|
||||||
|
|
||||||
|
import org.rebotted.entity.Renderable;
|
||||||
|
|
||||||
|
public final class WallObject {
|
||||||
|
|
||||||
|
public int zPos;
|
||||||
|
public int xPos;
|
||||||
|
public int yPos;
|
||||||
|
public int orientation1;
|
||||||
|
public int orientation2;
|
||||||
|
public Renderable renderable1;
|
||||||
|
public Renderable renderable2;
|
||||||
|
public int uid;
|
||||||
|
public byte mask;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,301 @@
|
|||||||
|
package org.rebotted.scene.object.tile;
|
||||||
|
|
||||||
|
public final class ShapedTile{
|
||||||
|
public ShapedTile(int yLoc, int j, int k, int l, int texture, int j1, int rotation, int l1, int i2, int j2, int k2, int l2, int i3, int j3, int k3, int l3, int i4, int xLoc, int l4){
|
||||||
|
flat = !(i3 != l2 || i3 != l || i3 != k2);
|
||||||
|
shape = j3;
|
||||||
|
this.rotation = rotation;
|
||||||
|
colourRGB = i2;
|
||||||
|
colourRGBA = l4;
|
||||||
|
char sideLength = 128;
|
||||||
|
int halfSizeLength = sideLength / 2;
|
||||||
|
int quarterSizeLight = sideLength / 4;
|
||||||
|
int k5 = (sideLength * 3) / 4;
|
||||||
|
int ai[] = anIntArrayArray696[j3];
|
||||||
|
int l5 = ai.length;
|
||||||
|
anIntArray673 = new int[l5];
|
||||||
|
anIntArray674 = new int[l5];
|
||||||
|
anIntArray675 = new int[l5];
|
||||||
|
int ai1[] = new int[l5];
|
||||||
|
int ai2[] = new int[l5];
|
||||||
|
int xPos = xLoc * sideLength;
|
||||||
|
int yPos = yLoc * sideLength;
|
||||||
|
for(int k6 = 0; k6 < l5; k6++){
|
||||||
|
int realShape = ai[k6];
|
||||||
|
if((realShape & 1) == 0 && realShape <= 8)
|
||||||
|
realShape = (realShape - rotation - rotation - 1 & 7) + 1;
|
||||||
|
if(realShape > 8 && realShape <= 12)
|
||||||
|
realShape = (realShape - 9 - rotation & 3) + 9;
|
||||||
|
if(realShape > 12 && realShape <= 16)
|
||||||
|
realShape = (realShape - 13 - rotation & 3) + 13;
|
||||||
|
int i7;
|
||||||
|
int k7;
|
||||||
|
int i8;
|
||||||
|
int k8;
|
||||||
|
int j9;
|
||||||
|
if(realShape == 1){
|
||||||
|
i7 = xPos;
|
||||||
|
k7 = yPos;
|
||||||
|
i8 = i3;
|
||||||
|
k8 = l1;
|
||||||
|
j9 = j;
|
||||||
|
} else if(realShape == 2){
|
||||||
|
i7 = xPos + halfSizeLength;
|
||||||
|
k7 = yPos;
|
||||||
|
i8 = i3 + l2 >> 1;
|
||||||
|
k8 = l1 + i4 >> 1;
|
||||||
|
j9 = j + l3 >> 1;
|
||||||
|
} else if(realShape == 3){
|
||||||
|
i7 = xPos + sideLength;
|
||||||
|
k7 = yPos;
|
||||||
|
i8 = l2;
|
||||||
|
k8 = i4;
|
||||||
|
j9 = l3;
|
||||||
|
} else if(realShape == 4){
|
||||||
|
i7 = xPos + sideLength;
|
||||||
|
k7 = yPos + halfSizeLength;
|
||||||
|
i8 = l2 + l >> 1;
|
||||||
|
k8 = i4 + j2 >> 1;
|
||||||
|
j9 = l3 + j1 >> 1;
|
||||||
|
} else if(realShape == 5){
|
||||||
|
i7 = xPos + sideLength;
|
||||||
|
k7 = yPos + sideLength;
|
||||||
|
i8 = l;
|
||||||
|
k8 = j2;
|
||||||
|
j9 = j1;
|
||||||
|
} else if(realShape == 6){
|
||||||
|
i7 = xPos + halfSizeLength;
|
||||||
|
k7 = yPos + sideLength;
|
||||||
|
i8 = l + k2 >> 1;
|
||||||
|
k8 = j2 + k >> 1;
|
||||||
|
j9 = j1 + k3 >> 1;
|
||||||
|
} else if(realShape == 7){
|
||||||
|
i7 = xPos;
|
||||||
|
k7 = yPos + sideLength;
|
||||||
|
i8 = k2;
|
||||||
|
k8 = k;
|
||||||
|
j9 = k3;
|
||||||
|
} else if(realShape == 8){
|
||||||
|
i7 = xPos;
|
||||||
|
k7 = yPos + halfSizeLength;
|
||||||
|
i8 = k2 + i3 >> 1;
|
||||||
|
k8 = k + l1 >> 1;
|
||||||
|
j9 = k3 + j >> 1;
|
||||||
|
} else if(realShape == 9){
|
||||||
|
i7 = xPos + halfSizeLength;
|
||||||
|
k7 = yPos + quarterSizeLight;
|
||||||
|
i8 = i3 + l2 >> 1;
|
||||||
|
k8 = l1 + i4 >> 1;
|
||||||
|
j9 = j + l3 >> 1;
|
||||||
|
} else if(realShape == 10){
|
||||||
|
i7 = xPos + k5;
|
||||||
|
k7 = yPos + halfSizeLength;
|
||||||
|
i8 = l2 + l >> 1;
|
||||||
|
k8 = i4 + j2 >> 1;
|
||||||
|
j9 = l3 + j1 >> 1;
|
||||||
|
} else if(realShape == 11){
|
||||||
|
i7 = xPos + halfSizeLength;
|
||||||
|
k7 = yPos + k5;
|
||||||
|
i8 = l + k2 >> 1;
|
||||||
|
k8 = j2 + k >> 1;
|
||||||
|
j9 = j1 + k3 >> 1;
|
||||||
|
} else if(realShape == 12){
|
||||||
|
i7 = xPos + quarterSizeLight;
|
||||||
|
k7 = yPos + halfSizeLength;
|
||||||
|
i8 = k2 + i3 >> 1;
|
||||||
|
k8 = k + l1 >> 1;
|
||||||
|
j9 = k3 + j >> 1;
|
||||||
|
} else if(realShape == 13){
|
||||||
|
i7 = xPos + quarterSizeLight;
|
||||||
|
k7 = yPos + quarterSizeLight;
|
||||||
|
i8 = i3;
|
||||||
|
k8 = l1;
|
||||||
|
j9 = j;
|
||||||
|
} else if(realShape == 14){
|
||||||
|
i7 = xPos + k5;
|
||||||
|
k7 = yPos + quarterSizeLight;
|
||||||
|
i8 = l2;
|
||||||
|
k8 = i4;
|
||||||
|
j9 = l3;
|
||||||
|
} else if(realShape == 15){
|
||||||
|
i7 = xPos + k5;
|
||||||
|
k7 = yPos + k5;
|
||||||
|
i8 = l;
|
||||||
|
k8 = j2;
|
||||||
|
j9 = j1;
|
||||||
|
} else {
|
||||||
|
i7 = xPos + quarterSizeLight;
|
||||||
|
k7 = yPos + k5;
|
||||||
|
i8 = k2;
|
||||||
|
k8 = k;
|
||||||
|
j9 = k3;
|
||||||
|
}
|
||||||
|
anIntArray673[k6] = i7;
|
||||||
|
anIntArray674[k6] = i8;
|
||||||
|
anIntArray675[k6] = k7;
|
||||||
|
ai1[k6] = k8;
|
||||||
|
ai2[k6] = j9;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ai3[] = anIntArrayArray697[j3];
|
||||||
|
int j7 = ai3.length / 4;
|
||||||
|
anIntArray679 = new int[j7];
|
||||||
|
anIntArray680 = new int[j7];
|
||||||
|
anIntArray681 = new int[j7];
|
||||||
|
anIntArray676 = new int[j7];
|
||||||
|
anIntArray677 = new int[j7];
|
||||||
|
anIntArray678 = new int[j7];
|
||||||
|
if(texture != -1)
|
||||||
|
anIntArray682 = new int[j7];
|
||||||
|
int l7 = 0;
|
||||||
|
for(int j8 = 0; j8 < j7; j8++){
|
||||||
|
int l8 = ai3[l7];
|
||||||
|
int k9 = ai3[l7 + 1];
|
||||||
|
int i10 = ai3[l7 + 2];
|
||||||
|
int k10 = ai3[l7 + 3];
|
||||||
|
l7 += 4;
|
||||||
|
if(k9 < 4)
|
||||||
|
k9 = k9 - rotation & 3;
|
||||||
|
if(i10 < 4)
|
||||||
|
i10 = i10 - rotation & 3;
|
||||||
|
if(k10 < 4)
|
||||||
|
k10 = k10 - rotation & 3;
|
||||||
|
anIntArray679[j8] = k9;
|
||||||
|
anIntArray680[j8] = i10;
|
||||||
|
anIntArray681[j8] = k10;
|
||||||
|
if(l8 == 0){
|
||||||
|
anIntArray676[j8] = ai1[k9];
|
||||||
|
anIntArray677[j8] = ai1[i10];
|
||||||
|
anIntArray678[j8] = ai1[k10];
|
||||||
|
if(anIntArray682 != null)
|
||||||
|
anIntArray682[j8] = -1;
|
||||||
|
} else {
|
||||||
|
anIntArray676[j8] = ai2[k9];
|
||||||
|
anIntArray677[j8] = ai2[i10];
|
||||||
|
anIntArray678[j8] = ai2[k10];
|
||||||
|
if(anIntArray682 != null)
|
||||||
|
anIntArray682[j8] = texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int i9 = i3;
|
||||||
|
int l9 = l2;
|
||||||
|
if(l2 < i9)
|
||||||
|
i9 = l2;
|
||||||
|
if(l2 > l9)
|
||||||
|
l9 = l2;
|
||||||
|
if(l < i9)
|
||||||
|
i9 = l;
|
||||||
|
if(l > l9)
|
||||||
|
l9 = l;
|
||||||
|
if(k2 < i9)
|
||||||
|
i9 = k2;
|
||||||
|
if(k2 > l9)
|
||||||
|
l9 = k2;
|
||||||
|
i9 /= 14;
|
||||||
|
l9 /= 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int[] anIntArray673;
|
||||||
|
public final int[] anIntArray674;
|
||||||
|
public final int[] anIntArray675;
|
||||||
|
public final int[] anIntArray676;
|
||||||
|
public final int[] anIntArray677;
|
||||||
|
public final int[] anIntArray678;
|
||||||
|
public final int[] anIntArray679;
|
||||||
|
public final int[] anIntArray680;
|
||||||
|
public final int[] anIntArray681;
|
||||||
|
public int anIntArray682[];
|
||||||
|
public final boolean flat;
|
||||||
|
public final int shape;
|
||||||
|
public final int rotation;
|
||||||
|
public final int colourRGB;
|
||||||
|
public final int colourRGBA;
|
||||||
|
public static final int[] anIntArray688 = new int[6];
|
||||||
|
public static final int[] anIntArray689 = new int[6];
|
||||||
|
public static final int[] anIntArray690 = new int[6];
|
||||||
|
public static final int[] anIntArray691 = new int[6];
|
||||||
|
public static final int[] anIntArray692 = new int[6];
|
||||||
|
public static final int[] depthPoint = new int[6];
|
||||||
|
static final int[] anIntArray693 = {
|
||||||
|
1, 0
|
||||||
|
};
|
||||||
|
static final int[] anIntArray694 = {
|
||||||
|
2, 1
|
||||||
|
};
|
||||||
|
static final int[] anIntArray695 = {
|
||||||
|
3, 3
|
||||||
|
};
|
||||||
|
private static final int[][] anIntArrayArray696 = {
|
||||||
|
{
|
||||||
|
1, 3, 5, 7
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 6
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 6
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 6
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 6
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 2, 6
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 2, 8
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 2, 8
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 11, 12
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 11, 12
|
||||||
|
}, {
|
||||||
|
1, 3, 5, 7, 13, 14
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private static final int[][] anIntArrayArray697 = {
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 0, 0, 1, 3
|
||||||
|
}, {
|
||||||
|
1, 1, 2, 3, 1, 0, 1, 3
|
||||||
|
}, {
|
||||||
|
0, 1, 2, 3, 1, 0, 1, 3
|
||||||
|
}, {
|
||||||
|
0, 0, 1, 2, 0, 0, 2, 4, 1, 0,
|
||||||
|
4, 3
|
||||||
|
}, {
|
||||||
|
0, 0, 1, 4, 0, 0, 4, 3, 1, 1,
|
||||||
|
2, 4
|
||||||
|
}, {
|
||||||
|
0, 0, 4, 3, 1, 0, 1, 2, 1, 0,
|
||||||
|
2, 4
|
||||||
|
}, {
|
||||||
|
0, 1, 2, 4, 1, 0, 1, 4, 1, 0,
|
||||||
|
4, 3
|
||||||
|
}, {
|
||||||
|
0, 4, 1, 2, 0, 4, 2, 5, 1, 0,
|
||||||
|
4, 5, 1, 0, 5, 3
|
||||||
|
}, {
|
||||||
|
0, 4, 1, 2, 0, 4, 2, 3, 0, 4,
|
||||||
|
3, 5, 1, 0, 4, 5
|
||||||
|
}, {
|
||||||
|
0, 0, 4, 5, 1, 4, 1, 2, 1, 4,
|
||||||
|
2, 3, 1, 4, 3, 5
|
||||||
|
}, {
|
||||||
|
0, 0, 1, 5, 0, 1, 4, 5, 0, 1,
|
||||||
|
2, 4, 1, 0, 5, 3, 1, 5, 4, 3,
|
||||||
|
1, 4, 2, 3
|
||||||
|
}, {
|
||||||
|
1, 0, 1, 5, 1, 1, 4, 5, 1, 1,
|
||||||
|
2, 4, 0, 0, 5, 3, 0, 5, 4, 3,
|
||||||
|
0, 4, 2, 3
|
||||||
|
}, {
|
||||||
|
1, 0, 5, 4, 1, 0, 1, 5, 0, 0,
|
||||||
|
4, 3, 0, 4, 5, 3, 0, 5, 2, 3,
|
||||||
|
0, 1, 2, 5
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package org.rebotted.scene.object.tile;
|
||||||
|
|
||||||
|
public final class SimpleTile {
|
||||||
|
|
||||||
|
private final int northEastColor;
|
||||||
|
private final int northColor;
|
||||||
|
private final int centerColor;
|
||||||
|
private final int eastColor;
|
||||||
|
private final int texture;
|
||||||
|
private final boolean flat;
|
||||||
|
private final int colorRGB;
|
||||||
|
|
||||||
|
public SimpleTile(int northEastColor, int northColor, int centerColor, int eastColor, int texture, int colorRGB, boolean flat) {
|
||||||
|
this.northEastColor = northEastColor;
|
||||||
|
this.northColor = northColor;
|
||||||
|
this.centerColor = centerColor;
|
||||||
|
this.eastColor = eastColor;
|
||||||
|
this.texture = texture;
|
||||||
|
this.colorRGB = colorRGB;
|
||||||
|
this.flat = flat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNorthEastColor() {
|
||||||
|
return northEastColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNorthColor() {
|
||||||
|
return northColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCenterColor() {
|
||||||
|
return centerColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEastColor() {
|
||||||
|
return eastColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTexture() {
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFlat() {
|
||||||
|
return flat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColourRGB() {
|
||||||
|
return colorRGB;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package org.rebotted.scene.object.tile;
|
||||||
|
import org.rebotted.collection.Linkable;
|
||||||
|
import org.rebotted.entity.GameObject;
|
||||||
|
import org.rebotted.entity.GroundItemTile;
|
||||||
|
import org.rebotted.scene.object.GroundDecoration;
|
||||||
|
import org.rebotted.scene.object.WallDecoration;
|
||||||
|
import org.rebotted.scene.object.WallObject;
|
||||||
|
|
||||||
|
public final class Tile extends Linkable {
|
||||||
|
public Tile(int i, int j, int k){
|
||||||
|
gameObjects = new GameObject[5];
|
||||||
|
tiledObjectMasks = new int[5];
|
||||||
|
anInt1310 = z1AnInt1307 = i;
|
||||||
|
anInt1308 = j;
|
||||||
|
anInt1309 = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int z1AnInt1307;
|
||||||
|
public final int anInt1308;
|
||||||
|
public final int anInt1309;
|
||||||
|
public final int anInt1310;
|
||||||
|
public SimpleTile mySimpleTile;
|
||||||
|
public ShapedTile myShapedTile;
|
||||||
|
public WallObject wallObject;
|
||||||
|
public WallDecoration wallDecoration;
|
||||||
|
public GroundDecoration groundDecoration;
|
||||||
|
public GroundItemTile groundItemTile;
|
||||||
|
public int gameObjectIndex;
|
||||||
|
public final GameObject[] gameObjects;
|
||||||
|
public final int[] tiledObjectMasks;
|
||||||
|
public int totalTiledObjectMask;
|
||||||
|
public int logicHeight;
|
||||||
|
public boolean aBoolean1322;
|
||||||
|
public boolean aBoolean1323;
|
||||||
|
public boolean aBoolean1324;
|
||||||
|
public int someTileMask;
|
||||||
|
public int anInt1326;
|
||||||
|
public int anInt1327;
|
||||||
|
public int anInt1328;
|
||||||
|
public Tile firstFloorTile;
|
||||||
|
}
|
||||||
@@ -0,0 +1,423 @@
|
|||||||
|
package org.rebotted.sign;
|
||||||
|
|
||||||
|
import java.applet.Applet;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
|
import javax.sound.midi.*;
|
||||||
|
import javax.sound.sampled.*;
|
||||||
|
|
||||||
|
import org.rebotted.Configuration;
|
||||||
|
|
||||||
|
public final class SignLink implements Runnable {
|
||||||
|
|
||||||
|
public static final int clientversion = 317;
|
||||||
|
public static int uid;
|
||||||
|
public static int storeid = 32;
|
||||||
|
public static RandomAccessFile cache_dat = null;
|
||||||
|
public static final RandomAccessFile[] indices = new RandomAccessFile[5];
|
||||||
|
public static boolean sunjava;
|
||||||
|
public static Applet mainapp = null;
|
||||||
|
private static boolean active;
|
||||||
|
private static int threadLiveId;
|
||||||
|
private static InetAddress socketAddress;
|
||||||
|
private static int socketRequest;
|
||||||
|
private static Socket socket = null;
|
||||||
|
private static int threadreqpri = 1;
|
||||||
|
private static Runnable threadreq = null;
|
||||||
|
private static String dnsreq = null;
|
||||||
|
public static String dns = null;
|
||||||
|
private static String urlRequest = null;
|
||||||
|
private static DataInputStream urlStream = null;
|
||||||
|
private static int savelen;
|
||||||
|
private static String savereq = null;
|
||||||
|
private static byte[] savebuf = null;
|
||||||
|
private static boolean play;
|
||||||
|
private static int midipos;
|
||||||
|
public static String midi = null;
|
||||||
|
public static int midiVolume;
|
||||||
|
public static int fadeMidi;
|
||||||
|
private static boolean waveplay;
|
||||||
|
private static int wavepos;
|
||||||
|
public static int wavevol;
|
||||||
|
public static boolean reporterror = true;
|
||||||
|
public static String errorName = "";
|
||||||
|
|
||||||
|
private SignLink() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startpriv(InetAddress inetaddress) {
|
||||||
|
threadLiveId = (int) (Math.random() * 99999999D);
|
||||||
|
if (active) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(500L);
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
socketRequest = 0;
|
||||||
|
threadreq = null;
|
||||||
|
dnsreq = null;
|
||||||
|
savereq = null;
|
||||||
|
urlRequest = null;
|
||||||
|
socketAddress = inetaddress;
|
||||||
|
Thread thread = new Thread(new SignLink());
|
||||||
|
thread.setDaemon(true);
|
||||||
|
thread.start();
|
||||||
|
while (!active)
|
||||||
|
try {
|
||||||
|
Thread.sleep(50L);
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
active = true;
|
||||||
|
String directory = findcachedir();
|
||||||
|
uid = getUid(directory);
|
||||||
|
try {
|
||||||
|
cache_dat = new RandomAccessFile(directory + "main_file_cache.dat", "rw");
|
||||||
|
for (int index = 0; index < 5; index++)
|
||||||
|
indices[index] = new RandomAccessFile(directory + "main_file_cache.idx"
|
||||||
|
+ index, "rw");
|
||||||
|
} catch (Exception exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
for (int i = threadLiveId; threadLiveId == i;) {
|
||||||
|
if (socketRequest != 0) {
|
||||||
|
try {
|
||||||
|
socket = new Socket(socketAddress, socketRequest);
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
socket = null;
|
||||||
|
}
|
||||||
|
socketRequest = 0;
|
||||||
|
} else if (threadreq != null) {
|
||||||
|
Thread thread = new Thread(threadreq);
|
||||||
|
thread.setDaemon(true);
|
||||||
|
thread.start();
|
||||||
|
thread.setPriority(threadreqpri);
|
||||||
|
threadreq = null;
|
||||||
|
} else if (dnsreq != null) {
|
||||||
|
try {
|
||||||
|
dns = InetAddress.getByName(dnsreq).getHostName();
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
dns = "unknown";
|
||||||
|
}
|
||||||
|
dnsreq = null;
|
||||||
|
} else if (savereq != null) {
|
||||||
|
if (savebuf != null)
|
||||||
|
try {
|
||||||
|
FileOutputStream fileoutputstream = new FileOutputStream(
|
||||||
|
directory + savereq);
|
||||||
|
fileoutputstream.write(savebuf, 0, savelen);
|
||||||
|
fileoutputstream.close();
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
if (waveplay) {
|
||||||
|
String wave = directory + savereq;
|
||||||
|
waveplay = false;
|
||||||
|
AudioInputStream audioInputStream = null;
|
||||||
|
try {
|
||||||
|
audioInputStream = AudioSystem
|
||||||
|
.getAudioInputStream(new File(wave));
|
||||||
|
} catch (UnsupportedAudioFileException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
return;
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AudioFormat format = audioInputStream.getFormat();
|
||||||
|
SourceDataLine auline = null;
|
||||||
|
DataLine.Info info = new DataLine.Info(
|
||||||
|
SourceDataLine.class, format);
|
||||||
|
try {
|
||||||
|
auline = (SourceDataLine) AudioSystem.getLine(info);
|
||||||
|
auline.open(format);
|
||||||
|
} catch (LineUnavailableException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (play) {
|
||||||
|
midi = directory + savereq;
|
||||||
|
try {
|
||||||
|
if (music != null) {
|
||||||
|
music.stop();
|
||||||
|
music.close();
|
||||||
|
}
|
||||||
|
playMidi(midi);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
play = false;
|
||||||
|
}
|
||||||
|
savereq = null;
|
||||||
|
} else if (urlRequest != null) {
|
||||||
|
try {
|
||||||
|
System.out.println("urlstream");
|
||||||
|
urlStream = new DataInputStream((new URL(
|
||||||
|
mainapp.getCodeBase(), urlRequest)).openStream());
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
urlStream = null;
|
||||||
|
}
|
||||||
|
urlRequest = null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(50L);
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String findcachedir() {
|
||||||
|
final String os = System.getProperty("os.name").toLowerCase();
|
||||||
|
|
||||||
|
final String cacheLoc = Configuration.CACHE_DIRECTORY;
|
||||||
|
|
||||||
|
final String local = "./Cache/";
|
||||||
|
|
||||||
|
final File cacheDirectory = new File(Configuration.CACHE_DIRECTORY);
|
||||||
|
|
||||||
|
if (!cacheDirectory.exists()) {
|
||||||
|
cacheDirectory.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
// windows
|
||||||
|
if (os.indexOf("win") >= 0) {
|
||||||
|
return cacheLoc;
|
||||||
|
|
||||||
|
// macintosh
|
||||||
|
} else if (os.indexOf("mac") >= 0) {
|
||||||
|
return cacheLoc;
|
||||||
|
|
||||||
|
// linux
|
||||||
|
} else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0
|
||||||
|
|| os.indexOf("aix") > 0) {
|
||||||
|
return cacheLoc;
|
||||||
|
|
||||||
|
// solaris
|
||||||
|
} else if (os.indexOf("sunos") >= 0) {
|
||||||
|
return cacheLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return local;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the specified midi sequence.
|
||||||
|
*
|
||||||
|
* @param location
|
||||||
|
*/
|
||||||
|
private void playMidi(String location) {
|
||||||
|
music = null;
|
||||||
|
synthesizer = null;
|
||||||
|
sequence = null;
|
||||||
|
File midiFile = new File(location);
|
||||||
|
try {
|
||||||
|
sequence = MidiSystem.getSequence(midiFile);
|
||||||
|
music = MidiSystem.getSequencer();
|
||||||
|
music.open();
|
||||||
|
music.setSequence(sequence);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Problem loading MIDI file.");
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (music instanceof Synthesizer) {
|
||||||
|
synthesizer = (Synthesizer) music;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
synthesizer = MidiSystem.getSynthesizer();
|
||||||
|
synthesizer.open();
|
||||||
|
if (synthesizer.getDefaultSoundbank() == null) {
|
||||||
|
music.getTransmitter()
|
||||||
|
.setReceiver(MidiSystem.getReceiver());
|
||||||
|
} else {
|
||||||
|
music.getTransmitter().setReceiver(
|
||||||
|
synthesizer.getReceiver());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
music.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
|
||||||
|
music.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the volume for the midi synthesizer.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public static void setVolume(int value) {
|
||||||
|
int CHANGE_VOLUME = 7;
|
||||||
|
midiVolume = value;
|
||||||
|
if (synthesizer.getDefaultSoundbank() == null) {
|
||||||
|
try {
|
||||||
|
ShortMessage volumeMessage = new ShortMessage();
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i,
|
||||||
|
CHANGE_VOLUME, midiVolume);
|
||||||
|
volumeMessage.setMessage(ShortMessage.CONTROL_CHANGE, i,
|
||||||
|
39, midiVolume);
|
||||||
|
MidiSystem.getReceiver().send(volumeMessage, -1);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MidiChannel[] channels = synthesizer.getChannels();
|
||||||
|
for (int c = 0; channels != null && c < channels.length; c++) {
|
||||||
|
channels[c].controlChange(CHANGE_VOLUME, midiVolume);
|
||||||
|
channels[c].controlChange(39, midiVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Sequencer music = null;
|
||||||
|
public static Sequence sequence = null;
|
||||||
|
public static Synthesizer synthesizer = null;
|
||||||
|
|
||||||
|
public static synchronized boolean saveWave(byte abyte0[], int i) {
|
||||||
|
if (i > 0x1e8480)
|
||||||
|
return false;
|
||||||
|
if (savereq != null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
wavepos = (wavepos + 1) % 5;
|
||||||
|
savelen = i;
|
||||||
|
savebuf = abyte0;
|
||||||
|
waveplay = true;
|
||||||
|
savereq = "sound" + wavepos + ".wav";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized boolean replayWave() {
|
||||||
|
if (savereq != null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
savebuf = null;
|
||||||
|
waveplay = true;
|
||||||
|
savereq = "sound" + wavepos + ".wav";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized void saveMidi(byte abyte0[], int i) {
|
||||||
|
if (i > 0x1e8480)
|
||||||
|
return;
|
||||||
|
if (savereq != null) {
|
||||||
|
} else {
|
||||||
|
midipos = (midipos + 1) % 5;
|
||||||
|
savelen = i;
|
||||||
|
savebuf = abyte0;
|
||||||
|
play = true;
|
||||||
|
savereq = "jingle" + midipos + ".mid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getUid(String s) {
|
||||||
|
try {
|
||||||
|
File file = new File(s + "uid.dat");
|
||||||
|
if (!file.exists() || file.length() < 4L) {
|
||||||
|
DataOutputStream dataoutputstream = new DataOutputStream(
|
||||||
|
new FileOutputStream(s + "uid.dat"));
|
||||||
|
dataoutputstream.writeInt((int) (Math.random() * 99999999D));
|
||||||
|
dataoutputstream.close();
|
||||||
|
}
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
DataInputStream datainputstream = new DataInputStream(
|
||||||
|
new FileInputStream(s + "uid.dat"));
|
||||||
|
int i = datainputstream.readInt();
|
||||||
|
datainputstream.close();
|
||||||
|
return i + 1;
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized Socket openSocket(int port) throws IOException {
|
||||||
|
for (socketRequest = port; socketRequest != 0;)
|
||||||
|
try {
|
||||||
|
Thread.sleep(50L);
|
||||||
|
} catch (Exception _ex) {
|
||||||
|
}
|
||||||
|
if (socket == null)
|
||||||
|
throw new IOException("could not open socket");
|
||||||
|
else
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized DataInputStream openUrl(String url)
|
||||||
|
throws IOException {
|
||||||
|
for (urlRequest = url; urlRequest != null;) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(50L);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (urlStream == null) {
|
||||||
|
throw new IOException("could not open: " + url);
|
||||||
|
}
|
||||||
|
return urlStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized void dnslookup(String s) {
|
||||||
|
dns = s;
|
||||||
|
dnsreq = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized void startthread(Runnable runnable, int i) {
|
||||||
|
threadreqpri = i;
|
||||||
|
threadreq = runnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized boolean wavesave(byte abyte0[], int i) {
|
||||||
|
if (i > 0x1e8480)
|
||||||
|
return false;
|
||||||
|
if (savereq != null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
wavepos = (wavepos + 1) % 5;
|
||||||
|
savelen = i;
|
||||||
|
savebuf = abyte0;
|
||||||
|
waveplay = true;
|
||||||
|
savereq = "sound" + wavepos + ".wav";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized boolean wavereplay() {
|
||||||
|
if (savereq != null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
savebuf = null;
|
||||||
|
waveplay = true;
|
||||||
|
savereq = "sound" + wavepos + ".wav";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String indexLocation(int cacheIndex, int index) {
|
||||||
|
return SignLink.findcachedir() + "index" + cacheIndex + "/"
|
||||||
|
+ (index != -1 ? index + ".gz" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reporterror(String s) {
|
||||||
|
System.out.println("Error: " + s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setError(String error) {
|
||||||
|
errorName = error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package org.rebotted.sound;
|
||||||
|
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple envelope generator to control a variety of parameters (such as
|
||||||
|
* attack and release).
|
||||||
|
* Refactored using Major's 317 refactored client
|
||||||
|
* http://www.rune-server.org/runescape-development/rs2-client/downloads/575183-almost-fully-refactored-317-client.html
|
||||||
|
*/
|
||||||
|
final class Envelope {
|
||||||
|
|
||||||
|
private int segments;
|
||||||
|
private int[] durations;
|
||||||
|
private int[] peaks;
|
||||||
|
int start;
|
||||||
|
int end;
|
||||||
|
int form;
|
||||||
|
private int threshold;
|
||||||
|
private int segmentIndex;
|
||||||
|
private int step;
|
||||||
|
private int amplitude;
|
||||||
|
private int ticks;
|
||||||
|
|
||||||
|
public void decode(Buffer stream) {
|
||||||
|
form = stream.readUnsignedByte();
|
||||||
|
start = stream.readInt();
|
||||||
|
end = stream.readInt();
|
||||||
|
decodeSegments(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes the segment data from the specified {@link Buffer}.
|
||||||
|
*
|
||||||
|
* @param buffer
|
||||||
|
* The buffer.
|
||||||
|
*/
|
||||||
|
public void decodeSegments(Buffer stream) {
|
||||||
|
segments = stream.readUnsignedByte();
|
||||||
|
durations = new int[segments];
|
||||||
|
peaks = new int[segments];
|
||||||
|
for (int i = 0; i < segments; i++) {
|
||||||
|
durations[i] = stream.readUShort();
|
||||||
|
peaks[i] = stream.readUShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets this envelope.
|
||||||
|
*/
|
||||||
|
void resetValues() {
|
||||||
|
threshold = 0;
|
||||||
|
segmentIndex = 0;
|
||||||
|
step = 0;
|
||||||
|
amplitude = 0;
|
||||||
|
ticks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proceeds to the next step of the envelope,
|
||||||
|
*
|
||||||
|
* @param period
|
||||||
|
* The current period.
|
||||||
|
* @return The change.
|
||||||
|
*/
|
||||||
|
int step(int period) {
|
||||||
|
if (ticks >= threshold) {
|
||||||
|
amplitude = peaks[segmentIndex++] << 15;
|
||||||
|
if (segmentIndex >= segments)
|
||||||
|
segmentIndex = segments - 1;
|
||||||
|
threshold = (int) (((double) durations[segmentIndex] / 65536D) * (double) period);
|
||||||
|
if (threshold > ticks)
|
||||||
|
step = ((peaks[segmentIndex] << 15) - amplitude)
|
||||||
|
/ (threshold - ticks);
|
||||||
|
}
|
||||||
|
amplitude += step;
|
||||||
|
ticks++;
|
||||||
|
return amplitude - step >> 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package org.rebotted.sound;
|
||||||
|
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* an implementation of a reconfigurable filter that calculates
|
||||||
|
* coefficients from pole magnitude/phases and a serial
|
||||||
|
* configuration of cascading second-order iir filters
|
||||||
|
* Refactored information from Major's 317 refactored client
|
||||||
|
* http://www.rune-server.org/runescape-development/rs2-client/downloads/575183-almost-fully-refactored-317-client.html
|
||||||
|
*/
|
||||||
|
final class Filter {
|
||||||
|
|
||||||
|
final int[] pairs;
|
||||||
|
private final int[][][] phases;
|
||||||
|
private final int[][][] magnitudes;
|
||||||
|
private final int[] unity;
|
||||||
|
private static final float[][] minimisedCoefficients = new float[2][8];
|
||||||
|
static final int[][] coefficients = new int[2][8];
|
||||||
|
private static float forwardMinimisedCoefficientMultiplier;
|
||||||
|
static int forwardMultiplier;
|
||||||
|
|
||||||
|
public Filter() {
|
||||||
|
pairs = new int[2];
|
||||||
|
phases = new int[2][2][4];
|
||||||
|
magnitudes = new int[2][2][4];
|
||||||
|
unity = new int[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform precise linear interpolation on the magnitude (where "precise" means that the result is guaranteed to be
|
||||||
|
* the first magnitude ({@code magnitudes[direction][1][pair]}) when the step is {@code 1}).
|
||||||
|
*
|
||||||
|
* @param direction The direction, where {@code 0} is feedforward, and {@code 1} is feedback.
|
||||||
|
* @param pair The pair.
|
||||||
|
* @param step The step (the interpolation parameter).
|
||||||
|
* @return The interpolated magnitude.
|
||||||
|
*/
|
||||||
|
private float interpolateMagnitude(int direction, int pair, float step) {
|
||||||
|
float magnitude = (float) magnitudes[direction][0][pair] + step
|
||||||
|
* (float) (magnitudes[direction][1][pair] - magnitudes[direction][0][pair]);
|
||||||
|
magnitude *= 0.001525879F;
|
||||||
|
return 1.0F - (float) Math.pow(10D, -magnitude / 20F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float normalise(float exponent) {
|
||||||
|
float f1 = 32.7032F * (float) Math.pow(2D, exponent);
|
||||||
|
return (f1 * 3.141593F) / 11025F;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform linear interpolation on the phase
|
||||||
|
*
|
||||||
|
* @param direction The direction, where {@code 0} is feedforward, and {@code 1} is feedback.
|
||||||
|
* @param pair The pair.
|
||||||
|
* @param step The step (the interpolation parameter).
|
||||||
|
* @return The interpolated phase.
|
||||||
|
*/
|
||||||
|
private float interpolatePhase(int direction, int pair, float step) {
|
||||||
|
float phase = (float) phases[direction][0][pair] + step
|
||||||
|
* (float) (phases[direction][1][pair] - phases[direction][0][pair]);
|
||||||
|
phase *= 0.0001220703F;
|
||||||
|
return normalise(phase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compute(int direction, float step) {
|
||||||
|
if (direction == 0) {
|
||||||
|
float unity = (float) this.unity[0] + (float) (this.unity[1] - this.unity[0]) * step;
|
||||||
|
unity *= 0.003051758F;
|
||||||
|
forwardMinimisedCoefficientMultiplier = (float) Math.pow(
|
||||||
|
0.10000000000000001D, unity / 20F);
|
||||||
|
forwardMultiplier = (int) (forwardMinimisedCoefficientMultiplier * 65536F);
|
||||||
|
}
|
||||||
|
if (pairs[direction] == 0)
|
||||||
|
return 0;
|
||||||
|
float initialMagnitude = interpolateMagnitude(direction, 0, step);
|
||||||
|
minimisedCoefficients[direction][0] = -2F * initialMagnitude
|
||||||
|
* (float) Math.cos(interpolatePhase(direction, 0, step));
|
||||||
|
minimisedCoefficients[direction][1] = initialMagnitude * initialMagnitude;
|
||||||
|
for (int pair = 1; pair < pairs[direction]; pair++) {
|
||||||
|
float magnitude = interpolateMagnitude(direction, pair, step);
|
||||||
|
float f4 = -2F * magnitude * (float) Math.cos(interpolatePhase(direction, pair, step));
|
||||||
|
float f5 = magnitude * magnitude;
|
||||||
|
minimisedCoefficients[direction][pair * 2 + 1] = minimisedCoefficients[direction][pair * 2 - 1]
|
||||||
|
* f5;
|
||||||
|
minimisedCoefficients[direction][pair * 2] = minimisedCoefficients[direction][pair * 2 - 1]
|
||||||
|
* f4 + minimisedCoefficients[direction][pair * 2 - 2] * f5;
|
||||||
|
for (int j1 = pair * 2 - 1; j1 >= 2; j1--)
|
||||||
|
minimisedCoefficients[direction][j1] += minimisedCoefficients[direction][j1 - 1]
|
||||||
|
* f4 + minimisedCoefficients[direction][j1 - 2] * f5;
|
||||||
|
|
||||||
|
minimisedCoefficients[direction][1] += minimisedCoefficients[direction][0] * f4
|
||||||
|
+ f5;
|
||||||
|
minimisedCoefficients[direction][0] += f4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (direction == 0) {
|
||||||
|
for (int l = 0; l < pairs[0] * 2; l++)
|
||||||
|
minimisedCoefficients[0][l] *= forwardMinimisedCoefficientMultiplier;
|
||||||
|
|
||||||
|
}
|
||||||
|
for (int pair = 0; pair < pairs[direction] * 2; pair++)
|
||||||
|
coefficients[direction][pair] = (int) (minimisedCoefficients[direction][pair] * 65536F);
|
||||||
|
|
||||||
|
return pairs[direction] * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decode(Buffer stream, Envelope soundEnveleope) {
|
||||||
|
int count = stream.readUnsignedByte();
|
||||||
|
pairs[0] = count >> 4;
|
||||||
|
pairs[1] = count & 0xf;
|
||||||
|
if (count != 0) {
|
||||||
|
unity[0] = stream.readUShort();
|
||||||
|
unity[1] = stream.readUShort();
|
||||||
|
int migration = stream.readUnsignedByte();
|
||||||
|
for (int k = 0; k < 2; k++) {
|
||||||
|
for (int l = 0; l < pairs[k]; l++) {
|
||||||
|
phases[k][0][l] = stream.readUShort();
|
||||||
|
magnitudes[k][0][l] = stream.readUShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int direction = 0; direction < 2; direction++) {
|
||||||
|
for (int pair = 0; pair < pairs[direction]; pair++)
|
||||||
|
if ((migration & 1 << direction * 4 << pair) != 0) {
|
||||||
|
phases[direction][1][pair] = stream
|
||||||
|
.readUShort();
|
||||||
|
magnitudes[direction][1][pair] = stream
|
||||||
|
.readUShort();
|
||||||
|
} else {
|
||||||
|
phases[direction][1][pair] = phases[direction][0][pair];
|
||||||
|
magnitudes[direction][1][pair] = magnitudes[direction][0][pair];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (migration != 0 || unity[1] != unity[0])
|
||||||
|
soundEnveleope.decodeSegments(stream);
|
||||||
|
} else {
|
||||||
|
unity[0] = unity[1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package org.rebotted.sound;
|
||||||
|
/**
|
||||||
|
* Class containing sound-related constants.
|
||||||
|
* @author 7Winds
|
||||||
|
*/
|
||||||
|
public class SoundConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Music player
|
||||||
|
*/
|
||||||
|
public static final int SCAPE_RUNE = 0;
|
||||||
|
public static final int OLD_THEME = 400;
|
||||||
|
public static final int HWEEN_THEME = 321;
|
||||||
|
public static final int XMAS_THEME = 547;
|
||||||
|
public static final int FARMING_THEME = 466;
|
||||||
|
public static final int HUNTER_THEME = 207;
|
||||||
|
public static final int SUMMON_THEME = 457;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package org.rebotted.sound;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.Clip;
|
||||||
|
import javax.sound.sampled.DataLine;
|
||||||
|
import javax.sound.sampled.FloatControl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom class which is not found in the 317 deob.
|
||||||
|
*/
|
||||||
|
public class SoundPlayer implements Runnable {
|
||||||
|
|
||||||
|
private AudioInputStream stream;
|
||||||
|
private DataLine.Info info;
|
||||||
|
private Clip sound;
|
||||||
|
|
||||||
|
private InputStream soundStream;
|
||||||
|
private Thread player;
|
||||||
|
private int delay;
|
||||||
|
private int soundLevel;
|
||||||
|
public static int volume;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the sound player.
|
||||||
|
* @param stream
|
||||||
|
* @param level
|
||||||
|
* @param delay
|
||||||
|
*/
|
||||||
|
public SoundPlayer(InputStream stream, int level, int delay) {
|
||||||
|
if (level == 0 || volume == 4 || level - volume <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.soundStream = stream;
|
||||||
|
this.soundLevel = level;
|
||||||
|
this.delay = delay;
|
||||||
|
player = new Thread(this);
|
||||||
|
player.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the sound.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
stream = AudioSystem.getAudioInputStream(soundStream);
|
||||||
|
info = new DataLine.Info(Clip.class, stream.getFormat());
|
||||||
|
sound = (Clip) AudioSystem.getLine(info);
|
||||||
|
sound.open(stream);
|
||||||
|
FloatControl volume = (FloatControl) sound.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
|
volume.setValue(getDecibels(soundLevel - getVolume()));
|
||||||
|
if (delay > 0) {
|
||||||
|
Thread.sleep(delay);
|
||||||
|
}
|
||||||
|
sound.start();
|
||||||
|
while (sound.isActive()) {
|
||||||
|
Thread.sleep(250);
|
||||||
|
}
|
||||||
|
Thread.sleep(10000);
|
||||||
|
sound.close();
|
||||||
|
stream.close();
|
||||||
|
player.interrupt();
|
||||||
|
} catch (Exception e) {
|
||||||
|
player.interrupt();
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the client's volume level.
|
||||||
|
* @param level
|
||||||
|
*/
|
||||||
|
public static void setVolume(int level) {
|
||||||
|
volume = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the client's volume level.
|
||||||
|
*/
|
||||||
|
public static int getVolume() {
|
||||||
|
return volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the decibels for a given volume level.
|
||||||
|
* @param level
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public float getDecibels(int level) {
|
||||||
|
switch (level) {
|
||||||
|
case 1:
|
||||||
|
return (float) -80.0;
|
||||||
|
case 2:
|
||||||
|
return (float) -70.0;
|
||||||
|
case 3:
|
||||||
|
return (float) -60.0;
|
||||||
|
case 4:
|
||||||
|
return (float) -50.0;
|
||||||
|
case 5:
|
||||||
|
return (float) -40.0;
|
||||||
|
case 6:
|
||||||
|
return (float) -30.0;
|
||||||
|
case 7:
|
||||||
|
return (float) -20.0;
|
||||||
|
case 8:
|
||||||
|
return (float) -10.0;
|
||||||
|
case 9:
|
||||||
|
return (float) -0.0;
|
||||||
|
case 10:
|
||||||
|
return (float) 6.0;
|
||||||
|
default:
|
||||||
|
return (float) 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
package org.rebotted.sound;
|
||||||
|
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refactored reference:
|
||||||
|
* http://www.rune-server.org/runescape-development/rs2-client/downloads/575183-almost-fully-refactored-317-client.html
|
||||||
|
*/
|
||||||
|
final class Synthesizer {
|
||||||
|
|
||||||
|
private Envelope pitch;
|
||||||
|
private Envelope volume;
|
||||||
|
private Envelope pitchModifier;
|
||||||
|
private Envelope pitchModifierAmplitude;
|
||||||
|
private Envelope volumeMultiplier;
|
||||||
|
private Envelope volumeMultiplierAmplitude;
|
||||||
|
private Envelope release;
|
||||||
|
private Envelope attack;
|
||||||
|
private final int[] oscillatorVolume;
|
||||||
|
private final int[] anIntArray107;
|
||||||
|
private final int[] anIntArray108;
|
||||||
|
private int delayTime;
|
||||||
|
private int delayDecay;
|
||||||
|
private Filter filter;
|
||||||
|
private Envelope filterEnvelope;
|
||||||
|
int duration;
|
||||||
|
int offset;
|
||||||
|
private static int[] samples;
|
||||||
|
private static int[] NOISE;
|
||||||
|
private static int[] SINE;
|
||||||
|
private static final int[] phases = new int[5];
|
||||||
|
private static final int[] delays = new int[5];
|
||||||
|
private static final int[] volumeSteps = new int[5];
|
||||||
|
private static final int[] pitchSteps = new int[5];
|
||||||
|
private static final int[] pitchBaseSteps = new int[5];
|
||||||
|
|
||||||
|
public Synthesizer() {
|
||||||
|
oscillatorVolume = new int[5];
|
||||||
|
anIntArray107 = new int[5];
|
||||||
|
anIntArray108 = new int[5];
|
||||||
|
delayDecay = 100;
|
||||||
|
duration = 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
NOISE = new int[32768];
|
||||||
|
for (int i = 0; i < 32768; i++)
|
||||||
|
if (Math.random() > 0.5D)
|
||||||
|
NOISE[i] = 1;
|
||||||
|
else
|
||||||
|
NOISE[i] = -1;
|
||||||
|
|
||||||
|
SINE = new int[32768];
|
||||||
|
for (int j = 0; j < 32768; j++)
|
||||||
|
SINE[j] = (int) (Math.sin((double) j / 5215.1903000000002D) * 16384D);
|
||||||
|
|
||||||
|
samples = new int[0x35d54];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] synthesize(int sampleCount, int duration) {
|
||||||
|
for (int k = 0; k < sampleCount; k++)
|
||||||
|
samples[k] = 0;
|
||||||
|
|
||||||
|
if (duration < 10)
|
||||||
|
return samples;
|
||||||
|
double d = (double) sampleCount / ((double) duration + 0.0D);
|
||||||
|
pitch.resetValues();
|
||||||
|
volume.resetValues();
|
||||||
|
int pitchMultiplierStep = 0;
|
||||||
|
int pitchModifierBaseStep = 0;
|
||||||
|
int pitchModifierPhase = 0;
|
||||||
|
if (pitchModifier != null) {
|
||||||
|
pitchModifier.resetValues();
|
||||||
|
pitchModifierAmplitude.resetValues();
|
||||||
|
pitchMultiplierStep = (int) (((double) (pitchModifier.end - pitchModifier.start) * 32.768000000000001D) / d);
|
||||||
|
pitchModifierBaseStep = (int) (((double) pitchModifier.start * 32.768000000000001D) / d);
|
||||||
|
}
|
||||||
|
int volumeMultiplierStep = 0;
|
||||||
|
int volumeMultiplierBaseStep = 0;
|
||||||
|
int volumeMultiplierPhase = 0;
|
||||||
|
if (volumeMultiplier != null) {
|
||||||
|
volumeMultiplier.resetValues();
|
||||||
|
volumeMultiplierAmplitude.resetValues();
|
||||||
|
volumeMultiplierStep = (int) (((double) (volumeMultiplier.end - volumeMultiplier.start) * 32.768000000000001D) / d);
|
||||||
|
volumeMultiplierBaseStep = (int) (((double) volumeMultiplier.start * 32.768000000000001D) / d);
|
||||||
|
}
|
||||||
|
for (int index = 0; index < 5; index++)
|
||||||
|
if (oscillatorVolume[index] != 0) {
|
||||||
|
phases[index] = 0;
|
||||||
|
delays[index] = (int) ((double) anIntArray108[index] * d);
|
||||||
|
volumeSteps[index] = (oscillatorVolume[index] << 14) / 100;
|
||||||
|
pitchSteps[index] = (int) (((double) (pitch.end - pitch.start) * 32.768000000000001D * Math
|
||||||
|
.pow(1.0057929410678534D, anIntArray107[index])) / d);
|
||||||
|
pitchBaseSteps[index] = (int) (((double) pitch.start * 32.768000000000001D) / d);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int sample = 0; sample < sampleCount; sample++) {
|
||||||
|
int pitchChange = pitch.step(sampleCount);
|
||||||
|
int volumeChange = volume.step(sampleCount);
|
||||||
|
if (pitchModifier != null) {
|
||||||
|
int modifier = pitchModifier.step(sampleCount);
|
||||||
|
int ampModifier = pitchModifierAmplitude.step(sampleCount);
|
||||||
|
pitchChange += evaluateWave(ampModifier, pitchModifierPhase,
|
||||||
|
pitchModifier.form) >> 1;
|
||||||
|
pitchModifierPhase += (modifier * pitchMultiplierStep >> 16)
|
||||||
|
+ pitchModifierBaseStep;
|
||||||
|
}
|
||||||
|
if (volumeMultiplier != null) {
|
||||||
|
int multiplier = volumeMultiplier.step(sampleCount);
|
||||||
|
int ampMultiplier = volumeMultiplierAmplitude.step(sampleCount);
|
||||||
|
volumeChange = volumeChange
|
||||||
|
* ((evaluateWave(ampMultiplier, volumeMultiplierPhase,
|
||||||
|
volumeMultiplier.form) >> 1) + 32768) >> 15;
|
||||||
|
volumeMultiplierPhase += (multiplier * volumeMultiplierStep >> 16)
|
||||||
|
+ volumeMultiplierBaseStep;
|
||||||
|
}
|
||||||
|
for (int delay = 0; delay < 5; delay++)
|
||||||
|
if (oscillatorVolume[delay] != 0) {
|
||||||
|
int id = sample + delays[delay];
|
||||||
|
if (id < sampleCount) {
|
||||||
|
samples[id] += evaluateWave(volumeChange
|
||||||
|
* volumeSteps[delay] >> 15, phases[delay],
|
||||||
|
pitch.form);
|
||||||
|
phases[delay] += (pitchChange * pitchSteps[delay] >> 16)
|
||||||
|
+ pitchBaseSteps[delay];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (release != null) {
|
||||||
|
release.resetValues();
|
||||||
|
attack.resetValues();
|
||||||
|
int counter = 0;
|
||||||
|
boolean muted = true;
|
||||||
|
for (int sample = 0; sample < sampleCount; sample++) {
|
||||||
|
int on = release.step(sampleCount);
|
||||||
|
int off = attack.step(sampleCount);
|
||||||
|
int threshold;
|
||||||
|
if (muted)
|
||||||
|
threshold = release.start
|
||||||
|
+ ((release.end - release.start) * on >> 8);
|
||||||
|
else
|
||||||
|
threshold = release.start
|
||||||
|
+ ((release.end - release.start) * off >> 8);
|
||||||
|
if ((counter += 256) >= threshold) {
|
||||||
|
counter = 0;
|
||||||
|
muted = !muted;
|
||||||
|
}
|
||||||
|
if (muted)
|
||||||
|
samples[sample] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (delayTime > 0 && delayDecay > 0) {
|
||||||
|
int delay = (int) ((double) delayTime * d);
|
||||||
|
for (int index = delay; index < sampleCount; index++)
|
||||||
|
samples[index] += (samples[index - delay] * delayDecay) / 100;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (filter.pairs[0] > 0 || filter.pairs[1] > 0) {
|
||||||
|
filterEnvelope.resetValues();
|
||||||
|
int change = filterEnvelope.step(sampleCount + 1);
|
||||||
|
int forwardOrder = filter.compute(0, (float) change / 65536F);
|
||||||
|
int backOrder = filter.compute(1, (float) change / 65536F);
|
||||||
|
if (sampleCount >= forwardOrder + backOrder) {
|
||||||
|
int index = 0;
|
||||||
|
int delay = backOrder;
|
||||||
|
if (delay > sampleCount - forwardOrder)
|
||||||
|
delay = sampleCount - forwardOrder;
|
||||||
|
for (; index < delay; index++) {
|
||||||
|
int sample = (int) ((long) samples[index + forwardOrder]
|
||||||
|
* (long) Filter.forwardMultiplier >> 16);
|
||||||
|
for (int j8 = 0; j8 < forwardOrder; j8++)
|
||||||
|
sample += (int) ((long) samples[(index + forwardOrder)
|
||||||
|
- 1 - j8]
|
||||||
|
* (long) Filter.coefficients[0][j8] >> 16);
|
||||||
|
|
||||||
|
for (int j9 = 0; j9 < index; j9++)
|
||||||
|
sample -= (int) ((long) samples[index - 1 - j9]
|
||||||
|
* (long) Filter.coefficients[1][j9] >> 16);
|
||||||
|
|
||||||
|
samples[index] = sample;
|
||||||
|
change = filterEnvelope.step(sampleCount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
char c = '\200';
|
||||||
|
delay = c;
|
||||||
|
do {
|
||||||
|
if (delay > sampleCount - forwardOrder)
|
||||||
|
delay = sampleCount - forwardOrder;
|
||||||
|
for (; index < delay; index++) {
|
||||||
|
int l8 = (int) ((long) samples[index + forwardOrder]
|
||||||
|
* (long) Filter.forwardMultiplier >> 16);
|
||||||
|
for (int k9 = 0; k9 < forwardOrder; k9++)
|
||||||
|
l8 += (int) ((long) samples[(index + forwardOrder)
|
||||||
|
- 1 - k9]
|
||||||
|
* (long) Filter.coefficients[0][k9] >> 16);
|
||||||
|
|
||||||
|
for (int i10 = 0; i10 < backOrder; i10++)
|
||||||
|
l8 -= (int) ((long) samples[index - 1 - i10]
|
||||||
|
* (long) Filter.coefficients[1][i10] >> 16);
|
||||||
|
|
||||||
|
samples[index] = l8;
|
||||||
|
change = filterEnvelope.step(sampleCount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= sampleCount - forwardOrder)
|
||||||
|
break;
|
||||||
|
forwardOrder = filter.compute(0, (float) change / 65536F);
|
||||||
|
backOrder = filter.compute(1, (float) change / 65536F);
|
||||||
|
delay += c;
|
||||||
|
} while (true);
|
||||||
|
for (; index < sampleCount; index++) {
|
||||||
|
int sample = 0;
|
||||||
|
for (int l9 = (index + forwardOrder) - sampleCount; l9 < forwardOrder; l9++)
|
||||||
|
sample += (int) ((long) samples[(index + forwardOrder)
|
||||||
|
- 1 - l9]
|
||||||
|
* (long) Filter.coefficients[0][l9] >> 16);
|
||||||
|
|
||||||
|
for (int j10 = 0; j10 < backOrder; j10++)
|
||||||
|
sample -= (int) ((long) samples[index - 1 - j10]
|
||||||
|
* (long) Filter.coefficients[1][j10] >> 16);
|
||||||
|
|
||||||
|
samples[index] = sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int sample = 0; sample < sampleCount; sample++) {
|
||||||
|
if (samples[sample] < -32768)
|
||||||
|
samples[sample] = -32768;
|
||||||
|
if (samples[sample] > 32767)
|
||||||
|
samples[sample] = 32767;
|
||||||
|
}
|
||||||
|
|
||||||
|
return samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int evaluateWave(int amplitude, int phase, int table) {
|
||||||
|
if (table == 1)
|
||||||
|
if ((phase & 0x7fff) < 16384)
|
||||||
|
return amplitude;
|
||||||
|
else
|
||||||
|
return -amplitude;
|
||||||
|
if (table == 2)
|
||||||
|
return SINE[phase & 0x7fff] * amplitude >> 14;
|
||||||
|
if (table == 3)
|
||||||
|
return ((phase & 0x7fff) * amplitude >> 14) - amplitude;
|
||||||
|
if (table == 4)
|
||||||
|
return NOISE[phase / 2607 & 0x7fff] * amplitude;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decode(Buffer stream) {
|
||||||
|
pitch = new Envelope();
|
||||||
|
pitch.decode(stream);
|
||||||
|
volume = new Envelope();
|
||||||
|
volume.decode(stream);
|
||||||
|
int option = stream.readUnsignedByte();
|
||||||
|
if (option != 0) {
|
||||||
|
stream.currentPosition--;
|
||||||
|
pitchModifier = new Envelope();
|
||||||
|
pitchModifier.decode(stream);
|
||||||
|
pitchModifierAmplitude = new Envelope();
|
||||||
|
pitchModifierAmplitude.decode(stream);
|
||||||
|
}
|
||||||
|
option = stream.readUnsignedByte();
|
||||||
|
if (option != 0) {
|
||||||
|
stream.currentPosition--;
|
||||||
|
volumeMultiplier = new Envelope();
|
||||||
|
volumeMultiplier.decode(stream);
|
||||||
|
volumeMultiplierAmplitude = new Envelope();
|
||||||
|
volumeMultiplierAmplitude.decode(stream);
|
||||||
|
}
|
||||||
|
option = stream.readUnsignedByte();
|
||||||
|
if (option != 0) {
|
||||||
|
stream.currentPosition--;
|
||||||
|
release = new Envelope();
|
||||||
|
release.decode(stream);
|
||||||
|
attack = new Envelope();
|
||||||
|
attack.decode(stream);
|
||||||
|
}
|
||||||
|
for (int index = 0; index < 10; index++) {
|
||||||
|
int volume = stream.readUSmart();
|
||||||
|
if (volume == 0)
|
||||||
|
break;
|
||||||
|
oscillatorVolume[index] = volume;
|
||||||
|
anIntArray107[index] = stream.readSmart();
|
||||||
|
anIntArray108[index] = stream.readUSmart();
|
||||||
|
}
|
||||||
|
|
||||||
|
delayTime = stream.readUSmart();
|
||||||
|
delayDecay = stream.readUSmart();
|
||||||
|
duration = stream.readUShort();
|
||||||
|
offset = stream.readUShort();
|
||||||
|
filter = new Filter();
|
||||||
|
filterEnvelope = new Envelope();
|
||||||
|
filter.decode(stream, filterEnvelope);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
package org.rebotted.sound;
|
||||||
|
|
||||||
|
import org.rebotted.io.Buffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refactored reference:
|
||||||
|
* http://www.rune-server.org/runescape-development/rs2-client/downloads/575183-almost-fully-refactored-317-client.html
|
||||||
|
*/
|
||||||
|
public final class Track {
|
||||||
|
|
||||||
|
private Track() {
|
||||||
|
synthesizers = new Synthesizer[10];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unpack(Buffer stream) {
|
||||||
|
output = new byte[0x6baa8];
|
||||||
|
riff = new Buffer(output);
|
||||||
|
Synthesizer.init();
|
||||||
|
do {
|
||||||
|
int id = stream.readUShort();
|
||||||
|
if (id == 65535)
|
||||||
|
return;
|
||||||
|
tracks[id] = new Track();
|
||||||
|
tracks[id].decode(stream);
|
||||||
|
delays[id] = tracks[id].calculateDelay();
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Buffer data(int loops, int id) {
|
||||||
|
if (tracks[id] != null) {
|
||||||
|
Track soundTrack = tracks[id];
|
||||||
|
return soundTrack.pack(loops);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decode(Buffer stream) {
|
||||||
|
for (int synthesizer = 0; synthesizer < 10; synthesizer++) {
|
||||||
|
int valid = stream.readUnsignedByte();
|
||||||
|
if (valid != 0) {
|
||||||
|
stream.currentPosition--;
|
||||||
|
synthesizers[synthesizer] = new Synthesizer();
|
||||||
|
synthesizers[synthesizer].decode(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loopStart = stream.readUShort();
|
||||||
|
loopEnd = stream.readUShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int calculateDelay() {
|
||||||
|
int offset = 0x98967f;
|
||||||
|
for (int syntheziser = 0; syntheziser < 10; syntheziser++)
|
||||||
|
if (synthesizers[syntheziser] != null
|
||||||
|
&& synthesizers[syntheziser].offset / 20 < offset)
|
||||||
|
offset = synthesizers[syntheziser].offset / 20;
|
||||||
|
|
||||||
|
if (loopStart < loopEnd && loopStart / 20 < offset)
|
||||||
|
offset = loopStart / 20;
|
||||||
|
if (offset == 0x98967f || offset == 0)
|
||||||
|
return 0;
|
||||||
|
for (int synthesizer = 0; synthesizer < 10; synthesizer++)
|
||||||
|
if (synthesizers[synthesizer] != null)
|
||||||
|
synthesizers[synthesizer].offset -= offset * 20;
|
||||||
|
|
||||||
|
if (loopStart < loopEnd) {
|
||||||
|
loopStart -= offset * 20;
|
||||||
|
loopEnd -= offset * 20;
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Buffer pack(int loops) {
|
||||||
|
int size = mix(loops);
|
||||||
|
riff.currentPosition = 0;
|
||||||
|
riff.writeInt(0x52494646);
|
||||||
|
riff.writeLEInt(36 + size);
|
||||||
|
riff.writeInt(0x57415645);
|
||||||
|
riff.writeInt(0x666d7420);
|
||||||
|
riff.writeLEInt(16);
|
||||||
|
riff.writeLEShort(1);
|
||||||
|
riff.writeLEShort(1);
|
||||||
|
riff.writeLEInt(22050);
|
||||||
|
riff.writeLEInt(22050);
|
||||||
|
riff.writeLEShort(1);
|
||||||
|
riff.writeLEShort(8);
|
||||||
|
riff.writeInt(0x64617461);
|
||||||
|
riff.writeLEInt(size);
|
||||||
|
riff.currentPosition += size;
|
||||||
|
return riff;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int mix(int loops) {
|
||||||
|
int duration = 0;
|
||||||
|
for (int synthesizer = 0; synthesizer < 10; synthesizer++)
|
||||||
|
if (synthesizers[synthesizer] != null
|
||||||
|
&& synthesizers[synthesizer].duration + synthesizers[synthesizer].offset > duration)
|
||||||
|
duration = synthesizers[synthesizer].duration + synthesizers[synthesizer].offset;
|
||||||
|
|
||||||
|
if (duration == 0)
|
||||||
|
return 0;
|
||||||
|
int sampleCount = (22050 * duration) / 1000;
|
||||||
|
int loopStart = (22050 * this.loopStart) / 1000;
|
||||||
|
int loopEnd = (22050 * this.loopEnd) / 1000;
|
||||||
|
if (loopStart < 0 || loopStart > sampleCount || loopEnd < 0 || loopEnd > sampleCount || loopStart >= loopEnd)
|
||||||
|
loops = 0;
|
||||||
|
int size = sampleCount + (loopEnd - loopStart) * (loops - 1);
|
||||||
|
for (int offset = 44; offset < size + 44; offset++)
|
||||||
|
output[offset] = -128;
|
||||||
|
|
||||||
|
for (int synthesizer = 0; synthesizer < 10; synthesizer++)
|
||||||
|
if (synthesizers[synthesizer] != null) {
|
||||||
|
int synthDuration = (synthesizers[synthesizer].duration * 22050) / 1000;
|
||||||
|
int synthOffset = (synthesizers[synthesizer].offset * 22050) / 1000;
|
||||||
|
int samples[] = synthesizers[synthesizer].synthesize(synthDuration,
|
||||||
|
synthesizers[synthesizer].duration);
|
||||||
|
for (int sample = 0; sample < synthDuration; sample++)
|
||||||
|
output[sample + synthOffset + 44] += (byte) (samples[sample] >> 8);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loops > 1) {
|
||||||
|
loopStart += 44;
|
||||||
|
loopEnd += 44;
|
||||||
|
sampleCount += 44;
|
||||||
|
int k2 = (size += 44) - sampleCount;
|
||||||
|
for (int j3 = sampleCount - 1; j3 >= loopEnd; j3--)
|
||||||
|
output[j3 + k2] = output[j3];
|
||||||
|
|
||||||
|
for (int k3 = 1; k3 < loops; k3++) {
|
||||||
|
int l2 = (loopEnd - loopStart) * k3;
|
||||||
|
System.arraycopy(output, loopStart, output, loopStart + l2, loopEnd - loopStart);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
size -= 44;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Track[] tracks = new Track[5000];
|
||||||
|
public static final int[] delays = new int[5000];
|
||||||
|
private static byte[] output;
|
||||||
|
private static Buffer riff;
|
||||||
|
private final Synthesizer[] synthesizers;
|
||||||
|
private int loopStart;
|
||||||
|
private int loopEnd;
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user