summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/DynamicForwardAttribute.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/DynamicForwardAttribute.java
downloadworlds.jar-main.tar.xz
worlds.jar-main.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/scape/DynamicForwardAttribute.java')
-rw-r--r--NET/worlds/scape/DynamicForwardAttribute.java308
1 files changed, 308 insertions, 0 deletions
diff --git a/NET/worlds/scape/DynamicForwardAttribute.java b/NET/worlds/scape/DynamicForwardAttribute.java
new file mode 100644
index 0000000..ecbefc9
--- /dev/null
+++ b/NET/worlds/scape/DynamicForwardAttribute.java
@@ -0,0 +1,308 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.console.Console;
+/* */ import NET.worlds.network.URL;
+/* */ import java.io.ByteArrayOutputStream;
+/* */ import java.io.DataInputStream;
+/* */ import java.io.DataOutputStream;
+/* */ import java.io.IOException;
+/* */ import java.io.PrintStream;
+/* */ import java.text.MessageFormat;
+/* */ import java.util.Enumeration;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public class DynamicForwardAttribute
+/* */ extends Attribute
+/* */ implements NonPersister, WobLoaded
+/* */ {
+/* 43 */ WObject wob = null;
+/* */
+/* */ DynamicForwardAttribute(int attrID)
+/* */ {
+/* 47 */ super(attrID);
+/* */ }
+/* */
+/* 50 */ static int DYNAMIC_CODE = 21990;
+/* */
+/* */ WobLoader wobLoader;
+/* */ DataInputStream wobLoaderProps;
+/* */
+/* */ private URL getDynamicHeader(DataInputStream ds)
+/* */ {
+/* */ try
+/* */ {
+/* 59 */ if (ds.readUnsignedShort() != DYNAMIC_CODE) {
+/* 60 */ return null;
+/* */ }
+/* 62 */ return new URL(this, ds.readUTF());
+/* */ }
+/* */ catch (IOException e) {}
+/* 65 */ return null;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void setFromNetData(DataInputStream ds, int len)
+/* */ throws IOException
+/* */ {
+/* 84 */ URL wobName = getDynamicHeader(ds);
+/* 85 */ if ((wobName == null) || (this.wob == null) ||
+/* 86 */ (!wobName.equals(this.wob.getSourceURL())))
+/* */ {
+/* */
+/* 89 */ if (this.wob != null)
+/* */ {
+/* */
+/* */
+/* 93 */ WObject w = this.wob;
+/* 94 */ this.wob = null;
+/* 95 */ w.detach();
+/* */ }
+/* */
+/* */
+/* 99 */ if (wobName == null)
+/* */ {
+/* 101 */ ((Sharer)getOwner()).removeAttribute(this);
+/* 102 */ return;
+/* */ }
+/* */
+/* */
+/* */
+/* 107 */ if ((this.wobLoader == null) || (!this.wobLoader.getWobName().equals(wobName))) {
+/* 108 */ this.wobLoader = new WobLoader(wobName, this);
+/* */ }
+/* */
+/* 111 */ this.wobLoaderProps = ds;
+/* */ }
+/* */ else
+/* */ {
+/* 115 */ setProps(ds);
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public void wobLoaded(WobLoader loader, SuperRoot w)
+/* */ {
+/* 124 */ if (loader != this.wobLoader) {
+/* 125 */ return;
+/* */ }
+/* 127 */ Object[] arguments = { new String(
+/* 128 */ loader.getWobName().toString()) };
+/* */
+/* 130 */ if (w == null)
+/* */ {
+/* */
+/* */
+/* 134 */ Console.println(MessageFormat.format(
+/* 135 */ Console.message("Couldnt-load"), arguments));
+/* 136 */ this.wobLoaderProps = null;
+/* 137 */ return; }
+/* 138 */ if (!(w instanceof WObject)) {
+/* 139 */ Console.println(MessageFormat.format(
+/* 140 */ Console.message("not-WObject"), arguments));
+/* 141 */ this.wobLoaderProps = null;
+/* 142 */ return;
+/* */ }
+/* */
+/* 145 */ this.wob = ((WObject)w);
+/* */
+/* */
+/* 148 */ this.wob.getSharer().createDynamicForwardedFromNet(this);
+/* */
+/* */
+/* 151 */ ((WObject)getOwner().getOwner()).add(this.wob);
+/* */
+/* */
+/* 154 */ setProps(this.wobLoaderProps);
+/* 155 */ this.wobLoaderProps = null;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ void connect(WObject w)
+/* */ {
+/* 164 */ assert (this.wob == null);
+/* 165 */ this.wob = w;
+/* */
+/* 167 */ noteChange();
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ void unconnect()
+/* */ {
+/* 177 */ if (this.wob != null)
+/* */ {
+/* 179 */ this.wob = null;
+/* 180 */ noteChange();
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public void setProps(DataInputStream ds)
+/* */ {
+/* */ for (;;)
+/* */ {
+/* */ try
+/* */ {
+/* */ int id;
+/* */
+/* */
+/* */
+/* */
+/* 200 */ if ((id = ds.read()) == -1) {
+/* 201 */ return;
+/* */ }
+/* 203 */ int len = ds.readByte();
+/* 204 */ byte[] b = new byte[len];
+/* 205 */ ds.readFully(b, 0, len); } catch (IOException e) { break; }
+/* */ int len;
+/* */ byte[] b;
+/* */ int id;
+/* 209 */ this.wob.getSharer().setFromNetData(id, b);
+/* */ }
+/* */
+/* 212 */ Object[] arguments = { new String(getAttrID()) };
+/* 213 */ Console.println(MessageFormat.format(
+/* 214 */ Console.message("Early-EOF"), arguments));
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* 221 */ private ByteArrayOutputStream _bs = new ByteArrayOutputStream();
+/* */
+/* */
+/* */
+/* */
+/* */ public void generateNetData(DataOutputStream s)
+/* */ throws IOException
+/* */ {
+/* 229 */ if ((this.wob == null) || (this.wob.getSourceURL() == null)) {
+/* 230 */ return;
+/* */ }
+/* 232 */ s.writeShort(DYNAMIC_CODE);
+/* */
+/* 234 */ s.writeUTF(this.wob.getSourceURL().getRelativeTo(this));
+/* */
+/* */
+/* 237 */ Enumeration<Attribute> e = this.wob.getSharer().getAttributes();
+/* 238 */ while (e.hasMoreElements())
+/* */ {
+/* */
+/* 241 */ Attribute a = (Attribute)e.nextElement();
+/* 242 */ s.writeByte(a.getAttrID());
+/* */
+/* 244 */ this._bs.reset();
+/* */ try {
+/* 246 */ a.generateNetData(new DataOutputStream(this._bs));
+/* */ }
+/* */ catch (IOException ex)
+/* */ {
+/* 250 */ System.err.println(ex);
+/* 251 */ throw new Error("Fatal in generateNetData");
+/* */ }
+/* */
+/* 254 */ s.writeByte(this._bs.size());
+/* 255 */ this._bs.writeTo(s);
+/* */ }
+/* */ }
+/* */
+/* */
+/* */ protected void noteAddingTo(SuperRoot owner)
+/* */ {
+/* 262 */ WObject w = (WObject)owner.getOwner();
+/* 263 */ if ((w.getSharer().getMode() & 0x1) != 0) {
+/* 264 */ throw new ClassCastException(
+/* 265 */ "Must forward to unforwarded object");
+/* */ }
+/* */ }
+/* */
+/* */ public void detach() {
+/* 270 */ if ((this.wob == null) && (!this._waitingForFeedback))
+/* */ {
+/* 272 */ this.wobLoader = null;
+/* 273 */ super.detach();
+/* */ }
+/* */ else
+/* */ {
+/* 277 */ Console.println(Console.message("Shutting-down"));
+/* 278 */ if (this.wob != null) {
+/* 279 */ this.wob.detach();
+/* */ }
+/* */ }
+/* */ }
+/* */
+/* */ public void setAttrID(int newID) {
+/* 285 */ Console.println(Console.message("Cant-change-ID"));
+/* */ }
+/* */
+/* */ public String toString()
+/* */ {
+/* 290 */ if (this.wob == null) {
+/* 291 */ return super.toString();
+/* */ }
+/* 293 */ return
+/* 294 */ super.toString() + "[forwarding wob " + this.wob.getName() + "]";
+/* */ }
+/* */
+/* */ public void restoreState(Restorer r)
+/* */ throws IOException, TooNewException
+/* */ {
+/* 300 */ if (!$assertionsDisabled) throw new AssertionError();
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\DynamicForwardAttribute.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file