aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/qcommon/netadr_t.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jake2/qcommon/netadr_t.java')
-rw-r--r--src/jake2/qcommon/netadr_t.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/jake2/qcommon/netadr_t.java b/src/jake2/qcommon/netadr_t.java
index 72473d7..40f27d5 100644
--- a/src/jake2/qcommon/netadr_t.java
+++ b/src/jake2/qcommon/netadr_t.java
@@ -19,10 +19,11 @@
*/
// Created on 27.11.2003 by RST.
-// $Id: netadr_t.java,v 1.4 2004-10-17 20:33:18 cawe Exp $
+// $Id: netadr_t.java,v 1.5 2004-10-20 20:37:32 cawe Exp $
package jake2.qcommon;
import jake2.Defines;
+import jake2.sys.NET;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -35,8 +36,6 @@ public class netadr_t {
public byte ip[];
- InetAddress ia = null;
-
public netadr_t() {
this.type = Defines.NA_LOOPBACK;
this.port = 0; // any
@@ -47,14 +46,16 @@ public class netadr_t {
}
public InetAddress getInetAddress() throws UnknownHostException {
- if (type == Defines.NA_BROADCAST) {
- ia = InetAddress.getByName("255.255.255.255");
- } else if (type == Defines.NA_LOOPBACK) {
- ia = InetAddress.getByName("localhost");
- } else if (ia == null) {
- ia = InetAddress.getByAddress(ip);
+ switch (type) {
+ case Defines.NA_BROADCAST:
+ return InetAddress.getByName("255.255.255.255");
+ case Defines.NA_LOOPBACK:
+ return InetAddress.getByName("localhost");
+ case Defines.NA_IP:
+ return InetAddress.getByAddress(ip);
+ default:
+ return null;
}
- return ia;
}
public void set(netadr_t from) {
@@ -65,4 +66,9 @@ public class netadr_t {
ip[2] = from.ip[2];
ip[3] = from.ip[3];
}
+
+ public String toString() {
+ return (type == Defines.NA_LOOPBACK) ? "loopback" : NET
+ .AdrToString(this);
+ }
} \ No newline at end of file