/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.AdBanner; /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.Gamma; /* */ import NET.worlds.console.Main; /* */ import NET.worlds.console.ProgressBar; /* */ import NET.worlds.console.Shaper; /* */ import NET.worlds.console.WorldsMarkPart; /* */ import NET.worlds.core.Hashtable; /* */ import NET.worlds.core.IniFile; /* */ import NET.worlds.core.Std; /* */ import NET.worlds.network.Galaxy; /* */ import NET.worlds.network.NetUpdate; /* */ import NET.worlds.network.URL; /* */ import NET.worlds.network.WorldServer; /* */ import java.io.BufferedReader; /* */ import java.io.File; /* */ import java.io.FileReader; /* */ import java.io.IOException; /* */ import java.io.PrintStream; /* */ import java.text.MessageFormat; /* */ import java.util.Enumeration; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class World /* */ extends SuperRoot /* */ implements URLSelf, LoadedURLSelf, IncrementalRestorer /* */ { /* */ public World getWorld() /* */ { /* 160 */ return this; /* */ } /* */ /* 163 */ static WorldRedirector redir = new WorldRedirector(URL.make(Gamma.getHome() + /* 164 */ "redir.txt")); /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void load(URL url, LoadedURLSelf callback, boolean force) /* */ { /* 173 */ if (Gamma.loadProgress != null) { /* 174 */ Gamma.loadProgress.setMessage("Loading world files..."); /* 175 */ Gamma.loadProgress.advance(); /* */ } /* */ /* */ /* 179 */ if (url.toString().indexOf("UserHomeWorld") != -1) { /* 180 */ String homeWorld = WorldsMarkPart.getFirstSystemMarkURL(); /* 181 */ if (homeWorld != null) /* */ { /* 183 */ int poundIdx = homeWorld.indexOf("#"); /* 184 */ if (poundIdx != -1) /* 185 */ homeWorld = homeWorld.substring(0, poundIdx); /* 186 */ url = URL.make(homeWorld); /* */ } /* */ } /* */ /* */ /* 191 */ File f = new File(url.unalias()); /* 192 */ if (!f.exists()) { /* 193 */ url = redir.get(url); /* */ } /* 195 */ if (isProscribed(url, force)) { /* 196 */ callback.loadedURLSelf(null, url, "Can't autoload WorldsStore"); /* 197 */ return; /* */ } /* */ /* */ /* */ /* 202 */ World w = (World)worldHash.get(url); /* 203 */ if (w != null) { /* 204 */ w.incRef(); /* 205 */ callback.loadedURLSelf(w, url, null); /* */ } else { /* 207 */ URLSelfLoader.load(url, callback, true); /* */ } /* */ } /* */ /* 211 */ public static void load(URL url, LoadedURLSelf callback) { load(url, callback, false); } /* */ /* */ /* 214 */ private static boolean cloistered = false; /* 215 */ private static boolean cloisteredSet = false; /* */ /* */ /* */ /* */ /* */ /* */ public static boolean isCloistered() /* */ { /* 223 */ if (!cloisteredSet) { /* 224 */ URL homeDir = URL.make("home:" + WorldsMarkPart.getFirstWorld()); /* 225 */ cloistered = new File(homeDir.unalias() + "/cloistered").exists(); /* 226 */ cloisteredSet = true; /* */ } /* 228 */ return cloistered; /* */ } /* */ /* */ public static URL getHomeStore() { /* 232 */ URL storeinf = URL.make("home:" + WorldsMarkPart.getFirstWorld() + /* 233 */ "/store.inf"); /* 234 */ URL homeStore = URL.make("home:PolyGram/polygramdlb.world"); /* */ /* 236 */ File sf = new File(storeinf.unalias()); /* 237 */ if ((!sf.exists()) || (!sf.isFile())) { /* 238 */ sf = new File(URL.make("home:PolyGram/store.inf").unalias()); /* 239 */ if ((!sf.exists()) || (!sf.isFile())) { /* 240 */ return homeStore; /* */ } /* */ } /* */ try /* */ { /* 245 */ BufferedReader rdr = new BufferedReader(new FileReader(sf)); /* 246 */ String s = rdr.readLine(); /* 247 */ rdr.close(); /* 248 */ homeStore = new URL(s); /* */ } /* */ catch (IOException localIOException) {} /* */ /* 252 */ return homeStore; /* */ } /* */ /* */ public static boolean isWorldsStoreProscribed() { /* 256 */ return (isCloistered()) && /* 257 */ (IniFile.gamma().getIniInt("WorldsStoreProscribed", 1) != 0); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static boolean isProscribed(URL url, boolean forceLoad) /* */ { /* 270 */ if ((!forceLoad) && (!WorldValidator.allow(url.toString()))) { /* 271 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 283 */ return false; /* */ } /* */ /* */ public boolean isHomeWorld() { /* 287 */ URL url = getSourceURL(); /* 288 */ if (url != null) { /* 289 */ URL homeURL = URL.make("home:" + WorldsMarkPart.getFirstWorld()); /* 290 */ if (url.unalias().startsWith(homeURL.unalias() + "/")) /* 291 */ return true; /* */ } /* 293 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ public void setEdited(boolean state) /* */ { /* 301 */ if (state != this.hasBeenEdited) { /* 302 */ this.hasBeenEdited = state; /* 303 */ worldListChanged(); /* */ } /* */ } /* */ /* */ public void markEdited() /* */ { /* 309 */ setEdited(true); /* */ } /* */ /* 312 */ private String adCubeBaseURL = null; /* */ /* */ public String getAdCubeBaseURL() { /* 315 */ if (this.adCubeBaseURL == null) { /* 316 */ String worldURL = getSourceURL().toString(); /* */ /* */ /* 319 */ if (worldURL.lastIndexOf("/") == -1) { /* 320 */ return "ads/ad"; /* */ } /* 322 */ worldURL = worldURL.substring(0, worldURL.lastIndexOf("/")); /* */ /* 324 */ WorldServer w = Pilot.getActive().getServer(); /* 325 */ if ((w != null) && (w.getGalaxy().getOnline())) { /* 326 */ String adserverURL = NetUpdate.getUpgradeServerURL(); /* 327 */ if (adserverURL != null) /* */ { /* 329 */ int i1 = worldURL.lastIndexOf("/"); /* 330 */ int i2 = worldURL.lastIndexOf(":"); /* 331 */ i1 = i1 > i2 ? i1 : i2; /* 332 */ if (i1 > -1) { /* 333 */ worldURL = worldURL.substring(i1 + 1); /* */ } /* 335 */ return adserverURL + worldURL + "/ads/ad"; /* */ } /* */ } /* */ /* 339 */ return worldURL + "/ads/ad"; /* */ } /* */ /* 342 */ return this.adCubeBaseURL; /* */ } /* */ /* */ public void setAdCubeBaseURL(String s) { /* 346 */ this.adCubeBaseURL = new String(s); /* */ } /* */ /* 349 */ private boolean hasClickableAdCube = false; /* */ /* */ public boolean getHasClickableAdCube() { /* 352 */ return this.hasClickableAdCube; /* */ } /* */ /* */ public void setHasClickableAdCube(boolean b) { /* 356 */ this.hasClickableAdCube = b; /* */ } /* */ /* 359 */ private boolean adCubeFormatIsGif = false; /* */ /* */ public boolean getAdCubeFormatIsGif() { /* 362 */ return this.adCubeFormatIsGif; /* */ } /* */ /* */ public void setAdCubeFormatIsGif(boolean b) { /* 366 */ this.adCubeFormatIsGif = b; /* */ } /* */ /* 369 */ private String defaultAdCubeURL = IniFile.override().getIniString( /* 370 */ "defaultAdCubeURL", "http://www.worlds.com/"); /* */ /* */ public String getDefaultAdCubeURL() { /* 373 */ return this.defaultAdCubeURL; /* */ } /* */ /* */ public void setDefaultAdCubeURL(String s) { /* 377 */ this.defaultAdCubeURL = new String(s); /* */ } /* */ /* */ /* */ /* */ public boolean getEdited() /* */ { /* 384 */ return this.hasBeenEdited; /* */ } /* */ /* */ /* */ /* */ /* */ /* 391 */ private boolean hasBeenEdited = false; /* */ /* */ /* */ /* */ private static void worldListChanged() /* */ { /* 397 */ if (Gamma.getShaper() != null) { /* 398 */ Gamma.getShaper().worldListChange(); /* */ } /* */ } /* */ /* */ /* */ public void getChildren(DeepEnumeration d) /* */ { /* 405 */ d.addChildEnumeration(getRooms()); /* 406 */ if (this.eventHandlers != null) { /* 407 */ d.addChildVector(this.eventHandlers); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ public Room getRoom(String roomName) /* */ { /* 416 */ if (roomName.indexOf("UserHomeRoom") != -1) { /* 417 */ roomName = getDefaultRoomName(); /* */ } /* */ /* 420 */ return (Room)this.roomHash.get(roomName); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public String getDefaultRoomName() /* */ { /* 430 */ if (getRoom(this.defaultRoomName) == null) { /* 431 */ if (this.roomList.isEmpty()) { /* 432 */ this.defaultRoomName = ""; /* */ } else { /* 434 */ this.defaultRoomName = ((Room)this.roomList.elementAt(0)).getName(); /* */ } /* */ } /* 437 */ return this.defaultRoomName; /* */ } /* */ /* */ public void setDefaultRoomName(String name) { /* 441 */ this.defaultRoomName = name; /* */ } /* */ /* 444 */ private String defaultRoomName = ""; /* */ /* */ /* */ /* */ /* */ public void addRoom(Room room) /* */ { /* 451 */ String name = room.getName(); /* 452 */ int roomNum = 1; /* 453 */ while (getRoom(name) != null) /* 454 */ name = "Room" + roomNum++; /* 455 */ room.setName(name); /* 456 */ this.roomHash.put(name, room); /* 457 */ this.roomList.addElement(room); /* 458 */ add(room); /* */ /* 460 */ URL sourceURL = getSourceURL(); /* 461 */ if ((sourceURL != null) && (worldHash.containsKey(sourceURL))) /* */ { /* */ /* 464 */ room.register(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void renameRoom(String oldName, String newName, Room room) /* */ { /* 474 */ if (oldName != null) { /* 475 */ assert (this.roomHash.get(oldName) == room); /* 476 */ this.roomHash.remove(oldName); /* */ } else { /* 478 */ assert (!this.roomList.removeElement(room)); /* 479 */ this.roomList.addElement(room); /* */ } /* */ /* 482 */ assert (newName != null); /* 483 */ assert (room.getName().equals(newName)); /* 484 */ this.roomHash.put(newName, room); /* */ } /* */ /* */ /* */ /* */ public void removeRoom(Room room) /* */ { /* 491 */ this.roomHash.remove(this.roomHash.getKey(room)); /* 492 */ this.roomList.removeElement(room); /* */ } /* */ /* */ /* */ /* */ public Enumeration getRooms() /* */ { /* 499 */ return this.roomList.elements(); /* */ } /* */ /* */ /* */ /* */ public static Room findRoomByName(String name) /* */ { /* 506 */ Enumeration we = worldList.elements(); /* 507 */ Enumeration re; for (; we.hasMoreElements(); /* */ /* */ /* 510 */ re.hasMoreElements()) /* */ { /* 508 */ World w = (World)we.nextElement(); /* 509 */ re = w.getRooms(); /* 510 */ continue; /* 511 */ Room r = (Room)re.nextElement(); /* 512 */ if (r.toString().equals(name)) { /* 513 */ return r; /* */ } /* */ } /* 516 */ return null; /* */ } /* */ /* 519 */ protected Hashtable roomHash = new Hashtable(); /* 520 */ protected Vector roomList = new Vector(); /* */ /* */ Vector eventHandlers; /* */ /* */ public void invokeActions(String actLabel) /* */ { /* 526 */ Enumeration en = getDeepOwned(); /* 527 */ while (en.hasMoreElements()) { /* 528 */ Object obj = en.nextElement(); /* 529 */ if ((obj instanceof WObject)) { /* 530 */ ((WObject)obj).doAction(actLabel, null); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public boolean deliver(FrameEvent event) /* */ { /* 546 */ if (this.eventHandlers != null) { /* 547 */ if (Main.profile != 0) { /* 548 */ int i = this.eventHandlers.size(); /* 549 */ do { FrameHandler fh = (FrameHandler)this.eventHandlers.elementAt(i); /* 550 */ int start = Std.getRealTime(); /* 551 */ long startBytes = Runtime.getRuntime().freeMemory(); /* 552 */ event.retargetAndDeliver(fh, null); /* 553 */ int dur = Std.getRealTime() - start; /* 554 */ long used = Runtime.getRuntime().freeMemory() - startBytes; /* 555 */ if (dur > Main.profile) { /* 556 */ System.out.println("Took " + dur + "ms and " + used + /* 557 */ " bytes to call world eventHandler " + fh); /* */ } /* 548 */ i--; } while (i >= 0); /* */ /* */ /* */ /* */ /* */ } /* */ else /* */ { /* */ /* */ /* */ /* */ /* 560 */ int i = this.eventHandlers.size(); /* 561 */ do { event.retargetAndDeliver( /* 562 */ (FrameHandler)this.eventHandlers.elementAt(i), null);i--; /* 560 */ } while (i >= 0); /* */ } /* */ } /* */ /* 564 */ return true; /* */ } /* */ /* 567 */ private static boolean[] didTouch = new boolean[1]; /* */ /* */ /* */ private static int lastGeneratedFrameEvents; /* */ /* */ /* */ private int renderStamp; /* */ /* */ /* */ public static void generateFrameEvents(FrameEvent f) /* */ { /* 578 */ didTouch[0] = false; /* */ /* 580 */ int now = Std.getFastTime(); /* */ /* 582 */ int i = worldList.size(); /* 583 */ do { World w = (World)worldList.elementAt(i); /* 584 */ if (!w.discardIfOld(didTouch)) { /* 585 */ w.deliver(f); /* */ } /* 582 */ i--; } while (i >= 0); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 590 */ if (Pilot.getActiveWorld() != null) { /* 591 */ lastGeneratedFrameEvents = now; /* */ } /* */ } /* */ /* */ public Enumeration getHandlers() /* */ { /* 597 */ if (this.eventHandlers == null) { /* 598 */ return new Vector().elements(); /* */ } /* 600 */ return this.eventHandlers.elements(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public boolean hasHandler(SuperRoot h) /* */ { /* 609 */ return (this.eventHandlers != null) && (this.eventHandlers.indexOf(h) != -1); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public World addHandler(SuperRoot h) /* */ { /* 618 */ if (!(h instanceof FrameHandler)) /* */ { /* 620 */ Object[] arguments = { new String(h.getName()) }; /* 621 */ Console.println(MessageFormat.format( /* 622 */ Console.message("FrameHandler"), arguments)); /* 623 */ return this; /* */ } /* 625 */ if (this.eventHandlers == null) /* 626 */ this.eventHandlers = new Vector(); /* 627 */ this.eventHandlers.addElement(h); /* */ /* 629 */ add(h); /* */ /* 631 */ return this; /* */ } /* */ /* */ /* */ /* */ public void removeHandler(SuperRoot h) /* */ { /* 638 */ if (this.eventHandlers.contains(h)) { /* 639 */ h.detach(); /* */ /* 641 */ this.eventHandlers.removeElement(h); /* 642 */ if (this.eventHandlers.size() == 0) { /* 643 */ this.eventHandlers = null; /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public void incRef() /* */ { /* 654 */ this.renderStamp = Std.getFastTime(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 675 */ private int timeoutAge = 15000; /* 676 */ private int nextRoomCheck = 0; /* */ /* */ /* */ /* */ /* */ public void decRef() {} /* */ /* */ /* */ /* */ /* */ private void touchAdjacentRooms(boolean[] didTouch) /* */ { /* 688 */ if (didTouch[0] == 0) { /* 689 */ didTouch[0] = true; /* */ /* */ /* 692 */ Room r = Pilot.getActiveRoom(); /* 693 */ if (r != null) { /* 694 */ Vector portals = r.getOutgoingPortals(); /* 695 */ int i = portals.size(); /* 696 */ do { Room farr = ((Portal)portals.elementAt(i)).farSideRoom(); /* 697 */ if (farr != null) { /* 698 */ farr.noteRef(); /* */ } /* 695 */ i--; } while (i >= 0); /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ boolean discardIfOld(boolean[] didTouch) /* */ { /* 712 */ int now = Std.getFastTime(); /* 713 */ if (now < this.nextRoomCheck) { /* 714 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* 722 */ this.nextRoomCheck = (now + 5000 + (int)(3000.0D * Math.random())); /* */ /* 724 */ touchAdjacentRooms(didTouch); /* */ /* 726 */ int i = this.roomList.size(); /* 727 */ do { ((Room)this.roomList.elementAt(i)).discardIfOld();i--; /* 726 */ } while (i >= 0); /* */ /* */ /* 729 */ if (this.hasBeenEdited) { /* 730 */ return false; /* */ } /* 732 */ int age = now - this.renderStamp; /* 733 */ if ((age > this.timeoutAge) && (this.renderStamp < lastGeneratedFrameEvents)) /* */ { /* */ /* 736 */ if (age > this.timeoutAge) { /* 737 */ discard(); /* 738 */ return true; /* */ } /* */ } /* */ /* 742 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void discard() /* */ { /* 754 */ URL url = getSourceURL(); /* 755 */ synchronized (worldHash) { /* 756 */ worldHash.remove(url); /* 757 */ worldList.removeElement(this); /* */ } /* 759 */ worldListChanged(); /* */ /* 761 */ URLSelfLoader.unload(this); /* */ /* 763 */ if (this.eventHandlers != null) { /* 764 */ int i = this.eventHandlers.size(); /* 765 */ do { removeHandler((SuperRoot)this.eventHandlers.elementAt(i));i--; /* 764 */ } while (i >= 0); /* */ } /* 766 */ assert (this.eventHandlers == null); /* */ /* */ /* */ /* */ /* 771 */ discardRooms(); /* */ /* 773 */ if (this.console != null) /* 774 */ this.console.decRef(); /* 775 */ this.console = null; /* */ /* */ /* 778 */ System.gc(); /* 779 */ System.runFinalization(); /* */ } /* */ /* */ private void discardRooms() /* */ { /* 784 */ while (!this.roomList.isEmpty()) { /* 785 */ Room r = (Room)this.roomList.elementAt(0); /* 786 */ r.discard(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ protected void finalize() /* */ { /* 795 */ discardRooms(); /* 796 */ super.finalize(); /* */ } /* */ /* */ /* */ /* */ /* */ /* 803 */ private static Hashtable worldHash = new Hashtable(); /* 804 */ private static Vector worldList = new Vector(); /* */ /* */ /* */ /* */ /* */ /* */ /* 811 */ private boolean registerable = false; /* */ /* */ /* */ /* */ /* */ /* */ /* */ private void markInitialized() /* */ { /* 820 */ if (getSourceURL() != null) { /* 821 */ register(); /* */ } else { /* 823 */ this.registerable = true; /* */ } /* */ } /* */ /* */ /* */ /* */ private void register() /* */ { /* 831 */ URL url = getSourceURL(); /* 832 */ synchronized (worldHash) { /* 833 */ assert (!worldHash.containsKey(url)); /* 834 */ worldHash.put(url, this); /* 835 */ worldList.addElement(this); /* */ } /* 837 */ worldListChanged(); /* 838 */ this.registerable = false; /* */ /* */ /* */ /* 842 */ int i = this.roomList.size(); /* 843 */ do { ((Room)this.roomList.elementAt(i)).register();i--; /* 842 */ } while (i >= 0); /* */ } /* */ /* */ /* */ /* */ /* */ public void setSourceURL(URL url) /* */ { /* 850 */ super.setSourceURL(url); /* */ /* 852 */ if (this.registerable) { /* 853 */ register(); /* */ } /* */ } /* */ /* */ public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException /* */ { /* 859 */ Object ret = null; /* */ /* 861 */ switch (index - offset) { /* */ case 0: /* 863 */ if (mode == 0) { /* 864 */ ret = StringPropertyEditor.make(new Property(this, index, /* 865 */ "Default Room Name")); /* 866 */ } else if (mode == 1) { /* 867 */ ret = getDefaultRoomName(); /* 868 */ } else if (mode == 2) { /* 869 */ String name = (String)value; /* 870 */ if (getRoom(name) == null) { /* 871 */ Console.println(name + Console.message("No-room-named")); /* */ } else /* 873 */ setDefaultRoomName(name); /* */ } /* 875 */ break; /* */ /* */ case 1: /* 878 */ if (mode == 0) { /* 879 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 880 */ "Multiuser"), "No", "Yes"); /* 881 */ } else if (mode == 1) { /* 882 */ ret = new Boolean(getMultiuser()); /* 883 */ } else if (mode == 2) /* 884 */ setMultiuser(((Boolean)value).booleanValue()); /* 885 */ break; /* */ case 2: /* 887 */ if (mode == 0) { /* 888 */ ret = new Property(this, index, "Console"); /* 889 */ } else if (mode == 1) /* 890 */ ret = this.console; /* 891 */ break; /* */ /* */ case 3: /* 894 */ if (mode == 0) { /* 895 */ ret = PropAdder.make(new VectorProperty(this, index, "Rooms")); /* 896 */ } else if (mode == 1) { /* 897 */ ret = VectorProperty.toVector(this.roomHash); /* 898 */ } else if (mode == 4) { /* 899 */ ((Room)value).detach(); /* 900 */ } else if (mode == 3) { /* 901 */ if (!(value instanceof Room)) /* 902 */ throw new Error("Can only add Rooms to a World."); /* 903 */ addRoom((Room)value); /* 904 */ } else if ((mode == 5) && ((value instanceof Room))) { /* 905 */ ret = value; } /* 906 */ break; /* */ case 4: /* 908 */ if (mode == 0) { /* 909 */ ret = FloatPropertyEditor.make(new Property(this, index, /* 910 */ "Time-out Age (seconds)")); /* 911 */ } else if (mode == 1) { /* 912 */ ret = new Float(this.timeoutAge / 1000.0F); /* 913 */ } else if (mode == 2) { /* 914 */ this.timeoutAge = Math.round(((Float)value).floatValue() * 1000.0F); /* */ } /* 916 */ break; /* */ /* */ case 5: /* 919 */ if (mode == 0) { /* 920 */ ret = PropAdder.make(new VectorProperty(this, index, /* 921 */ "Running Actions (delete to stop)")); /* 922 */ } else if (mode == 1) { /* 923 */ if (this.eventHandlers != null) /* 924 */ ret = this.eventHandlers.clone(); /* 925 */ } else if (mode == 4) { /* 926 */ removeHandler((SuperRoot)value); /* */ } /* 928 */ break; /* */ case 6: /* 930 */ if (mode == 0) { /* 931 */ ret = URLPropertyEditor.make(new Property(this, index, /* 932 */ "Server URL"), "console"); /* 933 */ } else if (mode == 1) { /* 934 */ ret = this.desiredWorldServerURL; /* 935 */ if (ret != null) { /* 936 */ String u = this.desiredWorldServerURL.unalias(); /* 937 */ if (u.startsWith("worldserver://")) /* 938 */ ret = URL.make(u + "default.console"); /* */ } /* 940 */ } else if (mode == 2) { /* 941 */ URL url = (URL)value; /* 942 */ if (url != null) { /* 943 */ String u = url.unalias(); /* 944 */ int len = u.length(); /* 945 */ if (u.startsWith("worldserver://")) /* */ { /* 947 */ if ((!url.endsWith("/default.console")) || (len < 31)) { /* 948 */ Console.println( /* 949 */ Console.message("server-URL") + "default.console"); /* */ } /* */ else /* */ { /* 953 */ u = u.substring(14, len - 16); } /* */ } else /* 955 */ url = Console.makeServerURL(u); /* */ } else { /* 957 */ setWorldServerURL(url); /* */ } } /* 959 */ break; /* */ case 7: /* 961 */ if (mode == 0) { /* 962 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 963 */ "Courtesy VIP"), "No", "Yes"); /* 964 */ } else if (mode == 1) { /* 965 */ ret = new Boolean(getCourtesyVIP()); /* 966 */ } else if (mode == 2) /* 967 */ setCourtesyVIP(((Boolean)value).booleanValue()); /* 968 */ break; /* */ /* */ case 8: /* 971 */ if (mode == 0) { /* 972 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 973 */ "Force Human"), "No", "Yes"); /* 974 */ } else if (mode == 1) { /* 975 */ ret = new Boolean(getForceHuman()); /* 976 */ } else if (mode == 2) /* 977 */ setForceHuman(((Boolean)value).booleanValue()); /* 978 */ break; /* */ /* */ case 9: /* 981 */ if (mode == 0) { /* 982 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 983 */ "Has Ad Banner"), "No", "Yes"); /* 984 */ } else if (mode == 1) { /* 985 */ ret = new Boolean(getHasAdBanner()); /* 986 */ } else if (mode == 2) { /* 987 */ setHasAdBanner(((Boolean)value).booleanValue()); /* 988 */ setupAdBanner(); /* */ } /* 990 */ break; /* */ case 10: /* 992 */ if (mode == 0) { /* 993 */ ret = IntegerPropertyEditor.make(new Property(this, index, /* 994 */ "Banner Width")); /* 995 */ } else if (mode == 1) { /* 996 */ ret = new Integer(getBannerWidth()); /* 997 */ } else if (mode == 2) { /* 998 */ setBannerWidth(((Integer)value).intValue()); /* 999 */ setupAdBanner(); /* */ } /* 1001 */ break; /* */ case 11: /* 1003 */ if (mode == 0) { /* 1004 */ ret = IntegerPropertyEditor.make(new Property(this, index, /* 1005 */ "Banner Height")); /* 1006 */ } else if (mode == 1) { /* 1007 */ ret = new Integer(getBannerHeight()); /* 1008 */ } else if (mode == 2) { /* 1009 */ setBannerHeight(((Integer)value).intValue()); /* 1010 */ setupAdBanner(); /* */ } /* 1012 */ break; /* */ case 12: /* 1014 */ if (mode == 0) { /* 1015 */ ret = StringPropertyEditor.make(new Property(this, index, /* 1016 */ "Ad Banner URL")); /* 1017 */ } else if (mode == 1) { /* 1018 */ ret = getBannerURL(); /* 1019 */ } else if (mode == 2) { /* 1020 */ String name = (String)value; /* 1021 */ setBannerURL(name); /* */ } /* 1023 */ break; /* */ case 13: /* 1025 */ if (mode == 0) { /* 1026 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 1027 */ "Has Clickable Ad Cube"), "No", "Yes"); /* 1028 */ } else if (mode == 1) { /* 1029 */ ret = new Boolean(getHasClickableAdCube()); /* 1030 */ } else if (mode == 2) { /* 1031 */ setHasClickableAdCube(((Boolean)value).booleanValue()); /* */ } /* 1033 */ break; /* */ /* */ case 14: /* 1036 */ if (mode == 0) { /* 1037 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 1038 */ "Ad Cube image format"), "CMP", "GIF"); /* 1039 */ } else if (mode == 1) { /* 1040 */ ret = new Boolean(getAdCubeFormatIsGif()); /* 1041 */ } else if (mode == 2) { /* 1042 */ setAdCubeFormatIsGif(((Boolean)value).booleanValue()); /* */ } /* 1044 */ break; /* */ /* */ case 15: /* 1047 */ if (mode == 0) { /* 1048 */ ret = StringPropertyEditor.make(new Property(this, index, /* 1049 */ "Ad cube base URL")); /* 1050 */ } else if (mode == 1) { /* 1051 */ ret = getAdCubeBaseURL(); /* 1052 */ } else if (mode == 2) { /* 1053 */ String name = (String)value; /* 1054 */ setAdCubeBaseURL(name); /* */ } /* 1056 */ break; /* */ /* */ case 16: /* 1059 */ if (mode == 0) { /* 1060 */ ret = StringPropertyEditor.make(new Property(this, index, /* 1061 */ "Ad cube default click URL")); /* 1062 */ } else if (mode == 1) { /* 1063 */ ret = getDefaultAdCubeURL(); /* 1064 */ } else if (mode == 2) { /* 1065 */ String name = (String)value; /* 1066 */ setDefaultAdCubeURL(name); /* */ } /* 1068 */ break; /* */ /* */ default: /* 1071 */ ret = super.properties(index, offset + 17, mode, value); /* */ } /* 1073 */ return ret; /* */ } /* */ /* */ /* 1077 */ private static Object classCookie = new Object(); /* */ private static final int INIT = 0; /* */ /* 1080 */ public void saveState(Saver s) throws IOException { s.saveVersion(13, classCookie); /* 1081 */ super.saveState(s); /* 1082 */ s.saveString(this.defaultRoomName); /* 1083 */ URL.save(s, this.desiredWorldServerURL); /* 1084 */ s.saveInt(this.timeoutAge); /* 1085 */ s.saveBoolean(getMultiuser()); /* 1086 */ s.saveBoolean(getCourtesyVIP()); /* 1087 */ s.saveBoolean(getForceHuman()); /* 1088 */ s.saveBoolean(getHasAdBanner()); /* 1089 */ s.saveInt(getBannerWidth()); /* 1090 */ s.saveInt(getBannerHeight()); /* 1091 */ s.saveString(getBannerURL()); /* 1092 */ s.saveBoolean(getHasClickableAdCube()); /* 1093 */ s.saveBoolean(getAdCubeFormatIsGif()); /* 1094 */ s.saveString(getAdCubeBaseURL()); /* 1095 */ s.saveString(getDefaultAdCubeURL()); /* */ /* 1097 */ s.save(this.roomHash); /* */ } /* */ /* */ /* */ /* */ private static final int RESTOREROOMS = 1; /* */ /* */ /* */ private static final int ADDROOMS = 2; /* */ /* */ /* */ public void restoreState(Restorer r) /* */ throws IOException, TooNewException /* */ { /* 1111 */ URLSelfLoader.immediateLoad(this, r); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private void restoreOldURL(Restorer r) /* */ throws IOException /* */ { /* 1124 */ String s = r.restoreString(); /* */ URL url; /* */ URL url; /* 1127 */ if ((s == null) || (s.equals("UNSHARED"))) { /* 1128 */ url = null; } else { URL url; /* 1129 */ if (!s.endsWith(".console")) { /* 1130 */ url = Console.makeServerURL(s); /* */ } else /* 1132 */ url = URL.restore(r, s, null); /* */ } /* 1134 */ if (url == null) { /* 1135 */ url = defaultServerURL; /* */ } else { /* 1137 */ setMultiuser(true); /* */ } /* 1139 */ setWorldServerURL(url); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public int restorePreRooms(Restorer r) /* */ throws IOException, TooNewException /* */ { /* 1150 */ int version = r.restoreVersion(classCookie); /* 1151 */ switch (version) { /* */ case 0: /* 1153 */ r.setOldFlag(); /* 1154 */ setName(r.restoreString()); /* 1155 */ this.defaultRoomName = r.restoreString(); /* 1156 */ restoreOldURL(r); /* 1157 */ this.roomHash = ((Hashtable)r.restore(false)); /* */ /* 1159 */ break; /* */ case 1: /* */ case 3: /* 1162 */ r.setOldFlag(); /* 1163 */ super.restoreState(r); /* 1164 */ this.defaultRoomName = r.restoreString(); /* 1165 */ restoreOldURL(r); /* 1166 */ this.roomHash = ((Hashtable)r.restore(false)); /* 1167 */ break; /* */ case 2: /* 1169 */ r.setOldFlag(); /* 1170 */ super.restoreState(r); /* 1171 */ this.defaultRoomName = r.restoreString(); /* 1172 */ restoreOldURL(r); /* 1173 */ r.restoreString(); /* 1174 */ this.roomHash = ((Hashtable)r.restore(false)); /* 1175 */ break; /* */ case 4: /* 1177 */ super.restoreState(r); /* 1178 */ this.defaultRoomName = r.restoreString(); /* 1179 */ restoreOldURL(r); /* 1180 */ this.roomHash = ((Hashtable)r.restore(false)); /* 1181 */ break; /* */ case 5: /* 1183 */ super.restoreState(r); /* 1184 */ this.defaultRoomName = r.restoreString(); /* 1185 */ restoreOldURL(r); /* 1186 */ this.timeoutAge = r.restoreInt(); /* 1187 */ this.roomHash = ((Hashtable)r.restore(false)); /* 1188 */ break; /* */ case 6: /* 1190 */ super.restoreState(r); /* 1191 */ this.defaultRoomName = r.restoreString(); /* 1192 */ restoreOldURL(r); /* 1193 */ this.timeoutAge = r.restoreInt(); /* 1194 */ r.restoreBoolean(); /* 1195 */ this.roomHash = ((Hashtable)r.restore(false)); /* 1196 */ break; /* */ case 7: /* 1198 */ super.restoreState(r); /* 1199 */ this.defaultRoomName = r.restoreString(); /* */ /* 1201 */ URL url = URL.restore(r); /* 1202 */ if (url == null) { /* 1203 */ url = defaultServerURL; /* */ } else { /* 1205 */ setMultiuser(true); /* */ } /* 1207 */ setWorldServerURL(url); /* */ /* 1209 */ this.timeoutAge = r.restoreInt(); /* 1210 */ r.restoreBoolean(); /* 1211 */ this.roomHash = ((Hashtable)r.restore(false)); /* 1212 */ break; /* */ case 8: /* */ case 9: /* */ case 10: /* */ case 11: /* */ case 12: /* */ case 13: /* 1219 */ super.restoreState(r); /* 1220 */ this.defaultRoomName = r.restoreString(); /* 1221 */ setWorldServerURL(URL.restore(r)); /* 1222 */ this.timeoutAge = r.restoreInt(); /* 1223 */ setMultiuser(r.restoreBoolean()); /* 1224 */ if (version > 9) /* 1225 */ setCourtesyVIP(r.restoreBoolean()); /* 1226 */ if (version > 10) /* 1227 */ setForceHuman(r.restoreBoolean()); /* 1228 */ if (version > 11) { /* 1229 */ setHasAdBanner(r.restoreBoolean()); /* 1230 */ setBannerWidth(r.restoreInt()); /* 1231 */ setBannerHeight(r.restoreInt()); /* 1232 */ setBannerURL(r.restoreString()); /* */ } /* 1234 */ if (version > 12) { /* 1235 */ setHasClickableAdCube(r.restoreBoolean()); /* 1236 */ setAdCubeFormatIsGif(r.restoreBoolean()); /* 1237 */ setAdCubeBaseURL(r.restoreString()); /* 1238 */ setDefaultAdCubeURL(r.restoreString()); /* */ } /* 1240 */ this.roomHash = ((Hashtable)r.restore(false)); /* 1241 */ break; /* */ default: /* 1243 */ throw new TooNewException(); /* */ } /* */ /* 1246 */ for (Enumeration e = this.roomHash.elements(); e.hasMoreElements();) { /* 1247 */ this.roomList.addElement(e.nextElement()); /* */ } /* 1249 */ if ((version < 9) && (this.timeoutAge == 60000)) { /* 1250 */ this.timeoutAge = 15000; /* */ } /* 1252 */ return version; /* */ } /* */ /* */ /* */ /* */ /* */ public Object clone() /* */ { /* 1260 */ World newWorld = (World)super.clone(); /* */ /* */ /* 1263 */ int worldNum = 1; /* */ String newname; /* */ URL key; /* */ do { /* 1267 */ newname = "World" + worldNum++; /* 1268 */ key = URL.make("session:" + newname + ".world"); /* 1269 */ } while (worldHash.containsKey(key)); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 1277 */ newWorld.setName(newname); /* 1278 */ newWorld.setSourceURL(key); /* */ /* 1280 */ return newWorld; /* */ } /* */ /* */ /* */ /* */ private static final int LOADCONSOLE = 3; /* */ /* */ /* */ private static final int DONE = -1; /* */ /* */ /* */ private Enumeration tmpenum; /* */ /* */ /* */ public int incRestore(int state, Restorer r, URLSelfLoader p) /* */ throws Exception /* */ { /* 1297 */ switch (state) { /* */ case 0: /* 1299 */ p.itemp2 = restorePreRooms(r); /* 1300 */ p.itemp1 = this.roomHash.restoreCount(r); /* */ /* */ case 1: /* 1303 */ if (--p.itemp1 >= 0) { /* 1304 */ this.roomHash.restoreEntry(r); /* 1305 */ return 1; /* */ } /* */ /* */ /* 1309 */ if (p.itemp2 == 4) { /* 1310 */ this.timeoutAge = r.restoreInt(); /* */ /* */ /* 1313 */ if ((this.timeoutAge == 900000) || (this.timeoutAge == 60000)) { /* 1314 */ this.timeoutAge = 15000; /* */ } /* */ } /* 1317 */ if (r.version() < 3) { /* 1318 */ return -1; /* */ } /* */ case 2: case 3: /* 1321 */ return finishRestore(state, /* 1322 */ (r.version() != Saver.version()) || (r.oldFlag()), p.getURL()); /* */ } /* */ /* 1325 */ if (!$assertionsDisabled) throw new AssertionError(); /* 1326 */ return -1; /* */ } /* */ /* */ /* */ /* */ public int finishRestore(int state, boolean oldFlag, URL url) /* */ throws Exception /* */ { /* 1334 */ switch (state) /* */ { /* */ /* */ /* */ case 0: /* */ case 1: /* 1340 */ this.tmpenum = this.roomHash.elements(); /* */ /* 1342 */ this.roomHash = new Hashtable(); /* */ /* */ case 2: /* 1345 */ if (this.tmpenum.hasMoreElements()) { /* 1346 */ Room rm = (Room)this.tmpenum.nextElement(); /* 1347 */ addRoom(rm); /* 1348 */ return 2; /* */ } /* 1350 */ this.tmpenum = null; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ case 3: /* 1359 */ if ((this.console == null) && (this.loadErr == null)) { /* 1360 */ return 3; /* */ } /* 1362 */ if (this.loadErr != null) { /* 1363 */ throw new IOException(this.loadErr); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 1374 */ markInitialized(); /* */ /* 1376 */ return -1; } /* */ /* 1378 */ if (!$assertionsDisabled) throw new AssertionError(); /* 1379 */ return -1; /* */ } /* */ /* */ public void postRestore(int version) { /* 1383 */ super.postRestore(version); /* 1384 */ if (version > 2) /* 1385 */ return; /* 1386 */ int state = 0; /* */ try { /* 1388 */ while ((state = finishRestore(state, true, /* 1389 */ URL.make("error:This file"))) != -1) {} /* */ } /* */ catch (Exception ex) /* */ { /* 1393 */ ex.printStackTrace(System.out); /* 1394 */ if (!$assertionsDisabled) { throw new AssertionError(); /* */ } /* */ } /* */ } /* */ /* */ /* 1400 */ protected Console console = null; /* */ /* */ String loadErr; /* */ /* */ /* */ public Console getConsole() /* */ { /* 1407 */ return this.console; /* */ } /* */ /* */ /* */ /* */ /* */ public void loadedURLSelf(URLSelf o, URL url, String err) /* */ { /* 1415 */ if ((err != null) || (!(o instanceof Console))) { /* 1416 */ if (err == null) { /* 1417 */ Object[] arguments = { new String(url) }; /* 1418 */ Console.println(MessageFormat.format( /* 1419 */ Console.message("no-world"), arguments)); /* 1420 */ o.decRef(); /* */ } /* */ /* */ /* 1424 */ Console.println(Console.message("cant-load") + err); /* 1425 */ Console.load(null, this); /* */ /* 1427 */ return; /* */ } /* */ /* */ /* 1431 */ Console oldConsole = this.console; /* */ /* 1433 */ this.console = ((Console)o); /* */ /* 1435 */ if (oldConsole != null) /* */ { /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 1444 */ Galaxy oldGalaxy = oldConsole.getGalaxy(); /* 1445 */ Galaxy galaxy = this.console.getGalaxy(); /* */ /* 1447 */ assert (oldGalaxy != null); /* 1448 */ assert (galaxy != null); /* 1449 */ if (oldGalaxy != galaxy) { /* 1450 */ oldGalaxy.forceObjectRereg(); /* */ } /* */ /* 1453 */ oldConsole.decRef(); /* */ } /* */ /* 1456 */ this.worldServerURL = url; /* */ /* */ /* 1459 */ if ((Pilot.getActive() != null) && (Pilot.getActive().getWorld() == this)) { /* 1460 */ Pilot.changeActiveRoom(Pilot.getActive().getRoom()); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* 1468 */ static URL defaultServerURL = URL.make("worldserver://www.3dcd.com:6650/"); /* */ private URL worldServerURL; /* 1470 */ private URL desiredWorldServerURL = defaultServerURL; /* */ /* */ /* */ private boolean isCourtesyVIP; /* */ /* */ /* */ /* */ public boolean getCourtesyVIP() /* */ { /* 1479 */ return this.isCourtesyVIP; /* */ } /* */ /* */ private void setCourtesyVIP(boolean b) { /* 1483 */ this.isCourtesyVIP = b; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* 1491 */ private boolean isForceHuman = false; /* */ /* */ public boolean getForceHuman() { /* 1494 */ return this.isForceHuman; /* */ } /* */ /* */ private void setForceHuman(boolean b) { /* 1498 */ this.isForceHuman = b; /* */ } /* */ /* */ /* */ /* */ /* */ /* 1505 */ private boolean hasAdBanner = false; /* 1506 */ private int adBannerWidth = 474; /* 1507 */ private int adBannerHeight = 65; /* 1508 */ private String adBannerURL = "$SCRIPTSERVERgetad.pl?s=$SERIALNUM"; /* */ /* */ public boolean getHasAdBanner() { /* 1511 */ return this.hasAdBanner; /* */ } /* */ /* */ public void setHasAdBanner(boolean b) { /* 1515 */ this.hasAdBanner = b; /* */ } /* */ /* */ public int getBannerWidth() { /* 1519 */ return this.adBannerWidth; /* */ } /* */ /* */ public void setBannerWidth(int i) { /* 1523 */ this.adBannerWidth = i; /* */ } /* */ /* */ public int getBannerHeight() { /* 1527 */ return this.adBannerHeight; /* */ } /* */ /* */ public void setBannerHeight(int i) { /* 1531 */ this.adBannerHeight = i; /* */ } /* */ /* */ public String getBannerURL() { /* 1535 */ return this.adBannerURL; /* */ } /* */ /* */ public void setBannerURL(String s) { /* 1539 */ this.adBannerURL = s; /* */ } /* */ /* 1542 */ private static AdBanner theAdBanner = null; /* */ private boolean isMultiuser; /* */ /* 1545 */ public void setupAdBanner() { if (theAdBanner != null) { /* 1546 */ theAdBanner.detach(); /* 1547 */ theAdBanner = null; /* */ } /* */ /* 1550 */ if (this.hasAdBanner) { /* 1551 */ theAdBanner = new AdBanner(this.adBannerWidth, this.adBannerHeight, /* 1552 */ this.adBannerURL); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ private boolean getMultiuser() /* */ { /* 1563 */ return this.isMultiuser; /* */ } /* */ /* */ private void setMultiuser(boolean b) { /* 1567 */ this.isMultiuser = b; /* 1568 */ setWorldServerURL(this.desiredWorldServerURL); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public World setWorldServerURL(URL s) /* */ { /* 1582 */ this.desiredWorldServerURL = s; /* */ /* */ /* 1585 */ String i = s.getInternal(); /* 1586 */ if ((i.startsWith("worldserver://www.3dcd.com")) && /* 1587 */ (NetUpdate.overrideWorldServer != null)) { /* 1588 */ i = i.substring(26); /* 1589 */ if ((i.startsWith(":")) && /* 1590 */ (NetUpdate.overrideWorldServer.indexOf(':', 13) >= 0)) /* */ { /* 1592 */ for (int j = 1; /* 1593 */ j < i.length(); j++) /* 1594 */ if (!Character.isDigit(i.charAt(j))) /* */ break; /* 1596 */ i = i.substring(j); /* */ } /* 1598 */ s = URL.make(NetUpdate.overrideWorldServer + i); /* */ } /* */ /* 1601 */ this.loadErr = null; /* 1602 */ Console.load(this.isMultiuser ? s : null, this); /* */ /* 1604 */ return this; /* */ } /* */ /* */ public static Enumeration getWorlds() { /* 1608 */ return worldList.elements(); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\World.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */