summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/HoloDrone.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/HoloDrone.java
downloadarchived-worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
archived-worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/HoloDrone.java')
-rw-r--r--NET/worlds/scape/HoloDrone.java261
1 files changed, 261 insertions, 0 deletions
diff --git a/NET/worlds/scape/HoloDrone.java b/NET/worlds/scape/HoloDrone.java
new file mode 100644
index 0000000..5dc17f8
--- /dev/null
+++ b/NET/worlds/scape/HoloDrone.java
@@ -0,0 +1,261 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.Console;
+import NET.worlds.console.Main;
+import NET.worlds.core.IniFile;
+import NET.worlds.core.ServerTableManager;
+import NET.worlds.network.ObjID;
+import NET.worlds.network.URL;
+import NET.worlds.network.WorldServer;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+public class HoloDrone extends Drone implements HoloCallback {
+ private WObject _avatar;
+ private WObject _realAvatar = null;
+ private boolean _isConstructing = false;
+ private Hologram _proxyHCnewImage = null;
+ private boolean _proxyHCok = false;
+ private static int _debugLevel = IniFile.gamma().getIniInt("dronedebug", 0);
+ private boolean permitAnyAvatar = IniFile.gamma().getIniInt("permitAnyAvatar", 0) != 0;
+ private static String[] permittedList;
+ private static String[] humanList;
+ private static Hashtable permittedHash;
+ private static Hashtable humanHash;
+ private static Object classCookie;
+
+ static {
+ if (_debugLevel > 0) {
+ System.out.println("DRONE DEBUGGING LEVEL = " + _debugLevel);
+ }
+
+ permittedList = ServerTableManager.instance().getTable("permittedHoloList");
+ humanList = ServerTableManager.instance().getTable("humanHoloList");
+ permittedHash = new Hashtable();
+ humanHash = new Hashtable();
+
+ for (int i = 0; i < permittedList.length; i += 2) {
+ if (permittedList[i + 1] != null) {
+ permittedHash.put(permittedList[i], permittedList[i + 1]);
+ } else {
+ permittedHash.put(permittedList[i], permittedList);
+ }
+ }
+
+ for (int ix = 0; ix < humanList.length; ix++) {
+ humanHash.put(humanList[ix], humanList[ix]);
+ }
+
+ classCookie = new Object();
+ }
+
+ public HoloDrone() {
+ }
+
+ public HoloDrone(ObjID objID, WorldServer serv) {
+ super(objID, serv);
+
+ assert Main.isMainThread();
+
+ if (this._proxyHCnewImage != null) {
+ this.holoCallback(this._proxyHCnewImage, this._proxyHCok);
+ this._proxyHCnewImage = null;
+ }
+ }
+
+ public static String[] getPermittedList() {
+ String[] result = new String[permittedList.length / 2];
+
+ for (int i = 0; i < result.length; i++) {
+ result[i] = permittedList[2 * i];
+ }
+
+ return result;
+ }
+
+ static URL permission(URL url) {
+ String name = url.getAbsolute().toLowerCase();
+ if (name.startsWith("avatar:") && name.endsWith(".mov")) {
+ name = name.substring(7, name.length() - 4);
+ Object newName = permittedHash.get(name);
+ if (newName == null) {
+ return null;
+ } else {
+ return newName instanceof String ? URL.make((String)newName) : url;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public static URL getHuman(URL url) {
+ if (!url.endsWith(".mov")) {
+ return PosableShape.getHuman(url);
+ } else if (permission(url) == null) {
+ return URL.make("avatar:holden.mov");
+ } else {
+ String s = url.getAbsolute().toLowerCase();
+ int len = s.length();
+
+ for (int i = 7; i < len; i++) {
+ if ("0123456789.".indexOf(s.charAt(i)) >= 0) {
+ if (humanHash.get(s.substring(7, i)) != null) {
+ return url;
+ }
+
+ return URL.make(IniFile.override().getIniString("defaultHumanAv", "avatar:holden.mov"));
+ }
+ }
+
+ return url;
+ }
+ }
+
+ @Override
+ public Drone setAvatarNow(URL url) {
+ if (!this.shouldBeMuted() && url.endsWith(".mov")) {
+ if (this.shouldBeForcedHuman()) {
+ url = getHuman(url);
+ }
+
+ url = PosableShape.getPermitted(url, this.getWorld());
+ if (url.equals(this.getSourceURL())) {
+ return this;
+ } else {
+ this.setSourceURL(url);
+ URL replacementURL = permission(url);
+ if (replacementURL != null) {
+ url = replacementURL;
+ } else if (!this.permitAnyAvatar) {
+ url = Console.getDefaultURL();
+ }
+
+ this._realAvatar = this.makeAvatar(url);
+ if (this._proxyHCnewImage != null) {
+ if ((_debugLevel & 1) > 0) {
+ System.out.println("Holo.stAvNow(" + url + "): doing proxy");
+ }
+
+ this.holoCallback(this._proxyHCnewImage, this._proxyHCok);
+ this._proxyHCnewImage = null;
+ }
+
+ return this;
+ }
+ } else {
+ return super.setAvatarNow(url);
+ }
+ }
+
+ public WObject makeAvatar(URL url) {
+ if ((_debugLevel & 1) > 0) {
+ System.out.println("HoloDrone.makeAvatar(" + url + ")");
+ }
+
+ this._isConstructing = true;
+ WObject bgAvatar = new Hologram(url, this);
+ this._isConstructing = false;
+ bgAvatar.setVisible(true);
+ bgAvatar.setBumpable(false);
+ return bgAvatar;
+ }
+
+ @Override
+ public void holoCallback(Hologram newImage, boolean ok) {
+ if ((_debugLevel & 1) > 0) {
+ System.out.println("HoloDrone.holoCallback(" + newImage + "," + ok + ")");
+ }
+
+ if (this._isConstructing) {
+ assert this._proxyHCnewImage == null;
+
+ this._proxyHCnewImage = newImage;
+ this._proxyHCok = ok;
+ if ((_debugLevel & 1) > 0) {
+ System.out.println("holoCallback: requesting proxy");
+ }
+ } else if (this._realAvatar == this._avatar) {
+ if ((_debugLevel & 1) > 0) {
+ System.out.println("holoCb: real avatar already loaded");
+ }
+ } else if (!ok) {
+ if (newImage == this._realAvatar) {
+ this._realAvatar = null;
+ }
+
+ if ((_debugLevel & 1) > 0) {
+ System.out.println("holoCb: not ok");
+ }
+ } else {
+ if ((_debugLevel & 1) > 0) {
+ System.out.println("holoCb: swapping avatars");
+ }
+
+ if (this._avatar != null) {
+ this._avatar.detach();
+ }
+
+ float avatarW = newImage.getW();
+ float avatarH = newImage.getH();
+ float factor;
+ if (avatarH < avatarW) {
+ factor = (float)Math.sqrt(25600.0F / (avatarW * avatarH));
+ } else {
+ factor = 160.0F / avatarH;
+ }
+
+ avatarH *= factor;
+ avatarW *= factor;
+ float heightAdj = 0.0F;
+ if (newImage == this._avatar) {
+ heightAdj = -this._avatar.getZ();
+ }
+
+ this._avatar = (WObject)newImage.scale(factor).raise(avatarH / 2.0F + heightAdj);
+ this.add(this._avatar);
+ this.avatarHeightChangedTo(avatarH);
+ }
+ }
+
+ @Override
+ public float getMinXYExtent() {
+ return this._avatar == null ? 0.0F : this._avatar.getMinXYExtent();
+ }
+
+ @Override
+ public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
+ Object ret = null;
+ int var10000 = index - offset;
+ return super.properties(index, offset + 0, mode, value);
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(0, classCookie);
+ super.saveState(s);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 0:
+ super.restoreState(r);
+ Enumeration e = this.getContents();
+
+ while (e.hasMoreElements()) {
+ WObject w = (WObject)e.nextElement();
+ if (w instanceof Hologram) {
+ Hologram h = (Hologram)w;
+ if (h.getMovieName() != null) {
+ this._avatar = h;
+ }
+ }
+ }
+
+ return;
+ default:
+ throw new TooNewException();
+ }
+ }
+}