diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/Sharer.java | |
| download | worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip | |
Diffstat (limited to 'NET/worlds/scape/Sharer.java')
| -rw-r--r-- | NET/worlds/scape/Sharer.java | 1089 |
1 files changed, 1089 insertions, 0 deletions
diff --git a/NET/worlds/scape/Sharer.java b/NET/worlds/scape/Sharer.java new file mode 100644 index 0000000..5ed5126 --- /dev/null +++ b/NET/worlds/scape/Sharer.java @@ -0,0 +1,1089 @@ +/* */ package NET.worlds.scape; +/* */ +/* */ import NET.worlds.console.Console; +/* */ import NET.worlds.console.Main; +/* */ import NET.worlds.console.MainCallback; +/* */ import NET.worlds.core.Std; +/* */ import NET.worlds.network.InfiniteWaitException; +/* */ import NET.worlds.network.NetworkRoom; +/* */ import NET.worlds.network.ObjID; +/* */ import NET.worlds.network.PacketTooLargeException; +/* */ import NET.worlds.network.PropertyList; +/* */ import NET.worlds.network.PropertySetCmd; +/* */ import NET.worlds.network.WorldServer; +/* */ import NET.worlds.network.net2Property; +/* */ import java.io.ByteArrayInputStream; +/* */ 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; +/* */ import java.util.Vector; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class Sharer +/* */ extends SuperRoot +/* */ implements MainCallback +/* */ { +/* */ private Vector<Attribute> attributes; +/* 143 */ private ByteArrayOutputStream bs = new ByteArrayOutputStream(); +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public Sharer() +/* */ { +/* 151 */ this.attributes = new Vector(256); +/* 152 */ this.attributes.setSize(256); +/* */ } +/* */ +/* 155 */ private boolean shared = false; +/* */ public static final int FIRST_TIME = 0; +/* */ +/* 158 */ public boolean isShared() { return this.shared; } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static final int STATIC = 2; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static final int FORWARDED_STATIC = 3; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private int getMaybeDefaultMode() +/* */ { +/* 186 */ return ((WObject)getOwner()).getSharerMode(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public int getMode() +/* */ { +/* 199 */ int mode = getMaybeDefaultMode(); +/* 200 */ if (mode == 0) { +/* 201 */ setMode(mode); +/* */ } +/* 203 */ return mode; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static final int DYNAMIC = 4; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static final int FORWARDED_DYNAMIC = 5; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static final int FORWARDED = 1; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void setMode(int mode) +/* */ { +/* 233 */ WObject w = (WObject)getOwner(); +/* */ +/* */ +/* */ +/* 237 */ if ((w instanceof Room)) { +/* 238 */ mode = 2; +/* 239 */ } else if (this.createdFromNet) { +/* 240 */ mode = 4; +/* 241 */ } else if ((mode == 2) || (mode == 4)) +/* */ { +/* 243 */ mode = 0; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* 249 */ if (mode == 0) { +/* 250 */ mode = 3; +/* */ } +/* 252 */ int oldMode = getMaybeDefaultMode(); +/* 253 */ if (oldMode != mode) +/* */ { +/* */ +/* 256 */ unshare(); +/* */ +/* */ +/* 259 */ w.setSharerMode(mode); +/* */ } +/* 261 */ share(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void createDynamicForwardedFromNet(DynamicForwardAttribute dfa) +/* */ { +/* 271 */ assert (!((WObject)getOwner()).isActive()); +/* 272 */ this.dfa = dfa; +/* 273 */ ((WObject)getOwner()).setSharerMode(5); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void createDynamicFromNet() +/* */ { +/* 283 */ assert ((!((WObject)getOwner()).isActive()) || (this.createdFromNet)); +/* 284 */ this.createdFromNet = true; +/* 285 */ ((WObject)getOwner()).setSharerMode(4); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void adjustShare() +/* */ { +/* 308 */ share(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private void share() +/* */ { +/* 318 */ if (this.shared) { +/* 319 */ return; +/* */ } +/* 321 */ int mode = getMaybeDefaultMode(); +/* */ +/* 323 */ switch (mode) { +/* */ case 0: +/* 325 */ setMode(0); +/* 326 */ break; +/* */ +/* */ +/* */ +/* */ +/* */ case 5: +/* 332 */ if (this.dfa == null) { +/* 333 */ flushQueue(); +/* */ +/* 335 */ WObject w = (WObject)getOwner(); +/* 336 */ WObject terminal = w.getServed(); +/* */ +/* */ +/* 339 */ if ((w.getSourceURL() != null) && (terminal != null)) { +/* 340 */ this.dfa = new DynamicForwardAttribute(-1); +/* 341 */ if (terminal.getSharer().addAttribute(this.dfa) == -1) { +/* 342 */ this.dfa = null; +/* */ } else +/* 344 */ this.dfa.connect(w); +/* */ } +/* */ } +/* 347 */ break; +/* */ +/* */ case 3: +/* 350 */ flushQueue(); +/* 351 */ for (Enumeration<Attribute> e = getAttributes(); e.hasMoreElements();) +/* 352 */ ((Attribute)e.nextElement()).addForwarding(); +/* 353 */ case 4: if ((goto 198) && +/* */ +/* */ +/* 356 */ (!$assertionsDisabled) && (!this.createdFromNet)) { throw new AssertionError(); +/* */ } +/* */ +/* */ break; +/* */ } +/* */ +/* */ +/* 363 */ this.shared = true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private void unshare() +/* */ { +/* 371 */ if (!this.shared) { +/* 372 */ return; +/* */ } +/* 374 */ int mode = getMaybeDefaultMode(); +/* */ +/* 376 */ switch (mode) { +/* */ case 5: +/* 378 */ if (this.dfa != null) +/* */ { +/* 380 */ this.dfa.unconnect(); +/* 381 */ this.dfa = null; +/* */ } +/* 383 */ break; +/* */ +/* */ case 3: +/* 386 */ Enumeration<Attribute> e = getAttributes(); +/* 387 */ for (;;) { ((Attribute)e.nextElement()).unforward(); +/* 386 */ if (!e.hasMoreElements()) { +/* */ break; +/* */ } +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* 395 */ this.shared = false; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public int addAttribute(Attribute a) +/* */ { +/* 418 */ setMode(getMaybeDefaultMode()); +/* */ +/* 420 */ a._attrID = getFreeAttrIDFor(a, a._attrID); +/* 421 */ if (a._attrID == -1) { +/* 422 */ return a._attrID; +/* */ } +/* */ +/* */ try +/* */ { +/* 427 */ add(a); +/* */ } catch (ClassCastException e) { +/* 429 */ Console.println(Console.message("Cant-attach") + e); +/* */ +/* 431 */ a._attrID = -1; +/* 432 */ return a._attrID; +/* */ } +/* */ +/* 435 */ this.attributes.setElementAt(a, a._attrID); +/* */ +/* 437 */ if (getMaybeDefaultMode() == 3) { +/* 438 */ a.addForwarding(); +/* */ } +/* 440 */ return a._attrID; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public boolean attrIDAvailable(int id) +/* */ { +/* 449 */ return this.attributes.elementAt(id) == null; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private int getFreeAttrID(int id, int low, int high) +/* */ { +/* 458 */ if ((id >= 20) && (id <= 255) && (attrIDAvailable(id))) { +/* 459 */ return id; +/* */ } +/* */ +/* */ +/* */ +/* 464 */ int freeCount = countFree(low, high); +/* */ +/* 466 */ if (freeCount == 0) { +/* 467 */ return -1; +/* */ } +/* */ int i; +/* */ do { +/* 471 */ int pos = (int)(Math.random() * freeCount); +/* 472 */ for (i = low;; i++) +/* 473 */ if (this.attributes.elementAt(i) == null) { +/* 474 */ pos--; if (pos < 0) +/* */ break; +/* */ } +/* 477 */ assert (i <= high); +/* 478 */ } while ((i == 150) || (i == 155) || (i == 160)); +/* */ +/* 480 */ return i; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public int getFreeAttrIDFor(Attribute a, int id) +/* */ { +/* 492 */ if ((a instanceof DynamicForwardAttribute)) { +/* 493 */ return getFreeAttrID(id, 210, 249); +/* */ } +/* 495 */ return getFreeAttrID(id, 100, 249); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public void removeAttribute(Attribute a) +/* */ { +/* 503 */ a.detach(); +/* */ +/* */ +/* 506 */ if (a.getOwner() == null) { +/* 507 */ this.attributes.setElementAt(null, a._attrID); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public int resetAttributeID(Attribute a, int newID) +/* */ { +/* 519 */ newID = getFreeAttrIDFor(a, newID); +/* 520 */ if (newID == -1) { +/* 521 */ return newID; +/* */ } +/* 523 */ if (this.attributes.elementAt(newID) == null) { +/* 524 */ int oldID = a._attrID; +/* 525 */ this.attributes.setElementAt(a, newID); +/* 526 */ this.attributes.setElementAt(null, oldID); +/* 527 */ a._attrID = newID; +/* */ } +/* */ +/* 530 */ return newID; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public void moveToSlot(WObject child, int newID) +/* */ { +/* 538 */ if (!child.isDynamic()) +/* 539 */ return; +/* 540 */ Sharer s = child.getSharer(); +/* 541 */ if (s.dfa == null) +/* 542 */ return; +/* 543 */ resetAttributeID(s.dfa, newID); +/* */ } +/* */ +/* */ +/* */ +/* */ public Enumeration<Attribute> getAttributes() +/* */ { +/* 550 */ return getAttributesList().elements(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public Vector<Attribute> getAttributesList() +/* */ { +/* 559 */ Vector<Attribute> v = new Vector(this.attributes.size()); +/* 560 */ fillAttributesList(v); +/* 561 */ return v; +/* */ } +/* */ +/* */ +/* */ +/* */ public void fillAttributesList(Vector<Attribute> v) +/* */ { +/* 568 */ int end = this.attributes.size(); +/* 569 */ for (int i = 0; i < end; i++) { +/* 570 */ Attribute a = (Attribute)this.attributes.elementAt(i); +/* 571 */ if (a != null) { +/* 572 */ v.addElement(a); +/* */ } +/* */ } +/* */ } +/* */ +/* */ +/* */ public Attribute getAttribute(int id) +/* */ { +/* */ try +/* */ { +/* 582 */ return (Attribute)this.attributes.elementAt(id); +/* */ } catch (ArrayIndexOutOfBoundsException e) {} +/* 584 */ return null; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public boolean isEmpty() +/* */ { +/* 592 */ return countFree(0, 255) == 256; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public int countFree(int low, int high) +/* */ { +/* 600 */ int count = 0; +/* */ +/* 602 */ for (int i = low; i <= high; i++) { +/* 603 */ if (this.attributes.elementAt(i) == null) +/* 604 */ count++; +/* */ } +/* 606 */ return count; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void getChildren(DeepEnumeration d) +/* */ { +/* 618 */ d.addChildVectorWithNulls(this.attributes); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private boolean createdFromNet; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ Vector<Attribute> noteQ; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ Vector<Attribute> prepQ; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ Vector<Attribute> sendQ; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private DynamicForwardAttribute dfa; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ int lastSendTime; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void noteChange(Attribute a, boolean sendTriggers) +/* */ { +/* 666 */ assert (Main.isMainThread()); +/* */ +/* */ +/* 669 */ if (this.prepQ == null) { +/* 670 */ this.noteQ = new Vector(); +/* 671 */ this.prepQ = new Vector(); +/* 672 */ this.sendQ = new Vector(); +/* */ } +/* */ +/* */ +/* */ +/* 677 */ if ((sendTriggers) && +/* 678 */ (!this.noteQ.contains(a))) { +/* 679 */ if ((this.noteQ.isEmpty()) && (this.prepQ.isEmpty()) && (this.sendQ.isEmpty())) { +/* 680 */ Main.register(this); +/* */ } +/* 682 */ this.noteQ.addElement(a); +/* */ } +/* */ +/* */ +/* */ Attribute fa; +/* */ +/* 688 */ if ((getMode() == 3) && +/* 689 */ ((fa = a.getForwardAttribute()) != null)) { +/* 690 */ fa.noteChange(); +/* 691 */ } else if (this.dfa != null) { +/* 692 */ this.dfa.noteChange(); +/* */ +/* */ } +/* 695 */ else if (!this.prepQ.contains(a)) { +/* 696 */ if ((this.noteQ.isEmpty()) && (this.prepQ.isEmpty()) && (this.sendQ.isEmpty())) { +/* 697 */ Main.register(this); +/* */ } +/* 699 */ this.prepQ.addElement(a); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private void prepQueue() +/* */ { +/* 713 */ if (!this.noteQ.isEmpty()) { +/* 714 */ int end = this.noteQ.size(); +/* */ +/* 716 */ for (int i = 0; i < end; i++) { +/* 717 */ Attribute a = (Attribute)this.noteQ.elementAt(i); +/* */ +/* */ +/* */ +/* 721 */ ValueEvent e = new ValueEvent( +/* 722 */ Std.getFastTime(), getOwner(), +/* 723 */ (WObject)getOwner(), a); +/* 724 */ a.trigger(e); +/* */ } +/* 726 */ this.noteQ.removeAllElements(); +/* */ } +/* */ +/* 729 */ int end = this.prepQ.size(); +/* 730 */ for (int i = 0; i < end; i++) { +/* 731 */ Attribute a = (Attribute)this.prepQ.elementAt(i); +/* */ +/* */ +/* 734 */ this.bs.reset(); +/* */ try { +/* 736 */ a.generateNetData(new DataOutputStream(this.bs)); +/* */ } catch (IOException ex) { +/* 738 */ System.err.println(ex); +/* 739 */ throw new Error("Fatal in generateNetData"); +/* */ } +/* */ +/* */ +/* 743 */ a._outgoing = this.bs.toByteArray(); +/* */ +/* 745 */ if (Std.byteArraysEqual(a._outgoing, a._serverData)) +/* */ { +/* */ +/* */ +/* */ +/* 750 */ a._outgoing = null; +/* */ } +/* 752 */ else if (!this.sendQ.contains(a)) { +/* 753 */ this.sendQ.addElement(a); +/* */ } +/* */ } +/* */ +/* 757 */ this.prepQ.removeAllElements(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void mainCallback() +/* */ { +/* 782 */ if ((this.noteQ.isEmpty()) && (this.prepQ.isEmpty()) && (this.sendQ.isEmpty())) { +/* 783 */ Main.unregister(this); +/* 784 */ return; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* 790 */ int frameTime = Std.getFastTime(); +/* 791 */ if (frameTime > this.lastSendTime + 250) +/* */ { +/* 793 */ sendQueue(); +/* */ +/* */ +/* 796 */ Main.unregister(this); +/* */ +/* 798 */ this.lastSendTime = frameTime; +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private void flushQueue() +/* */ { +/* 808 */ if (this.prepQ == null) { +/* 809 */ return; +/* */ } +/* 811 */ prepQueue(); +/* */ +/* 813 */ if (this.sendQ.isEmpty()) { +/* 814 */ return; +/* */ } +/* 816 */ int i = this.sendQ.size(); +/* 817 */ do { Attribute a = (Attribute)this.sendQ.elementAt(i); +/* 818 */ a._waitingForFeedback = false; +/* 819 */ a._serverData = null; +/* 820 */ a._outgoing = null;i--; +/* 816 */ } while (i >= 0); +/* */ +/* */ +/* */ +/* */ +/* */ +/* 822 */ this.sendQ.removeAllElements(); +/* */ } +/* */ +/* */ +/* */ +/* */ private void sendQueue() +/* */ { +/* 829 */ prepQueue(); +/* */ +/* 831 */ WorldServer rs = ((WObject)getOwner()).getServer(); +/* */ +/* */ +/* */ +/* 835 */ if (rs != null) { +/* 836 */ int end = this.sendQ.size(); +/* 837 */ for (int i = 0; i < end; i++) { +/* 838 */ Attribute a = (Attribute)this.sendQ.elementAt(i); +/* */ +/* */ +/* 841 */ if (a._outgoing != null) { +/* 842 */ share(rs, a); +/* 843 */ a._serverData = a._outgoing; +/* 844 */ a._outgoing = null; +/* 845 */ a._waitingForFeedback = true; +/* */ } +/* */ } +/* */ } +/* */ +/* 850 */ this.sendQ.removeAllElements(); +/* */ } +/* */ +/* */ +/* */ +/* */ private void share(WorldServer ws, Attribute a) +/* */ { +/* 857 */ SuperRoot w = getOwner(); +/* */ +/* */ +/* 860 */ ObjID objID = null; +/* */ +/* 862 */ if ((w instanceof Room)) { +/* 863 */ Pilot pilot = Pilot.getActive(); +/* 864 */ if ((pilot == null) || (pilot.getLastServedRoom() == w)) { +/* 865 */ objID = new ObjID(253); +/* */ } else +/* 867 */ objID = new ObjID(((Room)w).getNetworkRoom().getLongID()); +/* 868 */ } else if ((w instanceof Pilot)) { +/* 869 */ objID = new ObjID(1); +/* */ } else { +/* 871 */ objID = new ObjID(w.getName()); +/* */ } +/* */ try { +/* 874 */ PropertyList propList = new PropertyList(); +/* 875 */ propList.addProperty(new net2Property(a._attrID, +/* 876 */ a.getFlags(), a.getAccessFlags(), a._outgoing)); +/* 877 */ ws.sendNetworkMsg(new PropertySetCmd(objID, +/* 878 */ propList)); +/* */ } catch (InfiniteWaitException e) { +/* 880 */ Console.println(Console.message("Net-shutdown") + e.toString()); +/* */ } catch (PacketTooLargeException e) { +/* 882 */ if (!$assertionsDisabled) { throw new AssertionError(); +/* */ } +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public void setFromNetData(int attrID, byte[] data) +/* */ { +/* 892 */ if (this.prepQ != null) { +/* 893 */ prepQueue(); +/* */ } +/* 895 */ Attribute a = getAttribute(attrID); +/* 896 */ if (a == null) +/* */ { +/* */ +/* */ +/* 900 */ if ((getMode() & 0x1) == 0) { +/* 901 */ a = new DynamicForwardAttribute(attrID); +/* 902 */ addAttribute(a); +/* */ } else { +/* 904 */ Object[] arguments = { new String(attrID), +/* 905 */ new String(getOwner().getName()) }; +/* 906 */ Console.println(MessageFormat.format( +/* 907 */ Console.message("Unknown-attr"), arguments)); +/* 908 */ return; +/* */ } +/* */ } +/* */ +/* */ +/* 913 */ setData(a, data); +/* */ +/* 915 */ if (!a.loaded) { +/* 916 */ a.loaded = true; +/* 917 */ if ((a.callbacks != null) && (a.callbacks.size() > 0)) { +/* 918 */ Enumeration<LoadedAttribute> e = a.callbacks.elements(); +/* 919 */ while (e.hasMoreElements()) { +/* 920 */ LoadedAttribute la = (LoadedAttribute)e.nextElement(); +/* 921 */ la.loadedAttribute(a, null); +/* */ } +/* 923 */ a.callbacks.removeAllElements(); +/* */ } +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private void setData(Attribute a, byte[] data) +/* */ { +/* 933 */ boolean matchesLastSent = Std.byteArraysEqual(data, a._serverData); +/* */ +/* 935 */ if (a._waitingForFeedback) { +/* 936 */ if (matchesLastSent) +/* */ { +/* 938 */ a._waitingForFeedback = false; +/* */ +/* 940 */ if ((data.length == 0) && (a._outgoing == null)) { +/* */ break label44; +/* */ } +/* */ +/* */ } +/* */ } +/* 946 */ else if (matchesLastSent) { +/* 947 */ return; +/* */ } +/* */ label44: +/* 950 */ a._serverData = data; +/* */ +/* 952 */ if (Std.byteArraysEqual(data, a._outgoing)) +/* */ { +/* */ +/* */ +/* */ +/* 957 */ a._outgoing = null; +/* 958 */ } else if (a._outgoing == null) +/* */ { +/* */ try { +/* 961 */ a.setFromNetData(new DataInputStream(new ByteArrayInputStream( +/* 962 */ data)), data.length); +/* */ } catch (IOException e) { +/* 964 */ e.printStackTrace(); +/* 965 */ Console.println(Console.message("Unrec-format") + a.getName()); +/* */ } +/* */ +/* */ +/* 969 */ ValueEvent e = new ValueEvent(Std.getFastTime(), +/* 970 */ this, (WObject)getOwner(), a); +/* 971 */ a.trigger(e); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ public Object properties(int index, int offset, int mode, Object value) +/* */ throws NoSuchPropertyException +/* */ { +/* 980 */ throw new NoSuchPropertyException(); +/* */ } +/* */ +/* */ +/* */ +/* 985 */ private static Object classCookie = new Object(); +/* */ +/* */ public void saveState(Saver s) throws IOException +/* */ { +/* 989 */ s.saveVersion(2, classCookie); +/* */ +/* 991 */ super.saveState(s); +/* */ +/* 993 */ s.saveVector(getAttributesList()); +/* */ } +/* */ +/* 996 */ private Vector<Object> restoredAttributes = null; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void restoreState(Restorer r) +/* */ throws IOException, TooNewException +/* */ { +/* 1010 */ switch (r.restoreVersion(classCookie)) { +/* */ case 0: +/* 1012 */ setName(r.restoreString()); +/* */ +/* 1014 */ int nSharedAtts = r.restoreInt(); +/* 1015 */ this.restoredAttributes = new Vector(nSharedAtts); +/* 1016 */ for (int i = 0; i < nSharedAtts; i++) { +/* 1017 */ this.restoredAttributes.addElement(r.restoreString()); +/* */ } +/* 1019 */ break; +/* */ +/* */ case 1: +/* 1022 */ setName(r.restoreString()); +/* */ +/* */ +/* */ +/* */ +/* 1027 */ this.restoredAttributes = r.restoreVector(); +/* 1028 */ break; +/* */ +/* */ case 2: +/* 1031 */ super.restoreState(r); +/* */ +/* */ +/* */ +/* */ +/* */ +/* 1037 */ this.restoredAttributes = r.restoreVector(); +/* 1038 */ break; +/* */ +/* */ default: +/* 1041 */ throw new TooNewException(); +/* */ } +/* */ +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void ownerPostRestore() +/* */ { +/* 1052 */ int desiredMode = getMaybeDefaultMode(); +/* 1053 */ ((WObject)getOwner()).setSharerMode(0); +/* 1054 */ setMode(desiredMode); +/* */ +/* 1056 */ for (Enumeration<Object> e = this.restoredAttributes.elements(); e.hasMoreElements();) { +/* 1057 */ Attribute a = (Attribute)e.nextElement(); +/* */ +/* */ +/* 1060 */ addAttribute(a); +/* */ } +/* 1062 */ this.restoredAttributes = null; +/* */ } +/* */ +/* */ +/* */ public void releaseAuxilaryData() +/* */ { +/* 1068 */ for (int i = 0; i < 256; i++) { +/* 1069 */ Attribute a = (Attribute)this.attributes.elementAt(i); +/* */ +/* 1071 */ if (a != null) { +/* 1072 */ a.releaseAuxilaryData(); +/* */ } +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Sharer.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |