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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
package NET.worlds.scape;
import NET.worlds.core.FastDataInput;
import NET.worlds.network.URL;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Vector;
public class URLSelfLoader implements BGLoaded {
private static Hashtable loaded = new Hashtable();
private static Hashtable loading = new Hashtable();
private URL url;
private Vector callbacks = new Vector();
private static final int INIT = 0;
private static final int DONE = -1;
private int state = 0;
private FastDataInput inFile;
private Restorer restorer;
private URLSelf loadedObj;
public Object otemp1;
public Object otemp2;
public int itemp1;
public int itemp2;
public static void load(URL url, LoadedURLSelf callback) {
load(url, callback, false);
}
public static void load(URL url, LoadedURLSelf callback, boolean isHighPriority) {
URLSelf o = (URLSelf)loaded.get(url);
if (o != null) {
o.incRef();
callback.loadedURLSelf(o, url, null);
} else {
URLSelfLoader cl = (URLSelfLoader)loading.get(url);
if (cl != null) {
cl.callbacks.addElement(callback);
} else {
new URLSelfLoader(url, callback, isHighPriority);
}
}
}
public static void unload(URLSelf self) {
loaded.remove(self.getSourceURL());
}
public static void immediateLoad(IncrementalRestorer o, Restorer r) throws IOException, TooNewException {
new URLSelfLoader(o, r);
}
private URLSelfLoader(IncrementalRestorer o, Restorer r) throws IOException, TooNewException {
this.url = null;
while (this.state != -1) {
try {
this.state = o.incRestore(this.state, r, this);
} catch (Exception var4) {
var4.printStackTrace(System.out);
assert false;
}
}
}
public URL getURL() {
return this.url;
}
private URLSelfLoader(URL url, LoadedURLSelf callback, boolean isHighPriority) {
loading.put(url, this);
this.url = url;
this.callbacks.addElement(callback);
BackgroundLoader.get(this, url, isHighPriority);
}
@Override
public Object asyncBackgroundLoad(String localName, URL remoteName) {
if (localName == null) {
return "Can't find file " + this.url;
} else {
try {
return new FastDataInput(localName);
} catch (IOException var4) {
return "Can't load file " + this.url;
}
}
}
@Override
public boolean syncBackgroundLoad(Object obj, URL remoteURL) {
if (obj instanceof String) {
this.doneLoading(null, (String)obj);
return false;
} else {
assert this.state != -1;
if (this.state == 0) {
this.inFile = (FastDataInput)obj;
Object o = null;
try {
this.restorer = new Restorer(this.inFile, this.url);
o = this.restorer.restore(false);
this.loadedObj = (URLSelf)o;
this.loadedObj.setSourceURL(this.getURL());
if (!(this.loadedObj instanceof IncrementalRestorer)) {
this.loadedObj.restoreState(this.restorer);
this.restorer.done();
return this.doneLoading(this.loadedObj, null);
}
} catch (Exception var7) {
var7.printStackTrace(System.out);
return this.doneLoading(null, "Can't restore from file " + this.url + ": " + var7.toString());
}
}
try {
this.state = ((IncrementalRestorer)this.loadedObj).incRestore(this.state, this.restorer, this);
} catch (Exception var6) {
var6.printStackTrace(System.out);
return this.doneLoading(null, var6.toString());
}
if (this.state == -1) {
try {
this.restorer.done();
} catch (IOException var5) {
var5.printStackTrace(System.out);
return this.doneLoading(null, var5.toString());
}
if (this.restorer.version() < 3 && this.loadedObj instanceof Camera) {
Camera cam = (Camera)this.loadedObj;
World w = cam.getWorld();
w.setSourceURL(cam.getSourceURL());
}
return this.doneLoading(this.loadedObj, null);
} else {
return true;
}
}
}
private boolean doneLoading(URLSelf o, String err) {
if (this.inFile != null) {
this.inFile.close();
this.inFile = null;
}
loading.remove(this.url);
if (o != null) {
if (this.restorer.version() < 4 && o instanceof Camera) {
Camera c = (Camera)o;
o = c.getWorld();
c.detach();
}
loaded.put(this.url, o);
}
int end = this.callbacks.size();
for (int i = 0; i < end; i++) {
LoadedURLSelf callback = (LoadedURLSelf)this.callbacks.elementAt(i);
if (o != null) {
o.incRef();
}
callback.loadedURLSelf(o, this.url, err);
}
this.state = -1;
return false;
}
@Override
public Room getBackgroundLoadRoom() {
return null;
}
}
|