diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/RemotePortal.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
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); + } + } + } +} |