aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-12 20:47:02 +0000
committerHolger Zickner <[email protected]>2004-07-12 20:47:02 +0000
commit4dca2574fe978cb98a9320f6db8176ee77973e91 (patch)
tree6cd1d23b2136f4f3817de7a0ba71c6f0d9ff52d3 /src
parent25252922d19cd51c8bf7a3544d6b2a82c8a26fff (diff)
cleanups
Diffstat (limited to 'src')
-rw-r--r--src/jake2/client/CL_ents.java15
-rw-r--r--src/jake2/client/CL_parse.java14
-rw-r--r--src/jake2/game/client_persistant_t.java17
-rw-r--r--src/jake2/game/client_respawn_t.java7
-rw-r--r--src/jake2/game/game_locals_t.java5
-rw-r--r--src/jake2/game/trace_t.java19
-rw-r--r--src/jake2/qcommon/CM.java10
-rw-r--r--src/jake2/qcommon/Cbuf.java5
-rw-r--r--src/jake2/qcommon/Netchan.java15
-rw-r--r--src/jake2/server/SV_ENTS.java12
-rw-r--r--src/jake2/server/scrap.jpage24
-rw-r--r--src/jake2/util/Lib.java80
12 files changed, 54 insertions, 169 deletions
diff --git a/src/jake2/client/CL_ents.java b/src/jake2/client/CL_ents.java
index ae05398..37d044c 100644
--- a/src/jake2/client/CL_ents.java
+++ b/src/jake2/client/CL_ents.java
@@ -2,7 +2,7 @@
* CL_ents.java
* Copyright (C) 2004
*
- * $Id: CL_ents.java,v 1.4 2004-07-09 06:50:50 hzi Exp $
+ * $Id: CL_ents.java,v 1.5 2004-07-12 20:47:01 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -234,22 +234,23 @@ public class CL_ents extends CL_inv {
int bits=0;
entity_state_t oldstate=null;
- int oldindex, oldnum;
+ int oldnum;
newframe.parse_entities = cl.parse_entities;
newframe.num_entities = 0;
// delta from the entities present in oldframe
- oldindex = 0;
+ int oldindex = 0;
if (oldframe == null)
oldnum = 99999;
else {
- if (oldindex >= oldframe.num_entities)
- oldnum = 99999;
- else {
+ // oldindex == 0. hoz
+// if (oldindex >= oldframe.num_entities)
+// oldnum = 99999;
+// else {
oldstate = cl_parse_entities[(oldframe.parse_entities + oldindex) & (MAX_PARSE_ENTITIES - 1)];
oldnum = oldstate.number;
- }
+// }
}
while (true) {
diff --git a/src/jake2/client/CL_parse.java b/src/jake2/client/CL_parse.java
index a36e677..f50857d 100644
--- a/src/jake2/client/CL_parse.java
+++ b/src/jake2/client/CL_parse.java
@@ -2,7 +2,7 @@
* CL_parse.java
* Copyright (C) 2004
*
- * $Id: CL_parse.java,v 1.5 2004-07-09 06:50:50 hzi Exp $
+ * $Id: CL_parse.java,v 1.6 2004-07-12 20:47:01 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -218,7 +218,9 @@ public class CL_parse extends CL_view {
Com.Printf("Server does not have this file.\n");
if (cls.download != null) {
// if here, we tried to resume a file but the server said no
- fclose(cls.download);
+ try {
+ cls.download.close();
+ } catch (IOException e) {}
cls.download = null;
}
CL.RequestNextDownload();
@@ -262,7 +264,9 @@ public class CL_parse extends CL_view {
// Com.Printf ("100%%\n");
- fclose(cls.download);
+ try {
+ cls.download.close();
+ } catch (IOException e) {}
// rename the temp file to it's final name
oldn = DownloadFileName(cls.downloadtempname);
@@ -693,7 +697,9 @@ public class CL_parse extends CL_view {
Com.Printf("Server disconnected, reconnecting\n");
if (cls.download != null) {
//ZOID, close download
- fclose(cls.download);
+ try {
+ cls.download.close();
+ } catch (IOException e) {}
cls.download = null;
}
cls.state = ca_connecting;
diff --git a/src/jake2/game/client_persistant_t.java b/src/jake2/game/client_persistant_t.java
index 5014d3b..774cfa4 100644
--- a/src/jake2/game/client_persistant_t.java
+++ b/src/jake2/game/client_persistant_t.java
@@ -19,26 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: client_persistant_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+// $Id: client_persistant_t.java,v 1.4 2004-07-12 20:47:01 hzi Exp $
package jake2.game;
import jake2.Defines;
import jake2.util.Lib;
-import java.io.IOException;
import java.nio.ByteBuffer;
-public class client_persistant_t implements Cloneable {
-
-// public client_persistant_t getClone() {
-// try {
-// return (client_persistant_t) this.clone();
-// }
-// catch (CloneNotSupportedException e) {
-// return null;
-// }
-// }
+public class client_persistant_t {
public void set(client_persistant_t from)
{
@@ -51,7 +41,6 @@ public class client_persistant_t implements Cloneable {
savedFlags = from.savedFlags;
selected_item = from.selected_item;
System.arraycopy(from.inventory, 0, inventory, 0, inventory.length);
- //inventory = Lib.clone(from.inventory);
max_bullets = from.max_bullets;
max_shells = from.max_shells;
max_rockets = from.max_rockets;
@@ -100,7 +89,7 @@ public class client_persistant_t implements Cloneable {
int helpchanged;
boolean spectator; // client is a spectator
- public void load(ByteBuffer bb) throws IOException {
+ public void load(ByteBuffer bb) {
// client persistant_t
userinfo = Lib.readString(bb, Defines.MAX_INFO_STRING);
diff --git a/src/jake2/game/client_respawn_t.java b/src/jake2/game/client_respawn_t.java
index a2ed8d5..722d609 100644
--- a/src/jake2/game/client_respawn_t.java
+++ b/src/jake2/game/client_respawn_t.java
@@ -18,12 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: client_respawn_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+// $Id: client_respawn_t.java,v 1.4 2004-07-12 20:47:01 hzi Exp $
package jake2.game;
import jake2.qcommon.Com;
import jake2.util.Lib;
+import jake2.util.Math3D;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -42,7 +43,7 @@ public class client_respawn_t
coop_respawn.set(from.coop_respawn);
enterframe = from.enterframe;
score = from.score;
- cmd_angles = Lib.clone(from.cmd_angles);
+ Math3D.VectorCopy(from.cmd_angles, cmd_angles);
spectator = from.spectator;
}
@@ -52,7 +53,7 @@ public class client_respawn_t
coop_respawn = new client_persistant_t();
enterframe = 0;
score = 0;
- cmd_angles = new float[3];
+ Math3D.VectorClear(cmd_angles);
spectator = false;
}
diff --git a/src/jake2/game/game_locals_t.java b/src/jake2/game/game_locals_t.java
index 3a04445..e638195 100644
--- a/src/jake2/game/game_locals_t.java
+++ b/src/jake2/game/game_locals_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: game_locals_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: game_locals_t.java,v 1.3 2004-07-12 20:47:01 hzi Exp $
package jake2.game;
@@ -27,7 +27,6 @@ import jake2.Defines;
import jake2.qcommon.Com;
import jake2.util.Lib;
-import java.io.IOException;
import java.nio.ByteBuffer;
public class game_locals_t extends Defines
@@ -60,7 +59,7 @@ public class game_locals_t extends Defines
public int num_items;
public boolean autosaved;
- public void load(ByteBuffer bb) throws IOException
+ public void load(ByteBuffer bb)
{
String date = Lib.readString(bb, 16);
diff --git a/src/jake2/game/trace_t.java b/src/jake2/game/trace_t.java
index ac6d413..420a344 100644
--- a/src/jake2/game/trace_t.java
+++ b/src/jake2/game/trace_t.java
@@ -19,11 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: trace_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+// $Id: trace_t.java,v 1.4 2004-07-12 20:47:01 hzi Exp $
package jake2.game;
-import jake2.util.Lib;
+import jake2.util.Math3D;
//a trace is returned when a box is swept through the world
public class trace_t implements Cloneable {
@@ -44,23 +44,10 @@ public class trace_t implements Cloneable {
allsolid = from.allsolid;
startsolid = from.allsolid;
fraction = from.fraction;
- endpos = Lib.clone(from.endpos);
+ Math3D.VectorCopy(from.endpos, endpos);
plane.set(from.plane);
surface = from.surface;
contents = from.contents;
ent = from.ent;
}
-
- // =============
-// public trace_t getClone() {
-// trace_t out = null;
-// try {
-// out = (trace_t) this.clone();
-// out.plane = plane.getClone();
-// out.endpos = Lib.clone(endpos);
-// }
-// catch (CloneNotSupportedException e) {
-// }
-// return out;
-// }
}
diff --git a/src/jake2/qcommon/CM.java b/src/jake2/qcommon/CM.java
index 1c3a756..a75cf05 100644
--- a/src/jake2/qcommon/CM.java
+++ b/src/jake2/qcommon/CM.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 02.01.2004 by RST.
-// $Id: CM.java,v 1.3 2004-07-09 06:50:50 hzi Exp $
+// $Id: CM.java,v 1.4 2004-07-12 20:47:00 hzi Exp $
package jake2.qcommon;
@@ -1703,7 +1703,7 @@ public class CM extends Game {
public static byte[] CM_ClusterPVS(int cluster) {
if (cluster == -1)
- Lib.memset(pvsrow, (byte) 0, (numclusters + 7) >> 3);
+ Arrays.fill(pvsrow, 0, (numclusters + 7) >> 3, (byte)0);
else
CM_DecompressVis(map_visibility, map_vis.bitofs[cluster][DVIS_PVS], pvsrow);
return pvsrow;
@@ -1711,7 +1711,7 @@ public class CM extends Game {
public static byte[] CM_ClusterPHS(int cluster) {
if (cluster == -1)
- Lib.memset(phsrow, (byte) 0, (numclusters + 7) >> 3);
+ Arrays.fill(phsrow, 0, (numclusters + 7) >> 3, (byte)0);
else
CM_DecompressVis(map_visibility, map_vis.bitofs[cluster][Defines.DVIS_PHS], phsrow);
return phsrow;
@@ -1822,10 +1822,10 @@ public class CM extends Game {
bytes = (numareas + 7) >> 3;
if (map_noareas.value != 0) { // for debugging, send everything
- Lib.memset(buffer, 255, bytes);
+ Arrays.fill(buffer, 0, bytes, (byte)255);
}
else {
- Lib.memset(buffer, 0, bytes);
+ Arrays.fill(buffer, 0, bytes, (byte)0);
floodnum = map_areas[area].floodnum;
for (i = 0; i < numareas; i++) {
if (map_areas[i].floodnum == floodnum || area == 0)
diff --git a/src/jake2/qcommon/Cbuf.java b/src/jake2/qcommon/Cbuf.java
index 5281081..84dea9c 100644
--- a/src/jake2/qcommon/Cbuf.java
+++ b/src/jake2/qcommon/Cbuf.java
@@ -2,7 +2,7 @@
* Cbuf.java
* Copyright (C) 2003
*
- * $Id: Cbuf.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
+ * $Id: Cbuf.java,v 1.3 2004-07-12 20:47:00 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -28,7 +28,6 @@ package jake2.qcommon;
import jake2.Defines;
import jake2.Globals;
import jake2.game.Cmd;
-import jake2.util.Lib;
/**
* Cbuf
@@ -229,7 +228,7 @@ public final class Cbuf {
============
*/
public static void CopyToDefer() {
- Lib.memcpy(Globals.defer_text_buf, Globals.cmd_text_buf, Globals.cmd_text.cursize);
+ System.arraycopy(Globals.cmd_text_buf, 0, Globals.defer_text_buf, 0, Globals.cmd_text.cursize);
Globals.defer_text_buf[Globals.cmd_text.cursize] = 0;
Globals.cmd_text.cursize = 0;
}
diff --git a/src/jake2/qcommon/Netchan.java b/src/jake2/qcommon/Netchan.java
index 31699c3..3331646 100644
--- a/src/jake2/qcommon/Netchan.java
+++ b/src/jake2/qcommon/Netchan.java
@@ -2,7 +2,7 @@
* NetChannel.java
* Copyright (C) 2003
*
- * $Id: Netchan.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
+ * $Id: Netchan.java,v 1.3 2004-07-12 20:47:00 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,15 +25,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.qcommon;
-import sun.applet.resources.MsgAppletViewer;
-import jake2.*;
-import jake2.client.*;
-import jake2.game.*;
-import jake2.render.*;
-import jake2.server.*;
+import jake2.Defines;
+import jake2.Globals;
+import jake2.game.cvar_t;
+import jake2.server.SV_MAIN;
import jake2.sys.NET;
import jake2.sys.Sys;
-import jake2.util.Lib;
/**
* Netchan
@@ -224,7 +221,7 @@ public final class Netchan extends SV_MAIN {
send_reliable = Netchan_NeedReliable(chan) ? 1 : 0;
if (chan.reliable_length == 0 && chan.message.cursize != 0) {
- Lib.memcpy(chan.reliable_buf, chan.message_buf, chan.message.cursize);
+ System.arraycopy(chan.message_buf, 0, chan.reliable_buf, 0, chan.message.cursize);
chan.reliable_length = chan.message.cursize;
chan.message.cursize = 0;
chan.reliable_sequence ^= 1;
diff --git a/src/jake2/server/SV_ENTS.java b/src/jake2/server/SV_ENTS.java
index 6437dff..e3a5a2c 100644
--- a/src/jake2/server/SV_ENTS.java
+++ b/src/jake2/server/SV_ENTS.java
@@ -19,18 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_ENTS.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
+// $Id: SV_ENTS.java,v 1.3 2004-07-12 20:47:02 hzi Exp $
package jake2.server;
-import java.io.IOException;
-
-import jake2.*;
-import jake2.client.*;
import jake2.game.*;
import jake2.qcommon.*;
-import jake2.render.*;
-import jake2.util.Vargs;
+
+import java.io.IOException;
public class SV_ENTS extends SV_USER {
@@ -383,7 +379,7 @@ public class SV_ENTS extends SV_USER {
for (i = 0; i < count; i++)
leafs[i] = CM.CM_LeafCluster(leafs[i]);
- memcpy(fatpvs, CM.CM_ClusterPVS(leafs[0]), longs << 2);
+ System.arraycopy(CM.CM_ClusterPVS(leafs[0]), 0, fatpvs, 0, longs << 2);
// or in all the other leaf bits
for (i = 1; i < count; i++) {
for (j = 0; j < i; j++)
diff --git a/src/jake2/server/scrap.jpage b/src/jake2/server/scrap.jpage
deleted file mode 100644
index 1666502..0000000
--- a/src/jake2/server/scrap.jpage
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-String p="\"123456\"";
-
-System.out.println(p.substring(1,p.length()-1));
-
- String path ="c:/baseq2/game/*.sav";
- String findbase;
- String findpattern;
-
- int i = path.lastIndexOf('/');
- if (i!=-1)
- {
- findbase = path.substring(0,i);
- findpattern = path.substring(i+1,path.length());
- }
- else
- {
- findpattern = "*";
- findbase = path;
- }
-
-
- System.out.println(findbase + ":" + findpattern); \ No newline at end of file
diff --git a/src/jake2/util/Lib.java b/src/jake2/util/Lib.java
index 8a965ab..4f5559c 100644
--- a/src/jake2/util/Lib.java
+++ b/src/jake2/util/Lib.java
@@ -19,19 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 09.12.2003 by RST.
-// $Id: Lib.java,v 1.3 2004-07-09 06:50:51 hzi Exp $
+// $Id: Lib.java,v 1.4 2004-07-12 20:47:01 hzi Exp $
package jake2.util;
+import jake2.Defines;
import jake2.Globals;
import jake2.qcommon.Com;
import jake2.qcommon.FS;
import java.io.*;
import java.nio.*;
-import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-import java.util.Arrays;
import java.util.StringTokenizer;
import net.java.games.jogl.util.BufferUtils;
@@ -158,17 +156,10 @@ public class Lib {
}
- public static String readString(RandomAccessFile file, int len) throws IOException {
- byte buf[] = new byte[len];
-
- file.read(buf, 0, len);
- return new String(buf, 0, strlen(buf));
- }
-
- public static String readString(ByteBuffer bb, int len) throws IOException {
- byte buf[] = new byte[len];
- bb.get(buf);
- return new String(buf, 0, strlen(buf));
+ static byte[] buffer = new byte[Defines.MAX_INFO_STRING];
+ public static String readString(ByteBuffer bb, int len) {
+ bb.get(buffer, 0, len);
+ return new String(buffer, 0, len);
}
public static String hexdumpfile(ByteBuffer bb, int len) throws IOException {
@@ -236,19 +227,7 @@ public class Lib {
}
}
- public static void memset(byte[] dest, byte c, int len) {
- Arrays.fill(dest, 0, len, c);
- }
-
- public static void memset(byte[] dest, int c, int len) {
- Arrays.fill(dest, 0, len, (byte) c);
- }
-
- public static void memcpy(byte[] bs, byte[] bs2, int i) {
- System.arraycopy(bs2, 0, bs, 0, i);
- }
-
- static byte nullfiller[] = new byte[8192];
+ static final byte nullfiller[] = new byte[8192];
public static void fwriteString(String s, int len, RandomAccessFile f) throws IOException {
if (s == null)
@@ -366,51 +345,6 @@ public class Lib {
return out;
}
- public static long[] clone(long in[]) {
- long out[] = new long[in.length];
-
- if (in.length != 0)
- System.arraycopy(in, 0, out, 0, in.length);
-
- return out;
- }
-
- public static boolean[] clone(boolean in[]) {
- boolean out[] = new boolean[in.length];
-
- if (in.length != 0)
- System.arraycopy(in, 0, out, 0, in.length);
-
- return out;
- }
-
- public static int[] clone(int in[]) {
- int out[] = new int[in.length];
-
- if (in.length != 0)
- System.arraycopy(in, 0, out, 0, in.length);
-
- return out;
- }
-
- public static double[] clone(double in[]) {
- double out[] = new double[in.length];
-
- if (in.length != 0)
- System.arraycopy(in, 0, out, 0, in.length);
-
- return out;
- }
-
- // this works with Strings also.
- public static String[] clone(String in[]) {
- String out[] = new String[in.length];
- if (in.length != 0)
- System.arraycopy(in, 0, out, 0, in.length);
-
- return out;
- }
-
/*
* java.nio.* Buffer util functions
*/