diff options
Diffstat (limited to 'NET/worlds/scape/RemotePortal.java')
| -rw-r--r-- | NET/worlds/scape/RemotePortal.java | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/NET/worlds/scape/RemotePortal.java b/NET/worlds/scape/RemotePortal.java new file mode 100644 index 0000000..aa3621e --- /dev/null +++ b/NET/worlds/scape/RemotePortal.java @@ -0,0 +1,73 @@ +package NET.worlds.scape; + +import NET.worlds.network.URL; +import java.io.IOException; +import java.util.Enumeration; + +public class RemotePortal extends WObject { + private static Object classCookie = new Object(); + + RemotePortal() { + } + + @Override + public void saveState(Saver s) throws IOException { + assert false; + } + + @Override + public void restoreState(Restorer r) throws IOException, TooNewException { + Portal p = new Portal(); + r.replace(this, p); + int vers = r.restoreVersion(classCookie); + WObject dlRepresentation = null; + WObject initialRepresentation = null; + p.superRestoreState(r); + Point3 p1 = (Point3)r.restore(); + Point3 p2 = (Point3)r.restore(); + p.moveTo(p1); + p.setFarCorner(p2); + Point3 p3 = (Point3)r.restore(); + Point3 p4 = (Point3)r.restore(); + URL wname = URL.restore(r); + String rname = r.restoreString(); + p.connectTo(wname, rname, p3, p4); + switch (vers) { + case 0: + r.setOldFlag(); + r.restoreBoolean(); + dlRepresentation = (WObject)r.restoreMaybeNull(); + initialRepresentation = (WObject)r.restoreMaybeNull(); + r.restoreMaybeNull(); + break; + case 1: + dlRepresentation = (WObject)r.restoreMaybeNull(); + initialRepresentation = (WObject)r.restoreMaybeNull(); + break; + default: + throw new TooNewException(); + } + + if (initialRepresentation instanceof Surface) { + Surface s = (Surface)initialRepresentation; + Material m = s.getMaterial(); + s.setMaterial(null); + p.setMaterial(m); + } + + if (dlRepresentation instanceof Surface) { + Surface s = (Surface)dlRepresentation; + Material m = s.getMaterial(); + s.setMaterial(null); + p.setMaterial(m); + } + + if (initialRepresentation != null) { + for (Enumeration en = initialRepresentation.getHandlers(); en.hasMoreElements(); en = initialRepresentation.getHandlers()) { + SuperRoot h = (SuperRoot)en.nextElement(); + initialRepresentation.removeHandler(h); + p.addHandler(h); + } + } + } +} |