summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/ShapeLoader.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/ShapeLoader.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/ShapeLoader.java')
-rw-r--r--NET/worlds/scape/ShapeLoader.java113
1 files changed, 113 insertions, 0 deletions
diff --git a/NET/worlds/scape/ShapeLoader.java b/NET/worlds/scape/ShapeLoader.java
new file mode 100644
index 0000000..abee9b8
--- /dev/null
+++ b/NET/worlds/scape/ShapeLoader.java
@@ -0,0 +1,113 @@
+package NET.worlds.scape;
+
+import NET.worlds.network.URL;
+import java.util.Enumeration;
+import java.util.Vector;
+
+public class ShapeLoader implements BGLoaded {
+ Shape shape;
+ int binaryParam;
+ private int numTexturesLoading;
+ private Vector<Texture> textures;
+ private boolean wasError;
+
+ public ShapeLoader(Shape s) {
+ this.shape = s;
+ }
+
+ @Override
+ public Room getBackgroundLoadRoom() {
+ return this.shape.getRoom();
+ }
+
+ @Override
+ public Object asyncBackgroundLoad(String localName, URL remoteName) {
+ if (localName == null) {
+ return null;
+ } else if (remoteName.endsWith(".rwg") || remoteName.endsWith(".RWG")) {
+ this.binaryParam = this.loadBinaryFile(localName, remoteName);
+ return new Object();
+ } else if (remoteName.endsWith(".rwx") || remoteName.endsWith(".RWX")) {
+ this.loadTextFile(localName, remoteName);
+ return localName;
+ } else {
+ return !remoteName.endsWith(".bod") && !remoteName.endsWith(".BOD") ? null : localName;
+ }
+ }
+
+ @Override
+ public boolean syncBackgroundLoad(Object o, URL remoteURL) {
+ if (o == null) {
+ return false;
+ } else if (this.numTexturesLoading > 0) {
+ return true;
+ } else {
+ if (!remoteURL.equals(this.shape.realFile)) {
+ this.wasError = true;
+ } else if (!this.shape.hasClump() && this.shape.isDefault) {
+ this.wasError = true;
+ if (!this.shape.isLoaded()) {
+ this.shape.setState(0, null);
+ }
+ }
+
+ int newModel;
+ if (o instanceof String) {
+ if (!this.wasError) {
+ if (remoteURL.endsWith(".bod")) {
+ newModel = this.loadBodFile((String)o, this.shape.getBodPartNum());
+ } else {
+ newModel = this.finishLoadingTextFile((String)o);
+ }
+ } else {
+ newModel = 0;
+ }
+ } else {
+ newModel = this.finishLoadingBinaryFile(this.binaryParam, this.wasError);
+ }
+
+ if (newModel != 0) {
+ this.shape.setState(newModel, this.textures);
+ }
+
+ if ((newModel == 0 || newModel == -1) && this.textures != null) {
+ Enumeration<Texture> en = this.textures.elements();
+
+ while (en.hasMoreElements()) {
+ en.nextElement().decRef();
+ }
+ }
+
+ this.textures = null;
+ return false;
+ }
+ }
+
+ private void startTextureLoad(String relName, URL remoteName) {
+ this.numTexturesLoading++;
+ BackgroundLoader.get(new ShapeTextureLoader(this), URL.make(remoteName, relName), true);
+ }
+
+ synchronized void textureLoadEnd(Texture tex) {
+ this.numTexturesLoading--;
+ if (tex != null) {
+ if (this.textures == null) {
+ this.textures = new Vector<Texture>();
+ }
+
+ this.textures.addElement(tex);
+ } else {
+ this.wasError = true;
+ }
+ }
+
+ private native void loadTextFile(String var1, URL var2);
+
+ private native int finishLoadingTextFile(String var1);
+
+ private native int loadBodFile(String var1, int var2);
+
+ private native int loadBinaryFile(String var1, URL var2);
+
+ private native int finishLoadingBinaryFile(int var1, boolean var2);
+}