diff options
Diffstat (limited to 'src/jake2/qcommon')
-rw-r--r-- | src/jake2/qcommon/CM.java | 162 | ||||
-rw-r--r-- | src/jake2/qcommon/Cbuf.java | 4 | ||||
-rw-r--r-- | src/jake2/qcommon/Com.java | 45 | ||||
-rw-r--r-- | src/jake2/qcommon/FS.java | 2 | ||||
-rw-r--r-- | src/jake2/qcommon/MSG.java | 4 | ||||
-rw-r--r-- | src/jake2/qcommon/Netchan.java | 5 | ||||
-rw-r--r-- | src/jake2/qcommon/Qcommon.java | 32 | ||||
-rw-r--r-- | src/jake2/qcommon/SZ.java | 5 | ||||
-rw-r--r-- | src/jake2/qcommon/netadr_t.java | 8 |
9 files changed, 94 insertions, 173 deletions
diff --git a/src/jake2/qcommon/CM.java b/src/jake2/qcommon/CM.java index 907098c..278a1a9 100644 --- a/src/jake2/qcommon/CM.java +++ b/src/jake2/qcommon/CM.java @@ -19,7 +19,9 @@ */ // Created on 02.01.2004 by RST. -// $Id: CM.java,v 1.10 2005-02-06 19:25:14 salomo Exp $ + +// $Id: CM.java,v 1.10.6.1 2005-12-25 18:11:22 cawe Exp $ + package jake2.qcommon; import jake2.Defines; @@ -101,7 +103,7 @@ public class CM { static int numplanes; - // extra for box hull ( +6) + /** Extra for box hull ( +6) */ static cplane_t map_planes[] = new cplane_t[Defines.MAX_MAP_PLANES + 6]; static { @@ -111,7 +113,7 @@ public class CM { static int numnodes; - // extra for box hull ( +6) + /** Extra for box hull ( +6) */ static cnode_t map_nodes[] = new cnode_t[Defines.MAX_MAP_NODES + 6]; static { @@ -131,7 +133,6 @@ public class CM { static int numleafbrushes; - //static unsigned short map_leafbrushes[Defines.MAX_MAP_LEAFBRUSHES]; public static int map_leafbrushes[] = new int[Defines.MAX_MAP_LEAFBRUSHES]; public static int numcmodels; @@ -156,8 +157,7 @@ public class CM { public static byte map_visibility[] = new byte[Defines.MAX_MAP_VISIBILITY]; - // main visibility data. rst - // was: static dvis_t *map_vis = (dvis_t *)map_visibility; + /** Main visibility data. */ public static qfiles.dvis_t map_vis = new qfiles.dvis_t(ByteBuffer .wrap(map_visibility)); @@ -194,25 +194,14 @@ public class CM { public static cvar_t map_noareas; - /* - * =============================================================================== - * - * MAP LOADING - * - * =============================================================================== - */ - public static byte cmod_base[]; - // is that right (rst) ? public static int checksum; public static int last_checksum; - /* - * ================== CM_LoadMap - * - * Loads in the map and all submodels ================== + /** + * Loads in the map and all submodels. */ public static cmodel_t CM_LoadMap(String name, boolean clientload, int checksum[]) { @@ -303,20 +292,10 @@ public class CM { map_name = name; - // debug (rst) - /* - * Com.p("Testing pointleafes:"); for (int n = 0; n < 20; n++) { float - * pos[] = new float[] {(float) (Math.random() * 1000), (float) - * (Math.random() * 1000), 0 }; int x = CM_PointLeafnum(pos); - * Com.p(Lib.vtofsbeaty(pos) + " ---> leaf=" + x + " area = " - * +map_leafs[x].area); } - */ return map_cmodels[0]; } - /* - * ================= CMod_LoadSubmodels ================= - */ + /** Loads Submodels. */ public static void CMod_LoadSubmodels(lump_t l) { Com.DPrintf("CMod_LoadSubmodels()\n"); qfiles.dmodel_t in; @@ -366,9 +345,7 @@ public class CM { static boolean debugloadmap = false; - /* - * ================= CMod_LoadSurfaces ================= - */ + /** Loads surfaces. */ public static void CMod_LoadSurfaces(lump_t l) { Com.DPrintf("CMod_LoadSurfaces()\n"); texinfo_t in; @@ -408,11 +385,7 @@ public class CM { } } - /* - * ================= CMod_LoadNodes - * - * ================= - */ + /** Loads nodes. */ public static void CMod_LoadNodes(lump_t l) { Com.DPrintf("CMod_LoadNodes()\n"); qfiles.dnode_t in; @@ -454,11 +427,7 @@ public class CM { } } - /* - * ================= CMod_LoadBrushes - * - * ================= - */ + /** Loads brushes.*/ public static void CMod_LoadBrushes(lump_t l) { Com.DPrintf("CMod_LoadBrushes()\n"); qfiles.dbrush_t in; @@ -495,9 +464,7 @@ public class CM { } } - /* - * ================= CMod_LoadLeafs ================= - */ + /** Loads leafs. */ public static void CMod_LoadLeafs(lump_t l) { Com.DPrintf("CMod_LoadLeafs()\n"); int i; @@ -565,9 +532,7 @@ public class CM { Com.Error(Defines.ERR_DROP, "Map does not have an empty leaf"); } - /* - * ================= CMod_LoadPlanes ================= - */ + /** Loads planes. */ public static void CMod_LoadPlanes(lump_t l) { Com.DPrintf("CMod_LoadPlanes()\n"); int i, j; @@ -623,9 +588,7 @@ public class CM { } } - /* - * ================= CMod_LoadLeafBrushes ================= - */ + /** Loads leaf brushes. */ public static void CMod_LoadLeafBrushes(lump_t l) { Com.DPrintf("CMod_LoadLeafBrushes()\n"); int i; @@ -665,9 +628,7 @@ public class CM { } } - /* - * ================= CMod_LoadBrushSides ================= - */ + /** Loads brush sides. */ public static void CMod_LoadBrushSides(lump_t l) { Com.DPrintf("CMod_LoadBrushSides()\n"); int i, j; @@ -708,9 +669,7 @@ public class CM { if (j >= numtexinfo) Com.Error(Defines.ERR_DROP, "Bad brushside texinfo"); - // rst: some mysterious happens here, even in the original code ???, - // texinfo is -1!!! - // hoz: checked against c version: ok. + // java specific handling of -1 if (j == -1) out.surface = new mapsurface_t(); // just for safety else @@ -722,9 +681,7 @@ public class CM { } } - /* - * ================= CMod_LoadAreas ================= - */ + /** Loads areas. */ public static void CMod_LoadAreas(lump_t l) { Com.DPrintf("CMod_LoadAreas()\n"); int i; @@ -764,9 +721,7 @@ public class CM { } } - /* - * ================= CMod_LoadAreaPortals ================= - */ + /** Loads area portals. */ public static void CMod_LoadAreaPortals(lump_t l) { Com.DPrintf("CMod_LoadAreaPortals()\n"); int i; @@ -803,9 +758,7 @@ public class CM { } } - /* - * ================= CMod_LoadVisibility ================= - */ + /** Loads visibility data. */ public static void CMod_LoadVisibility(lump_t l) { Com.DPrintf("CMod_LoadVisibility()\n"); int i; @@ -826,9 +779,7 @@ public class CM { } - /* - * ================= CMod_LoadEntityString ================= - */ + /** Loads entity strings. */ public static void CMod_LoadEntityString(lump_t l) { Com.DPrintf("CMod_LoadEntityString()\n"); @@ -846,11 +797,7 @@ public class CM { map_entitystring.length(), 15)) + "...]" ); } - /* - * ================== CM_InlineModel ================== - */ - - // works fine + /** Returns the model with a given id "*" + <number> */ public static cmodel_t InlineModel(String name) { int num; @@ -895,8 +842,6 @@ public class CM { return map_leafs[leafnum].area; } - //======================================================================= - static cplane_t box_planes[]; static int box_headnode; @@ -905,12 +850,8 @@ public class CM { static cleaf_t box_leaf; - /* - * =================== CM_InitBoxHull - * - * Set up the planes and nodes so that the six floats of a bounding box can + /** Set up the planes and nodes so that the six floats of a bounding box can * just be stored out and get a proper clipping hull structure. - * =================== */ public static void CM_InitBoxHull() { int i; @@ -919,7 +860,7 @@ public class CM { cplane_t p; cbrushside_t s; - box_headnode = numnodes; // noch platz f?r 6 brushes + box_headnode = numnodes; //rst: still room for 6 brushes left? box_planes = new cplane_t[] { map_planes[numplanes], map_planes[numplanes + 1], map_planes[numplanes + 2], @@ -980,12 +921,8 @@ public class CM { } } - /* - * =================== CM_HeadnodeForBox - * - * To keep everything totally uniform, bounding boxes are turned into small - * BSP trees instead of being compared directly. =================== - */ + /** To keep everything totally uniform, bounding boxes are turned into small + * BSP trees instead of being compared directly. */ public static int HeadnodeForBox(float[] mins, float[] maxs) { box_planes[0].dist = maxs[0]; box_planes[1].dist = -maxs[0]; @@ -1003,10 +940,8 @@ public class CM { return box_headnode; } - /* - * ================== CM_PointLeafnum_r ================== - */ - public static int CM_PointLeafnum_r(float[] p, int num) { + /** Recursively searches the leaf number that contains the 3d point. */ + private static int CM_PointLeafnum_r(float[] p, int num) { float d; cnode_t node; cplane_t plane; @@ -1030,26 +965,25 @@ public class CM { return -1 - num; } + /** Searches the leaf number that contains the 3d point. */ public static int CM_PointLeafnum(float[] p) { + // sound may call this without map loaded if (numplanes == 0) - return 0; // sound may call this without map loaded + return 0; return CM_PointLeafnum_r(p, 0); } - /* - * ============= CM_BoxLeafnums - * - * Fills in a list of all the leafs touched ============= - */ - static int leaf_count, leaf_maxcount; - static int leaf_list[]; + private static int leaf_count, leaf_maxcount; + + private static int leaf_list[]; - static float leaf_mins[], leaf_maxs[]; + private static float leaf_mins[], leaf_maxs[]; - static int leaf_topnode; + private static int leaf_topnode; - public static void CM_BoxLeafnums_r(int nodenum) { + /** Recursively fills in a list of all the leafs touched. */ + private static void CM_BoxLeafnums_r(int nodenum) { cplane_t plane; cnode_t node; int s; @@ -1057,8 +991,7 @@ public class CM { while (true) { if (nodenum < 0) { if (leaf_count >= leaf_maxcount) { - //TODO: here is still an error. - //Com.DPrintf("CM_BoxLeafnums_r: overflow\n"); + Com.DPrintf("CM_BoxLeafnums_r: overflow\n"); return; } leaf_list[leaf_count++] = -1 - nodenum; @@ -1084,7 +1017,8 @@ public class CM { } } - public static int CM_BoxLeafnums_headnode(float[] mins, float[] maxs, + /** Fills in a list of all the leafs touched and starts with the head node. */ + private static int CM_BoxLeafnums_headnode(float[] mins, float[] maxs, int list[], int listsize, int headnode, int topnode[]) { leaf_list = list; leaf_count = 0; @@ -1102,19 +1036,14 @@ public class CM { return leaf_count; } + /** Fills in a list of all the leafs touched. */ public static int CM_BoxLeafnums(float[] mins, float[] maxs, int list[], int listsize, int topnode[]) { return CM_BoxLeafnums_headnode(mins, maxs, list, listsize, map_cmodels[0].headnode, topnode); } - /* - * public static class intwrap1 { public intwrap(int i) { this.i = i; } - * public int i; } - */ - /* - * ================== CM_PointContents ================== - */ + /** Returns a tag that describes the content of the point. */ public static int PointContents(float[] p, int headnode) { int l; @@ -1511,9 +1440,8 @@ public class CM { trace_trace.fraction = 1; trace_trace.surface = nullsurface.c; - if (numnodes == 0) // map not loaded - { - Com.DPrintf("dummy trace zurueck, da map not loaded!\n"); + if (numnodes == 0) { + // map not loaded return trace_trace; } diff --git a/src/jake2/qcommon/Cbuf.java b/src/jake2/qcommon/Cbuf.java index 593c058..28eb458 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.7 2005-02-19 11:12:42 salomo Exp $ + * $Id: Cbuf.java,v 1.7.6.1 2005-12-25 18:11:22 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -145,7 +145,7 @@ public final class Cbuf { Com.Printf("Cbuf_AddText: overflow\n"); return; } - SZ.Write(Globals.cmd_text, text.getBytes(), l); + SZ.Write(Globals.cmd_text, Lib.stringToBytes(text), l); } /** diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java index cffd15d..cdcc24d 100644 --- a/src/jake2/qcommon/Com.java +++ b/src/jake2/qcommon/Com.java @@ -2,7 +2,7 @@ * Com.java * Copyright (C) 2003 * - * $Id: Com.java,v 1.12.4.1 2005-11-13 12:57:56 cawe Exp $ + * $Id: Com.java,v 1.12.4.2 2005-12-25 18:11:22 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -51,15 +51,15 @@ public final class Com public abstract static class RD_Flusher { - public abstract void rd_flush(int target, byte[] buffer); + public abstract void rd_flush(int target, StringBuffer buffer); } static int rd_target; - static byte[] rd_buffer; + static StringBuffer rd_buffer; static int rd_buffersize; static RD_Flusher rd_flusher; - public static void BeginRedirect(int target, byte[] buffer, int buffersize, RD_Flusher flush) + public static void BeginRedirect(int target, StringBuffer buffer, int buffersize, RD_Flusher flush) { if (0 == target || null == buffer || 0 == buffersize || null == flush) return; @@ -69,7 +69,7 @@ public final class Com rd_buffersize= buffersize; rd_flusher= flush; - rd_buffer= null; + rd_buffer.setLength(0); } public static void EndRedirect() @@ -123,17 +123,6 @@ public final class Com return data[index]; } return 0; -// // faster than if -// try -// { -// return data[index]; -// } -// catch (Exception e) -// { -// data= null; -// // last char -// return 0; -// } } public char nextchar() @@ -144,19 +133,6 @@ public final class Com return data[index]; } return 0; -// try -// { -// index++; -// return data[index]; -// } -// catch (Exception e) -// { -// data= null; -// // avoid int wraps; -// index--; -// // last char -// return 0; -// } } public char prevchar() { @@ -366,21 +342,18 @@ public final class Com _debugContext=""; } + /** Prints out messages, which can also be redirected to a remote client. */ public static void Printf(String fmt, Vargs vargs) { - // Com.Printf is for testing only. String msg= sprintf(_debugContext + fmt, vargs); - if (rd_target != 0) { - if ((msg.length() + Lib.strlen(rd_buffer)) > (rd_buffersize - 1)) + if ((msg.length() + rd_buffer.length()) > (rd_buffersize - 1)) { rd_flusher.rd_flush(rd_target, rd_buffer); - // *rd_buffer = 0; - rd_buffer[rd_buffersize]= '\0'; + rd_buffer.setLength(0); } - // TODO handle rd_buffer - // strcat(rd_buffer, msg); + rd_buffer.append(msg); return; } diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java index 996f2a9..606aa97 100644 --- a/src/jake2/qcommon/FS.java +++ b/src/jake2/qcommon/FS.java @@ -2,7 +2,7 @@ * FS.java * Copyright (C) 2003 * - * $Id: FS.java,v 1.14.4.1 2005-11-13 12:57:56 cawe Exp $ + * $Id: FS.java,v 1.14.4.2 2005-12-25 18:11:22 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. diff --git a/src/jake2/qcommon/MSG.java b/src/jake2/qcommon/MSG.java index 4d5332b..be910c6 100644 --- a/src/jake2/qcommon/MSG.java +++ b/src/jake2/qcommon/MSG.java @@ -19,7 +19,7 @@ */ // Created on 29.11.2003 by RST. -// $Id: MSG.java,v 1.7 2005-02-19 21:20:47 salomo Exp $ +// $Id: MSG.java,v 1.7.6.1 2005-12-25 18:11:22 cawe Exp $ package jake2.qcommon; import jake2.Globals; @@ -85,7 +85,7 @@ public class MSG extends Globals { if (s == null) x = ""; - SZ.Write(sb, x.getBytes()); + SZ.Write(sb, Lib.stringToBytes(x)); WriteByte(sb, 0); //Com.dprintln("MSG.WriteString:" + s.replace('\0', '@')); } diff --git a/src/jake2/qcommon/Netchan.java b/src/jake2/qcommon/Netchan.java index 202a499..41c3ff6 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.6 2005-07-01 14:20:56 hzi Exp $ + * $Id: Netchan.java,v 1.6.2.1 2005-12-25 18:11:22 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -31,6 +31,7 @@ import jake2.game.cvar_t; import jake2.server.SV_MAIN; import jake2.sys.NET; import jake2.sys.Timer; +import jake2.util.Lib; /** * Netchan @@ -140,7 +141,7 @@ public final class Netchan extends SV_MAIN { } public static void OutOfBandPrint(int net_socket, netadr_t adr, String s) { - Netchan_OutOfBand(net_socket, adr, s.length(), s.getBytes()); + Netchan_OutOfBand(net_socket, adr, s.length(), Lib.stringToBytes(s)); } /* diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java index 9ff8177..6ffff02 100644 --- a/src/jake2/qcommon/Qcommon.java +++ b/src/jake2/qcommon/Qcommon.java @@ -2,7 +2,7 @@ * Qcommon.java * Copyright 2003 * - * $Id: Qcommon.java,v 1.19 2005-07-01 14:20:56 hzi Exp $ + * $Id: Qcommon.java,v 1.19.2.1 2005-12-25 18:11:22 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -74,15 +74,22 @@ public final class Qcommon extends Globals { Cbuf.AddEarlyCommands(false); Cbuf.Execute(); - Jake2.Q2Dialog.setStatus("initializing filesystem..."); + if (Globals.dedicated.value != 1.0f) + Jake2.Q2Dialog.setStatus("initializing filesystem..."); + FS.InitFilesystem(); - Jake2.Q2Dialog.setStatus("loading config..."); + if (Globals.dedicated.value != 1.0f) + Jake2.Q2Dialog.setStatus("loading config..."); + reconfigure(false); FS.setCDDir(); // use cddir from config.cfg FS.markBaseSearchPaths(); // mark the default search paths - Jake2.Q2Dialog.testQ2Data(); // test for valid baseq2 + + if (Globals.dedicated.value != 1.0f) + Jake2.Q2Dialog.testQ2Data(); // test for valid baseq2 + reconfigure(true); // reload default.cfg and config.cfg // save config when we have a valid baseq2 @@ -110,13 +117,19 @@ public final class Qcommon extends Globals { Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET); - Jake2.Q2Dialog.setStatus("initializing network subsystem..."); + if (Globals.dedicated.value != 1.0f) + Jake2.Q2Dialog.setStatus("initializing network subsystem..."); + NET.Init(); //ok Netchan.Netchan_Init(); //ok - Jake2.Q2Dialog.setStatus("initializing server subsystem..."); + if (Globals.dedicated.value != 1.0f) + Jake2.Q2Dialog.setStatus("initializing server subsystem..."); SV_MAIN.SV_Init(); //ok - Jake2.Q2Dialog.setStatus("initializing client subsystem..."); + + if (Globals.dedicated.value != 1.0f) + Jake2.Q2Dialog.setStatus("initializing client subsystem..."); + CL.Init(); // add + commands from command line @@ -135,7 +148,9 @@ public final class Qcommon extends Globals { } Com.Printf("====== Quake2 Initialized ======\n\n"); - Jake2.Q2Dialog.dispose(); + + if (Globals.dedicated.value != 1.0f) + Jake2.Q2Dialog.dispose(); } catch (longjmpException e) { Sys.Error("Error during initialization"); @@ -240,6 +255,7 @@ public final class Qcommon extends Globals { } } catch (longjmpException e) { + Com.DPrintf("lonjmp exception:" + e); } } diff --git a/src/jake2/qcommon/SZ.java b/src/jake2/qcommon/SZ.java index 46ac97b..b02eadb 100644 --- a/src/jake2/qcommon/SZ.java +++ b/src/jake2/qcommon/SZ.java @@ -2,7 +2,7 @@ * SZ.java * Copyright (C) 2003 * - * $Id: SZ.java,v 1.5 2005-02-06 19:26:50 salomo Exp $ + * $Id: SZ.java,v 1.5.6.1 2005-12-25 18:11:22 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.qcommon; import jake2.Defines; +import jake2.util.Lib; /** * SZ @@ -90,7 +91,7 @@ public final class SZ { public static void Print(sizebuf_t buf, String data) { Com.dprintln("SZ.print():<" + data + ">" ); int length = data.length(); - byte str[] = data.getBytes(); + byte str[] = Lib.stringToBytes(data); if (buf.cursize != 0) { diff --git a/src/jake2/qcommon/netadr_t.java b/src/jake2/qcommon/netadr_t.java index 40f27d5..1226889 100644 --- a/src/jake2/qcommon/netadr_t.java +++ b/src/jake2/qcommon/netadr_t.java @@ -19,7 +19,7 @@ */ // Created on 27.11.2003 by RST. -// $Id: netadr_t.java,v 1.5 2004-10-20 20:37:32 cawe Exp $ +// $Id: netadr_t.java,v 1.5.10.1 2005-12-25 18:11:22 cawe Exp $ package jake2.qcommon; import jake2.Defines; @@ -40,7 +40,8 @@ public class netadr_t { this.type = Defines.NA_LOOPBACK; this.port = 0; // any try { - this.ip = InetAddress.getByName("localhost").getAddress(); + // localhost / 127.0.0.1 + this.ip = InetAddress.getByName(null).getAddress(); } catch (UnknownHostException e) { } } @@ -50,7 +51,8 @@ public class netadr_t { case Defines.NA_BROADCAST: return InetAddress.getByName("255.255.255.255"); case Defines.NA_LOOPBACK: - return InetAddress.getByName("localhost"); + // localhost / 127.0.0.1 + return InetAddress.getByName(null); case Defines.NA_IP: return InetAddress.getByAddress(ip); default: |