1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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);
}
|