summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/DPState.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/DPState.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/DPState.java')
-rw-r--r--NET/worlds/scape/DPState.java118
1 files changed, 118 insertions, 0 deletions
diff --git a/NET/worlds/scape/DPState.java b/NET/worlds/scape/DPState.java
new file mode 100644
index 0000000..f4502eb
--- /dev/null
+++ b/NET/worlds/scape/DPState.java
@@ -0,0 +1,118 @@
+package NET.worlds.scape;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+public class DPState extends SuperRoot {
+ public static final int INFINITY = 60000;
+ protected Vector connections = new Vector();
+ protected int currentDist = 60000;
+ protected long currentTime = 0L;
+ private static Object classCookie = new Object();
+
+ public DPState(int dist, DPAction conn) {
+ this.currentDist = dist;
+ this.currentTime = 0L;
+ this.addConnection(conn);
+ }
+
+ public DPState() {
+ }
+
+ public void setDist(int d, int t) {
+ if (this.currentTime <= t) {
+ if (this.currentDist > d || this.currentTime != t) {
+ this.currentDist = d;
+ this.currentTime = t;
+ Enumeration e = this.connections.elements();
+
+ while (e.hasMoreElements()) {
+ ((DPAction)e.nextElement()).handleDist(d, t);
+ }
+ }
+ }
+ }
+
+ public int getDist() {
+ return this.currentDist;
+ }
+
+ public Enumeration getConnections() {
+ return this.connections.elements();
+ }
+
+ public Enumeration getPortals() {
+ Vector v = new Vector(this.connections.size());
+ Enumeration e = this.connections.elements();
+
+ while (e.hasMoreElements()) {
+ v.addElement(((DPAction)e.nextElement()).getOwner());
+ }
+
+ return v.elements();
+ }
+
+ public void addConnection(DPAction conn) {
+ if (!this.connections.contains(conn)) {
+ this.connections.addElement(conn);
+ }
+ }
+
+ public void dropConnection(DPAction conn) {
+ this.connections.removeElement(conn);
+ }
+
+ @Override
+ public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
+ Object ret = null;
+ switch (index - offset) {
+ case 0:
+ if (mode == 0) {
+ ret = IntegerPropertyEditor.make(new Property(this, index, "Current Distance"));
+ } else if (mode == 1) {
+ ret = new Integer(this.currentDist);
+ } else if (mode == 2) {
+ this.currentDist = (Integer)value;
+ }
+ break;
+ case 1:
+ if (mode == 0) {
+ ret = new VectorProperty(this, index, "Connections");
+ } else if (mode == 1) {
+ ret = this.connections.clone();
+ }
+ break;
+ default:
+ ret = super.properties(index, offset + 2, mode, value);
+ }
+
+ return ret;
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(0, classCookie);
+ super.saveState(s);
+ s.saveVector(this.connections);
+ s.saveInt(this.currentDist);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 0:
+ super.restoreState(r);
+ this.connections = r.restoreVector();
+ this.currentDist = r.restoreInt();
+ return;
+ default:
+ throw new TooNewException();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.getName();
+ }
+}