From bd16aab44f7774f6127702cfa036407462b5a0ba Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 9 Jul 2004 10:25:29 +0000 Subject: performance tweaks --- src/jake2/client/CL_tent.java | 23 +++---- src/jake2/render/fastjogl/Image.java | 18 ++++-- src/jake2/render/fastjogl/Light.java | 68 ++++++++++---------- src/jake2/render/fastjogl/Mesh.java | 118 ++++++++++++++++------------------- 4 files changed, 111 insertions(+), 116 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/CL_tent.java b/src/jake2/client/CL_tent.java index 8966e01..bca8edf 100644 --- a/src/jake2/client/CL_tent.java +++ b/src/jake2/client/CL_tent.java @@ -2,7 +2,7 @@ * CL_tent.java * Copyright (C) 2004 * - * $Id: CL_tent.java,v 1.3 2004-07-08 20:56:50 hzi Exp $ + * $Id: CL_tent.java,v 1.4 2004-07-09 10:19:57 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -1358,8 +1358,6 @@ public class CL_tent extends Globals { ================= */ static void AddPlayerBeams() { - int i, j; - beam_t[] b; float[] dist = new float[3]; float[] org = new float[3]; float d; @@ -1388,11 +1386,12 @@ public class CL_tent extends Globals { // PMM // update beams - b = cl_playerbeams; - for (i = 0; i < MAX_BEAMS; i++) { - float[] f = new float[3]; - float[] u = new float[3]; - float[] r = new float[3]; + beam_t[] b = cl_playerbeams; + float[] f = new float[3]; + float[] u = new float[3]; + float[] r = new float[3]; + for (int i = 0; i < MAX_BEAMS; i++) { + if (b[i].model == null || b[i].endtime < cl.time) continue; @@ -1404,7 +1403,7 @@ public class CL_tent extends Globals { // set up gun position // code straight out of CL_AddViewWeapon ps = cl.frame.playerstate; - j = (cl.frame.serverframe - 1) & UPDATE_MASK; + int j = (cl.frame.serverframe - 1) & UPDATE_MASK; oldframe = cl.frames[j]; if (oldframe.serverframe != cl.frame.serverframe - 1 || !oldframe.valid) @@ -1513,7 +1512,9 @@ public class CL_tent extends Globals { d = VectorNormalize(dist); //memset (&ent, 0, sizeof(ent)); - ent = new entity_t(); + //ent = new entity_t(); + // this is not required. hoz + if (b[i].model == cl_mod_heatbeam) { model_length = 32.0f; } else if (b[i].model == cl_mod_lightning) { @@ -1569,7 +1570,7 @@ public class CL_tent extends Globals { // Com_Printf("B: %d . %d\n", b[i].entity, b[i].dest_entity); V.AddEntity(ent); - for (j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) org[j] += dist[j] * len; d -= model_length; } diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java index de364c3..b05321b 100644 --- a/src/jake2/render/fastjogl/Image.java +++ b/src/jake2/render/fastjogl/Image.java @@ -2,7 +2,7 @@ * Image.java * Copyright (C) 2003 * - * $Id: Image.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Image.java,v 1.2 2004-07-09 10:22:28 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -743,19 +743,25 @@ public abstract class Image extends Main { // } // else if (pos[off] != 255) fdc = pos[off]; // } - + static floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; + static { + for (int j = 0; j < fifo.length; j++) { + fifo[j] = new floodfill_t(); + } + } // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight) + // TODO sync with jogl renderer. hoz void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) { // byte fillcolor = *skin; // assume this is the pixel to fill int fillcolor = skin[0] & 0xff; - floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; +// floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; int inpt = 0, outpt = 0; int filledcolor = -1; int i; - for (int j = 0; j < fifo.length; j++) { - fifo[j] = new floodfill_t(); - } +// for (int j = 0; j < fifo.length; j++) { +// fifo[j] = new floodfill_t(); +// } if (filledcolor == -1) { filledcolor = 0; diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java index b963b21..9f85766 100644 --- a/src/jake2/render/fastjogl/Light.java +++ b/src/jake2/render/fastjogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Light.java,v 1.2 2004-07-09 10:24:32 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,7 +28,6 @@ package jake2.render.fastjogl; import jake2.Defines; import jake2.Globals; import jake2.client.dlight_t; -import jake2.client.lightstyle_t; import jake2.game.GameBase; import jake2.game.cplane_t; import jake2.qcommon.longjmpException; @@ -223,14 +222,15 @@ public abstract class Light extends Warp { float[] pointcolor = {0, 0, 0}; // vec3_t cplane_t lightplane; // used as shadow plane float[] lightspot = {0, 0, 0}; // vec3_t - + float[] mid = {0, 0, 0}; + +// TODO sync with jogl renderer. hoz int RecursiveLightPoint (mnode_t node, float[] start, float[] end) { float front, back, frac; boolean side; int sideIndex; - cplane_t plane; - float[] mid = {0, 0, 0}; + cplane_t plane; msurface_t surf; int s, t, ds, dt; int i; @@ -272,6 +272,7 @@ public abstract class Light extends Warp { lightplane = plane; int surfIndex = node.firstsurface; + float[] scale = {0, 0, 0}; for (i=0 ; i> 4) + 1) + ds); @@ -398,26 +399,23 @@ public abstract class Light extends Warp { R_AddDynamicLights =============== */ + // TODO sync with jogl renderer. hoz void R_AddDynamicLights(msurface_t surf) { - int lnum; int sd, td; float fdist, frad, fminlight; float[] impact = {0, 0, 0}; float[] local = {0, 0, 0}; int s, t; - int i; - int smax, tmax; - mtexinfo_t tex; dlight_t dl; float[] pfBL; float fsacc, ftacc; - smax = (surf.extents[0]>>4)+1; - tmax = (surf.extents[1]>>4)+1; - tex = surf.texinfo; + int smax = (surf.extents[0]>>4)+1; + int tmax = (surf.extents[1]>>4)+1; + mtexinfo_t tex = surf.texinfo; - for (lnum=0 ; lnum> 4) + 1; - tmax = (surf.extents[1] >> 4) + 1; - size = smax * tmax; + int smax = (surf.extents[0] >> 4) + 1; + int tmax = (surf.extents[1] >> 4) + 1; + int size = smax * tmax; if (size > ((s_blocklights.length * Defines.SIZE_OF_FLOAT) >> 4) ) ri.Sys_Error(Defines.ERR_DROP, "Bad s_blocklights size"); @@ -525,11 +519,13 @@ public abstract class Light extends Warp { for (i=0 ; i= paliashdr.num_frames ) || ( e.frame < 0 ) ) { @@ -368,15 +358,15 @@ public abstract class Mesh extends Light { e.oldframe = 0; } - pframe = paliashdr.aliasFrames[e.frame]; - poldframe = paliashdr.aliasFrames[e.oldframe]; + qfiles.daliasframe_t pframe = paliashdr.aliasFrames[e.frame]; + qfiles.daliasframe_t poldframe = paliashdr.aliasFrames[e.oldframe]; /* ** compute axially aligned mins and maxs */ if ( pframe == poldframe ) { - for ( i = 0; i < 3; i++ ) + for ( int i = 0; i < 3; i++ ) { mins[i] = pframe.translate[i]; maxs[i] = mins[i] + pframe.scale[i]*255; @@ -384,18 +374,22 @@ public abstract class Mesh extends Light { } else { - for ( i = 0; i < 3; i++ ) + //float[] thismins = {0, 0, 0}; + //float[] oldmins = {0, 0, 0}; + float[] thismaxs = {0, 0, 0}; + float[] oldmaxs = {0, 0, 0}; + for ( int i = 0; i < 3; i++ ) { - thismins[i] = pframe.translate[i]; - thismaxs[i] = thismins[i] + pframe.scale[i]*255; + //thismins[i] = pframe.translate[i]; + thismaxs[i] = pframe.translate[i] + pframe.scale[i]*255; - oldmins[i] = poldframe.translate[i]; - oldmaxs[i] = oldmins[i] + poldframe.scale[i]*255; + //oldmins[i] = poldframe.translate[i]; + oldmaxs[i] = poldframe.translate[i] + poldframe.scale[i]*255; - if ( thismins[i] < oldmins[i] ) - mins[i] = thismins[i]; + if ( pframe.translate[i] < poldframe.translate[i] ) + mins[i] = pframe.translate[i]; else - mins[i] = oldmins[i]; + mins[i] = poldframe.translate[i]; if ( thismaxs[i] > oldmaxs[i] ) maxs[i] = thismaxs[i]; @@ -407,9 +401,9 @@ public abstract class Mesh extends Light { /* ** compute a full bounding box */ - for ( i = 0; i < 8; i++ ) + float[] tmp = {0, 0, 0}; + for ( int i = 0; i < 8; i++ ) { - float[] tmp = {0, 0, 0}; if ( (i & 1) != 0 ) tmp[0] = mins[0]; @@ -432,13 +426,12 @@ public abstract class Mesh extends Light { /* ** rotate the bounding box */ - Math3D.VectorCopy( e.angles, angles ); - angles[YAW] = -angles[YAW]; - Math3D.AngleVectors( angles, vectors[0], vectors[1], vectors[2] ); - - float[] tmp = {0, 0, 0}; + //float[] angles = {0, 0, 0}; + Math3D.VectorCopy( e.angles, tmp ); + tmp[YAW] = -tmp[YAW]; + Math3D.AngleVectors( tmp, vectors[0], vectors[1], vectors[2] ); - for ( i = 0; i < 8; i++ ) + for ( int i = 0; i < 8; i++ ) { Math3D.VectorCopy( bbox[i], tmp ); @@ -449,34 +442,32 @@ public abstract class Mesh extends Light { Math3D.VectorAdd( e.origin, bbox[i], bbox[i] ); } + int f, mask; + int aggregatemask = ~0; // 0xFFFFFFFF + + for ( int p = 0; p < 8; p++ ) { - int p, f; - int aggregatemask = ~0; // 0xFFFFFFFF - - for ( p = 0; p < 8; p++ ) + mask = 0; + + for ( f = 0; f < 4; f++ ) { - int mask = 0; + float dp = Math3D.DotProduct( frustum[f].normal, bbox[p] ); - for ( f = 0; f < 4; f++ ) + if ( ( dp - frustum[f].dist ) < 0 ) { - float dp = Math3D.DotProduct( frustum[f].normal, bbox[p] ); - - if ( ( dp - frustum[f].dist ) < 0 ) - { - mask |= ( 1 << f ); - } + mask |= ( 1 << f ); } - - aggregatemask &= mask; } - if ( aggregatemask != 0 ) - { - return true; - } + aggregatemask &= mask; + } - return false; + if ( aggregatemask != 0 ) + { + return true; } + + return false; } @@ -492,17 +483,18 @@ public abstract class Mesh extends Light { ================= */ +// TODO sync with jogl renderer. hoz void R_DrawAliasModel(entity_t e) { int i; - qfiles.dmdl_t paliashdr; - float an; + //qfiles.dmdl_t paliashdr; + //float an; image_t skin; if ( ( e.flags & Defines.RF_WEAPONMODEL ) == 0) { - if ( R_CullAliasModel( bbox, e ) ) + if ( R_CullAliasModel(e) ) return; } @@ -512,7 +504,7 @@ public abstract class Mesh extends Light { return; } - paliashdr = (qfiles.dmdl_t)currentmodel.extradata; + qfiles.dmdl_t paliashdr = (qfiles.dmdl_t)currentmodel.extradata; // // get lighting information @@ -629,7 +621,7 @@ public abstract class Mesh extends Light { shadedots = r_avertexnormal_dots[((int)(currententity.angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)]; - an = (float)(currententity.angles[1]/180*Math.PI); + float an = (float)(currententity.angles[1]/180*Math.PI); shadevector[0] = (float)Math.cos(-an); shadevector[1] = (float)Math.sin(-an); shadevector[2] = 1; -- cgit v1.2.3 From 531ca89792550bf84a20f5a57483987d6fc76782 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 9 Jul 2004 16:44:01 +0000 Subject: moving out mid was to optimistic --- src/jake2/render/fastjogl/Light.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java index 9f85766..298a3db 100644 --- a/src/jake2/render/fastjogl/Light.java +++ b/src/jake2/render/fastjogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.2 2004-07-09 10:24:32 hzi Exp $ + * $Id: Light.java,v 1.3 2004-07-09 16:44:01 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -222,7 +222,6 @@ public abstract class Light extends Warp { float[] pointcolor = {0, 0, 0}; // vec3_t cplane_t lightplane; // used as shadow plane float[] lightspot = {0, 0, 0}; // vec3_t - float[] mid = {0, 0, 0}; // TODO sync with jogl renderer. hoz int RecursiveLightPoint (mnode_t node, float[] start, float[] end) @@ -238,7 +237,8 @@ public abstract class Light extends Warp { ByteBuffer lightmap; int maps; int r; - + float[] mid = {0, 0, 0}; + if (node.contents != -1) return -1; // didn't hit anything -- cgit v1.2.3 From 25252922d19cd51c8bf7a3544d6b2a82c8a26fff Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Mon, 12 Jul 2004 18:19:42 +0000 Subject: fix nullpointer exception when first starting with: r_drawworld 0 r_drawentities 0 --- src/jake2/render/fastjogl/Surf.java | 10 ++++------ src/jake2/render/jogl/Surf.java | 12 +++++------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/fastjogl/Surf.java b/src/jake2/render/fastjogl/Surf.java index c7e7bc0..2bb812c 100644 --- a/src/jake2/render/fastjogl/Surf.java +++ b/src/jake2/render/fastjogl/Surf.java @@ -2,7 +2,7 @@ * Surf.java * Copyright (C) 2003 * - * $Id: Surf.java,v 1.1 2004-07-09 06:50:48 hzi Exp $ + * $Id: Surf.java,v 1.2 2004-07-12 18:19:42 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -911,6 +911,9 @@ public abstract class Surf extends Draw { void R_DrawWorld() { entity_t ent = new entity_t(); + // auto cycle the world frame for texture animation + ent.frame = (int)(r_newrefdef.time*2); + currententity = ent; if (r_drawworld.value == 0) return; @@ -922,11 +925,6 @@ public abstract class Surf extends Draw { Math3D.VectorCopy(r_newrefdef.vieworg, modelorg); - // auto cycle the world frame for texture animation - // memset (&ent, 0, sizeof(ent)); - ent.frame = (int)(r_newrefdef.time*2); - currententity = ent; - gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; gl.glColor3f (1,1,1); diff --git a/src/jake2/render/jogl/Surf.java b/src/jake2/render/jogl/Surf.java index 54e0e77..e4d0101 100644 --- a/src/jake2/render/jogl/Surf.java +++ b/src/jake2/render/jogl/Surf.java @@ -2,7 +2,7 @@ * Surf.java * Copyright (C) 2003 * - * $Id: Surf.java,v 1.3 2004-07-09 06:50:48 hzi Exp $ + * $Id: Surf.java,v 1.4 2004-07-12 18:19:42 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -1204,7 +1204,10 @@ public abstract class Surf extends Draw { void R_DrawWorld() { entity_t ent = new entity_t(); - + // auto cycle the world frame for texture animation + ent.frame = (int)(r_newrefdef.time*2); + currententity = ent; + if (r_drawworld.value == 0) return; @@ -1215,11 +1218,6 @@ public abstract class Surf extends Draw { Math3D.VectorCopy(r_newrefdef.vieworg, modelorg); - // auto cycle the world frame for texture animation - // memset (&ent, 0, sizeof(ent)); - ent.frame = (int)(r_newrefdef.time*2); - currententity = ent; - gl_state.currenttextures[0] = gl_state.currenttextures[1] = -1; gl.glColor3f (1,1,1); -- cgit v1.2.3 From 4dca2574fe978cb98a9320f6db8176ee77973e91 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Mon, 12 Jul 2004 20:47:02 +0000 Subject: cleanups --- src/jake2/client/CL_ents.java | 15 ++++--- src/jake2/client/CL_parse.java | 14 ++++-- src/jake2/game/client_persistant_t.java | 17 ++----- src/jake2/game/client_respawn_t.java | 7 +-- src/jake2/game/game_locals_t.java | 5 +-- src/jake2/game/trace_t.java | 19 ++------ src/jake2/qcommon/CM.java | 10 ++--- src/jake2/qcommon/Cbuf.java | 5 +-- src/jake2/qcommon/Netchan.java | 15 +++---- src/jake2/server/SV_ENTS.java | 12 ++--- src/jake2/server/scrap.jpage | 24 ---------- src/jake2/util/Lib.java | 80 +++------------------------------ 12 files changed, 54 insertions(+), 169 deletions(-) delete mode 100644 src/jake2/server/scrap.jpage (limited to 'src/jake2') 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 */ -- cgit v1.2.3 From 87169713e60b4e00e9179c1bc32a1bcbf2ce8d75 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Mon, 12 Jul 2004 22:08:04 +0000 Subject: small optimizations --- src/jake2/render/fastjogl/Image.java | 3 +- src/jake2/render/fastjogl/Light.java | 42 +++++++++---------------- src/jake2/render/fastjogl/Mesh.java | 25 ++++++--------- src/jake2/render/fastjogl/Model.java | 11 +++---- src/jake2/render/fastjogl/Warp.java | 15 ++++----- src/jake2/render/jogl/Image.java | 14 ++++----- src/jake2/render/jogl/Light.java | 54 +++++++++++++++------------------ src/jake2/render/jogl/Mesh.java | 59 +++++++++++++++++++----------------- src/jake2/render/jogl/Model.java | 33 +++++++------------- src/jake2/render/jogl/Warp.java | 12 +++----- 10 files changed, 114 insertions(+), 154 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java index b05321b..1f80af0 100644 --- a/src/jake2/render/fastjogl/Image.java +++ b/src/jake2/render/fastjogl/Image.java @@ -2,7 +2,7 @@ * Image.java * Copyright (C) 2003 * - * $Id: Image.java,v 1.2 2004-07-09 10:22:28 hzi Exp $ + * $Id: Image.java,v 1.3 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -750,7 +750,6 @@ public abstract class Image extends Main { } } // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight) - // TODO sync with jogl renderer. hoz void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) { // byte fillcolor = *skin; // assume this is the pixel to fill int fillcolor = skin[0] & 0xff; diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java index 298a3db..a9e64a5 100644 --- a/src/jake2/render/fastjogl/Light.java +++ b/src/jake2/render/fastjogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.3 2004-07-09 16:44:01 hzi Exp $ + * $Id: Light.java,v 1.4 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -223,44 +223,38 @@ public abstract class Light extends Warp { cplane_t lightplane; // used as shadow plane float[] lightspot = {0, 0, 0}; // vec3_t -// TODO sync with jogl renderer. hoz int RecursiveLightPoint (mnode_t node, float[] start, float[] end) { - float front, back, frac; - boolean side; - int sideIndex; - cplane_t plane; + if (node.contents != -1) + return -1; // didn't hit anything + msurface_t surf; int s, t, ds, dt; int i; mtexinfo_t tex; ByteBuffer lightmap; int maps; - int r; float[] mid = {0, 0, 0}; - - if (node.contents != -1) - return -1; // didn't hit anything // calculate mid point // FIXME: optimize for axial - plane = node.plane; - front = Math3D.DotProduct (start, plane.normal) - plane.dist; - back = Math3D.DotProduct (end, plane.normal) - plane.dist; - side = (front < 0); - sideIndex = (side) ? 1 : 0; + cplane_t plane = node.plane; + float front = Math3D.DotProduct (start, plane.normal) - plane.dist; + float back = Math3D.DotProduct (end, plane.normal) - plane.dist; + boolean side = (front < 0); + int sideIndex = (side) ? 1 : 0; if ( (back < 0) == side) return RecursiveLightPoint (node.children[sideIndex], start, end); - frac = front / (front-back); + float frac = front / (front-back); mid[0] = start[0] + (end[0] - start[0])*frac; mid[1] = start[1] + (end[1] - start[1])*frac; mid[2] = start[2] + (end[2] - start[2])*frac; // go down front side - r = RecursiveLightPoint (node.children[sideIndex], start, mid); + int r = RecursiveLightPoint (node.children[sideIndex], start, mid); if (r >= 0) return r; // hit something @@ -341,11 +335,7 @@ public abstract class Light extends Warp { assert (color.length == 3) : "rgb bug"; float[] end = {0, 0, 0}; - float r; - int lnum; dlight_t dl; - float light; - float[] dist = {0, 0, 0}; float add; if (r_worldmodel.lightdata == null) @@ -358,7 +348,7 @@ public abstract class Light extends Warp { end[1] = p[1]; end[2] = p[2] - 2048; - r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); + float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); if (r == -1) { @@ -372,13 +362,12 @@ public abstract class Light extends Warp { // // add dynamic lights // - light = 0; - for (lnum=0 ; lnum 0) { @@ -389,7 +378,6 @@ public abstract class Light extends Warp { Math3D.VectorScale (color, gl_modulate.value, color); } - // =================================================================== float[] s_blocklights = new float[34 * 34 * 3]; diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java index 572e691..257fc68 100644 --- a/src/jake2/render/fastjogl/Mesh.java +++ b/src/jake2/render/fastjogl/Mesh.java @@ -2,7 +2,7 @@ * Mesh.java * Copyright (C) 2003 * - * $Id: Mesh.java,v 1.2 2004-07-09 10:25:29 hzi Exp $ + * $Id: Mesh.java,v 1.3 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -67,20 +67,20 @@ public abstract class Mesh extends Light { float[] shadedots = r_avertexnormal_dots[0]; - void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, FloatBuffer lerp, float[] move, float[] frontv, float[] backv ) + void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv ) { - int i; int lerpIndex = 0; int[] ovv; int[] vv; + FloatBuffer lerp = vertexArrayBuf; //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) { float[] normal; int j = 0; - for (i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) + for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { normal = r_avertexnormals[verts[i].lightnormalindex]; ovv = ov[i].v; @@ -95,7 +95,7 @@ public abstract class Mesh extends Light { else { int j = 0; - for (i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) + for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) { ovv = ov[i].v; vv = v[i].v; @@ -140,7 +140,6 @@ public abstract class Mesh extends Light { float alpha; float[] move = {0, 0, 0}; // vec3_t - float[] delta = {0, 0, 0}; // vec3_t float[] frontv = {0, 0, 0}; // vec3_t float[] backv = {0, 0, 0}; // vec3_t @@ -168,29 +167,25 @@ public abstract class Mesh extends Light { frontlerp = 1.0f - backlerp; // move should be the delta back to the previous frame * backlerp - Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, delta); + Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv); Math3D.AngleVectors (currententity.angles, vectors[0], vectors[1], vectors[2]); - move[0] = Math3D.DotProduct (delta, vectors[0]); // forward - move[1] = -Math3D.DotProduct (delta, vectors[1]); // left - move[2] = Math3D.DotProduct (delta, vectors[2]); // up + move[0] = Math3D.DotProduct (frontv, vectors[0]); // forward + move[1] = -Math3D.DotProduct (frontv, vectors[1]); // left + move[2] = Math3D.DotProduct (frontv, vectors[2]); // up Math3D.VectorAdd (move, oldframe.translate, move); for (i=0 ; i<3 ; i++) { move[i] = backlerp*move[i] + frontlerp*frame.translate[i]; - } - - for (i=0 ; i<3 ; i++) - { frontv[i] = frontlerp*frame.scale[i]; backv[i] = backlerp*oldframe.scale[i]; } // ab hier wird optimiert - GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, vertexArrayBuf, move, frontv, backv ); + GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, move, frontv, backv ); //gl.glEnableClientState( GL.GL_VERTEX_ARRAY ); gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf ); diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java index 4b781be..c7d83e9 100644 --- a/src/jake2/render/fastjogl/Model.java +++ b/src/jake2/render/fastjogl/Model.java @@ -2,7 +2,7 @@ * Model.java * Copyright (C) 2003 * - * $Id: Model.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Model.java,v 1.2 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -560,18 +560,17 @@ public abstract class Model extends Surf { float[] maxs = {0, 0}; float val; - int i, j, e; + int j, e; mvertex_t v; - mtexinfo_t tex; int[] bmins = {0, 0}; int[] bmaxs = {0, 0}; mins[0] = mins[1] = 999999; maxs[0] = maxs[1] = -99999; - tex = s.texinfo; + mtexinfo_t tex = s.texinfo; - for (i=0 ; i= 0) @@ -592,7 +591,7 @@ public abstract class Model extends Surf { } } - for (i=0 ; i<2 ; i++) + for (int i=0 ; i<2 ; i++) { bmins[i] = (int)Math.floor(mins[i]/16); bmaxs[i] = (int)Math.ceil(maxs[i]/16); diff --git a/src/jake2/render/fastjogl/Warp.java b/src/jake2/render/fastjogl/Warp.java index f9a5b07..d7645f8 100644 --- a/src/jake2/render/fastjogl/Warp.java +++ b/src/jake2/render/fastjogl/Warp.java @@ -2,7 +2,7 @@ * Warp.java * Copyright (C) 2003 * - * $Id: Warp.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Warp.java,v 1.2 2004-07-12 22:08:02 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,15 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.fastjogl; -import java.nio.FloatBuffer; - import jake2.Defines; import jake2.Globals; -import jake2.game.GameBase; -import jake2.render.glpoly_t; -import jake2.render.image_t; -import jake2.render.msurface_t; +import jake2.render.*; import jake2.util.Math3D; + +import java.nio.FloatBuffer; + import net.java.games.jogl.GL; /** @@ -125,7 +123,6 @@ public abstract class Warp extends Model { int f, b; float[] dist = new float[64]; float frac; - glpoly_t poly; float s, t; float[] total = {0, 0, 0}; float total_s, total_t; @@ -194,7 +191,7 @@ public abstract class Warp extends Model { // poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float)); // init polys - poly = new glpoly_t(numverts + 2); + glpoly_t poly = new glpoly_t(numverts + 2); poly.next = warpface.polys; warpface.polys = poly; diff --git a/src/jake2/render/jogl/Image.java b/src/jake2/render/jogl/Image.java index f0034fe..3a58884 100644 --- a/src/jake2/render/jogl/Image.java +++ b/src/jake2/render/jogl/Image.java @@ -2,7 +2,7 @@ * Image.java * Copyright (C) 2003 * - * $Id: Image.java,v 1.3 2004-07-09 06:50:48 hzi Exp $ + * $Id: Image.java,v 1.4 2004-07-12 22:08:03 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -761,20 +761,20 @@ public abstract class Image extends Main { // } // else if (pos[off] != 255) fdc = pos[off]; // } - + static floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; + static { + for (int j = 0; j < fifo.length; j++) { + fifo[j] = new floodfill_t(); + } + } // TODO check this: R_FloodFillSkin( byte[] skin, int skinwidth, int skinheight) void R_FloodFillSkin(byte[] skin, int skinwidth, int skinheight) { // byte fillcolor = *skin; // assume this is the pixel to fill int fillcolor = skin[0] & 0xff; - floodfill_t[] fifo = new floodfill_t[FLOODFILL_FIFO_SIZE]; int inpt = 0, outpt = 0; int filledcolor = -1; int i; - for (int j = 0; j < fifo.length; j++) { - fifo[j] = new floodfill_t(); - } - if (filledcolor == -1) { filledcolor = 0; // attempt to find opaque black diff --git a/src/jake2/render/jogl/Light.java b/src/jake2/render/jogl/Light.java index 851f4e6..e9e83af 100644 --- a/src/jake2/render/jogl/Light.java +++ b/src/jake2/render/jogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.4 2004-07-09 06:50:48 hzi Exp $ + * $Id: Light.java,v 1.5 2004-07-12 22:08:04 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -230,41 +230,36 @@ public abstract class Light extends Warp { int RecursiveLightPoint (mnode_t node, float[] start, float[] end) { - float front, back, frac; - boolean side; - int sideIndex; - cplane_t plane; - float[] mid = {0, 0, 0}; + if (node.contents != -1) + return -1; // didn't hit anything + msurface_t surf; int s, t, ds, dt; int i; mtexinfo_t tex; ByteBuffer lightmap; int maps; - int r; - - if (node.contents != -1) - return -1; // didn't hit anything + float[] mid = {0, 0, 0}; // calculate mid point // FIXME: optimize for axial - plane = node.plane; - front = Math3D.DotProduct (start, plane.normal) - plane.dist; - back = Math3D.DotProduct (end, plane.normal) - plane.dist; - side = (front < 0); - sideIndex = (side) ? 1 : 0; + cplane_t plane = node.plane; + float front = Math3D.DotProduct (start, plane.normal) - plane.dist; + float back = Math3D.DotProduct (end, plane.normal) - plane.dist; + boolean side = (front < 0); + int sideIndex = (side) ? 1 : 0; if ( (back < 0) == side) return RecursiveLightPoint (node.children[sideIndex], start, end); - frac = front / (front-back); + float frac = front / (front-back); mid[0] = start[0] + (end[0] - start[0])*frac; mid[1] = start[1] + (end[1] - start[1])*frac; mid[2] = start[2] + (end[2] - start[2])*frac; // go down front side - r = RecursiveLightPoint (node.children[sideIndex], start, mid); + int r = RecursiveLightPoint (node.children[sideIndex], start, mid); if (r >= 0) return r; // hit something @@ -276,6 +271,7 @@ public abstract class Light extends Warp { lightplane = plane; int surfIndex = node.firstsurface; + float[] scale = {0, 0, 0}; for (i=0 ; i> 4) + 1) + ds); for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++) { - for (i=0 ; i<3 ; i++) - scale[i] = gl_modulate.value * r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb[i]; + rgb = r_newrefdef.lightstyles[surf.styles[maps] & 0xFF].rgb; + scale[0] = gl_modulate.value * rgb[0]; + scale[1] = gl_modulate.value * rgb[1]; + scale[2] = gl_modulate.value * rgb[2]; pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) * scale[0] * (1.0f/255); pointcolor[1] += (lightmap.get(lightmapIndex + 1) & 0xFF) * scale[1] * (1.0f/255); @@ -325,6 +324,7 @@ public abstract class Light extends Warp { } return 1; } + // go down back side return RecursiveLightPoint (node.children[1 - sideIndex], mid, end); } @@ -340,11 +340,7 @@ public abstract class Light extends Warp { assert (color.length == 3) : "rgb bug"; float[] end = {0, 0, 0}; - float r; - int lnum; dlight_t dl; - float light; - float[] dist = {0, 0, 0}; float add; if (r_worldmodel.lightdata == null) @@ -357,7 +353,7 @@ public abstract class Light extends Warp { end[1] = p[1]; end[2] = p[2] - 2048; - r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); + float r = RecursiveLightPoint(r_worldmodel.nodes[0], p, end); if (r == -1) { @@ -371,13 +367,12 @@ public abstract class Light extends Warp { // // add dynamic lights // - light = 0; - for (lnum=0 ; lnum 0) { @@ -388,7 +383,6 @@ public abstract class Light extends Warp { Math3D.VectorScale (color, gl_modulate.value, color); } - // =================================================================== float[] s_blocklights = new float[34 * 34 * 3]; diff --git a/src/jake2/render/jogl/Mesh.java b/src/jake2/render/jogl/Mesh.java index 991bf37..4a53371 100644 --- a/src/jake2/render/jogl/Mesh.java +++ b/src/jake2/render/jogl/Mesh.java @@ -2,7 +2,7 @@ * Mesh.java * Copyright (C) 2003 * - * $Id: Mesh.java,v 1.4 2004-07-09 06:50:48 hzi Exp $ + * $Id: Mesh.java,v 1.5 2004-07-12 22:08:03 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,18 +25,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.jogl; -import java.nio.FloatBuffer; - -import net.java.games.gluegen.runtime.BufferFactory; -import net.java.games.jogl.GL; -import net.java.games.jogl.util.BufferUtils; import jake2.Defines; -import jake2.Globals; import jake2.client.entity_t; import jake2.qcommon.qfiles; import jake2.render.image_t; import jake2.util.Math3D; +import java.nio.FloatBuffer; + +import net.java.games.jogl.GL; +import net.java.games.jogl.util.BufferUtils; + /** * Mesh * @@ -100,34 +99,43 @@ public abstract class Mesh extends Light { } } - void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, FloatBuffer lerp, float[] move, float[] frontv, float[] backv ) + void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv ) { - int i; int lerpIndex = 0; + int[] ovv; + int[] vv; + FloatBuffer lerp = vertexArrayBuf; + //PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 ) { float[] normal; int j = 0; - for (i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) + for (int i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */) { normal = r_avertexnormals[verts[i].lightnormalindex]; - - lerp.put(j++, move[0] + ov[i].v[0]*backv[0] + v[i].v[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); - lerp.put(j++, move[1] + ov[i].v[1]*backv[1] + v[i].v[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); - lerp.put(j++, move[2] + ov[i].v[2]*backv[2] + v[i].v[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + ovv = ov[i].v; + vv = v[i].v; + + lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); + lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); + lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); + j+=3; } } else { int j = 0; - for (i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) + for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) { + ovv = ov[i].v; + vv = v[i].v; - lerp.put(j++, move[0] + ov[i].v[0]*backv[0] + v[i].v[0]*frontv[0]); - lerp.put(j++, move[1] + ov[i].v[1]*backv[1] + v[i].v[1]*frontv[1]); - lerp.put(j++, move[2] + ov[i].v[2]*backv[2] + v[i].v[2]*frontv[2]); + lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]); + lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]); + lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]); + j+=3; } } } @@ -159,7 +167,6 @@ public abstract class Mesh extends Light { float alpha; float[] move = {0, 0, 0}; // vec3_t - float[] delta = {0, 0, 0}; // vec3_t float[][] vectors = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} // 3 mal vec3_t }; @@ -193,29 +200,25 @@ public abstract class Mesh extends Light { frontlerp = 1.0f - backlerp; // move should be the delta back to the previous frame * backlerp - Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, delta); + Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv); Math3D.AngleVectors (currententity.angles, vectors[0], vectors[1], vectors[2]); - move[0] = Math3D.DotProduct (delta, vectors[0]); // forward - move[1] = -Math3D.DotProduct (delta, vectors[1]); // left - move[2] = Math3D.DotProduct (delta, vectors[2]); // up + move[0] = Math3D.DotProduct(frontv, vectors[0]); // forward + move[1] = -Math3D.DotProduct(frontv, vectors[1]); // left + move[2] = Math3D.DotProduct(frontv, vectors[2]); // up Math3D.VectorAdd (move, oldframe.translate, move); for (i=0 ; i<3 ; i++) { move[i] = backlerp*move[i] + frontlerp*frame.translate[i]; - } - - for (i=0 ; i<3 ; i++) - { frontv[i] = frontlerp*frame.scale[i]; backv[i] = backlerp*oldframe.scale[i]; } if ( gl_vertex_arrays.value != 0.0f ) { - GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, vertexArrayBuf, move, frontv, backv ); + GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, move, frontv, backv ); gl.glEnableClientState( GL.GL_VERTEX_ARRAY ); gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf ); diff --git a/src/jake2/render/jogl/Model.java b/src/jake2/render/jogl/Model.java index 75357c3..9a10cf5 100644 --- a/src/jake2/render/jogl/Model.java +++ b/src/jake2/render/jogl/Model.java @@ -2,7 +2,7 @@ * Model.java * Copyright (C) 2003 * - * $Id: Model.java,v 1.2 2004-07-09 06:50:48 hzi Exp $ + * $Id: Model.java,v 1.3 2004-07-12 22:08:03 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,28 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.jogl; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.Vector; - import jake2.Defines; import jake2.game.cplane_t; import jake2.game.cvar_t; -import jake2.qcommon.lump_t; -import jake2.qcommon.qfiles; -import jake2.qcommon.texinfo_t; -import jake2.render.medge_t; -import jake2.render.mleaf_t; -import jake2.render.mmodel_t; -import jake2.render.mnode_t; -import jake2.render.model_t; -import jake2.render.msurface_t; -import jake2.render.mtexinfo_t; -import jake2.render.mvertex_t; +import jake2.qcommon.*; +import jake2.render.*; import jake2.util.Math3D; import jake2.util.Vargs; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; + /** * Model * @@ -568,18 +558,17 @@ public abstract class Model extends Surf { float[] maxs = {0, 0}; float val; - int i, j, e; + int j, e; mvertex_t v; - mtexinfo_t tex; int[] bmins = {0, 0}; int[] bmaxs = {0, 0}; mins[0] = mins[1] = 999999; maxs[0] = maxs[1] = -99999; - tex = s.texinfo; + mtexinfo_t tex = s.texinfo; - for (i=0 ; i= 0) @@ -600,7 +589,7 @@ public abstract class Model extends Surf { } } - for (i=0 ; i<2 ; i++) + for (int i=0 ; i<2 ; i++) { bmins[i] = (int)Math.floor(mins[i]/16); bmaxs[i] = (int)Math.ceil(maxs[i]/16); diff --git a/src/jake2/render/jogl/Warp.java b/src/jake2/render/jogl/Warp.java index 6dc5145..ba89fc6 100644 --- a/src/jake2/render/jogl/Warp.java +++ b/src/jake2/render/jogl/Warp.java @@ -2,7 +2,7 @@ * Warp.java * Copyright (C) 2003 * - * $Id: Warp.java,v 1.4 2004-07-09 06:50:48 hzi Exp $ + * $Id: Warp.java,v 1.5 2004-07-12 22:08:03 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -27,10 +27,7 @@ package jake2.render.jogl; import jake2.Defines; import jake2.Globals; -import jake2.game.GameBase; -import jake2.render.glpoly_t; -import jake2.render.image_t; -import jake2.render.msurface_t; +import jake2.render.*; import jake2.util.Math3D; import net.java.games.jogl.GL; @@ -117,13 +114,12 @@ public abstract class Warp extends Model { float[] maxs = {0, 0, 0}; float m; float[] v = {0, 0, 0}; - float[][] front = new float[64][3]; + float[][] front = new float[64][3]; float[][] back = new float[64][3]; int f, b; float[] dist = new float[64]; float frac; - glpoly_t poly; float s, t; float[] total = {0, 0, 0}; float total_s, total_t; @@ -192,7 +188,7 @@ public abstract class Warp extends Model { // poly = Hunk_Alloc (sizeof(glpoly_t) + ((numverts-4)+2) * VERTEXSIZE*sizeof(float)); // init polys - poly = new glpoly_t(numverts + 2); + glpoly_t poly = new glpoly_t(numverts + 2); poly.next = warpface.polys; warpface.polys = poly; -- cgit v1.2.3 From 192efd96bd58ae54cff4212915dd3c9278e181b3 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Tue, 13 Jul 2004 11:09:55 +0000 Subject: small optimizations --- src/jake2/client/CL_fx.java | 124 +++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 64 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/CL_fx.java b/src/jake2/client/CL_fx.java index 45e9fdd..529101b 100644 --- a/src/jake2/client/CL_fx.java +++ b/src/jake2/client/CL_fx.java @@ -2,7 +2,7 @@ * CL_fx.java * Copyright (C) 2004 * - * $Id: CL_fx.java,v 1.4 2004-07-08 20:56:50 hzi Exp $ + * $Id: CL_fx.java,v 1.5 2004-07-13 11:09:55 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -45,11 +45,10 @@ public class CL_fx extends CL_tent { float[] origin = { 0, 0, 0 }; float radius; float die; // stop lighting after this time - float decay; // drop this each second + //float decay; // drop this each second float minlight; // don't add when contributing less void clear() { - radius = - decay = die = minlight = color[0] = color[1] = color[2] = origin[0] = origin[1] = origin[2] = key = 0; + radius = minlight = color[0] = color[1] = color[2] = 0; } } @@ -100,24 +99,23 @@ public class CL_fx extends CL_tent { ================ */ static void RunLightStyles() { - int ofs; - int i; - clightstyle_t[] ls; + clightstyle_t ls; - ofs = cl.time / 100; + int ofs = cl.time / 100; if (ofs == lastofs) return; lastofs = ofs; - ls = cl_lightstyle; - for (i = 0; i < ls.length; i++) { - if (ls[i].length == 0) { - ls[i].value[0] = ls[i].value[1] = ls[i].value[2] = 1.0f; + + for (int i = 0; i < cl_lightstyle.length; i++) { + ls = cl_lightstyle[i]; + if (ls.length == 0) { + ls.value[0] = ls.value[1] = ls.value[2] = 1.0f; continue; } if (ls.length == 1) - ls[i].value[0] = ls[i].value[1] = ls[i].value[2] = ls[i].map[0]; + ls.value[0] = ls.value[1] = ls.value[2] = ls.map[0]; else - ls[i].value[0] = ls[i].value[1] = ls[i].value[2] = ls[i].map[ofs % ls[i].length]; + ls.value[0] = ls.value[1] = ls.value[2] = ls.map[ofs % ls.length]; } } @@ -143,12 +141,12 @@ public class CL_fx extends CL_tent { ================ */ static void AddLightStyles() { - int i; - clightstyle_t[] ls; + clightstyle_t ls; - ls = cl_lightstyle; - for (i = 0; i < ls.length; i++) - V.AddLightStyle(i, ls[i].value[0], ls[i].value[1], ls[i].value[2]); + for (int i = 0; i < cl_lightstyle.length; i++) { + ls = cl_lightstyle[i]; + V.AddLightStyle(i, ls.value[0], ls.value[1], ls.value[2]); + } } /* @@ -185,37 +183,38 @@ public class CL_fx extends CL_tent { */ static cdlight_t AllocDlight(int key) { int i; - cdlight_t[] dl; + cdlight_t dl; // first look for an exact key match - if (key != 0) { - dl = cl_dlights; + if (key != 0) { for (i = 0; i < MAX_DLIGHTS; i++) { - if (dl[i].key == key) { + dl = cl_dlights[i]; + if (dl.key == key) { //memset (dl, 0, sizeof(*dl)); - dl[i].clear(); - dl[i].key = key; - return dl[i]; + dl.clear(); + dl.key = key; + return dl; } } } // then look for anything else - dl = cl_dlights; for (i = 0; i < MAX_DLIGHTS; i++) { - if (dl[i].die < cl.time) { + dl = cl_dlights[i]; + if (dl.die < cl.time) { //memset (dl, 0, sizeof(*dl)); - dl[i].clear(); - dl[i].key = key; - return dl[i]; + dl.clear(); + dl.key = key; + return dl; } } //dl = &cl_dlights[0]; //memset (dl, 0, sizeof(*dl)); - dl[0].clear(); - dl[0].key = key; - return dl[0]; + dl = cl_dlights[0]; + dl.clear(); + dl.key = key; + return dl; } /* @@ -241,20 +240,20 @@ public class CL_fx extends CL_tent { =============== */ static void RunDLights() { - cdlight_t[] dl; + cdlight_t dl; - dl = cl_dlights; for (int i = 0; i < MAX_DLIGHTS; i++) { - if (dl[i].radius == 0.0f) + dl = cl_dlights[i]; + if (dl.radius == 0.0f) continue; - if (dl[i].die < cl.time) { - dl[i].radius = 0; + if (dl.die < cl.time) { + dl.radius = 0.0f; return; } - dl[i].radius -= cls.frametime * dl[i].decay; - if (dl[i].radius < 0) - dl[i].radius = 0; + //dl[i].radius -= cls.frametime * dl[i].decay; + //if (dl[i].radius < 0) + // dl[i].radius = 0; } } @@ -953,31 +952,31 @@ public class CL_fx extends CL_tent { =============== */ static void AddDLights() { - int i; - - cdlight_t[] dl = cl_dlights; + cdlight_t dl; // ===== // PGM if (vidref_val == VIDREF_GL) { - for (i = 0; i < MAX_DLIGHTS; i++) { - if (dl[i].radius == 0.0f) + for (int i = 0; i < MAX_DLIGHTS; i++) { + dl = cl_dlights[i]; + if (dl.radius == 0.0f) continue; - V.AddLight(dl[i].origin, dl[i].radius, dl[i].color[0], dl[i].color[1], dl[i].color[2]); + V.AddLight(dl.origin, dl.radius, dl.color[0], dl.color[1], dl.color[2]); } } else { - for (i = 0; i < MAX_DLIGHTS; i++) { - if (dl[i].radius == 0.0f) + for (int i = 0; i < MAX_DLIGHTS; i++) { + dl = cl_dlights[i]; + if (dl.radius == 0.0f) continue; // negative light in software. only black allowed - if ((dl[i].color[0] < 0) || (dl[i].color[1] < 0) || (dl[i].color[2] < 0)) { - dl[i].radius = - (dl[i].radius); - dl[i].color[0] = 1; - dl[i].color[1] = 1; - dl[i].color[2] = 1; + if ((dl.color[0] < 0) || (dl.color[1] < 0) || (dl.color[2] < 0)) { + dl.radius = - (dl.radius); + dl.color[0] = 1; + dl.color[1] = 1; + dl.color[2] = 1; } - V.AddLight(dl[i].origin, dl[i].radius, dl[i].color[0], dl[i].color[1], dl[i].color[2]); + V.AddLight(dl.origin, dl.radius, dl.color[0], dl.color[1], dl.color[2]); } } // PGM @@ -1507,18 +1506,15 @@ public class CL_fx extends CL_tent { static void DiminishingTrail(float[] start, float[] end, centity_t old, int flags) { float[] move = new float[3]; float[] vec = new float[3]; - float len; - int j; cparticle_t p; - float dec; float orgscale; float velscale; VectorCopy(start, move); VectorSubtract(end, start, vec); - len = VectorNormalize(vec); + float len = VectorNormalize(vec); - dec = 0.5f; + float dec = 0.5f; VectorScale(vec, dec, vec); if (old.trailcount > 900) { @@ -1552,7 +1548,7 @@ public class CL_fx extends CL_tent { p.alpha = 1.0f; p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); p.color = 0xe8 + (rand() & 7); - for (j = 0; j < 3; j++) { + for (int j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; p.accel[j] = 0; @@ -1562,7 +1558,7 @@ public class CL_fx extends CL_tent { p.alpha = 1.0f; p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f); p.color = 0xdb + (rand() & 7); - for (j = 0; j < 3; j++) { + for (int j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; p.accel[j] = 0; @@ -1572,7 +1568,7 @@ public class CL_fx extends CL_tent { p.alpha = 1.0f; p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f); p.color = 4 + (rand() & 7); - for (j = 0; j < 3; j++) { + for (int j = 0; j < 3; j++) { p.org[j] = move[j] + crand() * orgscale; p.vel[j] = crand() * velscale; } -- cgit v1.2.3 From 60f18a1c68322d078d3217710bf2a3d05678ecf8 Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Tue, 13 Jul 2004 11:20:28 +0000 Subject: experimental EAX2.0 support (today only win32 is supported) --- src/jake2/sound/joal/JOALSoundImpl.java | 137 ++++++++++++++++++++------------ src/jake2/sound/sfx_t.java | 17 ++-- 2 files changed, 91 insertions(+), 63 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/sound/joal/JOALSoundImpl.java b/src/jake2/sound/joal/JOALSoundImpl.java index 8a005ce..ff9f937 100644 --- a/src/jake2/sound/joal/JOALSoundImpl.java +++ b/src/jake2/sound/joal/JOALSoundImpl.java @@ -2,25 +2,26 @@ * JOALSoundImpl.java * Copyright (C) 2004 * - * $Id: JOALSoundImpl.java,v 1.1 2004-07-09 06:50:52 hzi Exp $ + * $Id: JOALSoundImpl.java,v 1.2 2004-07-13 11:20:28 cawe Exp $ */ package jake2.sound.joal; - import jake2.Defines; import jake2.Globals; import jake2.client.CL; import jake2.game.*; import jake2.qcommon.*; import jake2.sound.*; -import jake2.util.Math3D; -import jake2.util.Vargs; +import jake2.util.*; import java.io.IOException; import java.io.RandomAccessFile; +import java.nio.IntBuffer; import java.util.*; import net.java.games.joal.*; +import net.java.games.joal.eax.EAX; +import net.java.games.joal.eax.EAXFactory; /** * JOALSoundImpl @@ -33,6 +34,7 @@ public final class JOALSoundImpl implements Sound { static AL al; static ALC alc; + static EAX eax; cvar_t s_volume; @@ -42,11 +44,12 @@ public final class JOALSoundImpl implements Sound { private int[] buffers = new int[MAX_SFX]; private int[] sources = new int[MAX_CHANNELS]; private Channel[] channels = null; + private int num_channels = 0; + // singleton private JOALSoundImpl() { } - /* (non-Javadoc) * @see jake2.sound.SoundImpl#Init() */ @@ -56,19 +59,15 @@ public final class JOALSoundImpl implements Sound { initOpenAL(); al = ALFactory.getAL(); checkError(); + initOpenALExtensions(); } catch (OpenALException e) { Com.Printf(e.getMessage() + '\n'); return false; } - - checkError(); al.alGenBuffers(MAX_SFX, buffers); - al.alGenSources(MAX_CHANNELS, sources); - checkError(); s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); initChannels(); al.alDistanceModel(AL.AL_INVERSE_DISTANCE_CLAMPED); -// al.alDistanceModel(AL.AL_INVERSE_DISTANCE); Cmd.AddCommand("play", new xcommand_t() { public void execute() { Play(); @@ -124,6 +123,17 @@ public final class JOALSoundImpl implements Sound { } } + private void initOpenALExtensions() throws OpenALException { + if (al.alIsExtensionPresent("EAX2.0")) { + Com.Printf("... using EAX2.0\n"); + eax = EAXFactory.getEAX(); + } else { + Com.Printf("... EAX2.0 not found\n"); + eax = null; + } + } + + void exitOpenAL() { // Get the current context. ALC.Context curContext = alc.alcGetCurrentContext(); @@ -142,9 +152,20 @@ public final class JOALSoundImpl implements Sound { channels = new Channel[MAX_CHANNELS]; int sourceId; + int[] tmp = {0}; + int error; for (int i = 0; i < MAX_CHANNELS; i++) { - sourceId = sources[i]; + + al.alGenSources(1, tmp); + sourceId = tmp[0]; + + //if ((error = al.alGetError()) != AL.AL_NO_ERROR) break; + if (sourceId <= 0) break; + + sources[i] = sourceId; + channels[i] = new Channel(sourceId); + num_channels++; // set default values for AL sources al.alSourcef (sourceId, AL.AL_GAIN, s_volume.value); @@ -156,14 +177,14 @@ public final class JOALSoundImpl implements Sound { al.alSourcef (sourceId, AL.AL_MIN_GAIN, 0.0005f); al.alSourcef (sourceId, AL.AL_MAX_GAIN, 1.0f); } + Com.Printf("... using " + num_channels + " channels\n"); } /* (non-Javadoc) * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t) */ - private void initBuffer(sfx_t sfx) - { + private void initBuffer(sfx_t sfx) { if (sfx.cache == null ) { //System.out.println(sfx.name + " " + sfx.cache.length+ " " + sfx.cache.loopstart + " " + sfx.cache.speed + " " + sfx.cache.stereo + " " + sfx.cache.width); return; @@ -174,33 +195,17 @@ public final class JOALSoundImpl implements Sound { int freq = sfx.cache.speed; int size = data.length; -// if (buffers[sfx.id] != 0) -// al.alDeleteBuffers(1, new int[] {buffers[sfx.id] }); -// -// int[] bid = new int[1]; -// al.alBufferData( bid[0], format, data, size, freq); -// buffers[sfx.id] = bid[0]; -// al.alBufferData( bid[0], format, data, size, freq); - - al.alBufferData( buffers[sfx.id], format, data, size, freq); -// int error; -// if ((error = al.alGetError()) != AL.AL_NO_ERROR) { -// String message; -// switch(error) { -// case AL.AL_INVALID_OPERATION: message = "invalid operation"; break; -// case AL.AL_INVALID_VALUE: message = "invalid value"; break; -// case AL.AL_INVALID_ENUM: message = "invalid enum"; break; -// case AL.AL_INVALID_NAME: message = "invalid name"; break; -// default: message = "" + error; -// } -// Com.DPrintf("Error Buffer " + sfx.id + ": " + sfx.name + " (" + size + ") --> " + message + '\n'); -// } + al.alBufferData( buffers[sfx.bufferId], format, data, size, freq); } private void checkError() { + Com.DPrintf("AL Error: " + alErrorString() +'\n'); + } + + private String alErrorString(){ int error; + String message = ""; if ((error = al.alGetError()) != AL.AL_NO_ERROR) { - String message; switch(error) { case AL.AL_INVALID_OPERATION: message = "invalid operation"; break; case AL.AL_INVALID_VALUE: message = "invalid value"; break; @@ -208,11 +213,10 @@ public final class JOALSoundImpl implements Sound { case AL.AL_INVALID_NAME: message = "invalid name"; break; default: message = "" + error; } - Com.DPrintf("AL Error: " + message +'\n'); } + return message; } - /* (non-Javadoc) * @see jake2.sound.SoundImpl#Shutdown() */ @@ -221,7 +225,7 @@ public final class JOALSoundImpl implements Sound { al.alDeleteSources(sources.length, sources); al.alDeleteBuffers(buffers.length, buffers); exitOpenAL(); - //ALut.alutExit(); + Cmd.RemoveCommand("play"); Cmd.RemoveCommand("stopsound"); Cmd.RemoveCommand("soundlist"); @@ -234,6 +238,7 @@ public final class JOALSoundImpl implements Sound { known_sfx[i].clear(); } num_sfx = 0; + num_channels = 0; } private final static float[] NULLVECTOR = {0, 0, 0}; @@ -257,7 +262,7 @@ public final class JOALSoundImpl implements Sound { if (attenuation != Defines.ATTN_STATIC) attenuation *= 0.5f; - Channel ch = pickChannel(entnum, entchannel, buffers[sfx.id], attenuation); + Channel ch = pickChannel(entnum, entchannel, buffers[sfx.bufferId], attenuation); if (ch == null) return; @@ -276,7 +281,7 @@ public final class JOALSoundImpl implements Sound { int state; int i; - for (i = 0; i < MAX_CHANNELS; i++) { + for (i = 0; i < num_channels; i++) { ch = channels[i]; if (entchannel != 0 && ch.entnum == entnum && ch.entchannel == entchannel) { @@ -294,7 +299,7 @@ public final class JOALSoundImpl implements Sound { } } - if (i == MAX_CHANNELS) + if (i == num_channels) return null; ch.entnum = entnum; @@ -312,6 +317,15 @@ public final class JOALSoundImpl implements Sound { private float[] listenerOrigin = {0, 0, 0}; private float[] listenerOrientation = {0, 0, 0, 0, 0, 0}; + private IntBuffer eaxEnv = Lib.newIntBuffer(1); + private int currentEnv = -1; + private boolean changeEnv = true; + + // TODO workaround for JOAL-bug + // should be EAX.LISTENER + private final static int EAX_LISTENER = 0; + // should be EAX.SOURCE + private final static int EAX_SOURCE = 1; /* (non-Javadoc) * @see jake2.sound.SoundImpl#Update(float[], float[], float[], float[]) @@ -324,11 +338,32 @@ public final class JOALSoundImpl implements Sound { convertOrientation(forward, up, listenerOrientation); al.alListenerfv(AL.AL_ORIENTATION, listenerOrientation); + if (eax != null) { + // workaround for environment initialisation + if (currentEnv == -1) { + eaxEnv.put(0, EAX.EAX_ENVIRONMENT_UNDERWATER); + eax.EAXSet(EAX_LISTENER, EAX.DSPROPERTY_EAXLISTENER_ENVIRONMENT | EAX.DSPROPERTY_EAXLISTENER_DEFERRED, 0, eaxEnv, 4); + changeEnv = true; + } + + if ((Game.gi.pointcontents.pointcontents(origin)& Defines.MASK_WATER)!= 0) { + changeEnv = currentEnv != EAX.EAX_ENVIRONMENT_UNDERWATER; + currentEnv = EAX.EAX_ENVIRONMENT_UNDERWATER; + } else { + changeEnv = currentEnv != EAX.EAX_ENVIRONMENT_GENERIC; + currentEnv = EAX.EAX_ENVIRONMENT_GENERIC; + } + if (changeEnv) { + eaxEnv.put(0, currentEnv); + eax.EAXSet(EAX_LISTENER, EAX.DSPROPERTY_EAXLISTENER_ENVIRONMENT | EAX.DSPROPERTY_EAXLISTENER_DEFERRED, 0, eaxEnv, 4); + } + } + AddLoopSounds(origin); playChannels(listenerOrigin); } - Map looptable = new Hashtable(2 * MAX_CHANNELS); + Map looptable = new Hashtable(MAX_CHANNELS); /* ================== @@ -390,7 +425,7 @@ public final class JOALSoundImpl implements Sound { continue; // allocate a channel - ch = pickChannel(0, 0, buffers[sfx.id], 6); + ch = pickChannel(0, 0, buffers[sfx.bufferId], 6); if (ch == null) break; @@ -427,7 +462,7 @@ public final class JOALSoundImpl implements Sound { int sourceId; int state; - for (int i = 0; i < MAX_CHANNELS; i++) { + for (int i = 0; i < num_channels; i++) { ch = channels[i]; if (ch.active) { sourceId = ch.sourceId; @@ -466,13 +501,12 @@ public final class JOALSoundImpl implements Sound { } } } - /* (non-Javadoc) * @see jake2.sound.SoundImpl#StopAllSounds() */ public void StopAllSounds() { - for (int i = 0; i < MAX_CHANNELS; i++) { + for (int i = 0; i < num_channels; i++) { al.alSourceStop(sources[i]); al.alSourcei(sources[i], AL.AL_BUFFER, 0); channels[i].clear(); @@ -561,6 +595,7 @@ public final class JOALSoundImpl implements Sound { sfx_t sfx = null; // determine what model the client is using + // TODO configstrings for player male and female are wrong String model = "male"; int n = Globals.CS_PLAYERSKINS + ent.number - 1; if (Globals.cl.configstrings[n] != null) { @@ -597,13 +632,10 @@ public final class JOALSoundImpl implements Sound { sfx = RegisterSound(sexedFilename); } else { // no, revert to the male sound in the pak0.pak - //Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1); String maleFilename = "player/male/" + base.substring(1); sfx = AliasName(sexedFilename, maleFilename); } } - - //System.out.println(sfx.name); return sfx; } @@ -652,8 +684,7 @@ public final class JOALSoundImpl implements Sound { sfx.clear(); sfx.name = name; sfx.registration_sequence = s_registration_sequence; - // cwei - sfx.id = i; + sfx.bufferId = i; return sfx; } @@ -689,8 +720,8 @@ public final class JOALSoundImpl implements Sound { sfx.name = new String(aliasname); sfx.registration_sequence = s_registration_sequence; sfx.truename = s; - // cwei - sfx.id = i; + // set the AL bufferId + sfx.bufferId = i; return sfx; } diff --git a/src/jake2/sound/sfx_t.java b/src/jake2/sound/sfx_t.java index 992c0e7..00748e8 100644 --- a/src/jake2/sound/sfx_t.java +++ b/src/jake2/sound/sfx_t.java @@ -2,7 +2,7 @@ * sfx_t.java * Copyright (C) 2004 * - * $Id: sfx_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $ + * $Id: sfx_t.java,v 1.2 2004-07-13 11:20:27 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,22 +28,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.sound; - public class sfx_t { - public String name; //mem + public String name; public int registration_sequence; - public sfxcache_t cache; //ptr - public String truename; //ptr + public sfxcache_t cache; + public String truename; - // cwei - public int id = -1; + // is used for AL buffers + public int bufferId = -1; public void clear() { name = truename = null; cache = null; registration_sequence = 0; - - // cwei - id = -1; + bufferId = -1; } } -- cgit v1.2.3 From e45462dfe3f3db94bf9668d294794c27909a522f Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Wed, 14 Jul 2004 15:34:24 +0000 Subject: deprecated java.util.Date replaced --- src/jake2/game/GameMiscAdapters.java | 8 ++++---- src/jake2/server/SV_CCMDS.java | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/game/GameMiscAdapters.java b/src/jake2/game/GameMiscAdapters.java index 56aba1a..cfbe2e4 100644 --- a/src/jake2/game/GameMiscAdapters.java +++ b/src/jake2/game/GameMiscAdapters.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 26.02.2004 by RST. -// $Id: GameMiscAdapters.java,v 1.2 2004-07-08 20:24:29 hzi Exp $ +// $Id: GameMiscAdapters.java,v 1.3 2004-07-14 15:34:24 cawe Exp $ package jake2.game; @@ -29,7 +29,7 @@ import jake2.client.M; import jake2.util.Lib; import jake2.util.Math3D; -import java.util.Date; +import java.util.Calendar; public class GameMiscAdapters { @@ -878,8 +878,8 @@ public class GameMiscAdapters } else { - Date d = new Date(); - self.message = "" + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(); + Calendar c = Calendar.getInstance(); + self.message = "" + c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND); /* struct tm * ltime; diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java index 76e348d..f890cab 100644 --- a/src/jake2/server/SV_CCMDS.java +++ b/src/jake2/server/SV_CCMDS.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.01.2004 by RST. -// $Id: SV_CCMDS.java,v 1.3 2004-07-09 06:50:49 hzi Exp $ +// $Id: SV_CCMDS.java,v 1.4 2004-07-14 15:34:24 cawe Exp $ package jake2.server; @@ -32,7 +32,7 @@ import jake2.util.Lib; import jake2.util.Vargs; import java.io.*; -import java.util.Date; +import java.util.Calendar; public class SV_CCMDS extends SV_ENTS { @@ -433,11 +433,15 @@ public class SV_CCMDS extends SV_ENTS { if (!autosave) { //time( aclock); //newtime = localtime( aclock); - Date newtime = new Date(); + Calendar c = Calendar.getInstance(); comment = Com.sprintf( "%2i:%2i %2i/%2i ", - new Vargs().add(newtime.getHours()).add(newtime.getMinutes()).add(newtime.getMonth() + 1).add(newtime.getDay())); + new Vargs() + .add(c.get(Calendar.HOUR_OF_DAY)) + .add(c.get(Calendar.MINUTE)) + .add(c.get(Calendar.MONTH) + 1) + .add(c.get(Calendar.DAY_OF_MONTH))); comment += sv.configstrings[CS_NAME]; } else { // autosaved -- cgit v1.2.3 From 3dd339c9572b792b85bd49182c826aaec36ee161 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Thu, 15 Jul 2004 14:37:35 +0000 Subject: show fullscreen modes in video menu move common renderer code to JoglBase --- src/jake2/client/VID.java | 106 ++++++---- src/jake2/client/refexport_t.java | 5 +- src/jake2/render/FastJoglRenderer.java | 10 +- src/jake2/render/JoglBase.java | 370 +++++++++++++++++++++++++++++++++ src/jake2/render/JoglRenderer.java | 8 +- src/jake2/render/fastjogl/Base.java | 11 +- src/jake2/render/fastjogl/Draw.java | 4 +- src/jake2/render/fastjogl/Impl.java | 343 ------------------------------ src/jake2/render/fastjogl/Main.java | 46 +--- src/jake2/render/jogl/Base.java | 11 +- src/jake2/render/jogl/Draw.java | 4 +- src/jake2/render/jogl/Impl.java | 343 ------------------------------ src/jake2/render/jogl/Main.java | 52 +---- 13 files changed, 471 insertions(+), 842 deletions(-) create mode 100644 src/jake2/render/JoglBase.java delete mode 100644 src/jake2/render/fastjogl/Impl.java delete mode 100644 src/jake2/render/jogl/Impl.java (limited to 'src/jake2') diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java index b18683b..0eec17a 100644 --- a/src/jake2/client/VID.java +++ b/src/jake2/client/VID.java @@ -2,7 +2,7 @@ * VID.java * Copyright (C) 2003 * - * $Id: VID.java,v 1.5 2004-07-09 06:50:50 hzi Exp $ + * $Id: VID.java,v 1.6 2004-07-15 14:37:35 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -37,6 +37,7 @@ import jake2.sys.KBD; import jake2.util.Vargs; import java.awt.Dimension; +import java.awt.DisplayMode; /** * VID is a video driver. @@ -85,12 +86,6 @@ public class VID extends Globals { Com.DPrintf(fmt, vargs); } - public static void Error(int err_level, String fmt, Vargs vargs) - { - //static qboolean inupdate; - Com.Error(err_level, fmt, vargs); - } - // ========================================================================== /* @@ -123,15 +118,17 @@ public class VID extends Globals { new vidmode_t("Mode 8: 1280x1024", 1280, 1024, 8), new vidmode_t("Mode 9: 1600x1200", 1600, 1200, 9), new vidmode_t("Mode 10: 2048x1536", 2048, 1536, 10)}; - - static final int NUM_MODES = vid_modes.length; + static vidmode_t fs_modes[]; public static boolean GetModeInfo(Dimension dim, int mode) { - if (mode < 0 || mode >= NUM_MODES) + vidmode_t[] modes = vid_modes; + if (vid_fullscreen.value != 0.0f) modes = fs_modes; + + if (mode < 0 || mode >= modes.length) return false; - dim.width = vid_modes[mode].width; - dim.height = vid_modes[mode].height; + dim.width = modes[mode].width; + dim.height = modes[mode].height; return true; } @@ -191,11 +188,11 @@ public class VID extends Globals { Com.Printf( "LoadLibrary(\"" + name +"\")\n" ); refimport_t ri = new refimport_t() { public void Sys_Error(int err_level, String str) { - VID.Error(err_level, str, null); + Com.Error(err_level, str, null); } public void Sys_Error(int err_level, String str, Vargs vargs) { - VID.Error(err_level, str, vargs); + Com.Error(err_level, str, vargs); } public void Cmd_AddCommand(String name, xcommand_t cmd) { @@ -280,12 +277,6 @@ public class VID extends Globals { Com.Error(Defines.ERR_FATAL, name + " has incompatible api_version"); } - /* Init IN (Mouse) */ -// in_state.IN_CenterView_fp = IN_CenterView; -// in_state.Key_Event_fp = Do_Key_Event; -// in_state.viewangles = cl.viewangles; -// in_state.in_strafe_state = &in_strafe.state; - IN.Real_IN_Init(); if ( !Globals.re.Init((int)vid_xpos.value, (int)vid_ypos.value) ) @@ -413,19 +404,8 @@ public class VID extends Globals { // // ========================================================================== -// #define REF_SOFT 0 -// #define REF_SOFTX11 1 -// #define REF_MESA3D 2 -// #define REF_3DFXGL 3 -// #define REF_OPENGLX 4 static final int REF_OPENGL_JOGL = 0; static final int REF_OPENGL_FASTJOGL =1; -// #define REF_MESA3DGLX 5 - -// extern cvar_t *vid_ref; -// extern cvar_t *vid_fullscreen; -// extern cvar_t *vid_gamma; -// extern cvar_t *scr_viewsize; static cvar_t gl_mode; static cvar_t gl_driver; @@ -632,6 +612,10 @@ public class VID extends Globals { "[2048 1536]", null }; + static String[] fs_resolutions; + static int last_fs; + static int last_win; + static final String[] refs = { // "[software ]", @@ -651,13 +635,37 @@ public class VID extends Globals { null }; + static void initModeList() { + DisplayMode[] modes = re.getModeList(); + fs_resolutions = new String[modes.length + 1]; + fs_modes = new vidmode_t[modes.length]; + for (int i = 0; i < modes.length; i++) { + DisplayMode m = modes[i]; + StringBuffer sb = new StringBuffer(18); + sb.append('['); + sb.append(m.getWidth()); + sb.append(' '); + sb.append(m.getHeight()); + while (sb.length() < 10) sb.append(' '); + sb.append(']'); + fs_resolutions[i] = sb.toString(); + sb.setLength(0); + sb.append("Mode "); + sb.append(i); + sb.append(':'); + sb.append(m.getWidth()); + sb.append('x'); + sb.append(m.getHeight()); + fs_modes[i] = new vidmode_t(sb.toString(), m.getWidth(), m.getHeight(), i); + } + } + /* ** VID_MenuInit */ - public static void MenuInit() - { - int i; - + public static void MenuInit() { + if (fs_resolutions == null) initModeList(); + if ( gl_driver == null ) gl_driver = Cvar.Get( "gl_driver", "jogl", 0 ); if ( gl_picmip == null ) @@ -677,6 +685,19 @@ public class VID extends Globals { s_mode_list[SOFTWARE_MENU].curvalue = (int)sw_mode.value; s_mode_list[OPENGL_MENU].curvalue = (int)gl_mode.value; + if (vid_fullscreen.value != 0.0f) { + s_mode_list[OPENGL_MENU].itemnames = fs_resolutions; + if (s_mode_list[OPENGL_MENU].curvalue >= fs_resolutions.length - 1) { + s_mode_list[OPENGL_MENU].curvalue = 0; + } + last_fs = s_mode_list[OPENGL_MENU].curvalue; + } else { + s_mode_list[OPENGL_MENU].itemnames = resolutions; + if (s_mode_list[OPENGL_MENU].curvalue >= resolutions.length - 1) { + s_mode_list[OPENGL_MENU].curvalue = 0; + } + last_win = s_mode_list[OPENGL_MENU].curvalue; + } if ( SCR.scr_viewsize == null ) SCR.scr_viewsize = Cvar.Get ("viewsize", "100", CVAR_ARCHIVE); @@ -726,7 +747,7 @@ public class VID extends Globals { s_opengl_menu.x = (int)(viddef.width * 0.50f); s_opengl_menu.nitems = 0; - for ( i = 0; i < 2; i++ ) + for (int i = 0; i < 2; i++ ) { s_ref_list[i].type = MTYPE_SPINCONTROL; s_ref_list[i].name = "driver"; @@ -743,7 +764,6 @@ public class VID extends Globals { s_mode_list[i].name = "video mode"; s_mode_list[i].x = 0; s_mode_list[i].y = 10; - s_mode_list[i].itemnames = resolutions; s_screensize_slider[i].type = MTYPE_SLIDER; s_screensize_slider[i].x = 0; @@ -775,6 +795,18 @@ public class VID extends Globals { s_fs_box[i].name = "fullscreen"; s_fs_box[i].itemnames = yesno_names; s_fs_box[i].curvalue = (int)vid_fullscreen.value; + s_fs_box[i].callback = new Menu.mcallback() { + public void execute(Object o) { + int fs = ((Menu.menulist_s)o).curvalue; + if (fs == 0) { + s_mode_list[1].itemnames = resolutions; + s_mode_list[1].curvalue = last_win; + } else { + s_mode_list[1].itemnames = fs_resolutions; + s_mode_list[1].curvalue = last_fs; + } + } + }; s_defaults_action[i].type = MTYPE_ACTION; s_defaults_action[i].name = "reset to default"; diff --git a/src/jake2/client/refexport_t.java b/src/jake2/client/refexport_t.java index d1872c9..340a8c0 100644 --- a/src/jake2/client/refexport_t.java +++ b/src/jake2/client/refexport_t.java @@ -2,7 +2,7 @@ * refexport_t.java * Copyright (C) 2003 * - * $Id: refexport_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $ + * $Id: refexport_t.java,v 1.2 2004-07-15 14:37:35 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -31,6 +31,7 @@ import jake2.render.image_t; import jake2.render.model_t; import java.awt.Dimension; +import java.awt.DisplayMode; /** * refexport_t @@ -104,4 +105,6 @@ public interface refexport_t { void updateScreen(xcommand_t callback); int apiVersion(); + + DisplayMode[] getModeList(); } diff --git a/src/jake2/render/FastJoglRenderer.java b/src/jake2/render/FastJoglRenderer.java index da20bfd..56ab03b 100644 --- a/src/jake2/render/FastJoglRenderer.java +++ b/src/jake2/render/FastJoglRenderer.java @@ -2,7 +2,7 @@ * FastJoglRenderer.java * Copyright (C) 2003 * - * $Id: FastJoglRenderer.java,v 1.1 2004-07-09 06:50:47 hzi Exp $ + * $Id: FastJoglRenderer.java,v 1.2 2004-07-15 14:37:35 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,7 +28,7 @@ package jake2.render; import jake2.Defines; import jake2.client.*; import jake2.qcommon.xcommand_t; -import jake2.render.fastjogl.Impl; +import jake2.render.fastjogl.Misc; import java.awt.Dimension; @@ -37,8 +37,10 @@ import java.awt.Dimension; * * @author cwei */ -final class FastJoglRenderer extends Impl implements refexport_t, Ref { - +final class FastJoglRenderer extends Misc implements refexport_t, Ref { + + public static final String DRIVER_NAME = "fastjogl"; + static { Renderer.register(new FastJoglRenderer()); }; diff --git a/src/jake2/render/JoglBase.java b/src/jake2/render/JoglBase.java new file mode 100644 index 0000000..5477229 --- /dev/null +++ b/src/jake2/render/JoglBase.java @@ -0,0 +1,370 @@ +/* + * JoglCommon.java + * Copyright (C) 2004 + * + * $Id: JoglBase.java,v 1.1 2004-07-15 14:37:34 hzi Exp $ + */ +/* +Copyright (C) 1997-2001 Id Software, Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +package jake2.render; + +import jake2.Defines; +import jake2.client.refimport_t; +import jake2.client.viddef_t; +import jake2.game.cvar_t; +import jake2.qcommon.xcommand_t; +import jake2.sys.KBD; + +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.LinkedList; + +import javax.swing.JFrame; + +import net.java.games.jogl.*; +import net.java.games.jogl.util.GLUT; + +/** + * JoglCommon + */ +public abstract class JoglBase implements GLEventListener { + + // IMPORTED FUNCTIONS + protected refimport_t ri = null; + + protected GraphicsDevice device; + protected DisplayMode oldDisplayMode; + protected GLCanvas canvas; + JFrame window; + + protected GL gl; + protected GLU glu; + protected GLUT glut = new GLUT(); + + // window position on the screen + int window_xpos, window_ypos; + protected viddef_t vid = new viddef_t(); + + // handles the post initialization with JoglRenderer + protected boolean post_init = false; + protected boolean contextInUse = false; + protected abstract boolean R_Init2(); + + protected final xcommand_t INIT_CALLBACK = new xcommand_t() { + public void execute() { + // only used for the first run (initialization) + // clear the screen + gl.glClearColor(0, 0, 0, 0); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + // + // check the post init process + // + if (!post_init) { + ri.Con_Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n"); + } + + GLimp_EndFrame(); + } + }; + protected xcommand_t callback = INIT_CALLBACK; + + protected cvar_t vid_fullscreen; + + // enum rserr_t + protected static final int rserr_ok = 0; + protected static final int rserr_invalid_fullscreen = 1; + protected static final int rserr_invalid_mode = 2; + protected static final int rserr_unknown = 3; + + public DisplayMode[] getModeList() { + DisplayMode[] modes = device.getDisplayModes(); + LinkedList l = new LinkedList(); + l.add(oldDisplayMode); + + for (int i = 0; i < modes.length; i++) { + DisplayMode m = modes[i]; + + if (m.getBitDepth() != oldDisplayMode.getBitDepth()) continue; + if (m.getRefreshRate() > oldDisplayMode.getRefreshRate()) continue; + + int j = 0; + DisplayMode ml = null; + for (j = 0; j < l.size(); j++) { + ml = (DisplayMode)l.get(j); + if (ml.getWidth() >= m.getWidth()) break; + } + if (j == l.size()) { + l.addLast(m); + } else if (ml.getWidth() > m.getWidth()) { + l.add(j, m); + } else if (m.getRefreshRate() > ml.getRefreshRate()){ + l.remove(j); + l.add(j, m); + } + } + DisplayMode[] ma = new DisplayMode[l.size()]; + l.toArray(ma); + return ma; + } + + DisplayMode findDisplayMode(Dimension dim) { + DisplayMode mode = null; + DisplayMode m = null; + DisplayMode[] modes = getModeList(); + int w = dim.width; + int h = dim.height; + + for (int i = 0; i < modes.length; i++) { + m = modes[i]; + if (m.getWidth() == w) { + mode = m; + break; + } + } + if (mode == null) mode = oldDisplayMode; + return mode; + } + + String getModeString(DisplayMode m) { + StringBuffer sb = new StringBuffer(); + sb.append(m.getWidth()); + sb.append('x'); + sb.append(m.getHeight()); + sb.append('x'); + sb.append(m.getBitDepth()); + sb.append('@'); + sb.append(m.getRefreshRate()); + sb.append("Hz"); + return sb.toString(); + } + + /** + * @param dim + * @param mode + * @param fullscreen + * @return enum rserr_t + */ + protected int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) { + + Dimension newDim = new Dimension(); + + ri.Con_Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); + + ri.Con_Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); + + if (!ri.Vid_GetModeInfo(newDim, mode)) { + ri.Con_Printf(Defines.PRINT_ALL, " invalid mode\n"); + return rserr_invalid_mode; + } + + ri.Con_Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); + + // destroy the existing window + GLimp_Shutdown(); + + window = new JFrame("Jake2"); + + GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities()); + + // TODO Use debug pipeline + //canvas.setGL(new DebugGL(canvas.getGL())); + + canvas.setNoAutoRedrawMode(true); + canvas.addGLEventListener(this); + + //window.getContentPane().add(canvas); + + //canvas.setSize(newDim.width, newDim.height); + + // register event listener + window.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + ri.Cmd_ExecuteText(Defines.EXEC_APPEND, "quit"); + } + }); + + // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G + window.addComponentListener(KBD.listener); + canvas.addKeyListener(KBD.listener); + canvas.addMouseListener(KBD.listener); + canvas.addMouseMotionListener(KBD.listener); + + /* + * fullscreen handling + */ + GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); + device = env.getDefaultScreenDevice(); + + if (oldDisplayMode == null) { + oldDisplayMode = device.getDisplayMode(); + } + + if (fullscreen) { + + DisplayMode displayMode = findDisplayMode(newDim); + + newDim.width = displayMode.getWidth(); + newDim.height = displayMode.getHeight(); + window.setUndecorated(true); + window.setSize(displayMode.getWidth(), displayMode.getHeight()); + window.setResizable(false); + window.getContentPane().add(canvas); + + device.setFullScreenWindow(window); + + if (!displayMode.equals(oldDisplayMode)) + device.setDisplayMode(displayMode); + + window.setLocation(0, 0); + ri.Con_Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); + + } else { + window.setLocation(window_xpos, window_ypos); + window.setSize(newDim.width, newDim.height); + window.setResizable(false); + window.getContentPane().add(canvas); + window.setVisible(true); + } + + while (!canvas.isDisplayable()) { + try { + Thread.sleep(50); + } catch (InterruptedException e) {} + } + canvas.requestFocus(); + + this.canvas = canvas; + + vid.width = newDim.width; + vid.height = newDim.height; + + // let the sound and input subsystems know about the new window + ri.Vid_NewWindow(vid.width, vid.height); + + return rserr_ok; + } + + protected void GLimp_Shutdown() { + if (oldDisplayMode != null && device.getFullScreenWindow() != null) { + try { + if (!device.getDisplayMode().equals(oldDisplayMode)) + device.setDisplayMode(oldDisplayMode); + device.setFullScreenWindow(null); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (this.window != null) { + window.dispose(); + } + post_init = false; + callback = INIT_CALLBACK; + } + + /** + * @return true + */ + protected boolean GLimp_Init(int xpos, int ypos) { + // do nothing + window_xpos = xpos; + window_ypos = ypos; + return true; + } + + protected void GLimp_EndFrame() { + gl.glFlush(); + // swap buffer + // but jogl has no method to swap + } + protected void GLimp_BeginFrame(float camera_separation) { + // do nothing + } + + protected void GLimp_AppActivate(boolean activate) { + // do nothing + } + + protected void GLimp_EnableLogging(boolean enable) { + // doesn't need jogl logging + // do nothing + } + + protected void GLimp_LogNewFrame() { + // doesn't need jogl logging + // do nothing + } + + /* + * @see jake2.client.refexport_t#updateScreen() + */ + public void updateScreen() { + this.callback = INIT_CALLBACK; + canvas.display(); + } + + public void updateScreen(xcommand_t callback) { + this.callback = callback; + canvas.display(); + } + // ============================================================================ + // GLEventListener interface + // ============================================================================ + + /* + * @see net.java.games.jogl.GLEventListener#init(net.java.games.jogl.GLDrawable) + */ + public void init(GLDrawable drawable) { + this.gl = drawable.getGL(); + this.glu = drawable.getGLU(); + + // this is a hack to run R_init() in gl context + post_init = R_Init2(); + } + + /* + * @see net.java.games.jogl.GLEventListener#display(net.java.games.jogl.GLDrawable) + */ + public void display(GLDrawable drawable) { + this.gl = drawable.getGL(); + this.glu = drawable.getGLU(); + + contextInUse = true; + callback.execute(); + contextInUse = false; + } + + /* + * @see net.java.games.jogl.GLEventListener#displayChanged(net.java.games.jogl.GLDrawable, boolean, boolean) + */ + public void displayChanged(GLDrawable drawable, boolean arg1, boolean arg2) { + // do nothing + } + + /* + * @see net.java.games.jogl.GLEventListener#reshape(net.java.games.jogl.GLDrawable, int, int, int, int) + */ + public void reshape(GLDrawable drawable, int x, int y, int width, int height) { + // do nothing + } + +} diff --git a/src/jake2/render/JoglRenderer.java b/src/jake2/render/JoglRenderer.java index 97e3967..6e0926b 100644 --- a/src/jake2/render/JoglRenderer.java +++ b/src/jake2/render/JoglRenderer.java @@ -2,7 +2,7 @@ * JoglRenderer.java * Copyright (C) 2003 * - * $Id: JoglRenderer.java,v 1.3 2004-07-09 06:50:47 hzi Exp $ + * $Id: JoglRenderer.java,v 1.4 2004-07-15 14:37:35 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,7 +28,7 @@ package jake2.render; import jake2.Defines; import jake2.client.*; import jake2.qcommon.xcommand_t; -import jake2.render.jogl.Impl; +import jake2.render.jogl.Misc; import java.awt.Dimension; @@ -37,7 +37,9 @@ import java.awt.Dimension; * * @author cwei */ -final class JoglRenderer extends Impl implements refexport_t, Ref { +final class JoglRenderer extends Misc implements refexport_t, Ref { + + public static final String DRIVER_NAME = "jogl"; static { Renderer.register(new JoglRenderer()); diff --git a/src/jake2/render/fastjogl/Base.java b/src/jake2/render/fastjogl/Base.java index c5cc690..563b16a 100644 --- a/src/jake2/render/fastjogl/Base.java +++ b/src/jake2/render/fastjogl/Base.java @@ -2,7 +2,7 @@ * Base.java * Copyright (C) 2003 * - * $Id: Base.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Base.java,v 1.2 2004-07-15 14:37:33 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.fastjogl; +import jake2.render.JoglBase; import net.java.games.jogl.GL; /** @@ -32,7 +33,7 @@ import net.java.games.jogl.GL; * * @author cwei */ -public class Base { +public abstract class Base extends JoglBase { static final int GL_COLOR_INDEX8_EXT = GL.GL_COLOR_INDEX; static final String REF_VERSION = "GL 0.01"; @@ -75,12 +76,6 @@ public class Base { // =================================================================== - // enum rserr_t - static final int rserr_ok = 0; - static final int rserr_invalid_fullscreen = 1; - static final int rserr_invalid_mode = 2; - static final int rserr_unknown = 3; - // // #include "gl_model.h" // diff --git a/src/jake2/render/fastjogl/Draw.java b/src/jake2/render/fastjogl/Draw.java index fcb48b6..0309dba 100644 --- a/src/jake2/render/fastjogl/Draw.java +++ b/src/jake2/render/fastjogl/Draw.java @@ -2,7 +2,7 @@ * Draw.java * Copyright (C) 2003 * - * $Id: Draw.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Draw.java,v 1.2 2004-07-15 14:37:33 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -26,13 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render.fastjogl; import jake2.Defines; -import jake2.Globals; import jake2.render.image_t; import java.awt.Dimension; import net.java.games.jogl.GL; -import net.java.games.jogl.util.GLUT; /** * Draw diff --git a/src/jake2/render/fastjogl/Impl.java b/src/jake2/render/fastjogl/Impl.java deleted file mode 100644 index 03af496..0000000 --- a/src/jake2/render/fastjogl/Impl.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Impl.java - * Copyright (C) 2003 - * - * $Id: Impl.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ - */ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -package jake2.render.fastjogl; - -import jake2.Defines; -import jake2.Globals; -import jake2.qcommon.Com; -import jake2.qcommon.xcommand_t; -import jake2.sys.KBD; - -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import javax.swing.JFrame; - -import net.java.games.jogl.*; - -/** - * Impl - * - * @author cwei - */ -public class Impl extends Misc implements GLEventListener { - - public static final String DRIVER_NAME = "fastjogl"; - - // handles the post initialization with JoglRenderer - protected boolean post_init = false; - - private final xcommand_t INIT_CALLBACK = new xcommand_t() { - public void execute() { - // only used for the first run (initialization) - // clear the screen - gl.glClearColor(0, 0, 0, 0); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - - // - // check the post init process - // - if (!post_init) { - ri.Con_Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n"); - } - - GLimp_EndFrame(); - } - }; - - private xcommand_t callback = INIT_CALLBACK; - protected boolean contextInUse = false; - - private GraphicsDevice device; - private DisplayMode oldDisplayMode; - - GLCanvas canvas; - JFrame window; - - // window position on the screen - int window_xpos, window_ypos; - - /** - * @return true - */ - boolean GLimp_Init(int xpos, int ypos) { - // do nothing - window_xpos = xpos; - window_ypos = ypos; - return true; - } - - /** - * @param dim - * @param mode - * @param fullscreen - * @return enum rserr_t - */ - int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) { - - Dimension newDim = new Dimension(); - - ri.Cvar_Get("r_fakeFullscreen", "0", Globals.CVAR_ARCHIVE); - - ri.Con_Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); - - ri.Con_Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); - - if (!ri.Vid_GetModeInfo(newDim, mode)) { - ri.Con_Printf(Defines.PRINT_ALL, " invalid mode\n"); - return rserr_invalid_mode; - } - - ri.Con_Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); - - // destroy the existing window - GLimp_Shutdown(); - - window = new JFrame("Jake2"); - - GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities()); - - // TODO Use debug pipeline - //canvas.setGL(new DebugGL(canvas.getGL())); - - canvas.setNoAutoRedrawMode(true); - canvas.addGLEventListener(this); - - window.getContentPane().add(canvas); - - canvas.setSize(newDim.width, newDim.height); - - // register event listener - window.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - ri.Cmd_ExecuteText(Defines.EXEC_APPEND, "quit"); - } - }); - - // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G - window.addComponentListener(KBD.listener); - canvas.addKeyListener(KBD.listener); - canvas.addMouseListener(KBD.listener); - canvas.addMouseMotionListener(KBD.listener); - - /* - * fullscreen handling - */ - GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); - device = env.getDefaultScreenDevice(); - - if (fullscreen && !device.isFullScreenSupported()) { - ri.Con_Printf(Defines.PRINT_ALL, "...fullscreen not supported\n"); - vid_fullscreen.value = 0; - vid_fullscreen.modified = false; - } - - fullscreen = fullscreen && device.isFullScreenSupported(); - - if (oldDisplayMode == null) { - oldDisplayMode = device.getDisplayMode(); - } - - if (fullscreen) { - - DisplayMode displayMode = findDisplayMode(newDim, oldDisplayMode.getBitDepth(), oldDisplayMode.getRefreshRate()); - - if (displayMode != null) { - newDim.width = displayMode.getWidth(); - newDim.height = displayMode.getHeight(); - window.setUndecorated(true); - window.setResizable(false); - device.setFullScreenWindow(window); - device.setDisplayMode(displayMode); - window.setLocation(0, 0); - window.setSize(displayMode.getWidth(), displayMode.getHeight()); - canvas.setSize(displayMode.getWidth(), displayMode.getHeight()); - ri.Con_Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); - } - } else { - window.setLocation(window_xpos, window_ypos); - window.pack(); - window.setResizable(false); - window.setVisible(true); - } - - while (!canvas.isDisplayable()) { - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - } - canvas.requestFocus(); - - this.canvas = canvas; - - vid.width = newDim.width; - vid.height = newDim.height; - - // let the sound and input subsystems know about the new window - ri.Vid_NewWindow(vid.width, vid.height); - - return rserr_ok; - } - - DisplayMode findDisplayMode(Dimension dim, int depth, int rate) { - DisplayMode mode = null; - DisplayMode m = null; - DisplayMode[] modes = device.getDisplayModes(); - int w = dim.width; - int h = dim.height; - - for (int i = 0; i < modes.length; i++) { - m = modes[i]; - if (m.getWidth() == w && m.getHeight() == h && m.getBitDepth() == depth && m.getRefreshRate() == rate) { - mode = m; - break; - } - } - if (mode == null) mode = oldDisplayMode; - Com.Printf(getModeString(mode) + '\n'); - return mode; - } - - String getModeString(DisplayMode m) { - StringBuffer sb = new StringBuffer(); - sb.append(m.getWidth()); - sb.append('x'); - sb.append(m.getHeight()); - sb.append('x'); - sb.append(m.getBitDepth()); - sb.append('@'); - sb.append(m.getRefreshRate()); - sb.append("Hz"); - return sb.toString(); - } - - void GLimp_BeginFrame(float camera_separation) { - // do nothing - } - - protected void GLimp_EndFrame() { - gl.glFlush(); - // swap buffer - // but jogl has no method to swap - } - - protected void GLimp_AppActivate(boolean activate) { - // do nothing - } - - boolean QGL_Init(String dll_name) { - // doesn't need libGL.so or .dll loading - return true; - } - - void QGL_Shutdown() { - // doesn't need libGL.so or .dll loading - // do nothing - } - - void GLimp_Shutdown() { - if (oldDisplayMode != null && device.getFullScreenWindow() != null) { - try { - device.setDisplayMode(oldDisplayMode); - device.setFullScreenWindow(null); - } catch (Exception e) { - e.printStackTrace(); - } - } - if (this.window != null) { - window.dispose(); - } - post_init = false; - callback = INIT_CALLBACK; - } - - void GLimp_EnableLogging(boolean enable) { - // doesn't need jogl logging - // do nothing - } - - void GLimp_LogNewFrame() { - // doesn't need jogl logging - // do nothing - } - - - - // ============================================================================ - // GLEventListener interface - // ============================================================================ - - /* - * @see net.java.games.jogl.GLEventListener#init(net.java.games.jogl.GLDrawable) - */ - public void init(GLDrawable drawable) { - this.gl = drawable.getGL(); - this.glu = drawable.getGLU(); - - // this is a hack to run R_init() in gl context - post_init = R_Init2(); - } - - /* - * @see net.java.games.jogl.GLEventListener#display(net.java.games.jogl.GLDrawable) - */ - public void display(GLDrawable drawable) { - this.gl = drawable.getGL(); - this.glu = drawable.getGLU(); - - contextInUse = true; - callback.execute(); - contextInUse = false; - } - - /* - * @see net.java.games.jogl.GLEventListener#displayChanged(net.java.games.jogl.GLDrawable, boolean, boolean) - */ - public void displayChanged(GLDrawable drawable, boolean arg1, boolean arg2) { - // do nothing - } - - /* - * @see net.java.games.jogl.GLEventListener#reshape(net.java.games.jogl.GLDrawable, int, int, int, int) - */ - public void reshape(GLDrawable drawable, int x, int y, int width, int height) { - // do nothing - } - - /* - * @see jake2.client.refexport_t#updateScreen() - */ - public void updateScreen() { - this.callback = INIT_CALLBACK; - canvas.display(); - } - - public void updateScreen(xcommand_t callback) { - this.callback = callback; - canvas.display(); - } -} \ No newline at end of file diff --git a/src/jake2/render/fastjogl/Main.java b/src/jake2/render/fastjogl/Main.java index 2363db4..4e32817 100644 --- a/src/jake2/render/fastjogl/Main.java +++ b/src/jake2/render/fastjogl/Main.java @@ -2,7 +2,7 @@ * Main.java * Copyright (C) 2003 * - * $Id: Main.java,v 1.1 2004-07-09 06:50:49 hzi Exp $ + * $Id: Main.java,v 1.2 2004-07-15 14:37:33 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,7 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.fastjogl; -import jake2.*; +import jake2.Defines; +import jake2.Globals; import jake2.client.*; import jake2.game.cplane_t; import jake2.game.cvar_t; @@ -40,9 +41,6 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import net.java.games.jogl.GL; -import net.java.games.jogl.GLU; -import net.java.games.jogl.util.BufferUtils; -import net.java.games.jogl.util.GLUT; /** * Main @@ -51,9 +49,6 @@ import net.java.games.jogl.util.GLUT; */ public abstract class Main extends Base { - GL gl; - GLU glu; - GLUT glut = new GLUT(); public static int[] d_8to24table = new int[256]; @@ -83,15 +78,6 @@ public abstract class Main extends Base { abstract void Mod_Modellist_f(); abstract mleaf_t Mod_PointInLeaf(float[] point, model_t model); - abstract boolean QGL_Init(String dll_name); - abstract void QGL_Shutdown(); - abstract boolean GLimp_Init(int xpos, int ypos); - abstract void GLimp_BeginFrame(float camera_separation); - abstract int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen); - abstract void GLimp_Shutdown(); - abstract void GLimp_EnableLogging(boolean enable); - abstract void GLimp_LogNewFrame(); - abstract void GL_SetDefaultState(); abstract void GL_InitImages(); @@ -125,13 +111,9 @@ public abstract class Main extends Base { ==================================================================== */ - // IMPORTED FUNCTIONS - protected refimport_t ri = null; - int GL_TEXTURE0 = GL.GL_TEXTURE0; int GL_TEXTURE1 = GL.GL_TEXTURE1; - viddef_t vid = new viddef_t(); model_t r_worldmodel; @@ -235,7 +217,6 @@ public abstract class Main extends Base { cvar_t gl_3dlabs_broken; - cvar_t vid_fullscreen; cvar_t vid_gamma; cvar_t vid_ref; @@ -1110,32 +1091,18 @@ public abstract class Main extends Base { R_Register(); - // initialize our QGL dynamic bindings - if (!QGL_Init(gl_driver.string)) { - QGL_Shutdown(); - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not load \"" + gl_driver.string + "\"\n"); - return false; - } - - // initialize OS-specific parts of OpenGL - if (!GLimp_Init(vid_xpos, vid_ypos)) { - QGL_Shutdown(); - return false; - } - // set our "safe" modes gl_state.prev_mode = 3; // create the window and set up the context if (!R_SetMode()) { - QGL_Shutdown(); ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n"); return false; } return true; } - boolean R_Init2() { + protected boolean R_Init2() { ri.Vid_MenuInit(); /* @@ -1350,11 +1317,6 @@ public abstract class Main extends Base { * shut down OS specific OpenGL stuff like contexts, etc. */ GLimp_Shutdown(); - - /* - * shutdown our QGL subsystem - */ - QGL_Shutdown(); } /* diff --git a/src/jake2/render/jogl/Base.java b/src/jake2/render/jogl/Base.java index 91cbdea..5a4e9ea 100644 --- a/src/jake2/render/jogl/Base.java +++ b/src/jake2/render/jogl/Base.java @@ -2,7 +2,7 @@ * Base.java * Copyright (C) 2003 * - * $Id: Base.java,v 1.1 2004-07-07 19:59:36 hzi Exp $ + * $Id: Base.java,v 1.2 2004-07-15 14:37:34 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.jogl; +import jake2.render.JoglBase; import net.java.games.jogl.GL; /** @@ -32,7 +33,7 @@ import net.java.games.jogl.GL; * * @author cwei */ -public class Base { +public abstract class Base extends JoglBase { static final int GL_COLOR_INDEX8_EXT = GL.GL_COLOR_INDEX; static final String REF_VERSION = "GL 0.01"; @@ -75,12 +76,6 @@ public class Base { // =================================================================== - // enum rserr_t - static final int rserr_ok = 0; - static final int rserr_invalid_fullscreen = 1; - static final int rserr_invalid_mode = 2; - static final int rserr_unknown = 3; - // // #include "gl_model.h" // diff --git a/src/jake2/render/jogl/Draw.java b/src/jake2/render/jogl/Draw.java index 3251b0e..b83e422 100644 --- a/src/jake2/render/jogl/Draw.java +++ b/src/jake2/render/jogl/Draw.java @@ -2,7 +2,7 @@ * Draw.java * Copyright (C) 2003 * - * $Id: Draw.java,v 1.3 2004-07-09 06:50:48 hzi Exp $ + * $Id: Draw.java,v 1.4 2004-07-15 14:37:34 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -26,13 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render.jogl; import jake2.Defines; -import jake2.Globals; import jake2.render.image_t; import java.awt.Dimension; import net.java.games.jogl.GL; -import net.java.games.jogl.util.GLUT; /** * Draw diff --git a/src/jake2/render/jogl/Impl.java b/src/jake2/render/jogl/Impl.java deleted file mode 100644 index cfaec7e..0000000 --- a/src/jake2/render/jogl/Impl.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Impl.java - * Copyright (C) 2003 - * - * $Id: Impl.java,v 1.5 2004-07-09 06:50:48 hzi Exp $ - */ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -package jake2.render.jogl; - -import jake2.Defines; -import jake2.Globals; -import jake2.qcommon.Com; -import jake2.qcommon.xcommand_t; -import jake2.sys.KBD; - -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import javax.swing.JFrame; - -import net.java.games.jogl.*; - -/** - * Impl - * - * @author cwei - */ -public class Impl extends Misc implements GLEventListener { - - public static final String DRIVER_NAME = "jogl"; - - // handles the post initialization with JoglRenderer - protected boolean post_init = false; - - private final xcommand_t INIT_CALLBACK = new xcommand_t() { - public void execute() { - // only used for the first run (initialization) - // clear the screen - gl.glClearColor(0, 0, 0, 0); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - - // - // check the post init process - // - if (!post_init) { - ri.Con_Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n"); - } - - GLimp_EndFrame(); - } - }; - - private xcommand_t callback = INIT_CALLBACK; - protected boolean contextInUse = false; - - private GraphicsDevice device; - private DisplayMode oldDisplayMode; - - GLCanvas canvas; - JFrame window; - - // window position on the screen - int window_xpos, window_ypos; - - /** - * @return true - */ - boolean GLimp_Init(int xpos, int ypos) { - // do nothing - window_xpos = xpos; - window_ypos = ypos; - return true; - } - - /** - * @param dim - * @param mode - * @param fullscreen - * @return enum rserr_t - */ - int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) { - - Dimension newDim = new Dimension(); - - ri.Cvar_Get("r_fakeFullscreen", "0", Globals.CVAR_ARCHIVE); - - ri.Con_Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); - - ri.Con_Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); - - if (!ri.Vid_GetModeInfo(newDim, mode)) { - ri.Con_Printf(Defines.PRINT_ALL, " invalid mode\n"); - return rserr_invalid_mode; - } - - ri.Con_Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); - - // destroy the existing window - GLimp_Shutdown(); - - window = new JFrame("Jake2"); - - GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities()); - - // TODO Use debug pipeline - //canvas.setGL(new DebugGL(canvas.getGL())); - - canvas.setNoAutoRedrawMode(true); - canvas.addGLEventListener(this); - - window.getContentPane().add(canvas); - - canvas.setSize(newDim.width, newDim.height); - - // register event listener - window.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - ri.Cmd_ExecuteText(Defines.EXEC_APPEND, "quit"); - } - }); - - // D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G - window.addComponentListener(KBD.listener); - canvas.addKeyListener(KBD.listener); - canvas.addMouseListener(KBD.listener); - canvas.addMouseMotionListener(KBD.listener); - - /* - * fullscreen handling - */ - GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); - device = env.getDefaultScreenDevice(); - - if (fullscreen && !device.isFullScreenSupported()) { - ri.Con_Printf(Defines.PRINT_ALL, "...fullscreen not supported\n"); - vid_fullscreen.value = 0; - vid_fullscreen.modified = false; - } - - fullscreen = fullscreen && device.isFullScreenSupported(); - - if (oldDisplayMode == null) { - oldDisplayMode = device.getDisplayMode(); - } - - if (fullscreen) { - - DisplayMode displayMode = findDisplayMode(newDim, oldDisplayMode.getBitDepth(), oldDisplayMode.getRefreshRate()); - - if (displayMode != null) { - newDim.width = displayMode.getWidth(); - newDim.height = displayMode.getHeight(); - window.setUndecorated(true); - window.setResizable(false); - device.setFullScreenWindow(window); - device.setDisplayMode(displayMode); - window.setLocation(0, 0); - window.setSize(displayMode.getWidth(), displayMode.getHeight()); - canvas.setSize(displayMode.getWidth(), displayMode.getHeight()); - ri.Con_Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); - } - } else { - window.setLocation(window_xpos, window_ypos); - window.pack(); - window.setResizable(false); - window.setVisible(true); - } - - while (!canvas.isDisplayable()) { - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - } - canvas.requestFocus(); - - this.canvas = canvas; - - vid.width = newDim.width; - vid.height = newDim.height; - - // let the sound and input subsystems know about the new window - ri.Vid_NewWindow(vid.width, vid.height); - - return rserr_ok; - } - - DisplayMode findDisplayMode(Dimension dim, int depth, int rate) { - DisplayMode mode = null; - DisplayMode m = null; - DisplayMode[] modes = device.getDisplayModes(); - int w = dim.width; - int h = dim.height; - - for (int i = 0; i < modes.length; i++) { - m = modes[i]; - if (m.getWidth() == w && m.getHeight() == h && m.getBitDepth() == depth && m.getRefreshRate() == rate) { - mode = m; - break; - } - } - if (mode == null) mode = oldDisplayMode; - Com.Printf(getModeString(mode) + '\n'); - return mode; - } - - String getModeString(DisplayMode m) { - StringBuffer sb = new StringBuffer(); - sb.append(m.getWidth()); - sb.append('x'); - sb.append(m.getHeight()); - sb.append('x'); - sb.append(m.getBitDepth()); - sb.append('@'); - sb.append(m.getRefreshRate()); - sb.append("Hz"); - return sb.toString(); - } - - void GLimp_BeginFrame(float camera_separation) { - // do nothing - } - - protected void GLimp_EndFrame() { - gl.glFlush(); - // swap buffer - // but jogl has no method to swap - } - - protected void GLimp_AppActivate(boolean activate) { - // do nothing - } - - boolean QGL_Init(String dll_name) { - // doesn't need libGL.so or .dll loading - return true; - } - - void QGL_Shutdown() { - // doesn't need libGL.so or .dll loading - // do nothing - } - - void GLimp_Shutdown() { - if (oldDisplayMode != null && device.getFullScreenWindow() != null) { - try { - device.setDisplayMode(oldDisplayMode); - device.setFullScreenWindow(null); - } catch (Exception e) { - e.printStackTrace(); - } - } - if (this.window != null) { - window.dispose(); - } - post_init = false; - callback = INIT_CALLBACK; - } - - void GLimp_EnableLogging(boolean enable) { - // doesn't need jogl logging - // do nothing - } - - void GLimp_LogNewFrame() { - // doesn't need jogl logging - // do nothing - } - - - - // ============================================================================ - // GLEventListener interface - // ============================================================================ - - /* - * @see net.java.games.jogl.GLEventListener#init(net.java.games.jogl.GLDrawable) - */ - public void init(GLDrawable drawable) { - this.gl = drawable.getGL(); - this.glu = drawable.getGLU(); - - // this is a hack to run R_init() in gl context - post_init = R_Init2(); - } - - /* - * @see net.java.games.jogl.GLEventListener#display(net.java.games.jogl.GLDrawable) - */ - public void display(GLDrawable drawable) { - this.gl = drawable.getGL(); - this.glu = drawable.getGLU(); - - contextInUse = true; - callback.execute(); - contextInUse = false; - } - - /* - * @see net.java.games.jogl.GLEventListener#displayChanged(net.java.games.jogl.GLDrawable, boolean, boolean) - */ - public void displayChanged(GLDrawable drawable, boolean arg1, boolean arg2) { - // do nothing - } - - /* - * @see net.java.games.jogl.GLEventListener#reshape(net.java.games.jogl.GLDrawable, int, int, int, int) - */ - public void reshape(GLDrawable drawable, int x, int y, int width, int height) { - // do nothing - } - - /* - * @see jake2.client.refexport_t#updateScreen() - */ - public void updateScreen() { - this.callback = INIT_CALLBACK; - canvas.display(); - } - - public void updateScreen(xcommand_t callback) { - this.callback = callback; - canvas.display(); - } -} diff --git a/src/jake2/render/jogl/Main.java b/src/jake2/render/jogl/Main.java index 2b46501..9f85422 100644 --- a/src/jake2/render/jogl/Main.java +++ b/src/jake2/render/jogl/Main.java @@ -2,7 +2,7 @@ * Main.java * Copyright (C) 2003 * - * $Id: Main.java,v 1.3 2004-07-09 06:50:47 hzi Exp $ + * $Id: Main.java,v 1.4 2004-07-15 14:37:34 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,13 +25,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.render.jogl; -import jake2.*; +import jake2.Defines; +import jake2.Globals; import jake2.client.*; import jake2.game.cplane_t; import jake2.game.cvar_t; -import jake2.qcommon.Cvar; -import jake2.qcommon.qfiles; -import jake2.qcommon.xcommand_t; +import jake2.qcommon.*; import jake2.render.*; import jake2.util.Math3D; import jake2.util.Vargs; @@ -41,9 +40,6 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import net.java.games.jogl.GL; -import net.java.games.jogl.GLU; -import net.java.games.jogl.util.BufferUtils; -import net.java.games.jogl.util.GLUT; /** * Main @@ -52,10 +48,6 @@ import net.java.games.jogl.util.GLUT; */ public abstract class Main extends Base { - GL gl; - GLU glu; - GLUT glut = new GLUT(); - public static int[] d_8to24table = new int[256]; int c_visible_lightmaps; @@ -86,15 +78,6 @@ public abstract class Main extends Base { abstract void Mod_Modellist_f(); abstract mleaf_t Mod_PointInLeaf(float[] point, model_t model); - abstract boolean QGL_Init(String dll_name); - abstract void QGL_Shutdown(); - abstract boolean GLimp_Init(int xpos, int ypos); - abstract void GLimp_BeginFrame(float camera_separation); - abstract int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen); - abstract void GLimp_Shutdown(); - abstract void GLimp_EnableLogging(boolean enable); - abstract void GLimp_LogNewFrame(); - abstract void GL_SetDefaultState(); abstract void GL_InitImages(); @@ -128,14 +111,9 @@ public abstract class Main extends Base { ==================================================================== */ - // IMPORTED FUNCTIONS - protected refimport_t ri = null; - int GL_TEXTURE0 = GL.GL_TEXTURE0; int GL_TEXTURE1 = GL.GL_TEXTURE1; - viddef_t vid = new viddef_t(); - model_t r_worldmodel; float gldepthmin, gldepthmax; @@ -238,7 +216,6 @@ public abstract class Main extends Base { cvar_t gl_3dlabs_broken; - cvar_t vid_fullscreen; cvar_t vid_gamma; cvar_t vid_ref; @@ -1113,32 +1090,18 @@ public abstract class Main extends Base { R_Register(); - // initialize our QGL dynamic bindings - if (!QGL_Init(gl_driver.string)) { - QGL_Shutdown(); - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not load \"" + gl_driver.string + "\"\n"); - return false; - } - - // initialize OS-specific parts of OpenGL - if (!GLimp_Init(vid_xpos, vid_ypos)) { - QGL_Shutdown(); - return false; - } - // set our "safe" modes gl_state.prev_mode = 3; // create the window and set up the context if (!R_SetMode()) { - QGL_Shutdown(); ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n"); return false; } return true; } - boolean R_Init2() { + protected boolean R_Init2() { ri.Vid_MenuInit(); /* @@ -1385,11 +1348,6 @@ public abstract class Main extends Base { * shut down OS specific OpenGL stuff like contexts, etc. */ GLimp_Shutdown(); - - /* - * shutdown our QGL subsystem - */ - QGL_Shutdown(); } /* -- cgit v1.2.3 From 0f7d8b8bab6c018dfb19e9c295bb501b990f2b85 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Thu, 15 Jul 2004 16:16:24 +0000 Subject: fullscreen modes work again --- src/jake2/client/VID.java | 5 +++-- src/jake2/render/JoglBase.java | 40 ++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java index 0eec17a..6ef8f1c 100644 --- a/src/jake2/client/VID.java +++ b/src/jake2/client/VID.java @@ -2,7 +2,7 @@ * VID.java * Copyright (C) 2003 * - * $Id: VID.java,v 1.6 2004-07-15 14:37:35 hzi Exp $ + * $Id: VID.java,v 1.7 2004-07-15 16:16:24 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -121,6 +121,8 @@ public class VID extends Globals { static vidmode_t fs_modes[]; public static boolean GetModeInfo(Dimension dim, int mode) { + if (fs_modes == null) initModeList(); + vidmode_t[] modes = vid_modes; if (vid_fullscreen.value != 0.0f) modes = fs_modes; @@ -664,7 +666,6 @@ public class VID extends Globals { ** VID_MenuInit */ public static void MenuInit() { - if (fs_resolutions == null) initModeList(); if ( gl_driver == null ) gl_driver = Cvar.Get( "gl_driver", "jogl", 0 ); diff --git a/src/jake2/render/JoglBase.java b/src/jake2/render/JoglBase.java index 5477229..e46d0c2 100644 --- a/src/jake2/render/JoglBase.java +++ b/src/jake2/render/JoglBase.java @@ -2,7 +2,7 @@ * JoglCommon.java * Copyright (C) 2004 * - * $Id: JoglBase.java,v 1.1 2004-07-15 14:37:34 hzi Exp $ + * $Id: JoglBase.java,v 1.2 2004-07-15 16:16:23 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -171,6 +171,16 @@ public abstract class JoglBase implements GLEventListener { ri.Con_Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); ri.Con_Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); + + /* + * fullscreen handling + */ + GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); + device = env.getDefaultScreenDevice(); + + if (oldDisplayMode == null) { + oldDisplayMode = device.getDisplayMode(); + } if (!ri.Vid_GetModeInfo(newDim, mode)) { ri.Con_Printf(Defines.PRINT_ALL, " invalid mode\n"); @@ -192,9 +202,9 @@ public abstract class JoglBase implements GLEventListener { canvas.setNoAutoRedrawMode(true); canvas.addGLEventListener(this); - //window.getContentPane().add(canvas); + window.getContentPane().add(canvas); - //canvas.setSize(newDim.width, newDim.height); + canvas.setSize(newDim.width, newDim.height); // register event listener window.addWindowListener(new WindowAdapter() { @@ -208,17 +218,7 @@ public abstract class JoglBase implements GLEventListener { canvas.addKeyListener(KBD.listener); canvas.addMouseListener(KBD.listener); canvas.addMouseMotionListener(KBD.listener); - - /* - * fullscreen handling - */ - GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); - device = env.getDefaultScreenDevice(); - - if (oldDisplayMode == null) { - oldDisplayMode = device.getDisplayMode(); - } - + if (fullscreen) { DisplayMode displayMode = findDisplayMode(newDim); @@ -226,23 +226,23 @@ public abstract class JoglBase implements GLEventListener { newDim.width = displayMode.getWidth(); newDim.height = displayMode.getHeight(); window.setUndecorated(true); - window.setSize(displayMode.getWidth(), displayMode.getHeight()); window.setResizable(false); - window.getContentPane().add(canvas); device.setFullScreenWindow(window); - if (!displayMode.equals(oldDisplayMode)) + if (device.isFullScreenSupported()) device.setDisplayMode(displayMode); window.setLocation(0, 0); + window.setSize(displayMode.getWidth(), displayMode.getHeight()); + canvas.setSize(displayMode.getWidth(), displayMode.getHeight()); + ri.Con_Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); } else { window.setLocation(window_xpos, window_ypos); - window.setSize(newDim.width, newDim.height); + window.pack(); window.setResizable(false); - window.getContentPane().add(canvas); window.setVisible(true); } @@ -267,7 +267,7 @@ public abstract class JoglBase implements GLEventListener { protected void GLimp_Shutdown() { if (oldDisplayMode != null && device.getFullScreenWindow() != null) { try { - if (!device.getDisplayMode().equals(oldDisplayMode)) + if (device.isFullScreenSupported()) device.setDisplayMode(oldDisplayMode); device.setFullScreenWindow(null); } catch (Exception e) { -- cgit v1.2.3 From 6797f747378633e79ad4510d7f9449dc6bf3defd Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Thu, 15 Jul 2004 16:33:24 +0000 Subject: show all fullscreen modes in menu --- src/jake2/render/JoglBase.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/JoglBase.java b/src/jake2/render/JoglBase.java index e46d0c2..7c8cde1 100644 --- a/src/jake2/render/JoglBase.java +++ b/src/jake2/render/JoglBase.java @@ -2,7 +2,7 @@ * JoglCommon.java * Copyright (C) 2004 * - * $Id: JoglBase.java,v 1.2 2004-07-15 16:16:23 hzi Exp $ + * $Id: JoglBase.java,v 1.3 2004-07-15 16:33:24 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -111,11 +111,12 @@ public abstract class JoglBase implements GLEventListener { DisplayMode ml = null; for (j = 0; j < l.size(); j++) { ml = (DisplayMode)l.get(j); - if (ml.getWidth() >= m.getWidth()) break; + if (ml.getWidth() > m.getWidth()) break; + if (ml.getWidth() == m.getWidth() && ml.getHeight() >= m.getHeight()) break; } if (j == l.size()) { l.addLast(m); - } else if (ml.getWidth() > m.getWidth()) { + } else if (ml.getWidth() > m.getWidth() || ml.getHeight() > m.getHeight()) { l.add(j, m); } else if (m.getRefreshRate() > ml.getRefreshRate()){ l.remove(j); @@ -136,7 +137,7 @@ public abstract class JoglBase implements GLEventListener { for (int i = 0; i < modes.length; i++) { m = modes[i]; - if (m.getWidth() == w) { + if (m.getWidth() == w && m.getHeight() == h) { mode = m; break; } -- cgit v1.2.3 From c19debe92ce0eb509cd5c3596b7f858e40424451 Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Fri, 16 Jul 2004 10:11:36 +0000 Subject: refimport_t deleted --- src/jake2/client/VID.java | 88 +---------- src/jake2/client/refimport_t.java | 70 --------- src/jake2/render/FastJoglRenderer.java | 5 +- src/jake2/render/JoglBase.java | 26 ++-- src/jake2/render/JoglRenderer.java | 5 +- src/jake2/render/Ref.java | 5 +- src/jake2/render/Renderer.java | 9 +- src/jake2/render/fastjogl/Draw.java | 12 +- src/jake2/render/fastjogl/Image.java | 68 ++++----- src/jake2/render/fastjogl/Light.java | 7 +- src/jake2/render/fastjogl/Main.java | 248 +++++++++++++++---------------- src/jake2/render/fastjogl/Mesh.java | 11 +- src/jake2/render/fastjogl/Misc.java | 15 +- src/jake2/render/fastjogl/Model.java | 77 +++++----- src/jake2/render/fastjogl/Surf.java | 7 +- src/jake2/render/fastjogl/Warp.java | 7 +- src/jake2/render/jogl/Draw.java | 12 +- src/jake2/render/jogl/Image.java | 68 ++++----- src/jake2/render/jogl/Light.java | 7 +- src/jake2/render/jogl/Main.java | 257 +++++++++++++++++---------------- src/jake2/render/jogl/Mesh.java | 11 +- src/jake2/render/jogl/Misc.java | 15 +- src/jake2/render/jogl/Model.java | 77 +++++----- src/jake2/render/jogl/Surf.java | 9 +- src/jake2/render/jogl/Warp.java | 7 +- test/jake2/render/DancingQueens.java | 90 +----------- test/jake2/render/DebugCulling.java | 114 +-------------- test/jake2/render/TestMap.java | 112 +------------- test/jake2/render/TestRenderer.java | 90 +----------- 29 files changed, 508 insertions(+), 1021 deletions(-) delete mode 100644 src/jake2/client/refimport_t.java (limited to 'src/jake2') diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java index 6ef8f1c..59c9252 100644 --- a/src/jake2/client/VID.java +++ b/src/jake2/client/VID.java @@ -2,7 +2,7 @@ * VID.java * Copyright (C) 2003 * - * $Id: VID.java,v 1.7 2004-07-15 16:16:24 hzi Exp $ + * $Id: VID.java,v 1.8 2004-07-16 10:11:36 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -31,7 +31,7 @@ import jake2.game.Cmd; import jake2.game.cvar_t; import jake2.qcommon.*; import jake2.render.Renderer; -import jake2.sound.*; +import jake2.sound.S; import jake2.sys.IN; import jake2.sys.KBD; import jake2.util.Vargs; @@ -78,6 +78,10 @@ public class VID extends Globals { ========================================================================== */ + public static void Printf(int print_level, String fmt) { + Printf(print_level, fmt, null); + } + public static void Printf(int print_level, String fmt, Vargs vargs) { // static qboolean inupdate; if (print_level == Defines.PRINT_ALL) @@ -188,85 +192,7 @@ public class VID extends Globals { } Com.Printf( "LoadLibrary(\"" + name +"\")\n" ); - refimport_t ri = new refimport_t() { - public void Sys_Error(int err_level, String str) { - Com.Error(err_level, str, null); - } - - public void Sys_Error(int err_level, String str, Vargs vargs) { - Com.Error(err_level, str, vargs); - } - - public void Cmd_AddCommand(String name, xcommand_t cmd) { - Cmd.AddCommand(name, cmd); - } - - public void Cmd_RemoveCommand(String name) { - Cmd.RemoveCommand(name); - } - - public int Cmd_Argc() { - return Cmd.Argc(); - } - - public String Cmd_Argv(int i) { - return Cmd.Argv(i); - } - - public void Cmd_ExecuteText(int exec_when, String text) { - Cbuf.ExecuteText(exec_when, text); - } - - public void Con_Printf(int print_level, String str) { - VID.Printf(print_level, str, null); - } - - public void Con_Printf(int print_level, String str, Vargs vargs) { - VID.Printf(print_level, str, vargs); - } - - public byte[] FS_LoadFile(String name) { - return FS.LoadFile(name); - } - - public int FS_FileLength(String name) { - return FS.FileLength(name); - } - - public void FS_FreeFile(byte[] buf) { - FS.FreeFile(buf); - } - - public String FS_Gamedir() { - return FS.Gamedir(); - } - - public cvar_t Cvar_Get(String name, String value, int flags) { - return Cvar.Get(name, value, flags); - } - - public cvar_t Cvar_Set(String name, String value) { - return Cvar.Set(name, value); - } - - public void Cvar_SetValue(String name, float value) { - Cvar.SetValue(name, value); - } - - public boolean Vid_GetModeInfo(Dimension dim, int mode) { - return VID.GetModeInfo(dim, mode); - } - - public void Vid_MenuInit() { - VID.MenuInit(); - } - - public void Vid_NewWindow(int width, int height) { - VID.NewWindow(width, height); - } - }; - - Globals.re = Renderer.getDriver( name, ri ); + Globals.re = Renderer.getDriver(name); if (Globals.re == null) { diff --git a/src/jake2/client/refimport_t.java b/src/jake2/client/refimport_t.java deleted file mode 100644 index 849b143..0000000 --- a/src/jake2/client/refimport_t.java +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Created on 20.11.2003 by RST. -// $Id: refimport_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $ - - -package jake2.client; - -import java.awt.Dimension; - -import jake2.game.*; -import jake2.qcommon.xcommand_t; -import jake2.util.Vargs; - -public interface refimport_t { - // ref.h - // these are the functions imported by the refresh module - // - void Sys_Error(int err_level, String str); - void Sys_Error(int err_level, String str, Vargs vargs); - - void Cmd_AddCommand(String name, xcommand_t cmd); - void Cmd_RemoveCommand(String name); - int Cmd_Argc(); - String Cmd_Argv(int i); - void Cmd_ExecuteText(int exec_when, String text); - - void Con_Printf(int print_level, String str, Vargs vargs); - - void Con_Printf(int print_level, String str); - - // files will be memory mapped read only - // the returned buffer may be part of a larger pak file, - // or a discrete file from anywhere in the quake search path - // a -1 return means the file does not exist - // NULL can be passed for buf to just determine existance - byte[] FS_LoadFile(String name); - int FS_FileLength(String name); - - void FS_FreeFile(byte[] buf); - // gamedir will be the current directory that generated - // files should be stored to, ie: "f:\quake\id1" - String FS_Gamedir(); - - cvar_t Cvar_Get(String name, String value, int flags); - cvar_t Cvar_Set(String name, String value); - void Cvar_SetValue(String name, float value); - - boolean Vid_GetModeInfo(Dimension dim /* int *w, *h */, int mode); - void Vid_MenuInit(); - void Vid_NewWindow(int width, int height); -} \ No newline at end of file diff --git a/src/jake2/render/FastJoglRenderer.java b/src/jake2/render/FastJoglRenderer.java index 56ab03b..e333c10 100644 --- a/src/jake2/render/FastJoglRenderer.java +++ b/src/jake2/render/FastJoglRenderer.java @@ -2,7 +2,7 @@ * FastJoglRenderer.java * Copyright (C) 2003 * - * $Id: FastJoglRenderer.java,v 1.2 2004-07-15 14:37:35 hzi Exp $ + * $Id: FastJoglRenderer.java,v 1.3 2004-07-16 10:11:34 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -300,8 +300,7 @@ final class FastJoglRenderer extends Misc implements refexport_t, Ref { return DRIVER_NAME; } - public refexport_t GetRefAPI(refimport_t rimp) { - this.ri = rimp; + public refexport_t GetRefAPI() { return this; } diff --git a/src/jake2/render/JoglBase.java b/src/jake2/render/JoglBase.java index 7c8cde1..113cd28 100644 --- a/src/jake2/render/JoglBase.java +++ b/src/jake2/render/JoglBase.java @@ -2,7 +2,7 @@ * JoglCommon.java * Copyright (C) 2004 * - * $Id: JoglBase.java,v 1.3 2004-07-15 16:33:24 hzi Exp $ + * $Id: JoglBase.java,v 1.4 2004-07-16 10:11:34 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -27,9 +27,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render; import jake2.Defines; -import jake2.client.refimport_t; -import jake2.client.viddef_t; +import jake2.client.*; import jake2.game.cvar_t; +import jake2.qcommon.Cbuf; import jake2.qcommon.xcommand_t; import jake2.sys.KBD; @@ -49,8 +49,6 @@ import net.java.games.jogl.util.GLUT; public abstract class JoglBase implements GLEventListener { // IMPORTED FUNCTIONS - protected refimport_t ri = null; - protected GraphicsDevice device; protected DisplayMode oldDisplayMode; protected GLCanvas canvas; @@ -80,7 +78,7 @@ public abstract class JoglBase implements GLEventListener { // check the post init process // if (!post_init) { - ri.Con_Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n"); + VID.Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n"); } GLimp_EndFrame(); @@ -169,9 +167,9 @@ public abstract class JoglBase implements GLEventListener { Dimension newDim = new Dimension(); - ri.Con_Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); + VID.Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n"); - ri.Con_Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); + VID.Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":"); /* * fullscreen handling @@ -183,12 +181,12 @@ public abstract class JoglBase implements GLEventListener { oldDisplayMode = device.getDisplayMode(); } - if (!ri.Vid_GetModeInfo(newDim, mode)) { - ri.Con_Printf(Defines.PRINT_ALL, " invalid mode\n"); + if (!VID.GetModeInfo(newDim, mode)) { + VID.Printf(Defines.PRINT_ALL, " invalid mode\n"); return rserr_invalid_mode; } - ri.Con_Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); + VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); // destroy the existing window GLimp_Shutdown(); @@ -210,7 +208,7 @@ public abstract class JoglBase implements GLEventListener { // register event listener window.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - ri.Cmd_ExecuteText(Defines.EXEC_APPEND, "quit"); + Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit"); } }); @@ -238,7 +236,7 @@ public abstract class JoglBase implements GLEventListener { window.setSize(displayMode.getWidth(), displayMode.getHeight()); canvas.setSize(displayMode.getWidth(), displayMode.getHeight()); - ri.Con_Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); + VID.Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n'); } else { window.setLocation(window_xpos, window_ypos); @@ -260,7 +258,7 @@ public abstract class JoglBase implements GLEventListener { vid.height = newDim.height; // let the sound and input subsystems know about the new window - ri.Vid_NewWindow(vid.width, vid.height); + VID.NewWindow(vid.width, vid.height); return rserr_ok; } diff --git a/src/jake2/render/JoglRenderer.java b/src/jake2/render/JoglRenderer.java index 6e0926b..4aa619d 100644 --- a/src/jake2/render/JoglRenderer.java +++ b/src/jake2/render/JoglRenderer.java @@ -2,7 +2,7 @@ * JoglRenderer.java * Copyright (C) 2003 * - * $Id: JoglRenderer.java,v 1.4 2004-07-15 14:37:35 hzi Exp $ + * $Id: JoglRenderer.java,v 1.5 2004-07-16 10:11:34 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -298,8 +298,7 @@ final class JoglRenderer extends Misc implements refexport_t, Ref { return DRIVER_NAME; } - public refexport_t GetRefAPI(refimport_t rimp) { - this.ri = rimp; + public refexport_t GetRefAPI() { return this; } } \ No newline at end of file diff --git a/src/jake2/render/Ref.java b/src/jake2/render/Ref.java index f5818c7..568f709 100644 --- a/src/jake2/render/Ref.java +++ b/src/jake2/render/Ref.java @@ -2,7 +2,7 @@ * Ref.java * Copyright (C) 2003 * - * $Id: Ref.java,v 1.1 2004-07-07 19:59:34 hzi Exp $ + * $Id: Ref.java,v 1.2 2004-07-16 10:11:34 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render; import jake2.client.refexport_t; -import jake2.client.refimport_t; /** * Ref @@ -38,6 +37,6 @@ public interface Ref { // ============================================================================ // extensions (cwei) // ============================================================================ - refexport_t GetRefAPI(refimport_t rimp); + refexport_t GetRefAPI(); String getName(); } diff --git a/src/jake2/render/Renderer.java b/src/jake2/render/Renderer.java index 55d985c..7c3cdbb 100644 --- a/src/jake2/render/Renderer.java +++ b/src/jake2/render/Renderer.java @@ -2,7 +2,7 @@ * Renderer.java * Copyright (C) 2003 * - * $Id: Renderer.java,v 1.2 2004-07-09 06:50:47 hzi Exp $ + * $Id: Renderer.java,v 1.3 2004-07-16 10:11:34 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,7 +28,6 @@ package jake2.render; import java.util.Vector; import jake2.client.refexport_t; -import jake2.client.refimport_t; /** * Renderer @@ -65,16 +64,14 @@ public class Renderer { * Factory method to get the Renderer implementation. * @return refexport_t (Renderer singleton) */ - public static refexport_t getDriver(String driverName, refimport_t rimp) { - if (rimp == null) - throw new IllegalArgumentException("refimport_t can't be null"); + public static refexport_t getDriver(String driverName) { // find a driver Ref driver = null; int count = drivers.size(); for (int i = 0; i < count; i++) { driver = (Ref) drivers.get(i); if (driver.getName().equals(driverName)) { - return driver.GetRefAPI(rimp); + return driver.GetRefAPI(); } } // null if driver not found diff --git a/src/jake2/render/fastjogl/Draw.java b/src/jake2/render/fastjogl/Draw.java index 0309dba..3098697 100644 --- a/src/jake2/render/fastjogl/Draw.java +++ b/src/jake2/render/fastjogl/Draw.java @@ -2,7 +2,7 @@ * Draw.java * Copyright (C) 2003 * - * $Id: Draw.java,v 1.2 2004-07-15 14:37:33 hzi Exp $ + * $Id: Draw.java,v 1.3 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render.fastjogl; import jake2.Defines; +import jake2.client.VID; +import jake2.qcommon.Com; import jake2.render.image_t; import java.awt.Dimension; @@ -136,7 +138,7 @@ public abstract class Draw extends Image { image = Draw_FindPic(pic); if (image == null) { - ri.Con_Printf (Defines.PRINT_ALL, "Can't find pic: " + pic +'\n'); + VID.Printf (Defines.PRINT_ALL, "Can't find pic: " + pic +'\n'); return; } @@ -175,7 +177,7 @@ public abstract class Draw extends Image { image = Draw_FindPic(pic); if (image == null) { - ri.Con_Printf(Defines.PRINT_ALL, "Can't find pic: " +pic + '\n'); + VID.Printf(Defines.PRINT_ALL, "Can't find pic: " +pic + '\n'); return; } if (scrap_dirty) @@ -215,7 +217,7 @@ public abstract class Draw extends Image { image = Draw_FindPic(pic); if (image == null) { - ri.Con_Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n'); + VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n'); return; } @@ -249,7 +251,7 @@ public abstract class Draw extends Image { protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) { if ( colorIndex > 255) - ri.Sys_Error(Defines.ERR_FATAL, "Draw_Fill: bad color"); + Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color"); gl.glDisable(GL.GL_TEXTURE_2D); diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java index 1f80af0..a6b1a91 100644 --- a/src/jake2/render/fastjogl/Image.java +++ b/src/jake2/render/fastjogl/Image.java @@ -2,7 +2,7 @@ * Image.java * Copyright (C) 2003 * - * $Id: Image.java,v 1.3 2004-07-12 22:08:02 hzi Exp $ + * $Id: Image.java,v 1.4 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -26,8 +26,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render.fastjogl; import jake2.Defines; +import jake2.client.VID; import jake2.client.particle_t; import jake2.game.cvar_t; +import jake2.qcommon.*; import jake2.qcommon.longjmpException; import jake2.qcommon.qfiles; import jake2.render.image_t; @@ -245,7 +247,7 @@ public abstract class Image extends Main { } if (i == NUM_GL_MODES) { - ri.Con_Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n"); + VID.Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n"); return; } @@ -279,7 +281,7 @@ public abstract class Image extends Main { } if (i == NUM_GL_ALPHA_MODES) { - ri.Con_Printf(Defines.PRINT_ALL, "bad alpha texture mode name: [" + string + "]\n"); + VID.Printf(Defines.PRINT_ALL, "bad alpha texture mode name: [" + string + "]\n"); return; } @@ -299,7 +301,7 @@ public abstract class Image extends Main { } if (i == NUM_GL_SOLID_MODES) { - ri.Con_Printf(Defines.PRINT_ALL, "bad solid texture mode name: [" + string + "]\n"); + VID.Printf(Defines.PRINT_ALL, "bad solid texture mode name: [" + string + "]\n"); return; } @@ -317,7 +319,7 @@ public abstract class Image extends Main { int texels; final String[] palstrings = { "RGB", "PAL" }; - ri.Con_Printf(Defines.PRINT_ALL, "------------------\n"); + VID.Printf(Defines.PRINT_ALL, "------------------\n"); texels = 0; for (int i = 0; i < numgltextures; i++) { @@ -328,29 +330,29 @@ public abstract class Image extends Main { texels += image.upload_width * image.upload_height; switch (image.type) { case it_skin : - ri.Con_Printf(Defines.PRINT_ALL, "M"); + VID.Printf(Defines.PRINT_ALL, "M"); break; case it_sprite : - ri.Con_Printf(Defines.PRINT_ALL, "S"); + VID.Printf(Defines.PRINT_ALL, "S"); break; case it_wall : - ri.Con_Printf(Defines.PRINT_ALL, "W"); + VID.Printf(Defines.PRINT_ALL, "W"); break; case it_pic : - ri.Con_Printf(Defines.PRINT_ALL, "P"); + VID.Printf(Defines.PRINT_ALL, "P"); break; default : - ri.Con_Printf(Defines.PRINT_ALL, " "); + VID.Printf(Defines.PRINT_ALL, " "); break; } - ri.Con_Printf( + VID.Printf( Defines.PRINT_ALL, " %3i %3i %s: %s\n", new Vargs(4).add(image.upload_width).add(image.upload_height).add(palstrings[(image.paletted) ? 1 : 0]).add( image.name)); } - ri.Con_Printf(Defines.PRINT_ALL, "Total texel count (not counting mipmaps): " + texels + '\n'); + VID.Printf(Defines.PRINT_ALL, "Total texel count (not counting mipmaps): " + texels + '\n'); } /* @@ -446,10 +448,10 @@ public abstract class Image extends Main { // // load the file // - byte[] raw = ri.FS_LoadFile(filename); + byte[] raw = FS.LoadFile(filename); if (raw == null) { - ri.Con_Printf(Defines.PRINT_DEVELOPER, "Bad pcx file " + filename + '\n'); + VID.Printf(Defines.PRINT_DEVELOPER, "Bad pcx file " + filename + '\n'); return null; } @@ -465,7 +467,7 @@ public abstract class Image extends Main { || pcx.xmax >= 640 || pcx.ymax >= 480) { - ri.Con_Printf(Defines.PRINT_ALL, "Bad pcx file " + filename + '\n'); + VID.Printf(Defines.PRINT_ALL, "Bad pcx file " + filename + '\n'); return null; } @@ -541,21 +543,21 @@ public abstract class Image extends Main { // // load the file // - raw = ri.FS_LoadFile (name); + raw = FS.LoadFile(name); if (raw == null) { - ri.Con_Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n'); + VID.Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n'); return null; } targa_header = new qfiles.tga_t(raw); if (targa_header.image_type != 2 && targa_header.image_type != 10) - ri.Sys_Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n"); + Com.Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n"); if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24)) - ri.Sys_Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); + Com.Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); columns = targa_header.width; rows = targa_header.height; @@ -1088,7 +1090,7 @@ public abstract class Image extends Main { upload_height = scaled_height; if (scaled_width * scaled_height > 256 * 256) - ri.Sys_Error(Defines.ERR_DROP, "GL_Upload32: too big"); + Com.Error(Defines.ERR_DROP, "GL_Upload32: too big"); // scan the texture for any non-255 alpha c = width * height; @@ -1106,7 +1108,7 @@ public abstract class Image extends Main { else if (samples == gl_alpha_format) comp = gl_tex_alpha_format; else { - ri.Con_Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n'); + VID.Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n'); comp = samples; } @@ -1248,7 +1250,7 @@ public abstract class Image extends Main { int s = width * height; if (s > trans.length) - ri.Sys_Error(Defines.ERR_DROP, "GL_Upload8: too large"); + Com.Error(Defines.ERR_DROP, "GL_Upload8: too large"); if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && is_sky) { gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, width, height, 0, GL.GL_COLOR_INDEX, GL.GL_UNSIGNED_BYTE, data); @@ -1315,14 +1317,14 @@ public abstract class Image extends Main { if (i == numgltextures) { if (numgltextures == MAX_GLTEXTURES) - ri.Sys_Error (Defines.ERR_DROP, "MAX_GLTEXTURES"); + Com.Error (Defines.ERR_DROP, "MAX_GLTEXTURES"); numgltextures++; } image = gltextures[i]; if (name.length() > Defines.MAX_QPATH) - ri.Sys_Error(Defines.ERR_DROP, "Draw_LoadPic: \"" + name + "\" is too long"); + Com.Error(Defines.ERR_DROP, "Draw_LoadPic: \"" + name + "\" is too long"); image.name = name; image.registration_sequence = registration_sequence; @@ -1438,9 +1440,9 @@ public abstract class Image extends Main { image_t image = null; - byte[] raw = ri.FS_LoadFile(name); + byte[] raw = FS.LoadFile(name); if (raw == null) { - ri.Con_Printf(Defines.PRINT_ALL, "GL_FindImage: can't load " + name + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_FindImage: can't load " + name + '\n'); return r_notexture; } @@ -1472,8 +1474,8 @@ public abstract class Image extends Main { name = name.substring(0, index); if (name == null || name.length() < 5) - return null; // ri.Sys_Error (ERR_DROP, "GL_FindImage: NULL name"); - // ri.Sys_Error (ERR_DROP, "GL_FindImage: bad name: %s", name); + return null; // Com.Error (ERR_DROP, "GL_FindImage: NULL name"); + // Com.Error (ERR_DROP, "GL_FindImage: bad name: %s", name); // look for it for (int i = 0; i < numgltextures; i++) @@ -1581,7 +1583,7 @@ public abstract class Image extends Main { pic = LoadPCX("pics/colormap.pcx", palette, dim = new Dimension()); if (palette[0] == null || palette[0].length != 768) - ri.Sys_Error(Defines.ERR_FATAL, "Couldn't load pics/colormap.pcx"); + Com.Error(Defines.ERR_FATAL, "Couldn't load pics/colormap.pcx"); byte[] pal = palette[0]; @@ -1611,19 +1613,19 @@ public abstract class Image extends Main { registration_sequence = 1; // init intensity conversions - intensity = ri.Cvar_Get("intensity", "2", 0); + intensity = Cvar.Get("intensity", "2", 0); if (intensity.value <= 1) - ri.Cvar_Set("intensity", "1"); + Cvar.Set("intensity", "1"); gl_state.inverse_intensity = 1 / intensity.value; Draw_GetPalette(); if (qglColorTableEXT) { - gl_state.d_16to8table = ri.FS_LoadFile("pics/16to8.dat"); + gl_state.d_16to8table = FS.LoadFile("pics/16to8.dat"); if (gl_state.d_16to8table == null) - ri.Sys_Error(Defines.ERR_FATAL, "Couldn't load pics/16to8.pcx"); + Com.Error(Defines.ERR_FATAL, "Couldn't load pics/16to8.pcx"); } if ((gl_config.renderer & (GL_RENDERER_VOODOO | GL_RENDERER_VOODOO2)) != 0) { diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java index a9e64a5..5e7cce5 100644 --- a/src/jake2/render/fastjogl/Light.java +++ b/src/jake2/render/fastjogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.4 2004-07-12 22:08:02 hzi Exp $ + * $Id: Light.java,v 1.5 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -30,6 +30,7 @@ import jake2.Globals; import jake2.client.dlight_t; import jake2.game.GameBase; import jake2.game.cplane_t; +import jake2.qcommon.Com; import jake2.qcommon.longjmpException; import jake2.render.*; import jake2.util.Math3D; @@ -491,13 +492,13 @@ public abstract class Light extends Warp { //lightstyle_t style; if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) != 0 ) - ri.Sys_Error(Defines.ERR_DROP, "R_BuildLightMap called for non-lit surface"); + Com.Error(Defines.ERR_DROP, "R_BuildLightMap called for non-lit surface"); int smax = (surf.extents[0] >> 4) + 1; int tmax = (surf.extents[1] >> 4) + 1; int size = smax * tmax; if (size > ((s_blocklights.length * Defines.SIZE_OF_FLOAT) >> 4) ) - ri.Sys_Error(Defines.ERR_DROP, "Bad s_blocklights size"); + Com.Error(Defines.ERR_DROP, "Bad s_blocklights size"); try { // set to full bright if no light data diff --git a/src/jake2/render/fastjogl/Main.java b/src/jake2/render/fastjogl/Main.java index 4e32817..bcc4e92 100644 --- a/src/jake2/render/fastjogl/Main.java +++ b/src/jake2/render/fastjogl/Main.java @@ -2,7 +2,7 @@ * Main.java * Copyright (C) 2003 * - * $Id: Main.java,v 1.2 2004-07-15 14:37:33 hzi Exp $ + * $Id: Main.java,v 1.3 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,8 +28,10 @@ package jake2.render.fastjogl; import jake2.Defines; import jake2.Globals; import jake2.client.*; +import jake2.game.*; import jake2.game.cplane_t; import jake2.game.cvar_t; +import jake2.qcommon.*; import jake2.qcommon.qfiles; import jake2.qcommon.xcommand_t; import jake2.render.*; @@ -420,7 +422,7 @@ public abstract class Main extends Base { R_DrawSpriteModel(currententity); break; default : - ri.Sys_Error(Defines.ERR_DROP, "Bad modeltype"); + Com.Error(Defines.ERR_DROP, "Bad modeltype"); break; } } @@ -454,7 +456,7 @@ public abstract class Main extends Base { R_DrawSpriteModel(currententity); break; default : - ri.Sys_Error(Defines.ERR_DROP, "Bad modeltype"); + Com.Error(Defines.ERR_DROP, "Bad modeltype"); break; } } @@ -826,11 +828,11 @@ public abstract class Main extends Base { // included by cwei if (r_newrefdef == null) { - ri.Sys_Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null"); + Com.Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null"); } if (r_worldmodel == null && (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) - ri.Sys_Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel"); + Com.Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel"); if (r_speeds.value != 0.0f) { c_brush_polys = 0; @@ -863,7 +865,7 @@ public abstract class Main extends Base { R_Flash(); if (r_speeds.value != 0.0f) { - ri.Con_Printf( + VID.Printf( Defines.PRINT_ALL, "%4i wpoly %4i epoly %i tex %i lmaps\n", new Vargs(4).add(c_brush_polys).add(c_alias_polys).add(c_visible_textures).add(c_visible_lightmaps)); @@ -930,90 +932,90 @@ public abstract class Main extends Base { } protected void R_Register() { - r_lefthand = ri.Cvar_Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE); - r_norefresh = ri.Cvar_Get("r_norefresh", "0", 0); - r_fullbright = ri.Cvar_Get("r_fullbright", "0", 0); - r_drawentities = ri.Cvar_Get("r_drawentities", "1", 0); - r_drawworld = ri.Cvar_Get("r_drawworld", "1", 0); - r_novis = ri.Cvar_Get("r_novis", "0", 0); - r_nocull = ri.Cvar_Get("r_nocull", "0", 0); - r_lerpmodels = ri.Cvar_Get("r_lerpmodels", "1", 0); - r_speeds = ri.Cvar_Get("r_speeds", "0", 0); - - r_lightlevel = ri.Cvar_Get("r_lightlevel", "1", 0); - - gl_nosubimage = ri.Cvar_Get("gl_nosubimage", "0", 0); - gl_allow_software = ri.Cvar_Get("gl_allow_software", "0", 0); - - gl_particle_min_size = ri.Cvar_Get("gl_particle_min_size", "2", Globals.CVAR_ARCHIVE); - gl_particle_max_size = ri.Cvar_Get("gl_particle_max_size", "40", Globals.CVAR_ARCHIVE); - gl_particle_size = ri.Cvar_Get("gl_particle_size", "40", Globals.CVAR_ARCHIVE); - gl_particle_att_a = ri.Cvar_Get("gl_particle_att_a", "0.01", Globals.CVAR_ARCHIVE); - gl_particle_att_b = ri.Cvar_Get("gl_particle_att_b", "0.0", Globals.CVAR_ARCHIVE); - gl_particle_att_c = ri.Cvar_Get("gl_particle_att_c", "0.01", Globals.CVAR_ARCHIVE); - - gl_modulate = ri.Cvar_Get("gl_modulate", "1", Globals.CVAR_ARCHIVE); - gl_log = ri.Cvar_Get("gl_log", "0", 0); - gl_bitdepth = ri.Cvar_Get("gl_bitdepth", "0", 0); - gl_mode = ri.Cvar_Get("gl_mode", "3", Globals.CVAR_ARCHIVE); // 640x480 - gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0); - gl_shadows = ri.Cvar_Get("gl_shadows", "0", Globals.CVAR_ARCHIVE); - gl_dynamic = ri.Cvar_Get("gl_dynamic", "1", 0); - gl_nobind = ri.Cvar_Get("gl_nobind", "0", 0); - gl_round_down = ri.Cvar_Get("gl_round_down", "1", 0); - gl_picmip = ri.Cvar_Get("gl_picmip", "0", 0); - gl_skymip = ri.Cvar_Get("gl_skymip", "0", 0); - gl_showtris = ri.Cvar_Get("gl_showtris", "0", 0); - gl_ztrick = ri.Cvar_Get("gl_ztrick", "0", 0); - gl_finish = ri.Cvar_Get("gl_finish", "0", Globals.CVAR_ARCHIVE); - gl_clear = ri.Cvar_Get("gl_clear", "0", 0); - gl_cull = ri.Cvar_Get("gl_cull", "1", 0); - gl_polyblend = ri.Cvar_Get("gl_polyblend", "1", 0); - gl_flashblend = ri.Cvar_Get("gl_flashblend", "0", 0); - gl_playermip = ri.Cvar_Get("gl_playermip", "0", 0); - gl_monolightmap = ri.Cvar_Get("gl_monolightmap", "0", 0); - gl_driver = ri.Cvar_Get("gl_driver", "opengl32", Globals.CVAR_ARCHIVE); - gl_texturemode = ri.Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", Globals.CVAR_ARCHIVE); - gl_texturealphamode = ri.Cvar_Get("gl_texturealphamode", "default", Globals.CVAR_ARCHIVE); - gl_texturesolidmode = ri.Cvar_Get("gl_texturesolidmode", "default", Globals.CVAR_ARCHIVE); - gl_lockpvs = ri.Cvar_Get("gl_lockpvs", "0", 0); - - gl_vertex_arrays = ri.Cvar_Get("gl_vertex_arrays", "1", Globals.CVAR_ARCHIVE); - - gl_ext_swapinterval = ri.Cvar_Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE); - gl_ext_palettedtexture = ri.Cvar_Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE); - gl_ext_multitexture = ri.Cvar_Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE); - gl_ext_pointparameters = ri.Cvar_Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE); - gl_ext_compiled_vertex_array = ri.Cvar_Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE); - - gl_drawbuffer = ri.Cvar_Get("gl_drawbuffer", "GL_BACK", 0); - gl_swapinterval = ri.Cvar_Get("gl_swapinterval", "0", Globals.CVAR_ARCHIVE); - - gl_saturatelighting = ri.Cvar_Get("gl_saturatelighting", "0", 0); - - gl_3dlabs_broken = ri.Cvar_Get("gl_3dlabs_broken", "1", Globals.CVAR_ARCHIVE); - - vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", Globals.CVAR_ARCHIVE); - vid_gamma = ri.Cvar_Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE); - vid_ref = ri.Cvar_Get("vid_ref", "fastjogl", Globals.CVAR_ARCHIVE); - - ri.Cmd_AddCommand("imagelist", new xcommand_t() { + r_lefthand = Cvar.Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE); + r_norefresh = Cvar.Get("r_norefresh", "0", 0); + r_fullbright = Cvar.Get("r_fullbright", "0", 0); + r_drawentities = Cvar.Get("r_drawentities", "1", 0); + r_drawworld = Cvar.Get("r_drawworld", "1", 0); + r_novis = Cvar.Get("r_novis", "0", 0); + r_nocull = Cvar.Get("r_nocull", "0", 0); + r_lerpmodels = Cvar.Get("r_lerpmodels", "1", 0); + r_speeds = Cvar.Get("r_speeds", "0", 0); + + r_lightlevel = Cvar.Get("r_lightlevel", "1", 0); + + gl_nosubimage = Cvar.Get("gl_nosubimage", "0", 0); + gl_allow_software = Cvar.Get("gl_allow_software", "0", 0); + + gl_particle_min_size = Cvar.Get("gl_particle_min_size", "2", Globals.CVAR_ARCHIVE); + gl_particle_max_size = Cvar.Get("gl_particle_max_size", "40", Globals.CVAR_ARCHIVE); + gl_particle_size = Cvar.Get("gl_particle_size", "40", Globals.CVAR_ARCHIVE); + gl_particle_att_a = Cvar.Get("gl_particle_att_a", "0.01", Globals.CVAR_ARCHIVE); + gl_particle_att_b = Cvar.Get("gl_particle_att_b", "0.0", Globals.CVAR_ARCHIVE); + gl_particle_att_c = Cvar.Get("gl_particle_att_c", "0.01", Globals.CVAR_ARCHIVE); + + gl_modulate = Cvar.Get("gl_modulate", "1", Globals.CVAR_ARCHIVE); + gl_log = Cvar.Get("gl_log", "0", 0); + gl_bitdepth = Cvar.Get("gl_bitdepth", "0", 0); + gl_mode = Cvar.Get("gl_mode", "3", Globals.CVAR_ARCHIVE); // 640x480 + gl_lightmap = Cvar.Get("gl_lightmap", "0", 0); + gl_shadows = Cvar.Get("gl_shadows", "0", Globals.CVAR_ARCHIVE); + gl_dynamic = Cvar.Get("gl_dynamic", "1", 0); + gl_nobind = Cvar.Get("gl_nobind", "0", 0); + gl_round_down = Cvar.Get("gl_round_down", "1", 0); + gl_picmip = Cvar.Get("gl_picmip", "0", 0); + gl_skymip = Cvar.Get("gl_skymip", "0", 0); + gl_showtris = Cvar.Get("gl_showtris", "0", 0); + gl_ztrick = Cvar.Get("gl_ztrick", "0", 0); + gl_finish = Cvar.Get("gl_finish", "0", Globals.CVAR_ARCHIVE); + gl_clear = Cvar.Get("gl_clear", "0", 0); + gl_cull = Cvar.Get("gl_cull", "1", 0); + gl_polyblend = Cvar.Get("gl_polyblend", "1", 0); + gl_flashblend = Cvar.Get("gl_flashblend", "0", 0); + gl_playermip = Cvar.Get("gl_playermip", "0", 0); + gl_monolightmap = Cvar.Get("gl_monolightmap", "0", 0); + gl_driver = Cvar.Get("gl_driver", "opengl32", Globals.CVAR_ARCHIVE); + gl_texturemode = Cvar.Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", Globals.CVAR_ARCHIVE); + gl_texturealphamode = Cvar.Get("gl_texturealphamode", "default", Globals.CVAR_ARCHIVE); + gl_texturesolidmode = Cvar.Get("gl_texturesolidmode", "default", Globals.CVAR_ARCHIVE); + gl_lockpvs = Cvar.Get("gl_lockpvs", "0", 0); + + gl_vertex_arrays = Cvar.Get("gl_vertex_arrays", "1", Globals.CVAR_ARCHIVE); + + gl_ext_swapinterval = Cvar.Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE); + gl_ext_palettedtexture = Cvar.Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE); + gl_ext_multitexture = Cvar.Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE); + gl_ext_pointparameters = Cvar.Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE); + gl_ext_compiled_vertex_array = Cvar.Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE); + + gl_drawbuffer = Cvar.Get("gl_drawbuffer", "GL_BACK", 0); + gl_swapinterval = Cvar.Get("gl_swapinterval", "0", Globals.CVAR_ARCHIVE); + + gl_saturatelighting = Cvar.Get("gl_saturatelighting", "0", 0); + + gl_3dlabs_broken = Cvar.Get("gl_3dlabs_broken", "1", Globals.CVAR_ARCHIVE); + + vid_fullscreen = Cvar.Get("vid_fullscreen", "0", Globals.CVAR_ARCHIVE); + vid_gamma = Cvar.Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE); + vid_ref = Cvar.Get("vid_ref", "fastjogl", Globals.CVAR_ARCHIVE); + + Cmd.AddCommand("imagelist", new xcommand_t() { public void execute() { GL_ImageList_f(); } }); - ri.Cmd_AddCommand("screenshot", new xcommand_t() { + Cmd.AddCommand("screenshot", new xcommand_t() { public void execute() { GL_ScreenShot_f(); } }); - ri.Cmd_AddCommand("modellist", new xcommand_t() { + Cmd.AddCommand("modellist", new xcommand_t() { public void execute() { Mod_Modellist_f(); } }); - ri.Cmd_AddCommand("gl_strings", new xcommand_t() { + Cmd.AddCommand("gl_strings", new xcommand_t() { public void execute() { GL_Strings_f(); } @@ -1031,8 +1033,8 @@ public abstract class Main extends Base { boolean fullscreen; // if (vid_fullscreen.modified && !gl_config.allow_cds) { -// ri.Con_Printf(Defines.PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n"); -// ri.Cvar_SetValue("vid_fullscreen", (vid_fullscreen.value > 0.0f) ? 0.0f : 1.0f); +// VID.Printf(Defines.PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n"); +// Cvar.SetValue("vid_fullscreen", (vid_fullscreen.value > 0.0f) ? 0.0f : 1.0f); // vid_fullscreen.modified = false; // } @@ -1048,21 +1050,21 @@ public abstract class Main extends Base { } else { if (err == rserr_invalid_fullscreen) { - ri.Cvar_SetValue("vid_fullscreen", 0); + Cvar.SetValue("vid_fullscreen", 0); vid_fullscreen.modified = false; - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n"); + VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n"); if ((err = GLimp_SetMode(dim, (int) gl_mode.value, false)) == rserr_ok) return true; } else if (err == rserr_invalid_mode) { - ri.Cvar_SetValue("gl_mode", gl_state.prev_mode); + Cvar.SetValue("gl_mode", gl_state.prev_mode); gl_mode.modified = false; - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n"); + VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n"); } // try setting it back to something safe if ((err = GLimp_SetMode(dim, gl_state.prev_mode, false)) != rserr_ok) { - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n"); + VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n"); return false; } } @@ -1085,7 +1087,7 @@ public abstract class Main extends Base { r_turbsin[j] = Warp.SIN[j] * 0.5f; } - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl version: " + REF_VERSION + '\n'); + VID.Printf(Defines.PRINT_ALL, "ref_gl version: " + REF_VERSION + '\n'); Draw_GetPalette(); @@ -1096,26 +1098,26 @@ public abstract class Main extends Base { // create the window and set up the context if (!R_SetMode()) { - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n"); + VID.Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n"); return false; } return true; } protected boolean R_Init2() { - ri.Vid_MenuInit(); + VID.MenuInit(); /* ** get our various GL strings */ gl_config.vendor_string = gl.glGetString(GL.GL_VENDOR); - ri.Con_Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); gl_config.renderer_string = gl.glGetString(GL.GL_RENDERER); - ri.Con_Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); gl_config.version_string = gl.glGetString(GL.GL_VERSION); - ri.Con_Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); gl_config.extensions_string = gl.glGetString(GL.GL_EXTENSIONS); - ri.Con_Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); String renderer_buffer = gl_config.renderer_string.toLowerCase(); String vendor_buffer = gl_config.vendor_string.toLowerCase(); @@ -1146,33 +1148,33 @@ public abstract class Main extends Base { String monolightmap = gl_monolightmap.string.toUpperCase(); if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') { if (gl_config.renderer == GL_RENDERER_PERMEDIA2) { - ri.Cvar_Set("gl_monolightmap", "A"); - ri.Con_Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\n"); + Cvar.Set("gl_monolightmap", "A"); + VID.Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\n"); } else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { - ri.Cvar_Set("gl_monolightmap", "0"); + Cvar.Set("gl_monolightmap", "0"); } else { - ri.Cvar_Set("gl_monolightmap", "0"); + Cvar.Set("gl_monolightmap", "0"); } } // power vr can't have anything stay in the framebuffer, so // the screen needs to redraw the tiled background every frame if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { - ri.Cvar_Set("scr_drawall", "1"); + Cvar.Set("scr_drawall", "1"); } else { - ri.Cvar_Set("scr_drawall", "0"); + Cvar.Set("scr_drawall", "0"); } // #ifdef __linux__ - ri.Cvar_SetValue("gl_finish", 1); + Cvar.SetValue("gl_finish", 1); // #endif // MCD has buffering issues if (gl_config.renderer == GL_RENDERER_MCD) { - ri.Cvar_SetValue("gl_finish", 1); + Cvar.SetValue("gl_finish", 1); } if ((gl_config.renderer & GL_RENDERER_3DLABS) != 0) { @@ -1186,16 +1188,16 @@ public abstract class Main extends Base { } if (gl_config.allow_cds) - ri.Con_Printf(Defines.PRINT_ALL, "...allowing CDS\n"); + VID.Printf(Defines.PRINT_ALL, "...allowing CDS\n"); else - ri.Con_Printf(Defines.PRINT_ALL, "...disabling CDS\n"); + VID.Printf(Defines.PRINT_ALL, "...disabling CDS\n"); /* ** grab extensions */ if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0 || gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) { - ri.Con_Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n"); + VID.Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n"); // qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" ); if (gl_ext_compiled_vertex_array.value != 0.0f) qglLockArraysEXT = true; @@ -1205,16 +1207,16 @@ public abstract class Main extends Base { //qglUnlockArraysEXT = true; } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n"); qglLockArraysEXT = false; } if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) { qwglSwapIntervalEXT = true; - ri.Con_Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n"); + VID.Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n"); } else { qwglSwapIntervalEXT = false; - ri.Con_Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n"); + VID.Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n"); } if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) { @@ -1222,14 +1224,14 @@ public abstract class Main extends Base { // qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" ); qglPointParameterfEXT = true; // qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" ); - ri.Con_Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\n"); + VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\n"); } else { - ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n"); + VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n"); } } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n"); } // #ifdef __linux__ @@ -1237,18 +1239,18 @@ public abstract class Main extends Base { // { // if ( gl_ext_palettedtexture->value ) // { - // ri.Con_Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" ); + // VID.Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" ); // qgl3DfxSetPaletteEXT = ( void ( APIENTRY * ) (GLuint *) )qwglGetProcAddress( "gl3DfxSetPaletteEXT" ); //// qglColorTableEXT = Fake_glColorTableEXT; // } // else // { - // ri.Con_Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" ); + // VID.Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" ); // } // } // else // { - // ri.Con_Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" ); + // VID.Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" ); // } // #endif @@ -1256,26 +1258,26 @@ public abstract class Main extends Base { && gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0 && gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) { if (gl_ext_palettedtexture.value != 0.0f) { - ri.Con_Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\n"); + VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\n"); qglColorTableEXT = false; // true; TODO jogl bug } else { - ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n"); + VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n"); qglColorTableEXT = false; } } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n"); } if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) { - ri.Con_Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n"); + VID.Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n"); qglActiveTextureARB = true; GL_TEXTURE0 = GL.GL_TEXTURE0_ARB; GL_TEXTURE1 = GL.GL_TEXTURE1_ARB; } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n"); } if (!(qglActiveTextureARB)) @@ -1290,7 +1292,7 @@ public abstract class Main extends Base { int err = gl.glGetError(); if (err != GL.GL_NO_ERROR) - ri.Con_Printf( + VID.Printf( Defines.PRINT_ALL, "glGetError() = 0x%x\n\t%s\n", new Vargs(2).add(err).add("" + gl.glGetString(err))); @@ -1304,10 +1306,10 @@ public abstract class Main extends Base { =============== */ protected void R_Shutdown() { - ri.Cmd_RemoveCommand("modellist"); - ri.Cmd_RemoveCommand("screenshot"); - ri.Cmd_RemoveCommand("imagelist"); - ri.Cmd_RemoveCommand("gl_strings"); + Cmd.RemoveCommand("modellist"); + Cmd.RemoveCommand("screenshot"); + Cmd.RemoveCommand("imagelist"); + Cmd.RemoveCommand("gl_strings"); Mod_FreeAll(); @@ -1335,7 +1337,7 @@ public abstract class Main extends Base { // FIXME: only restart if CDS is required cvar_t ref; - ref = ri.Cvar_Get("vid_ref", "fastjogl", 0); + ref = Cvar.Get("vid_ref", "fastjogl", 0); ref.modified = true; } @@ -1368,7 +1370,7 @@ public abstract class Main extends Base { Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g ); putenv( envbuffer ); */ - ri.Con_Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt"); + VID.Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt"); } } diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java index 257fc68..1569ff9 100644 --- a/src/jake2/render/fastjogl/Mesh.java +++ b/src/jake2/render/fastjogl/Mesh.java @@ -2,7 +2,7 @@ * Mesh.java * Copyright (C) 2003 * - * $Id: Mesh.java,v 1.3 2004-07-12 22:08:02 hzi Exp $ + * $Id: Mesh.java,v 1.4 2004-07-16 10:11:35 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.render.fastjogl; import jake2.Defines; +import jake2.client.VID; import jake2.client.entity_t; import jake2.qcommon.qfiles; import jake2.render.image_t; @@ -344,12 +345,12 @@ public abstract class Mesh extends Light { if ( ( e.frame >= paliashdr.num_frames ) || ( e.frame < 0 ) ) { - ri.Con_Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name +": no such frame " + e.frame + '\n'); + VID.Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name +": no such frame " + e.frame + '\n'); e.frame = 0; } if ( ( e.oldframe >= paliashdr.num_frames ) || ( e.oldframe < 0 ) ) { - ri.Con_Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n'); + VID.Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n'); e.oldframe = 0; } @@ -683,7 +684,7 @@ public abstract class Mesh extends Light { if ( (currententity.frame >= paliashdr.num_frames) || (currententity.frame < 0) ) { - ri.Con_Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such frame " + currententity.frame + '\n'); + VID.Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such frame " + currententity.frame + '\n'); currententity.frame = 0; currententity.oldframe = 0; } @@ -691,7 +692,7 @@ public abstract class Mesh extends Light { if ( (currententity.oldframe >= paliashdr.num_frames) || (currententity.oldframe < 0)) { - ri.Con_Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such oldframe " + currententity.oldframe + '\n'); + VID.Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such oldframe " + currententity.oldframe + '\n'); currententity.frame = 0; currententity.oldframe = 0; } diff --git a/src/jake2/render/fastjogl/Misc.java b/src/jake2/render/fastjogl/Misc.java index bcd2a5f..dad5ae0 100644 --- a/src/jake2/render/fastjogl/Misc.java +++ b/src/jake2/render/fastjogl/Misc.java @@ -2,7 +2,7 @@ * Misc.java * Copyright (C) 2003 * - * $Id: Misc.java,v 1.1 2004-07-09 06:50:48 hzi Exp $ + * $Id: Misc.java,v 1.2 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -29,6 +29,7 @@ import net.java.games.jogl.GL; import net.java.games.jogl.WGL; import jake2.Defines; +import jake2.client.VID; /** * Misc @@ -143,7 +144,7 @@ public abstract class Misc extends Mesh { // } // if (i==100) // { -// ri.Con_Printf (PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n"); +// VID.Printf (PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n"); // return; // } // @@ -173,17 +174,17 @@ public abstract class Misc extends Mesh { // fclose (f); // // free (buffer); -// ri.Con_Printf (PRINT_ALL, "Wrote %s\n", picname); +// VID.Printf (PRINT_ALL, "Wrote %s\n", picname); } /* ** GL_Strings_f */ void GL_Strings_f() { - ri.Con_Printf (Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); - ri.Con_Printf (Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); - ri.Con_Printf (Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); - ri.Con_Printf (Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); } /* diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java index c7d83e9..e928c5e 100644 --- a/src/jake2/render/fastjogl/Model.java +++ b/src/jake2/render/fastjogl/Model.java @@ -2,7 +2,7 @@ * Model.java * Copyright (C) 2003 * - * $Id: Model.java,v 1.2 2004-07-12 22:08:02 hzi Exp $ + * $Id: Model.java,v 1.3 2004-07-16 10:11:35 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.render.fastjogl; import jake2.Defines; +import jake2.client.VID; import jake2.game.cplane_t; import jake2.game.cvar_t; import jake2.qcommon.*; @@ -74,7 +75,7 @@ public abstract class Model extends Surf { cplane_t plane; if (model == null || model.nodes == null) - ri.Sys_Error (Defines.ERR_DROP, "Mod_PointInLeaf: bad model"); + Com.Error (Defines.ERR_DROP, "Mod_PointInLeaf: bad model"); node = model.nodes[0]; // root node while (true) @@ -171,17 +172,17 @@ public abstract class Model extends Surf { int total; total = 0; - ri.Con_Printf(Defines.PRINT_ALL,"Loaded models:\n"); + VID.Printf(Defines.PRINT_ALL,"Loaded models:\n"); for (i=0; i < mod_numknown ; i++) { mod = mod_known[i]; if (mod.name == "") continue; - ri.Con_Printf (Defines.PRINT_ALL, "%8i : %s\n", new Vargs(2).add(mod.extradatasize).add(mod.name)); + VID.Printf (Defines.PRINT_ALL, "%8i : %s\n", new Vargs(2).add(mod.extradatasize).add(mod.name)); total += mod.extradatasize; } - ri.Con_Printf (Defines.PRINT_ALL, "Total resident: " + total +'\n'); + VID.Printf (Defines.PRINT_ALL, "Total resident: " + total +'\n'); } /* @@ -213,7 +214,7 @@ public abstract class Model extends Surf { int i; if (name == null || name.length() == 0) - ri.Sys_Error(Defines.ERR_DROP, "Mod_ForName: NULL name"); + Com.Error(Defines.ERR_DROP, "Mod_ForName: NULL name"); // // inline models are grabbed only from worldmodel @@ -222,7 +223,7 @@ public abstract class Model extends Surf { { i = Integer.parseInt(name.substring(1)); if (i < 1 || r_worldmodel == null || i >= r_worldmodel.numsubmodels) - ri.Sys_Error (Defines.ERR_DROP, "bad inline model number"); + Com.Error (Defines.ERR_DROP, "bad inline model number"); return mod_inline[i]; } @@ -252,7 +253,7 @@ public abstract class Model extends Surf { if (i == mod_numknown) { if (mod_numknown == MAX_MOD_KNOWN) - ri.Sys_Error (Defines.ERR_DROP, "mod_numknown == MAX_MOD_KNOWN"); + Com.Error (Defines.ERR_DROP, "mod_numknown == MAX_MOD_KNOWN"); mod_numknown++; mod = mod_known[i]; } @@ -262,12 +263,12 @@ public abstract class Model extends Surf { // // load the file // - fileBuffer = ri.FS_LoadFile(name); + fileBuffer = FS.LoadFile(name); if (fileBuffer == null) { if (crash) - ri.Sys_Error(Defines.ERR_DROP, "Mod_NumForName: " + mod.name + " not found"); + Com.Error(Defines.ERR_DROP, "Mod_NumForName: " + mod.name + " not found"); mod.name = ""; return null; @@ -302,7 +303,7 @@ public abstract class Model extends Surf { Mod_LoadBrushModel(mod, bb); break; default: - ri.Sys_Error(Defines.ERR_DROP,"Mod_NumForName: unknown fileid for " + mod.name); + Com.Error(Defines.ERR_DROP,"Mod_NumForName: unknown fileid for " + mod.name); break; } @@ -384,7 +385,7 @@ public abstract class Model extends Surf { int i, count; if ( (l.filelen % mvertex_t.DISK_SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / mvertex_t.DISK_SIZE; @@ -431,7 +432,7 @@ public abstract class Model extends Surf { int i, j, count; if ((l.filelen % qfiles.dmodel_t.SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dmodel_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -471,7 +472,7 @@ public abstract class Model extends Surf { int i, count; if ( (l.filelen % medge_t.DISK_SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / medge_t.DISK_SIZE; // out = Hunk_Alloc ( (count + 1) * sizeof(*out)); @@ -504,7 +505,7 @@ public abstract class Model extends Surf { String name; if ((l.filelen % texinfo_t.SIZE) != 0) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / texinfo_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -534,7 +535,7 @@ public abstract class Model extends Surf { out[i].image = GL_FindImage(name, it_wall); if (out[i].image == null) { - ri.Con_Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n'); + VID.Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n'); out[i].image = r_notexture; } } @@ -616,7 +617,7 @@ public abstract class Model extends Surf { int ti; if ((l.filelen % qfiles.dface_t.SIZE) != 0) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dface_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -650,7 +651,7 @@ public abstract class Model extends Surf { ti = in.texinfo; if (ti < 0 || ti >= loadmodel.numtexinfo) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: bad texinfo number"); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: bad texinfo number"); out[surfnum].texinfo = loadmodel.texinfo[ti]; @@ -722,7 +723,7 @@ public abstract class Model extends Surf { mnode_t[] out; if ((l.filelen % qfiles.dnode_t.SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dnode_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -779,7 +780,7 @@ public abstract class Model extends Surf { int i, j, count, p; if ((l.filelen % qfiles.dleaf_t.SIZE) != 0) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dleaf_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -824,7 +825,7 @@ public abstract class Model extends Surf { msurface_t[] out; if ((l.filelen % Defines.SIZE_OF_SHORT) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / Defines.SIZE_OF_SHORT; // out = Hunk_Alloc ( count*sizeof(*out)); out = new msurface_t[count]; @@ -839,7 +840,7 @@ public abstract class Model extends Surf { { j = bb.getShort(); if (j < 0 || j >= loadmodel.numsurfaces) - ri.Sys_Error(Defines.ERR_DROP, "Mod_ParseMarksurfaces: bad surface number"); + Com.Error(Defines.ERR_DROP, "Mod_ParseMarksurfaces: bad surface number"); out[i] = loadmodel.surfaces[j]; } @@ -857,11 +858,11 @@ public abstract class Model extends Surf { int[] offsets; if ( (l.filelen % Defines.SIZE_OF_INT) != 0) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / Defines.SIZE_OF_INT; if (count < 1 || count >= Defines.MAX_MAP_SURFEDGES) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: bad surfedges count in " + loadmodel.name + ": " + count); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: bad surfedges count in " + loadmodel.name + ": " + count); offsets = new int[count]; @@ -889,7 +890,7 @@ public abstract class Model extends Surf { int bits; if ((l.filelen % qfiles.dplane_t.SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dplane_t.SIZE; // out = Hunk_Alloc ( count*2*sizeof(*out)); @@ -932,13 +933,13 @@ public abstract class Model extends Surf { loadmodel.type = mod_brush; if (loadmodel != mod_known[0]) - ri.Sys_Error(Defines.ERR_DROP, "Loaded a brush model after the world"); + Com.Error(Defines.ERR_DROP, "Loaded a brush model after the world"); header = new qfiles.dheader_t(buffer); i = header.version; if (i != Defines.BSPVERSION) - ri.Sys_Error (Defines.ERR_DROP, "Mod_LoadBrushModel: " + mod.name + " has wrong version number (" + i + " should be " + Defines.BSPVERSION + ")"); + Com.Error (Defines.ERR_DROP, "Mod_LoadBrushModel: " + mod.name + " has wrong version number (" + i + " should be " + Defines.BSPVERSION + ")"); mod_base = fileBuffer; //(byte *)header; @@ -972,7 +973,7 @@ public abstract class Model extends Surf { starmod.nummodelsurfaces = bm.numfaces; starmod.firstnode = bm.headnode; if (starmod.firstnode >= loadmodel.numnodes) - ri.Sys_Error(Defines.ERR_DROP, "Inline model " + i + " has bad firstnode"); + Com.Error(Defines.ERR_DROP, "Inline model " + i + " has bad firstnode"); Math3D.VectorCopy(bm.maxs, starmod.maxs); Math3D.VectorCopy(bm.mins, starmod.mins); @@ -1010,26 +1011,26 @@ public abstract class Model extends Surf { pheader = new qfiles.dmdl_t(buffer); if (pheader.version != qfiles.ALIAS_VERSION) - ri.Sys_Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", + Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", new Vargs(3).add(mod.name).add(pheader.version).add(qfiles.ALIAS_VERSION)); if (pheader.skinheight > MAX_LBM_HEIGHT) - ri.Sys_Error(Defines.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT); + Com.Error(Defines.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT); if (pheader.num_xyz <= 0) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no vertices"); + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no vertices"); if (pheader.num_xyz > qfiles.MAX_VERTS) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name +" has too many vertices"); + Com.Error(Defines.ERR_DROP, "model " + mod.name +" has too many vertices"); if (pheader.num_st <= 0) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no st vertices"); + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no st vertices"); if (pheader.num_tris <= 0) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no triangles"); + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no triangles"); if (pheader.num_frames <= 0) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no frames"); + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no frames"); // // load base s and t vertices (not used in gl version) @@ -1124,11 +1125,11 @@ public abstract class Model extends Surf { qfiles.dsprite_t sprout = new qfiles.dsprite_t(buffer); if (sprout.version != qfiles.SPRITE_VERSION) - ri.Sys_Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", + Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", new Vargs(3).add(mod.name).add(sprout.version).add(qfiles.SPRITE_VERSION)); if (sprout.numframes > qfiles.MAX_MD2SKINS) - ri.Sys_Error(Defines.ERR_DROP, "%s has too many frames (%i > %i)", + Com.Error(Defines.ERR_DROP, "%s has too many frames (%i > %i)", new Vargs(3).add(mod.name).add(sprout.numframes).add(qfiles.MAX_MD2SKINS)); for (int i=0 ; i 60) - ri.Sys_Error(Defines.ERR_DROP, "numverts = " + numverts); + Com.Error(Defines.ERR_DROP, "numverts = " + numverts); BoundPoly(numverts, verts, mins, maxs); @@ -463,7 +464,7 @@ public abstract class Warp extends Model { int i, j; if (nump > MAX_CLIP_VERTS-2) - ri.Sys_Error(Defines.ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); + Com.Error(Defines.ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); if (stage == 6) { // fully clipped, so draw it DrawSkyPolygon(nump, vecs); diff --git a/src/jake2/render/jogl/Draw.java b/src/jake2/render/jogl/Draw.java index b83e422..5047ddb 100644 --- a/src/jake2/render/jogl/Draw.java +++ b/src/jake2/render/jogl/Draw.java @@ -2,7 +2,7 @@ * Draw.java * Copyright (C) 2003 * - * $Id: Draw.java,v 1.4 2004-07-15 14:37:34 hzi Exp $ + * $Id: Draw.java,v 1.5 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render.jogl; import jake2.Defines; +import jake2.client.VID; +import jake2.qcommon.Com; import jake2.render.image_t; import java.awt.Dimension; @@ -136,7 +138,7 @@ public abstract class Draw extends Image { image = Draw_FindPic(pic); if (image == null) { - ri.Con_Printf (Defines.PRINT_ALL, "Can't find pic: " + pic +'\n'); + VID.Printf (Defines.PRINT_ALL, "Can't find pic: " + pic +'\n'); return; } @@ -175,7 +177,7 @@ public abstract class Draw extends Image { image = Draw_FindPic(pic); if (image == null) { - ri.Con_Printf(Defines.PRINT_ALL, "Can't find pic: " +pic + '\n'); + VID.Printf(Defines.PRINT_ALL, "Can't find pic: " +pic + '\n'); return; } if (scrap_dirty) @@ -215,7 +217,7 @@ public abstract class Draw extends Image { image = Draw_FindPic(pic); if (image == null) { - ri.Con_Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n'); + VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n'); return; } @@ -249,7 +251,7 @@ public abstract class Draw extends Image { protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) { if ( colorIndex > 255) - ri.Sys_Error(Defines.ERR_FATAL, "Draw_Fill: bad color"); + Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color"); gl.glDisable(GL.GL_TEXTURE_2D); diff --git a/src/jake2/render/jogl/Image.java b/src/jake2/render/jogl/Image.java index 3a58884..64588ef 100644 --- a/src/jake2/render/jogl/Image.java +++ b/src/jake2/render/jogl/Image.java @@ -2,7 +2,7 @@ * Image.java * Copyright (C) 2003 * - * $Id: Image.java,v 1.4 2004-07-12 22:08:03 hzi Exp $ + * $Id: Image.java,v 1.5 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -26,8 +26,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package jake2.render.jogl; import jake2.Defines; +import jake2.client.VID; import jake2.client.particle_t; import jake2.game.cvar_t; +import jake2.qcommon.*; import jake2.qcommon.longjmpException; import jake2.qcommon.qfiles; import jake2.render.image_t; @@ -263,7 +265,7 @@ public abstract class Image extends Main { } if (i == NUM_GL_MODES) { - ri.Con_Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n"); + VID.Printf(Defines.PRINT_ALL, "bad filter name: [" + string + "]\n"); return; } @@ -297,7 +299,7 @@ public abstract class Image extends Main { } if (i == NUM_GL_ALPHA_MODES) { - ri.Con_Printf(Defines.PRINT_ALL, "bad alpha texture mode name: [" + string + "]\n"); + VID.Printf(Defines.PRINT_ALL, "bad alpha texture mode name: [" + string + "]\n"); return; } @@ -317,7 +319,7 @@ public abstract class Image extends Main { } if (i == NUM_GL_SOLID_MODES) { - ri.Con_Printf(Defines.PRINT_ALL, "bad solid texture mode name: [" + string + "]\n"); + VID.Printf(Defines.PRINT_ALL, "bad solid texture mode name: [" + string + "]\n"); return; } @@ -335,7 +337,7 @@ public abstract class Image extends Main { int texels; final String[] palstrings = { "RGB", "PAL" }; - ri.Con_Printf(Defines.PRINT_ALL, "------------------\n"); + VID.Printf(Defines.PRINT_ALL, "------------------\n"); texels = 0; for (int i = 0; i < numgltextures; i++) { @@ -346,29 +348,29 @@ public abstract class Image extends Main { texels += image.upload_width * image.upload_height; switch (image.type) { case it_skin : - ri.Con_Printf(Defines.PRINT_ALL, "M"); + VID.Printf(Defines.PRINT_ALL, "M"); break; case it_sprite : - ri.Con_Printf(Defines.PRINT_ALL, "S"); + VID.Printf(Defines.PRINT_ALL, "S"); break; case it_wall : - ri.Con_Printf(Defines.PRINT_ALL, "W"); + VID.Printf(Defines.PRINT_ALL, "W"); break; case it_pic : - ri.Con_Printf(Defines.PRINT_ALL, "P"); + VID.Printf(Defines.PRINT_ALL, "P"); break; default : - ri.Con_Printf(Defines.PRINT_ALL, " "); + VID.Printf(Defines.PRINT_ALL, " "); break; } - ri.Con_Printf( + VID.Printf( Defines.PRINT_ALL, " %3i %3i %s: %s\n", new Vargs(4).add(image.upload_width).add(image.upload_height).add(palstrings[(image.paletted) ? 1 : 0]).add( image.name)); } - ri.Con_Printf(Defines.PRINT_ALL, "Total texel count (not counting mipmaps): " + texels + '\n'); + VID.Printf(Defines.PRINT_ALL, "Total texel count (not counting mipmaps): " + texels + '\n'); } /* @@ -464,10 +466,10 @@ public abstract class Image extends Main { // // load the file // - byte[] raw = ri.FS_LoadFile(filename); + byte[] raw = FS.LoadFile(filename); if (raw == null) { - ri.Con_Printf(Defines.PRINT_DEVELOPER, "Bad pcx file " + filename + '\n'); + VID.Printf(Defines.PRINT_DEVELOPER, "Bad pcx file " + filename + '\n'); return null; } @@ -483,7 +485,7 @@ public abstract class Image extends Main { || pcx.xmax >= 640 || pcx.ymax >= 480) { - ri.Con_Printf(Defines.PRINT_ALL, "Bad pcx file " + filename + '\n'); + VID.Printf(Defines.PRINT_ALL, "Bad pcx file " + filename + '\n'); return null; } @@ -559,21 +561,21 @@ public abstract class Image extends Main { // // load the file // - raw = ri.FS_LoadFile (name); + raw = FS.LoadFile (name); if (raw == null) { - ri.Con_Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n'); + VID.Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n'); return null; } targa_header = new qfiles.tga_t(raw); if (targa_header.image_type != 2 && targa_header.image_type != 10) - ri.Sys_Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n"); + Com.Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n"); if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24)) - ri.Sys_Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); + Com.Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); columns = targa_header.width; rows = targa_header.height; @@ -1101,7 +1103,7 @@ public abstract class Image extends Main { upload_height = scaled_height; if (scaled_width * scaled_height > 256 * 256) - ri.Sys_Error(Defines.ERR_DROP, "GL_Upload32: too big"); + Com.Error(Defines.ERR_DROP, "GL_Upload32: too big"); // scan the texture for any non-255 alpha c = width * height; @@ -1119,7 +1121,7 @@ public abstract class Image extends Main { else if (samples == gl_alpha_format) comp = gl_tex_alpha_format; else { - ri.Con_Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n'); + VID.Printf(Defines.PRINT_ALL, "Unknown number of texture components " + samples + '\n'); comp = samples; } @@ -1262,7 +1264,7 @@ public abstract class Image extends Main { int s = width * height; if (s > trans.length) - ri.Sys_Error(Defines.ERR_DROP, "GL_Upload8: too large"); + Com.Error(Defines.ERR_DROP, "GL_Upload8: too large"); if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f && is_sky) { gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, width, height, 0, GL.GL_COLOR_INDEX, GL.GL_UNSIGNED_BYTE, data); @@ -1329,14 +1331,14 @@ public abstract class Image extends Main { if (i == numgltextures) { if (numgltextures == MAX_GLTEXTURES) - ri.Sys_Error (Defines.ERR_DROP, "MAX_GLTEXTURES"); + Com.Error (Defines.ERR_DROP, "MAX_GLTEXTURES"); numgltextures++; } image = gltextures[i]; if (name.length() > Defines.MAX_QPATH) - ri.Sys_Error(Defines.ERR_DROP, "Draw_LoadPic: \"" + name + "\" is too long"); + Com.Error(Defines.ERR_DROP, "Draw_LoadPic: \"" + name + "\" is too long"); image.name = name; image.registration_sequence = registration_sequence; @@ -1452,9 +1454,9 @@ public abstract class Image extends Main { image_t image = null; - byte[] raw = ri.FS_LoadFile(name); + byte[] raw = FS.LoadFile(name); if (raw == null) { - ri.Con_Printf(Defines.PRINT_ALL, "GL_FindImage: can't load " + name + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_FindImage: can't load " + name + '\n'); return r_notexture; } @@ -1486,8 +1488,8 @@ public abstract class Image extends Main { name = name.substring(0, index); if (name == null || name.length() < 5) - return null; // ri.Sys_Error (ERR_DROP, "GL_FindImage: NULL name"); - // ri.Sys_Error (ERR_DROP, "GL_FindImage: bad name: %s", name); + return null; // Com.Error (ERR_DROP, "GL_FindImage: NULL name"); + // Com.Error (ERR_DROP, "GL_FindImage: bad name: %s", name); // look for it for (int i = 0; i < numgltextures; i++) @@ -1595,7 +1597,7 @@ public abstract class Image extends Main { pic = LoadPCX("pics/colormap.pcx", palette, dim = new Dimension()); if (palette[0] == null || palette[0].length != 768) - ri.Sys_Error(Defines.ERR_FATAL, "Couldn't load pics/colormap.pcx"); + Com.Error(Defines.ERR_FATAL, "Couldn't load pics/colormap.pcx"); byte[] pal = palette[0]; @@ -1625,19 +1627,19 @@ public abstract class Image extends Main { registration_sequence = 1; // init intensity conversions - intensity = ri.Cvar_Get("intensity", "2", 0); + intensity = Cvar.Get("intensity", "2", 0); if (intensity.value <= 1) - ri.Cvar_Set("intensity", "1"); + Cvar.Set("intensity", "1"); gl_state.inverse_intensity = 1 / intensity.value; Draw_GetPalette(); if (qglColorTableEXT) { - gl_state.d_16to8table = ri.FS_LoadFile("pics/16to8.dat"); + gl_state.d_16to8table = FS.LoadFile("pics/16to8.dat"); if (gl_state.d_16to8table == null) - ri.Sys_Error(Defines.ERR_FATAL, "Couldn't load pics/16to8.pcx"); + Com.Error(Defines.ERR_FATAL, "Couldn't load pics/16to8.pcx"); } if ((gl_config.renderer & (GL_RENDERER_VOODOO | GL_RENDERER_VOODOO2)) != 0) { diff --git a/src/jake2/render/jogl/Light.java b/src/jake2/render/jogl/Light.java index e9e83af..de23629 100644 --- a/src/jake2/render/jogl/Light.java +++ b/src/jake2/render/jogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.5 2004-07-12 22:08:04 hzi Exp $ + * $Id: Light.java,v 1.6 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -31,6 +31,7 @@ import jake2.client.dlight_t; import jake2.client.lightstyle_t; import jake2.game.GameBase; import jake2.game.cplane_t; +import jake2.qcommon.Com; import jake2.qcommon.longjmpException; import jake2.render.*; import jake2.util.Math3D; @@ -503,13 +504,13 @@ public abstract class Light extends Warp { int monolightmap; if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP)) != 0 ) - ri.Sys_Error(Defines.ERR_DROP, "R_BuildLightMap called for non-lit surface"); + Com.Error(Defines.ERR_DROP, "R_BuildLightMap called for non-lit surface"); smax = (surf.extents[0] >> 4) + 1; tmax = (surf.extents[1] >> 4) + 1; size = smax * tmax; if (size > ((s_blocklights.length * Defines.SIZE_OF_FLOAT) >> 4) ) - ri.Sys_Error(Defines.ERR_DROP, "Bad s_blocklights size"); + Com.Error(Defines.ERR_DROP, "Bad s_blocklights size"); try { // set to full bright if no light data diff --git a/src/jake2/render/jogl/Main.java b/src/jake2/render/jogl/Main.java index 9f85422..ce5c8fe 100644 --- a/src/jake2/render/jogl/Main.java +++ b/src/jake2/render/jogl/Main.java @@ -2,7 +2,7 @@ * Main.java * Copyright (C) 2003 * - * $Id: Main.java,v 1.4 2004-07-15 14:37:34 hzi Exp $ + * $Id: Main.java,v 1.5 2004-07-16 10:11:35 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,6 +28,7 @@ package jake2.render.jogl; import jake2.Defines; import jake2.Globals; import jake2.client.*; +import jake2.game.*; import jake2.game.cplane_t; import jake2.game.cvar_t; import jake2.qcommon.*; @@ -419,7 +420,7 @@ public abstract class Main extends Base { R_DrawSpriteModel(currententity); break; default : - ri.Sys_Error(Defines.ERR_DROP, "Bad modeltype"); + Com.Error(Defines.ERR_DROP, "Bad modeltype"); break; } } @@ -453,7 +454,7 @@ public abstract class Main extends Base { R_DrawSpriteModel(currententity); break; default : - ri.Sys_Error(Defines.ERR_DROP, "Bad modeltype"); + Com.Error(Defines.ERR_DROP, "Bad modeltype"); break; } } @@ -825,11 +826,11 @@ public abstract class Main extends Base { // included by cwei if (r_newrefdef == null) { - ri.Sys_Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null"); + Com.Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null"); } if (r_worldmodel == null && (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0) - ri.Sys_Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel"); + Com.Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel"); if (r_speeds.value != 0.0f) { c_brush_polys = 0; @@ -862,7 +863,7 @@ public abstract class Main extends Base { R_Flash(); if (r_speeds.value != 0.0f) { - ri.Con_Printf( + VID.Printf( Defines.PRINT_ALL, "%4i wpoly %4i epoly %i tex %i lmaps\n", new Vargs(4).add(c_brush_polys).add(c_alias_polys).add(c_visible_textures).add(c_visible_lightmaps)); @@ -929,90 +930,90 @@ public abstract class Main extends Base { } protected void R_Register() { - r_lefthand = ri.Cvar_Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE); - r_norefresh = ri.Cvar_Get("r_norefresh", "0", 0); - r_fullbright = ri.Cvar_Get("r_fullbright", "0", 0); - r_drawentities = ri.Cvar_Get("r_drawentities", "1", 0); - r_drawworld = ri.Cvar_Get("r_drawworld", "1", 0); - r_novis = ri.Cvar_Get("r_novis", "0", 0); - r_nocull = ri.Cvar_Get("r_nocull", "0", 0); - r_lerpmodels = ri.Cvar_Get("r_lerpmodels", "1", 0); - r_speeds = ri.Cvar_Get("r_speeds", "0", 0); - - r_lightlevel = ri.Cvar_Get("r_lightlevel", "1", 0); - - gl_nosubimage = ri.Cvar_Get("gl_nosubimage", "0", 0); - gl_allow_software = ri.Cvar_Get("gl_allow_software", "0", 0); - - gl_particle_min_size = ri.Cvar_Get("gl_particle_min_size", "2", Globals.CVAR_ARCHIVE); - gl_particle_max_size = ri.Cvar_Get("gl_particle_max_size", "40", Globals.CVAR_ARCHIVE); - gl_particle_size = ri.Cvar_Get("gl_particle_size", "40", Globals.CVAR_ARCHIVE); - gl_particle_att_a = ri.Cvar_Get("gl_particle_att_a", "0.01", Globals.CVAR_ARCHIVE); - gl_particle_att_b = ri.Cvar_Get("gl_particle_att_b", "0.0", Globals.CVAR_ARCHIVE); - gl_particle_att_c = ri.Cvar_Get("gl_particle_att_c", "0.01", Globals.CVAR_ARCHIVE); - - gl_modulate = ri.Cvar_Get("gl_modulate", "1", Globals.CVAR_ARCHIVE); - gl_log = ri.Cvar_Get("gl_log", "0", 0); - gl_bitdepth = ri.Cvar_Get("gl_bitdepth", "0", 0); - gl_mode = ri.Cvar_Get("gl_mode", "1", Globals.CVAR_ARCHIVE); - gl_lightmap = ri.Cvar_Get("gl_lightmap", "0", 0); - gl_shadows = ri.Cvar_Get("gl_shadows", "0", Globals.CVAR_ARCHIVE); - gl_dynamic = ri.Cvar_Get("gl_dynamic", "1", 0); - gl_nobind = ri.Cvar_Get("gl_nobind", "0", 0); - gl_round_down = ri.Cvar_Get("gl_round_down", "1", 0); - gl_picmip = ri.Cvar_Get("gl_picmip", "0", 0); - gl_skymip = ri.Cvar_Get("gl_skymip", "0", 0); - gl_showtris = ri.Cvar_Get("gl_showtris", "0", 0); - gl_ztrick = ri.Cvar_Get("gl_ztrick", "0", 0); - gl_finish = ri.Cvar_Get("gl_finish", "0", Globals.CVAR_ARCHIVE); - gl_clear = ri.Cvar_Get("gl_clear", "0", 0); - gl_cull = ri.Cvar_Get("gl_cull", "1", 0); - gl_polyblend = ri.Cvar_Get("gl_polyblend", "1", 0); - gl_flashblend = ri.Cvar_Get("gl_flashblend", "0", 0); - gl_playermip = ri.Cvar_Get("gl_playermip", "0", 0); - gl_monolightmap = ri.Cvar_Get("gl_monolightmap", "0", 0); - gl_driver = ri.Cvar_Get("gl_driver", "opengl32", Globals.CVAR_ARCHIVE); - gl_texturemode = ri.Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", Globals.CVAR_ARCHIVE); - gl_texturealphamode = ri.Cvar_Get("gl_texturealphamode", "default", Globals.CVAR_ARCHIVE); - gl_texturesolidmode = ri.Cvar_Get("gl_texturesolidmode", "default", Globals.CVAR_ARCHIVE); - gl_lockpvs = ri.Cvar_Get("gl_lockpvs", "0", 0); - - gl_vertex_arrays = ri.Cvar_Get("gl_vertex_arrays", "0", Globals.CVAR_ARCHIVE); - - gl_ext_swapinterval = ri.Cvar_Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE); - gl_ext_palettedtexture = ri.Cvar_Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE); - gl_ext_multitexture = ri.Cvar_Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE); - gl_ext_pointparameters = ri.Cvar_Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE); - gl_ext_compiled_vertex_array = ri.Cvar_Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE); - - gl_drawbuffer = ri.Cvar_Get("gl_drawbuffer", "GL_BACK", 0); - gl_swapinterval = ri.Cvar_Get("gl_swapinterval", "1", Globals.CVAR_ARCHIVE); - - gl_saturatelighting = ri.Cvar_Get("gl_saturatelighting", "0", 0); - - gl_3dlabs_broken = ri.Cvar_Get("gl_3dlabs_broken", "1", Globals.CVAR_ARCHIVE); - - vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", Globals.CVAR_ARCHIVE); - vid_gamma = ri.Cvar_Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE); - vid_ref = ri.Cvar_Get("vid_ref", "jogl", Globals.CVAR_ARCHIVE); - - ri.Cmd_AddCommand("imagelist", new xcommand_t() { + r_lefthand = Cvar.Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE); + r_norefresh = Cvar.Get("r_norefresh", "0", 0); + r_fullbright = Cvar.Get("r_fullbright", "0", 0); + r_drawentities = Cvar.Get("r_drawentities", "1", 0); + r_drawworld = Cvar.Get("r_drawworld", "1", 0); + r_novis = Cvar.Get("r_novis", "0", 0); + r_nocull = Cvar.Get("r_nocull", "0", 0); + r_lerpmodels = Cvar.Get("r_lerpmodels", "1", 0); + r_speeds = Cvar.Get("r_speeds", "0", 0); + + r_lightlevel = Cvar.Get("r_lightlevel", "1", 0); + + gl_nosubimage = Cvar.Get("gl_nosubimage", "0", 0); + gl_allow_software = Cvar.Get("gl_allow_software", "0", 0); + + gl_particle_min_size = Cvar.Get("gl_particle_min_size", "2", Globals.CVAR_ARCHIVE); + gl_particle_max_size = Cvar.Get("gl_particle_max_size", "40", Globals.CVAR_ARCHIVE); + gl_particle_size = Cvar.Get("gl_particle_size", "40", Globals.CVAR_ARCHIVE); + gl_particle_att_a = Cvar.Get("gl_particle_att_a", "0.01", Globals.CVAR_ARCHIVE); + gl_particle_att_b = Cvar.Get("gl_particle_att_b", "0.0", Globals.CVAR_ARCHIVE); + gl_particle_att_c = Cvar.Get("gl_particle_att_c", "0.01", Globals.CVAR_ARCHIVE); + + gl_modulate = Cvar.Get("gl_modulate", "1", Globals.CVAR_ARCHIVE); + gl_log = Cvar.Get("gl_log", "0", 0); + gl_bitdepth = Cvar.Get("gl_bitdepth", "0", 0); + gl_mode = Cvar.Get("gl_mode", "1", Globals.CVAR_ARCHIVE); + gl_lightmap = Cvar.Get("gl_lightmap", "0", 0); + gl_shadows = Cvar.Get("gl_shadows", "0", Globals.CVAR_ARCHIVE); + gl_dynamic = Cvar.Get("gl_dynamic", "1", 0); + gl_nobind = Cvar.Get("gl_nobind", "0", 0); + gl_round_down = Cvar.Get("gl_round_down", "1", 0); + gl_picmip = Cvar.Get("gl_picmip", "0", 0); + gl_skymip = Cvar.Get("gl_skymip", "0", 0); + gl_showtris = Cvar.Get("gl_showtris", "0", 0); + gl_ztrick = Cvar.Get("gl_ztrick", "0", 0); + gl_finish = Cvar.Get("gl_finish", "0", Globals.CVAR_ARCHIVE); + gl_clear = Cvar.Get("gl_clear", "0", 0); + gl_cull = Cvar.Get("gl_cull", "1", 0); + gl_polyblend = Cvar.Get("gl_polyblend", "1", 0); + gl_flashblend = Cvar.Get("gl_flashblend", "0", 0); + gl_playermip = Cvar.Get("gl_playermip", "0", 0); + gl_monolightmap = Cvar.Get("gl_monolightmap", "0", 0); + gl_driver = Cvar.Get("gl_driver", "opengl32", Globals.CVAR_ARCHIVE); + gl_texturemode = Cvar.Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", Globals.CVAR_ARCHIVE); + gl_texturealphamode = Cvar.Get("gl_texturealphamode", "default", Globals.CVAR_ARCHIVE); + gl_texturesolidmode = Cvar.Get("gl_texturesolidmode", "default", Globals.CVAR_ARCHIVE); + gl_lockpvs = Cvar.Get("gl_lockpvs", "0", 0); + + gl_vertex_arrays = Cvar.Get("gl_vertex_arrays", "0", Globals.CVAR_ARCHIVE); + + gl_ext_swapinterval = Cvar.Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE); + gl_ext_palettedtexture = Cvar.Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE); + gl_ext_multitexture = Cvar.Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE); + gl_ext_pointparameters = Cvar.Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE); + gl_ext_compiled_vertex_array = Cvar.Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE); + + gl_drawbuffer = Cvar.Get("gl_drawbuffer", "GL_BACK", 0); + gl_swapinterval = Cvar.Get("gl_swapinterval", "1", Globals.CVAR_ARCHIVE); + + gl_saturatelighting = Cvar.Get("gl_saturatelighting", "0", 0); + + gl_3dlabs_broken = Cvar.Get("gl_3dlabs_broken", "1", Globals.CVAR_ARCHIVE); + + vid_fullscreen = Cvar.Get("vid_fullscreen", "0", Globals.CVAR_ARCHIVE); + vid_gamma = Cvar.Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE); + vid_ref = Cvar.Get("vid_ref", "jogl", Globals.CVAR_ARCHIVE); + + Cmd.AddCommand("imagelist", new xcommand_t() { public void execute() { GL_ImageList_f(); } }); - ri.Cmd_AddCommand("screenshot", new xcommand_t() { + Cmd.AddCommand("screenshot", new xcommand_t() { public void execute() { GL_ScreenShot_f(); } }); - ri.Cmd_AddCommand("modellist", new xcommand_t() { + Cmd.AddCommand("modellist", new xcommand_t() { public void execute() { Mod_Modellist_f(); } }); - ri.Cmd_AddCommand("gl_strings", new xcommand_t() { + Cmd.AddCommand("gl_strings", new xcommand_t() { public void execute() { GL_Strings_f(); } @@ -1030,8 +1031,8 @@ public abstract class Main extends Base { boolean fullscreen; // if (vid_fullscreen.modified && !gl_config.allow_cds) { -// ri.Con_Printf(Defines.PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n"); -// ri.Cvar_SetValue("vid_fullscreen", (vid_fullscreen.value > 0.0f) ? 0.0f : 1.0f); +// VID.Printf(Defines.PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n"); +// Cvar.SetValue("vid_fullscreen", (vid_fullscreen.value > 0.0f) ? 0.0f : 1.0f); // vid_fullscreen.modified = false; // } @@ -1047,21 +1048,21 @@ public abstract class Main extends Base { } else { if (err == rserr_invalid_fullscreen) { - ri.Cvar_SetValue("vid_fullscreen", 0); + Cvar.SetValue("vid_fullscreen", 0); vid_fullscreen.modified = false; - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n"); + VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n"); if ((err = GLimp_SetMode(dim, (int) gl_mode.value, false)) == rserr_ok) return true; } else if (err == rserr_invalid_mode) { - ri.Cvar_SetValue("gl_mode", gl_state.prev_mode); + Cvar.SetValue("gl_mode", gl_state.prev_mode); gl_mode.modified = false; - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n"); + VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n"); } // try setting it back to something safe if ((err = GLimp_SetMode(dim, gl_state.prev_mode, false)) != rserr_ok) { - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n"); + VID.Printf(Defines.PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n"); return false; } } @@ -1084,7 +1085,7 @@ public abstract class Main extends Base { r_turbsin[j] = Warp.SIN[j] * 0.5f; } - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl version: " + REF_VERSION + '\n'); + VID.Printf(Defines.PRINT_ALL, "ref_gl version: " + REF_VERSION + '\n'); Draw_GetPalette(); @@ -1095,26 +1096,26 @@ public abstract class Main extends Base { // create the window and set up the context if (!R_SetMode()) { - ri.Con_Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n"); + VID.Printf(Defines.PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n"); return false; } return true; } protected boolean R_Init2() { - ri.Vid_MenuInit(); + VID.MenuInit(); /* ** get our various GL strings */ gl_config.vendor_string = gl.glGetString(GL.GL_VENDOR); - ri.Con_Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); gl_config.renderer_string = gl.glGetString(GL.GL_RENDERER); - ri.Con_Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); gl_config.version_string = gl.glGetString(GL.GL_VERSION); - ri.Con_Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); gl_config.extensions_string = gl.glGetString(GL.GL_EXTENSIONS); - ri.Con_Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); + VID.Printf(Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); String renderer_buffer = gl_config.renderer_string.toLowerCase(); String vendor_buffer = gl_config.vendor_string.toLowerCase(); @@ -1145,33 +1146,33 @@ public abstract class Main extends Base { String monolightmap = gl_monolightmap.string.toUpperCase(); if (monolightmap.length() < 2 || monolightmap.charAt(1) != 'F') { if (gl_config.renderer == GL_RENDERER_PERMEDIA2) { - ri.Cvar_Set("gl_monolightmap", "A"); - ri.Con_Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\n"); + Cvar.Set("gl_monolightmap", "A"); + VID.Printf(Defines.PRINT_ALL, "...using gl_monolightmap 'a'\n"); } else if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { - ri.Cvar_Set("gl_monolightmap", "0"); + Cvar.Set("gl_monolightmap", "0"); } else { - ri.Cvar_Set("gl_monolightmap", "0"); + Cvar.Set("gl_monolightmap", "0"); } } // power vr can't have anything stay in the framebuffer, so // the screen needs to redraw the tiled background every frame if ((gl_config.renderer & GL_RENDERER_POWERVR) != 0) { - ri.Cvar_Set("scr_drawall", "1"); + Cvar.Set("scr_drawall", "1"); } else { - ri.Cvar_Set("scr_drawall", "0"); + Cvar.Set("scr_drawall", "0"); } // #ifdef __linux__ - ri.Cvar_SetValue("gl_finish", 1); + Cvar.SetValue("gl_finish", 1); // #endif // MCD has buffering issues if (gl_config.renderer == GL_RENDERER_MCD) { - ri.Cvar_SetValue("gl_finish", 1); + Cvar.SetValue("gl_finish", 1); } if ((gl_config.renderer & GL_RENDERER_3DLABS) != 0) { @@ -1185,16 +1186,16 @@ public abstract class Main extends Base { } if (gl_config.allow_cds) - ri.Con_Printf(Defines.PRINT_ALL, "...allowing CDS\n"); + VID.Printf(Defines.PRINT_ALL, "...allowing CDS\n"); else - ri.Con_Printf(Defines.PRINT_ALL, "...disabling CDS\n"); + VID.Printf(Defines.PRINT_ALL, "...disabling CDS\n"); /* ** grab extensions */ if (gl_config.extensions_string.indexOf("GL_EXT_compiled_vertex_array") >= 0 || gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) { - ri.Con_Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n"); + VID.Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n"); // qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" ); if (gl_ext_compiled_vertex_array.value != 0.0f) qglLockArraysEXT = true; @@ -1204,15 +1205,15 @@ public abstract class Main extends Base { //qglUnlockArraysEXT = true; } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n"); } if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) { qwglSwapIntervalEXT = true; - ri.Con_Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n"); + VID.Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n"); } else { qwglSwapIntervalEXT = false; - ri.Con_Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n"); + VID.Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n"); } if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) { @@ -1220,14 +1221,14 @@ public abstract class Main extends Base { // qglPointParameterfEXT = ( void (APIENTRY *)( GLenum, GLfloat ) ) qwglGetProcAddress( "glPointParameterfEXT" ); qglPointParameterfEXT = true; // qglPointParameterfvEXT = ( void (APIENTRY *)( GLenum, const GLfloat * ) ) qwglGetProcAddress( "glPointParameterfvEXT" ); - ri.Con_Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\n"); + VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_point_parameters\n"); } else { - ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n"); + VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_point_parameters\n"); } } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_EXT_point_parameters not found\n"); } // #ifdef __linux__ @@ -1235,18 +1236,18 @@ public abstract class Main extends Base { // { // if ( gl_ext_palettedtexture->value ) // { - // ri.Con_Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" ); + // VID.Printf( Defines.PRINT_ALL, "...using 3DFX_set_global_palette\n" ); // qgl3DfxSetPaletteEXT = ( void ( APIENTRY * ) (GLuint *) )qwglGetProcAddress( "gl3DfxSetPaletteEXT" ); //// qglColorTableEXT = Fake_glColorTableEXT; // } // else // { - // ri.Con_Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" ); + // VID.Printf( Defines.PRINT_ALL, "...ignoring 3DFX_set_global_palette\n" ); // } // } // else // { - // ri.Con_Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" ); + // VID.Printf( Defines.PRINT_ALL, "...3DFX_set_global_palette not found\n" ); // } // #endif @@ -1254,21 +1255,21 @@ public abstract class Main extends Base { && gl_config.extensions_string.indexOf("GL_EXT_paletted_texture") >= 0 && gl_config.extensions_string.indexOf("GL_EXT_shared_texture_palette") >= 0) { if (gl_ext_palettedtexture.value != 0.0f) { - ri.Con_Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\n"); + VID.Printf(Defines.PRINT_ALL, "...using GL_EXT_shared_texture_palette\n"); qglColorTableEXT = false; // true; TODO jogl bug } else { - ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n"); + VID.Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n"); qglColorTableEXT = false; } } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n"); } if (gl_config.extensions_string.indexOf("GL_ARB_multitexture") >= 0) { if (gl_ext_multitexture.value != 0.0f) { - ri.Con_Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n"); + VID.Printf(Defines.PRINT_ALL, "...using GL_ARB_multitexture\n"); // qglMTexCoord2fSGIS = ( void * ) qwglGetProcAddress( "glMultiTexCoord2fARB" ); // qglActiveTextureARB = ( void * ) qwglGetProcAddress( "glActiveTextureARB" ); // qglClientActiveTextureARB = ( void * ) qwglGetProcAddress( "glClientActiveTextureARB" ); @@ -1279,21 +1280,21 @@ public abstract class Main extends Base { Cvar.SetValue("r_fullbright", 1); } else { - ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_ARB_multitexture\n"); + VID.Printf(Defines.PRINT_ALL, "...ignoring GL_ARB_multitexture\n"); Cvar.SetValue("r_fullbright", 0); } } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n"); Cvar.SetValue("r_fullbright", 0); } if (gl_config.extensions_string.indexOf("GL_SGIS_multitexture") >= 0) { if (qglActiveTextureARB) { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_SGIS_multitexture deprecated in favor of ARB_multitexture\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_SGIS_multitexture deprecated in favor of ARB_multitexture\n"); Cvar.SetValue("r_fullbright", 1); } else if (gl_ext_multitexture.value != 0.0f) { - ri.Con_Printf(Defines.PRINT_ALL, "...using GL_SGIS_multitexture\n"); + VID.Printf(Defines.PRINT_ALL, "...using GL_SGIS_multitexture\n"); // qglMTexCoord2fSGIS = ( void * ) qwglGetProcAddress( "glMTexCoord2fSGIS" ); // qglSelectTextureSGIS = ( void * ) qwglGetProcAddress( "glSelectTextureSGIS" ); qglSelectTextureSGIS = true; @@ -1302,12 +1303,12 @@ public abstract class Main extends Base { // //GL_TEXTURE0 = GL.GL_TEXTURE0_SGIS; // //GL_TEXTURE1 = GL.GL_TEXTURE1_SGIS; } else { - ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_SGIS_multitexture\n"); + VID.Printf(Defines.PRINT_ALL, "...ignoring GL_SGIS_multitexture\n"); Cvar.SetValue("r_fullbright", 0); } } else { - ri.Con_Printf(Defines.PRINT_ALL, "...GL_SGIS_multitexture not found\n"); + VID.Printf(Defines.PRINT_ALL, "...GL_SGIS_multitexture not found\n"); if (!qglActiveTextureARB) Cvar.SetValue("r_fullbright", 0); } @@ -1321,7 +1322,7 @@ public abstract class Main extends Base { int err = gl.glGetError(); if (err != GL.GL_NO_ERROR) - ri.Con_Printf( + VID.Printf( Defines.PRINT_ALL, "glGetError() = 0x%x\n\t%s\n", new Vargs(2).add(err).add("" + gl.glGetString(err))); @@ -1335,10 +1336,10 @@ public abstract class Main extends Base { =============== */ protected void R_Shutdown() { - ri.Cmd_RemoveCommand("modellist"); - ri.Cmd_RemoveCommand("screenshot"); - ri.Cmd_RemoveCommand("imagelist"); - ri.Cmd_RemoveCommand("gl_strings"); + Cmd.RemoveCommand("modellist"); + Cmd.RemoveCommand("screenshot"); + Cmd.RemoveCommand("imagelist"); + Cmd.RemoveCommand("gl_strings"); Mod_FreeAll(); @@ -1366,7 +1367,7 @@ public abstract class Main extends Base { // FIXME: only restart if CDS is required cvar_t ref; - ref = ri.Cvar_Get("vid_ref", "jogl", 0); + ref = Cvar.Get("vid_ref", "jogl", 0); ref.modified = true; } @@ -1399,7 +1400,7 @@ public abstract class Main extends Base { Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g ); putenv( envbuffer ); */ - ri.Con_Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt"); + VID.Printf(Defines.PRINT_DEVELOPER, "gamma anpassung fuer VOODOO nicht gesetzt"); } } diff --git a/src/jake2/render/jogl/Mesh.java b/src/jake2/render/jogl/Mesh.java index 4a53371..4a8aed3 100644 --- a/src/jake2/render/jogl/Mesh.java +++ b/src/jake2/render/jogl/Mesh.java @@ -2,7 +2,7 @@ * Mesh.java * Copyright (C) 2003 * - * $Id: Mesh.java,v 1.5 2004-07-12 22:08:03 hzi Exp $ + * $Id: Mesh.java,v 1.6 2004-07-16 10:11:35 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.render.jogl; import jake2.Defines; +import jake2.client.VID; import jake2.client.entity_t; import jake2.qcommon.qfiles; import jake2.render.image_t; @@ -474,12 +475,12 @@ public abstract class Mesh extends Light { if ( ( e.frame >= paliashdr.num_frames ) || ( e.frame < 0 ) ) { - ri.Con_Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name +": no such frame " + e.frame + '\n'); + VID.Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name +": no such frame " + e.frame + '\n'); e.frame = 0; } if ( ( e.oldframe >= paliashdr.num_frames ) || ( e.oldframe < 0 ) ) { - ri.Con_Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n'); + VID.Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n'); e.oldframe = 0; } @@ -809,7 +810,7 @@ public abstract class Mesh extends Light { if ( (currententity.frame >= paliashdr.num_frames) || (currententity.frame < 0) ) { - ri.Con_Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such frame " + currententity.frame + '\n'); + VID.Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such frame " + currententity.frame + '\n'); currententity.frame = 0; currententity.oldframe = 0; } @@ -817,7 +818,7 @@ public abstract class Mesh extends Light { if ( (currententity.oldframe >= paliashdr.num_frames) || (currententity.oldframe < 0)) { - ri.Con_Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such oldframe " + currententity.oldframe + '\n'); + VID.Printf (Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name +": no such oldframe " + currententity.oldframe + '\n'); currententity.frame = 0; currententity.oldframe = 0; } diff --git a/src/jake2/render/jogl/Misc.java b/src/jake2/render/jogl/Misc.java index a1d2e70..256e0cf 100644 --- a/src/jake2/render/jogl/Misc.java +++ b/src/jake2/render/jogl/Misc.java @@ -2,7 +2,7 @@ * Misc.java * Copyright (C) 2003 * - * $Id: Misc.java,v 1.2 2004-07-09 06:50:48 hzi Exp $ + * $Id: Misc.java,v 1.3 2004-07-16 10:11:35 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.render.jogl; import jake2.Defines; +import jake2.client.VID; import net.java.games.jogl.GL; import net.java.games.jogl.WGL; @@ -145,7 +146,7 @@ public abstract class Misc extends Mesh { // } // if (i==100) // { -// ri.Con_Printf (PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n"); +// VID.Printf (PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n"); // return; // } // @@ -175,17 +176,17 @@ public abstract class Misc extends Mesh { // fclose (f); // // free (buffer); -// ri.Con_Printf (PRINT_ALL, "Wrote %s\n", picname); +// VID.Printf (PRINT_ALL, "Wrote %s\n", picname); } /* ** GL_Strings_f */ void GL_Strings_f() { - ri.Con_Printf (Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); - ri.Con_Printf (Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); - ri.Con_Printf (Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); - ri.Con_Printf (Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); + VID.Printf (Defines.PRINT_ALL, "GL_VENDOR: " + gl_config.vendor_string + '\n'); + VID.Printf (Defines.PRINT_ALL, "GL_RENDERER: " + gl_config.renderer_string + '\n'); + VID.Printf (Defines.PRINT_ALL, "GL_VERSION: " + gl_config.version_string + '\n'); + VID.Printf (Defines.PRINT_ALL, "GL_EXTENSIONS: " + gl_config.extensions_string + '\n'); } /* diff --git a/src/jake2/render/jogl/Model.java b/src/jake2/render/jogl/Model.java index 9a10cf5..2508d69 100644 --- a/src/jake2/render/jogl/Model.java +++ b/src/jake2/render/jogl/Model.java @@ -2,7 +2,7 @@ * Model.java * Copyright (C) 2003 * - * $Id: Model.java,v 1.3 2004-07-12 22:08:03 hzi Exp $ + * $Id: Model.java,v 1.4 2004-07-16 10:11:35 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.render.jogl; import jake2.Defines; +import jake2.client.VID; import jake2.game.cplane_t; import jake2.game.cvar_t; import jake2.qcommon.*; @@ -72,7 +73,7 @@ public abstract class Model extends Surf { cplane_t plane; if (model == null || model.nodes == null) - ri.Sys_Error (Defines.ERR_DROP, "Mod_PointInLeaf: bad model"); + Com.Error (Defines.ERR_DROP, "Mod_PointInLeaf: bad model"); node = model.nodes[0]; // root node while (true) @@ -169,17 +170,17 @@ public abstract class Model extends Surf { int total; total = 0; - ri.Con_Printf(Defines.PRINT_ALL,"Loaded models:\n"); + VID.Printf(Defines.PRINT_ALL,"Loaded models:\n"); for (i=0; i < mod_numknown ; i++) { mod = mod_known[i]; if (mod.name == "") continue; - ri.Con_Printf (Defines.PRINT_ALL, "%8i : %s\n", new Vargs(2).add(mod.extradatasize).add(mod.name)); + VID.Printf (Defines.PRINT_ALL, "%8i : %s\n", new Vargs(2).add(mod.extradatasize).add(mod.name)); total += mod.extradatasize; } - ri.Con_Printf (Defines.PRINT_ALL, "Total resident: " + total +'\n'); + VID.Printf (Defines.PRINT_ALL, "Total resident: " + total +'\n'); } /* @@ -211,7 +212,7 @@ public abstract class Model extends Surf { int i; if (name == null || name.length() == 0) - ri.Sys_Error(Defines.ERR_DROP, "Mod_ForName: NULL name"); + Com.Error(Defines.ERR_DROP, "Mod_ForName: NULL name"); // // inline models are grabbed only from worldmodel @@ -220,7 +221,7 @@ public abstract class Model extends Surf { { i = Integer.parseInt(name.substring(1)); if (i < 1 || r_worldmodel == null || i >= r_worldmodel.numsubmodels) - ri.Sys_Error (Defines.ERR_DROP, "bad inline model number"); + Com.Error (Defines.ERR_DROP, "bad inline model number"); return mod_inline[i]; } @@ -250,7 +251,7 @@ public abstract class Model extends Surf { if (i == mod_numknown) { if (mod_numknown == MAX_MOD_KNOWN) - ri.Sys_Error (Defines.ERR_DROP, "mod_numknown == MAX_MOD_KNOWN"); + Com.Error (Defines.ERR_DROP, "mod_numknown == MAX_MOD_KNOWN"); mod_numknown++; mod = mod_known[i]; } @@ -260,12 +261,12 @@ public abstract class Model extends Surf { // // load the file // - fileBuffer = ri.FS_LoadFile(name); + fileBuffer = FS.LoadFile(name); if (fileBuffer == null) { if (crash) - ri.Sys_Error(Defines.ERR_DROP, "Mod_NumForName: " + mod.name + " not found"); + Com.Error(Defines.ERR_DROP, "Mod_NumForName: " + mod.name + " not found"); mod.name = ""; return null; @@ -300,7 +301,7 @@ public abstract class Model extends Surf { Mod_LoadBrushModel(mod, bb); break; default: - ri.Sys_Error(Defines.ERR_DROP,"Mod_NumForName: unknown fileid for " + mod.name); + Com.Error(Defines.ERR_DROP,"Mod_NumForName: unknown fileid for " + mod.name); break; } @@ -382,7 +383,7 @@ public abstract class Model extends Surf { int i, count; if ( (l.filelen % mvertex_t.DISK_SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / mvertex_t.DISK_SIZE; @@ -429,7 +430,7 @@ public abstract class Model extends Surf { int i, j, count; if ((l.filelen % qfiles.dmodel_t.SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dmodel_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -469,7 +470,7 @@ public abstract class Model extends Surf { int i, count; if ( (l.filelen % medge_t.DISK_SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / medge_t.DISK_SIZE; // out = Hunk_Alloc ( (count + 1) * sizeof(*out)); @@ -502,7 +503,7 @@ public abstract class Model extends Surf { String name; if ((l.filelen % texinfo_t.SIZE) != 0) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / texinfo_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -532,7 +533,7 @@ public abstract class Model extends Surf { out[i].image = GL_FindImage(name, it_wall); if (out[i].image == null) { - ri.Con_Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n'); + VID.Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n'); out[i].image = r_notexture; } } @@ -614,7 +615,7 @@ public abstract class Model extends Surf { int ti; if ((l.filelen % qfiles.dface_t.SIZE) != 0) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dface_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -648,7 +649,7 @@ public abstract class Model extends Surf { ti = in.texinfo; if (ti < 0 || ti >= loadmodel.numtexinfo) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: bad texinfo number"); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: bad texinfo number"); out[surfnum].texinfo = loadmodel.texinfo[ti]; @@ -720,7 +721,7 @@ public abstract class Model extends Surf { mnode_t[] out; if ((l.filelen % qfiles.dnode_t.SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dnode_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -777,7 +778,7 @@ public abstract class Model extends Surf { int i, j, count, p; if ((l.filelen % qfiles.dleaf_t.SIZE) != 0) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dleaf_t.SIZE; // out = Hunk_Alloc ( count*sizeof(*out)); @@ -822,7 +823,7 @@ public abstract class Model extends Surf { msurface_t[] out; if ((l.filelen % Defines.SIZE_OF_SHORT) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / Defines.SIZE_OF_SHORT; // out = Hunk_Alloc ( count*sizeof(*out)); out = new msurface_t[count]; @@ -837,7 +838,7 @@ public abstract class Model extends Surf { { j = bb.getShort(); if (j < 0 || j >= loadmodel.numsurfaces) - ri.Sys_Error(Defines.ERR_DROP, "Mod_ParseMarksurfaces: bad surface number"); + Com.Error(Defines.ERR_DROP, "Mod_ParseMarksurfaces: bad surface number"); out[i] = loadmodel.surfaces[j]; } @@ -855,11 +856,11 @@ public abstract class Model extends Surf { int[] offsets; if ( (l.filelen % Defines.SIZE_OF_INT) != 0) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / Defines.SIZE_OF_INT; if (count < 1 || count >= Defines.MAX_MAP_SURFEDGES) - ri.Sys_Error (Defines.ERR_DROP, "MOD_LoadBmodel: bad surfedges count in " + loadmodel.name + ": " + count); + Com.Error (Defines.ERR_DROP, "MOD_LoadBmodel: bad surfedges count in " + loadmodel.name + ": " + count); offsets = new int[count]; @@ -887,7 +888,7 @@ public abstract class Model extends Surf { int bits; if ((l.filelen % qfiles.dplane_t.SIZE) != 0) - ri.Sys_Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); + Com.Error(Defines.ERR_DROP, "MOD_LoadBmodel: funny lump size in " + loadmodel.name); count = l.filelen / qfiles.dplane_t.SIZE; // out = Hunk_Alloc ( count*2*sizeof(*out)); @@ -930,13 +931,13 @@ public abstract class Model extends Surf { loadmodel.type = mod_brush; if (loadmodel != mod_known[0]) - ri.Sys_Error(Defines.ERR_DROP, "Loaded a brush model after the world"); + Com.Error(Defines.ERR_DROP, "Loaded a brush model after the world"); header = new qfiles.dheader_t(buffer); i = header.version; if (i != Defines.BSPVERSION) - ri.Sys_Error (Defines.ERR_DROP, "Mod_LoadBrushModel: " + mod.name + " has wrong version number (" + i + " should be " + Defines.BSPVERSION + ")"); + Com.Error (Defines.ERR_DROP, "Mod_LoadBrushModel: " + mod.name + " has wrong version number (" + i + " should be " + Defines.BSPVERSION + ")"); mod_base = fileBuffer; //(byte *)header; @@ -970,7 +971,7 @@ public abstract class Model extends Surf { starmod.nummodelsurfaces = bm.numfaces; starmod.firstnode = bm.headnode; if (starmod.firstnode >= loadmodel.numnodes) - ri.Sys_Error(Defines.ERR_DROP, "Inline model " + i + " has bad firstnode"); + Com.Error(Defines.ERR_DROP, "Inline model " + i + " has bad firstnode"); Math3D.VectorCopy(bm.maxs, starmod.maxs); Math3D.VectorCopy(bm.mins, starmod.mins); @@ -1008,26 +1009,26 @@ public abstract class Model extends Surf { pheader = new qfiles.dmdl_t(buffer); if (pheader.version != qfiles.ALIAS_VERSION) - ri.Sys_Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", + Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", new Vargs(3).add(mod.name).add(pheader.version).add(qfiles.ALIAS_VERSION)); if (pheader.skinheight > MAX_LBM_HEIGHT) - ri.Sys_Error(Defines.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT); + Com.Error(Defines.ERR_DROP, "model "+ mod.name +" has a skin taller than " + MAX_LBM_HEIGHT); if (pheader.num_xyz <= 0) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no vertices"); + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no vertices"); if (pheader.num_xyz > qfiles.MAX_VERTS) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name +" has too many vertices"); + Com.Error(Defines.ERR_DROP, "model " + mod.name +" has too many vertices"); if (pheader.num_st <= 0) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no st vertices"); + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no st vertices"); if (pheader.num_tris <= 0) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no triangles"); + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no triangles"); if (pheader.num_frames <= 0) - ri.Sys_Error(Defines.ERR_DROP, "model " + mod.name + " has no frames"); + Com.Error(Defines.ERR_DROP, "model " + mod.name + " has no frames"); // // load base s and t vertices (not used in gl version) @@ -1120,11 +1121,11 @@ public abstract class Model extends Surf { qfiles.dsprite_t sprout = new qfiles.dsprite_t(buffer); if (sprout.version != qfiles.SPRITE_VERSION) - ri.Sys_Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", + Com.Error(Defines.ERR_DROP, "%s has wrong version number (%i should be %i)", new Vargs(3).add(mod.name).add(sprout.version).add(qfiles.SPRITE_VERSION)); if (sprout.numframes > qfiles.MAX_MD2SKINS) - ri.Sys_Error(Defines.ERR_DROP, "%s has too many frames (%i > %i)", + Com.Error(Defines.ERR_DROP, "%s has too many frames (%i > %i)", new Vargs(3).add(mod.name).add(sprout.numframes).add(qfiles.MAX_MD2SKINS)); for (int i=0 ; i 60) - ri.Sys_Error(Defines.ERR_DROP, "numverts = " + numverts); + Com.Error(Defines.ERR_DROP, "numverts = " + numverts); BoundPoly(numverts, verts, mins, maxs); @@ -454,7 +455,7 @@ public abstract class Warp extends Model { int i, j; if (nump > MAX_CLIP_VERTS-2) - ri.Sys_Error(Defines.ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); + Com.Error(Defines.ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); if (stage == 6) { // fully clipped, so draw it DrawSkyPolygon(nump, vecs); diff --git a/test/jake2/render/DancingQueens.java b/test/jake2/render/DancingQueens.java index c59c509..a95891f 100644 --- a/test/jake2/render/DancingQueens.java +++ b/test/jake2/render/DancingQueens.java @@ -2,7 +2,7 @@ * DancingQueens.java * Copyright (C) 2003 * - * $Id: DancingQueens.java,v 1.4 2004-07-15 14:38:40 hzi Exp $ + * $Id: DancingQueens.java,v 1.5 2004-07-16 10:11:36 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -50,7 +50,6 @@ public class DancingQueens String[] args; refexport_t re; - refimport_t ri; viddef_t viddef; int framecount = 0; @@ -67,91 +66,6 @@ public class DancingQueens void init() { - // only for testing - // a simple refimport_t implementation - ri = new refimport_t() { - public void Sys_Error(int err_level, String str) { - Com.Error(err_level, str, null); - } - - public void Sys_Error(int err_level, String str, Vargs vargs) { - Com.Error(err_level, str, vargs); - } - - public void Cmd_AddCommand(String name, xcommand_t cmd) { - Cmd.AddCommand(name, cmd); - } - - public void Cmd_RemoveCommand(String name) { - Cmd.RemoveCommand(name); - } - - public int Cmd_Argc() { - return Cmd.Argc(); - } - - public String Cmd_Argv(int i) { - return Cmd.Argv(i); - } - - public void Cmd_ExecuteText(int exec_when, String text) { - Cbuf.ExecuteText(exec_when, text); - } - - public void Con_Printf(int print_level, String str) { - VID.Printf(print_level, str, null); - } - - public void Con_Printf(int print_level, String str, Vargs vargs) { - VID.Printf(print_level, str, vargs); - } - - public byte[] FS_LoadFile(String name) { - return FS.LoadFile(name); - } - - public int FS_FileLength(String name) { - return FS.FileLength(name); - } - - public void FS_FreeFile(byte[] buf) { - FS.FreeFile(buf); - } - - public String FS_Gamedir() { - return FS.Gamedir(); - } - - public cvar_t Cvar_Get(String name, String value, int flags) { - return Cvar.Get(name, value, flags); - } - - public cvar_t Cvar_Set(String name, String value) { - return Cvar.Set(name, value); - } - - public void Cvar_SetValue(String name, float value) { - Cvar.SetValue(name, value); - } - - public boolean Vid_GetModeInfo(Dimension dim, int mode) { - return VID.GetModeInfo(dim, mode); - } - - public void Vid_MenuInit() { - VID.MenuInit(); - } - - public void Vid_NewWindow(int width, int height) { - VID.NewWindow(width, height); - } - - public void updateScreenCallback() { - DancingQueens.this.updateScreen(); - } - }; - - Qcommon.Init(new String[] {"DancingQueens"}); // sehr wichtig !!! VID.Shutdown(); @@ -159,7 +73,7 @@ public class DancingQueens String[] names = Renderer.getDriverNames(); System.out.println("Registered Drivers: " + Arrays.asList(names)); - this.re = Renderer.getDriver("fastjogl", ri); + this.re = Renderer.getDriver("fastjogl"); System.out.println("Use driver: " + re); System.out.println(); diff --git a/test/jake2/render/DebugCulling.java b/test/jake2/render/DebugCulling.java index 8782ce9..1cf6793 100644 --- a/test/jake2/render/DebugCulling.java +++ b/test/jake2/render/DebugCulling.java @@ -2,7 +2,7 @@ * DebugCulling.java * Copyright (C) 2003 * - * $Id: DebugCulling.java,v 1.2 2004-07-15 14:38:40 hzi Exp $ + * $Id: DebugCulling.java,v 1.3 2004-07-16 10:11:36 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -50,7 +50,6 @@ public class DebugCulling String[] args; refexport_t re; - refimport_t ri; viddef_t viddef; int framecount = 0; @@ -70,116 +69,11 @@ public class DebugCulling void init() { - // only for testing - // a simple refimport_t implementation - ri = new refimport_t() - { - public void Sys_Error(int err_level, String str) - { - Com.Error(err_level, str, null); - } - - public void Sys_Error(int err_level, String str, Vargs vargs) - { - Com.Error(err_level, str, vargs); - } - - public void Cmd_AddCommand(String name, xcommand_t cmd) - { - Cmd.AddCommand(name, cmd); - } - - public void Cmd_RemoveCommand(String name) - { - Cmd.RemoveCommand(name); - } - - public int Cmd_Argc() - { - return Cmd.Argc(); - } - - public String Cmd_Argv(int i) - { - return Cmd.Argv(i); - } - - public void Cmd_ExecuteText(int exec_when, String text) - { - Cbuf.ExecuteText(exec_when, text); - } - - public void Con_Printf(int print_level, String str) - { - VID.Printf(print_level, str, null); - } - - public void Con_Printf(int print_level, String str, Vargs vargs) - { - VID.Printf(print_level, str, vargs); - } - - public byte[] FS_LoadFile(String name) - { - return FS.LoadFile(name); - } - - public int FS_FileLength(String name) - { - return FS.FileLength(name); - } - - public void FS_FreeFile(byte[] buf) - { - FS.FreeFile(buf); - } - - public String FS_Gamedir() - { - return FS.Gamedir(); - } - - public cvar_t Cvar_Get(String name, String value, int flags) - { - return Cvar.Get(name, value, flags); - } - - public cvar_t Cvar_Set(String name, String value) - { - return Cvar.Set(name, value); - } - - public void Cvar_SetValue(String name, float value) - { - Cvar.SetValue(name, value); - } - - public boolean Vid_GetModeInfo(Dimension dim, int mode) - { - return VID.GetModeInfo(dim, mode); - } - - public void Vid_MenuInit() - { - VID.MenuInit(); - } - - public void Vid_NewWindow(int width, int height) - { - VID.NewWindow(width, height); - } - - public void updateScreenCallback() - { - DebugCulling.this.updateScreen(); - } - }; - - Qcommon.Init(new String[] { "$Id: DebugCulling.java,v 1.2 2004-07-15 14:38:40 hzi Exp $" }); + Qcommon.Init(new String[] { "$Id: DebugCulling.java,v 1.3 2004-07-16 10:11:36 cawe Exp $" }); // sehr wichtig !!! VID.Shutdown(); - this.re = Renderer.getDriver("jogl", ri); + this.re = Renderer.getDriver("jogl"); re.Init(0, 0); @@ -317,7 +211,7 @@ public class DebugCulling double x; if (fov_x < 1 || fov_x > 179) - ri.Sys_Error(Defines.ERR_DROP, "Bad fov: " + fov_x); + Com.Error(Defines.ERR_DROP, "Bad fov: " + fov_x); x = width / Math.tan(fov_x / 360 * Math.PI); diff --git a/test/jake2/render/TestMap.java b/test/jake2/render/TestMap.java index 71207b9..c8cfb76 100644 --- a/test/jake2/render/TestMap.java +++ b/test/jake2/render/TestMap.java @@ -2,7 +2,7 @@ * TestMap.java * Copyright (C) 2003 * - * $Id: TestMap.java,v 1.4 2004-07-15 14:38:40 hzi Exp $ + * $Id: TestMap.java,v 1.5 2004-07-16 10:11:36 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -53,7 +53,6 @@ public class TestMap String[] args; refexport_t re; - refimport_t ri; viddef_t viddef; int framecount = 0; @@ -73,116 +72,11 @@ public class TestMap void init() { - // only for testing - // a simple refimport_t implementation - ri = new refimport_t() - { - public void Sys_Error(int err_level, String str) - { - Com.Error(err_level, str, null); - } - - public void Sys_Error(int err_level, String str, Vargs vargs) - { - Com.Error(err_level, str, vargs); - } - - public void Cmd_AddCommand(String name, xcommand_t cmd) - { - Cmd.AddCommand(name, cmd); - } - - public void Cmd_RemoveCommand(String name) - { - Cmd.RemoveCommand(name); - } - - public int Cmd_Argc() - { - return Cmd.Argc(); - } - - public String Cmd_Argv(int i) - { - return Cmd.Argv(i); - } - - public void Cmd_ExecuteText(int exec_when, String text) - { - Cbuf.ExecuteText(exec_when, text); - } - - public void Con_Printf(int print_level, String str) - { - VID.Printf(print_level, str, null); - } - - public void Con_Printf(int print_level, String str, Vargs vargs) - { - VID.Printf(print_level, str, vargs); - } - - public byte[] FS_LoadFile(String name) - { - return FS.LoadFile(name); - } - - public int FS_FileLength(String name) - { - return FS.FileLength(name); - } - - public void FS_FreeFile(byte[] buf) - { - FS.FreeFile(buf); - } - - public String FS_Gamedir() - { - return FS.Gamedir(); - } - - public cvar_t Cvar_Get(String name, String value, int flags) - { - return Cvar.Get(name, value, flags); - } - - public cvar_t Cvar_Set(String name, String value) - { - return Cvar.Set(name, value); - } - - public void Cvar_SetValue(String name, float value) - { - Cvar.SetValue(name, value); - } - - public boolean Vid_GetModeInfo(Dimension dim, int mode) - { - return VID.GetModeInfo(dim, mode); - } - - public void Vid_MenuInit() - { - VID.MenuInit(); - } - - public void Vid_NewWindow(int width, int height) - { - VID.NewWindow(width, height); - } - - public void updateScreenCallback() - { - TestMap.this.updateScreen(); - } - }; - - Qcommon.Init(new String[] { "TestMap $Id: TestMap.java,v 1.4 2004-07-15 14:38:40 hzi Exp $" }); + Qcommon.Init(new String[] { "TestMap $Id: TestMap.java,v 1.5 2004-07-16 10:11:36 cawe Exp $" }); // sehr wichtig !!! VID.Shutdown(); - this.re = Renderer.getDriver("jogl", ri); + this.re = Renderer.getDriver("jogl"); re.Init(0, 0); diff --git a/test/jake2/render/TestRenderer.java b/test/jake2/render/TestRenderer.java index 62ffc7c..8388b20 100644 --- a/test/jake2/render/TestRenderer.java +++ b/test/jake2/render/TestRenderer.java @@ -2,7 +2,7 @@ * TestRenderer.java * Copyright (C) 2003 * - * $Id: TestRenderer.java,v 1.4 2004-07-15 14:38:40 hzi Exp $ + * $Id: TestRenderer.java,v 1.5 2004-07-16 10:11:36 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -48,7 +48,6 @@ public class TestRenderer { String[] args; refexport_t re; - refimport_t ri; viddef_t viddef; int framecount = 0; static int testnr = 0; @@ -66,91 +65,6 @@ public class TestRenderer { void init() { - // only for testing - // a simple refimport_t implementation - ri = new refimport_t() { - public void Sys_Error(int err_level, String str) { - Com.Error(err_level, str, null); - } - - public void Sys_Error(int err_level, String str, Vargs vargs) { - Com.Error(err_level, str, vargs); - } - - public void Cmd_AddCommand(String name, xcommand_t cmd) { - Cmd.AddCommand(name, cmd); - } - - public void Cmd_RemoveCommand(String name) { - Cmd.RemoveCommand(name); - } - - public int Cmd_Argc() { - return Cmd.Argc(); - } - - public String Cmd_Argv(int i) { - return Cmd.Argv(i); - } - - public void Cmd_ExecuteText(int exec_when, String text) { - Cbuf.ExecuteText(exec_when, text); - } - - public void Con_Printf(int print_level, String str) { - VID.Printf(print_level, str, null); - } - - public void Con_Printf(int print_level, String str, Vargs vargs) { - VID.Printf(print_level, str, vargs); - } - - public byte[] FS_LoadFile(String name) { - return FS.LoadFile(name); - } - - public int FS_FileLength(String name) { - return FS.FileLength(name); - } - - public void FS_FreeFile(byte[] buf) { - FS.FreeFile(buf); - } - - public String FS_Gamedir() { - return FS.Gamedir(); - } - - public cvar_t Cvar_Get(String name, String value, int flags) { - return Cvar.Get(name, value, flags); - } - - public cvar_t Cvar_Set(String name, String value) { - return Cvar.Set(name, value); - } - - public void Cvar_SetValue(String name, float value) { - Cvar.SetValue(name, value); - } - - public boolean Vid_GetModeInfo(Dimension dim, int mode) { - return VID.GetModeInfo(dim, mode); - } - - public void Vid_MenuInit() { - VID.MenuInit(); - } - - public void Vid_NewWindow(int width, int height) { - VID.NewWindow(width, height); - } - - public void updateScreenCallback() { - TestRenderer.this.updateScreen(); - } - }; - - Qcommon.Init(new String[] {"TestRenderer"}); // sehr wichtig !!! VID.Shutdown(); @@ -158,7 +72,7 @@ public class TestRenderer { String[] names = Renderer.getDriverNames(); System.out.println("Registered Drivers: " + Arrays.asList(names)); - this.re = Renderer.getDriver("jogl", ri); + this.re = Renderer.getDriver("jogl"); System.out.println("Use driver: " + re); System.out.println(); -- cgit v1.2.3 From e229dac5a749c49f6a02e696304d66b5f3d6feb9 Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Fri, 16 Jul 2004 12:12:29 +0000 Subject: this will solve the flickering bug on "Loading" (but only with a new JOGL-release) --- src/jake2/render/JoglBase.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/JoglBase.java b/src/jake2/render/JoglBase.java index 113cd28..6a1b91b 100644 --- a/src/jake2/render/JoglBase.java +++ b/src/jake2/render/JoglBase.java @@ -2,7 +2,7 @@ * JoglCommon.java * Copyright (C) 2004 * - * $Id: JoglBase.java,v 1.4 2004-07-16 10:11:34 cawe Exp $ + * $Id: JoglBase.java,v 1.5 2004-07-16 12:12:29 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -199,6 +199,9 @@ public abstract class JoglBase implements GLEventListener { //canvas.setGL(new DebugGL(canvas.getGL())); canvas.setNoAutoRedrawMode(true); +// TODO this and a new JOGL-release solves the flickering bug (Loading) +// change also GLimp_EndFrame() +// canvas.setAutoSwapBufferMode(false); canvas.addGLEventListener(this); window.getContentPane().add(canvas); @@ -293,7 +296,8 @@ public abstract class JoglBase implements GLEventListener { protected void GLimp_EndFrame() { gl.glFlush(); // swap buffer - // but jogl has no method to swap +// TODO this and a new JOGL-release solves the flickering bug (Loading) +// canvas.swapBuffers(); } protected void GLimp_BeginFrame(float camera_separation) { // do nothing -- cgit v1.2.3 From 09ccacb4e4147050811b286c5bedcd68a4c23991 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Mon, 19 Jul 2004 19:22:57 +0000 Subject: profiling --- src/jake2/client/CL_pred.java | 8 ++++++-- src/jake2/client/Console.java | 23 +++++++++++------------ src/jake2/sys/IN.java | 4 ++-- src/jake2/sys/InputListener.java | 8 +++----- src/jake2/sys/Sys.java | 25 ++++++++----------------- 5 files changed, 30 insertions(+), 38 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/CL_pred.java b/src/jake2/client/CL_pred.java index 0b0e2ab..7f6a279 100644 --- a/src/jake2/client/CL_pred.java +++ b/src/jake2/client/CL_pred.java @@ -2,7 +2,7 @@ * CL_pred.java * Copyright (C) 2004 * - * $Id: CL_pred.java,v 1.3 2004-07-08 20:24:28 hzi Exp $ + * $Id: CL_pred.java,v 1.4 2004-07-19 19:20:22 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -243,7 +243,11 @@ public class CL_pred extends CL_parse { } }; - PMove.pm_airaccelerate = atof(cl.configstrings[CS_AIRACCEL]); + try { + PMove.pm_airaccelerate = Float.parseFloat(cl.configstrings[CS_AIRACCEL]); + } catch (Exception e) { + PMove.pm_airaccelerate = 0; + } // bugfix (rst) yeah !!!!!!!! found the solution to the B E W E G U N G S P R O B L E M. pm.s.set(cl.frame.playerstate.pmove); diff --git a/src/jake2/client/Console.java b/src/jake2/client/Console.java index 11a7a64..4010eaf 100644 --- a/src/jake2/client/Console.java +++ b/src/jake2/client/Console.java @@ -2,7 +2,7 @@ * Con.java * Copyright (C) 2003 * - * $Id: Console.java,v 1.2 2004-07-08 15:58:42 hzi Exp $ + * $Id: Console.java,v 1.3 2004-07-19 19:20:22 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -167,10 +167,8 @@ public final class Console extends Globals { * If the line width has changed, reformat the buffer. */ public static void CheckResize() { - int i, j, width, oldwidth, oldtotallines, numlines, numchars; - byte[] tbuf = new byte[Defines.CON_TEXTSIZE]; - - width = (Globals.viddef.width >> 3) - 2; + + int width = (Globals.viddef.width >> 3) - 2; if (width == Globals.con.linewidth) return; @@ -182,25 +180,26 @@ public final class Console extends Globals { Arrays.fill(Globals.con.text, (byte)' '); } else { - oldwidth = Globals.con.linewidth; + int oldwidth = Globals.con.linewidth; Globals.con.linewidth = width; - oldtotallines = Globals.con.totallines; + int oldtotallines = Globals.con.totallines; Globals.con.totallines = Defines.CON_TEXTSIZE / Globals.con.linewidth; - numlines = oldtotallines; + int numlines = oldtotallines; if (Globals.con.totallines < numlines) numlines = Globals.con.totallines; - numchars = oldwidth; + int numchars = oldwidth; if (Globals.con.linewidth < numchars) numchars = Globals.con.linewidth; - + + byte[] tbuf = new byte[Defines.CON_TEXTSIZE]; System.arraycopy(Globals.con.text, 0, tbuf, 0, Defines.CON_TEXTSIZE); Arrays.fill(Globals.con.text, (byte)' '); - for (i=0 ; i Date: Mon, 19 Jul 2004 19:32:12 +0000 Subject: profiling --- src/jake2/util/Math3D.java | 66 ++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 34 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/util/Math3D.java b/src/jake2/util/Math3D.java index a434a05..e949f07 100644 --- a/src/jake2/util/Math3D.java +++ b/src/jake2/util/Math3D.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 09.12.2003 by RST. -// $Id: Math3D.java,v 1.4 2004-07-08 20:56:54 hzi Exp $ +// $Id: Math3D.java,v 1.5 2004-07-19 19:32:12 hzi Exp $ package jake2.util; @@ -315,21 +315,18 @@ public class Math3D extends Lib { } public static void ProjectPointOnPlane(float[] dst, float[] p, float[] normal) { - float d; - float[] n = { 0.0f, 0.0f, 0.0f }; - float inv_denom; - inv_denom = 1.0F / Math3D.DotProduct(normal, normal); + float inv_denom = 1.0F / Math3D.DotProduct(normal, normal); - d = Math3D.DotProduct(normal, p) * inv_denom; + float d = Math3D.DotProduct(normal, p) * inv_denom; - n[0] = normal[0] * inv_denom; - n[1] = normal[1] * inv_denom; - n[2] = normal[2] * inv_denom; + dst[0] = normal[0] * inv_denom; + dst[1] = normal[1] * inv_denom; + dst[2] = normal[2] * inv_denom; - dst[0] = p[0] - d * n[0]; - dst[1] = p[1] - d * n[1]; - dst[2] = p[2] - d * n[2]; + dst[0] = p[0] - d * dst[0]; + dst[1] = p[1] - d * dst[1]; + dst[2] = p[2] - d * dst[2]; } /** assumes "src" is normalized */ @@ -361,7 +358,6 @@ public class Math3D extends Lib { stellt fest, auf welcher Seite sich die Kiste befindet, wenn die Ebene durch Entfernung und Senkrechten-Normale gegeben ist. erste Version mit vec3_t... */ - public static final int BoxOnPlaneSide(float emins[], float emaxs[], cplane_t p) { assert (emins.length == 3 && emaxs.length == 3) : "vec3_t bug"; @@ -427,7 +423,7 @@ public class Math3D extends Lib { assert (sides != 0) : "BoxOnPlaneSide(): sides == 0 bug"; return sides; - } + } // this is the slow, general version private static float corners[][] = new float[2][3]; @@ -456,34 +452,36 @@ public class Math3D extends Lib { } public static void AngleVectors(float[] angles, float[] forward, float[] right, float[] up) { - float angle; - float sr, sp, sy, cr, cp, cy; - cr = 2.0f * piratio; - angle = (float) (angles[Defines.YAW] * (cr)); - sy = (float) Math.sin(angle); - cy = (float) Math.cos(angle); + float cr = 2.0f * piratio; + float angle = (float) (angles[Defines.YAW] * (cr)); + float sy = (float) Math.sin(angle); + float cy = (float) Math.cos(angle); angle = (float) (angles[Defines.PITCH] * (cr)); - sp = (float) Math.sin(angle); - cp = (float) Math.cos(angle); - angle = (float) (angles[Defines.ROLL] * (cr)); - sr = (float) Math.sin(angle); - cr = (float) Math.cos(angle); + float sp = (float) Math.sin(angle); + float cp = (float) Math.cos(angle); if (forward != null) { forward[0] = cp * cy; forward[1] = cp * sy; forward[2] = -sp; } - if (right != null) { - right[0] = (-sr * sp * cy + cr * sy); - right[1] = (-sr * sp * sy + -cr * cy); - right[2] = -sr * cp; - } - if (up != null) { - up[0] = (cr * sp * cy + -sr * -sy); - up[1] = (cr * sp * sy + -sr * cy); - up[2] = cr * cp; + + if (right != null || up != null) { + angle = (float) (angles[Defines.ROLL] * (cr)); + float sr = (float) Math.sin(angle); + cr = (float) Math.cos(angle); + + if (right != null) { + right[0] = (-sr * sp * cy + cr * sy); + right[1] = (-sr * sp * sy + -cr * cy); + right[2] = -sr * cp; + } + if (up != null) { + up[0] = (cr * sp * cy + sr * sy); + up[1] = (cr * sp * sy + -sr * cy); + up[2] = cr * cp; + } } } -- cgit v1.2.3 From a1fc4edc16c4e8960a0f2b0a97ea973b0785372a Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Mon, 19 Jul 2004 19:39:57 +0000 Subject: profiling --- src/jake2/render/fastjogl/Image.java | 19 ++-- src/jake2/render/fastjogl/Light.java | 4 +- src/jake2/render/fastjogl/Main.java | 33 +++---- src/jake2/render/fastjogl/Mesh.java | 183 ++++++++++++++--------------------- src/jake2/render/fastjogl/Model.java | 8 +- src/jake2/render/fastjogl/Surf.java | 8 +- 6 files changed, 111 insertions(+), 144 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java index a6b1a91..22f3d02 100644 --- a/src/jake2/render/fastjogl/Image.java +++ b/src/jake2/render/fastjogl/Image.java @@ -2,7 +2,7 @@ * Image.java * Copyright (C) 2003 * - * $Id: Image.java,v 1.4 2004-07-16 10:11:35 cawe Exp $ + * $Id: Image.java,v 1.5 2004-07-19 19:39:57 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -1465,13 +1465,13 @@ public abstract class Image extends Main { */ image_t GL_FindImage(String name, int type) { image_t image = null; - - // TODO loest das grossschreibungs problem - name = name.toLowerCase(); - // bughack for bad strings (fuck \0) - int index = name.indexOf('\0'); - if (index != -1) - name = name.substring(0, index); + +// // TODO loest das grossschreibungs problem +// name = name.toLowerCase(); +// // bughack for bad strings (fuck \0) +// int index = name.indexOf('\0'); +// if (index != -1) +// name = name.substring(0, index); if (name == null || name.length() < 5) return null; // Com.Error (ERR_DROP, "GL_FindImage: NULL name"); @@ -1491,6 +1491,7 @@ public abstract class Image extends Main { // // load the pic from disk // + image = null; byte[] pic = null; Dimension dim = new Dimension(); @@ -1517,8 +1518,6 @@ public abstract class Image extends Main { image = GL_LoadPic(name, pic, dim.width, dim.height, type, 32); } - else - return null; return image; } diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java index 5e7cce5..0ec6807 100644 --- a/src/jake2/render/fastjogl/Light.java +++ b/src/jake2/render/fastjogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.5 2004-07-16 10:11:35 cawe Exp $ + * $Id: Light.java,v 1.6 2004-07-19 19:39:57 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -570,7 +570,7 @@ public abstract class Light extends Warp { // memset( s_blocklights, 0, sizeof( s_blocklights[0] ) * size * 3 ); - Arrays.fill(s_blocklights, 0, size * 3, 0.0f); + //Arrays.fill(s_blocklights, 0, size * 3, 0.0f); for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ; maps++) diff --git a/src/jake2/render/fastjogl/Main.java b/src/jake2/render/fastjogl/Main.java index bcc4e92..44c31c8 100644 --- a/src/jake2/render/fastjogl/Main.java +++ b/src/jake2/render/fastjogl/Main.java @@ -2,7 +2,7 @@ * Main.java * Copyright (C) 2003 * - * $Id: Main.java,v 1.3 2004-07-16 10:11:35 cawe Exp $ + * $Id: Main.java,v 1.4 2004-07-19 19:39:57 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -502,11 +502,12 @@ public abstract class Main extends Base { scale = (scale < 20) ? 1 : 1 + scale * 0.004f; color = sourceColors.get(i); + gl.glColor4ub( - (byte)((color >> 0) & 0xFF), + (byte)((color) & 0xFF), (byte)((color >> 8) & 0xFF), (byte)((color >> 16) & 0xFF), - (byte)((color >> 24) & 0xFF) + (byte)((color >>> 24)) ); // first vertex gl.glTexCoord2f(0.0625f, 0.0625f); @@ -718,26 +719,28 @@ public abstract class Main extends Base { ============= */ void R_SetupGL() { - float screenaspect; - int x, x2, y2, y, w, h; // // set up viewport // - x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width); - x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width); - y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height); - y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height); - - w = x2 - x; - h = y - y2; + //int x = (int) Math.floor(r_newrefdef.x * vid.width / vid.width); + int x = r_newrefdef.x; + //int x2 = (int) Math.ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width); + int x2 = r_newrefdef.x + r_newrefdef.width; + //int y = (int) Math.floor(vid.height - r_newrefdef.y * vid.height / vid.height); + int y = vid.height - r_newrefdef.y; + //int y2 = (int) Math.ceil(vid.height - (r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height); + int y2 = vid.height - (r_newrefdef.y + r_newrefdef.height); + + int w = x2 - x; + int h = y - y2; gl.glViewport(x, y2, w, h); // // set up projection matrix // - screenaspect = (float) r_newrefdef.width / r_newrefdef.height; + float screenaspect = (float) r_newrefdef.width / r_newrefdef.height; gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096); @@ -1168,10 +1171,6 @@ public abstract class Main extends Base { Cvar.Set("scr_drawall", "0"); } - // #ifdef __linux__ - Cvar.SetValue("gl_finish", 1); - // #endif - // MCD has buffering issues if (gl_config.renderer == GL_RENDERER_MCD) { Cvar.SetValue("gl_finish", 1); diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java index 1569ff9..bff8756 100644 --- a/src/jake2/render/fastjogl/Mesh.java +++ b/src/jake2/render/fastjogl/Mesh.java @@ -2,7 +2,7 @@ * Mesh.java * Copyright (C) 2003 * - * $Id: Mesh.java,v 1.4 2004-07-16 10:11:35 cawe Exp $ + * $Id: Mesh.java,v 1.5 2004-07-19 19:39:57 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -68,10 +68,8 @@ public abstract class Mesh extends Light { float[] shadedots = r_avertexnormal_dots[0]; - void GL_LerpVerts( int nverts, qfiles.dtrivertx_t[] v, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv ) + void GL_LerpVerts(int nverts, qfiles.dtrivertx_t[] ov, qfiles.dtrivertx_t[] verts, float[] move, float[] frontv, float[] backv ) { - int lerpIndex = 0; - int[] ovv; int[] vv; FloatBuffer lerp = vertexArrayBuf; @@ -85,12 +83,11 @@ public abstract class Mesh extends Light { { normal = r_avertexnormals[verts[i].lightnormalindex]; ovv = ov[i].v; - vv = v[i].v; + vv = verts[i].v; - lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); - lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); - lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); - j+=3; + lerp.put(j++, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE); + lerp.put(j++, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE); + lerp.put(j++, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE); } } else @@ -99,12 +96,11 @@ public abstract class Mesh extends Light { for (int i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */) { ovv = ov[i].v; - vv = v[i].v; + vv = verts[i].v; - lerp.put(j, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]); - lerp.put(j + 1, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]); - lerp.put(j + 2, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]); - j+=3; + lerp.put(j++, move[0] + ovv[0]*backv[0] + vv[0]*frontv[0]); + lerp.put(j++, move[1] + ovv[1]*backv[1] + vv[1]*frontv[1]); + lerp.put(j++, move[2] + ovv[2]*backv[2] + vv[2]*frontv[2]); } } } @@ -129,32 +125,20 @@ public abstract class Mesh extends Light { void GL_DrawAliasFrameLerp(qfiles.dmdl_t paliashdr, float backlerp) { - float l; - qfiles.daliasframe_t frame, oldframe; - qfiles.dtrivertx_t[] v, ov, verts; - - int[] order; - int orderIndex = 0; int count; - - float frontlerp; float alpha; - float[] move = {0, 0, 0}; // vec3_t - + float[] move = {0, 0, 0}; // vec3_t float[] frontv = {0, 0, 0}; // vec3_t float[] backv = {0, 0, 0}; // vec3_t - int i; - int index_xyz; - - frame = paliashdr.aliasFrames[currententity.frame]; + qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame]; - verts = v = frame.verts; + qfiles.dtrivertx_t[] verts = frame.verts; - oldframe = paliashdr.aliasFrames[currententity.oldframe]; + qfiles.daliasframe_t oldframe = paliashdr.aliasFrames[currententity.oldframe]; - ov = oldframe.verts; + qfiles.dtrivertx_t[] ov = oldframe.verts; if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) alpha = currententity.alpha; @@ -165,7 +149,7 @@ public abstract class Mesh extends Light { if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0) gl.glDisable( GL.GL_TEXTURE_2D ); - frontlerp = 1.0f - backlerp; + float frontlerp = 1.0f - backlerp; // move should be the delta back to the previous frame * backlerp Math3D.VectorSubtract (currententity.oldorigin, currententity.origin, frontv); @@ -177,7 +161,7 @@ public abstract class Mesh extends Light { Math3D.VectorAdd (move, oldframe.translate, move); - for (i=0 ; i<3 ; i++) + for (int i=0 ; i<3 ; i++) { move[i] = backlerp*move[i] + frontlerp*frame.translate[i]; frontv[i] = frontlerp*frame.scale[i]; @@ -186,7 +170,7 @@ public abstract class Mesh extends Light { // ab hier wird optimiert - GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, move, frontv, backv ); + GL_LerpVerts( paliashdr.num_xyz, ov, verts, move, frontv, backv ); //gl.glEnableClientState( GL.GL_VERTEX_ARRAY ); gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf ); @@ -206,7 +190,8 @@ public abstract class Mesh extends Light { // FloatBuffer color = colorArrayBuf; int j = 0; - for ( i = 0; i < paliashdr.num_xyz; i++ ) + float l; + for (int i = 0; i < paliashdr.num_xyz; i++ ) { l = shadedots[verts[i].lightnormalindex]; color.put(j++, l * shadelight[0]); @@ -241,20 +226,21 @@ public abstract class Mesh extends Light { srcIndexBuf = paliashdr.indexElements[j]; - size = (count < 0) ? -count + pos : count + pos; + int mode = GL.GL_TRIANGLE_STRIP; + if (count < 0) { + mode = GL.GL_TRIANGLE_FAN; + count = -count; + } + size = count + pos; + srcIndex = 2 * pos; for (int k = pos; k < size; k++) { - srcIndex = 2 * k; dstIndex = 2 * srcIndexBuf.get(k-pos); - dstTextureCoords.put(dstIndex, srcTextureCoords.get(srcIndex)); - dstTextureCoords.put(dstIndex + 1, srcTextureCoords.get(srcIndex + 1)); + dstTextureCoords.put(dstIndex++, srcTextureCoords.get(srcIndex++)); + dstTextureCoords.put(dstIndex, srcTextureCoords.get(srcIndex++)); } - if (count < 0) { - count = -count; - gl.glDrawElements(GL.GL_TRIANGLE_FAN, count, GL.GL_UNSIGNED_INT, srcIndexBuf); - } else { - gl.glDrawElements(GL.GL_TRIANGLE_STRIP, count, GL.GL_UNSIGNED_INT, srcIndexBuf); - } + gl.glDrawElements(mode, count, GL.GL_UNSIGNED_INT, srcIndexBuf); + pos += count; } @@ -336,21 +322,18 @@ public abstract class Mesh extends Light { ** R_CullAliasModel */ // TODO sync with jogl renderer. hoz - boolean R_CullAliasModel(entity_t e) - { - float[] mins = {0, 0, 0}; - float[] maxs = {0, 0, 0}; - - qfiles.dmdl_t paliashdr = (qfiles.dmdl_t)currentmodel.extradata; + boolean R_CullAliasModel(entity_t e) { + float[] mins = { 0, 0, 0 }; + float[] maxs = { 0, 0, 0 }; - if ( ( e.frame >= paliashdr.num_frames ) || ( e.frame < 0 ) ) - { - VID.Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name +": no such frame " + e.frame + '\n'); + qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata; + + if ((e.frame >= paliashdr.num_frames) || (e.frame < 0)) { + VID.Printf(Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such frame " + e.frame + '\n'); e.frame = 0; } - if ( ( e.oldframe >= paliashdr.num_frames ) || ( e.oldframe < 0 ) ) - { - VID.Printf (Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n'); + if ((e.oldframe >= paliashdr.num_frames) || (e.oldframe < 0)) { + VID.Printf(Defines.PRINT_ALL, "R_CullAliasModel " + currentmodel.name + ": no such oldframe " + e.oldframe + '\n'); e.oldframe = 0; } @@ -360,106 +343,88 @@ public abstract class Mesh extends Light { /* ** compute axially aligned mins and maxs */ - if ( pframe == poldframe ) - { - for ( int i = 0; i < 3; i++ ) - { + if (pframe == poldframe) { + for (int i = 0; i < 3; i++) { mins[i] = pframe.translate[i]; - maxs[i] = mins[i] + pframe.scale[i]*255; + maxs[i] = mins[i] + pframe.scale[i] * 255; } - } - else - { - //float[] thismins = {0, 0, 0}; - //float[] oldmins = {0, 0, 0}; - float[] thismaxs = {0, 0, 0}; - float[] oldmaxs = {0, 0, 0}; - for ( int i = 0; i < 3; i++ ) - { - //thismins[i] = pframe.translate[i]; - thismaxs[i] = pframe.translate[i] + pframe.scale[i]*255; + } else { + float thismaxs, oldmaxs; + for (int i = 0; i < 3; i++) { + thismaxs = pframe.translate[i] + pframe.scale[i] * 255; - //oldmins[i] = poldframe.translate[i]; - oldmaxs[i] = poldframe.translate[i] + poldframe.scale[i]*255; + oldmaxs = poldframe.translate[i] + poldframe.scale[i] * 255; - if ( pframe.translate[i] < poldframe.translate[i] ) + if (pframe.translate[i] < poldframe.translate[i]) mins[i] = pframe.translate[i]; else mins[i] = poldframe.translate[i]; - if ( thismaxs[i] > oldmaxs[i] ) - maxs[i] = thismaxs[i]; + if (thismaxs > oldmaxs) + maxs[i] = thismaxs; else - maxs[i] = oldmaxs[i]; + maxs[i] = oldmaxs; } } /* ** compute a full bounding box */ - float[] tmp = {0, 0, 0}; - for ( int i = 0; i < 8; i++ ) - { - - if ( (i & 1) != 0 ) + float[] tmp; + for (int i = 0; i < 8; i++) { + tmp = bbox[i]; + if ((i & 1) != 0) tmp[0] = mins[0]; else tmp[0] = maxs[0]; - if ( (i & 2) != 0) + if ((i & 2) != 0) tmp[1] = mins[1]; else tmp[1] = maxs[1]; - if ( (i & 4) != 0) + if ((i & 4) != 0) tmp[2] = mins[2]; else tmp[2] = maxs[2]; - - Math3D.VectorCopy( tmp, bbox[i] ); } /* ** rotate the bounding box */ - //float[] angles = {0, 0, 0}; - Math3D.VectorCopy( e.angles, tmp ); + tmp = mins; + Math3D.VectorCopy(e.angles, tmp); tmp[YAW] = -tmp[YAW]; - Math3D.AngleVectors( tmp, vectors[0], vectors[1], vectors[2] ); + Math3D.AngleVectors(tmp, vectors[0], vectors[1], vectors[2]); - for ( int i = 0; i < 8; i++ ) - { - Math3D.VectorCopy( bbox[i], tmp ); + for (int i = 0; i < 8; i++) { + Math3D.VectorCopy(bbox[i], tmp); - bbox[i][0] = Math3D.DotProduct( vectors[0], tmp ); - bbox[i][1] = -Math3D.DotProduct( vectors[1], tmp ); - bbox[i][2] = Math3D.DotProduct( vectors[2], tmp ); + bbox[i][0] = Math3D.DotProduct(vectors[0], tmp); + bbox[i][1] = -Math3D.DotProduct(vectors[1], tmp); + bbox[i][2] = Math3D.DotProduct(vectors[2], tmp); - Math3D.VectorAdd( e.origin, bbox[i], bbox[i] ); + Math3D.VectorAdd(e.origin, bbox[i], bbox[i]); } int f, mask; int aggregatemask = ~0; // 0xFFFFFFFF - - for ( int p = 0; p < 8; p++ ) - { + + for (int p = 0; p < 8; p++) { mask = 0; - for ( f = 0; f < 4; f++ ) - { - float dp = Math3D.DotProduct( frustum[f].normal, bbox[p] ); + for (f = 0; f < 4; f++) { + float dp = Math3D.DotProduct(frustum[f].normal, bbox[p]); - if ( ( dp - frustum[f].dist ) < 0 ) - { - mask |= ( 1 << f ); + if ((dp - frustum[f].dist) < 0) { + mask |= (1 << f); } } aggregatemask &= mask; } - if ( aggregatemask != 0 ) - { + if (aggregatemask != 0) { return true; } diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java index e928c5e..90cb7c9 100644 --- a/src/jake2/render/fastjogl/Model.java +++ b/src/jake2/render/fastjogl/Model.java @@ -2,7 +2,7 @@ * Model.java * Copyright (C) 2003 * - * $Id: Model.java,v 1.3 2004-07-16 10:11:35 cawe Exp $ + * $Id: Model.java,v 1.4 2004-07-19 19:39:57 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -1084,7 +1084,11 @@ public abstract class Model extends Surf { for (i=0 ; i -1) { + skinNames[i] = skinNames[i].substring(0, n); + } mod.skins[i] = GL_FindImage(skinNames[i], it_skin); } diff --git a/src/jake2/render/fastjogl/Surf.java b/src/jake2/render/fastjogl/Surf.java index a37eb32..32f1a92 100644 --- a/src/jake2/render/fastjogl/Surf.java +++ b/src/jake2/render/fastjogl/Surf.java @@ -2,7 +2,7 @@ * Surf.java * Copyright (C) 2003 * - * $Id: Surf.java,v 1.3 2004-07-16 10:11:35 cawe Exp $ + * $Id: Surf.java,v 1.4 2004-07-19 19:39:57 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -973,10 +973,10 @@ public abstract class Surf extends Draw { */ void R_MarkLeaves() { - byte[] vis; + //byte[] vis; //byte[] fatvis = new byte[Defines.MAX_MAP_LEAFS / 8]; - Arrays.fill(fatvis, (byte)0); + //Arrays.fill(fatvis, (byte)0); mnode_t node; int i, c; @@ -1005,7 +1005,7 @@ public abstract class Surf extends Draw { return; } - vis = Mod_ClusterPVS(r_viewcluster, r_worldmodel); + byte[] vis = Mod_ClusterPVS(r_viewcluster, r_worldmodel); // may have to combine two clusters because of solid water boundaries if (r_viewcluster2 != r_viewcluster) { -- cgit v1.2.3 From 2fec1b289e4887b7e6e1a68be3e69f84d94f9905 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Tue, 20 Jul 2004 11:02:24 +0000 Subject: replace atof() --- src/jake2/qcommon/Cvar.java | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/qcommon/Cvar.java b/src/jake2/qcommon/Cvar.java index b84a40c..8f1c182 100644 --- a/src/jake2/qcommon/Cvar.java +++ b/src/jake2/qcommon/Cvar.java @@ -2,7 +2,7 @@ * Cvar.java * Copyright (C) 2003 * - * $Id: Cvar.java,v 1.1 2004-07-07 19:59:30 hzi Exp $ + * $Id: Cvar.java,v 1.2 2004-07-20 11:02:24 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -132,7 +132,12 @@ public class Cvar extends Globals { Globals.userinfo_modified = true; // transmit at next oportunity var.string = value; - var.value = Lib.atof(var.string); + try { + var.value = Float.parseFloat(var.string); + } catch (Exception e) { + var.value = 0.0f; + } + var.flags = flags; return var; @@ -186,13 +191,15 @@ public class Cvar extends Globals { if (Com.ServerState() != 0) { Com.Printf(var_name + " will be changed for next game.\n"); - //var.latched_string = CopyString(value); var.latched_string = value; } else { - //var.string = CopyString(value); var.string = value; - var.value = Lib.atof(var.string); + try { + var.value = Float.parseFloat(var.string); + } catch (Exception e) { + var.value = 0.0f; + } if (var.name.equals("game")) { FS.SetGamedir(var.string); FS.ExecAutoexec(); @@ -216,11 +223,12 @@ public class Cvar extends Globals { if ((var.flags & CVAR_USERINFO) != 0) Globals.userinfo_modified = true; // transmit at next oportunity - //Z_Free(var.string); // free the old value string - - //var.string = CopyString(value); var.string = value; - var.value = Lib.atof(var.string); + try { + var.value = Float.parseFloat(var.string); + } catch (Exception e) { + var.value = 0.0f; + } return var; } @@ -311,7 +319,11 @@ public class Cvar extends Globals { cvar_t var = Cvar.FindVar(var_name); if (var == null) return 0; - return Lib.atof(var.string); + float val = 0.0f; + try { + val = Float.parseFloat(var.string); + } catch (Exception e) {} + return val; } /* -- cgit v1.2.3 From 4d14584117e56e51ea4fd69de1807a0e3329e7dc Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Tue, 20 Jul 2004 16:14:37 +0000 Subject: hack removed --- src/jake2/game/PlayerHud.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/game/PlayerHud.java b/src/jake2/game/PlayerHud.java index 244e398..6226cca 100644 --- a/src/jake2/game/PlayerHud.java +++ b/src/jake2/game/PlayerHud.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 28.12.2003 by RST. -// $Id: PlayerHud.java,v 1.3 2004-07-09 06:50:49 hzi Exp $ +// $Id: PlayerHud.java,v 1.4 2004-07-20 16:14:37 cawe Exp $ package jake2.game; @@ -98,17 +98,8 @@ public class PlayerHud extends GameTarget { } level.intermissiontime = level.time; - - // TODO: BIG HACK TO IGNORE CINEMATIC - - String xxx = targ.map; - int pos = xxx.indexOf(".cin"); - if (pos != -1) - level.changemap = xxx.substring(pos + 5); // including "+" - else - level.changemap = xxx; - // ------------------------ - //level.changemap = targ.map; + level.changemap = targ.map; + if (level.changemap.indexOf('*') > -1) { if (coop.value != 0) { for (i = 0; i < maxclients.value; i++) { -- cgit v1.2.3 From a161d9817f1a86aedffb8789e2134c6a29e5fa35 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 23 Jul 2004 10:09:55 +0000 Subject: replace Lib functions --- src/jake2/client/Key.java | 8 +++++--- src/jake2/client/Menu.java | 6 +++--- src/jake2/game/Cmd.java | 12 ++++++------ src/jake2/game/GameSpawn.java | 11 +++++------ src/jake2/game/M_Flyer.java | 8 ++++---- src/jake2/server/SV_CCMDS.java | 4 ++-- src/jake2/server/SV_MAIN.java | 6 +++--- src/jake2/util/Lib.java | 33 +-------------------------------- 8 files changed, 29 insertions(+), 59 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/Key.java b/src/jake2/client/Key.java index 5f7d921..6d011cb 100644 --- a/src/jake2/client/Key.java +++ b/src/jake2/client/Key.java @@ -2,7 +2,7 @@ * Key.java * Copyright (C) 2003 * - * $Id: Key.java,v 1.4 2004-07-09 06:50:50 hzi Exp $ + * $Id: Key.java,v 1.5 2004-07-23 10:02:49 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -615,7 +615,8 @@ public class Key extends Globals { while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0); if (history_line == Globals.edit_line) history_line = (Globals.edit_line + 1) & 31; - Lib.strcpy(Globals.key_lines[Globals.edit_line], Globals.key_lines[history_line]); + //Lib.strcpy(Globals.key_lines[Globals.edit_line], Globals.key_lines[history_line]); + System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length); Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]); return; } @@ -632,7 +633,8 @@ public class Key extends Globals { Globals.key_linepos = 1; } else { - Lib.strcpy(Globals.key_lines[Globals.edit_line], Globals.key_lines[history_line]); + //Lib.strcpy(Globals.key_lines[Globals.edit_line], Globals.key_lines[history_line]); + System.arraycopy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].length); Globals.key_linepos = Lib.strlen(Globals.key_lines[Globals.edit_line]); } return; diff --git a/src/jake2/client/Menu.java b/src/jake2/client/Menu.java index faaf77c..c6c7606 100644 --- a/src/jake2/client/Menu.java +++ b/src/jake2/client/Menu.java @@ -2,7 +2,7 @@ * Menu.java * Copyright (C) 2004 * - * $Id: Menu.java,v 1.4 2004-07-09 06:50:50 hzi Exp $ + * $Id: Menu.java,v 1.5 2004-07-23 10:02:49 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -2531,7 +2531,7 @@ public final class Menu extends Key { // ignore if duplicated for (i = 0; i < m_num_servers; i++) - if (0 == strcmp(x, local_server_names[i])) + if (x.equals(local_server_names[i])) return; local_server_netadr[m_num_servers] = adr; @@ -3924,7 +3924,7 @@ public final class Menu extends Key { // copy the valid skins for (s = 0, k = 0; k < npcxfiles - 1; k++) { - if (!strstr(pcxnames[k], "_i.pcx")) { + if (pcxnames[k].indexOf("_i.pcx") < 0) { if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles - 1)) { a = pcxnames[k].lastIndexOf('/'); b = pcxnames[k].lastIndexOf('\\'); diff --git a/src/jake2/game/Cmd.java b/src/jake2/game/Cmd.java index a5a0a50..22d35a5 100644 --- a/src/jake2/game/Cmd.java +++ b/src/jake2/game/Cmd.java @@ -2,7 +2,7 @@ * Cmd.java * Copyright (C) 2003 * - * $Id: Cmd.java,v 1.3 2004-07-09 06:50:49 hzi Exp $ + * $Id: Cmd.java,v 1.4 2004-07-23 10:07:14 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -395,7 +395,7 @@ public final class Cmd extends PlayerView for (cmd= cmd_functions; cmd != null; cmd= cmd.next) { - if (0 == strcmp(cmd_name, cmd.name)) + if (cmd.name.equals(cmd_name)) return true; } @@ -1197,9 +1197,9 @@ public final class Cmd extends PlayerView if (arg0) { - strcat(text, gi.argv(0)); - strcat(text, " "); - strcat(text, gi.args()); + text += gi.argv(0); + text += " "; + text += gi.args(); } else { @@ -1224,7 +1224,7 @@ public final class Cmd extends PlayerView //text[150] = 0; text= text.substring(0, 150); - strcat(text, "\n"); + text += "\n"; if (flood_msgs.value != 0) { diff --git a/src/jake2/game/GameSpawn.java b/src/jake2/game/GameSpawn.java index 34412fd..7dc4934 100644 --- a/src/jake2/game/GameSpawn.java +++ b/src/jake2/game/GameSpawn.java @@ -19,13 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.11.2003 by RST. -// $Id: GameSpawn.java,v 1.3 2004-07-09 06:50:49 hzi Exp $ +// $Id: GameSpawn.java,v 1.4 2004-07-23 10:07:14 hzi Exp $ package jake2.game; -import jake2.Defines; -import jake2.util.*; -import jake2.qcommon.*; +import jake2.qcommon.Com; +import jake2.util.Lib; public class GameSpawn extends GameSave { @@ -595,14 +594,14 @@ public class GameSpawn extends GameSave { if (item.classname == null) continue; - if (0 == Lib.stricmp(item.classname, ent.classname)) { // found it + if (item.classname.equalsIgnoreCase(ent.classname)) { // found it SpawnItem(ent, item); return; } } // check normal spawn functions for (i=0; (s = spawns[i]) !=null && s.name != null; i++) { - if (0 == Lib.stricmp(s.name, ent.classname)) { // found it + if (s.name.equalsIgnoreCase(ent.classname)) { // found it if (s.spawn == null) gi.error("ED_CallSpawn: null-spawn on index=" + i); diff --git a/src/jake2/game/M_Flyer.java b/src/jake2/game/M_Flyer.java index 7cfc66b..09b629a 100644 --- a/src/jake2/game/M_Flyer.java +++ b/src/jake2/game/M_Flyer.java @@ -19,12 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 13.11.2003 by RST. -// $Id: M_Flyer.java,v 1.2 2004-07-08 15:58:44 hzi Exp $ +// $Id: M_Flyer.java,v 1.3 2004-07-23 10:07:14 hzi Exp $ package jake2.game; -import jake2.util.*; -import jake2.util.*; +import jake2.util.Lib; +import jake2.util.Math3D; public class M_Flyer extends M_Player { // This file generated by ModelGen - Do NOT Modify @@ -760,7 +760,7 @@ public class M_Flyer extends M_Player { } // fix a map bug in jail5.bsp - if (0 == Lib.stricmp(level.mapname, "jail5") && (self.s.origin[2] == -104)) { + if (level.mapname.equalsIgnoreCase("jail5") && (self.s.origin[2] == -104)) { self.targetname= self.target; self.target= null; } diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java index f890cab..105e156 100644 --- a/src/jake2/server/SV_CCMDS.java +++ b/src/jake2/server/SV_CCMDS.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.01.2004 by RST. -// $Id: SV_CCMDS.java,v 1.4 2004-07-14 15:34:24 cawe Exp $ +// $Id: SV_CCMDS.java,v 1.5 2004-07-23 10:09:01 hzi Exp $ package jake2.server; @@ -652,7 +652,7 @@ public class SV_CCMDS extends SV_ENTS { // if not a pcx, demo, or cinematic, check to make sure the level exists map = Cmd.Argv(1); - if (!strstr(map, ".")) { + if (map.indexOf(".") < 0) { expanded = "maps/" + map + ".bsp"; if (FS.LoadFile(expanded) == null) { Com.Printf("Can't find " + expanded + "\n"); diff --git a/src/jake2/server/SV_MAIN.java b/src/jake2/server/SV_MAIN.java index 510decc..b3d5e9d 100644 --- a/src/jake2/server/SV_MAIN.java +++ b/src/jake2/server/SV_MAIN.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 13.01.2004 by RST. -// $Id: SV_MAIN.java,v 1.3 2004-07-09 06:50:49 hzi Exp $ +// $Id: SV_MAIN.java,v 1.4 2004-07-23 10:09:01 hzi Exp $ package jake2.server; @@ -444,8 +444,8 @@ public class SV_MAIN extends SV_GAME { remaining = ""; for (i = 2; i < Cmd.Argc(); i++) { - strcat(remaining, Cmd.Argv(i)); - strcat(remaining, " "); + remaining += Cmd.Argv(i); + remaining += " "; } Cmd.ExecuteString(remaining); diff --git a/src/jake2/util/Lib.java b/src/jake2/util/Lib.java index 4f5559c..e0d1791 100644 --- a/src/jake2/util/Lib.java +++ b/src/jake2/util/Lib.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 09.12.2003 by RST. -// $Id: Lib.java,v 1.4 2004-07-12 20:47:01 hzi Exp $ +// $Id: Lib.java,v 1.5 2004-07-23 10:09:55 hzi Exp $ package jake2.util; @@ -75,10 +75,6 @@ public class Lib { return in1.compareTo(in2); } - public static int stricmp(String in1, String in2) { - return in1.compareToIgnoreCase(in2); - } - public static boolean strstr(String i1, String i2) { return (i1.indexOf(i2) != -1); } @@ -123,10 +119,6 @@ public class Lib { return res; } -// public static int strlen(String in) { -// return in.length(); -// } - public static int strlen(char in[]) { for (int i = 0; i < in.length; i++) if (in[i] == 0) @@ -141,21 +133,6 @@ public class Lib { return in.length; } - public static void strcat(String in, String i) { - in += i; - } - - public static void strcpy(byte dest[], byte src[]) { - for (int i = 0; i < dest.length && i < src.length; i++) - if (src[i] == 0) { - dest[i] = 0; - return; - } - else - dest[i] = src[i]; - - } - static byte[] buffer = new byte[Defines.MAX_INFO_STRING]; public static String readString(ByteBuffer bb, int len) { bb.get(buffer, 0, len); @@ -242,14 +219,6 @@ public class Lib { f.write(s.getBytes(), 0, len); } - public static String cut(String in, char c) { - int pos = in.indexOf(c); - - if (pos != -1) - return in.substring(0, pos); - return in; - } - public static RandomAccessFile fopen(String name, String mode) { try { return new RandomAccessFile(name, mode); -- cgit v1.2.3 From fb25025a51a56f3d5bfaeb10d59634d870f8449c Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 23 Jul 2004 22:38:52 +0000 Subject: fix download bug --- src/jake2/client/CL_parse.java | 6 +++--- src/jake2/qcommon/Com.java | 16 ++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/CL_parse.java b/src/jake2/client/CL_parse.java index f50857d..130e89f 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.6 2004-07-12 20:47:01 hzi Exp $ + * $Id: CL_parse.java,v 1.7 2004-07-23 22:38:51 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -103,7 +103,7 @@ public class CL_parse extends CL_view { // download to a temp name, and only rename // to the real name when done, so if interrupted // a runt file wont be left - Com.StripExtension(cls.downloadname, cls.downloadtempname); + cls.downloadtempname = Com.StripExtension(cls.downloadname); cls.downloadtempname += ".tmp"; // ZOID @@ -175,7 +175,7 @@ public class CL_parse extends CL_view { // download to a temp name, and only rename // to the real name when done, so if interrupted // a runt file wont be left - Com.StripExtension(cls.downloadname, cls.downloadtempname); + cls.downloadtempname = Com.StripExtension(cls.downloadname); cls.downloadtempname += ".tmp"; MSG.WriteByte(cls.netchan.message, clc_stringcmd); diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java index 705a009..16c592f 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.3 2004-07-09 06:50:50 hzi Exp $ + * $Id: Com.java,v 1.4 2004-07-23 22:38:52 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -350,11 +350,6 @@ public final class Com DPrintf(fmt, null); } - public static void d(String fmt) - { - DPrintf(fmt + "\n", null); - } - public static void Printf(String fmt) { Printf(fmt, null); @@ -515,15 +510,16 @@ public final class Com return MD4.Com_BlockChecksum(buf, length); } - public static void StripExtension(String string, String string2) - { - // TODO implement StripExtension + public static String StripExtension(String string) { + int i = string.lastIndexOf('.'); + if (i < 0) + return string; + return string.substring(0, i); } /** * CRC table. */ - static int chktbl[]= { 0x84, -- cgit v1.2.3 From 8b2d42cf2dedadfded95aa22677a0baf9d92cc1a Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Mon, 26 Jul 2004 18:45:48 +0000 Subject: bugfix --- src/jake2/server/SV.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/server/SV.java b/src/jake2/server/SV.java index def4112..b1bed64 100644 --- a/src/jake2/server/SV.java +++ b/src/jake2/server/SV.java @@ -2,7 +2,7 @@ * SV.java * Copyright (C) 2003 * - * $Id: SV.java,v 1.2 2004-07-08 15:58:45 hzi Exp $ + * $Id: SV.java,v 1.3 2004-07-26 18:45:48 cawe Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -1018,7 +1018,7 @@ public final class SV { //FIXME: how did we get here with no enemy if (enemy == null) { - Com.d("SV_NewChaseDir without enemy!"); + Com.DPrintf("SV_NewChaseDir without enemy!"); return; } olddir = Math3D.anglemod((int) (actor.ideal_yaw / 45) * 45); -- cgit v1.2.3 From 4f0bdcb0d084872e21a783066d569e5b6cac070a Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Mon, 26 Jul 2004 19:17:06 +0000 Subject: replace Com.d() --- src/jake2/server/SV.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/server/SV.java b/src/jake2/server/SV.java index b1bed64..be38f1c 100644 --- a/src/jake2/server/SV.java +++ b/src/jake2/server/SV.java @@ -2,7 +2,7 @@ * SV.java * Copyright (C) 2003 * - * $Id: SV.java,v 1.3 2004-07-26 18:45:48 cawe Exp $ + * $Id: SV.java,v 1.4 2004-07-26 19:17:06 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -1018,7 +1018,7 @@ public final class SV { //FIXME: how did we get here with no enemy if (enemy == null) { - Com.DPrintf("SV_NewChaseDir without enemy!"); + Com.DPrintf("SV_NewChaseDir without enemy!\n"); return; } olddir = Math3D.anglemod((int) (actor.ideal_yaw / 45) * 45); -- cgit v1.2.3 From ed868109431bbb4f4964142816a32ad991bc9bde Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Tue, 27 Jul 2004 11:58:29 +0000 Subject: clear s_blocklights again. --- src/jake2/render/fastjogl/Light.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java index 0ec6807..0608e2b 100644 --- a/src/jake2/render/fastjogl/Light.java +++ b/src/jake2/render/fastjogl/Light.java @@ -2,7 +2,7 @@ * Light.java * Copyright (C) 2003 * - * $Id: Light.java,v 1.6 2004-07-19 19:39:57 hzi Exp $ + * $Id: Light.java,v 1.7 2004-07-27 11:58:29 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -570,7 +570,7 @@ public abstract class Light extends Warp { // memset( s_blocklights, 0, sizeof( s_blocklights[0] ) * size * 3 ); - //Arrays.fill(s_blocklights, 0, size * 3, 0.0f); + Arrays.fill(s_blocklights, 0, size * 3, 0.0f); for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255 ; maps++) -- cgit v1.2.3 From e2a16dc654fd51f44d4e173bcbf8a79226fc393b Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Wed, 28 Jul 2004 11:54:43 +0000 Subject: fix parser bug --- src/jake2/qcommon/Com.java | 119 ++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 72 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java index 16c592f..3eb56d3 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.4 2004-07-23 22:38:52 hzi Exp $ + * $Id: Com.java,v 1.5 2004-07-28 11:54:43 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -86,12 +86,6 @@ public final class Com // helper class to replace the pointer-pointer public static class ParseHelp { - - public ParseHelp(String in, int offset) - { - this(in.toCharArray(), offset); - } - public ParseHelp(String in) { if (in == null) @@ -112,10 +106,7 @@ public final class Com public ParseHelp(char in[], int offset) { - if (in == null || in.length == 0) - data= null; - else - data= in; + data= in; index= offset; } @@ -151,6 +142,15 @@ public final class Com return 0; } } + + public char prevchar() { + if (index > 0) + { + index--; + return data[index]; + } + return 0; + } public boolean isEof() { @@ -188,89 +188,64 @@ public final class Com public static char com_token[]= new char[Defines.MAX_TOKEN_CHARS]; // See GameSpanw.ED_ParseEdict() to see how to use it now. - // works perfect ! - public static String Parse(ParseHelp hlp) - { - + public static String Parse(ParseHelp hlp) { int c; - int len= 0; - len= 0; - - com_token[0]= 0; + int len = 0; - if (hlp.data == null) - { + if (hlp.data == null) { return ""; } - // skip whitespace - hlp.skipwhites(); - - if (hlp.isEof()) - { - return ""; - } + while (true) { + // skip whitespace + hlp.skipwhites(); + if (hlp.isEof()) + return ""; - // skip // comments - if (hlp.getchar() == '/') - { - if (hlp.nextchar() == '/') - { - if ((hlp.skiptoeol() == 0) || (hlp.skipwhites() == 0)) - { + // skip // comments + if (hlp.getchar() == '/') { + if (hlp.nextchar() == '/') { + hlp.skipwhitestoeol(); return ""; + } else { + hlp.prevchar(); + break; } - } - else - { - com_token[len]= '/'; - len++; - } + } else + break; } - // handle quoted strings specially - if (hlp.getchar() == '\"') - { - while (true) - { - c= hlp.nextchar(); - if (c == '\"' || c == 0) - { - hlp.nextchar(); - com_token[len]= '?'; + // handle quoted strings specially + if (hlp.getchar() == '\"') { + hlp.nextchar(); + while (true) { + c = hlp.getchar(); + hlp.nextchar(); + if (c == '\"' || c == 0) { return new String(com_token, 0, len); } - if (len < Defines.MAX_TOKEN_CHARS) - { - com_token[len]= hlp.getchar(); + if (len < Defines.MAX_TOKEN_CHARS) { + com_token[len] = (char) c; len++; } } } - // parse a regular word - do - { - if (len < Defines.MAX_TOKEN_CHARS) - { - com_token[len]= hlp.getchar(); + // parse a regular word + c = hlp.getchar(); + do { + if (len < Defines.MAX_TOKEN_CHARS) { + com_token[len] = (char) c; len++; } + c = hlp.nextchar(); + } while (c > 32); - c= hlp.nextchar(); + if (len == Defines.MAX_TOKEN_CHARS) { + Com.Printf("Token exceeded " + Defines.MAX_TOKEN_CHARS + " chars, discarded.\n"); + len = 0; } - while (c > 32); - - if (len == Defines.MAX_TOKEN_CHARS) - { - Printf("Token exceeded " + Defines.MAX_TOKEN_CHARS + " chars, discarded.\n"); - len= 0; - } - - // trigger the eof - hlp.skipwhites(); - com_token[len]= 0; return new String(com_token, 0, len); } -- cgit v1.2.3 From b5de667077d7a0b2a469ede1d592d3980ca57b8f Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Wed, 28 Jul 2004 11:58:10 +0000 Subject: unify string read buffers --- src/jake2/qcommon/MSG.java | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/qcommon/MSG.java b/src/jake2/qcommon/MSG.java index 36b1467..4396ac3 100644 --- a/src/jake2/qcommon/MSG.java +++ b/src/jake2/qcommon/MSG.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 29.11.2003 by RST. -// $Id: MSG.java,v 1.3 2004-07-08 20:24:48 hzi Exp $ +// $Id: MSG.java,v 1.4 2004-07-28 11:58:10 hzi Exp $ package jake2.qcommon; @@ -477,12 +477,9 @@ public class MSG extends GameBase { l++; } while (l < 2047); - //readbuf[l] = 0; return new String(readbuf, 0, l); } - // 2k read buffer. - public static byte readbuf1[] = new byte[2048]; public static String ReadStringLine(sizebuf_t msg_read) { int l; @@ -493,14 +490,11 @@ public class MSG extends GameBase { c = (byte) ReadChar(msg_read); if (c == -1 || c == 0 || c == 0x0a) break; - readbuf1[l] = c; + readbuf[l] = c; l++; - } - while (l < 2047); - - readbuf1[l] = 0; + } while (l < 2047); - return new String(readbuf1, 0, l).trim(); + return new String(readbuf, 0, l).trim(); } public static float ReadCoord(sizebuf_t msg_read) { @@ -562,11 +556,7 @@ public class MSG extends GameBase { } public static void ReadData(sizebuf_t msg_read, byte data[], int len) { - int i; - - for (i = 0; i < len; i++) + for (int i = 0; i < len; i++) data[i] = (byte) ReadByte(msg_read); } - - //============================================================================ } -- cgit v1.2.3 From 9567b7d3f26a222a3d3210a398a3ea91235a914a Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Wed, 28 Jul 2004 12:01:27 +0000 Subject: replace Lib functions --- src/jake2/qcommon/CM.java | 4 ++-- src/jake2/sys/Sys.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/qcommon/CM.java b/src/jake2/qcommon/CM.java index a75cf05..5978f88 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.4 2004-07-12 20:47:00 hzi Exp $ +// $Id: CM.java,v 1.5 2004-07-28 12:01:27 hzi Exp $ package jake2.qcommon; @@ -198,7 +198,7 @@ public class CM extends Game { map_noareas = Cvar.Get("map_noareas", "0", 0); - if (0 == strcmp(map_name, name) && (clientload || 0 == Cvar.VariableValue("flushmap"))) { + if (map_name.equals(name) && (clientload || 0 == Cvar.VariableValue("flushmap"))) { checksum[0] = last_checksum; diff --git a/src/jake2/sys/Sys.java b/src/jake2/sys/Sys.java index ddab111..cd09fd6 100644 --- a/src/jake2/sys/Sys.java +++ b/src/jake2/sys/Sys.java @@ -2,7 +2,7 @@ * Sys.java * Copyright (C) 2003 * - * $Id: Sys.java,v 1.5 2004-07-19 19:22:57 hzi Exp $ + * $Id: Sys.java,v 1.6 2004-07-28 11:59:32 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -176,7 +176,7 @@ public final class Sys extends Defines { // . and .. never match String name = dir.getName(); - if (Lib.strcmp(name, ".") == 0 || Lib.strcmp(name, "..") == 0) + if (name.equals(".") || name.equals("..")) return false; return true; -- cgit v1.2.3 From 0681b364734d9f4d6b08e89e41850e0d36891c02 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 30 Jul 2004 06:03:40 +0000 Subject: replace serverState functions --- src/jake2/client/CL.java | 8 ++++---- src/jake2/client/CL_parse.java | 5 +++-- src/jake2/client/Console.java | 4 ++-- src/jake2/client/Menu.java | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java index 125cedd..b1231f8 100644 --- a/src/jake2/client/CL.java +++ b/src/jake2/client/CL.java @@ -2,7 +2,7 @@ * CL.java * Copyright (C) 2004 * - * $Id: CL.java,v 1.5 2004-07-09 06:50:50 hzi Exp $ + * $Id: CL.java,v 1.6 2004-07-30 06:03:40 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -249,7 +249,7 @@ public final class CL extends CL_pred { public void execute() { // never pause in multiplayer - if (Cvar.VariableValue("maxclients") > 1 || Com.ServerState() == 0) { + if (Cvar.VariableValue("maxclients") > 1 || Globals.server_state == 0) { Cvar.SetValue("paused", 0); return; } @@ -312,7 +312,7 @@ public final class CL extends CL_pred { // if the local server is running and we aren't // then connect - if (cls.state == ca_disconnected && Com.ServerState() != 0) { + if (cls.state == ca_disconnected && Globals.server_state != 0) { cls.state = ca_connecting; cls.servername = "localhost"; // we don't need a challenge on the localhost @@ -358,7 +358,7 @@ public final class CL extends CL_pred { return; } - if (Com.ServerState() != 0) { + if (Globals.server_state != 0) { // if running a local server, kill it and reissue SV_MAIN.SV_Shutdown("Server quit\n", false); } else { diff --git a/src/jake2/client/CL_parse.java b/src/jake2/client/CL_parse.java index 130e89f..432df25 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.7 2004-07-23 22:38:51 hzi Exp $ + * $Id: CL_parse.java,v 1.8 2004-07-30 06:03:40 hzi 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.client; import jake2.Defines; +import jake2.Globals; import jake2.game.Cmd; import jake2.game.entity_state_t; import jake2.qcommon.*; @@ -315,7 +316,7 @@ public class CL_parse extends CL_view { cls.serverProtocol = i; // BIG HACK to let demos from release work with the 3.0x patch!!! - if (Com.ServerState() != 0 && PROTOCOL_VERSION == 34) { + if (Globals.server_state != 0 && PROTOCOL_VERSION == 34) { } else if (i != PROTOCOL_VERSION) Com.Error(ERR_DROP, "Server returned version " + i + ", not " + PROTOCOL_VERSION); diff --git a/src/jake2/client/Console.java b/src/jake2/client/Console.java index 4010eaf..b37a1f8 100644 --- a/src/jake2/client/Console.java +++ b/src/jake2/client/Console.java @@ -2,7 +2,7 @@ * Con.java * Copyright (C) 2003 * - * $Id: Console.java,v 1.3 2004-07-19 19:20:22 hzi Exp $ + * $Id: Console.java,v 1.4 2004-07-30 06:03:40 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -66,7 +66,7 @@ public final class Console extends Globals { Menu.ForceMenuOff(); Globals.cls.key_dest = Defines.key_console; - if (Cvar.VariableValue("maxclients") == 1 && Com.ServerState()!= 0) + if (Cvar.VariableValue("maxclients") == 1 && Globals.server_state!= 0) Cvar.Set("paused", "1"); } } diff --git a/src/jake2/client/Menu.java b/src/jake2/client/Menu.java index c6c7606..6e451b9 100644 --- a/src/jake2/client/Menu.java +++ b/src/jake2/client/Menu.java @@ -2,7 +2,7 @@ * Menu.java * Copyright (C) 2004 * - * $Id: Menu.java,v 1.5 2004-07-23 10:02:49 hzi Exp $ + * $Id: Menu.java,v 1.6 2004-07-30 06:03:40 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -158,7 +158,7 @@ public final class Menu extends Key { static void PushMenu(xcommand_t draw, keyfunc_t key) { //, String(*key) (int k) ) { int i; - if (Cvar.VariableValue("maxclients") == 1 && Com.ServerState() != 0) + if (Cvar.VariableValue("maxclients") == 1 && Globals.server_state != 0) Cvar.Set("paused", "1"); // if this menu is already present, drop back to that level @@ -2475,7 +2475,7 @@ public final class Menu extends Key { } }; static void Menu_SaveGame_f() { - if (0 == Com.ServerState()) + if (0 == Globals.server_state) return; // not playing a game SaveGame_MenuInit(); @@ -2800,7 +2800,7 @@ public final class Menu extends Key { } if (spot != null) { - if (Com.ServerState() != 0) + if (Globals.server_state != 0) Cbuf.AddText("disconnect\n"); Cbuf.AddText("gamemap \"*" + startmap + "$" + spot + "\"\n"); } -- cgit v1.2.3 From b196d0fafd0399c14aefa7660c55f55a27d9d941 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 30 Jul 2004 06:07:23 +0000 Subject: replace serverState and game_interface functions --- src/jake2/server/SV.java | 15 +++++++-------- src/jake2/server/SV_INIT.java | 21 ++++++++++----------- src/jake2/server/SV_MAIN.java | 5 ++--- 3 files changed, 19 insertions(+), 22 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/server/SV.java b/src/jake2/server/SV.java index be38f1c..4792264 100644 --- a/src/jake2/server/SV.java +++ b/src/jake2/server/SV.java @@ -2,7 +2,7 @@ * SV.java * Copyright (C) 2003 * - * $Id: SV.java,v 1.4 2004-07-26 19:17:06 hzi Exp $ + * $Id: SV.java,v 1.5 2004-07-30 06:07:23 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,13 +25,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.server; -import jake2.*; +import jake2.Defines; +import jake2.client.M; import jake2.game.*; import jake2.qcommon.Com; -import jake2.util.*; -import jake2.client.*; -import jake2.game.*; -import jake2.game.trace_t; +import jake2.util.Lib; +import jake2.util.Math3D; /** * SV @@ -90,7 +89,7 @@ public final class SV { ent.nextthink = 0; if (ent.think == null) - GameBase.gi.error("NULL ent.think"); + Com.Error(Defines.ERR_FATAL, "NULL ent.think"); ent.think.think(ent); @@ -486,7 +485,7 @@ public final class SV { } } if (GameBase.pushed_p > Defines.MAX_EDICTS) - GameBase.gi.error(Defines.ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted"); + SV_GAME.PF_error(Defines.ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted"); if (part != null) { // the move failed, bump all nextthink times and back out moves diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java index 631e898..fd0823c 100644 --- a/src/jake2/server/SV_INIT.java +++ b/src/jake2/server/SV_INIT.java @@ -19,20 +19,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 14.01.2004 by RST. -// $Id: SV_INIT.java,v 1.4 2004-07-09 06:50:49 hzi Exp $ +// $Id: SV_INIT.java,v 1.5 2004-07-30 06:07:23 hzi Exp $ package jake2.server; -import java.io.IOException; -import java.io.RandomAccessFile; - -import jake2.*; -import jake2.client.*; +import jake2.Globals; +import jake2.client.CL; +import jake2.client.SCR; import jake2.game.*; import jake2.qcommon.*; -import jake2.render.*; import jake2.sys.NET; -import jake2.util.Lib; + +import java.io.IOException; +import java.io.RandomAccessFile; public class SV_INIT extends Globals { @@ -211,7 +210,7 @@ public class SV_INIT extends Globals { // restarted sv.state = ss_dead; - Com.SetServerState(sv.state); + Globals.server_state= sv.state; // wipe the entire per-level structure //memset(sv, 0, sizeof(sv)); @@ -280,7 +279,7 @@ public class SV_INIT extends Globals { // precache and static commands can be issued during // map initialization sv.state = ss_loading; - Com.SetServerState(sv.state); + Globals.server_state= sv.state; // load and spawn all other entities SV_GAME.ge.SpawnEntities(sv.name, CM.CM_EntityString(), spawnpoint); @@ -291,7 +290,7 @@ public class SV_INIT extends Globals { // all precaches are complete sv.state = serverstate; - Com.SetServerState(sv.state); + Globals.server_state= sv.state; // create a baseline for more efficient communications SV_CreateBaseline(); diff --git a/src/jake2/server/SV_MAIN.java b/src/jake2/server/SV_MAIN.java index b3d5e9d..99b74e9 100644 --- a/src/jake2/server/SV_MAIN.java +++ b/src/jake2/server/SV_MAIN.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 13.01.2004 by RST. -// $Id: SV_MAIN.java,v 1.4 2004-07-23 10:09:01 hzi Exp $ +// $Id: SV_MAIN.java,v 1.5 2004-07-30 06:07:23 hzi Exp $ package jake2.server; @@ -1006,9 +1006,8 @@ public class SV_MAIN extends SV_GAME { //memset (&sv, 0, sizeof(sv)); sv = new server_t(); - - Com.SetServerState (sv.state); + Globals.server_state= sv.state; // free server static data //if (svs.clients!=null) -- cgit v1.2.3 From f78b1188f95977ecf68f2e428e8c67f06ed9f93e Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 30 Jul 2004 06:08:41 +0000 Subject: replace serverState functions --- src/jake2/qcommon/Cvar.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/qcommon/Cvar.java b/src/jake2/qcommon/Cvar.java index 8f1c182..34bcb70 100644 --- a/src/jake2/qcommon/Cvar.java +++ b/src/jake2/qcommon/Cvar.java @@ -2,7 +2,7 @@ * Cvar.java * Copyright (C) 2003 * - * $Id: Cvar.java,v 1.2 2004-07-20 11:02:24 hzi Exp $ + * $Id: Cvar.java,v 1.3 2004-07-30 06:08:41 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -189,7 +189,7 @@ public class Cvar extends Globals { return var; } - if (Com.ServerState() != 0) { + if (Globals.server_state != 0) { Com.Printf(var_name + " will be changed for next game.\n"); var.latched_string = value; } -- cgit v1.2.3 From b0a652c28dd045cd7b5376f1525175b7d5074926 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Wed, 18 Aug 2004 20:27:36 +0000 Subject: remove Swap class --- src/jake2/Globals.java | 4 +--- src/jake2/client/CL.java | 17 +++++++++------- src/jake2/game/Swap.java | 46 ------------------------------------------ src/jake2/qcommon/Qcommon.java | 4 +--- 4 files changed, 12 insertions(+), 59 deletions(-) delete mode 100644 src/jake2/game/Swap.java (limited to 'src/jake2') diff --git a/src/jake2/Globals.java b/src/jake2/Globals.java index 32771bf..c0530a4 100644 --- a/src/jake2/Globals.java +++ b/src/jake2/Globals.java @@ -2,7 +2,7 @@ * Globals.java * Copyright (C) 2003 * - * $Id: Globals.java,v 1.3 2004-07-08 20:24:48 hzi Exp $ + * $Id: Globals.java,v 1.4 2004-08-18 20:27:36 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -128,8 +128,6 @@ public class Globals extends Defines { public static FileWriter log_stats_file = null; - public static EndianHandler endian = null; - public static cvar_t m_pitch; public static cvar_t m_yaw; public static cvar_t m_forward; diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java index b1231f8..25d8ab6 100644 --- a/src/jake2/client/CL.java +++ b/src/jake2/client/CL.java @@ -2,7 +2,7 @@ * CL.java * Copyright (C) 2004 * - * $Id: CL.java,v 1.6 2004-07-30 06:03:40 hzi Exp $ + * $Id: CL.java,v 1.7 2004-08-18 20:27:35 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -37,6 +37,7 @@ import jake2.util.Vargs; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; +import java.nio.ByteOrder; /** * CL @@ -948,7 +949,9 @@ public final class CL extends CL_pred { continue; // couldn't load it } ByteBuffer bb = ByteBuffer.wrap(precache_model); - int header = Globals.endian.LittleLong(bb.getInt()); + bb.order(ByteOrder.LITTLE_ENDIAN); + + int header = bb.getInt(); if (header != qfiles.IDALIASHEADER) { // not an alias model @@ -958,17 +961,17 @@ public final class CL extends CL_pred { precache_check++; continue; } - pheader = new qfiles.dmdl_t(ByteBuffer.wrap(precache_model)); - if (Globals.endian.LittleLong(pheader.version) != ALIAS_VERSION) { + pheader = new qfiles.dmdl_t(ByteBuffer.wrap(precache_model).order(ByteOrder.LITTLE_ENDIAN)); + if (pheader.version != ALIAS_VERSION) { precache_check++; precache_model_skin = 0; continue; // couldn't load it } } - pheader = new qfiles.dmdl_t(ByteBuffer.wrap(precache_model)); + pheader = new qfiles.dmdl_t(ByteBuffer.wrap(precache_model).order(ByteOrder.LITTLE_ENDIAN)); - int num_skins = Globals.endian.LittleLong(pheader.num_skins); + int num_skins = pheader.num_skins; while (precache_model_skin - 1 < num_skins) { Com.Printf("critical code section because of endian mess!"); @@ -976,7 +979,7 @@ public final class CL extends CL_pred { String name = new String( precache_model, - Globals.endian.LittleLong(pheader.ofs_skins) + (precache_model_skin - 1) * MAX_SKINNAME, + pheader.ofs_skins + (precache_model_skin - 1) * MAX_SKINNAME, MAX_SKINNAME * num_skins); if (!CheckOrDownloadFile(name)) { diff --git a/src/jake2/game/Swap.java b/src/jake2/game/Swap.java deleted file mode 100644 index 3a074b1..0000000 --- a/src/jake2/game/Swap.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Swap.java - * Copyright (C) 2003 - * - * $Id: Swap.java,v 1.1 2004-07-07 19:59:24 hzi Exp $ - */ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -package jake2.game; - -import java.nio.ByteOrder; - -import jake2.Globals; - -/** - * Swap - */ -public final class Swap { - - public static void Init() { - // set the byte swapping variables in a portable manner - if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) { - Globals.endian= new BigEndianHandler(); - } else { - Globals.endian= new LittleEndianHandler(); - } - } - -} diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java index 9f653d4..e11b06d 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.4 2004-07-09 06:50:49 hzi Exp $ + * $Id: Qcommon.java,v 1.5 2004-08-18 20:27:36 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,7 +28,6 @@ package jake2.qcommon; import jake2.Globals; import jake2.client.*; import jake2.game.Cmd; -import jake2.game.Swap; import jake2.server.SV_MAIN; import jake2.sys.NET; import jake2.sys.Sys; @@ -59,7 +58,6 @@ public final class Qcommon extends Globals { // cvar and command buffer management Com.InitArgv(args); - Swap.Init(); Cbuf.Init(); Cmd.Init(); -- cgit v1.2.3 From 59a051a177d1a3730a332bee518dabb086349e96 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Thu, 19 Aug 2004 20:49:56 +0000 Subject: disable FocusTraversalKeys for the GLCanvas --- src/jake2/render/JoglBase.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/JoglBase.java b/src/jake2/render/JoglBase.java index 6a1b91b..f29b0d2 100644 --- a/src/jake2/render/JoglBase.java +++ b/src/jake2/render/JoglBase.java @@ -2,7 +2,7 @@ * JoglCommon.java * Copyright (C) 2004 * - * $Id: JoglBase.java,v 1.5 2004-07-16 12:12:29 cawe Exp $ + * $Id: JoglBase.java,v 1.6 2004-08-19 20:49:56 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -192,9 +192,11 @@ public abstract class JoglBase implements GLEventListener { GLimp_Shutdown(); window = new JFrame("Jake2"); - GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities()); + // we want keypressed events for TAB key + canvas.setFocusTraversalKeysEnabled(false); + // TODO Use debug pipeline //canvas.setGL(new DebugGL(canvas.getGL())); @@ -205,7 +207,6 @@ public abstract class JoglBase implements GLEventListener { canvas.addGLEventListener(this); window.getContentPane().add(canvas); - canvas.setSize(newDim.width, newDim.height); // register event listener -- cgit v1.2.3 From a1a1c7334c9b03113344078d2d7977193a1d7b5e Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Thu, 19 Aug 2004 20:56:41 +0000 Subject: command line completion remove references to GameBase.gi from Cmd --- src/jake2/client/Key.java | 72 +++++++++++++++++--------- src/jake2/game/Cmd.java | 120 ++++++++++++++++++++++++++------------------ src/jake2/qcommon/Cvar.java | 22 ++++---- 3 files changed, 127 insertions(+), 87 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/Key.java b/src/jake2/client/Key.java index 6d011cb..d1c1fc8 100644 --- a/src/jake2/client/Key.java +++ b/src/jake2/client/Key.java @@ -2,7 +2,7 @@ * Key.java * Copyright (C) 2003 * - * $Id: Key.java,v 1.5 2004-07-23 10:02:49 hzi Exp $ + * $Id: Key.java,v 1.6 2004-08-19 20:56:41 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -25,17 +25,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package jake2.client; -import java.io.IOException; -import java.io.RandomAccessFile; - import jake2.Defines; import jake2.Globals; import jake2.game.Cmd; import jake2.qcommon.*; -import jake2.qcommon.Cbuf; -import jake2.qcommon.Com; import jake2.util.Lib; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.Vector; + /** * Key */ @@ -673,26 +672,49 @@ public class Key extends Globals { } + private static void printCompletions(String type, Vector compl) { + Com.Printf(type); + for (int i = 0; i < compl.size(); i++) { + Com.Printf((String)compl.get(i) + " "); + } + Com.Printf("\n"); + } + static void CompleteCommand() { - // 00166 char *cmd, *s; - // 00167 - // 00168 s = key_lines[edit_line]+1; - // 00169 if (*s == '\\' || *s == '/') - // 00170 s++; - // 00171 - // 00172 cmd = Cmd_CompleteCommand (s); - // 00173 if (!cmd) - // 00174 cmd = Cvar_CompleteVariable (s); - // 00175 if (cmd) - // 00176 { - // 00177 key_lines[edit_line][1] = '/'; - // 00178 strcpy (key_lines[edit_line]+2, cmd); - // 00179 key_linepos = strlen(cmd)+2; - // 00180 key_lines[edit_line][key_linepos] = ' '; - // 00181 key_linepos++; - // 00182 key_lines[edit_line][key_linepos] = 0; - // 00183 return; - // 00184 } + + int start = 1; + if (key_lines[edit_line][start] == '\\' || key_lines[edit_line][start] == '/') + start++; + + int end = start; + while (key_lines[edit_line][end] != 0) end++; + + String s = new String(key_lines[edit_line], start, end-start); + + Vector cmds = Cmd.CompleteCommand(s); + Vector vars = Cvar.CompleteVariable(s); + + int c = cmds.size(); + int v = vars.size(); + + if ((c + v) > 1) { + if (c > 0) printCompletions("\nCommands:\n", cmds); + if (v > 0) printCompletions("\nVariables:\n", vars); + return; + } else if (c == 1) { + s = (String)cmds.get(0); + } else if (v == 1) { + s = (String)vars.get(0); + } else return; + + key_lines[edit_line][1] = '/'; + byte[] bytes = s.getBytes(); + System.arraycopy(bytes, 0, key_lines[edit_line], 2, bytes.length); + key_linepos = bytes.length + 2; + key_lines[edit_line][key_linepos++] = ' '; + key_lines[edit_line][key_linepos] = 0; + + return; } public static xcommand_t Bind_f = new xcommand_t() { diff --git a/src/jake2/game/Cmd.java b/src/jake2/game/Cmd.java index 22d35a5..591e9fc 100644 --- a/src/jake2/game/Cmd.java +++ b/src/jake2/game/Cmd.java @@ -2,7 +2,7 @@ * Cmd.java * Copyright (C) 2003 * - * $Id: Cmd.java,v 1.4 2004-07-23 10:07:14 hzi Exp $ + * $Id: Cmd.java,v 1.5 2004-08-19 20:56:41 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,9 +28,11 @@ package jake2.game; import jake2.Defines; import jake2.Globals; import jake2.qcommon.*; +import jake2.server.SV_GAME; import jake2.util.Lib; import java.util.Arrays; +import java.util.Vector; /** * Cmd @@ -504,21 +506,21 @@ public final class Cmd extends PlayerView if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); return; } - name= GameBase.gi.args(); + name= Cmd.Args(); if (0 == Lib.Q_stricmp(name, "all")) give_all= true; else give_all= false; - if (give_all || 0 == Lib.Q_stricmp(GameBase.gi.argv(1), "health")) + if (give_all || 0 == Lib.Q_stricmp(Cmd.Argv(1), "health")) { - if (GameBase.gi.argc() == 3) - ent.health= Lib.atoi(GameBase.gi.argv(2)); + if (Cmd.Argc() == 3) + ent.health= Lib.atoi(Cmd.Argv(2)); else ent.health= ent.max_health; if (!give_all) @@ -604,18 +606,18 @@ public final class Cmd extends PlayerView it= GameUtil.FindItem(name); if (it == null) { - name= GameBase.gi.argv(1); + name= Cmd.Argv(1); it= GameUtil.FindItem(name); if (it == null) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "unknown item\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item\n"); return; } } if (it.pickup == null) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "non-pickup item\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "non-pickup item\n"); return; } @@ -623,8 +625,8 @@ public final class Cmd extends PlayerView if ((it.flags & Defines.IT_AMMO) != 0) { - if (GameBase.gi.argc() == 3) - ent.client.pers.inventory[index]= Lib.atoi(GameBase.gi.argv(2)); + if (Cmd.Argc() == 3) + ent.client.pers.inventory[index]= Lib.atoi(Cmd.Argv(2)); else ent.client.pers.inventory[index] += it.quantity; } @@ -654,7 +656,7 @@ public final class Cmd extends PlayerView if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); return; } @@ -664,7 +666,7 @@ public final class Cmd extends PlayerView else msg= "godmode ON\n"; - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, msg); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, msg); } /* @@ -682,7 +684,7 @@ public final class Cmd extends PlayerView if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); return; } @@ -692,7 +694,7 @@ public final class Cmd extends PlayerView else msg= "notarget ON\n"; - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, msg); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, msg); } /* @@ -708,7 +710,7 @@ public final class Cmd extends PlayerView if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n"); return; } @@ -723,7 +725,7 @@ public final class Cmd extends PlayerView msg= "noclip ON\n"; } - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, msg); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, msg); } /* @@ -739,22 +741,22 @@ public final class Cmd extends PlayerView gitem_t it; String s; - s= GameBase.gi.args(); + s= Cmd.Args(); it= GameUtil.FindItem(s); if (it == null) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s + "\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s + "\n"); return; } if (it.use == null) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Item is not usable.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Item is not usable.\n"); return; } index= GameUtil.ITEM_INDEX(it); if (0 == ent.client.pers.inventory[index]) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Out of item: " + s + "\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Out of item: " + s + "\n"); return; } @@ -774,22 +776,22 @@ public final class Cmd extends PlayerView gitem_t it; String s; - s= GameBase.gi.args(); + s= Cmd.Args(); it= GameUtil.FindItem(s); if (it == null) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s + "\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s + "\n"); return; } if (it.drop == null) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Item is not dropable.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Item is not dropable.\n"); return; } index= GameUtil.ITEM_INDEX(it); if (0 == ent.client.pers.inventory[index]) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Out of item: " + s + "\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Out of item: " + s + "\n"); return; } @@ -840,14 +842,14 @@ public final class Cmd extends PlayerView if (ent.client.pers.selected_item == -1) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "No item to use.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "No item to use.\n"); return; } it= GameAI.itemlist[ent.client.pers.selected_item]; if (it.use == null) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Item is not usable.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Item is not usable.\n"); return; } it.use.use(ent, it); @@ -970,14 +972,14 @@ public final class Cmd extends PlayerView if (ent.client.pers.selected_item == -1) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "No item to drop.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "No item to drop.\n"); return; } it= GameAI.itemlist[ent.client.pers.selected_item]; if (it.drop == null) { - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Item is not dropable.\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Item is not dropable.\n"); return; } it.drop.drop(ent, it); @@ -1117,7 +1119,7 @@ public final class Cmd extends PlayerView large += small; } - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "" + large + "\n" + count + " players\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "" + large + "\n" + count + " players\n"); } /* @@ -1129,7 +1131,7 @@ public final class Cmd extends PlayerView { int i; - i= Lib.atoi(GameBase.gi.argv(1)); + i= Lib.atoi(Cmd.Argv(1)); // can't wave when ducked if ((ent.client.ps.pmove.pm_flags & Defines.PMF_DUCKED) != 0) @@ -1143,28 +1145,28 @@ public final class Cmd extends PlayerView switch (i) { case 0 : - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "flipoff\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "flipoff\n"); ent.s.frame= M_Player.FRAME_flip01 - 1; ent.client.anim_end= M_Player.FRAME_flip12; break; case 1 : - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "salute\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "salute\n"); ent.s.frame= M_Player.FRAME_salute01 - 1; ent.client.anim_end= M_Player.FRAME_salute11; break; case 2 : - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "taunt\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "taunt\n"); ent.s.frame= M_Player.FRAME_taunt01 - 1; ent.client.anim_end= M_Player.FRAME_taunt17; break; case 3 : - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "wave\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "wave\n"); ent.s.frame= M_Player.FRAME_wave01 - 1; ent.client.anim_end= M_Player.FRAME_wave11; break; case 4 : default : - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "point\n"); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "point\n"); ent.s.frame= M_Player.FRAME_point01 - 1; ent.client.anim_end= M_Player.FRAME_point12; break; @@ -1184,7 +1186,7 @@ public final class Cmd extends PlayerView String text; gclient_t cl; - if (gi.argc() < 2 && !arg0) + if (Cmd.Argc() < 2 && !arg0) return; if (0 == ((int) (dmflags.value) & (DF_MODELTEAMS | DF_SKINTEAMS))) @@ -1197,16 +1199,16 @@ public final class Cmd extends PlayerView if (arg0) { - text += gi.argv(0); + text += Cmd.Argv(0); text += " "; - text += gi.args(); + text += Cmd.Args(); } else { - if (gi.args().startsWith("\"")) - text += gi.args().substring(1, gi.args().length() - 1); + if (Cmd.Args().startsWith("\"")) + text += Cmd.Args().substring(1, Cmd.Args().length() - 1); else - text += gi.args(); + text += Cmd.Args(); /* p = gi.args(); // *p == @@ -1232,7 +1234,7 @@ public final class Cmd extends PlayerView if (level.time < cl.flood_locktill) { - gi.cprintf(ent, PRINT_HIGH, "You can't talk for " + (int) (cl.flood_locktill - level.time) + " more seconds\n"); + SV_GAME.PF_cprintf(ent, PRINT_HIGH, "You can't talk for " + (int) (cl.flood_locktill - level.time) + " more seconds\n"); return; } i= (int) (cl.flood_whenhead - flood_msgs.value + 1); @@ -1242,7 +1244,7 @@ public final class Cmd extends PlayerView if (cl.flood_when[i] != 0 && level.time - cl.flood_when[i] < flood_persecond.value) { cl.flood_locktill= level.time + flood_waitdelay.value; - gi.cprintf(ent, PRINT_CHAT, "Flood protection: You can't talk for " + (int) flood_waitdelay.value + " seconds.\n"); + SV_GAME.PF_cprintf(ent, PRINT_CHAT, "Flood protection: You can't talk for " + (int) flood_waitdelay.value + " seconds.\n"); return; } //cl.flood_whenhead = (cl.flood_whenhead + 1) % (sizeof(cl.flood_when) / sizeof(cl.flood_when[0])); @@ -1251,7 +1253,7 @@ public final class Cmd extends PlayerView } if (dedicated.value != 0) - gi.cprintf(null, PRINT_CHAT, "" + text + ""); + SV_GAME.PF_cprintf(null, PRINT_CHAT, "" + text + ""); for (j= 1; j <= game.maxclients; j++) { @@ -1265,7 +1267,7 @@ public final class Cmd extends PlayerView if (!OnSameTeam(ent, other)) continue; } - gi.cprintf(other, PRINT_CHAT, "" + text + ""); + SV_GAME.PF_cprintf(other, PRINT_CHAT, "" + text + ""); } } @@ -1308,12 +1310,12 @@ public final class Cmd extends PlayerView if (text.length() + st.length() > 1024 - 50) { text += "And more...\n"; - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "" + text + ""); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "" + text + ""); return; } text += st; } - GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, text); + SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, text); } // ====================================================================== @@ -1345,6 +1347,26 @@ public final class Cmd extends PlayerView SZ.Print(Globals.cls.netchan.message, " "); SZ.Print(Globals.cls.netchan.message, Cmd.Args()); } - }; + } + + /* + ============ + Cmd_CompleteCommand + ============ + */ + public static Vector CompleteCommand(String partial) + { + Vector cmds = new Vector(); + + // check for match + for (cmd_function_t cmd = cmd_functions; cmd != null ; cmd = cmd.next) + if (cmd.name.startsWith(partial)) + cmds.add(cmd.name); + for (cmdalias_t a = cmd_alias; a != null; a=a.next) + if (a.name.startsWith(partial)) + cmds.add(a.name); + + return cmds; + } } diff --git a/src/jake2/qcommon/Cvar.java b/src/jake2/qcommon/Cvar.java index 34bcb70..a43464b 100644 --- a/src/jake2/qcommon/Cvar.java +++ b/src/jake2/qcommon/Cvar.java @@ -2,7 +2,7 @@ * Cvar.java * Copyright (C) 2003 * - * $Id: Cvar.java,v 1.3 2004-07-30 06:08:41 hzi Exp $ + * $Id: Cvar.java,v 1.4 2004-08-19 20:56:41 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -28,6 +28,7 @@ package jake2.qcommon; import java.io.IOException; import java.io.RandomAccessFile; +import java.util.Vector; import jake2.Defines; import jake2.Globals; @@ -430,21 +431,16 @@ public class Cvar extends Globals { Cvar_CompleteVariable ============ */ - static String CompleteVariable(String partial) { - cvar_t cvar; - int len; - - len = partial.length(); - - if (len == 0) - return null; + public static Vector CompleteVariable(String partial) { + + Vector vars = new Vector(); // check match - for (cvar = Globals.cvar_vars; cvar != null; cvar = cvar.next) + for (cvar_t cvar = Globals.cvar_vars; cvar != null; cvar = cvar.next) if (cvar.name.startsWith(partial)) - return cvar.name; - - return null; + vars.add(cvar.name); + + return vars; } /* -- cgit v1.2.3 From 93a1cb6d6bfa9d7a80c004100125c829f1f36e86 Mon Sep 17 00:00:00 2001 From: Rene Stoeckel Date: Fri, 20 Aug 2004 21:29:58 +0000 Subject: savegames now seem to work. --- src/jake2/client/Menu.java | 2692 +++++++++++++++--------------- src/jake2/game/GameBase.java | 5 +- src/jake2/game/GameSave.java | 721 ++------ src/jake2/game/GameUtil.java | 3 +- src/jake2/game/PlayerClient.java | 11 +- src/jake2/game/PlayerClientAdapters.java | 106 +- src/jake2/game/SuperAdapter.java | 87 +- src/jake2/game/client_persistant_t.java | 89 +- src/jake2/game/client_respawn_t.java | 62 +- src/jake2/game/edict_t.java | 781 ++++++--- src/jake2/game/entity_state_t.java | 80 +- src/jake2/game/game_export_t.java | 35 +- src/jake2/game/game_locals_t.java | 58 +- src/jake2/game/gclient_t.java | 340 ++-- src/jake2/game/gitem_t.java | 4 +- src/jake2/game/level_locals_t.java | 98 +- src/jake2/game/mframe_t.java | 32 +- src/jake2/game/mmove_t.java | 46 +- src/jake2/game/monsterinfo_t.java | 101 +- src/jake2/game/moveinfo_t.java | 64 +- src/jake2/game/player_state_t.java | 179 +- src/jake2/game/pmove_state_t.java | 74 +- src/jake2/qcommon/FS.java | 4 +- src/jake2/server/SV.java | 913 +++++----- src/jake2/server/SV_CCMDS.java | 823 +++++---- src/jake2/server/SV_INIT.java | 273 +-- src/jake2/server/SV_WORLD.java | 14 +- src/jake2/util/QuakeFile.java | 180 ++ 28 files changed, 4473 insertions(+), 3402 deletions(-) create mode 100644 src/jake2/util/QuakeFile.java (limited to 'src/jake2') diff --git a/src/jake2/client/Menu.java b/src/jake2/client/Menu.java index 6e451b9..74f6714 100644 --- a/src/jake2/client/Menu.java +++ b/src/jake2/client/Menu.java @@ -2,7 +2,7 @@ * Menu.java * Copyright (C) 2004 * - * $Id: Menu.java,v 1.6 2004-07-30 06:03:40 hzi Exp $ + * $Id: Menu.java,v 1.7 2004-08-20 21:29:56 salomo Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -34,8 +34,10 @@ import jake2.sys.NET; import jake2.sys.Sys; import jake2.util.Lib; import jake2.util.Math3D; +import jake2.util.QuakeFile; import java.awt.Dimension; +import java.io.IOException; import java.io.RandomAccessFile; import java.util.Arrays; import java.util.Comparator; @@ -53,11 +55,11 @@ abstract class keyfunc_t { public final class Menu extends Key { static int m_main_cursor; - static final int NUM_CURSOR_FRAMES = 15; + static final int NUM_CURSOR_FRAMES= 15; - static final String menu_in_sound = "misc/menu1.wav"; - static final String menu_move_sound = "misc/menu2.wav"; - static final String menu_out_sound = "misc/menu3.wav"; + static final String menu_in_sound= "misc/menu1.wav"; + static final String menu_move_sound= "misc/menu2.wav"; + static final String menu_out_sound= "misc/menu3.wav"; static boolean m_entersound; // play after drawing a frame, so caching // won't disrupt the sound @@ -69,7 +71,7 @@ public final class Menu extends Key { // ============================================================================= /* Support Routines */ - public final static int MAX_MENU_DEPTH = 8; + public final static int MAX_MENU_DEPTH= 8; public static class menulayer_t { xcommand_t draw; @@ -82,7 +84,7 @@ public final class Menu extends Key { int nitems; int nslots; - menucommon_s items[] = new menucommon_s[64]; + menucommon_s items[]= new menucommon_s[64]; String statusbar; @@ -97,15 +99,15 @@ public final class Menu extends Key { static class menucommon_s { int type; - String name; + String name= ""; int x, y; menuframework_s parent; int cursor_offset; - int localdata[] = { 0, 0, 0, 0 }; + int localdata[]= { 0, 0, 0, 0 }; int flags; - int n = -1; //position in an array. + int n= -1; //position in an array. - String statusbar; + String statusbar= ""; mcallback callback; mcallback statusbarfunc; @@ -145,11 +147,11 @@ public final class Menu extends Key { } - public static menulayer_t m_layers[] = new menulayer_t[MAX_MENU_DEPTH]; + public static menulayer_t m_layers[]= new menulayer_t[MAX_MENU_DEPTH]; public static int m_menudepth; static void Banner(String name) { - Dimension dim = new Dimension(); + Dimension dim= new Dimension(); Globals.re.DrawGetPicSize(dim, name); Globals.re.DrawPic(viddef.width / 2 - dim.width / 2, viddef.height / 2 - 110, name); @@ -163,33 +165,33 @@ public final class Menu extends Key { // if this menu is already present, drop back to that level // to avoid stacking menus by hotkeys - for (i = 0; i < m_menudepth; i++) + for (i= 0; i < m_menudepth; i++) if (m_layers[i].draw == draw && m_layers[i].key == key) { - m_menudepth = i; + m_menudepth= i; } if (i == m_menudepth) { if (m_menudepth >= MAX_MENU_DEPTH) Com.Error(ERR_FATAL, "PushMenu: MAX_MENU_DEPTH"); - m_layers[m_menudepth].draw = m_drawfunc; - m_layers[m_menudepth].key = m_keyfunc; + m_layers[m_menudepth].draw= m_drawfunc; + m_layers[m_menudepth].key= m_keyfunc; m_menudepth++; } - m_drawfunc = draw; - m_keyfunc = key; + m_drawfunc= draw; + m_keyfunc= key; - m_entersound = true; + m_entersound= true; - cls.key_dest = key_menu; + cls.key_dest= key_menu; } static void ForceMenuOff() { - m_drawfunc = null; - m_keyfunc = null; - cls.key_dest = key_game; - m_menudepth = 0; + m_drawfunc= null; + m_keyfunc= null; + cls.key_dest= key_game; + m_menudepth= 0; Key.ClearStates(); Cvar.Set("paused", "0"); } @@ -200,19 +202,19 @@ public final class Menu extends Key { Com.Error(ERR_FATAL, "PopMenu: depth < 1"); m_menudepth--; - m_drawfunc = m_layers[m_menudepth].draw; - m_keyfunc = m_layers[m_menudepth].key; + m_drawfunc= m_layers[m_menudepth].draw; + m_keyfunc= m_layers[m_menudepth].key; if (0 == m_menudepth) ForceMenuOff(); } static String Default_MenuKey(menuframework_s m, int key) { - String sound = null; + String sound= null; menucommon_s item; if (m != null) { - if ((item = ((menucommon_s) Menu_ItemAtCursor(m))) != null) { + if ((item= ((menucommon_s) Menu_ItemAtCursor(m))) != null) { if (item.type == MTYPE_FIELD) { if (Field_Key((menufield_s) item, key)) return null; @@ -229,14 +231,14 @@ public final class Menu extends Key { if (m != null) { m.cursor--; Menu_AdjustCursor(m, -1); - sound = menu_move_sound; + sound= menu_move_sound; } break; case K_TAB : if (m != null) { m.cursor++; Menu_AdjustCursor(m, 1); - sound = menu_move_sound; + sound= menu_move_sound; } break; case K_KP_DOWNARROW : @@ -244,21 +246,21 @@ public final class Menu extends Key { if (m != null) { m.cursor++; Menu_AdjustCursor(m, 1); - sound = menu_move_sound; + sound= menu_move_sound; } break; case K_KP_LEFTARROW : case K_LEFTARROW : if (m != null) { Menu_SlideItem(m, -1); - sound = menu_move_sound; + sound= menu_move_sound; } break; case K_KP_RIGHTARROW : case K_RIGHTARROW : if (m != null) { Menu_SlideItem(m, 1); - sound = menu_move_sound; + sound= menu_move_sound; } break; @@ -307,7 +309,7 @@ public final class Menu extends Key { case K_ENTER : if (m != null) Menu_SelectItem(m); - sound = menu_move_sound; + sound= menu_move_sound; break; } @@ -329,7 +331,7 @@ public final class Menu extends Key { public static void Print(int cx, int cy, String str) { //while (*str) - for (int n = 0; n < str.length(); n++) { + for (int n= 0; n < str.length(); n++) { DrawCharacter(cx, cy, str.charAt(n) + 128); //str++; cx += 8; @@ -337,7 +339,7 @@ public final class Menu extends Key { } public static void PrintWhite(int cx, int cy, String str) { - for (int n = 0; n < str.length(); n++) { + for (int n= 0; n < str.length(); n++) { DrawCharacter(cx, cy, str.charAt(n)); //str++; cx += 8; @@ -364,20 +366,20 @@ public final class Menu extends Key { assert(f >= 0) : "negative time and cursor bug"; - f = Math.abs(f); + f= Math.abs(f); if (!cached) { int i; - for (i = 0; i < NUM_CURSOR_FRAMES; i++) { - cursorname = "m_cursor" + i; + for (i= 0; i < NUM_CURSOR_FRAMES; i++) { + cursorname= "m_cursor" + i; re.RegisterPic(cursorname); } - cached = true; + cached= true; } - cursorname = "m_cursor" + f; + cursorname= "m_cursor" + f; re.DrawPic(x, y, cursorname); } @@ -386,11 +388,11 @@ public final class Menu extends Key { int n; // draw left side - cx = x; - cy = y; + cx= x; + cy= y; DrawCharacter(cx, cy, 1); - for (n = 0; n < lines; n++) { + for (n= 0; n < lines; n++) { cy += 8; DrawCharacter(cx, cy, 4); } @@ -399,10 +401,10 @@ public final class Menu extends Key { // draw middle cx += 8; while (width > 0) { - cy = y; + cy= y; DrawCharacter(cx, cy, 2); - for (n = 0; n < lines; n++) { + for (n= 0; n < lines; n++) { cy += 8; DrawCharacter(cx, cy, 5); } @@ -413,9 +415,9 @@ public final class Menu extends Key { } // draw right side - cy = y; + cy= y; DrawCharacter(cx, cy, 3); - for (n = 0; n < lines; n++) { + for (n= 0; n < lines; n++) { cy += 8; DrawCharacter(cx, cy, 6); @@ -431,9 +433,9 @@ public final class Menu extends Key { ======================================================================= */ - static final int MAIN_ITEMS = 5; + static final int MAIN_ITEMS= 5; - static xcommand_t Main_Draw = new xcommand_t() { + static xcommand_t Main_Draw= new xcommand_t() { public void execute() { Main_Draw(); } @@ -443,52 +445,52 @@ public final class Menu extends Key { int w, h; int ystart; int xoffset; - int widest = -1; - int totalheight = 0; + int widest= -1; + int totalheight= 0; String litname; - String[] names = { "m_main_game", "m_main_multiplayer", "m_main_options", "m_main_video", "m_main_quit" }; - Dimension dim = new Dimension(); + String[] names= { "m_main_game", "m_main_multiplayer", "m_main_options", "m_main_video", "m_main_quit" }; + Dimension dim= new Dimension(); - for (i = 0; i < names.length; i++) { + for (i= 0; i < names.length; i++) { Globals.re.DrawGetPicSize(dim, names[i]); - w = dim.width; - h = dim.height; + w= dim.width; + h= dim.height; if (w > widest) - widest = w; + widest= w; totalheight += (h + 12); } - ystart = (Globals.viddef.height / 2 - 110); - xoffset = (Globals.viddef.width - widest + 70) / 2; + ystart= (Globals.viddef.height / 2 - 110); + xoffset= (Globals.viddef.width - widest + 70) / 2; - for (i = 0; i < names.length; i++) { + for (i= 0; i < names.length; i++) { if (i != m_main_cursor) Globals.re.DrawPic(xoffset, ystart + i * 40 + 13, names[i]); } //strcat(litname, "_sel"); - litname = names[m_main_cursor] + "_sel"; + litname= names[m_main_cursor] + "_sel"; Globals.re.DrawPic(xoffset, ystart + m_main_cursor * 40 + 13, litname); DrawCursor(xoffset - 25, ystart + m_main_cursor * 40 + 11, (int) ((Globals.cls.realtime / 100)) % NUM_CURSOR_FRAMES); Globals.re.DrawGetPicSize(dim, "m_main_plaque"); - w = dim.width; - h = dim.height; + w= dim.width; + h= dim.height; Globals.re.DrawPic(xoffset - 30 - w, ystart, "m_main_plaque"); Globals.re.DrawPic(xoffset - 30 - w, ystart + h + 5, "m_main_logo"); } - static keyfunc_t Main_Key = new keyfunc_t() { + static keyfunc_t Main_Key= new keyfunc_t() { public String execute(int key) { return Main_Key(key); } }; static String Main_Key(int key) { - String sound = menu_move_sound; + String sound= menu_move_sound; switch (key) { case Key.K_ESCAPE : @@ -498,18 +500,18 @@ public final class Menu extends Key { case Key.K_KP_DOWNARROW : case Key.K_DOWNARROW : if (++m_main_cursor >= MAIN_ITEMS) - m_main_cursor = 0; + m_main_cursor= 0; return sound; case Key.K_KP_UPARROW : case Key.K_UPARROW : if (--m_main_cursor < 0) - m_main_cursor = MAIN_ITEMS - 1; + m_main_cursor= MAIN_ITEMS - 1; return sound; case Key.K_KP_ENTER : case Key.K_ENTER : - m_entersound = true; + m_entersound= true; switch (m_main_cursor) { case 0 : @@ -537,7 +539,7 @@ public final class Menu extends Key { return null; } - static xcommand_t Menu_Main = new xcommand_t() { + static xcommand_t Menu_Main= new xcommand_t() { public void execute() { Menu_Main_f(); } @@ -562,10 +564,10 @@ public final class Menu extends Key { ======================================================================= */ - static menuframework_s s_multiplayer_menu = new menuframework_s(); - static menuaction_s s_join_network_server_action = new menuaction_s(); - static menuaction_s s_start_network_server_action = new menuaction_s(); - static menuaction_s s_player_setup_action = new menuaction_s(); + static menuframework_s s_multiplayer_menu= new menuframework_s(); + static menuaction_s s_join_network_server_action= new menuaction_s(); + static menuaction_s s_start_network_server_action= new menuaction_s(); + static menuaction_s s_player_setup_action= new menuaction_s(); static void Multiplayer_MenuDraw() { Banner("m_banner_multiplayer"); @@ -587,37 +589,37 @@ public final class Menu extends Key { } static void Multiplayer_MenuInit() { - s_multiplayer_menu.x = (int) (viddef.width * 0.50f - 64); - s_multiplayer_menu.nitems = 0; - - s_join_network_server_action.type = MTYPE_ACTION; - s_join_network_server_action.flags = QMF_LEFT_JUSTIFY; - s_join_network_server_action.x = 0; - s_join_network_server_action.y = 0; - s_join_network_server_action.name = " join network server"; - s_join_network_server_action.callback = new mcallback() { + s_multiplayer_menu.x= (int) (viddef.width * 0.50f - 64); + s_multiplayer_menu.nitems= 0; + + s_join_network_server_action.type= MTYPE_ACTION; + s_join_network_server_action.flags= QMF_LEFT_JUSTIFY; + s_join_network_server_action.x= 0; + s_join_network_server_action.y= 0; + s_join_network_server_action.name= " join network server"; + s_join_network_server_action.callback= new mcallback() { public void execute(Object o) { JoinNetworkServerFunc(o); }; }; - s_start_network_server_action.type = MTYPE_ACTION; - s_start_network_server_action.flags = QMF_LEFT_JUSTIFY; - s_start_network_server_action.x = 0; - s_start_network_server_action.y = 10; - s_start_network_server_action.name = " start network server"; - s_start_network_server_action.callback = new mcallback() { + s_start_network_server_action.type= MTYPE_ACTION; + s_start_network_server_action.flags= QMF_LEFT_JUSTIFY; + s_start_network_server_action.x= 0; + s_start_network_server_action.y= 10; + s_start_network_server_action.name= " start network server"; + s_start_network_server_action.callback= new mcallback() { public void execute(Object o) { StartNetworkServerFunc(o); } }; - s_player_setup_action.type = MTYPE_ACTION; - s_player_setup_action.flags = QMF_LEFT_JUSTIFY; - s_player_setup_action.x = 0; - s_player_setup_action.y = 20; - s_player_setup_action.name = " player setup"; - s_player_setup_action.callback = new mcallback() { + s_player_setup_action.type= MTYPE_ACTION; + s_player_setup_action.flags= QMF_LEFT_JUSTIFY; + s_player_setup_action.x= 0; + s_player_setup_action.y= 20; + s_player_setup_action.name= " player setup"; + s_player_setup_action.callback= new mcallback() { public void execute(Object o) { PlayerSetupFunc(o); } @@ -636,7 +638,7 @@ public final class Menu extends Key { return Default_MenuKey(s_multiplayer_menu, key); } - static xcommand_t Menu_Multiplayer = new xcommand_t() { + static xcommand_t Menu_Multiplayer= new xcommand_t() { public void execute() { Menu_Multiplayer_f(); } @@ -662,7 +664,7 @@ public final class Menu extends Key { ======================================================================= */ - static String bindnames[][] = { { "+attack", "attack" }, { + static String bindnames[][]= { { "+attack", "attack" }, { "weapnext", "next weapon" }, { "+forward", "walk forward" }, { "+back", "backpedal" }, { @@ -693,38 +695,38 @@ public final class Menu extends Key { int keys_cursor; static boolean bind_grab; - static menuframework_s s_keys_menu = new menuframework_s(); - static menuaction_s s_keys_attack_action = new menuaction_s(); - static menuaction_s s_keys_change_weapon_action = new menuaction_s(); - static menuaction_s s_keys_walk_forward_action = new menuaction_s(); - static menuaction_s s_keys_backpedal_action = new menuaction_s(); - static menuaction_s s_keys_turn_left_action = new menuaction_s(); - static menuaction_s s_keys_turn_right_action = new menuaction_s(); - static menuaction_s s_keys_run_action = new menuaction_s(); - static menuaction_s s_keys_step_left_action = new menuaction_s(); - static menuaction_s s_keys_step_right_action = new menuaction_s(); - static menuaction_s s_keys_sidestep_action = new menuaction_s(); - static menuaction_s s_keys_look_up_action = new menuaction_s(); - static menuaction_s s_keys_look_down_action = new menuaction_s(); - static menuaction_s s_keys_center_view_action = new menuaction_s(); - static menuaction_s s_keys_mouse_look_action = new menuaction_s(); - static menuaction_s s_keys_keyboard_look_action = new menuaction_s(); - static menuaction_s s_keys_move_up_action = new menuaction_s(); - static menuaction_s s_keys_move_down_action = new menuaction_s(); - static menuaction_s s_keys_inventory_action = new menuaction_s(); - static menuaction_s s_keys_inv_use_action = new menuaction_s(); - static menuaction_s s_keys_inv_drop_action = new menuaction_s(); - static menuaction_s s_keys_inv_prev_action = new menuaction_s(); - static menuaction_s s_keys_inv_next_action = new menuaction_s(); - - static menuaction_s s_keys_help_computer_action = new menuaction_s(); + static menuframework_s s_keys_menu= new menuframework_s(); + static menuaction_s s_keys_attack_action= new menuaction_s(); + static menuaction_s s_keys_change_weapon_action= new menuaction_s(); + static menuaction_s s_keys_walk_forward_action= new menuaction_s(); + static menuaction_s s_keys_backpedal_action= new menuaction_s(); + static menuaction_s s_keys_turn_left_action= new menuaction_s(); + static menuaction_s s_keys_turn_right_action= new menuaction_s(); + static menuaction_s s_keys_run_action= new menuaction_s(); + static menuaction_s s_keys_step_left_action= new menuaction_s(); + static menuaction_s s_keys_step_right_action= new menuaction_s(); + static menuaction_s s_keys_sidestep_action= new menuaction_s(); + static menuaction_s s_keys_look_up_action= new menuaction_s(); + static menuaction_s s_keys_look_down_action= new menuaction_s(); + static menuaction_s s_keys_center_view_action= new menuaction_s(); + static menuaction_s s_keys_mouse_look_action= new menuaction_s(); + static menuaction_s s_keys_keyboard_look_action= new menuaction_s(); + static menuaction_s s_keys_move_up_action= new menuaction_s(); + static menuaction_s s_keys_move_down_action= new menuaction_s(); + static menuaction_s s_keys_inventory_action= new menuaction_s(); + static menuaction_s s_keys_inv_use_action= new menuaction_s(); + static menuaction_s s_keys_inv_drop_action= new menuaction_s(); + static menuaction_s s_keys_inv_prev_action= new menuaction_s(); + static menuaction_s s_keys_inv_next_action= new menuaction_s(); + + static menuaction_s s_keys_help_computer_action= new menuaction_s(); static void UnbindCommand(String command) { int j; String b; - for (j = 0; j < 256; j++) { - b = keybindings[j]; + for (j= 0; j < 256; j++) { + b= keybindings[j]; if (b == null) continue; if (b.equals(command)) @@ -737,16 +739,16 @@ public final class Menu extends Key { int j; String b; - twokeys[0] = twokeys[1] = -1; - count = 0; + twokeys[0]= twokeys[1]= -1; + count= 0; - for (j = 0; j < 256; j++) { - b = keybindings[j]; + for (j= 0; j < 256; j++) { + b= keybindings[j]; if (b == null) continue; - - if (b.equals(command)) { - twokeys[count] = j; + + if (b.equals(command)) { + twokeys[count]= j; count++; if (count == 2) break; @@ -762,8 +764,8 @@ public final class Menu extends Key { } static void DrawKeyBindingFunc(Object self) { - int keys[] = { 0, 0 }; - menuaction_s a = (menuaction_s) self; + int keys[]= { 0, 0 }; + menuaction_s a= (menuaction_s) self; FindKeysForCommand(bindnames[a.localdata[0]][0], keys); @@ -774,11 +776,11 @@ public final class Menu extends Key { int x; String name; - name = Key.KeynumToString(keys[0]); + name= Key.KeynumToString(keys[0]); Menu_DrawString(a.x + a.parent.x + 16, a.y + a.parent.y, name); - x = name.length() * 8; + x= name.length() * 8; if (keys[1] != -1) { Menu_DrawString(a.x + a.parent.x + 24 + x, a.y + a.parent.y, "or"); @@ -788,322 +790,322 @@ public final class Menu extends Key { } static void KeyBindingFunc(Object self) { - menuaction_s a = (menuaction_s) self; - int keys[] = { 0, 0 }; + menuaction_s a= (menuaction_s) self; + int keys[]= { 0, 0 }; FindKeysForCommand(bindnames[a.localdata[0]][0], keys); if (keys[1] != -1) UnbindCommand(bindnames[a.localdata[0]][0]); - bind_grab = true; + bind_grab= true; Menu_SetStatusBar(s_keys_menu, "press a key or button for this action"); } static void Keys_MenuInit() { - int y = 0; - int i = 0; + int y= 0; + int i= 0; - s_keys_menu.x = (int) (viddef.width * 0.50); - s_keys_menu.nitems = 0; - s_keys_menu.cursordraw = new mcallback() { + s_keys_menu.x= (int) (viddef.width * 0.50); + s_keys_menu.nitems= 0; + s_keys_menu.cursordraw= new mcallback() { public void execute(Object o) { KeyCursorDrawFunc((menuframework_s) o); } }; - s_keys_attack_action.type = MTYPE_ACTION; - s_keys_attack_action.flags = QMF_GRAYED; - s_keys_attack_action.x = 0; - s_keys_attack_action.y = y; - s_keys_attack_action.ownerdraw = new mcallback() { + s_keys_attack_action.type= MTYPE_ACTION; + s_keys_attack_action.flags= QMF_GRAYED; + s_keys_attack_action.x= 0; + s_keys_attack_action.y= y; + s_keys_attack_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_attack_action.localdata[0] = i; - s_keys_attack_action.name = bindnames[s_keys_attack_action.localdata[0]][1]; - - s_keys_change_weapon_action.type = MTYPE_ACTION; - s_keys_change_weapon_action.flags = QMF_GRAYED; - s_keys_change_weapon_action.x = 0; - s_keys_change_weapon_action.y = y += 9; - s_keys_change_weapon_action.ownerdraw = new mcallback() { + s_keys_attack_action.localdata[0]= i; + s_keys_attack_action.name= bindnames[s_keys_attack_action.localdata[0]][1]; + + s_keys_change_weapon_action.type= MTYPE_ACTION; + s_keys_change_weapon_action.flags= QMF_GRAYED; + s_keys_change_weapon_action.x= 0; + s_keys_change_weapon_action.y= y += 9; + s_keys_change_weapon_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_change_weapon_action.localdata[0] = ++i; - s_keys_change_weapon_action.name = bindnames[s_keys_change_weapon_action.localdata[0]][1]; + s_keys_change_weapon_action.localdata[0]= ++i; + s_keys_change_weapon_action.name= bindnames[s_keys_change_weapon_action.localdata[0]][1]; - s_keys_walk_forward_action.type = MTYPE_ACTION; - s_keys_walk_forward_action.flags = QMF_GRAYED; - s_keys_walk_forward_action.x = 0; - s_keys_walk_forward_action.y = y += 9; - s_keys_walk_forward_action.ownerdraw = new mcallback() { + s_keys_walk_forward_action.type= MTYPE_ACTION; + s_keys_walk_forward_action.flags= QMF_GRAYED; + s_keys_walk_forward_action.x= 0; + s_keys_walk_forward_action.y= y += 9; + s_keys_walk_forward_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_walk_forward_action.localdata[0] = ++i; - s_keys_walk_forward_action.name = bindnames[s_keys_walk_forward_action.localdata[0]][1]; - - s_keys_backpedal_action.type = MTYPE_ACTION; - s_keys_backpedal_action.flags = QMF_GRAYED; - s_keys_backpedal_action.x = 0; - s_keys_backpedal_action.y = y += 9; - s_keys_backpedal_action.ownerdraw = new mcallback() { + s_keys_walk_forward_action.localdata[0]= ++i; + s_keys_walk_forward_action.name= bindnames[s_keys_walk_forward_action.localdata[0]][1]; + + s_keys_backpedal_action.type= MTYPE_ACTION; + s_keys_backpedal_action.flags= QMF_GRAYED; + s_keys_backpedal_action.x= 0; + s_keys_backpedal_action.y= y += 9; + s_keys_backpedal_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_backpedal_action.localdata[0] = ++i; - s_keys_backpedal_action.name = bindnames[s_keys_backpedal_action.localdata[0]][1]; - - s_keys_turn_left_action.type = MTYPE_ACTION; - s_keys_turn_left_action.flags = QMF_GRAYED; - s_keys_turn_left_action.x = 0; - s_keys_turn_left_action.y = y += 9; - s_keys_turn_left_action.ownerdraw = new mcallback() { + s_keys_backpedal_action.localdata[0]= ++i; + s_keys_backpedal_action.name= bindnames[s_keys_backpedal_action.localdata[0]][1]; + + s_keys_turn_left_action.type= MTYPE_ACTION; + s_keys_turn_left_action.flags= QMF_GRAYED; + s_keys_turn_left_action.x= 0; + s_keys_turn_left_action.y= y += 9; + s_keys_turn_left_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_turn_left_action.localdata[0] = ++i; - s_keys_turn_left_action.name = bindnames[s_keys_turn_left_action.localdata[0]][1]; - - s_keys_turn_right_action.type = MTYPE_ACTION; - s_keys_turn_right_action.flags = QMF_GRAYED; - s_keys_turn_right_action.x = 0; - s_keys_turn_right_action.y = y += 9; - s_keys_turn_right_action.ownerdraw = new mcallback() { + s_keys_turn_left_action.localdata[0]= ++i; + s_keys_turn_left_action.name= bindnames[s_keys_turn_left_action.localdata[0]][1]; + + s_keys_turn_right_action.type= MTYPE_ACTION; + s_keys_turn_right_action.flags= QMF_GRAYED; + s_keys_turn_right_action.x= 0; + s_keys_turn_right_action.y= y += 9; + s_keys_turn_right_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_turn_right_action.localdata[0] = ++i; - s_keys_turn_right_action.name = bindnames[s_keys_turn_right_action.localdata[0]][1]; - - s_keys_run_action.type = MTYPE_ACTION; - s_keys_run_action.flags = QMF_GRAYED; - s_keys_run_action.x = 0; - s_keys_run_action.y = y += 9; - s_keys_run_action.ownerdraw = new mcallback() { + s_keys_turn_right_action.localdata[0]= ++i; + s_keys_turn_right_action.name= bindnames[s_keys_turn_right_action.localdata[0]][1]; + + s_keys_run_action.type= MTYPE_ACTION; + s_keys_run_action.flags= QMF_GRAYED; + s_keys_run_action.x= 0; + s_keys_run_action.y= y += 9; + s_keys_run_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_run_action.localdata[0] = ++i; - s_keys_run_action.name = bindnames[s_keys_run_action.localdata[0]][1]; - - s_keys_step_left_action.type = MTYPE_ACTION; - s_keys_step_left_action.flags = QMF_GRAYED; - s_keys_step_left_action.x = 0; - s_keys_step_left_action.y = y += 9; - s_keys_step_left_action.ownerdraw = new mcallback() { + s_keys_run_action.localdata[0]= ++i; + s_keys_run_action.name= bindnames[s_keys_run_action.localdata[0]][1]; + + s_keys_step_left_action.type= MTYPE_ACTION; + s_keys_step_left_action.flags= QMF_GRAYED; + s_keys_step_left_action.x= 0; + s_keys_step_left_action.y= y += 9; + s_keys_step_left_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_step_left_action.localdata[0] = ++i; - s_keys_step_left_action.name = bindnames[s_keys_step_left_action.localdata[0]][1]; - - s_keys_step_right_action.type = MTYPE_ACTION; - s_keys_step_right_action.flags = QMF_GRAYED; - s_keys_step_right_action.x = 0; - s_keys_step_right_action.y = y += 9; - s_keys_step_right_action.ownerdraw = new mcallback() { + s_keys_step_left_action.localdata[0]= ++i; + s_keys_step_left_action.name= bindnames[s_keys_step_left_action.localdata[0]][1]; + + s_keys_step_right_action.type= MTYPE_ACTION; + s_keys_step_right_action.flags= QMF_GRAYED; + s_keys_step_right_action.x= 0; + s_keys_step_right_action.y= y += 9; + s_keys_step_right_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_step_right_action.localdata[0] = ++i; - s_keys_step_right_action.name = bindnames[s_keys_step_right_action.localdata[0]][1]; + s_keys_step_right_action.localdata[0]= ++i; + s_keys_step_right_action.name= bindnames[s_keys_step_right_action.localdata[0]][1]; - s_keys_sidestep_action.type = MTYPE_ACTION; - s_keys_sidestep_action.flags = QMF_GRAYED; - s_keys_sidestep_action.x = 0; - s_keys_sidestep_action.y = y += 9; - s_keys_sidestep_action.ownerdraw = new mcallback() { + s_keys_sidestep_action.type= MTYPE_ACTION; + s_keys_sidestep_action.flags= QMF_GRAYED; + s_keys_sidestep_action.x= 0; + s_keys_sidestep_action.y= y += 9; + s_keys_sidestep_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_sidestep_action.localdata[0] = ++i; - s_keys_sidestep_action.name = bindnames[s_keys_sidestep_action.localdata[0]][1]; + s_keys_sidestep_action.localdata[0]= ++i; + s_keys_sidestep_action.name= bindnames[s_keys_sidestep_action.localdata[0]][1]; - s_keys_look_up_action.type = MTYPE_ACTION; - s_keys_look_up_action.flags = QMF_GRAYED; - s_keys_look_up_action.x = 0; - s_keys_look_up_action.y = y += 9; - s_keys_look_up_action.ownerdraw = new mcallback() { + s_keys_look_up_action.type= MTYPE_ACTION; + s_keys_look_up_action.flags= QMF_GRAYED; + s_keys_look_up_action.x= 0; + s_keys_look_up_action.y= y += 9; + s_keys_look_up_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_look_up_action.localdata[0] = ++i; - s_keys_look_up_action.name = bindnames[s_keys_look_up_action.localdata[0]][1]; + s_keys_look_up_action.localdata[0]= ++i; + s_keys_look_up_action.name= bindnames[s_keys_look_up_action.localdata[0]][1]; - s_keys_look_down_action.type = MTYPE_ACTION; - s_keys_look_down_action.flags = QMF_GRAYED; - s_keys_look_down_action.x = 0; - s_keys_look_down_action.y = y += 9; - s_keys_look_down_action.ownerdraw = new mcallback() { + s_keys_look_down_action.type= MTYPE_ACTION; + s_keys_look_down_action.flags= QMF_GRAYED; + s_keys_look_down_action.x= 0; + s_keys_look_down_action.y= y += 9; + s_keys_look_down_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_look_down_action.localdata[0] = ++i; - s_keys_look_down_action.name = bindnames[s_keys_look_down_action.localdata[0]][1]; + s_keys_look_down_action.localdata[0]= ++i; + s_keys_look_down_action.name= bindnames[s_keys_look_down_action.localdata[0]][1]; - s_keys_center_view_action.type = MTYPE_ACTION; - s_keys_center_view_action.flags = QMF_GRAYED; - s_keys_center_view_action.x = 0; - s_keys_center_view_action.y = y += 9; - s_keys_center_view_action.ownerdraw = new mcallback() { + s_keys_center_view_action.type= MTYPE_ACTION; + s_keys_center_view_action.flags= QMF_GRAYED; + s_keys_center_view_action.x= 0; + s_keys_center_view_action.y= y += 9; + s_keys_center_view_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_center_view_action.localdata[0] = ++i; - s_keys_center_view_action.name = bindnames[s_keys_center_view_action.localdata[0]][1]; + s_keys_center_view_action.localdata[0]= ++i; + s_keys_center_view_action.name= bindnames[s_keys_center_view_action.localdata[0]][1]; - s_keys_mouse_look_action.type = MTYPE_ACTION; - s_keys_mouse_look_action.flags = QMF_GRAYED; - s_keys_mouse_look_action.x = 0; - s_keys_mouse_look_action.y = y += 9; - s_keys_mouse_look_action.ownerdraw = new mcallback() { + s_keys_mouse_look_action.type= MTYPE_ACTION; + s_keys_mouse_look_action.flags= QMF_GRAYED; + s_keys_mouse_look_action.x= 0; + s_keys_mouse_look_action.y= y += 9; + s_keys_mouse_look_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_mouse_look_action.localdata[0] = ++i; - s_keys_mouse_look_action.name = bindnames[s_keys_mouse_look_action.localdata[0]][1]; + s_keys_mouse_look_action.localdata[0]= ++i; + s_keys_mouse_look_action.name= bindnames[s_keys_mouse_look_action.localdata[0]][1]; - s_keys_keyboard_look_action.type = MTYPE_ACTION; - s_keys_keyboard_look_action.flags = QMF_GRAYED; - s_keys_keyboard_look_action.x = 0; - s_keys_keyboard_look_action.y = y += 9; - s_keys_keyboard_look_action.ownerdraw = new mcallback() { + s_keys_keyboard_look_action.type= MTYPE_ACTION; + s_keys_keyboard_look_action.flags= QMF_GRAYED; + s_keys_keyboard_look_action.x= 0; + s_keys_keyboard_look_action.y= y += 9; + s_keys_keyboard_look_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_keyboard_look_action.localdata[0] = ++i; - s_keys_keyboard_look_action.name = bindnames[s_keys_keyboard_look_action.localdata[0]][1]; + s_keys_keyboard_look_action.localdata[0]= ++i; + s_keys_keyboard_look_action.name= bindnames[s_keys_keyboard_look_action.localdata[0]][1]; - s_keys_move_up_action.type = MTYPE_ACTION; - s_keys_move_up_action.flags = QMF_GRAYED; - s_keys_move_up_action.x = 0; - s_keys_move_up_action.y = y += 9; - s_keys_move_up_action.ownerdraw = new mcallback() { + s_keys_move_up_action.type= MTYPE_ACTION; + s_keys_move_up_action.flags= QMF_GRAYED; + s_keys_move_up_action.x= 0; + s_keys_move_up_action.y= y += 9; + s_keys_move_up_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_move_up_action.localdata[0] = ++i; - s_keys_move_up_action.name = bindnames[s_keys_move_up_action.localdata[0]][1]; + s_keys_move_up_action.localdata[0]= ++i; + s_keys_move_up_action.name= bindnames[s_keys_move_up_action.localdata[0]][1]; - s_keys_move_down_action.type = MTYPE_ACTION; - s_keys_move_down_action.flags = QMF_GRAYED; - s_keys_move_down_action.x = 0; - s_keys_move_down_action.y = y += 9; - s_keys_move_down_action.ownerdraw = new mcallback() { + s_keys_move_down_action.type= MTYPE_ACTION; + s_keys_move_down_action.flags= QMF_GRAYED; + s_keys_move_down_action.x= 0; + s_keys_move_down_action.y= y += 9; + s_keys_move_down_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_move_down_action.localdata[0] = ++i; - s_keys_move_down_action.name = bindnames[s_keys_move_down_action.localdata[0]][1]; + s_keys_move_down_action.localdata[0]= ++i; + s_keys_move_down_action.name= bindnames[s_keys_move_down_action.localdata[0]][1]; - s_keys_inventory_action.type = MTYPE_ACTION; - s_keys_inventory_action.flags = QMF_GRAYED; - s_keys_inventory_action.x = 0; - s_keys_inventory_action.y = y += 9; - s_keys_inventory_action.ownerdraw = new mcallback() { + s_keys_inventory_action.type= MTYPE_ACTION; + s_keys_inventory_action.flags= QMF_GRAYED; + s_keys_inventory_action.x= 0; + s_keys_inventory_action.y= y += 9; + s_keys_inventory_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_inventory_action.localdata[0] = ++i; - s_keys_inventory_action.name = bindnames[s_keys_inventory_action.localdata[0]][1]; + s_keys_inventory_action.localdata[0]= ++i; + s_keys_inventory_action.name= bindnames[s_keys_inventory_action.localdata[0]][1]; - s_keys_inv_use_action.type = MTYPE_ACTION; - s_keys_inv_use_action.flags = QMF_GRAYED; - s_keys_inv_use_action.x = 0; - s_keys_inv_use_action.y = y += 9; - s_keys_inv_use_action.ownerdraw = new mcallback() { + s_keys_inv_use_action.type= MTYPE_ACTION; + s_keys_inv_use_action.flags= QMF_GRAYED; + s_keys_inv_use_action.x= 0; + s_keys_inv_use_action.y= y += 9; + s_keys_inv_use_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_inv_use_action.localdata[0] = ++i; - s_keys_inv_use_action.name = bindnames[s_keys_inv_use_action.localdata[0]][1]; + s_keys_inv_use_action.localdata[0]= ++i; + s_keys_inv_use_action.name= bindnames[s_keys_inv_use_action.localdata[0]][1]; - s_keys_inv_drop_action.type = MTYPE_ACTION; - s_keys_inv_drop_action.flags = QMF_GRAYED; - s_keys_inv_drop_action.x = 0; - s_keys_inv_drop_action.y = y += 9; - s_keys_inv_drop_action.ownerdraw = new mcallback() { + s_keys_inv_drop_action.type= MTYPE_ACTION; + s_keys_inv_drop_action.flags= QMF_GRAYED; + s_keys_inv_drop_action.x= 0; + s_keys_inv_drop_action.y= y += 9; + s_keys_inv_drop_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_inv_drop_action.localdata[0] = ++i; - s_keys_inv_drop_action.name = bindnames[s_keys_inv_drop_action.localdata[0]][1]; + s_keys_inv_drop_action.localdata[0]= ++i; + s_keys_inv_drop_action.name= bindnames[s_keys_inv_drop_action.localdata[0]][1]; - s_keys_inv_prev_action.type = MTYPE_ACTION; - s_keys_inv_prev_action.flags = QMF_GRAYED; - s_keys_inv_prev_action.x = 0; - s_keys_inv_prev_action.y = y += 9; - s_keys_inv_prev_action.ownerdraw = new mcallback() { + s_keys_inv_prev_action.type= MTYPE_ACTION; + s_keys_inv_prev_action.flags= QMF_GRAYED; + s_keys_inv_prev_action.x= 0; + s_keys_inv_prev_action.y= y += 9; + s_keys_inv_prev_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_inv_prev_action.localdata[0] = ++i; - s_keys_inv_prev_action.name = bindnames[s_keys_inv_prev_action.localdata[0]][1]; + s_keys_inv_prev_action.localdata[0]= ++i; + s_keys_inv_prev_action.name= bindnames[s_keys_inv_prev_action.localdata[0]][1]; - s_keys_inv_next_action.type = MTYPE_ACTION; - s_keys_inv_next_action.flags = QMF_GRAYED; - s_keys_inv_next_action.x = 0; - s_keys_inv_next_action.y = y += 9; - s_keys_inv_next_action.ownerdraw = new mcallback() { + s_keys_inv_next_action.type= MTYPE_ACTION; + s_keys_inv_next_action.flags= QMF_GRAYED; + s_keys_inv_next_action.x= 0; + s_keys_inv_next_action.y= y += 9; + s_keys_inv_next_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_inv_next_action.localdata[0] = ++i; - s_keys_inv_next_action.name = bindnames[s_keys_inv_next_action.localdata[0]][1]; + s_keys_inv_next_action.localdata[0]= ++i; + s_keys_inv_next_action.name= bindnames[s_keys_inv_next_action.localdata[0]][1]; - s_keys_help_computer_action.type = MTYPE_ACTION; - s_keys_help_computer_action.flags = QMF_GRAYED; - s_keys_help_computer_action.x = 0; - s_keys_help_computer_action.y = y += 9; - s_keys_help_computer_action.ownerdraw = new mcallback() { + s_keys_help_computer_action.type= MTYPE_ACTION; + s_keys_help_computer_action.flags= QMF_GRAYED; + s_keys_help_computer_action.x= 0; + s_keys_help_computer_action.y= y += 9; + s_keys_help_computer_action.ownerdraw= new mcallback() { public void execute(Object o) { DrawKeyBindingFunc(o); } }; - s_keys_help_computer_action.localdata[0] = ++i; - s_keys_help_computer_action.name = bindnames[s_keys_help_computer_action.localdata[0]][1]; + s_keys_help_computer_action.localdata[0]= ++i; + s_keys_help_computer_action.name= bindnames[s_keys_help_computer_action.localdata[0]][1]; Menu_AddItem(s_keys_menu, s_keys_attack_action); Menu_AddItem(s_keys_menu, s_keys_change_weapon_action); @@ -1135,7 +1137,7 @@ public final class Menu extends Key { Menu_Center(s_keys_menu); } - static xcommand_t Keys_MenuDraw = new xcommand_t() { + static xcommand_t Keys_MenuDraw= new xcommand_t() { public void execute() { Keys_MenuDraw_f(); } @@ -1146,13 +1148,13 @@ public final class Menu extends Key { Menu_Draw(s_keys_menu); } - static keyfunc_t Keys_MenuKey = new keyfunc_t() { + static keyfunc_t Keys_MenuKey= new keyfunc_t() { public String execute(int key) { return Keys_MenuKey_f(key); } }; static String Keys_MenuKey_f(int key) { - menuaction_s item = (menuaction_s) Menu_ItemAtCursor(s_keys_menu); + menuaction_s item= (menuaction_s) Menu_ItemAtCursor(s_keys_menu); if (bind_grab) { if (key != K_ESCAPE && key != '`') { @@ -1160,12 +1162,12 @@ public final class Menu extends Key { String cmd; //Com_sprintf(cmd, sizeof(cmd), "bind \"%s\" \"%s\"\n", Key_KeynumToString(key), bindnames[item.localdata[0]][0]); - cmd = "bind \"" + Key.KeynumToString(key) + "\" \"" + bindnames[item.localdata[0]][0] + "\""; + cmd= "bind \"" + Key.KeynumToString(key) + "\" \"" + bindnames[item.localdata[0]][0] + "\""; Cbuf.InsertText(cmd); } Menu_SetStatusBar(s_keys_menu, "enter to change, backspace to clear"); - bind_grab = false; + bind_grab= false; return menu_out_sound; } @@ -1184,7 +1186,7 @@ public final class Menu extends Key { } } - static xcommand_t Menu_Keys = new xcommand_t() { + static xcommand_t Menu_Keys= new xcommand_t() { public void execute() { Menu_Keys_f(); } @@ -1211,23 +1213,23 @@ public final class Menu extends Key { */ static cvar_t win_noalttab; - static menuframework_s s_options_menu = new menuframework_s(); - static menuaction_s s_options_defaults_action = new menuaction_s(); - static menuaction_s s_options_customize_options_action = new menuaction_s(); - static menuslider_s s_options_sensitivity_slider = new menuslider_s(); - static menulist_s s_options_freelook_box = new menulist_s(); - static menulist_s s_options_noalttab_box = new menulist_s(); - static menulist_s s_options_alwaysrun_box = new menulist_s(); - static menulist_s s_options_invertmouse_box = new menulist_s(); - static menulist_s s_options_lookspring_box = new menulist_s(); - static menulist_s s_options_lookstrafe_box = new menulist_s(); - static menulist_s s_options_crosshair_box = new menulist_s(); - static menuslider_s s_options_sfxvolume_slider = new menuslider_s(); - static menulist_s s_options_joystick_box = new menulist_s(); - static menulist_s s_options_cdvolume_box = new menulist_s(); - static menulist_s s_options_quality_list = new menulist_s(); + static menuframework_s s_options_menu= new menuframework_s(); + static menuaction_s s_options_defaults_action= new menuaction_s(); + static menuaction_s s_options_customize_options_action= new menuaction_s(); + static menuslider_s s_options_sensitivity_slider= new menuslider_s(); + static menulist_s s_options_freelook_box= new menulist_s(); + static menulist_s s_options_noalttab_box= new menulist_s(); + static menulist_s s_options_alwaysrun_box= new menulist_s(); + static menulist_s s_options_invertmouse_box= new menulist_s(); + static menulist_s s_options_lookspring_box= new menulist_s(); + static menulist_s s_options_lookstrafe_box= new menulist_s(); + static menulist_s s_options_crosshair_box= new menulist_s(); + static menuslider_s s_options_sfxvolume_slider= new menuslider_s(); + static menulist_s s_options_joystick_box= new menulist_s(); + static menulist_s s_options_cdvolume_box= new menulist_s(); + static menulist_s s_options_quality_list= new menulist_s(); //static menulist_s s_options_compatibility_list = new menulist_s(); - static menuaction_s s_options_console_action = new menuaction_s(); + static menuaction_s s_options_console_action= new menuaction_s(); static void CrosshairFunc(Object unused) { Cvar.SetValue("crosshair", s_options_crosshair_box.curvalue); @@ -1266,38 +1268,39 @@ public final class Menu extends Key { } static void ControlsSetMenuItemValues() { - s_options_sfxvolume_slider.curvalue = Cvar.VariableValue("s_volume") * 10; - s_options_cdvolume_box.curvalue = 1 - ((int) Cvar.VariableValue("cd_nocd")); + s_options_sfxvolume_slider.curvalue= Cvar.VariableValue("s_volume") * 10; + s_options_cdvolume_box.curvalue= 1 - ((int) Cvar.VariableValue("cd_nocd")); //s_options_quality_list.curvalue = 1 - ((int) Cvar.VariableValue("s_loadas8bit")); if ("joal".equals(Cvar.VariableString("s_impl"))) { - s_options_quality_list.curvalue = 0; - } else { - s_options_quality_list.curvalue = 1; + s_options_quality_list.curvalue= 0; } - - s_options_sensitivity_slider.curvalue = (sensitivity.value) * 2; + else { + s_options_quality_list.curvalue= 1; + } + + s_options_sensitivity_slider.curvalue= (sensitivity.value) * 2; Cvar.SetValue("cl_run", ClampCvar(0, 1, cl_run.value)); - s_options_alwaysrun_box.curvalue = (int) cl_run.value; + s_options_alwaysrun_box.curvalue= (int) cl_run.value; - s_options_invertmouse_box.curvalue = m_pitch.value < 0 ? 1 : 0; + s_options_invertmouse_box.curvalue= m_pitch.value < 0 ? 1 : 0; Cvar.SetValue("lookspring", ClampCvar(0, 1, lookspring.value)); - s_options_lookspring_box.curvalue = (int) lookspring.value; + s_options_lookspring_box.curvalue= (int) lookspring.value; Cvar.SetValue("lookstrafe", ClampCvar(0, 1, lookstrafe.value)); - s_options_lookstrafe_box.curvalue = (int) lookstrafe.value; + s_options_lookstrafe_box.curvalue= (int) lookstrafe.value; Cvar.SetValue("freelook", ClampCvar(0, 1, freelook.value)); - s_options_freelook_box.curvalue = (int) freelook.value; + s_options_freelook_box.curvalue= (int) freelook.value; Cvar.SetValue("crosshair", ClampCvar(0, 3, Globals.crosshair.value)); - s_options_crosshair_box.curvalue = (int) Globals.crosshair.value; + s_options_crosshair_box.curvalue= (int) Globals.crosshair.value; Cvar.SetValue("in_joystick", ClampCvar(0, 1, in_joystick.value)); - s_options_joystick_box.curvalue = (int) in_joystick.value; + s_options_joystick_box.curvalue= (int) in_joystick.value; - s_options_noalttab_box.curvalue = (int) win_noalttab.value; + s_options_noalttab_box.curvalue= (int) win_noalttab.value; } static void ControlsResetDefaultsFunc(Object unused) { @@ -1341,21 +1344,21 @@ public final class Menu extends Key { Console.ClearNotify(); ForceMenuOff(); - cls.key_dest = key_console; + cls.key_dest= key_console; } static void UpdateSoundQualityFunc(Object unused) { - boolean driverNotChanged = false; + boolean driverNotChanged= false; if (s_options_quality_list.curvalue != 0) { -// Cvar.SetValue("s_khz", 22); -// Cvar.SetValue("s_loadas8bit", 0); - driverNotChanged = S.getDriverName().equals("dummy"); + // Cvar.SetValue("s_khz", 22); + // Cvar.SetValue("s_loadas8bit", 0); + driverNotChanged= S.getDriverName().equals("dummy"); Cvar.Set("s_impl", "dummy"); } else { -// Cvar.SetValue("s_khz", 11); -// Cvar.SetValue("s_loadas8bit", 1); - driverNotChanged = S.getDriverName().equals("joal"); + // Cvar.SetValue("s_khz", 11); + // Cvar.SetValue("s_loadas8bit", 1); + driverNotChanged= S.getDriverName().equals("joal"); Cvar.Set("s_impl", "joal"); } @@ -1363,8 +1366,9 @@ public final class Menu extends Key { if (driverNotChanged) { re.EndFrame(); - return; - } else { + return; + } + else { DrawTextBox(8, 120 - 48, 36, 3); Print(16 + 16, 120 - 48 + 8, "Restarting the sound system. This"); @@ -1373,159 +1377,158 @@ public final class Menu extends Key { // the text box won't show up unless we do a buffer swap re.EndFrame(); - + CL.Snd_Restart_f.execute(); } } - static String cd_music_items[] = { "disabled", "enabled", null }; - static String soundstate_items[] = { "on", "off", null }; + static String cd_music_items[]= { "disabled", "enabled", null }; + static String soundstate_items[]= { "on", "off", null }; - static String compatibility_items[] = { "max compatibility", "max performance", null }; + static String compatibility_items[]= { "max compatibility", "max performance", null }; - static String yesno_names[] = { "no", "yes", null }; + static String yesno_names[]= { "no", "yes", null }; - static String crosshair_names[] = { "none", "cross", "dot", "angle", null }; + static String crosshair_names[]= { "none", "cross", "dot", "angle", null }; static void Options_MenuInit() { - win_noalttab = Cvar.Get("win_noalttab", "0", CVAR_ARCHIVE); + win_noalttab= Cvar.Get("win_noalttab", "0", CVAR_ARCHIVE); /* ** configure controls menu and menu items */ - s_options_menu.x = viddef.width / 2; - s_options_menu.y = viddef.height / 2 - 58; - s_options_menu.nitems = 0; - - s_options_sfxvolume_slider.type = MTYPE_SLIDER; - s_options_sfxvolume_slider.x = 0; - s_options_sfxvolume_slider.y = 0; - s_options_sfxvolume_slider.name = "effects volume"; - s_options_sfxvolume_slider.callback = new mcallback() { + s_options_menu.x= viddef.width / 2; + s_options_menu.y= viddef.height / 2 - 58; + s_options_menu.nitems= 0; + + s_options_sfxvolume_slider.type= MTYPE_SLIDER; + s_options_sfxvolume_slider.x= 0; + s_options_sfxvolume_slider.y= 0; + s_options_sfxvolume_slider.name= "effects volume"; + s_options_sfxvolume_slider.callback= new mcallback() { public void execute(Object o) { UpdateVolumeFunc(o); } }; - s_options_sfxvolume_slider.minvalue = 0; - s_options_sfxvolume_slider.maxvalue = 10; - s_options_sfxvolume_slider.curvalue = Cvar.VariableValue("s_volume") * 10; - - s_options_cdvolume_box.type = MTYPE_SPINCONTROL; - s_options_cdvolume_box.x = 0; - s_options_cdvolume_box.y = 10; - s_options_cdvolume_box.name = "CD music"; - s_options_cdvolume_box.callback = new mcallback() { + s_options_sfxvolume_slider.minvalue= 0; + s_options_sfxvolume_slider.maxvalue= 10; + s_options_sfxvolume_slider.curvalue= Cvar.VariableValue("s_volume") * 10; + + s_options_cdvolume_box.type= MTYPE_SPINCONTROL; + s_options_cdvolume_box.x= 0; + s_options_cdvolume_box.y= 10; + s_options_cdvolume_box.name= "CD music"; + s_options_cdvolume_box.callback= new mcallback() { public void execute(Object o) { UpdateCDVolumeFunc(o); } }; - s_options_cdvolume_box.itemnames = cd_music_items; - s_options_cdvolume_box.curvalue = 1 - (int) Cvar.VariableValue("cd_nocd"); + s_options_cdvolume_box.itemnames= cd_music_items; + s_options_cdvolume_box.curvalue= 1 - (int) Cvar.VariableValue("cd_nocd"); - s_options_quality_list.type = MTYPE_SPINCONTROL; - s_options_quality_list.x = 0; - s_options_quality_list.y = 20; + s_options_quality_list.type= MTYPE_SPINCONTROL; + s_options_quality_list.x= 0; + s_options_quality_list.y= 20; ; - s_options_quality_list.name = "sound"; - s_options_quality_list.callback = new mcallback() { + s_options_quality_list.name= "sound"; + s_options_quality_list.callback= new mcallback() { public void execute(Object o) { UpdateSoundQualityFunc(o); } }; - s_options_quality_list.itemnames = soundstate_items; + s_options_quality_list.itemnames= soundstate_items; //s_options_quality_list.curvalue = 1 - (int) Cvar.VariableValue("s_loadas8bit"); - -// s_options_compatibility_list.type = MTYPE_SPINCONTROL; -// s_options_compatibility_list.x = 0; -// s_options_compatibility_list.y = 30; -// s_options_compatibility_list.name = "sound compatibility"; -// s_options_compatibility_list.callback = new mcallback() { -// public void execute(Object o) { -// UpdateSoundQualityFunc(o); -// } -// }; -// s_options_compatibility_list.itemnames = compatibility_items; -// s_options_compatibility_list.curvalue = (int) Cvar.VariableValue("s_primary"); - - s_options_sensitivity_slider.type = MTYPE_SLIDER; - s_options_sensitivity_slider.x = 0; - s_options_sensitivity_slider.y = 50; - s_options_sensitivity_slider.name = "mouse speed"; - s_options_sensitivity_slider.callback = new mcallback() { + // s_options_compatibility_list.type = MTYPE_SPINCONTROL; + // s_options_compatibility_list.x = 0; + // s_options_compatibility_list.y = 30; + // s_options_compatibility_list.name = "sound compatibility"; + // s_options_compatibility_list.callback = new mcallback() { + // public void execute(Object o) { + // UpdateSoundQualityFunc(o); + // } + // }; + // s_options_compatibility_list.itemnames = compatibility_items; + // s_options_compatibility_list.curvalue = (int) Cvar.VariableValue("s_primary"); + + s_options_sensitivity_slider.type= MTYPE_SLIDER; + s_options_sensitivity_slider.x= 0; + s_options_sensitivity_slider.y= 50; + s_options_sensitivity_slider.name= "mouse speed"; + s_options_sensitivity_slider.callback= new mcallback() { public void execute(Object o) { MouseSpeedFunc(o); } }; - s_options_sensitivity_slider.minvalue = 2; - s_options_sensitivity_slider.maxvalue = 22; - - s_options_alwaysrun_box.type = MTYPE_SPINCONTROL; - s_options_alwaysrun_box.x = 0; - s_options_alwaysrun_box.y = 60; - s_options_alwaysrun_box.name = "always run"; - s_options_alwaysrun_box.callback = new mcallback() { + s_options_sensitivity_slider.minvalue= 2; + s_options_sensitivity_slider.maxvalue= 22; + + s_options_alwaysrun_box.type= MTYPE_SPINCONTROL; + s_options_alwaysrun_box.x= 0; + s_options_alwaysrun_box.y= 60; + s_options_alwaysrun_box.name= "always run"; + s_options_alwaysrun_box.callback= new mcallback() { public void execute(Object o) { AlwaysRunFunc(o); } }; - s_options_alwaysrun_box.itemnames = yesno_names; + s_options_alwaysrun_box.itemnames= yesno_names; - s_options_invertmouse_box.type = MTYPE_SPINCONTROL; - s_options_invertmouse_box.x = 0; - s_options_invertmouse_box.y = 70; - s_options_invertmouse_box.name = "invert mouse"; - s_options_invertmouse_box.callback = new mcallback() { + s_options_invertmouse_box.type= MTYPE_SPINCONTROL; + s_options_invertmouse_box.x= 0; + s_options_invertmouse_box.y= 70; + s_options_invertmouse_box.name= "invert mouse"; + s_options_invertmouse_box.callback= new mcallback() { public void execute(Object o) { InvertMouseFunc(o); } }; - s_options_invertmouse_box.itemnames = yesno_names; + s_options_invertmouse_box.itemnames= yesno_names; - s_options_lookspring_box.type = MTYPE_SPINCONTROL; - s_options_lookspring_box.x = 0; - s_options_lookspring_box.y = 80; - s_options_lookspring_box.name = "lookspring"; - s_options_lookspring_box.callback = new mcallback() { + s_options_lookspring_box.type= MTYPE_SPINCONTROL; + s_options_lookspring_box.x= 0; + s_options_lookspring_box.y= 80; + s_options_lookspring_box.name= "lookspring"; + s_options_lookspring_box.callback= new mcallback() { public void execute(Object o) { LookspringFunc(o); } }; - s_options_lookspring_box.itemnames = yesno_names; + s_options_lookspring_box.itemnames= yesno_names; - s_options_lookstrafe_box.type = MTYPE_SPINCONTROL; - s_options_lookstrafe_box.x = 0; - s_options_lookstrafe_box.y = 90; - s_options_lookstrafe_box.name = "lookstrafe"; - s_options_lookstrafe_box.callback = new mcallback() { + s_options_lookstrafe_box.type= MTYPE_SPINCONTROL; + s_options_lookstrafe_box.x= 0; + s_options_lookstrafe_box.y= 90; + s_options_lookstrafe_box.name= "lookstrafe"; + s_options_lookstrafe_box.callback= new mcallback() { public void execute(Object o) { LookstrafeFunc(o); } }; - s_options_lookstrafe_box.itemnames = yesno_names; + s_options_lookstrafe_box.itemnames= yesno_names; - s_options_freelook_box.type = MTYPE_SPINCONTROL; - s_options_freelook_box.x = 0; - s_options_freelook_box.y = 100; - s_options_freelook_box.name = "free look"; - s_options_freelook_box.callback = new mcallback() { + s_options_freelook_box.type= MTYPE_SPINCONTROL; + s_options_freelook_box.x= 0; + s_options_freelook_box.y= 100; + s_options_freelook_box.name= "free look"; + s_options_freelook_box.callback= new mcallback() { public void execute(Object o) { FreeLookFunc(o); } }; - s_options_freelook_box.itemnames = yesno_names; + s_options_freelook_box.itemnames= yesno_names; - s_options_crosshair_box.type = MTYPE_SPINCONTROL; - s_options_crosshair_box.x = 0; - s_options_crosshair_box.y = 110; - s_options_crosshair_box.name = "crosshair"; - s_options_crosshair_box.callback = new mcallback() { + s_options_crosshair_box.type= MTYPE_SPINCONTROL; + s_options_crosshair_box.x= 0; + s_options_crosshair_box.y= 110; + s_options_crosshair_box.name= "crosshair"; + s_options_crosshair_box.callback= new mcallback() { public void execute(Object o) { CrosshairFunc(o); } }; - s_options_crosshair_box.itemnames = crosshair_names; + s_options_crosshair_box.itemnames= crosshair_names; /* s_options_noalttab_box.type = MTYPE_SPINCONTROL; s_options_noalttab_box.x = 0; @@ -1534,42 +1537,42 @@ public final class Menu extends Key { s_options_noalttab_box.callback = NoAltTabFunc; s_options_noalttab_box.itemnames = yesno_names; */ - s_options_joystick_box.type = MTYPE_SPINCONTROL; - s_options_joystick_box.x = 0; - s_options_joystick_box.y = 120; - s_options_joystick_box.name = "use joystick"; - s_options_joystick_box.callback = new mcallback() { + s_options_joystick_box.type= MTYPE_SPINCONTROL; + s_options_joystick_box.x= 0; + s_options_joystick_box.y= 120; + s_options_joystick_box.name= "use joystick"; + s_options_joystick_box.callback= new mcallback() { public void execute(Object o) { JoystickFunc(o); } }; - s_options_joystick_box.itemnames = yesno_names; + s_options_joystick_box.itemnames= yesno_names; - s_options_customize_options_action.type = MTYPE_ACTION; - s_options_customize_options_action.x = 0; - s_options_customize_options_action.y = 140; - s_options_customize_options_action.name = "customize controls"; - s_options_customize_options_action.callback = new mcallback() { + s_options_customize_options_action.type= MTYPE_ACTION; + s_options_customize_options_action.x= 0; + s_options_customize_options_action.y= 140; + s_options_customize_options_action.name= "customize controls"; + s_options_customize_options_action.callback= new mcallback() { public void execute(Object o) { CustomizeControlsFunc(o); } }; - s_options_defaults_action.type = MTYPE_ACTION; - s_options_defaults_action.x = 0; - s_options_defaults_action.y = 150; - s_options_defaults_action.name = "reset defaults"; - s_options_defaults_action.callback = new mcallback() { + s_options_defaults_action.type= MTYPE_ACTION; + s_options_defaults_action.x= 0; + s_options_defaults_action.y= 150; + s_options_defaults_action.name= "reset defaults"; + s_options_defaults_action.callback= new mcallback() { public void execute(Object o) { ControlsResetDefaultsFunc(o); } }; - s_options_console_action.type = MTYPE_ACTION; - s_options_console_action.x = 0; - s_options_console_action.y = 160; - s_options_console_action.name = "go to console"; - s_options_console_action.callback = new mcallback() { + s_options_console_action.type= MTYPE_ACTION; + s_options_console_action.x= 0; + s_options_console_action.y= 160; + s_options_console_action.name= "go to console"; + s_options_console_action.callback= new mcallback() { public void execute(Object o) { ConsoleFunc(o); } @@ -1581,7 +1584,7 @@ public final class Menu extends Key { Menu_AddItem(s_options_menu, s_options_cdvolume_box); Menu_AddItem(s_options_menu, s_options_quality_list); -// Menu_AddItem(s_options_menu, s_options_compatibility_list); + // Menu_AddItem(s_options_menu, s_options_compatibility_list); Menu_AddItem(s_options_menu, s_options_sensitivity_slider); Menu_AddItem(s_options_menu, s_options_alwaysrun_box); Menu_AddItem(s_options_menu, s_options_invertmouse_box); @@ -1589,7 +1592,7 @@ public final class Menu extends Key { Menu_AddItem(s_options_menu, s_options_lookstrafe_box); Menu_AddItem(s_options_menu, s_options_freelook_box); Menu_AddItem(s_options_menu, s_options_crosshair_box); -// Menu_AddItem(s_options_menu, s_options_joystick_box); + // Menu_AddItem(s_options_menu, s_options_joystick_box); Menu_AddItem(s_options_menu, s_options_customize_options_action); Menu_AddItem(s_options_menu, s_options_defaults_action); Menu_AddItem(s_options_menu, s_options_console_action); @@ -1605,7 +1608,7 @@ public final class Menu extends Key { return Default_MenuKey(s_options_menu, key); } - static xcommand_t Menu_Options = new xcommand_t() { + static xcommand_t Menu_Options= new xcommand_t() { public void execute() { Menu_Options_f(); } @@ -1632,7 +1635,7 @@ public final class Menu extends Key { ======================================================================= */ - static xcommand_t Menu_Video = new xcommand_t() { + static xcommand_t Menu_Video= new xcommand_t() { public void execute() { Menu_Video_f(); } @@ -1660,9 +1663,9 @@ public final class Menu extends Key { */ static int credits_start_time; - static String creditsIndex[] = new String[256]; + static String creditsIndex[]= new String[256]; static String creditsBuffer; - static String idcredits[] = + static String idcredits[]= { "+QUAKE II BY ID SOFTWARE", "", @@ -1675,7 +1678,7 @@ public final class Menu extends Key { "CWEI", "HOZ", "RST", - "", + "", "+ART", "Adrian Carmack", "Kevin Cloud", @@ -1756,8 +1759,8 @@ public final class Menu extends Key { "other trademarks and trade names are", "properties of their respective owners.", null }; - static String credits[] = idcredits; - static String xatcredits[] = + static String credits[]= idcredits; + static String xatcredits[]= { "+QUAKE II MISSION PACK: THE RECKONING", "+BY", @@ -1897,7 +1900,7 @@ public final class Menu extends Key { "respective owners.", null }; - static String roguecredits[] = + static String roguecredits[]= { "+QUAKE II MISSION PACK 2: GROUND ZERO", "+BY", @@ -2016,28 +2019,28 @@ public final class Menu extends Key { /* ** draw the credits */ - for (i = 0, y = (int) (viddef.height - ((cls.realtime - credits_start_time) / 40.0F)); + for (i= 0, y= (int) (viddef.height - ((cls.realtime - credits_start_time) / 40.0F)); credits[i] != null && y < viddef.height; y += 10, i++) { - int j, stringoffset = 0; - boolean bold = false; + int j, stringoffset= 0; + boolean bold= false; if (y <= -8) continue; if (credits[i].length() > 0 && credits[i].charAt(0) == '+') { - bold = true; - stringoffset = 1; + bold= true; + stringoffset= 1; } else { - bold = false; - stringoffset = 0; + bold= false; + stringoffset= 0; } - for (j = 0; j + stringoffset < credits[i].length(); j++) { + for (j= 0; j + stringoffset < credits[i].length(); j++) { int x; - x = (viddef.width - credits[i].length() * 8 - stringoffset * 8) / 2 + (j + stringoffset) * 8; + x= (viddef.width - credits[i].length() * 8 - stringoffset * 8) / 2 + (j + stringoffset) * 8; if (bold) re.DrawChar(x, y, credits[i].charAt(j + stringoffset) + 128); @@ -2047,7 +2050,7 @@ public final class Menu extends Key { } if (y < 0) - credits_start_time = cls.realtime; + credits_start_time= cls.realtime; } public static String Credits_Key(int key) { @@ -2064,42 +2067,42 @@ public final class Menu extends Key { } - static xcommand_t Menu_Credits = new xcommand_t() { + static xcommand_t Menu_Credits= new xcommand_t() { public void execute() { Menu_Credits_f(); } }; static void Menu_Credits_f() { int n; - int isdeveloper = 0; + int isdeveloper= 0; - byte b[] = FS.LoadFile("credits"); + byte b[]= FS.LoadFile("credits"); if (b != null) { - creditsBuffer = new String(b); - String line[] = Lib.linesplit(creditsBuffer); + creditsBuffer= new String(b); + String line[]= Lib.linesplit(creditsBuffer); - for (n = 0; n < line.length; n++) { - creditsIndex[n] = line[n]; + for (n= 0; n < line.length; n++) { + creditsIndex[n]= line[n]; } - creditsIndex[n] = null; - credits = creditsIndex; + creditsIndex[n]= null; + credits= creditsIndex; } else { - isdeveloper = FS.Developer_searchpath(1); + isdeveloper= FS.Developer_searchpath(1); if (isdeveloper == 1) // xatrix - credits = xatcredits; + credits= xatcredits; else if (isdeveloper == 2) // ROGUE - credits = roguecredits; + credits= roguecredits; else { - credits = idcredits; + credits= idcredits; } } - credits_start_time = cls.realtime; + credits_start_time= cls.realtime; PushMenu(new xcommand_t() { public void execute() { Credits_MenuDraw(); @@ -2121,18 +2124,18 @@ public final class Menu extends Key { static int m_game_cursor; - static menuframework_s s_game_menu = new menuframework_s(); - static menuaction_s s_easy_game_action = new menuaction_s(); - static menuaction_s s_medium_game_action = new menuaction_s(); - static menuaction_s s_hard_game_action = new menuaction_s(); - static menuaction_s s_load_game_action = new menuaction_s(); - static menuaction_s s_save_game_action = new menuaction_s(); - static menuaction_s s_credits_action = new menuaction_s(); - static menuseparator_s s_blankline = new menuseparator_s(); + static menuframework_s s_game_menu= new menuframework_s(); + static menuaction_s s_easy_game_action= new menuaction_s(); + static menuaction_s s_medium_game_action= new menuaction_s(); + static menuaction_s s_hard_game_action= new menuaction_s(); + static menuaction_s s_load_game_action= new menuaction_s(); + static menuaction_s s_save_game_action= new menuaction_s(); + static menuaction_s s_credits_action= new menuaction_s(); + static menuseparator_s s_blankline= new menuseparator_s(); static void StartGame() { // disable updates and start the cinematic going - cl.servercount = -1; + cl.servercount= -1; ForceMenuOff(); Cvar.SetValue("deathmatch", 0); Cvar.SetValue("coop", 0); @@ -2140,7 +2143,7 @@ public final class Menu extends Key { Cvar.SetValue("gamerules", 0); //PGM Cbuf.AddText("loading ; killserver ; wait ; newgame\n"); - cls.key_dest = key_game; + cls.key_dest= key_game; } static void EasyGameFunc(Object data) { @@ -2170,75 +2173,75 @@ public final class Menu extends Key { Menu_Credits_f(); } - static String difficulty_names[] = { "easy", "medium", "fuckin shitty hard", null }; + static String difficulty_names[]= { "easy", "medium", "fuckin shitty hard", null }; static void Game_MenuInit() { - s_game_menu.x = (int) (viddef.width * 0.50); - s_game_menu.nitems = 0; + s_game_menu.x= (int) (viddef.width * 0.50); + s_game_menu.nitems= 0; - s_easy_game_action.type = MTYPE_ACTION; - s_easy_game_action.flags = QMF_LEFT_JUSTIFY; - s_easy_game_action.x = 0; - s_easy_game_action.y = 0; - s_easy_game_action.name = "easy"; - s_easy_game_action.callback = new mcallback() { + s_easy_game_action.type= MTYPE_ACTION; + s_easy_game_action.flags= QMF_LEFT_JUSTIFY; + s_easy_game_action.x= 0; + s_easy_game_action.y= 0; + s_easy_game_action.name= "easy"; + s_easy_game_action.callback= new mcallback() { public void execute(Object o) { EasyGameFunc(o); } }; - s_medium_game_action.type = MTYPE_ACTION; - s_medium_game_action.flags = QMF_LEFT_JUSTIFY; - s_medium_game_action.x = 0; - s_medium_game_action.y = 10; - s_medium_game_action.name = "medium"; - s_medium_game_action.callback = new mcallback() { + s_medium_game_action.type= MTYPE_ACTION; + s_medium_game_action.flags= QMF_LEFT_JUSTIFY; + s_medium_game_action.x= 0; + s_medium_game_action.y= 10; + s_medium_game_action.name= "medium"; + s_medium_game_action.callback= new mcallback() { public void execute(Object o) { MediumGameFunc(o); } }; - s_hard_game_action.type = MTYPE_ACTION; - s_hard_game_action.flags = QMF_LEFT_JUSTIFY; - s_hard_game_action.x = 0; - s_hard_game_action.y = 20; - s_hard_game_action.name = "hard"; - s_hard_game_action.callback = new mcallback() { + s_hard_game_action.type= MTYPE_ACTION; + s_hard_game_action.flags= QMF_LEFT_JUSTIFY; + s_hard_game_action.x= 0; + s_hard_game_action.y= 20; + s_hard_game_action.name= "hard"; + s_hard_game_action.callback= new mcallback() { public void execute(Object o) { HardGameFunc(o); } }; - s_blankline.type = MTYPE_SEPARATOR; + s_blankline.type= MTYPE_SEPARATOR; - s_load_game_action.type = MTYPE_ACTION; - s_load_game_action.flags = QMF_LEFT_JUSTIFY; - s_load_game_action.x = 0; - s_load_game_action.y = 40; - s_load_game_action.name = "load game"; - s_load_game_action.callback = new mcallback() { + s_load_game_action.type= MTYPE_ACTION; + s_load_game_action.flags= QMF_LEFT_JUSTIFY; + s_load_game_action.x= 0; + s_load_game_action.y= 40; + s_load_game_action.name= "load game"; + s_load_game_action.callback= new mcallback() { public void execute(Object o) { LoadGameFunc(o); } }; - s_save_game_action.type = MTYPE_ACTION; - s_save_game_action.flags = QMF_LEFT_JUSTIFY; - s_save_game_action.x = 0; - s_save_game_action.y = 50; - s_save_game_action.name = "save game"; - s_save_game_action.callback = new mcallback() { + s_save_game_action.type= MTYPE_ACTION; + s_save_game_action.flags= QMF_LEFT_JUSTIFY; + s_save_game_action.x= 0; + s_save_game_action.y= 50; + s_save_game_action.name= "save game"; + s_save_game_action.callback= new mcallback() { public void execute(Object o) { SaveGameFunc(o); } }; - s_credits_action.type = MTYPE_ACTION; - s_credits_action.flags = QMF_LEFT_JUSTIFY; - s_credits_action.x = 0; - s_credits_action.y = 60; - s_credits_action.name = "credits"; - s_credits_action.callback = new mcallback() { + s_credits_action.type= MTYPE_ACTION; + s_credits_action.flags= QMF_LEFT_JUSTIFY; + s_credits_action.x= 0; + s_credits_action.y= 60; + s_credits_action.name= "credits"; + s_credits_action.callback= new mcallback() { public void execute(Object o) { CreditsFunc(o); } @@ -2266,7 +2269,7 @@ public final class Menu extends Key { return Default_MenuKey(s_game_menu, key); } - static xcommand_t Menu_Game = new xcommand_t() { + static xcommand_t Menu_Game= new xcommand_t() { public void execute() { Menu_Game_f(); } @@ -2283,7 +2286,7 @@ public final class Menu extends Key { return Game_MenuKey(key); } }); - m_game_cursor = 1; + m_game_cursor= 1; } /* @@ -2294,51 +2297,62 @@ public final class Menu extends Key { ============================================================================= */ - public final static int MAX_SAVEGAMES = 15; + public final static int MAX_SAVEGAMES= 15; - static menuframework_s s_savegame_menu = new menuframework_s(); - static menuframework_s s_loadgame_menu = new menuframework_s(); + static menuframework_s s_savegame_menu= new menuframework_s(); + static menuframework_s s_loadgame_menu= new menuframework_s(); - static menuaction_s s_loadgame_actions[] = new menuaction_s[MAX_SAVEGAMES]; + static menuaction_s s_loadgame_actions[]= new menuaction_s[MAX_SAVEGAMES]; static { - for (int n = 0; n < MAX_SAVEGAMES; n++) - s_loadgame_actions[n] = new menuaction_s(); + for (int n= 0; n < MAX_SAVEGAMES; n++) + s_loadgame_actions[n]= new menuaction_s(); } //String m_savestrings[] = new String [MAX_SAVEGAMES][32]; - static String m_savestrings[] = new String[MAX_SAVEGAMES]; + static String m_savestrings[]= new String[MAX_SAVEGAMES]; static { - for (int n = 0; n < MAX_SAVEGAMES; n++) - m_savestrings[n] = ""; + for (int n= 0; n < MAX_SAVEGAMES; n++) + m_savestrings[n]= ""; } - static boolean m_savevalid[] = new boolean[MAX_SAVEGAMES]; + static boolean m_savevalid[]= new boolean[MAX_SAVEGAMES]; + /** Search the save dir for saved games and their names. */ static void Create_Savestrings() { int i; - RandomAccessFile f; - //char name[MAX_OSPATH]; + QuakeFile f; String name; - for (i = 0; i < MAX_SAVEGAMES; i++) { - name = FS.Gamedir() + "/save/save" + i + "/server.ssv"; - f = fopen(name, "r"); - if (f == null) { - m_savestrings[i] = ""; - m_savevalid[i] = false; - } - else { - m_savestrings[i] = freadString(f, 32); - fclose(f); - m_savevalid[i] = true; + for (i= 0; i < MAX_SAVEGAMES; i++) { + + m_savestrings[i]= ""; + name= FS.Gamedir() + "/save/save" + i + "/server.ssv"; + + try { + f= new QuakeFile(name, "r"); + if (f == null) { + m_savestrings[i]= ""; + m_savevalid[i]= false; + } + else { + String str= f.readString(); + if (str != null) + m_savestrings[i]= str; + f.close(); + m_savevalid[i]= true; + } } + catch (Exception e) { + m_savestrings[i]= ""; + m_savevalid[i]= false; + }; } } static void LoadGameCallback(Object self) { - menuaction_s a = (menuaction_s) self; + menuaction_s a= (menuaction_s) self; if (m_savevalid[a.localdata[0]]) Cbuf.AddText("load save" + a.localdata[0] + "\n"); @@ -2348,28 +2362,28 @@ public final class Menu extends Key { static void LoadGame_MenuInit() { int i; - s_loadgame_menu.x = viddef.width / 2 - 120; - s_loadgame_menu.y = viddef.height / 2 - 58; - s_loadgame_menu.nitems = 0; + s_loadgame_menu.x= viddef.width / 2 - 120; + s_loadgame_menu.y= viddef.height / 2 - 58; + s_loadgame_menu.nitems= 0; Create_Savestrings(); - for (i = 0; i < MAX_SAVEGAMES; i++) { - s_loadgame_actions[i].name = m_savestrings[i]; - s_loadgame_actions[i].flags = QMF_LEFT_JUSTIFY; - s_loadgame_actions[i].localdata[0] = i; - s_loadgame_actions[i].callback = new mcallback() { + for (i= 0; i < MAX_SAVEGAMES; i++) { + s_loadgame_actions[i].name= m_savestrings[i]; + s_loadgame_actions[i].flags= QMF_LEFT_JUSTIFY; + s_loadgame_actions[i].localdata[0]= i; + s_loadgame_actions[i].callback= new mcallback() { public void execute(Object o) { LoadGameCallback(o); } }; - s_loadgame_actions[i].x = 0; - s_loadgame_actions[i].y = (i) * 10; + s_loadgame_actions[i].x= 0; + s_loadgame_actions[i].y= (i) * 10; if (i > 0) // separate from autosave s_loadgame_actions[i].y += 10; - s_loadgame_actions[i].type = MTYPE_ACTION; + s_loadgame_actions[i].type= MTYPE_ACTION; Menu_AddItem(s_loadgame_menu, s_loadgame_actions[i]); } @@ -2383,14 +2397,14 @@ public final class Menu extends Key { static String LoadGame_MenuKey(int key) { if (key == K_ESCAPE || key == K_ENTER) { - s_savegame_menu.cursor = s_loadgame_menu.cursor - 1; + s_savegame_menu.cursor= s_loadgame_menu.cursor - 1; if (s_savegame_menu.cursor < 0) - s_savegame_menu.cursor = 0; + s_savegame_menu.cursor= 0; } return Default_MenuKey(s_loadgame_menu, key); } - static xcommand_t Menu_LoadGame = new xcommand_t() { + static xcommand_t Menu_LoadGame= new xcommand_t() { public void execute() { Menu_LoadGame_f(); } @@ -2416,10 +2430,16 @@ public final class Menu extends Key { ============================================================================= */ //static menuframework_s s_savegame_menu; - static menuaction_s s_savegame_actions[] = new menuaction_s[MAX_SAVEGAMES]; + static menuaction_s s_savegame_actions[]= new menuaction_s[MAX_SAVEGAMES]; + + static { + for (int n= 0; n < MAX_SAVEGAMES; n++) + s_savegame_actions[n]= new menuaction_s(); + + } static void SaveGameCallback(Object self) { - menuaction_s a = (menuaction_s) self; + menuaction_s a= (menuaction_s) self; Cbuf.AddText("save save" + a.localdata[0] + "\n"); ForceMenuOff(); @@ -2434,27 +2454,27 @@ public final class Menu extends Key { static void SaveGame_MenuInit() { int i; - s_savegame_menu.x = viddef.width / 2 - 120; - s_savegame_menu.y = viddef.height / 2 - 58; - s_savegame_menu.nitems = 0; + s_savegame_menu.x= viddef.width / 2 - 120; + s_savegame_menu.y= viddef.height / 2 - 58; + s_savegame_menu.nitems= 0; Create_Savestrings(); // don't include the autosave slot - for (i = 0; i < MAX_SAVEGAMES - 1; i++) { - s_savegame_actions[i].name = m_savestrings[i + 1]; - s_savegame_actions[i].localdata[0] = i + 1; - s_savegame_actions[i].flags = QMF_LEFT_JUSTIFY; - s_savegame_actions[i].callback = new mcallback() { + for (i= 0; i < MAX_SAVEGAMES - 1; i++) { + s_savegame_actions[i].name= m_savestrings[i + 1]; + s_savegame_actions[i].localdata[0]= i + 1; + s_savegame_actions[i].flags= QMF_LEFT_JUSTIFY; + s_savegame_actions[i].callback= new mcallback() { public void execute(Object o) { SaveGameCallback(o); } }; - s_savegame_actions[i].x = 0; - s_savegame_actions[i].y = (i) * 10; + s_savegame_actions[i].x= 0; + s_savegame_actions[i].y= (i) * 10; - s_savegame_actions[i].type = MTYPE_ACTION; + s_savegame_actions[i].type= MTYPE_ACTION; Menu_AddItem(s_savegame_menu, s_savegame_actions[i]); } @@ -2462,18 +2482,19 @@ public final class Menu extends Key { static String SaveGame_MenuKey(int key) { if (key == K_ENTER || key == K_ESCAPE) { - s_loadgame_menu.cursor = s_savegame_menu.cursor - 1; + s_loadgame_menu.cursor= s_savegame_menu.cursor - 1; if (s_loadgame_menu.cursor < 0) - s_loadgame_menu.cursor = 0; + s_loadgame_menu.cursor= 0; } return Default_MenuKey(s_savegame_menu, key); } - static xcommand_t Menu_SaveGame = new xcommand_t() { + static xcommand_t Menu_SaveGame= new xcommand_t() { public void execute() { Menu_SaveGame_f(); } }; + static void Menu_SaveGame_f() { if (0 == Globals.server_state) return; // not playing a game @@ -2499,23 +2520,23 @@ public final class Menu extends Key { ============================================================================= */ - static menuframework_s s_joinserver_menu = new menuframework_s(); - static menuseparator_s s_joinserver_server_title = new menuseparator_s(); - static menuaction_s s_joinserver_search_action = new menuaction_s(); - static menuaction_s s_joinserver_address_book_action = new menuaction_s(); + static menuframework_s s_joinserver_menu= new menuframework_s(); + static menuseparator_s s_joinserver_server_title= new menuseparator_s(); + static menuaction_s s_joinserver_search_action= new menuaction_s(); + static menuaction_s s_joinserver_address_book_action= new menuaction_s(); - static netadr_t local_server_netadr[] = new netadr_t[MAX_LOCAL_SERVERS]; - static String local_server_names[] = new String[MAX_LOCAL_SERVERS]; //[80]; - static menuaction_s s_joinserver_server_actions[] = new menuaction_s[MAX_LOCAL_SERVERS]; + static netadr_t local_server_netadr[]= new netadr_t[MAX_LOCAL_SERVERS]; + static String local_server_names[]= new String[MAX_LOCAL_SERVERS]; //[80]; + static menuaction_s s_joinserver_server_actions[]= new menuaction_s[MAX_LOCAL_SERVERS]; // user readable information // network address static { - for (int n = 0; n < MAX_LOCAL_SERVERS; n++) { - local_server_netadr[n] = new netadr_t(); - local_server_names[n] = ""; - s_joinserver_server_actions[n] = new menuaction_s(); - s_joinserver_server_actions[n].n = n; + for (int n= 0; n < MAX_LOCAL_SERVERS; n++) { + local_server_netadr[n]= new netadr_t(); + local_server_names[n]= ""; + s_joinserver_server_actions[n]= new menuaction_s(); + s_joinserver_server_actions[n].n= n; } } @@ -2527,15 +2548,16 @@ public final class Menu extends Key { if (m_num_servers == MAX_LOCAL_SERVERS) return; - String x = info.trim(); + String x= info.trim(); // ignore if duplicated - for (i = 0; i < m_num_servers; i++) + + for (i= 0; i < m_num_servers; i++) if (x.equals(local_server_names[i])) return; - local_server_netadr[m_num_servers] = adr; - local_server_names[m_num_servers] = x; + local_server_netadr[m_num_servers]= adr; + local_server_names[m_num_servers]= x; m_num_servers++; } @@ -2543,7 +2565,7 @@ public final class Menu extends Key { String buffer; int index; - index = ((menucommon_s) self).n; + index= ((menucommon_s) self).n; if (Q_stricmp(local_server_names[index], NO_SERVER_STRING) == 0) return; @@ -2551,7 +2573,7 @@ public final class Menu extends Key { if (index >= m_num_servers) return; - buffer = "connect " + NET.AdrToString(local_server_netadr[index]) + "\n"; + buffer= "connect " + NET.AdrToString(local_server_netadr[index]) + "\n"; Cbuf.AddText(buffer); ForceMenuOff(); } @@ -2566,9 +2588,9 @@ public final class Menu extends Key { static void SearchLocalGames() { int i; - m_num_servers = 0; - for (i = 0; i < MAX_LOCAL_SERVERS; i++) - local_server_names[i] = NO_SERVER_STRING; + m_num_servers= 0; + for (i= 0; i < MAX_LOCAL_SERVERS; i++) + local_server_names[i]= NO_SERVER_STRING; DrawTextBox(8, 120 - 48, 36, 3); Print(16 + 16, 120 - 48 + 8, "Searching for local servers, this"); @@ -2589,57 +2611,57 @@ public final class Menu extends Key { static void JoinServer_MenuInit() { int i; - s_joinserver_menu.x = (int) (viddef.width * 0.50 - 120); - s_joinserver_menu.nitems = 0; + s_joinserver_menu.x= (int) (viddef.width * 0.50 - 120); + s_joinserver_menu.nitems= 0; - s_joinserver_address_book_action.type = MTYPE_ACTION; - s_joinserver_address_book_action.name = "address book"; - s_joinserver_address_book_action.flags = QMF_LEFT_JUSTIFY; - s_joinserver_address_book_action.x = 0; - s_joinserver_address_book_action.y = 0; - s_joinserver_address_book_action.callback = new mcallback() { + s_joinserver_address_book_action.type= MTYPE_ACTION; + s_joinserver_address_book_action.name= "address book"; + s_joinserver_address_book_action.flags= QMF_LEFT_JUSTIFY; + s_joinserver_address_book_action.x= 0; + s_joinserver_address_book_action.y= 0; + s_joinserver_address_book_action.callback= new mcallback() { public void execute(Object o) { AddressBookFunc(o); } }; - s_joinserver_search_action.type = MTYPE_ACTION; - s_joinserver_search_action.name = "refresh server list"; - s_joinserver_search_action.flags = QMF_LEFT_JUSTIFY; - s_joinserver_search_action.x = 0; - s_joinserver_search_action.y = 10; - s_joinserver_search_action.callback = new mcallback() { + s_joinserver_search_action.type= MTYPE_ACTION; + s_joinserver_search_action.name= "refresh server list"; + s_joinserver_search_action.flags= QMF_LEFT_JUSTIFY; + s_joinserver_search_action.x= 0; + s_joinserver_search_action.y= 10; + s_joinserver_search_action.callback= new mcallback() { public void execute(Object o) { SearchLocalGamesFunc(o); } }; - s_joinserver_search_action.statusbar = "search for servers"; - - s_joinserver_server_title.type = MTYPE_SEPARATOR; - s_joinserver_server_title.name = "connect to..."; - s_joinserver_server_title.x = 80; - s_joinserver_server_title.y = 30; - - for (i = 0; i < MAX_LOCAL_SERVERS; i++) { - s_joinserver_server_actions[i].type = MTYPE_ACTION; - local_server_names[i] = NO_SERVER_STRING; - s_joinserver_server_actions[i].name = local_server_names[i]; - s_joinserver_server_actions[i].flags = QMF_LEFT_JUSTIFY; - s_joinserver_server_actions[i].x = 0; - s_joinserver_server_actions[i].y = 40 + i * 10; - s_joinserver_server_actions[i].callback = new mcallback() { + s_joinserver_search_action.statusbar= "search for servers"; + + s_joinserver_server_title.type= MTYPE_SEPARATOR; + s_joinserver_server_title.name= "connect to..."; + s_joinserver_server_title.x= 80; + s_joinserver_server_title.y= 30; + + for (i= 0; i < MAX_LOCAL_SERVERS; i++) { + s_joinserver_server_actions[i].type= MTYPE_ACTION; + local_server_names[i]= NO_SERVER_STRING; + s_joinserver_server_actions[i].name= local_server_names[i]; + s_joinserver_server_actions[i].flags= QMF_LEFT_JUSTIFY; + s_joinserver_server_actions[i].x= 0; + s_joinserver_server_actions[i].y= 40 + i * 10; + s_joinserver_server_actions[i].callback= new mcallback() { public void execute(Object o) { JoinServerFunc(o); } }; - s_joinserver_server_actions[i].statusbar = "press ENTER to connect"; + s_joinserver_server_actions[i].statusbar= "press ENTER to connect"; } Menu_AddItem(s_joinserver_menu, s_joinserver_address_book_action); Menu_AddItem(s_joinserver_menu, s_joinserver_server_title); Menu_AddItem(s_joinserver_menu, s_joinserver_search_action); - for (i = 0; i < 8; i++) + for (i= 0; i < 8; i++) Menu_AddItem(s_joinserver_menu, s_joinserver_server_actions[i]); Menu_Center(s_joinserver_menu); @@ -2656,7 +2678,7 @@ public final class Menu extends Key { return Default_MenuKey(s_joinserver_menu, key); } - static xcommand_t Menu_JoinServer = new xcommand_t() { + static xcommand_t Menu_JoinServer= new xcommand_t() { public void execute() { Menu_JoinServer_f(); } @@ -2681,18 +2703,18 @@ public final class Menu extends Key { ============================================================================= */ - static menuframework_s s_startserver_menu = new menuframework_s(); + static menuframework_s s_startserver_menu= new menuframework_s(); static String mapnames[]; static int nummaps; - static menuaction_s s_startserver_start_action = new menuaction_s(); - static menuaction_s s_startserver_dmoptions_action = new menuaction_s(); - static menufield_s s_timelimit_field = new menufield_s(); - static menufield_s s_fraglimit_field = new menufield_s(); - static menufield_s s_maxclients_field = new menufield_s(); - static menufield_s s_hostname_field = new menufield_s(); - static menulist_s s_startmap_list = new menulist_s(); - static menulist_s s_rules_box = new menulist_s(); + static menuaction_s s_startserver_start_action= new menuaction_s(); + static menuaction_s s_startserver_dmoptions_action= new menuaction_s(); + static menufield_s s_timelimit_field= new menufield_s(); + static menufield_s s_fraglimit_field= new menufield_s(); + static menufield_s s_maxclients_field= new menufield_s(); + static menufield_s s_hostname_field= new menufield_s(); + static menulist_s s_startmap_list= new menulist_s(); + static menulist_s s_rules_box= new menulist_s(); static void DMOptionsFunc(Object self) { if (s_rules_box.curvalue == 1) @@ -2703,16 +2725,16 @@ public final class Menu extends Key { static void RulesChangeFunc(Object self) { // DM if (s_rules_box.curvalue == 0) { - s_maxclients_field.statusbar = null; - s_startserver_dmoptions_action.statusbar = null; + s_maxclients_field.statusbar= null; + s_startserver_dmoptions_action.statusbar= null; } else if (s_rules_box.curvalue == 1) // coop // PGM { - s_maxclients_field.statusbar = "4 maximum for cooperative"; + s_maxclients_field.statusbar= "4 maximum for cooperative"; if (atoi(s_maxclients_field.buffer.toString()) > 4) - s_maxclients_field.buffer = new StringBuffer("4"); - s_startserver_dmoptions_action.statusbar = "N/A for cooperative"; + s_maxclients_field.buffer= new StringBuffer("4"); + s_startserver_dmoptions_action.statusbar= "N/A for cooperative"; } // ===== // PGM @@ -2720,8 +2742,8 @@ public final class Menu extends Key { else if (FS.Developer_searchpath(2) == 2) { if (s_rules_box.curvalue == 2) // tag { - s_maxclients_field.statusbar = null; - s_startserver_dmoptions_action.statusbar = null; + s_maxclients_field.statusbar= null; + s_startserver_dmoptions_action.statusbar= null; } /* else if(s_rules_box.curvalue == 3) // deathball @@ -2744,17 +2766,17 @@ public final class Menu extends Key { String spot; //strcpy(startmap, strchr(mapnames[s_startmap_list.curvalue], '\n') + 1); - String x = mapnames[s_startmap_list.curvalue]; + String x= mapnames[s_startmap_list.curvalue]; - int pos = x.indexOf('\n'); + int pos= x.indexOf('\n'); if (pos == -1) - startmap = x; + startmap= x; else - startmap = x.substring(pos + 1, x.length()); + startmap= x.substring(pos + 1, x.length()); - maxclients = atoi(s_maxclients_field.buffer.toString()); - timelimit = atoi(s_timelimit_field.buffer.toString()); - fraglimit = atoi(s_fraglimit_field.buffer.toString()); + maxclients= atoi(s_maxclients_field.buffer.toString()); + timelimit= atoi(s_timelimit_field.buffer.toString()); + fraglimit= atoi(s_fraglimit_field.buffer.toString()); Cvar.SetValue("maxclients", ClampCvar(0, maxclients, maxclients)); Cvar.SetValue("timelimit", ClampCvar(0, timelimit, timelimit)); @@ -2778,25 +2800,25 @@ public final class Menu extends Key { } // PGM - spot = null; + spot= null; if (s_rules_box.curvalue == 1) // PGM { if (Q_stricmp(startmap, "bunk1") == 0) - spot = "start"; + spot= "start"; else if (Q_stricmp(startmap, "mintro") == 0) - spot = "start"; + spot= "start"; else if (Q_stricmp(startmap, "fact1") == 0) - spot = "start"; + spot= "start"; else if (Q_stricmp(startmap, "power1") == 0) - spot = "pstart"; + spot= "pstart"; else if (Q_stricmp(startmap, "biggun") == 0) - spot = "bstart"; + spot= "bstart"; else if (Q_stricmp(startmap, "hangar1") == 0) - spot = "unitstart"; + spot= "unitstart"; else if (Q_stricmp(startmap, "city1") == 0) - spot = "unitstart"; + spot= "unitstart"; else if (Q_stricmp(startmap, "boss1") == 0) - spot = "bosstart"; + spot= "bosstart"; } if (spot != null) { @@ -2811,8 +2833,8 @@ public final class Menu extends Key { ForceMenuOff(); } - static String dm_coop_names[] = { "deathmatch", "cooperative", null }; - static String dm_coop_names_rogue[] = { "deathmatch", "cooperative", "tag", + static String dm_coop_names[]= { "deathmatch", "cooperative", null }; + static String dm_coop_names_rogue[]= { "deathmatch", "cooperative", "tag", // "deathball", null }; @@ -2821,8 +2843,8 @@ public final class Menu extends Key { // ======= // PGM // ======= - - byte[] buffer = null; + + byte[] buffer= null; String mapsname; String s; int i; @@ -2831,18 +2853,18 @@ public final class Menu extends Key { /* ** load the list of map names */ - mapsname = FS.Gamedir() + "/maps.lst"; + mapsname= FS.Gamedir() + "/maps.lst"; - if ((fp = fopen(mapsname, "r")) == null) { - buffer = FS.LoadFile("maps.lst"); + if ((fp= fopen(mapsname, "r")) == null) { + buffer= FS.LoadFile("maps.lst"); if (buffer == null) //if ((length = FS_LoadFile("maps.lst", (Object *) & buffer)) == -1) Com.Error(ERR_DROP, "couldn't find maps.lst\n"); } else { try { - int len = (int) fp.length(); - buffer = new byte[len]; + int len= (int) fp.length(); + buffer= new byte[len]; fp.readFully(buffer); } catch (Exception e) { @@ -2850,31 +2872,31 @@ public final class Menu extends Key { } } - s = new String(buffer); - String lines[] = Lib.linesplit(s); + s= new String(buffer); + String lines[]= Lib.linesplit(s); - nummaps = lines.length; + nummaps= lines.length; if (nummaps == 0) Com.Error(ERR_DROP, "no maps in maps.lst\n"); - mapnames = new String[nummaps + 1]; + mapnames= new String[nummaps + 1]; - for (i = 0; i < nummaps; i++) { + for (i= 0; i < nummaps; i++) { String shortname, longname, scratch; - Com.ParseHelp ph = new Com.ParseHelp(lines[i]); + Com.ParseHelp ph= new Com.ParseHelp(lines[i]); - shortname = Com.Parse(ph).toUpperCase(); - longname = Com.Parse(ph); - scratch = longname + "\n" + shortname; - mapnames[i] = scratch; + shortname= Com.Parse(ph).toUpperCase(); + longname= Com.Parse(ph); + scratch= longname + "\n" + shortname; + mapnames[i]= scratch; } - mapnames[nummaps] = null; + mapnames[nummaps]= null; if (fp != null) { fclose(fp); - fp = null; + fp= null; } else { @@ -2884,56 +2906,56 @@ public final class Menu extends Key { /* ** initialize the menu stuff */ - s_startserver_menu.x = (int) (viddef.width * 0.50); - s_startserver_menu.nitems = 0; + s_startserver_menu.x= (int) (viddef.width * 0.50); + s_startserver_menu.nitems= 0; - s_startmap_list.type = MTYPE_SPINCONTROL; - s_startmap_list.x = 0; - s_startmap_list.y = 0; - s_startmap_list.name = "initial map"; - s_startmap_list.itemnames = mapnames; + s_startmap_list.type= MTYPE_SPINCONTROL; + s_startmap_list.x= 0; + s_startmap_list.y= 0; + s_startmap_list.name= "initial map"; + s_startmap_list.itemnames= mapnames; - s_rules_box.type = MTYPE_SPINCONTROL; - s_rules_box.x = 0; - s_rules_box.y = 20; - s_rules_box.name = "rules"; + s_rules_box.type= MTYPE_SPINCONTROL; + s_rules_box.x= 0; + s_rules_box.y= 20; + s_rules_box.name= "rules"; // PGM - rogue games only available with rogue DLL. if (FS.Developer_searchpath(2) == 2) - s_rules_box.itemnames = dm_coop_names_rogue; + s_rules_box.itemnames= dm_coop_names_rogue; else - s_rules_box.itemnames = dm_coop_names; + s_rules_box.itemnames= dm_coop_names; // PGM if (Cvar.VariableValue("coop") != 0) - s_rules_box.curvalue = 1; + s_rules_box.curvalue= 1; else - s_rules_box.curvalue = 0; - s_rules_box.callback = new mcallback() { + s_rules_box.curvalue= 0; + s_rules_box.callback= new mcallback() { public void execute(Object o) { RulesChangeFunc(o); } }; - s_timelimit_field.type = MTYPE_FIELD; - s_timelimit_field.name = "time limit"; - s_timelimit_field.flags = QMF_NUMBERSONLY; - s_timelimit_field.x = 0; - s_timelimit_field.y = 36; - s_timelimit_field.statusbar = "0 = no limit"; - s_timelimit_field.length = 3; - s_timelimit_field.visible_length = 3; - s_timelimit_field.buffer = new StringBuffer(Cvar.VariableString("timelimit")); - - s_fraglimit_field.type = MTYPE_FIELD; - s_fraglimit_field.name = "frag limit"; - s_fraglimit_field.flags = QMF_NUMBERSONLY; - s_fraglimit_field.x = 0; - s_fraglimit_field.y = 54; - s_fraglimit_field.statusbar = "0 = no limit"; - s_fraglimit_field.length = 3; - s_fraglimit_field.visible_length = 3; - s_fraglimit_field.buffer = new StringBuffer(Cvar.VariableString("fraglimit")); + s_timelimit_field.type= MTYPE_FIELD; + s_timelimit_field.name= "time limit"; + s_timelimit_field.flags= QMF_NUMBERSONLY; + s_timelimit_field.x= 0; + s_timelimit_field.y= 36; + s_timelimit_field.statusbar= "0 = no limit"; + s_timelimit_field.length= 3; + s_timelimit_field.visible_length= 3; + s_timelimit_field.buffer= new StringBuffer(Cvar.VariableString("timelimit")); + + s_fraglimit_field.type= MTYPE_FIELD; + s_fraglimit_field.name= "frag limit"; + s_fraglimit_field.flags= QMF_NUMBERSONLY; + s_fraglimit_field.x= 0; + s_fraglimit_field.y= 54; + s_fraglimit_field.statusbar= "0 = no limit"; + s_fraglimit_field.length= 3; + s_fraglimit_field.visible_length= 3; + s_fraglimit_field.buffer= new StringBuffer(Cvar.VariableString("fraglimit")); /* ** maxclients determines the maximum number of players that can join @@ -2941,48 +2963,48 @@ public final class Menu extends Key { ** option to 8 players, otherwise use whatever its current value is. ** Clamping will be done when the server is actually started. */ - s_maxclients_field.type = MTYPE_FIELD; - s_maxclients_field.name = "max players"; - s_maxclients_field.flags = QMF_NUMBERSONLY; - s_maxclients_field.x = 0; - s_maxclients_field.y = 72; - s_maxclients_field.statusbar = null; - s_maxclients_field.length = 3; - s_maxclients_field.visible_length = 3; + s_maxclients_field.type= MTYPE_FIELD; + s_maxclients_field.name= "max players"; + s_maxclients_field.flags= QMF_NUMBERSONLY; + s_maxclients_field.x= 0; + s_maxclients_field.y= 72; + s_maxclients_field.statusbar= null; + s_maxclients_field.length= 3; + s_maxclients_field.visible_length= 3; if (Cvar.VariableValue("maxclients") == 1) - s_maxclients_field.buffer = new StringBuffer("8"); + s_maxclients_field.buffer= new StringBuffer("8"); else - s_maxclients_field.buffer = new StringBuffer(Cvar.VariableString("maxclients")); - - s_hostname_field.type = MTYPE_FIELD; - s_hostname_field.name = "hostname"; - s_hostname_field.flags = 0; - s_hostname_field.x = 0; - s_hostname_field.y = 90; - s_hostname_field.statusbar = null; - s_hostname_field.length = 12; - s_hostname_field.visible_length = 12; - s_hostname_field.buffer = new StringBuffer(Cvar.VariableString("hostname")); - s_hostname_field.cursor = s_hostname_field.buffer.length(); - - s_startserver_dmoptions_action.type = MTYPE_ACTION; - s_startserver_dmoptions_action.name = " deathmatch flags"; - s_startserver_dmoptions_action.flags = QMF_LEFT_JUSTIFY; - s_startserver_dmoptions_action.x = 24; - s_startserver_dmoptions_action.y = 108; - s_startserver_dmoptions_action.statusbar = null; - s_startserver_dmoptions_action.callback = new mcallback() { + s_maxclients_field.buffer= new StringBuffer(Cvar.VariableString("maxclients")); + + s_hostname_field.type= MTYPE_FIELD; + s_hostname_field.name= "hostname"; + s_hostname_field.flags= 0; + s_hostname_field.x= 0; + s_hostname_field.y= 90; + s_hostname_field.statusbar= null; + s_hostname_field.length= 12; + s_hostname_field.visible_length= 12; + s_hostname_field.buffer= new StringBuffer(Cvar.VariableString("hostname")); + s_hostname_field.cursor= s_hostname_field.buffer.length(); + + s_startserver_dmoptions_action.type= MTYPE_ACTION; + s_startserver_dmoptions_action.name= " deathmatch flags"; + s_startserver_dmoptions_action.flags= QMF_LEFT_JUSTIFY; + s_startserver_dmoptions_action.x= 24; + s_startserver_dmoptions_action.y= 108; + s_startserver_dmoptions_action.statusbar= null; + s_startserver_dmoptions_action.callback= new mcallback() { public void execute(Object o) { DMOptionsFunc(o); } }; - s_startserver_start_action.type = MTYPE_ACTION; - s_startserver_start_action.name = " begin"; - s_startserver_start_action.flags = QMF_LEFT_JUSTIFY; - s_startserver_start_action.x = 24; - s_startserver_start_action.y = 128; - s_startserver_start_action.callback = new mcallback() { + s_startserver_start_action.type= MTYPE_ACTION; + s_startserver_start_action.name= " begin"; + s_startserver_start_action.flags= QMF_LEFT_JUSTIFY; + s_startserver_start_action.x= 24; + s_startserver_start_action.y= 128; + s_startserver_start_action.callback= new mcallback() { public void execute(Object o) { StartServerActionFunc(o); } @@ -3012,18 +3034,18 @@ public final class Menu extends Key { if (mapnames != null) { int i; - for (i = 0; i < nummaps; i++) - mapnames[i] = null; + for (i= 0; i < nummaps; i++) + mapnames[i]= null; } - mapnames = null; - nummaps = 0; + mapnames= null; + nummaps= 0; } return Default_MenuKey(s_startserver_menu, key); } - static xcommand_t Menu_StartServer = new xcommand_t() { + static xcommand_t Menu_StartServer= new xcommand_t() { public void execute() { Menu_StartServer_f(); } @@ -3050,42 +3072,42 @@ public final class Menu extends Key { */ static String dmoptions_statusbar; //[128]; - static menuframework_s s_dmoptions_menu = new menuframework_s(); - - static menulist_s s_friendlyfire_box = new menulist_s(); - static menulist_s s_falls_box = new menulist_s(); - static menulist_s s_weapons_stay_box = new menulist_s(); - static menulist_s s_instant_powerups_box = new menulist_s(); - static menulist_s s_powerups_box = new menulist_s(); - static menulist_s s_health_box = new menulist_s(); - static menulist_s s_spawn_farthest_box = new menulist_s(); - static menulist_s s_teamplay_box = new menulist_s(); - static menulist_s s_samelevel_box = new menulist_s(); - static menulist_s s_force_respawn_box = new menulist_s(); - static menulist_s s_armor_box = new menulist_s(); - static menulist_s s_allow_exit_box = new menulist_s(); - static menulist_s s_infinite_ammo_box = new menulist_s(); - static menulist_s s_fixed_fov_box = new menulist_s(); - static menulist_s s_quad_drop_box = new menulist_s(); + static menuframework_s s_dmoptions_menu= new menuframework_s(); + + static menulist_s s_friendlyfire_box= new menulist_s(); + static menulist_s s_falls_box= new menulist_s(); + static menulist_s s_weapons_stay_box= new menulist_s(); + static menulist_s s_instant_powerups_box= new menulist_s(); + static menulist_s s_powerups_box= new menulist_s(); + static menulist_s s_health_box= new menulist_s(); + static menulist_s s_spawn_farthest_box= new menulist_s(); + static menulist_s s_teamplay_box= new menulist_s(); + static menulist_s s_samelevel_box= new menulist_s(); + static menulist_s s_force_respawn_box= new menulist_s(); + static menulist_s s_armor_box= new menulist_s(); + static menulist_s s_allow_exit_box= new menulist_s(); + static menulist_s s_infinite_ammo_box= new menulist_s(); + static menulist_s s_fixed_fov_box= new menulist_s(); + static menulist_s s_quad_drop_box= new menulist_s(); // ROGUE - static menulist_s s_no_mines_box = new menulist_s(); - static menulist_s s_no_nukes_box = new menulist_s(); - static menulist_s s_stack_double_box = new menulist_s(); - static menulist_s s_no_spheres_box = new menulist_s(); + static menulist_s s_no_mines_box= new menulist_s(); + static menulist_s s_no_nukes_box= new menulist_s(); + static menulist_s s_stack_double_box= new menulist_s(); + static menulist_s s_no_spheres_box= new menulist_s(); // ROGUE static void setvalue(int flags) { Cvar.SetValue("dmflags", flags); - dmoptions_statusbar = "dmflags = " + flags; + dmoptions_statusbar= "dmflags = " + flags; } static void DMFlagCallback(Object self) { - menulist_s f = (menulist_s) self; + menulist_s f= (menulist_s) self; int flags; - int bit = 0; + int bit= 0; - flags = (int) Cvar.VariableValue("dmflags"); + flags= (int) Cvar.VariableValue("dmflags"); if (f == s_friendlyfire_box) { if (f.curvalue != 0) @@ -3104,13 +3126,13 @@ public final class Menu extends Key { return; } else if (f == s_weapons_stay_box) { - bit = DF_WEAPONS_STAY; + bit= DF_WEAPONS_STAY; } else if (f == s_instant_powerups_box) { - bit = DF_INSTANT_ITEMS; + bit= DF_INSTANT_ITEMS; } else if (f == s_allow_exit_box) { - bit = DF_ALLOW_EXIT; + bit= DF_ALLOW_EXIT; } else if (f == s_powerups_box) { if (f.curvalue != 0) @@ -3129,7 +3151,7 @@ public final class Menu extends Key { return; } else if (f == s_spawn_farthest_box) { - bit = DF_SPAWN_FARTHEST; + bit= DF_SPAWN_FARTHEST; } else if (f == s_teamplay_box) { if (f.curvalue == 1) { @@ -3148,10 +3170,10 @@ public final class Menu extends Key { return; } else if (f == s_samelevel_box) { - bit = DF_SAME_LEVEL; + bit= DF_SAME_LEVEL; } else if (f == s_force_respawn_box) { - bit = DF_FORCE_RESPAWN; + bit= DF_FORCE_RESPAWN; } else if (f == s_armor_box) { if (f.curvalue != 0) @@ -3162,29 +3184,29 @@ public final class Menu extends Key { return; } else if (f == s_infinite_ammo_box) { - bit = DF_INFINITE_AMMO; + bit= DF_INFINITE_AMMO; } else if (f == s_fixed_fov_box) { - bit = DF_FIXED_FOV; + bit= DF_FIXED_FOV; } else if (f == s_quad_drop_box) { - bit = DF_QUAD_DROP; + bit= DF_QUAD_DROP; } // ======= // ROGUE else if (FS.Developer_searchpath(2) == 2) { if (f == s_no_mines_box) { - bit = DF_NO_MINES; + bit= DF_NO_MINES; } else if (f == s_no_nukes_box) { - bit = DF_NO_NUKES; + bit= DF_NO_NUKES; } else if (f == s_stack_double_box) { - bit = DF_NO_STACK_DOUBLE; + bit= DF_NO_STACK_DOUBLE; } else if (f == s_no_spheres_box) { - bit = DF_NO_SPHERES; + bit= DF_NO_SPHERES; } } // ROGUE @@ -3199,250 +3221,250 @@ public final class Menu extends Key { Cvar.SetValue("dmflags", flags); - dmoptions_statusbar = "dmflags = " + flags; + dmoptions_statusbar= "dmflags = " + flags; } //static String yes_no_names[] = { "no", "yes", 0 }; - static String teamplay_names[] = { "disabled", "by skin", "by model", null }; + static String teamplay_names[]= { "disabled", "by skin", "by model", null }; static void DMOptions_MenuInit() { - int dmflags = (int) Cvar.VariableValue("dmflags"); - int y = 0; + int dmflags= (int) Cvar.VariableValue("dmflags"); + int y= 0; - s_dmoptions_menu.x = (int) (viddef.width * 0.50); - s_dmoptions_menu.nitems = 0; + s_dmoptions_menu.x= (int) (viddef.width * 0.50); + s_dmoptions_menu.nitems= 0; - s_falls_box.type = MTYPE_SPINCONTROL; - s_falls_box.x = 0; - s_falls_box.y = y; - s_falls_box.name = "falling damage"; - s_falls_box.callback = new mcallback() { + s_falls_box.type= MTYPE_SPINCONTROL; + s_falls_box.x= 0; + s_falls_box.y= y; + s_falls_box.name= "falling damage"; + s_falls_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_falls_box.itemnames = yes_no_names; - s_falls_box.curvalue = (dmflags & DF_NO_FALLING) == 0 ? 1 : 0; - - s_weapons_stay_box.type = MTYPE_SPINCONTROL; - s_weapons_stay_box.x = 0; - s_weapons_stay_box.y = y += 10; - s_weapons_stay_box.name = "weapons stay"; - s_weapons_stay_box.callback = new mcallback() { + s_falls_box.itemnames= yes_no_names; + s_falls_box.curvalue= (dmflags & DF_NO_FALLING) == 0 ? 1 : 0; + + s_weapons_stay_box.type= MTYPE_SPINCONTROL; + s_weapons_stay_box.x= 0; + s_weapons_stay_box.y= y += 10; + s_weapons_stay_box.name= "weapons stay"; + s_weapons_stay_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_weapons_stay_box.itemnames = yes_no_names; - s_weapons_stay_box.curvalue = (dmflags & DF_WEAPONS_STAY) != 0 ? 1 : 0; - - s_instant_powerups_box.type = MTYPE_SPINCONTROL; - s_instant_powerups_box.x = 0; - s_instant_powerups_box.y = y += 10; - s_instant_powerups_box.name = "instant powerups"; - s_instant_powerups_box.callback = new mcallback() { + s_weapons_stay_box.itemnames= yes_no_names; + s_weapons_stay_box.curvalue= (dmflags & DF_WEAPONS_STAY) != 0 ? 1 : 0; + + s_instant_powerups_box.type= MTYPE_SPINCONTROL; + s_instant_powerups_box.x= 0; + s_instant_powerups_box.y= y += 10; + s_instant_powerups_box.name= "instant powerups"; + s_instant_powerups_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_instant_powerups_box.itemnames = yes_no_names; - s_instant_powerups_box.curvalue = (dmflags & DF_INSTANT_ITEMS) != 0 ? 1 : 0; - - s_powerups_box.type = MTYPE_SPINCONTROL; - s_powerups_box.x = 0; - s_powerups_box.y = y += 10; - s_powerups_box.name = "allow powerups"; - s_powerups_box.callback = new mcallback() { + s_instant_powerups_box.itemnames= yes_no_names; + s_instant_powerups_box.curvalue= (dmflags & DF_INSTANT_ITEMS) != 0 ? 1 : 0; + + s_powerups_box.type= MTYPE_SPINCONTROL; + s_powerups_box.x= 0; + s_powerups_box.y= y += 10; + s_powerups_box.name= "allow powerups"; + s_powerups_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_powerups_box.itemnames = yes_no_names; - s_powerups_box.curvalue = (dmflags & DF_NO_ITEMS) == 0 ? 1 : 0; + s_powerups_box.itemnames= yes_no_names; + s_powerups_box.curvalue= (dmflags & DF_NO_ITEMS) == 0 ? 1 : 0; - s_health_box.type = MTYPE_SPINCONTROL; - s_health_box.x = 0; - s_health_box.y = y += 10; - s_health_box.callback = new mcallback() { + s_health_box.type= MTYPE_SPINCONTROL; + s_health_box.x= 0; + s_health_box.y= y += 10; + s_health_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_health_box.name = "allow health"; - s_health_box.itemnames = yes_no_names; - s_health_box.curvalue = (dmflags & DF_NO_HEALTH) == 0 ? 1 : 0; - - s_armor_box.type = MTYPE_SPINCONTROL; - s_armor_box.x = 0; - s_armor_box.y = y += 10; - s_armor_box.name = "allow armor"; - s_armor_box.callback = new mcallback() { + s_health_box.name= "allow health"; + s_health_box.itemnames= yes_no_names; + s_health_box.curvalue= (dmflags & DF_NO_HEALTH) == 0 ? 1 : 0; + + s_armor_box.type= MTYPE_SPINCONTROL; + s_armor_box.x= 0; + s_armor_box.y= y += 10; + s_armor_box.name= "allow armor"; + s_armor_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_armor_box.itemnames = yes_no_names; - s_armor_box.curvalue = (dmflags & DF_NO_ARMOR) == 0 ? 1 : 0; - - s_spawn_farthest_box.type = MTYPE_SPINCONTROL; - s_spawn_farthest_box.x = 0; - s_spawn_farthest_box.y = y += 10; - s_spawn_farthest_box.name = "spawn farthest"; - s_spawn_farthest_box.callback = new mcallback() { + s_armor_box.itemnames= yes_no_names; + s_armor_box.curvalue= (dmflags & DF_NO_ARMOR) == 0 ? 1 : 0; + + s_spawn_farthest_box.type= MTYPE_SPINCONTROL; + s_spawn_farthest_box.x= 0; + s_spawn_farthest_box.y= y += 10; + s_spawn_farthest_box.name= "spawn farthest"; + s_spawn_farthest_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_spawn_farthest_box.itemnames = yes_no_names; - s_spawn_farthest_box.curvalue = (dmflags & DF_SPAWN_FARTHEST) != 0 ? 1 : 0; - - s_samelevel_box.type = MTYPE_SPINCONTROL; - s_samelevel_box.x = 0; - s_samelevel_box.y = y += 10; - s_samelevel_box.name = "same map"; - s_samelevel_box.callback = new mcallback() { + s_spawn_farthest_box.itemnames= yes_no_names; + s_spawn_farthest_box.curvalue= (dmflags & DF_SPAWN_FARTHEST) != 0 ? 1 : 0; + + s_samelevel_box.type= MTYPE_SPINCONTROL; + s_samelevel_box.x= 0; + s_samelevel_box.y= y += 10; + s_samelevel_box.name= "same map"; + s_samelevel_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_samelevel_box.itemnames = yes_no_names; - s_samelevel_box.curvalue = (dmflags & DF_SAME_LEVEL) != 0 ? 1 : 0; - - s_force_respawn_box.type = MTYPE_SPINCONTROL; - s_force_respawn_box.x = 0; - s_force_respawn_box.y = y += 10; - s_force_respawn_box.name = "force respawn"; - s_force_respawn_box.callback = new mcallback() { + s_samelevel_box.itemnames= yes_no_names; + s_samelevel_box.curvalue= (dmflags & DF_SAME_LEVEL) != 0 ? 1 : 0; + + s_force_respawn_box.type= MTYPE_SPINCONTROL; + s_force_respawn_box.x= 0; + s_force_respawn_box.y= y += 10; + s_force_respawn_box.name= "force respawn"; + s_force_respawn_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_force_respawn_box.itemnames = yes_no_names; - s_force_respawn_box.curvalue = (dmflags & DF_FORCE_RESPAWN) != 0 ? 1 : 0; - - s_teamplay_box.type = MTYPE_SPINCONTROL; - s_teamplay_box.x = 0; - s_teamplay_box.y = y += 10; - s_teamplay_box.name = "teamplay"; - s_teamplay_box.callback = new mcallback() { + s_force_respawn_box.itemnames= yes_no_names; + s_force_respawn_box.curvalue= (dmflags & DF_FORCE_RESPAWN) != 0 ? 1 : 0; + + s_teamplay_box.type= MTYPE_SPINCONTROL; + s_teamplay_box.x= 0; + s_teamplay_box.y= y += 10; + s_teamplay_box.name= "teamplay"; + s_teamplay_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_teamplay_box.itemnames = teamplay_names; + s_teamplay_box.itemnames= teamplay_names; - s_allow_exit_box.type = MTYPE_SPINCONTROL; - s_allow_exit_box.x = 0; - s_allow_exit_box.y = y += 10; - s_allow_exit_box.name = "allow exit"; - s_allow_exit_box.callback = new mcallback() { + s_allow_exit_box.type= MTYPE_SPINCONTROL; + s_allow_exit_box.x= 0; + s_allow_exit_box.y= y += 10; + s_allow_exit_box.name= "allow exit"; + s_allow_exit_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_allow_exit_box.itemnames = yes_no_names; - s_allow_exit_box.curvalue = (dmflags & DF_ALLOW_EXIT) != 0 ? 1 : 0; - - s_infinite_ammo_box.type = MTYPE_SPINCONTROL; - s_infinite_ammo_box.x = 0; - s_infinite_ammo_box.y = y += 10; - s_infinite_ammo_box.name = "infinite ammo"; - s_infinite_ammo_box.callback = new mcallback() { + s_allow_exit_box.itemnames= yes_no_names; + s_allow_exit_box.curvalue= (dmflags & DF_ALLOW_EXIT) != 0 ? 1 : 0; + + s_infinite_ammo_box.type= MTYPE_SPINCONTROL; + s_infinite_ammo_box.x= 0; + s_infinite_ammo_box.y= y += 10; + s_infinite_ammo_box.name= "infinite ammo"; + s_infinite_ammo_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_infinite_ammo_box.itemnames = yes_no_names; - s_infinite_ammo_box.curvalue = (dmflags & DF_INFINITE_AMMO) != 0 ? 1 : 0; - - s_fixed_fov_box.type = MTYPE_SPINCONTROL; - s_fixed_fov_box.x = 0; - s_fixed_fov_box.y = y += 10; - s_fixed_fov_box.name = "fixed FOV"; - s_fixed_fov_box.callback = new mcallback() { + s_infinite_ammo_box.itemnames= yes_no_names; + s_infinite_ammo_box.curvalue= (dmflags & DF_INFINITE_AMMO) != 0 ? 1 : 0; + + s_fixed_fov_box.type= MTYPE_SPINCONTROL; + s_fixed_fov_box.x= 0; + s_fixed_fov_box.y= y += 10; + s_fixed_fov_box.name= "fixed FOV"; + s_fixed_fov_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_fixed_fov_box.itemnames = yes_no_names; - s_fixed_fov_box.curvalue = (dmflags & DF_FIXED_FOV) != 0 ? 1 : 0; - - s_quad_drop_box.type = MTYPE_SPINCONTROL; - s_quad_drop_box.x = 0; - s_quad_drop_box.y = y += 10; - s_quad_drop_box.name = "quad drop"; - s_quad_drop_box.callback = new mcallback() { + s_fixed_fov_box.itemnames= yes_no_names; + s_fixed_fov_box.curvalue= (dmflags & DF_FIXED_FOV) != 0 ? 1 : 0; + + s_quad_drop_box.type= MTYPE_SPINCONTROL; + s_quad_drop_box.x= 0; + s_quad_drop_box.y= y += 10; + s_quad_drop_box.name= "quad drop"; + s_quad_drop_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_quad_drop_box.itemnames = yes_no_names; - s_quad_drop_box.curvalue = (dmflags & DF_QUAD_DROP) != 0 ? 1 : 0; - - s_friendlyfire_box.type = MTYPE_SPINCONTROL; - s_friendlyfire_box.x = 0; - s_friendlyfire_box.y = y += 10; - s_friendlyfire_box.name = "friendly fire"; - s_friendlyfire_box.callback = new mcallback() { + s_quad_drop_box.itemnames= yes_no_names; + s_quad_drop_box.curvalue= (dmflags & DF_QUAD_DROP) != 0 ? 1 : 0; + + s_friendlyfire_box.type= MTYPE_SPINCONTROL; + s_friendlyfire_box.x= 0; + s_friendlyfire_box.y= y += 10; + s_friendlyfire_box.name= "friendly fire"; + s_friendlyfire_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_friendlyfire_box.itemnames = yes_no_names; - s_friendlyfire_box.curvalue = (dmflags & DF_NO_FRIENDLY_FIRE) == 0 ? 1 : 0; + s_friendlyfire_box.itemnames= yes_no_names; + s_friendlyfire_box.curvalue= (dmflags & DF_NO_FRIENDLY_FIRE) == 0 ? 1 : 0; // ============ // ROGUE if (FS.Developer_searchpath(2) == 2) { - s_no_mines_box.type = MTYPE_SPINCONTROL; - s_no_mines_box.x = 0; - s_no_mines_box.y = y += 10; - s_no_mines_box.name = "remove mines"; - s_no_mines_box.callback = new mcallback() { + s_no_mines_box.type= MTYPE_SPINCONTROL; + s_no_mines_box.x= 0; + s_no_mines_box.y= y += 10; + s_no_mines_box.name= "remove mines"; + s_no_mines_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_no_mines_box.itemnames = yes_no_names; - s_no_mines_box.curvalue = (dmflags & DF_NO_MINES) != 0 ? 1 : 0; - - s_no_nukes_box.type = MTYPE_SPINCONTROL; - s_no_nukes_box.x = 0; - s_no_nukes_box.y = y += 10; - s_no_nukes_box.name = "remove nukes"; - s_no_nukes_box.callback = new mcallback() { + s_no_mines_box.itemnames= yes_no_names; + s_no_mines_box.curvalue= (dmflags & DF_NO_MINES) != 0 ? 1 : 0; + + s_no_nukes_box.type= MTYPE_SPINCONTROL; + s_no_nukes_box.x= 0; + s_no_nukes_box.y= y += 10; + s_no_nukes_box.name= "remove nukes"; + s_no_nukes_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_no_nukes_box.itemnames = yes_no_names; - s_no_nukes_box.curvalue = (dmflags & DF_NO_NUKES) != 0 ? 1 : 0; - - s_stack_double_box.type = MTYPE_SPINCONTROL; - s_stack_double_box.x = 0; - s_stack_double_box.y = y += 10; - s_stack_double_box.name = "2x/4x stacking off"; - s_stack_double_box.callback = new mcallback() { + s_no_nukes_box.itemnames= yes_no_names; + s_no_nukes_box.curvalue= (dmflags & DF_NO_NUKES) != 0 ? 1 : 0; + + s_stack_double_box.type= MTYPE_SPINCONTROL; + s_stack_double_box.x= 0; + s_stack_double_box.y= y += 10; + s_stack_double_box.name= "2x/4x stacking off"; + s_stack_double_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_stack_double_box.itemnames = yes_no_names; - s_stack_double_box.curvalue = (dmflags & DF_NO_STACK_DOUBLE); - - s_no_spheres_box.type = MTYPE_SPINCONTROL; - s_no_spheres_box.x = 0; - s_no_spheres_box.y = y += 10; - s_no_spheres_box.name = "remove spheres"; - s_no_spheres_box.callback = new mcallback() { + s_stack_double_box.itemnames= yes_no_names; + s_stack_double_box.curvalue= (dmflags & DF_NO_STACK_DOUBLE); + + s_no_spheres_box.type= MTYPE_SPINCONTROL; + s_no_spheres_box.x= 0; + s_no_spheres_box.y= y += 10; + s_no_spheres_box.name= "remove spheres"; + s_no_spheres_box.callback= new mcallback() { public void execute(Object o) { DMFlagCallback(o); } }; - s_no_spheres_box.itemnames = yes_no_names; - s_no_spheres_box.curvalue = (dmflags & DF_NO_SPHERES) != 0 ? 1 : 0; + s_no_spheres_box.itemnames= yes_no_names; + s_no_spheres_box.curvalue= (dmflags & DF_NO_SPHERES) != 0 ? 1 : 0; } // ROGUE @@ -3490,7 +3512,7 @@ public final class Menu extends Key { return Default_MenuKey(s_dmoptions_menu, key); } - static xcommand_t Menu_DMOptions = new xcommand_t() { + static xcommand_t Menu_DMOptions= new xcommand_t() { public void execute() { Menu_DMOptions_f(); } @@ -3515,17 +3537,17 @@ public final class Menu extends Key { ============================================================================= */ - static menuframework_s s_downloadoptions_menu = new menuframework_s(); + static menuframework_s s_downloadoptions_menu= new menuframework_s(); - static menuseparator_s s_download_title = new menuseparator_s(); - static menulist_s s_allow_download_box = new menulist_s(); - static menulist_s s_allow_download_maps_box = new menulist_s(); - static menulist_s s_allow_download_models_box = new menulist_s(); - static menulist_s s_allow_download_players_box = new menulist_s(); - static menulist_s s_allow_download_sounds_box = new menulist_s(); + static menuseparator_s s_download_title= new menuseparator_s(); + static menulist_s s_allow_download_box= new menulist_s(); + static menulist_s s_allow_download_maps_box= new menulist_s(); + static menulist_s s_allow_download_models_box= new menulist_s(); + static menulist_s s_allow_download_players_box= new menulist_s(); + static menulist_s s_allow_download_sounds_box= new menulist_s(); static void DownloadCallback(Object self) { - menulist_s f = (menulist_s) self; + menulist_s f= (menulist_s) self; if (f == s_allow_download_box) { Cvar.SetValue("allow_download", f.curvalue); @@ -3548,78 +3570,78 @@ public final class Menu extends Key { } } - static String yes_no_names[] = { "no", "yes", null }; + static String yes_no_names[]= { "no", "yes", null }; static void DownloadOptions_MenuInit() { - int y = 0; + int y= 0; - s_downloadoptions_menu.x = (int) (viddef.width * 0.50); - s_downloadoptions_menu.nitems = 0; + s_downloadoptions_menu.x= (int) (viddef.width * 0.50); + s_downloadoptions_menu.nitems= 0; - s_download_title.type = MTYPE_SEPARATOR; - s_download_title.name = "Download Options"; - s_download_title.x = 48; - s_download_title.y = y; + s_download_title.type= MTYPE_SEPARATOR; + s_download_title.name= "Download Options"; + s_download_title.x= 48; + s_download_title.y= y; - s_allow_download_box.type = MTYPE_SPINCONTROL; - s_allow_download_box.x = 0; - s_allow_download_box.y = y += 20; - s_allow_download_box.name = "allow downloading"; - s_allow_download_box.callback = new mcallback() { + s_allow_download_box.type= MTYPE_SPINCONTROL; + s_allow_download_box.x= 0; + s_allow_download_box.y= y += 20; + s_allow_download_box.name= "allow downloading"; + s_allow_download_box.callback= new mcallback() { public void execute(Object o) { DownloadCallback(o); } }; - s_allow_download_box.itemnames = yes_no_names; - s_allow_download_box.curvalue = (Cvar.VariableValue("allow_download") != 0) ? 1 : 0; - - s_allow_download_maps_box.type = MTYPE_SPINCONTROL; - s_allow_download_maps_box.x = 0; - s_allow_download_maps_box.y = y += 20; - s_allow_download_maps_box.name = "maps"; - s_allow_download_maps_box.callback = new mcallback() { + s_allow_download_box.itemnames= yes_no_names; + s_allow_download_box.curvalue= (Cvar.VariableValue("allow_download") != 0) ? 1 : 0; + + s_allow_download_maps_box.type= MTYPE_SPINCONTROL; + s_allow_download_maps_box.x= 0; + s_allow_download_maps_box.y= y += 20; + s_allow_download_maps_box.name= "maps"; + s_allow_download_maps_box.callback= new mcallback() { public void execute(Object o) { DownloadCallback(o); } }; - s_allow_download_maps_box.itemnames = yes_no_names; - s_allow_download_maps_box.curvalue = (Cvar.VariableValue("allow_download_maps") != 0) ? 1 : 0; - - s_allow_download_players_box.type = MTYPE_SPINCONTROL; - s_allow_download_players_box.x = 0; - s_allow_download_players_box.y = y += 10; - s_allow_download_players_box.name = "player models/skins"; - s_allow_download_players_box.callback = new mcallback() { + s_allow_download_maps_box.itemnames= yes_no_names; + s_allow_download_maps_box.curvalue= (Cvar.VariableValue("allow_download_maps") != 0) ? 1 : 0; + + s_allow_download_players_box.type= MTYPE_SPINCONTROL; + s_allow_download_players_box.x= 0; + s_allow_download_players_box.y= y += 10; + s_allow_download_players_box.name= "player models/skins"; + s_allow_download_players_box.callback= new mcallback() { public void execute(Object o) { DownloadCallback(o); } }; - s_allow_download_players_box.itemnames = yes_no_names; - s_allow_download_players_box.curvalue = (Cvar.VariableValue("allow_download_players") != 0) ? 1 : 0; - - s_allow_download_models_box.type = MTYPE_SPINCONTROL; - s_allow_download_models_box.x = 0; - s_allow_download_models_box.y = y += 10; - s_allow_download_models_box.name = "models"; - s_allow_download_models_box.callback = new mcallback() { + s_allow_download_players_box.itemnames= yes_no_names; + s_allow_download_players_box.curvalue= (Cvar.VariableValue("allow_download_players") != 0) ? 1 : 0; + + s_allow_download_models_box.type= MTYPE_SPINCONTROL; + s_allow_download_models_box.x= 0; + s_allow_download_models_box.y= y += 10; + s_allow_download_models_box.name= "models"; + s_allow_download_models_box.callback= new mcallback() { public void execute(Object o) { DownloadCallback(o); } }; - s_allow_download_models_box.itemnames = yes_no_names; - s_allow_download_models_box.curvalue = (Cvar.VariableValue("allow_download_models") != 0) ? 1 : 0; - - s_allow_download_sounds_box.type = MTYPE_SPINCONTROL; - s_allow_download_sounds_box.x = 0; - s_allow_download_sounds_box.y = y += 10; - s_allow_download_sounds_box.name = "sounds"; - s_allow_download_sounds_box.callback = new mcallback() { + s_allow_download_models_box.itemnames= yes_no_names; + s_allow_download_models_box.curvalue= (Cvar.VariableValue("allow_download_models") != 0) ? 1 : 0; + + s_allow_download_sounds_box.type= MTYPE_SPINCONTROL; + s_allow_download_sounds_box.x= 0; + s_allow_download_sounds_box.y= y += 10; + s_allow_download_sounds_box.name= "sounds"; + s_allow_download_sounds_box.callback= new mcallback() { public void execute(Object o) { DownloadCallback(o); } }; - s_allow_download_sounds_box.itemnames = yes_no_names; - s_allow_download_sounds_box.curvalue = (Cvar.VariableValue("allow_download_sounds") != 0) ? 1 : 0; + s_allow_download_sounds_box.itemnames= yes_no_names; + s_allow_download_sounds_box.curvalue= (Cvar.VariableValue("allow_download_sounds") != 0) ? 1 : 0; Menu_AddItem(s_downloadoptions_menu, s_download_title); Menu_AddItem(s_downloadoptions_menu, s_allow_download_box); @@ -3632,7 +3654,7 @@ public final class Menu extends Key { // skip over title if (s_downloadoptions_menu.cursor == 0) - s_downloadoptions_menu.cursor = 1; + s_downloadoptions_menu.cursor= 1; } static void DownloadOptions_MenuDraw() { @@ -3643,7 +3665,7 @@ public final class Menu extends Key { return Default_MenuKey(s_downloadoptions_menu, key); } - static xcommand_t Menu_DownloadOptions = new xcommand_t() { + static xcommand_t Menu_DownloadOptions= new xcommand_t() { public void execute() { Menu_DownloadOptions_f(); } @@ -3668,47 +3690,47 @@ public final class Menu extends Key { ============================================================================= */ - static menuframework_s s_addressbook_menu = new menuframework_s(); - static menufield_s s_addressbook_fields[] = new menufield_s[NUM_ADDRESSBOOK_ENTRIES]; + static menuframework_s s_addressbook_menu= new menuframework_s(); + static menufield_s s_addressbook_fields[]= new menufield_s[NUM_ADDRESSBOOK_ENTRIES]; static { - for (int n = 0; n < NUM_ADDRESSBOOK_ENTRIES; n++) - s_addressbook_fields[n] = new menufield_s(); + for (int n= 0; n < NUM_ADDRESSBOOK_ENTRIES; n++) + s_addressbook_fields[n]= new menufield_s(); } static void AddressBook_MenuInit() { int i; - s_addressbook_menu.x = viddef.width / 2 - 142; - s_addressbook_menu.y = viddef.height / 2 - 58; - s_addressbook_menu.nitems = 0; + s_addressbook_menu.x= viddef.width / 2 - 142; + s_addressbook_menu.y= viddef.height / 2 - 58; + s_addressbook_menu.nitems= 0; - for (i = 0; i < NUM_ADDRESSBOOK_ENTRIES; i++) { + for (i= 0; i < NUM_ADDRESSBOOK_ENTRIES; i++) { cvar_t adr; //char buffer[20]; String buffer; //Com_sprintf(buffer, sizeof(buffer), "adr%d", i); - buffer = "adr" + i; + buffer= "adr" + i; - adr = Cvar.Get(buffer, "", CVAR_ARCHIVE); + adr= Cvar.Get(buffer, "", CVAR_ARCHIVE); - s_addressbook_fields[i].type = MTYPE_FIELD; - s_addressbook_fields[i].name = null; - s_addressbook_fields[i].callback = null; - s_addressbook_fields[i].x = 0; - s_addressbook_fields[i].y = i * 18 + 0; - s_addressbook_fields[i].localdata[0] = i; - s_addressbook_fields[i].cursor = 0; - s_addressbook_fields[i].length = 60; - s_addressbook_fields[i].visible_length = 30; + s_addressbook_fields[i].type= MTYPE_FIELD; + s_addressbook_fields[i].name= null; + s_addressbook_fields[i].callback= null; + s_addressbook_fields[i].x= 0; + s_addressbook_fields[i].y= i * 18 + 0; + s_addressbook_fields[i].localdata[0]= i; + s_addressbook_fields[i].cursor= 0; + s_addressbook_fields[i].length= 60; + s_addressbook_fields[i].visible_length= 30; - s_addressbook_fields[i].buffer = new StringBuffer(adr.string); + s_addressbook_fields[i].buffer= new StringBuffer(adr.string); Menu_AddItem(s_addressbook_menu, s_addressbook_fields[i]); } } - static keyfunc_t AddressBook_MenuKey = new keyfunc_t() { + static keyfunc_t AddressBook_MenuKey= new keyfunc_t() { public String execute(int key) { return AddressBook_MenuKey_f(key); } @@ -3720,8 +3742,8 @@ public final class Menu extends Key { //char buffer[20]; String buffer; - for (index = 0; index < NUM_ADDRESSBOOK_ENTRIES; index++) { - buffer = "adr" + index; + for (index= 0; index < NUM_ADDRESSBOOK_ENTRIES; index++) { + buffer= "adr" + index; //Com_sprintf(buffer, sizeof(buffer), "adr%d", index); Cvar.Set(buffer, s_addressbook_fields[index].buffer.toString()); } @@ -3729,7 +3751,7 @@ public final class Menu extends Key { return Default_MenuKey(s_addressbook_menu, key); } - static xcommand_t AddressBook_MenuDraw = new xcommand_t() { + static xcommand_t AddressBook_MenuDraw= new xcommand_t() { public void execute() { AddressBook_MenuDraw_f(); } @@ -3739,7 +3761,7 @@ public final class Menu extends Key { Menu_Draw(s_addressbook_menu); } - static xcommand_t Menu_AddressBook = new xcommand_t() { + static xcommand_t Menu_AddressBook= new xcommand_t() { public void execute() { Menu_AddressBook_f(); } @@ -3763,17 +3785,17 @@ public final class Menu extends Key { ============================================================================= */ - static menuframework_s s_player_config_menu = new menuframework_s(); - static menufield_s s_player_name_field = new menufield_s(); - static menulist_s s_player_model_box = new menulist_s(); - static menulist_s s_player_skin_box = new menulist_s(); - static menulist_s s_player_handedness_box = new menulist_s(); - static menulist_s s_player_rate_box = new menulist_s(); - static menuseparator_s s_player_skin_title = new menuseparator_s(); - static menuseparator_s s_player_model_title = new menuseparator_s(); - static menuseparator_s s_player_hand_title = new menuseparator_s(); - static menuseparator_s s_player_rate_title = new menuseparator_s(); - static menuaction_s s_player_download_action = new menuaction_s(); + static menuframework_s s_player_config_menu= new menuframework_s(); + static menufield_s s_player_name_field= new menufield_s(); + static menulist_s s_player_model_box= new menulist_s(); + static menulist_s s_player_skin_box= new menulist_s(); + static menulist_s s_player_handedness_box= new menulist_s(); + static menulist_s s_player_rate_box= new menulist_s(); + static menuseparator_s s_player_skin_title= new menuseparator_s(); + static menuseparator_s s_player_model_title= new menuseparator_s(); + static menuseparator_s s_player_hand_title= new menuseparator_s(); + static menuseparator_s s_player_rate_title= new menuseparator_s(); + static menuaction_s s_player_download_action= new menuaction_s(); static class playermodelinfo_s { int nskins; @@ -3784,12 +3806,12 @@ public final class Menu extends Key { String directory; }; - static playermodelinfo_s s_pmi[] = new playermodelinfo_s[MAX_PLAYERMODELS]; - static String s_pmnames[] = new String[MAX_PLAYERMODELS]; + static playermodelinfo_s s_pmi[]= new playermodelinfo_s[MAX_PLAYERMODELS]; + static String s_pmnames[]= new String[MAX_PLAYERMODELS]; static int s_numplayermodels; - static int rate_tbl[] = { 2500, 3200, 5000, 10000, 25000, 0 }; - static String rate_names[] = { "28.8 Modem", "33.6 Modem", "Single ISDN", "Dual ISDN/Cable", "T1/LAN", "User defined", null }; + static int rate_tbl[]= { 2500, 3200, 5000, 10000, 25000, 0 }; + static String rate_names[]= { "28.8 Modem", "33.6 Modem", "Single ISDN", "Dual ISDN/Cable", "T1/LAN", "User defined", null }; static void DownloadOptionsFunc(Object self) { Menu_DownloadOptions_f(); @@ -3805,8 +3827,8 @@ public final class Menu extends Key { } static void ModelCallback(Object unused) { - s_player_skin_box.itemnames = s_pmi[s_player_model_box.curvalue].skindisplaynames; - s_player_skin_box.curvalue = 0; + s_player_skin_box.itemnames= s_pmi[s_player_model_box.curvalue].skindisplaynames; + s_player_skin_box.curvalue= 0; } static boolean IconOfSkinExists(String skin, String pcxfiles[], int npcxfiles) { @@ -3815,15 +3837,15 @@ public final class Menu extends Key { String scratch; //strcpy(scratch, skin); - scratch = skin; - int pos = scratch.lastIndexOf('.'); + scratch= skin; + int pos= scratch.lastIndexOf('.'); if (pos != -1) - scratch = scratch.substring(0, pos) + "_i.pcx"; + scratch= scratch.substring(0, pos) + "_i.pcx"; else scratch += "_i.pcx"; - for (i = 0; i < npcxfiles; i++) { + for (i= 0; i < npcxfiles; i++) { if (strcmp(pcxfiles[i], scratch) == 0) return true; } @@ -3837,27 +3859,27 @@ public final class Menu extends Key { //char scratch[1024]; String scratch; - int ndirs = 0, npms = 0; + int ndirs= 0, npms= 0; int a, b, c; String dirnames[]; - String path = null; + String path= null; int i; //extern String * FS_ListFiles(String , int *, unsigned, unsigned); - s_numplayermodels = 0; + s_numplayermodels= 0; /* ** get a list of directories */ do { - path = FS.NextPath(path); - findname = path + "/players/*.*"; + path= FS.NextPath(path); + findname= path + "/players/*.*"; - if ((dirnames = FS.ListFiles(findname, 0, SFF_SUBDIR)) != null) { - ndirs = dirnames.length; + if ((dirnames= FS.ListFiles(findname, 0, SFF_SUBDIR)) != null) { + ndirs= dirnames.length; break; } } @@ -3869,45 +3891,45 @@ public final class Menu extends Key { /* ** go through the subdirectories */ - npms = ndirs; + npms= ndirs; if (npms > MAX_PLAYERMODELS) - npms = MAX_PLAYERMODELS; + npms= MAX_PLAYERMODELS; - for (i = 0; i < npms; i++) { + for (i= 0; i < npms; i++) { int k, s; //String a, b, c; String pcxnames[]; String skinnames[]; int npcxfiles; - int nskins = 0; + int nskins= 0; if (dirnames[i] == null) continue; // verify the existence of tris.md2 - scratch = dirnames[i]; + scratch= dirnames[i]; scratch += "/tris.md2"; if (Sys.FindFirst(scratch, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM) == null) { //free(dirnames[i]); - dirnames[i] = null; + dirnames[i]= null; Sys.FindClose(); continue; } Sys.FindClose(); // verify the existence of at least one pcx skin - scratch = dirnames[i] + "/*.pcx"; - pcxnames = FS.ListFiles(scratch, 0, 0); - npcxfiles = pcxnames.length; + scratch= dirnames[i] + "/*.pcx"; + pcxnames= FS.ListFiles(scratch, 0, 0); + npcxfiles= pcxnames.length; if (pcxnames == null) { - dirnames[i] = null; + dirnames[i]= null; continue; } // count valid skins, which consist of a skin with a matching "_i" icon - for (k = 0; k < npcxfiles - 1; k++) { + for (k= 0; k < npcxfiles - 1; k++) { if (!pcxnames[k].endsWith("_i.pcx")) { //if (!strstr(pcxnames[k], "_i.pcx")) { if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles - 1)) { @@ -3918,28 +3940,28 @@ public final class Menu extends Key { if (nskins == 0) continue; - skinnames = new String[nskins + 1]; //malloc(sizeof(String) * (nskins + 1)); + skinnames= new String[nskins + 1]; //malloc(sizeof(String) * (nskins + 1)); //memset(skinnames, 0, sizeof(String) * (nskins + 1)); // copy the valid skins - for (s = 0, k = 0; k < npcxfiles - 1; k++) { + for (s= 0, k= 0; k < npcxfiles - 1; k++) { if (pcxnames[k].indexOf("_i.pcx") < 0) { if (IconOfSkinExists(pcxnames[k], pcxnames, npcxfiles - 1)) { - a = pcxnames[k].lastIndexOf('/'); - b = pcxnames[k].lastIndexOf('\\'); + a= pcxnames[k].lastIndexOf('/'); + b= pcxnames[k].lastIndexOf('\\'); if (a > b) - c = a; + c= a; else - c = b; + c= b; - scratch = pcxnames[k].substring(c + 1, pcxnames[k].length()); - int pos = scratch.lastIndexOf('.'); + scratch= pcxnames[k].substring(c + 1, pcxnames[k].length()); + int pos= scratch.lastIndexOf('.'); if (pos != -1) - scratch = scratch.substring(0, pos); + scratch= scratch.substring(0, pos); - skinnames[s] = scratch; + skinnames[s]= scratch; s++; } } @@ -3947,22 +3969,22 @@ public final class Menu extends Key { // at this point we have a valid player model if (s_pmi[s_numplayermodels] == null) - s_pmi[s_numplayermodels] = new playermodelinfo_s(); + s_pmi[s_numplayermodels]= new playermodelinfo_s(); - s_pmi[s_numplayermodels].nskins = nskins; - s_pmi[s_numplayermodels].skindisplaynames = skinnames; + s_pmi[s_numplayermodels].nskins= nskins; + s_pmi[s_numplayermodels].skindisplaynames= skinnames; // make short name for the model - a = dirnames[i].lastIndexOf('/'); - b = dirnames[i].lastIndexOf('\\'); + a= dirnames[i].lastIndexOf('/'); + b= dirnames[i].lastIndexOf('\\'); if (a > b) - c = a; + c= a; else - c = b; + c= b; - s_pmi[s_numplayermodels].displayname = dirnames[i].substring(c + 1); - s_pmi[s_numplayermodels].directory = dirnames[i].substring(c + 1); + s_pmi[s_numplayermodels].displayname= dirnames[i].substring(c + 1); + s_pmi[s_numplayermodels].directory= dirnames[i].substring(c + 1); s_numplayermodels++; } @@ -3972,8 +3994,8 @@ public final class Menu extends Key { } static int pmicmpfnc(Object _a, Object _b) { - playermodelinfo_s a = (playermodelinfo_s) _a; - playermodelinfo_s b = (playermodelinfo_s) _b; + playermodelinfo_s a= (playermodelinfo_s) _a; + playermodelinfo_s b= (playermodelinfo_s) _b; /* ** sort by male, female, then alphabetical @@ -3991,7 +4013,7 @@ public final class Menu extends Key { return strcmp(a.directory, b.directory); } - static String handedness[] = { "right", "left", "center", null }; + static String handedness[]= { "right", "left", "center", null }; static boolean PlayerConfig_MenuInit() { /* @@ -4004,12 +4026,12 @@ public final class Menu extends Key { //char currentskin[1024]; String currentskin; - int i = 0; + int i= 0; - int currentdirectoryindex = 0; - int currentskinindex = 0; + int currentdirectoryindex= 0; + int currentskinindex= 0; - cvar_t hand = Cvar.Get("hand", "0", CVAR_USERINFO | CVAR_ARCHIVE); + cvar_t hand= Cvar.Get("hand", "0", CVAR_USERINFO | CVAR_ARCHIVE); PlayerConfig_ScanDirectories(); @@ -4019,19 +4041,19 @@ public final class Menu extends Key { if (hand.value < 0 || hand.value > 2) Cvar.SetValue("hand", 0); - currentdirectory = skin.string; + currentdirectory= skin.string; if (currentdirectory.lastIndexOf('/') != -1) { - currentskin = rightFrom(currentdirectory, '/'); - currentdirectory = leftFrom(currentdirectory, '/'); + currentskin= rightFrom(currentdirectory, '/'); + currentdirectory= leftFrom(currentdirectory, '/'); } else if (currentdirectory.lastIndexOf('\\') != -1) { - currentskin = rightFrom(currentdirectory, '\\'); - currentdirectory = leftFrom(currentdirectory, '\\'); + currentskin= rightFrom(currentdirectory, '\\'); + currentdirectory= leftFrom(currentdirectory, '\\'); } else { - currentdirectory = "male"; - currentskin = "grunt"; + currentdirectory= "male"; + currentskin= "grunt"; } //qsort(s_pmi, s_numplayermodels, sizeof(s_pmi[0]), pmicmpfnc); @@ -4042,116 +4064,116 @@ public final class Menu extends Key { }); //memset(s_pmnames, 0, sizeof(s_pmnames)); - s_pmnames = new String[MAX_PLAYERMODELS]; + s_pmnames= new String[MAX_PLAYERMODELS]; - for (i = 0; i < s_numplayermodels; i++) { - s_pmnames[i] = s_pmi[i].displayname; + for (i= 0; i < s_numplayermodels; i++) { + s_pmnames[i]= s_pmi[i].displayname; if (Q_stricmp(s_pmi[i].directory, currentdirectory) == 0) { int j; - currentdirectoryindex = i; + currentdirectoryindex= i; - for (j = 0; j < s_pmi[i].nskins; j++) { + for (j= 0; j < s_pmi[i].nskins; j++) { if (Q_stricmp(s_pmi[i].skindisplaynames[j], currentskin) == 0) { - currentskinindex = j; + currentskinindex= j; break; } } } } - s_player_config_menu.x = viddef.width / 2 - 95; - s_player_config_menu.y = viddef.height / 2 - 97; - s_player_config_menu.nitems = 0; + s_player_config_menu.x= viddef.width / 2 - 95; + s_player_config_menu.y= viddef.height / 2 - 97; + s_player_config_menu.nitems= 0; - s_player_name_field.type = MTYPE_FIELD; - s_player_name_field.name = "name"; - s_player_name_field.callback = null; - s_player_name_field.x = 0; - s_player_name_field.y = 0; - s_player_name_field.length = 20; - s_player_name_field.visible_length = 20; - s_player_name_field.buffer = new StringBuffer(name.string); - s_player_name_field.cursor = name.string.length(); + s_player_name_field.type= MTYPE_FIELD; + s_player_name_field.name= "name"; + s_player_name_field.callback= null; + s_player_name_field.x= 0; + s_player_name_field.y= 0; + s_player_name_field.length= 20; + s_player_name_field.visible_length= 20; + s_player_name_field.buffer= new StringBuffer(name.string); + s_player_name_field.cursor= name.string.length(); - s_player_model_title.type = MTYPE_SEPARATOR; - s_player_model_title.name = "model"; - s_player_model_title.x = -8; - s_player_model_title.y = 60; + s_player_model_title.type= MTYPE_SEPARATOR; + s_player_model_title.name= "model"; + s_player_model_title.x= -8; + s_player_model_title.y= 60; - s_player_model_box.type = MTYPE_SPINCONTROL; - s_player_model_box.x = -56; - s_player_model_box.y = 70; - s_player_model_box.callback = new mcallback() { + s_player_model_box.type= MTYPE_SPINCONTROL; + s_player_model_box.x= -56; + s_player_model_box.y= 70; + s_player_model_box.callback= new mcallback() { public void execute(Object o) { ModelCallback(o); } }; - s_player_model_box.cursor_offset = -48; - s_player_model_box.curvalue = currentdirectoryindex; - s_player_model_box.itemnames = s_pmnames; - - s_player_skin_title.type = MTYPE_SEPARATOR; - s_player_skin_title.name = "skin"; - s_player_skin_title.x = -16; - s_player_skin_title.y = 84; - - s_player_skin_box.type = MTYPE_SPINCONTROL; - s_player_skin_box.x = -56; - s_player_skin_box.y = 94; - s_player_skin_box.name = null; - s_player_skin_box.callback = null; - s_player_skin_box.cursor_offset = -48; - s_player_skin_box.curvalue = currentskinindex; - s_player_skin_box.itemnames = s_pmi[currentdirectoryindex].skindisplaynames; - - s_player_hand_title.type = MTYPE_SEPARATOR; - s_player_hand_title.name = "handedness"; - s_player_hand_title.x = 32; - s_player_hand_title.y = 108; - - s_player_handedness_box.type = MTYPE_SPINCONTROL; - s_player_handedness_box.x = -56; - s_player_handedness_box.y = 118; - s_player_handedness_box.name = null; - s_player_handedness_box.cursor_offset = -48; - s_player_handedness_box.callback = new mcallback() { + s_player_model_box.cursor_offset= -48; + s_player_model_box.curvalue= currentdirectoryindex; + s_player_model_box.itemnames= s_pmnames; + + s_player_skin_title.type= MTYPE_SEPARATOR; + s_player_skin_title.name= "skin"; + s_player_skin_title.x= -16; + s_player_skin_title.y= 84; + + s_player_skin_box.type= MTYPE_SPINCONTROL; + s_player_skin_box.x= -56; + s_player_skin_box.y= 94; + s_player_skin_box.name= null; + s_player_skin_box.callback= null; + s_player_skin_box.cursor_offset= -48; + s_player_skin_box.curvalue= currentskinindex; + s_player_skin_box.itemnames= s_pmi[currentdirectoryindex].skindisplaynames; + + s_player_hand_title.type= MTYPE_SEPARATOR; + s_player_hand_title.name= "handedness"; + s_player_hand_title.x= 32; + s_player_hand_title.y= 108; + + s_player_handedness_box.type= MTYPE_SPINCONTROL; + s_player_handedness_box.x= -56; + s_player_handedness_box.y= 118; + s_player_handedness_box.name= null; + s_player_handedness_box.cursor_offset= -48; + s_player_handedness_box.callback= new mcallback() { public void execute(Object o) { HandednessCallback(o); } }; - s_player_handedness_box.curvalue = (int) Cvar.VariableValue("hand"); - s_player_handedness_box.itemnames = handedness; + s_player_handedness_box.curvalue= (int) Cvar.VariableValue("hand"); + s_player_handedness_box.itemnames= handedness; - for (i = 0; i < rate_tbl.length - 1; i++) + for (i= 0; i < rate_tbl.length - 1; i++) if (Cvar.VariableValue("rate") == rate_tbl[i]) break; - s_player_rate_title.type = MTYPE_SEPARATOR; - s_player_rate_title.name = "connect speed"; - s_player_rate_title.x = 56; - s_player_rate_title.y = 156; - - s_player_rate_box.type = MTYPE_SPINCONTROL; - s_player_rate_box.x = -56; - s_player_rate_box.y = 166; - s_player_rate_box.name = null; - s_player_rate_box.cursor_offset = -48; - s_player_rate_box.callback = new mcallback() { + s_player_rate_title.type= MTYPE_SEPARATOR; + s_player_rate_title.name= "connect speed"; + s_player_rate_title.x= 56; + s_player_rate_title.y= 156; + + s_player_rate_box.type= MTYPE_SPINCONTROL; + s_player_rate_box.x= -56; + s_player_rate_box.y= 166; + s_player_rate_box.name= null; + s_player_rate_box.cursor_offset= -48; + s_player_rate_box.callback= new mcallback() { public void execute(Object o) { RateCallback(o); } }; - s_player_rate_box.curvalue = i; - s_player_rate_box.itemnames = rate_names; - - s_player_download_action.type = MTYPE_ACTION; - s_player_download_action.name = "download options"; - s_player_download_action.flags = QMF_LEFT_JUSTIFY; - s_player_download_action.x = -24; - s_player_download_action.y = 186; - s_player_download_action.statusbar = null; - s_player_download_action.callback = new mcallback() { + s_player_rate_box.curvalue= i; + s_player_rate_box.itemnames= rate_names; + + s_player_download_action.type= MTYPE_ACTION; + s_player_download_action.name= "download options"; + s_player_download_action.flags= QMF_LEFT_JUSTIFY; + s_player_download_action.x= -24; + s_player_download_action.y= 186; + s_player_download_action.statusbar= null; + s_player_download_action.callback= new mcallback() { public void execute(Object o) { DownloadOptionsFunc(o); } @@ -4177,56 +4199,56 @@ public final class Menu extends Key { static void PlayerConfig_MenuDraw() { - refdef_t refdef = new refdef_t(); + refdef_t refdef= new refdef_t(); //char scratch[MAX_QPATH]; String scratch; //memset(refdef, 0, sizeof(refdef)); - refdef.x = viddef.width / 2; - refdef.y = viddef.height / 2 - 72; - refdef.width = 144; - refdef.height = 168; - refdef.fov_x = 40; - refdef.fov_y = Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height); - refdef.time = cls.realtime * 0.001f; + refdef.x= viddef.width / 2; + refdef.y= viddef.height / 2 - 72; + refdef.width= 144; + refdef.height= 168; + refdef.fov_x= 40; + refdef.fov_y= Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height); + refdef.time= cls.realtime * 0.001f; if (s_pmi[s_player_model_box.curvalue].skindisplaynames != null) { - int maxframe = 29; - entity_t entity = new entity_t(); + int maxframe= 29; + entity_t entity= new entity_t(); //memset(entity, 0, sizeof(entity)); - scratch = "players/" + s_pmi[s_player_model_box.curvalue].directory + "/tris.md2"; + scratch= "players/" + s_pmi[s_player_model_box.curvalue].directory + "/tris.md2"; - entity.model = re.RegisterModel(scratch); + entity.model= re.RegisterModel(scratch); - scratch = + scratch= "players/" + s_pmi[s_player_model_box.curvalue].directory + "/" + s_pmi[s_player_model_box.curvalue].skindisplaynames[s_player_skin_box.curvalue] + ".pcx"; - entity.skin = re.RegisterSkin(scratch); - entity.flags = RF_FULLBRIGHT; - entity.origin[0] = 80; - entity.origin[1] = 0; - entity.origin[2] = 0; + entity.skin= re.RegisterSkin(scratch); + entity.flags= RF_FULLBRIGHT; + entity.origin[0]= 80; + entity.origin[1]= 0; + entity.origin[2]= 0; VectorCopy(entity.origin, entity.oldorigin); - entity.frame = 0; - entity.oldframe = 0; - entity.backlerp = 0.0f; - entity.angles[1] = yaw++; + entity.frame= 0; + entity.oldframe= 0; + entity.backlerp= 0.0f; + entity.angles[1]= yaw++; if (++yaw > 360) yaw -= 360; - refdef.areabits = null; - refdef.num_entities = 1; - refdef.entities = new entity_t[] { entity }; - refdef.lightstyles = null; - refdef.rdflags = RDF_NOWORLDMODEL; + refdef.areabits= null; + refdef.num_entities= 1; + refdef.entities= new entity_t[] { entity }; + refdef.lightstyles= null; + refdef.rdflags= RDF_NOWORLDMODEL; Menu_Draw(s_player_config_menu); @@ -4239,7 +4261,7 @@ public final class Menu extends Key { re.RenderFrame(refdef); - scratch = + scratch= "/players/" + s_pmi[s_player_model_box.curvalue].directory + "/" @@ -4259,28 +4281,28 @@ public final class Menu extends Key { Cvar.Set("name", s_player_name_field.buffer.toString()); - scratch = + scratch= s_pmi[s_player_model_box.curvalue].directory + "/" + s_pmi[s_player_model_box.curvalue].skindisplaynames[s_player_skin_box.curvalue]; Cvar.Set("skin", scratch); - for (i = 0; i < s_numplayermodels; i++) { + for (i= 0; i < s_numplayermodels; i++) { int j; - for (j = 0; j < s_pmi[i].nskins; j++) { + for (j= 0; j < s_pmi[i].nskins; j++) { if (s_pmi[i].skindisplaynames[j] != null) - s_pmi[i].skindisplaynames[j] = null; + s_pmi[i].skindisplaynames[j]= null; } - s_pmi[i].skindisplaynames = null; - s_pmi[i].nskins = 0; + s_pmi[i].skindisplaynames= null; + s_pmi[i].nskins= 0; } } return Default_MenuKey(s_player_config_menu, key); } - static xcommand_t Menu_PlayerConfig = new xcommand_t() { + static xcommand_t Menu_PlayerConfig= new xcommand_t() { public void execute() { Menu_PlayerConfig_f(); } @@ -4320,7 +4342,7 @@ public final class Menu extends Key { case 'Y' : case 'y' : - cls.key_dest = key_console; + cls.key_dest= key_console; CL.Quit_f.execute(); break; @@ -4334,14 +4356,14 @@ public final class Menu extends Key { static void Quit_Draw() { int w, h; - Dimension d = new Dimension(); + Dimension d= new Dimension(); re.DrawGetPicSize(d, "quit"); - w = d.width; - h = d.height; + w= d.width; + h= d.height; re.DrawPic((viddef.width - w) / 2, (viddef.height - h) / 2, "quit"); } - static xcommand_t Menu_Quit = new xcommand_t() { + static xcommand_t Menu_Quit= new xcommand_t() { public void execute() { Menu_Quit_f(); } @@ -4383,8 +4405,8 @@ public final class Menu extends Key { Cmd.AddCommand("menu_keys", Menu_Keys); Cmd.AddCommand("menu_quit", Menu_Quit); - for (int i = 0; i < m_layers.length; i++) { - m_layers[i] = new menulayer_t(); + for (int i= 0; i < m_layers.length; i++) { + m_layers[i]= new menulayer_t(); } } @@ -4413,7 +4435,7 @@ public final class Menu extends Key { // caching images if (m_entersound) { S.StartLocalSound(menu_in_sound); - m_entersound = false; + m_entersound= false; } } @@ -4426,7 +4448,7 @@ public final class Menu extends Key { String s; if (m_keyfunc != null) - if ((s = m_keyfunc.execute(key)) != null) + if ((s= m_keyfunc.execute(key)) != null) S.StartLocalSound(s); } @@ -4469,28 +4491,28 @@ public final class Menu extends Key { Menu_DrawStringR2LDark(f.x + f.parent.x + LCOLUMN_OFFSET, f.y + f.parent.y, f.name); //strncpy(tempbuffer, f.buffer + f.visible_offset, f.visible_length); - String s = f.buffer.toString(); - tempbuffer = s.substring(f.visible_offset, s.length()); + String s= f.buffer.toString(); + tempbuffer= s.substring(f.visible_offset, s.length()); re.DrawChar(f.x + f.parent.x + 16, f.y + f.parent.y - 4, 18); re.DrawChar(f.x + f.parent.x + 16, f.y + f.parent.y + 4, 24); re.DrawChar(f.x + f.parent.x + 24 + f.visible_length * 8, f.y + f.parent.y - 4, 20); re.DrawChar(f.x + f.parent.x + 24 + f.visible_length * 8, f.y + f.parent.y + 4, 26); - for (i = 0; i < f.visible_length; i++) { + for (i= 0; i < f.visible_length; i++) { re.DrawChar(f.x + f.parent.x + 24 + i * 8, f.y + f.parent.y - 4, 19); re.DrawChar(f.x + f.parent.x + 24 + i * 8, f.y + f.parent.y + 4, 25); } Menu_DrawString(f.x + f.parent.x + 24, f.y + f.parent.y, tempbuffer); - + if (Menu_ItemAtCursor(f.parent) == f) { int offset; if (f.visible_offset != 0) - offset = f.visible_length; + offset= f.visible_length; else - offset = f.cursor; + offset= f.cursor; if ((((int) (Sys.Milliseconds() / 250)) & 1) != 0) { re.DrawChar(f.x + f.parent.x + (offset + 2) * 8 + 8, f.y + f.parent.y, 11); @@ -4502,50 +4524,50 @@ public final class Menu extends Key { } public static boolean Field_Key(menufield_s f, int k) { - char key = (char) k; + char key= (char) k; switch (key) { case K_KP_SLASH : - key = '/'; + key= '/'; break; case K_KP_MINUS : - key = '-'; + key= '-'; break; case K_KP_PLUS : - key = '+'; + key= '+'; break; case K_KP_HOME : - key = '7'; + key= '7'; break; case K_KP_UPARROW : - key = '8'; + key= '8'; break; case K_KP_PGUP : - key = '9'; + key= '9'; break; case K_KP_LEFTARROW : - key = '4'; + key= '4'; break; case K_KP_5 : - key = '5'; + key= '5'; break; case K_KP_RIGHTARROW : - key = '6'; + key= '6'; break; case K_KP_END : - key = '1'; + key= '1'; break; case K_KP_DOWNARROW : - key = '2'; + key= '2'; break; case K_KP_PGDN : - key = '3'; + key= '3'; break; case K_KP_INS : - key = '0'; + key= '0'; break; case K_KP_DEL : - key = '.'; + key= '.'; break; } @@ -4563,18 +4585,18 @@ public final class Menu extends Key { if ((Character.toUpperCase(key) == 'V' && keydown[K_CTRL]) || (((key == K_INS) || (key == K_KP_INS)) && keydown[K_SHIFT])) { String cbd; - if ((cbd = Sys.GetClipboardData()) != null) { + if ((cbd= Sys.GetClipboardData()) != null) { //strtok(cbd, "\n\r\b"); - String lines[] = Lib.linesplit(cbd); + String lines[]= Lib.linesplit(cbd); if (lines.length > 0 && lines[0].length() != 0) { //strncpy(f.buffer, cbd, f.length - 1); - f.buffer = new StringBuffer(lines[0]); - f.cursor = f.buffer.length(); + f.buffer= new StringBuffer(lines[0]); + f.cursor= f.buffer.length(); - f.visible_offset = f.cursor - f.visible_length; + f.visible_offset= f.cursor - f.visible_length; if (f.visible_offset < 0) - f.visible_offset = 0; + f.visible_offset= 0; } } return true; @@ -4627,15 +4649,15 @@ public final class Menu extends Key { public static void Menu_AddItem(menuframework_s menu, menucommon_s item) { if (menu.nitems == 0) - menu.nslots = 0; + menu.nslots= 0; if (menu.nitems < MAXMENUITEMS) { - menu.items[menu.nitems] = item; - ((menucommon_s) menu.items[menu.nitems]).parent = menu; + menu.items[menu.nitems]= item; + ((menucommon_s) menu.items[menu.nitems]).parent= menu; menu.nitems++; } - menu.nslots = Menu_TallySlots(menu); + menu.nslots= Menu_TallySlots(menu); } /* @@ -4652,7 +4674,7 @@ public final class Menu extends Key { ** see if it's in a valid spot */ if (m.cursor >= 0 && m.cursor < m.nitems) { - if ((citem = Menu_ItemAtCursor(m)) != null) { + if ((citem= Menu_ItemAtCursor(m)) != null) { if (citem.type != MTYPE_SEPARATOR) return; } @@ -4664,24 +4686,24 @@ public final class Menu extends Key { */ if (dir == 1) { while (true) { - citem = Menu_ItemAtCursor(m); + citem= Menu_ItemAtCursor(m); if (citem != null) if (citem.type != MTYPE_SEPARATOR) break; m.cursor += dir; if (m.cursor >= m.nitems) - m.cursor = 0; + m.cursor= 0; } } else { while (true) { - citem = Menu_ItemAtCursor(m); + citem= Menu_ItemAtCursor(m); if (citem != null) if (citem.type != MTYPE_SEPARATOR) break; m.cursor += dir; if (m.cursor < 0) - m.cursor = m.nitems - 1; + m.cursor= m.nitems - 1; } } } @@ -4689,10 +4711,10 @@ public final class Menu extends Key { public static void Menu_Center(menuframework_s menu) { int height; - height = ((menucommon_s) menu.items[menu.nitems - 1]).y; + height= ((menucommon_s) menu.items[menu.nitems - 1]).y; height += 10; - menu.y = (viddef.height - height) / 2; + menu.y= (viddef.height - height) / 2; } public static void Menu_Draw(menuframework_s menu) { @@ -4702,7 +4724,7 @@ public final class Menu extends Key { /* ** draw contents */ - for (i = 0; i < menu.nitems; i++) { + for (i= 0; i < menu.nitems; i++) { switch (((menucommon_s) menu.items[i]).type) { case MTYPE_FIELD : Field_Draw((menufield_s) menu.items[i]); @@ -4725,7 +4747,7 @@ public final class Menu extends Key { } } - item = Menu_ItemAtCursor(menu); + item= Menu_ItemAtCursor(menu); if (item != null && item.cursordraw != null) { item.cursordraw.execute(item); @@ -4758,10 +4780,10 @@ public final class Menu extends Key { public static void Menu_DrawStatusBar(String string) { if (string != null) { - int l = string.length(); - int maxrow = viddef.height / 8; - int maxcol = viddef.width / 8; - int col = maxcol / 2 - l / 2; + int l= string.length(); + int maxrow= viddef.height / 8; + int maxcol= viddef.width / 8; + int col= maxcol / 2 - l / 2; re.DrawFill(0, viddef.height - 8, viddef.width, 8, 4); Menu_DrawString(col * 8, viddef.height - 8, string); @@ -4774,7 +4796,7 @@ public final class Menu extends Key { public static void Menu_DrawString(int x, int y, String string) { int i; - for (i = 0; i < string.length(); i++) { + for (i= 0; i < string.length(); i++) { re.DrawChar((x + i * 8), y, string.charAt(i)); } } @@ -4782,7 +4804,7 @@ public final class Menu extends Key { public static void Menu_DrawStringDark(int x, int y, String string) { int i; - for (i = 0; i < string.length(); i++) { + for (i= 0; i < string.length(); i++) { re.DrawChar((x + i * 8), y, string.charAt(i) + 128); } } @@ -4790,8 +4812,8 @@ public final class Menu extends Key { public static void Menu_DrawStringR2L(int x, int y, String string) { int i; - int l = string.length(); - for (i = 0; i < l; i++) { + int l= string.length(); + for (i= 0; i < l; i++) { re.DrawChar((x - i * 8), y, string.charAt(l - i - 1)); } } @@ -4799,8 +4821,8 @@ public final class Menu extends Key { public static void Menu_DrawStringR2LDark(int x, int y, String string) { int i; - int l = string.length(); - for (i = 0; i < l; i++) { + int l= string.length(); + for (i= 0; i < l; i++) { re.DrawChar((x - i * 8), y, string.charAt(l - i - 1) + 128); } } @@ -4813,7 +4835,7 @@ public final class Menu extends Key { } static boolean Menu_SelectItem(menuframework_s s) { - menucommon_s item = Menu_ItemAtCursor(s); + menucommon_s item= Menu_ItemAtCursor(s); if (item != null) { switch (item.type) { @@ -4834,11 +4856,11 @@ public final class Menu extends Key { } public static void Menu_SetStatusBar(menuframework_s m, String string) { - m.statusbar = string; + m.statusbar= string; } public static void Menu_SlideItem(menuframework_s s, int dir) { - menucommon_s item = (menucommon_s) Menu_ItemAtCursor(s); + menucommon_s item= (menucommon_s) Menu_ItemAtCursor(s); if (item != null) { switch (item.type) { @@ -4854,12 +4876,12 @@ public final class Menu extends Key { public static int Menu_TallySlots(menuframework_s menu) { int i; - int total = 0; + int total= 0; - for (i = 0; i < menu.nitems; i++) { + for (i= 0; i < menu.nitems; i++) { if (((menucommon_s) menu.items[i]).type == MTYPE_LIST) { - int nitems = 0; - String n[] = ((menulist_s) menu.items[i]).itemnames; + int nitems= 0; + String n[]= ((menulist_s) menu.items[i]).itemnames; while (n[nitems] != null) nitems++; @@ -4877,9 +4899,9 @@ public final class Menu extends Key { public static void Menulist_DoEnter(menulist_s l) { int start; - start = l.y / 10 + 1; + start= l.y / 10 + 1; - l.curvalue = l.parent.cursor - start; + l.curvalue= l.parent.cursor - start; if (l.callback != null) l.callback.execute(l); @@ -4887,14 +4909,14 @@ public final class Menu extends Key { public static void MenuList_Draw(menulist_s l) { String n[]; - int y = 0; + int y= 0; Menu_DrawStringR2LDark(l.x + l.parent.x + LCOLUMN_OFFSET, l.y + l.parent.y, l.name); - n = l.itemnames; + n= l.itemnames; re.DrawFill(l.x - 112 + l.parent.x, l.parent.y + l.y + l.curvalue * 10 + 10, 128, 10, 16); - int i = 0; + int i= 0; while (n[i] != null) { Menu_DrawStringR2LDark(l.x + l.parent.x + LCOLUMN_OFFSET, l.y + l.parent.y + y + 10, n[i]); @@ -4913,29 +4935,29 @@ public final class Menu extends Key { s.curvalue += dir; if (s.curvalue > s.maxvalue) - s.curvalue = s.maxvalue; + s.curvalue= s.maxvalue; else if (s.curvalue < s.minvalue) - s.curvalue = s.minvalue; + s.curvalue= s.minvalue; if (s.callback != null) s.callback.execute(s); } - public static final int SLIDER_RANGE = 10; + public static final int SLIDER_RANGE= 10; public static void Slider_Draw(menuslider_s s) { int i; Menu_DrawStringR2LDark(s.x + s.parent.x + LCOLUMN_OFFSET, s.y + s.parent.y, s.name); - s.range = (s.curvalue - s.minvalue) / (float) (s.maxvalue - s.minvalue); + s.range= (s.curvalue - s.minvalue) / (float) (s.maxvalue - s.minvalue); if (s.range < 0) - s.range = 0; + s.range= 0; if (s.range > 1) - s.range = 1; + s.range= 1; re.DrawChar(s.x + s.parent.x + RCOLUMN_OFFSET, s.y + s.parent.y, 128); - for (i = 0; i < SLIDER_RANGE; i++) + for (i= 0; i < SLIDER_RANGE; i++) re.DrawChar(RCOLUMN_OFFSET + s.x + i * 8 + s.parent.x + 8, s.y + s.parent.y, 129); re.DrawChar(RCOLUMN_OFFSET + s.x + i * 8 + s.parent.x + 8, s.y + s.parent.y, 130); re.DrawChar((int) (8 + RCOLUMN_OFFSET + s.parent.x + s.x + (SLIDER_RANGE - 1) * 8 * s.range), s.y + s.parent.y, 131); @@ -4944,7 +4966,7 @@ public final class Menu extends Key { public static void SpinControl_DoEnter(menulist_s s) { s.curvalue++; if (s.itemnames[s.curvalue] == null) - s.curvalue = 0; + s.curvalue= 0; if (s.callback != null) s.callback.execute(s); @@ -4954,7 +4976,7 @@ public final class Menu extends Key { s.curvalue += dir; if (s.curvalue < 0) - s.curvalue = 0; + s.curvalue= 0; else if (s.itemnames[s.curvalue] == null) s.curvalue--; @@ -4975,14 +4997,14 @@ public final class Menu extends Key { } else { String line1, line2; - line1 = Lib.leftFrom(s.itemnames[s.curvalue], '\n'); + line1= Lib.leftFrom(s.itemnames[s.curvalue], '\n'); Menu_DrawString(RCOLUMN_OFFSET + s.x + s.parent.x, s.y + s.parent.y, line1); - line2 = Lib.rightFrom(s.itemnames[s.curvalue], '\n'); + line2= Lib.rightFrom(s.itemnames[s.curvalue], '\n'); - int pos = line2.indexOf('\n'); + int pos= line2.indexOf('\n'); if (pos != -1) - line2 = line2.substring(0, pos); + line2= line2.substring(0, pos); Menu_DrawString(RCOLUMN_OFFSET + s.x + s.parent.x, s.y + s.parent.y + 10, line2); } diff --git a/src/jake2/game/GameBase.java b/src/jake2/game/GameBase.java index 871e084..db2b3f0 100644 --- a/src/jake2/game/GameBase.java +++ b/src/jake2/game/GameBase.java @@ -19,9 +19,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 30.11.2003 by RST. -// $Id: GameBase.java,v 1.3 2004-07-09 06:50:49 hzi Exp $ +// $Id: GameBase.java,v 1.4 2004-08-20 21:29:58 salomo Exp $ -/** Father of all Objects. */ +/** Father of all GameObjects. */ package jake2.game; @@ -441,6 +441,7 @@ public class GameBase extends Globals */ public static void G_RunEntity(edict_t ent) { + if (ent.prethink != null) ent.prethink.think(ent); diff --git a/src/jake2/game/GameSave.java b/src/jake2/game/GameSave.java index d399b8c..ba36e06 100644 --- a/src/jake2/game/GameSave.java +++ b/src/jake2/game/GameSave.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 29.12.2003 by RST. -// $Id: GameSave.java,v 1.1 2004-07-07 19:59:01 hzi Exp $ +// $Id: GameSave.java,v 1.2 2004-08-20 21:29:57 salomo Exp $ package jake2.game; @@ -57,6 +57,7 @@ public class GameSave extends GameFunc { g_edicts = new edict_t[game.maxentities]; for (int i = 0; i < game.maxentities; i++) g_edicts[i] = new edict_t(i); + SV_GAME.ge.edicts = g_edicts; } public static void CreateClients() { @@ -131,16 +132,11 @@ public class GameSave extends GameFunc { // items InitItems(); - //Com_sprintf (game.helpmessage1, sizeof(game.helpmessage1), ""); game.helpmessage1 = ""; - - //Com_sprintf (game.helpmessage2, sizeof(game.helpmessage2), ""); game.helpmessage2 = ""; // initialize all entities for this game game.maxentities = (int) maxentities.value; - - //g_edicts = gi.TagMalloc(game.maxentities * sizeof(g_edicts[0]), TAG_GAME); CreateEdicts(); globals.edicts = g_edicts; @@ -149,585 +145,196 @@ public class GameSave extends GameFunc { // initialize all clients for this game game.maxclients = (int) maxclients.value; - //game.clients = gi.TagMalloc(game.maxclients * sizeof(game.clients[0]), TAG_GAME); CreateClients(); - + globals.num_edicts = game.maxclients + 1; } - ////========================================================= - // - //public static void WriteField1 (FILE *f, field_t field, byte base) - //{ - // void *p; - // int len; - // int index; - // - // if (field.flags & FFL_SPAWNTEMP) - // return; - // - // p = (void *)(base + field.ofs); - // switch (field.type) - // { - // case F_INT: - // case F_FLOAT: - // case F_ANGLEHACK: - // case F_VECTOR: - // case F_IGNORE: - // break; - // - // case F_LSTRING: - // case F_GSTRING: - // if ( *(char **)p ) - // len = strlen(*(char **)p) + 1; - // else - // len = 0; - // *(int *)p = len; - // break; - // case F_EDICT: - // if ( *(edict_t **)p == NULL) - // index = -1; - // else - // index = *(edict_t **)p - g_edicts; - // *(int *)p = index; - // break; - // case F_CLIENT: - // if ( *(gclient_t **)p == NULL) - // index = -1; - // else - // index = *(gclient_t **)p - game.clients; - // *(int *)p = index; - // break; - // case F_ITEM: - // if ( *(edict_t **)p == NULL) - // index = -1; - // else - // index = *(gitem_t **)p - itemlist; - // *(int *)p = index; - // break; - // - // //relative to code segment - // case F_FUNCTION: - // if (*(byte **)p == NULL) - // index = 0; - // else - // index = *(byte **)p - ((byte *)InitGame); - // *(int *)p = index; - // break; - // - // //relative to data segment - // case F_MMOVE: - // if (*(byte **)p == NULL) - // index = 0; - // else - // index = *(byte **)p - (byte *)&mmove_reloc; - // *(int *)p = index; - // break; - // - // default: - // gi.error ("WriteEdict: unknown field type"); - // } - //} - // - // - //void WriteField2 (FILE *f, field_t *field, byte *base) - //{ - // int len; - // void *p; - // - // if (field.flags & FFL_SPAWNTEMP) - // return; - // - // p = (void *)(base + field.ofs); - // switch (field.type) - // { - // case F_LSTRING: - // if ( *(char **)p ) - // { - // len = strlen(*(char **)p) + 1; - // fwrite (*(char **)p, len, 1, f); - // } - // break; - // } - //} - // - //void ReadField (FILE *f, field_t *field, byte *base) - //{ - // void *p; - // int len; - // int index; - // - // if (field.flags & FFL_SPAWNTEMP) - // return; - // - // p = (void *)(base + field.ofs); - // switch (field.type) - // { - // case F_INT: - // case F_FLOAT: - // case F_ANGLEHACK: - // case F_VECTOR: - // case F_IGNORE: - // break; - // - // case F_LSTRING: - // len = *(int *)p; - // if (!len) - // *(char **)p = NULL; - // else - // { - // *(char **)p = gi.TagMalloc (len, TAG_LEVEL); - // fread (*(char **)p, len, 1, f); - // } - // break; - // case F_EDICT: - // index = *(int *)p; - // if ( index == -1 ) - // *(edict_t **)p = NULL; - // else - // *(edict_t **)p = &g_edicts[index]; - // break; - // case F_CLIENT: - // index = *(int *)p; - // if ( index == -1 ) - // *(gclient_t **)p = NULL; - // else - // *(gclient_t **)p = &game.clients[index]; - // break; - // case F_ITEM: - // index = *(int *)p; - // if ( index == -1 ) - // *(gitem_t **)p = NULL; - // else - // *(gitem_t **)p = &itemlist[index]; - // break; - // - // //relative to code segment - // case F_FUNCTION: - // index = *(int *)p; - // if ( index == 0 ) - // *(byte **)p = NULL; - // else - // *(byte **)p = ((byte *)InitGame) + index; - // break; - // - // //relative to data segment - // case F_MMOVE: - // index = *(int *)p; - // if (index == 0) - // *(byte **)p = NULL; - // else - // *(byte **)p = (byte *)&mmove_reloc + index; - // break; - // - // default: - // gi.error ("ReadEdict: unknown field type"); - // } - //} - // - ////========================================================= - // - ///* - //============== - //WriteClient - // - //All pointer variables (except function pointers) must be handled specially. - //============== - //*/ - //void WriteClient (FILE *f, gclient_t *client) - //{ - // field_t *field; - // gclient_t temp; - // - // // all of the ints, floats, and vectors stay as they are - // temp = *client; - // - // // change the pointers to lengths or indexes - // for (field=clientfields ; field.name ; field++) - // { - // WriteField1 (f, field, (byte *)&temp); - // } - // - // // write the block - // fwrite (&temp, sizeof(temp), 1, f); - // - // // now write any allocated data following the edict - // for (field=clientfields ; field.name ; field++) - // { - // WriteField2 (f, field, (byte *)client); - // } - //} - // /* - ============== - ReadClient + ============ + WriteGame + + This will be called whenever the game goes to a new level, + and when the user explicitly saves the game. - All pointer variables (except function pointers) must be handled specially. - ============== + Game information include cross level data, like multi level + triggers, help computer info, and all client states. + + A single player death will automatically restore from the + last save position. + ============ */ - - //} // - - /* - //============ - //WriteGame - // - //This will be called whenever the game goes to a new level, - //and when the user explicitly saves the game. - // - //Game information include cross level data, like multi level - //triggers, help computer info, and all client states. - // - //A single player death will automatically restore from the - //last save position. - //============ - //*/ - //public static void WriteGame (String filename, boolean autosave) - //{ - // FILE *f; - // int i; - // char str[16]; - // - // if (!autosave) - // SaveClientData (); - // - // f = fopen (filename, "rw"); - // if (!f) - // gi.error ("Couldn't open %s", filename); - // - // memset (str, 0, sizeof(str)); - // strcpy (str, __DATE__); - // fwrite (str, sizeof(str), 1, f); - // - // game.autosaved = autosave; - // fwrite (&game, sizeof(game), 1, f); - // game.autosaved = false; - // - // for (i=0 ; i= globals.num_edicts) - // globals.num_edicts = entnum+1; - // - // ent = &g_edicts[entnum]; - // ReadEdict (f, ent); - // - // // let the server rebuild world links for this ent - // memset (&ent.area, 0, sizeof(ent.area)); - // gi.linkentity (ent); - // } - // - // fclose (f); - // - // // mark all clients as unconnected - // for (i=0 ; i= globals.num_edicts) + globals.num_edicts = entnum + 1; + + ent = g_edicts[entnum]; + System.out.println("readint ent" + entnum); + ent.read(f); + ent.cleararealinks(); + gi.linkentity(ent); + } + + fclose (f); + + // mark all clients as unconnected + for (int i=0 ; i 0) return GameBase.gi.trace(start, mins, maxs, end, pm_passent, Defines.MASK_PLAYERSOLID); else return GameBase.gi.trace(start, mins, maxs, end, pm_passent, Defines.MASK_DEADSOLID); } - + }; } diff --git a/src/jake2/game/SuperAdapter.java b/src/jake2/game/SuperAdapter.java index 67285aa..29dcfb5 100644 --- a/src/jake2/game/SuperAdapter.java +++ b/src/jake2/game/SuperAdapter.java @@ -19,51 +19,80 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 09.01.2004 by RST. -// $Id: SuperAdapter.java,v 1.1 2004-07-07 19:59:24 hzi Exp $ +// $Id: SuperAdapter.java,v 1.2 2004-08-20 21:29:58 salomo Exp $ package jake2.game; import jake2.qcommon.Com; +import java.util.Hashtable; import java.util.Vector; +public class SuperAdapter +{ -// import jake2.*; -// import jake2.client.*; -// import jake2.game.*; -// import jake2.qcommon.*; -// import jake2.render.*; -// import jake2.server.*; - -public class SuperAdapter { - - // registration - private static void register(SuperAdapter sa) + /** Adapter registration. */ + private static void register(SuperAdapter sa, String id) { - adapters.add(sa); - //Com.Println("registering adapter " + sa.getID() + " (" + sa.getClass().getSuperclass() + ")"); + adapters.put(id, sa); } - - private static int id=0; - private static Vector adapters = new Vector(); - - - private static SuperAdapter find(int num) + + /** Adapter repository. */ + private static Hashtable adapters= new Hashtable(); + + /** Returns the adapter from the repository given by its ID. */ + public static SuperAdapter getFromID(String key) { - return (SuperAdapter) adapters.elementAt(num); + System.out.println("SuperAdapter.getFromID(\"" + key + "\")"); + SuperAdapter sa = (SuperAdapter) adapters.get(key); + + // try to create the adapter + if (sa == null) + { + System.out.println("adapter not found:" + key); + int pos = key.indexOf('$'); + String classname = key; + if (pos != -1) + classname = key.substring(0, pos); + + // load class and instantiate + try + { + System.err.println("loading class " + classname); + Class.forName(classname).newInstance(); + } + catch(Exception e) + { + System.err.println("jake2: class not found:" + classname); + } + + // try it again... + sa = (SuperAdapter) adapters.get(key); + + if (sa == null) + System.err.println("jake2: could not load adapter:" + key); + } + + return sa; } - - // constructor + + /** Constructor, does the adapter registration. */ public SuperAdapter() - { - adapterid = id++; - register(this); + { + StackTraceElement tr[] = new Throwable().getStackTrace(); + adapterid= tr[2].getClassName(); + if (adapterid == "") + new Throwable("error in creating an adapter id!").printStackTrace(); + else + register(this, adapterid); } - - public int getID() + + /** Returns the Adapter-ID. */ + public String getID() { return adapterid; } - private int adapterid; + /** Adapter id. */ + private String adapterid; } diff --git a/src/jake2/game/client_persistant_t.java b/src/jake2/game/client_persistant_t.java index 774cfa4..126d5d5 100644 --- a/src/jake2/game/client_persistant_t.java +++ b/src/jake2/game/client_persistant_t.java @@ -19,13 +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.4 2004-07-12 20:47:01 hzi Exp $ +// $Id: client_persistant_t.java,v 1.5 2004-08-20 21:29:58 salomo Exp $ package jake2.game; import jake2.Defines; import jake2.util.Lib; +import jake2.util.QuakeFile; +import java.io.IOException; +import java.io.RandomAccessFile; import java.nio.ByteBuffer; public class client_persistant_t { @@ -89,42 +92,78 @@ public class client_persistant_t { int helpchanged; boolean spectator; // client is a spectator - public void load(ByteBuffer bb) { - // client persistant_t - userinfo = Lib.readString(bb, Defines.MAX_INFO_STRING); - netname = Lib.readString(bb, 16); + /** Reads a client_persistant structure from a file. */ + public void read(QuakeFile f) throws IOException { + + userinfo = f.readString(); + netname = f.readString(); - hand = bb.getInt(); + hand = f.readInt(); - connected = bb.getInt() != 0; - health = bb.getInt(); + connected = f.readInt() != 0; + health = f.readInt(); - max_health = bb.getInt(); - savedFlags = bb.getInt(); - selected_item = bb.getInt(); + max_health = f.readInt(); + savedFlags = f.readInt(); + selected_item = f.readInt(); for (int n = 0; n < Defines.MAX_ITEMS; n++) - inventory[n] = bb.getInt(); + inventory[n] = f.readInt(); + + max_bullets = f.readInt(); + max_shells = f.readInt(); + max_rockets = f.readInt(); + max_grenades = f.readInt(); + max_cells = f.readInt(); + max_slugs = f.readInt(); + + weapon = f.readItem(); + lastweapon = f.readItem(); + power_cubes = f.readInt(); + score = f.readInt(); + + game_helpchanged = f.readInt(); + helpchanged = f.readInt(); + spectator = f.readInt() != 0; + } - max_bullets = bb.getInt(); - max_shells = bb.getInt(); - max_rockets = bb.getInt(); - max_grenades = bb.getInt(); - max_cells = bb.getInt(); - max_slugs = bb.getInt(); + /** Writes a client_persistant structure to a file. */ + public void write(QuakeFile f) throws IOException { + // client persistant_t + f.writeString(userinfo); + f.writeString(netname); - weapon = GameAI.itemlist[bb.getInt()]; - lastweapon = GameAI.itemlist[bb.getInt()]; - power_cubes = bb.getInt(); - score = bb.getInt(); + f.writeInt(hand); - game_helpchanged = bb.getInt(); - helpchanged = bb.getInt(); - spectator = bb.getInt() != 0; + f.writeInt(connected ? 1:0); + f.writeInt(health); + f.writeInt(max_health); + f.writeInt(savedFlags); + f.writeInt(selected_item); + + for (int n = 0; n < Defines.MAX_ITEMS; n++) + f.writeInt(inventory[n]); + + f.writeInt(max_bullets); + f.writeInt(max_shells); + f.writeInt(max_rockets); + f.writeInt(max_grenades); + f.writeInt(max_cells); + f.writeInt(max_slugs); + + f.writeItem(weapon); + f.writeItem(lastweapon); + f.writeInt(power_cubes); + f.writeInt(score); + + f.writeInt(game_helpchanged); + f.writeInt(helpchanged); + f.writeInt(spectator?1:0); } + public void dump() { // client persistant_t diff --git a/src/jake2/game/client_respawn_t.java b/src/jake2/game/client_respawn_t.java index 722d609..26e69a2 100644 --- a/src/jake2/game/client_respawn_t.java +++ b/src/jake2/game/client_respawn_t.java @@ -18,26 +18,40 @@ 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.4 2004-07-12 20:47:01 hzi Exp $ +// $Id: client_respawn_t.java,v 1.5 2004-08-20 21:29:57 salomo Exp $ package jake2.game; import jake2.qcommon.Com; import jake2.util.Lib; import jake2.util.Math3D; +import jake2.util.QuakeFile; import java.io.IOException; +import java.io.RandomAccessFile; import java.nio.ByteBuffer; +/** Client data that stays across deathmatch respawns.*/ public class client_respawn_t -// client data that stays across deathmatch respawns + { - client_persistant_t coop_respawn = new client_persistant_t(); // what to set client->pers to on a respawn - int enterframe; // level.framenum the client entered the game - int score; // frags, etc - float cmd_angles[] = { 0, 0, 0 }; // angles sent over in the last command - boolean spectator; // client is a spectator + /** What to set client->pers to on a respawn */ + protected client_persistant_t coop_respawn = new client_persistant_t(); + + /** Level.framenum the client entered the game. */ + protected int enterframe; + + /** frags, etc. */ + protected int score; + + /** angles sent over in the last command. */ + protected float cmd_angles[] = { 0, 0, 0 }; + + /** client is a spectator. */ + protected boolean spectator; + + /** Copies the client respawn data. */ public void set(client_respawn_t from) { coop_respawn.set(from.coop_respawn); @@ -47,7 +61,7 @@ public class client_respawn_t spectator = from.spectator; } - //ok + /** Clears the client reaspawn informations. */ public void clear() { coop_respawn = new client_persistant_t(); @@ -57,17 +71,33 @@ public class client_respawn_t spectator = false; } - public void load(ByteBuffer bb) throws IOException + /** Reads a client_respawn from a file. */ + public void read(QuakeFile f) throws IOException + { + coop_respawn.read(f); + enterframe = f.readInt(); + score = f.readInt(); + cmd_angles[0] = f.readFloat(); + cmd_angles[1] = f.readFloat(); + cmd_angles[2] = f.readFloat(); + spectator = f.readInt() != 0; + } + + /** Writes a client_respawn to a file. */ + public void write(QuakeFile f) throws IOException { - coop_respawn.load(bb); - enterframe = bb.getInt(); - score = bb.getInt(); - cmd_angles[0] = bb.getFloat(); - cmd_angles[1] = bb.getFloat(); - cmd_angles[2] = bb.getFloat(); - spectator = bb.getInt() != 0; + coop_respawn.write(f); + f.writeInt(enterframe); + f.writeInt(score); + f.writeFloat(cmd_angles[0]); + f.writeFloat(cmd_angles[1]); + f.writeFloat(cmd_angles[2]); + f.writeInt(spectator?1:0); } + + + /** Prints out a client_respawn_t to the quake console.*/ public void dump() { coop_respawn.dump(); diff --git a/src/jake2/game/edict_t.java b/src/jake2/game/edict_t.java index 229b18b..a132072 100644 --- a/src/jake2/game/edict_t.java +++ b/src/jake2/game/edict_t.java @@ -18,111 +18,130 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +// Created on 04.11.2003 by RST. +// $Id: edict_t.java,v 1.3 2004-08-20 21:29:57 salomo Exp $ + package jake2.game; +import java.io.IOException; +import java.io.RandomAccessFile; + import jake2.*; import jake2.util.*; -public class edict_t { - - public edict_t(int i) { - s.number = i; - index = i; +public class edict_t +{ + + /** Constructor. */ + public edict_t(int i) + { + s.number= i; + index= i; } - public void clear() { + /** Used during level loading. */ + public void cleararealinks() + { + area= new link_t(this); } - // integrated entity state - public entity_state_t s = new entity_state_t(this); + /** Integrated entity state. */ + public entity_state_t s= new entity_state_t(this); public boolean inuse; public int linkcount; - // FIXME: move these fields to a server private sv_entity_t - public link_t area = new link_t(this); // linked to a division node or leaf + /** FIXME: move these fields to a server private sv_entity_t. + * linked to a division node or leaf. */ + public link_t area= new link_t(this); + + /** if -1, use headnode instead.*/ + public int num_clusters; + public int clusternums[]= new int[Defines.MAX_ENT_CLUSTERS]; - public int num_clusters; // if -1, use headnode instead - public int clusternums[] = new int[Defines.MAX_ENT_CLUSTERS]; - public int headnode; // unused if num_clusters != -1 + /** unused if num_clusters != -1. */ + public int headnode; public int areanum, areanum2; //================================ - public int svflags; // SVF_NOCLIENT, SVF_DEADMONSTER, SVF_MONSTER, etc - public float[] mins = { 0, 0, 0 }; - public float[] maxs = { 0, 0, 0 }; - public float[] absmin = { 0, 0, 0 }; - public float[] absmax = { 0, 0, 0 }; - public float[] size = { 0, 0, 0 }; + /** SVF_NOCLIENT, SVF_DEADMONSTER, SVF_MONSTER, etc. */ + public int svflags; + public float[] mins= { 0, 0, 0 }; + public float[] maxs= { 0, 0, 0 }; + public float[] absmin= { 0, 0, 0 }; + public float[] absmax= { 0, 0, 0 }; + public float[] size= { 0, 0, 0 }; public int solid; public int clipmask; - // the game dll can add anything it wants after - // this point in the structure - // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER - // EXPECTS THE FIELDS IN THAT ORDER! - //================================ public int movetype; public int flags; - public String model = null; - public float freetime; // sv.time when the object was freed + public String model= null; + + /** sv.time when the object was freed. */ + public float freetime; // // only used locally in game, not by server // - public String message = null; - public String classname = ""; + public String message= null; + public String classname= ""; public int spawnflags; public float timestamp; - // set in qe3, -1 = up, -2 = down + /** set in qe3, -1 = up, -2 = down */ public float angle; - public String target = null; - public String targetname = null; - public String killtarget = null; - public String team = null; - public String pathtarget = null; - public String deathtarget = null; - public String combattarget = null; + public String target= null; + public String targetname= null; + public String killtarget= null; + public String team= null; + public String pathtarget= null; + public String deathtarget= null; + public String combattarget= null; - public edict_t target_ent = null; + public edict_t target_ent= null; public float speed, accel, decel; - public float[] movedir = { 0, 0, 0 }; + public float[] movedir= { 0, 0, 0 }; - public float[] pos1 = { 0, 0, 0 }; - public float[] pos2 = { 0, 0, 0 }; + public float[] pos1= { 0, 0, 0 }; + public float[] pos2= { 0, 0, 0 }; - public float[] velocity = { 0, 0, 0 }; - public float[] avelocity = { 0, 0, 0 }; + public float[] velocity= { 0, 0, 0 }; + public float[] avelocity= { 0, 0, 0 }; public int mass; public float air_finished; - public float gravity; // per entity gravity multiplier (1.0 is normal) - // use for lowgrav artifact, flares - public edict_t goalentity = null; - public edict_t movetarget = null; + /** per entity gravity multiplier (1.0 is normal). */ + public float gravity; + /** use for lowgrav artifact, flares. */ + + public edict_t goalentity= null; + public edict_t movetarget= null; public float yaw_speed; public float ideal_yaw; public float nextthink; - public EntThinkAdapter prethink = null; - public EntThinkAdapter think = null; - public EntBlockedAdapter blocked = null; - public EntTouchAdapter touch = null; - public EntUseAdapter use = null; - public EntPainAdapter pain = null; - public EntDieAdapter die = null; + public EntThinkAdapter prethink= null; + public EntThinkAdapter think= null; + public EntBlockedAdapter blocked= null; + public EntTouchAdapter touch= null; + public EntUseAdapter use= null; + public EntPainAdapter pain= null; + public EntDieAdapter die= null; - public float touch_debounce_time; // are all these legit? do we need more/less of them? + /** Are all these legit? do we need more/less of them? */ + public float touch_debounce_time; public float pain_debounce_time; public float damage_debounce_time; - public float fly_sound_debounce_time; //move to clientinfo + + /** Move to clientinfo.*/ + public float fly_sound_debounce_time; public float last_move_time; public int health; @@ -133,37 +152,42 @@ public class edict_t { public float powerarmor_time; - public String map = null; - ; // target_changelevel + /** target_changelevel. */ + public String map= null; - public int viewheight; // height above origin where eyesight is determined + /** Height above origin where eyesight is determined. */ + public int viewheight; public int takedamage; public int dmg; public int radius_dmg; public float dmg_radius; - public int sounds; //make this a spawntemp var? + + /** make this a spawntemp var? */ + public int sounds; public int count; - public edict_t chain = null; - public edict_t enemy = null; - public edict_t oldenemy = null; - public edict_t activator = null; - public edict_t groundentity = null; + public edict_t chain= null; + public edict_t enemy= null; + public edict_t oldenemy= null; + public edict_t activator= null; + public edict_t groundentity= null; public int groundentity_linkcount; - public edict_t teamchain = null; - public edict_t teammaster = null; + public edict_t teamchain= null; + public edict_t teammaster= null; - public edict_t mynoise = null; // can go in client only - public edict_t mynoise2 = null; + /** can go in client only. */ + public edict_t mynoise= null; + public edict_t mynoise2= null; public int noise_index; public int noise_index2; public float volume; public float attenuation; - // timing variables + /** Timing variables. */ public float wait; - public float delay; // before firing targets + /** before firing targets...*/ + public float delay; public float random; public float teleport_time; @@ -171,298 +195,557 @@ public class edict_t { public int watertype; public int waterlevel; - public float[] move_origin = { 0, 0, 0 }; + public float[] move_origin= { 0, 0, 0 }; - public float[] move_angles = { 0, 0, 0 }; + public float[] move_angles= { 0, 0, 0 }; - // move this to clientinfo? + /** move this to clientinfo? .*/ public int light_level; - public int style; // also used as areaportal number + /** also used as areaportal number. */ + public int style; public gitem_t item; // for bonus items - // common integrated data blocks - public moveinfo_t moveinfo = new moveinfo_t(); - public monsterinfo_t monsterinfo = new monsterinfo_t(); + /** common integrated data blocks. */ + public moveinfo_t moveinfo= new moveinfo_t(); + public monsterinfo_t monsterinfo= new monsterinfo_t(); public gclient_t client; public edict_t owner; - - public int index; //introduced by rst - + + /** Introduced by rst. */ + public int index; ///////////////////////////////////////////////// - public boolean set(String key, String value) { + public boolean set(String key, String value) + { - if (key.equals("classname")) { - classname = GameSpawn.ED_NewString(value); + if (key.equals("classname")) + { + classname= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("model")) { - model = GameSpawn.ED_NewString(value); + if (key.equals("model")) + { + model= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("spawnflags")) { - spawnflags = Lib.atoi(value); + if (key.equals("spawnflags")) + { + spawnflags= Lib.atoi(value); return true; } // F_INT), - if (key.equals("speed")) { - speed = Lib.atof(value); + if (key.equals("speed")) + { + speed= Lib.atof(value); return true; } // F_FLOAT), - if (key.equals("accel")) { - accel = Lib.atof(value); + if (key.equals("accel")) + { + accel= Lib.atof(value); return true; } // F_FLOAT), - if (key.equals("decel")) { - decel = Lib.atof(value); + if (key.equals("decel")) + { + decel= Lib.atof(value); return true; } // F_FLOAT), - if (key.equals("target")) { - target = GameSpawn.ED_NewString(value); + if (key.equals("target")) + { + target= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("targetname")) { - targetname = GameSpawn.ED_NewString(value); + if (key.equals("targetname")) + { + targetname= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("pathtarget")) { - pathtarget = GameSpawn.ED_NewString(value); + if (key.equals("pathtarget")) + { + pathtarget= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("deathtarget")) { - deathtarget = GameSpawn.ED_NewString(value); + if (key.equals("deathtarget")) + { + deathtarget= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("killtarget")) { - killtarget = GameSpawn.ED_NewString(value); + if (key.equals("killtarget")) + { + killtarget= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("combattarget")) { - combattarget = GameSpawn.ED_NewString(value); + if (key.equals("combattarget")) + { + combattarget= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("message")) { - message = GameSpawn.ED_NewString(value); + if (key.equals("message")) + { + message= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("team")) { - team = GameSpawn.ED_NewString(value); + if (key.equals("team")) + { + team= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("wait")) { - wait = Lib.atof(value); + if (key.equals("wait")) + { + wait= Lib.atof(value); return true; } // F_FLOAT), - if (key.equals("delay")) { - delay = Lib.atof(value); + if (key.equals("delay")) + { + delay= Lib.atof(value); return true; } // F_FLOAT), - if (key.equals("random")) { - random = Lib.atof(value); + if (key.equals("random")) + { + random= Lib.atof(value); return true; } // F_FLOAT), - if (key.equals("move_origin")) { - move_origin = Lib.atov(value); + if (key.equals("move_origin")) + { + move_origin= Lib.atov(value); return true; } // F_VECTOR), - if (key.equals("move_angles")) { - move_angles = Lib.atov(value); + if (key.equals("move_angles")) + { + move_angles= Lib.atov(value); return true; } // F_VECTOR), - if (key.equals("style")) { - style = Lib.atoi(value); + if (key.equals("style")) + { + style= Lib.atoi(value); return true; } // F_INT), - if (key.equals("count")) { - count = Lib.atoi(value); + if (key.equals("count")) + { + count= Lib.atoi(value); return true; } // F_INT), - if (key.equals("health")) { - health = Lib.atoi(value); + if (key.equals("health")) + { + health= Lib.atoi(value); return true; } // F_INT), - if (key.equals("sounds")) { - sounds = Lib.atoi(value); + if (key.equals("sounds")) + { + sounds= Lib.atoi(value); return true; } // F_INT), - if (key.equals("light")) { + if (key.equals("light")) + { return true; } // F_IGNORE), - if (key.equals("dmg")) { - dmg = Lib.atoi(value); + if (key.equals("dmg")) + { + dmg= Lib.atoi(value); return true; } // F_INT), - if (key.equals("mass")) { - mass = Lib.atoi(value); + if (key.equals("mass")) + { + mass= Lib.atoi(value); return true; } // F_INT), - if (key.equals("volume")) { - volume = Lib.atof(value); + if (key.equals("volume")) + { + volume= Lib.atof(value); return true; } // F_FLOAT), - if (key.equals("attenuation")) { - attenuation = Lib.atof(value); + if (key.equals("attenuation")) + { + attenuation= Lib.atof(value); return true; } // F_FLOAT), - if (key.equals("map")) { - map = GameSpawn.ED_NewString(value); + if (key.equals("map")) + { + map= GameSpawn.ED_NewString(value); return true; } // F_LSTRING), - if (key.equals("origin")) { - s.origin = Lib.atov(value); + if (key.equals("origin")) + { + s.origin= Lib.atov(value); return true; } // F_VECTOR), - if (key.equals("angles")) { - s.angles = Lib.atov(value); + if (key.equals("angles")) + { + s.angles= Lib.atov(value); return true; } // F_VECTOR), - if (key.equals("angle")) { - s.angles = new float[] { 0, Lib.atof(value), 0 }; + if (key.equals("angle")) + { + s.angles= new float[] { 0, Lib.atof(value), 0 }; return true; } // F_ANGLEHACK), - /* --- NOSPAWN --- - if (key.equals("goalentity")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - - if (key.equals("movetarget")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - - if (key.equals("enemy")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - - if (key.equals("oldenemy")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - - if (key.equals("activator")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - - if (key.equals("groundentity")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - if (key.equals("teamchain")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - if (key.equals("teammaster")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - if (key.equals("owner")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - if (key.equals("mynoise")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - if (key.equals("mynoise2")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - if (key.equals("target_ent")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - if (key.equals("chain")) { - return true; - } // F_EDICT, FFL_NOSPAWN), - if (key.equals("prethink")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("think")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("blocked")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("touch")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("use")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("pain")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("die")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("stand")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("idle")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("search")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("walk")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("run")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("dodge")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("attack")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("melee")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("sight")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("checkattack")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - if (key.equals("currentmove")) { - return true; - } // F_MMOVE, FFL_NOSPAWN), - if (key.equals("endfunc")) { - return true; - } // F_FUNCTION, FFL_NOSPAWN), - - */ - if (key.equals("item")) { + if (key.equals("item")) + { Game.gi.error("ent.set(\"item\") called."); return true; } // F_ITEM) return false; } + + /** Writes the entity to the file. */ + public void write(QuakeFile f) throws IOException + { + + s.write(f); + f.writeBoolean(inuse); + f.writeInt(linkcount); + f.writeInt(num_clusters); + + f.writeInt(9999); + + if (clusternums == null) + f.writeInt(-1); + else + { + f.writeInt(Defines.MAX_ENT_CLUSTERS); + for (int n= 0; n < Defines.MAX_ENT_CLUSTERS; n++) + f.writeInt(clusternums[n]); + + } + f.writeInt(headnode); + f.writeInt(areanum); + f.writeInt(areanum2); + f.writeInt(svflags); + f.writeVector(mins); + f.writeVector(maxs); + f.writeVector(absmin); + f.writeVector(absmax); + f.writeVector(size); + f.writeInt(solid); + f.writeInt(clipmask); + + f.writeInt(movetype); + f.writeInt(flags); + + f.writeString(model); + f.writeFloat(freetime); + f.writeString(message); + f.writeString(classname); + f.writeInt(spawnflags); + f.writeFloat(timestamp); + + f.writeFloat(angle); + + f.writeString(target); + f.writeString(targetname); + f.writeString(team); + f.writeString(pathtarget); + f.writeString(deathtarget); + f.writeString(combattarget); + + f.writeEdictRef(target_ent); + + f.writeFloat(speed); + f.writeFloat(accel); + f.writeFloat(decel); + + f.writeVector(movedir); + + f.writeVector(pos1); + f.writeVector(pos2); + + f.writeVector(velocity); + f.writeVector(avelocity); + + f.writeInt(mass); + f.writeFloat(air_finished); + + f.writeFloat(gravity); + + f.writeEdictRef(goalentity); + f.writeEdictRef(movetarget); + + f.writeFloat(yaw_speed); + f.writeFloat(ideal_yaw); + + f.writeFloat(nextthink); + + f.writeAdapter(prethink); + f.writeAdapter(think); + f.writeAdapter(blocked); + + f.writeAdapter(touch); + f.writeAdapter(use); + f.writeAdapter(pain); + f.writeAdapter(die); + + f.writeFloat(touch_debounce_time); + f.writeFloat(pain_debounce_time); + f.writeFloat(damage_debounce_time); + + f.writeFloat(fly_sound_debounce_time); + f.writeFloat(last_move_time); + + f.writeInt(health); + f.writeInt(max_health); + + f.writeInt(gib_health); + f.writeInt(deadflag); + f.writeInt(show_hostile); + + f.writeFloat(powerarmor_time); + + f.writeString(map); + + f.writeInt(viewheight); + f.writeInt(takedamage); + f.writeInt(dmg); + f.writeInt(radius_dmg); + f.writeFloat(dmg_radius); + + f.writeInt(sounds); + f.writeInt(count); + + f.writeEdictRef(chain); + f.writeEdictRef(enemy); + f.writeEdictRef(oldenemy); + f.writeEdictRef(activator); + f.writeEdictRef(groundentity); + f.writeInt(groundentity_linkcount); + f.writeEdictRef(teamchain); + f.writeEdictRef(teammaster); + + f.writeEdictRef(mynoise); + f.writeEdictRef(mynoise2); + + f.writeInt(noise_index); + f.writeInt(noise_index2); + + f.writeFloat(volume); + f.writeFloat(attenuation); + f.writeFloat(wait); + f.writeFloat(delay); + f.writeFloat(random); + + f.writeFloat(teleport_time); + + f.writeInt(watertype); + f.writeInt(waterlevel); + f.writeVector(move_origin); + f.writeVector(move_angles); + + f.writeInt(light_level); + f.writeInt(style); + + f.writeItem(item); + + moveinfo.write(f); + monsterinfo.write(f); + if (client == null) + f.writeInt(-1); + else + f.writeInt(client.index); + + f.writeEdictRef(owner); + + // rst's checker :-) + f.writeInt(9876); + } + + /** Reads the entity from the file.*/ + public void read(QuakeFile f) throws IOException + { + s.read(f); + inuse= f.readBoolean(); + linkcount= f.readInt(); + num_clusters= f.readInt(); + + if (f.readInt() != 9999) + new Throwable("wrong read pos!").printStackTrace(); + + int len= f.readInt(); + + if (len == -1) + clusternums= null; + else + { + clusternums= new int[Defines.MAX_ENT_CLUSTERS]; + for (int n= 0; n < Defines.MAX_ENT_CLUSTERS; n++) + clusternums[n]= f.readInt(); + } + + headnode= f.readInt(); + areanum= f.readInt(); + areanum2= f.readInt(); + svflags= f.readInt(); + mins= f.readVector(); + maxs= f.readVector(); + absmin= f.readVector(); + absmax= f.readVector(); + size= f.readVector(); + solid= f.readInt(); + clipmask= f.readInt(); + + movetype= f.readInt(); + flags= f.readInt(); + + model= f.readString(); + freetime= f.readFloat(); + message= f.readString(); + classname= f.readString(); + spawnflags= f.readInt(); + timestamp= f.readFloat(); + + angle= f.readFloat(); + + target= f.readString(); + targetname= f.readString(); + team= f.readString(); + pathtarget= f.readString(); + deathtarget= f.readString(); + combattarget= f.readString(); + + target_ent= f.readEdictRef(); + + speed= f.readFloat(); + accel= f.readFloat(); + decel= f.readFloat(); + + movedir= f.readVector(); + + pos1= f.readVector(); + pos2= f.readVector(); + + velocity= f.readVector(); + avelocity= f.readVector(); + + mass= f.readInt(); + air_finished= f.readFloat(); + + gravity= f.readFloat(); + + goalentity= f.readEdictRef(); + movetarget= f.readEdictRef(); + + yaw_speed= f.readFloat(); + ideal_yaw= f.readFloat(); + + nextthink= f.readFloat(); + + prethink= (EntThinkAdapter) f.readAdapter(); + think= (EntThinkAdapter) f.readAdapter(); + blocked= (EntBlockedAdapter) f.readAdapter(); + + touch= (EntTouchAdapter) f.readAdapter(); + use= (EntUseAdapter) f.readAdapter(); + pain= (EntPainAdapter) f.readAdapter(); + die= (EntDieAdapter) f.readAdapter(); + + touch_debounce_time= f.readFloat(); + pain_debounce_time= f.readFloat(); + damage_debounce_time= f.readFloat(); + + fly_sound_debounce_time= f.readFloat(); + last_move_time= f.readFloat(); + + health= f.readInt(); + max_health= f.readInt(); + + gib_health= f.readInt(); + deadflag= f.readInt(); + show_hostile= f.readInt(); + + powerarmor_time= f.readFloat(); + + map= f.readString(); + + viewheight= f.readInt(); + takedamage= f.readInt(); + dmg= f.readInt(); + radius_dmg= f.readInt(); + dmg_radius= f.readFloat(); + + sounds= f.readInt(); + count= f.readInt(); + + chain= f.readEdictRef(); + enemy= f.readEdictRef(); + + oldenemy= f.readEdictRef(); + activator= f.readEdictRef(); + groundentity= f.readEdictRef(); + if (index == 145) + System.out.println("loadground:" + groundentity); + groundentity_linkcount= f.readInt(); + teamchain= f.readEdictRef(); + teammaster= f.readEdictRef(); + + mynoise= f.readEdictRef(); + mynoise2= f.readEdictRef(); + + noise_index= f.readInt(); + noise_index2= f.readInt(); + + volume= f.readFloat(); + attenuation= f.readFloat(); + wait= f.readFloat(); + delay= f.readFloat(); + random= f.readFloat(); + + teleport_time= f.readFloat(); + + watertype= f.readInt(); + waterlevel= f.readInt(); + move_origin= f.readVector(); + move_angles= f.readVector(); + + light_level= f.readInt(); + style= f.readInt(); + + item= f.readItem(); + + moveinfo.read(f); + monsterinfo.read(f); + + int ndx= f.readInt(); + if (ndx == -1) + client= null; + else + client= Game.game.clients[ndx]; + + owner= f.readEdictRef(); + + // rst's checker :-) + if (f.readInt() != 9876) + System.err.println("ent load check failed for num " + index); + } } diff --git a/src/jake2/game/entity_state_t.java b/src/jake2/game/entity_state_t.java index 25c3162..e4e7b68 100644 --- a/src/jake2/game/entity_state_t.java +++ b/src/jake2/game/entity_state_t.java @@ -19,33 +19,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 08.11.2003 by RST. -// $Id: entity_state_t.java,v 1.2 2004-07-08 15:58:43 hzi Exp $ +// $Id: entity_state_t.java,v 1.3 2004-08-20 21:29:58 salomo Exp $ package jake2.game; +import java.io.IOException; +import java.io.RandomAccessFile; + import jake2.util.Math3D; +import jake2.util.QuakeFile; public class entity_state_t implements Cloneable { - // entity_state_t is the information conveyed from the server - // in an update message about entities that the client will - // need to render in some way - + /** entity_state_t is the information conveyed from the server + in an update message about entities that the client will + need to render in some way. */ public entity_state_t(edict_t ent) { this.surrounding_ent = ent; } - public int number = -99999; // edict index + /** edict index. */ + public int number = -99999; public edict_t surrounding_ent = null; public float[] origin = { 0, 0, 0 }; public float[] angles = { 0, 0, 0 }; - public float[] old_origin = { 0, 0, 0 }; // for lerping + + /** for lerping. */ + public float[] old_origin = { 0, 0, 0 }; public int modelindex; - public int modelindex2, modelindex3, modelindex4; // weapons, CTF flags, etc. + /** weapons, CTF flags, etc. */ + public int modelindex2, modelindex3, modelindex4; public int frame; public int skinnum; - public int effects; // PGM - we're filling it, so it needs to be unsigned + /** PGM - we're filling it, so it needs to be unsigned. */ + public int effects; public int renderfx; public int solid; // for client side prediction, 8*(bits 0-4) is x/y radius @@ -56,6 +64,60 @@ public class entity_state_t implements Cloneable // events only go out for a single frame, they // are automatically cleared each frame + /** Writes the entity state to the file. */ + public void write(QuakeFile f) throws IOException + { + f.writeEdictRef(surrounding_ent); + f.writeVector(origin); + f.writeVector(angles); + f.writeVector(old_origin); + + f.writeInt(modelindex); + + f.writeInt(modelindex2); + f.writeInt(modelindex3); + f.writeInt(modelindex4); + + f.writeInt(frame); + f.writeInt(skinnum); + + f.writeInt(effects); + f.writeInt(renderfx); + f.writeInt(solid); + + f.writeInt(sound); + f.writeInt(event); + + } + + /** Reads the entity state from the file. */ + public void read(QuakeFile f) throws IOException + { + surrounding_ent = f.readEdictRef(); + origin = f.readVector(); + angles = f.readVector(); + old_origin = f.readVector(); + + modelindex = f.readInt(); + + modelindex2= f.readInt(); + modelindex3= f.readInt(); + modelindex4= f.readInt(); + + frame = f.readInt(); + skinnum = f.readInt(); + + effects = f.readInt(); + renderfx = f.readInt(); + solid = f.readInt(); + + sound = f.readInt(); + event = f.readInt(); + + + } + + public entity_state_t getClone() { entity_state_t out = new entity_state_t(this.surrounding_ent); diff --git a/src/jake2/game/game_export_t.java b/src/jake2/game/game_export_t.java index 9dabf51..38df9db 100644 --- a/src/jake2/game/game_export_t.java +++ b/src/jake2/game/game_export_t.java @@ -19,11 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: game_export_t.java,v 1.3 2004-07-09 06:50:49 hzi Exp $ +// $Id: game_export_t.java,v 1.4 2004-08-20 21:29:58 salomo Exp $ package jake2.game; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; + import jake2.qcommon.Com; +import jake2.util.QuakeFile; // //functions exported by the game subsystem @@ -58,8 +63,7 @@ public class game_export_t // ReadGame is called on a loadgame. public void WriteGame(String filename, boolean autosave) { - // TODO WriteGame not implemented. - Com.Println("WriteGame not implemented."); + GameSave.WriteGame(filename, autosave); } public void ReadGame(String filename) @@ -71,28 +75,43 @@ public class game_export_t // loaded with SpawnEntities public void WriteLevel(String filename) { - // TODO WriteLevel not implemented. - Com.Println("WriteLevel not implemented."); + try + { + GameSave.WriteLevel(filename); + } + catch (IOException e) + { + e.printStackTrace(); + } } public void ReadLevel(String filename) { - // TODO ReadLevel not implemented. - Com.Println("ReadLevel not implemented."); + try + { + GameSave.ReadLevel(filename); + } + catch (IOException e) + { + e.printStackTrace(); + } } public boolean ClientConnect(edict_t ent, String userinfo) { return PlayerClient.ClientConnect(ent, userinfo); } + public void ClientBegin(edict_t ent) { PlayerClient.ClientBegin(ent); } + public void ClientUserinfoChanged(edict_t ent, String userinfo) { PlayerClient.ClientUserinfoChanged(ent, userinfo); } + public void ClientDisconnect(edict_t ent) { PlayerClient.ClientDisconnect(ent); @@ -132,4 +151,4 @@ public class game_export_t public edict_t edicts[] = Game.g_edicts; public int num_edicts; // current number, <= max_edicts public int max_edicts; -} +} \ No newline at end of file diff --git a/src/jake2/game/game_locals_t.java b/src/jake2/game/game_locals_t.java index e638195..cbc109f 100644 --- a/src/jake2/game/game_locals_t.java +++ b/src/jake2/game/game_locals_t.java @@ -19,15 +19,19 @@ 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.3 2004-07-12 20:47:01 hzi Exp $ +// $Id: game_locals_t.java,v 1.4 2004-08-20 21:29:58 salomo Exp $ package jake2.game; import jake2.Defines; import jake2.qcommon.Com; import jake2.util.Lib; +import jake2.util.QuakeFile; +import java.io.IOException; +import java.io.RandomAccessFile; import java.nio.ByteBuffer; +import java.util.Date; public class game_locals_t extends Defines { @@ -59,28 +63,54 @@ public class game_locals_t extends Defines public int num_items; public boolean autosaved; - public void load(ByteBuffer bb) + /** Reads the game locals from a file. */ + public void load(QuakeFile f) throws IOException { - String date = Lib.readString(bb, 16); + String date = f.readString(); - helpmessage1 = Lib.readString(bb, 512); - helpmessage2 = Lib.readString(bb, 512); + helpmessage1 = f.readString(); + helpmessage2 = f.readString(); - helpchanged = bb.getInt(); + helpchanged = f.readInt(); // gclient_t* - bb.getInt(); - spawnpoint = Lib.readString(bb, 512); - maxclients = bb.getInt(); - maxentities = bb.getInt(); - serverflags = bb.getInt(); - num_items = bb.getInt(); - autosaved = bb.getInt() != 0; + + spawnpoint = f.readString(); + maxclients = f.readInt(); + maxentities = f.readInt(); + serverflags = f.readInt(); + num_items = f.readInt(); + autosaved = f.readInt() != 0; + + // rst's checker :-) + if (f.readInt()!=1928) + System.err.println("error in loading game_locals."); + + } + + /** Writes the game locals to a file. */ + public void write(QuakeFile f) throws IOException + { + f.writeString(new Date().toString()); + f.writeString(helpmessage1); + f.writeString(helpmessage2); + + f.writeInt(helpchanged); + // gclient_t* + + f.writeString(spawnpoint); + f.writeInt(maxclients); + f.writeInt(maxentities); + f.writeInt(serverflags); + f.writeInt(num_items); + f.writeInt(autosaved?1:0); + // rst's checker :-) + f.writeInt(1928); } + /** Prints the game locals.*/ public void dump() { - Com.Println("String helpmessage1: " + helpmessage1); Com.Println("String helpmessage2: " + helpmessage2); diff --git a/src/jake2/game/gclient_t.java b/src/jake2/game/gclient_t.java index ce0a491..2cbda59 100644 --- a/src/jake2/game/gclient_t.java +++ b/src/jake2/game/gclient_t.java @@ -19,15 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: gclient_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $ +// $Id: gclient_t.java,v 1.3 2004-08-20 21:29:58 salomo Exp $ package jake2.game; import jake2.qcommon.Com; import jake2.util.Lib; +import jake2.util.QuakeFile; import java.awt.event.ItemListener; import java.io.IOException; +import java.io.RandomAccessFile; import java.nio.ByteBuffer; public class gclient_t @@ -123,6 +125,9 @@ public class gclient_t public int index; + + + public void clear() { player_state_t ps = new player_state_t(); @@ -163,116 +168,233 @@ public class gclient_t } - public void load(ByteBuffer bb) throws IOException + /** Reads a game client from the file. */ + public void read(QuakeFile f) throws IOException { - ps.load(bb); - - ping = bb.getInt(); - - pers.load(bb); - resp.load(bb); - - old_pmove.load(bb); - - showscores = bb.getInt() != 0; - showinventory = bb.getInt() != 0; - showhelp = bb.getInt() != 0; - showhelpicon = bb.getInt() != 0; - ammo_index = bb.getInt(); - - buttons = bb.getInt(); - oldbuttons = bb.getInt(); - latched_buttons = bb.getInt(); - - //weapon_thunk=bb.getInt()!=0; - bb.getInt(); - //newweapon=GameTarget.itemlist[bb.getInt()]; - bb.getInt(); - - damage_armor = bb.getInt(); - damage_parmor = bb.getInt(); - damage_blood = bb.getInt(); - damage_knockback = bb.getInt(); - - damage_from[0] = bb.getFloat(); - damage_from[1] = bb.getFloat(); - damage_from[2] = bb.getFloat(); - - killer_yaw = bb.getFloat(); - - weaponstate = bb.getInt(); - - kick_angles[0] = bb.getFloat(); - kick_angles[1] = bb.getFloat(); - kick_angles[2] = bb.getFloat(); - - kick_origin[0] = bb.getFloat(); - kick_origin[1] = bb.getFloat(); - kick_origin[2] = bb.getFloat(); - - v_dmg_roll = bb.getFloat(); - v_dmg_pitch = bb.getFloat(); - v_dmg_time = bb.getFloat(); - fall_time = bb.getFloat(); - fall_value = bb.getFloat(); - damage_alpha = bb.getFloat(); - bonus_alpha = bb.getFloat(); - - damage_blend[0] = bb.getFloat(); - damage_blend[1] = bb.getFloat(); - damage_blend[2] = bb.getFloat(); - - v_angle[0] = bb.getFloat(); - v_angle[1] = bb.getFloat(); - v_angle[2] = bb.getFloat(); - - bobtime = bb.getFloat(); - - oldviewangles[0] = bb.getFloat(); - oldviewangles[1] = bb.getFloat(); - oldviewangles[2] = bb.getFloat(); - - oldvelocity[0] = bb.getFloat(); - oldvelocity[1] = bb.getFloat(); - oldvelocity[2] = bb.getFloat(); - - next_drown_time = bb.getFloat(); - - old_waterlevel = bb.getInt(); - breather_sound = bb.getInt(); - machinegun_shots = bb.getInt(); - anim_end = bb.getInt(); - anim_priority = bb.getInt(); - anim_duck = bb.getInt() != 0; - anim_run = bb.getInt() != 0; - - quad_framenum = bb.getFloat(); - invincible_framenum = bb.getFloat(); - breather_framenum = bb.getFloat(); - enviro_framenum = bb.getFloat(); - - grenade_blew_up = bb.getInt() != 0; - grenade_time = bb.getFloat(); - silencer_shots = bb.getInt(); - weapon_sound = bb.getInt(); - pickup_msg_time = bb.getFloat(); - flood_locktill = bb.getFloat(); - flood_when[0] = bb.getFloat(); - flood_when[1] = bb.getFloat(); - flood_when[2] = bb.getFloat(); - flood_when[3] = bb.getFloat(); - flood_when[4] = bb.getFloat(); - flood_when[5] = bb.getFloat(); - flood_when[6] = bb.getFloat(); - flood_when[7] = bb.getFloat(); - flood_when[8] = bb.getFloat(); - flood_when[9] = bb.getFloat(); - flood_whenhead = bb.getInt(); - respawn_time = bb.getFloat(); - chase_target = GameUtil.g_edicts[bb.getInt()]; - update_chase = bb.getInt() != 0; + ps.load(f); + + ping = f.readInt(); + + pers.read(f); + resp.read(f); + + old_pmove.load(f); + + showscores = f.readInt() != 0; + showinventory = f.readInt() != 0; + showhelp = f.readInt() != 0; + showhelpicon = f.readInt() != 0; + ammo_index = f.readInt(); + + buttons = f.readInt(); + oldbuttons = f.readInt(); + latched_buttons = f.readInt(); + + weapon_thunk=f.readInt()!=0; + + newweapon=f.readItem(); + + + damage_armor = f.readInt(); + damage_parmor = f.readInt(); + damage_blood = f.readInt(); + damage_knockback = f.readInt(); + + damage_from[0] = f.readFloat(); + damage_from[1] = f.readFloat(); + damage_from[2] = f.readFloat(); + + killer_yaw = f.readFloat(); + + weaponstate = f.readInt(); + + kick_angles[0] = f.readFloat(); + kick_angles[1] = f.readFloat(); + kick_angles[2] = f.readFloat(); + + kick_origin[0] = f.readFloat(); + kick_origin[1] = f.readFloat(); + kick_origin[2] = f.readFloat(); + + v_dmg_roll = f.readFloat(); + v_dmg_pitch = f.readFloat(); + v_dmg_time = f.readFloat(); + fall_time = f.readFloat(); + fall_value = f.readFloat(); + damage_alpha = f.readFloat(); + bonus_alpha = f.readFloat(); + + damage_blend[0] = f.readFloat(); + damage_blend[1] = f.readFloat(); + damage_blend[2] = f.readFloat(); + + v_angle[0] = f.readFloat(); + v_angle[1] = f.readFloat(); + v_angle[2] = f.readFloat(); + + bobtime = f.readFloat(); + + oldviewangles[0] = f.readFloat(); + oldviewangles[1] = f.readFloat(); + oldviewangles[2] = f.readFloat(); + + oldvelocity[0] = f.readFloat(); + oldvelocity[1] = f.readFloat(); + oldvelocity[2] = f.readFloat(); + + next_drown_time = f.readFloat(); + + old_waterlevel = f.readInt(); + breather_sound = f.readInt(); + machinegun_shots = f.readInt(); + anim_end = f.readInt(); + anim_priority = f.readInt(); + anim_duck = f.readInt() != 0; + anim_run = f.readInt() != 0; + + quad_framenum = f.readFloat(); + invincible_framenum = f.readFloat(); + breather_framenum = f.readFloat(); + enviro_framenum = f.readFloat(); + + grenade_blew_up = f.readInt() != 0; + grenade_time = f.readFloat(); + silencer_shots = f.readInt(); + weapon_sound = f.readInt(); + pickup_msg_time = f.readFloat(); + flood_locktill = f.readFloat(); + flood_when[0] = f.readFloat(); + flood_when[1] = f.readFloat(); + flood_when[2] = f.readFloat(); + flood_when[3] = f.readFloat(); + flood_when[4] = f.readFloat(); + flood_when[5] = f.readFloat(); + flood_when[6] = f.readFloat(); + flood_when[7] = f.readFloat(); + flood_when[8] = f.readFloat(); + flood_when[9] = f.readFloat(); + flood_whenhead = f.readInt(); + respawn_time = f.readFloat(); + chase_target = f.readEdictRef(); + update_chase = f.readInt() != 0; + + if (f.readInt() != 8765) + System.err.println("game client load failed for num=" + index); } + + /** Writes a game_client_t (a player) to a file. */ + public void write(QuakeFile f) throws IOException + { + ps.write(f); + + f.writeInt(ping); + + pers.write(f); + resp.write(f); + + old_pmove.write(f); + + f.writeInt(showscores?1:0); + f.writeInt(showinventory?1:0); + f.writeInt(showhelp?1:0); + f.writeInt(showhelpicon?1:0); + f.writeInt(ammo_index); + + f.writeInt(buttons); + f.writeInt(oldbuttons); + f.writeInt(latched_buttons); + + f.writeInt(weapon_thunk?1:0); + f.writeItem(newweapon); + + + f.writeInt(damage_armor); + f.writeInt(damage_parmor); + f.writeInt(damage_blood); + f.writeInt(damage_knockback); + + f.writeFloat(damage_from[0]); + f.writeFloat(damage_from[1]); + f.writeFloat(damage_from[2]); + + f.writeFloat(killer_yaw); + + f.writeInt(weaponstate); + + f.writeFloat(kick_angles[0]); + f.writeFloat(kick_angles[1]); + f.writeFloat(kick_angles[2]); + + f.writeFloat(kick_origin[0]); + f.writeFloat(kick_origin[1]); + f.writeFloat(kick_origin[2]); + + f.writeFloat(v_dmg_roll); + f.writeFloat(v_dmg_pitch); + f.writeFloat(v_dmg_time); + f.writeFloat(fall_time); + f.writeFloat(fall_value); + f.writeFloat(damage_alpha); + f.writeFloat(bonus_alpha); + + f.writeFloat(damage_blend[0]); + f.writeFloat(damage_blend[1]); + f.writeFloat(damage_blend[2]); + + f.writeFloat(v_angle[0]); + f.writeFloat(v_angle[1]); + f.writeFloat(v_angle[2]); + + f.writeFloat(bobtime); + + f.writeFloat(oldviewangles[0]); + f.writeFloat(oldviewangles[1]); + f.writeFloat(oldviewangles[2]); + + f.writeFloat(oldvelocity[0]); + f.writeFloat(oldvelocity[1]); + f.writeFloat(oldvelocity[2]); + + f.writeFloat(next_drown_time); + + f.writeInt(old_waterlevel); + f.writeInt(breather_sound); + f.writeInt(machinegun_shots); + f.writeInt(anim_end); + f.writeInt(anim_priority); + f.writeInt(anim_duck?1:0); + f.writeInt(anim_run?1:0); + + f.writeFloat(quad_framenum); + f.writeFloat(invincible_framenum); + f.writeFloat(breather_framenum); + f.writeFloat(enviro_framenum); + + f.writeInt(grenade_blew_up?1:0); + f.writeFloat(grenade_time); + f.writeInt(silencer_shots); + f.writeInt(weapon_sound); + f.writeFloat(pickup_msg_time); + f.writeFloat(flood_locktill); + f.writeFloat(flood_when[0]); + f.writeFloat(flood_when[1]); + f.writeFloat(flood_when[2]); + f.writeFloat(flood_when[3]); + f.writeFloat(flood_when[4]); + f.writeFloat(flood_when[5]); + f.writeFloat(flood_when[6]); + f.writeFloat(flood_when[7]); + f.writeFloat(flood_when[8]); + f.writeFloat(flood_when[9]); + f.writeInt(flood_whenhead); + f.writeFloat(respawn_time); + f.writeEdictRef(chase_target); + f.writeInt(update_chase?1:0); + + f.writeInt(8765); + } + public void dump() { @@ -357,7 +479,5 @@ public class gclient_t Com.Println("respawn_time: " + respawn_time); Com.Println("chase_target: " + chase_target); Com.Println("update_chase: " + update_chase); - } - } diff --git a/src/jake2/game/gitem_t.java b/src/jake2/game/gitem_t.java index 6849809..f478f34 100644 --- a/src/jake2/game/gitem_t.java +++ b/src/jake2/game/gitem_t.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 20.11.2003 by RST. -// $Id: gitem_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $ +// $Id: gitem_t.java,v 1.3 2004-08-20 21:29:57 salomo Exp $ package jake2.game; @@ -141,5 +141,5 @@ public class gitem_t ""); } - int index; + public int index; } diff --git a/src/jake2/game/level_locals_t.java b/src/jake2/game/level_locals_t.java index 18038bf..dc12cab 100644 --- a/src/jake2/game/level_locals_t.java +++ b/src/jake2/game/level_locals_t.java @@ -19,12 +19,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 20.11.2003 by RST -// $Id: level_locals_t.java,v 1.1 2004-07-07 19:59:25 hzi Exp $ +// $Id: level_locals_t.java,v 1.2 2004-08-20 21:29:57 salomo Exp $ package jake2.game; -public class level_locals_t { - // +import jake2.util.Lib; +import jake2.util.QuakeFile; + +import java.io.IOException; +import java.io.RandomAccessFile; + +public class level_locals_t +{ + // this structure is cleared as each map is entered // it is read/written to the level.sav file for savegames // @@ -46,8 +53,10 @@ public class level_locals_t { public edict_t sight_entity; public int sight_entity_framenum; + public edict_t sound_entity; public int sound_entity_framenum; + public edict_t sound2_entity; public int sound2_entity_framenum; @@ -66,4 +75,87 @@ public class level_locals_t { public int body_que; // dead bodies public int power_cubes; // ugly necessity for coop + + /** Writes the levellocales to the file.*/ + public void write(QuakeFile f) throws IOException + { + f.writeInt(framenum); + f.writeFloat(time); + f.writeString(level_name); + f.writeString(mapname); + f.writeString(nextmap); + f.writeFloat(intermissiontime); + f.writeString(changemap); + f.writeBoolean(exitintermission); + f.writeVector(intermission_origin); + f.writeVector(intermission_angle); + f.writeEdictRef(sight_client); + + f.writeEdictRef(sight_entity); + f.writeInt(sight_entity_framenum); + + f.writeEdictRef(sound_entity); + f.writeInt(sound_entity_framenum); + f.writeEdictRef(sound2_entity); + f.writeInt(sound2_entity_framenum); + + f.writeInt(pic_health); + + f.writeInt(total_secrets); + f.writeInt(found_secrets); + + f.writeInt(total_goals); + f.writeInt(found_goals); + f.writeInt(total_monsters); + f.writeInt(killed_monsters); + + f.writeEdictRef(current_entity); + f.writeInt(body_que); // dead bodies + f.writeInt(power_cubes); // ugly necessity for coop + + // rst's checker :-) + f.writeInt(4711); + } + + /** Reads the level locals from the file. */ + public void read(QuakeFile f) throws IOException + { + framenum = f.readInt(); + time = f.readFloat(); + level_name = f.readString(); + mapname = f.readString(); + nextmap = f.readString(); + intermissiontime = f.readFloat(); + changemap = f.readString(); + exitintermission = f.readBoolean(); + intermission_origin = f.readVector(); + intermission_angle = f.readVector(); + sight_client = f.readEdictRef(); + + sight_entity = f.readEdictRef(); + sight_entity_framenum = f.readInt(); + + sound_entity = f.readEdictRef(); + sound_entity_framenum = f.readInt(); + sound2_entity = f.readEdictRef(); + sound2_entity_framenum = f.readInt(); + + pic_health = f.readInt(); + + total_secrets = f.readInt(); + found_secrets = f.readInt(); + + total_goals = f.readInt(); + found_goals = f.readInt(); + total_monsters = f.readInt(); + killed_monsters = f.readInt(); + + current_entity = f.readEdictRef(); + body_que = f.readInt(); // dead bodies + power_cubes = f.readInt(); // ugly necessity for coop + + // rst's checker :-) + if (f.readInt()!= 4711) + System.out.println("error in reading level_locals."); + } } diff --git a/src/jake2/game/mframe_t.java b/src/jake2/game/mframe_t.java index 6e81af4..af5f095 100644 --- a/src/jake2/game/mframe_t.java +++ b/src/jake2/game/mframe_t.java @@ -19,18 +19,44 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 11.11.2003 by RST. -// $Id: mframe_t.java,v 1.1 2004-07-07 19:59:26 hzi Exp $ +// $Id: mframe_t.java,v 1.2 2004-08-20 21:29:58 salomo Exp $ package jake2.game; -public class mframe_t { - public mframe_t(AIAdapter ai, float dist, EntThinkAdapter think) { +import jake2.util.Lib; +import jake2.util.QuakeFile; + +import java.io.IOException; +import java.io.RandomAccessFile; + +public class mframe_t +{ + public mframe_t(AIAdapter ai, float dist, EntThinkAdapter think) + { this.ai= ai; this.dist= dist; this.think= think; } + + /** Empty constructor. */ + public mframe_t() + {} public AIAdapter ai; public float dist; public EntThinkAdapter think; + + public void write(QuakeFile f) throws IOException + { + f.writeAdapter(ai); + f.writeFloat(dist); + f.writeAdapter(think); + } + + public void read(QuakeFile f) throws IOException + { + ai= (AIAdapter) f.readAdapter(); + dist= f.readFloat(); + think= (EntThinkAdapter) f.readAdapter(); + } } diff --git a/src/jake2/game/mmove_t.java b/src/jake2/game/mmove_t.java index b0c19d0..cf8b2c2 100644 --- a/src/jake2/game/mmove_t.java +++ b/src/jake2/game/mmove_t.java @@ -19,20 +19,64 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 11.11.2003 by RST. -// $Id: mmove_t.java,v 1.1 2004-07-07 19:59:26 hzi Exp $ +// $Id: mmove_t.java,v 1.2 2004-08-20 21:29:57 salomo Exp $ package jake2.game; +import jake2.util.Lib; +import jake2.util.QuakeFile; + +import java.io.IOException; +import java.io.RandomAccessFile; + public class mmove_t { public mmove_t(int firstframe, int lastframe, mframe_t frame[], EntThinkAdapter endfunc) { + this.firstframe= firstframe; this.lastframe= lastframe; this.frame= frame; this.endfunc= endfunc; } + public mmove_t() + {} + public int firstframe; public int lastframe; public mframe_t frame[]; //ptr public EntThinkAdapter endfunc; + + + /** Writes the structure to a random acccess file. */ + public void write(QuakeFile f) throws IOException + { + f.writeInt(firstframe); + f.writeInt(lastframe); + if (frame == null) + f.writeInt(-1); + else + { + f. writeInt(frame.length); + for (int n=0; n < frame.length; n++) + frame[n].write(f); + } + f.writeAdapter(endfunc); + } + + /** Read the mmove_t from the RandomAccessFile. */ + public void read(QuakeFile f) throws IOException + { + firstframe = f.readInt(); + lastframe = f.readInt(); + + int len = f.readInt(); + + frame = new mframe_t[len]; + for (int n=0; n < len ; n++) + { + frame[n] = new mframe_t(); + frame[n].read(f); + } + endfunc = (EntThinkAdapter) f.readAdapter(); + } } diff --git a/src/jake2/game/monsterinfo_t.java b/src/jake2/game/monsterinfo_t.java index 48b96f0..4a98213 100644 --- a/src/jake2/game/monsterinfo_t.java +++ b/src/jake2/game/monsterinfo_t.java @@ -19,10 +19,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: monsterinfo_t.java,v 1.1 2004-07-07 19:59:26 hzi Exp $ +// $Id: monsterinfo_t.java,v 1.2 2004-08-20 21:29:58 salomo Exp $ package jake2.game; +import jake2.util.QuakeFile; + +import java.io.IOException; +import java.io.RandomAccessFile; + public class monsterinfo_t { public mmove_t currentmove; @@ -60,4 +65,98 @@ public class monsterinfo_t { public int power_armor_type; public int power_armor_power; + /** Writes the monsterinfo to the file.*/ + public void write(QuakeFile f) throws IOException + { + f.writeBoolean(currentmove != null); + if (currentmove != null) + currentmove.write(f); + f.writeInt(aiflags); + f.writeInt(nextframe); + f.writeFloat(scale); + f.writeAdapter(stand); + f.writeAdapter(idle); + f.writeAdapter(search); + f.writeAdapter(walk); + f.writeAdapter(run); + + f.writeAdapter(dodge); + + f.writeAdapter(attack); + f.writeAdapter(melee); + + f.writeAdapter(sight); + + f.writeAdapter(checkattack); + + f.writeFloat(pausetime); + f.writeFloat(attack_finished); + + f.writeVector(saved_goal); + + f.writeFloat(search_time); + f.writeFloat(trail_time); + + f.writeVector(last_sighting); + + f.writeInt(attack_state); + f.writeInt(lefty); + + f.writeFloat(idle_time); + f.writeInt(linkcount); + + f.writeInt(power_armor_power); + f.writeInt(power_armor_type); + } + + /** Writes the monsterinfo to the file.*/ + public void read(QuakeFile f) throws IOException + { + if (f.readBoolean()) + { + currentmove= new mmove_t(); + currentmove.read(f); + } + else + currentmove= null; + aiflags = f.readInt(); + nextframe = f.readInt(); + scale = f.readFloat(); + stand = (EntThinkAdapter) f.readAdapter(); + idle = (EntThinkAdapter) f.readAdapter(); + search = (EntThinkAdapter) f.readAdapter(); + walk = (EntThinkAdapter) f.readAdapter(); + run = (EntThinkAdapter) f.readAdapter(); + + dodge = (EntDodgeAdapter) f.readAdapter(); + + attack = (EntThinkAdapter) f.readAdapter(); + melee = (EntThinkAdapter) f.readAdapter(); + + sight = (EntInteractAdapter) f.readAdapter(); + + checkattack = (EntThinkAdapter) f.readAdapter(); + + pausetime = f.readFloat(); + attack_finished = f.readFloat(); + + saved_goal = f.readVector(); + + search_time = f.readFloat(); + trail_time = f.readFloat(); + + last_sighting = f.readVector(); + + attack_state = f.readInt(); + lefty = f.readInt(); + + idle_time = f.readFloat(); + linkcount = f.readInt(); + + power_armor_power = f.readInt(); + power_armor_type = f.readInt(); + + } + + } diff --git a/src/jake2/game/moveinfo_t.java b/src/jake2/game/moveinfo_t.java index 16b0b50..864051d 100644 --- a/src/jake2/game/moveinfo_t.java +++ b/src/jake2/game/moveinfo_t.java @@ -19,10 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: moveinfo_t.java,v 1.1 2004-07-07 19:59:26 hzi Exp $ +// $Id: moveinfo_t.java,v 1.2 2004-08-20 21:29:58 salomo Exp $ package jake2.game; +import java.io.IOException; + +import jake2.util.QuakeFile; + public class moveinfo_t { // fixed data float[] start_origin= { 0, 0, 0 }; @@ -51,4 +55,62 @@ public class moveinfo_t { float remaining_distance; float decel_distance; EntThinkAdapter endfunc; + + /** saves the moveinfo to the file.*/ + public void write(QuakeFile f) throws IOException { + f.writeVector(start_origin); + f.writeVector(start_angles); + f.writeVector(end_origin); + f.writeVector(end_angles); + + f.writeInt(sound_start); + f.writeInt(sound_middle); + f.writeInt(sound_end); + + f.writeFloat(accel); + f.writeFloat(speed); + f.writeFloat(decel); + f.writeFloat(distance); + + f.writeFloat(wait); + + f.writeInt(state); + f.writeVector(dir); + + f.writeFloat(current_speed); + f.writeFloat(move_speed); + f.writeFloat(next_speed); + f.writeFloat(remaining_distance); + f.writeFloat(decel_distance); + f.writeAdapter(endfunc); + } + + /** Reads the moveinfo from a file. */ + public void read(QuakeFile f) throws IOException { + start_origin= f.readVector(); + start_angles= f.readVector(); + end_origin= f.readVector(); + end_angles= f.readVector(); + + sound_start= f.readInt(); + sound_middle= f.readInt(); + sound_end= f.readInt(); + + accel= f.readFloat(); + speed= f.readFloat(); + decel= f.readFloat(); + distance= f.readFloat(); + + wait= f.readFloat(); + + state= f.readInt(); + dir= f.readVector(); + + current_speed= f.readFloat(); + move_speed= f.readFloat(); + next_speed= f.readFloat(); + remaining_distance= f.readFloat(); + decel_distance= f.readFloat(); + endfunc= (EntThinkAdapter) f.readAdapter(); + } } diff --git a/src/jake2/game/player_state_t.java b/src/jake2/game/player_state_t.java index d4ecc72..cf4daf4 100644 --- a/src/jake2/game/player_state_t.java +++ b/src/jake2/game/player_state_t.java @@ -19,11 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: player_state_t.java,v 1.3 2004-07-09 06:50:49 hzi Exp $ +// $Id: player_state_t.java,v 1.4 2004-08-20 21:29:58 salomo Exp $ package jake2.game; import java.io.IOException; +import java.io.RandomAccessFile; import java.nio.ByteBuffer; import jake2.*; @@ -32,114 +33,156 @@ import jake2.qcommon.Com; import jake2.util.Lib; import jake2.util.Math3D; +/** + Player_state_t is the information needed in addition to pmove_state_t + to rendered a view. There will only be 10 player_state_t sent each second, + but the number of pmove_state_t changes will be relative to client + frame rates. +*/ + public class player_state_t { - // player_state_t is the information needed in addition to pmove_state_t - // to rendered a view. There will only be 10 player_state_t sent each second, - // but the number of pmove_state_t changes will be reletive to client - // frame rates - public pmove_state_t pmove = new pmove_state_t(); // for prediction + public pmove_state_t pmove= new pmove_state_t(); // for prediction // these fields do not need to be communicated bit-precise - public float[] viewangles = { 0, 0, 0 }; // for fixed views - public float[] viewoffset = { 0, 0, 0 }; // add to pmovestate->origin - public float[] kick_angles = { 0, 0, 0 }; // add to view direction to get render angles + public float[] viewangles= { 0, 0, 0 }; // for fixed views + public float[] viewoffset= { 0, 0, 0 }; // add to pmovestate->origin + public float[] kick_angles= { 0, 0, 0 }; // add to view direction to get render angles // set by weapon kicks, pain effects, etc - public float[] gunangles = { 0, 0, 0 }; - public float[] gunoffset = { 0, 0, 0 }; + public float[] gunangles= { 0, 0, 0 }; + public float[] gunoffset= { 0, 0, 0 }; public int gunindex; public int gunframe; - public float blend[] = new float[4]; // rgba full screen effect + public float blend[]= new float[4]; // rgba full screen effect public float fov; // horizontal field of view public int rdflags; // refdef flags - public short stats[] = new short[Defines.MAX_STATS]; + public short stats[]= new short[Defines.MAX_STATS]; + + /** Lets cleverly reset the structure. */ + private static player_state_t prototype= new player_state_t(); - /** - * - */ - private static player_state_t prototype = new player_state_t(); - + /** Clears the player_state.*/ public void clear() { this.set(prototype); } - - public player_state_t getClone() - { + + /** Clones the object.*/ + public player_state_t getClone() { return new player_state_t().set(this); } - - public player_state_t set(player_state_t from) - { + + /** Copies the player state data. */ + public player_state_t set(player_state_t from) { pmove.set(from.pmove); Math3D.VectorCopy(from.viewangles, viewangles); - Math3D.VectorCopy(from.viewoffset,viewoffset); + Math3D.VectorCopy(from.viewoffset, viewoffset); Math3D.VectorCopy(from.kick_angles, kick_angles); - Math3D.VectorCopy(from.gunangles,gunangles); + Math3D.VectorCopy(from.gunangles, gunangles); Math3D.VectorCopy(from.gunoffset, gunoffset); - gunindex = from.gunindex; - gunframe = from.gunframe; - - blend[0] = from.blend[0]; - blend[1] = from.blend[1]; - blend[2] = from.blend[2]; - blend[3] = from.blend[3]; - - fov = from.fov; - rdflags = from.rdflags; - - //stats = new short[Defines.MAX_STATS]; - System.arraycopy(from.stats, 0, stats,0, Defines.MAX_STATS); - + gunindex= from.gunindex; + gunframe= from.gunframe; + + blend[0]= from.blend[0]; + blend[1]= from.blend[1]; + blend[2]= from.blend[2]; + blend[3]= from.blend[3]; + + fov= from.fov; + rdflags= from.rdflags; + + System.arraycopy(from.stats, 0, stats, 0, Defines.MAX_STATS); + return this; } - public void load(ByteBuffer bb) throws IOException { - pmove.load(bb); + /** Reads a player_state from a file.*/ + public void load(RandomAccessFile f) throws IOException { + pmove.load(f); + + viewangles[0]= f.readFloat(); + viewangles[1]= f.readFloat(); + viewangles[2]= f.readFloat(); + + viewoffset[0]= f.readFloat(); + viewoffset[1]= f.readFloat(); + viewoffset[2]= f.readFloat(); + + kick_angles[0]= f.readFloat(); + kick_angles[1]= f.readFloat(); + kick_angles[2]= f.readFloat(); + + gunangles[0]= f.readFloat(); + gunangles[1]= f.readFloat(); + gunangles[2]= f.readFloat(); + + gunoffset[0]= f.readFloat(); + gunoffset[1]= f.readFloat(); + gunoffset[2]= f.readFloat(); + + gunindex= f.readInt(); + gunframe= f.readInt(); + + blend[0]= f.readFloat(); + blend[1]= f.readFloat(); + blend[2]= f.readFloat(); + blend[3]= f.readFloat(); + + fov= f.readFloat(); + + rdflags= f.readInt(); + + for (int n= 0; n < Defines.MAX_STATS; n++) + stats[n]= f.readShort(); + } - viewangles[0] = bb.getFloat(); - viewangles[1] = bb.getFloat(); - viewangles[2] = bb.getFloat(); + /** Writes a player_state to a file.*/ + public void write(RandomAccessFile f) throws IOException { + pmove.write(f); - viewoffset[0] = bb.getFloat(); - viewoffset[1] = bb.getFloat(); - viewoffset[2] = bb.getFloat(); + f.writeFloat(viewangles[0]); + f.writeFloat(viewangles[1]); + f.writeFloat(viewangles[2]); - kick_angles[0] = bb.getFloat(); - kick_angles[1] = bb.getFloat(); - kick_angles[2] = bb.getFloat(); + f.writeFloat(viewoffset[0]); + f.writeFloat(viewoffset[1]); + f.writeFloat(viewoffset[2]); - gunangles[0] = bb.getFloat(); - gunangles[1] = bb.getFloat(); - gunangles[2] = bb.getFloat(); + f.writeFloat(kick_angles[0]); + f.writeFloat(kick_angles[1]); + f.writeFloat(kick_angles[2]); - gunoffset[0] = bb.getFloat(); - gunoffset[1] = bb.getFloat(); - gunoffset[2] = bb.getFloat(); + f.writeFloat(gunangles[0]); + f.writeFloat(gunangles[1]); + f.writeFloat(gunangles[2]); - gunindex = bb.getInt(); - gunframe = bb.getInt(); + f.writeFloat(gunoffset[0]); + f.writeFloat(gunoffset[1]); + f.writeFloat(gunoffset[2]); - blend[0] = bb.getFloat(); - blend[1] = bb.getFloat(); - blend[2] = bb.getFloat(); - blend[3] = bb.getFloat(); + f.writeInt(gunindex); + f.writeInt(gunframe); - fov = bb.getFloat(); + f.writeFloat(blend[0]); + f.writeFloat(blend[1]); + f.writeFloat(blend[2]); + f.writeFloat(blend[3]); - rdflags = bb.getInt(); + f.writeFloat(fov); - for (int n = 0; n < Defines.MAX_STATS; n++) - stats[n] = bb.getShort(); + f.writeInt(rdflags); + for (int n= 0; n < Defines.MAX_STATS; n++) + f.writeShort(stats[n]); } + /** Prints the player state. */ public void dump() { pmove.dump(); @@ -158,7 +201,7 @@ public class player_state_t { Com.Println("rdflags: " + rdflags); - for (int n = 0; n < Defines.MAX_STATS; n++) + for (int n= 0; n < Defines.MAX_STATS; n++) System.out.println("stats[" + n + "]: " + stats[n]); } } diff --git a/src/jake2/game/pmove_state_t.java b/src/jake2/game/pmove_state_t.java index 6c0906e..01b0bf6 100644 --- a/src/jake2/game/pmove_state_t.java +++ b/src/jake2/game/pmove_state_t.java @@ -19,13 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: pmove_state_t.java,v 1.1 2004-07-07 19:59:26 hzi Exp $ +// $Id: pmove_state_t.java,v 1.2 2004-08-20 21:29:58 salomo Exp $ package jake2.game; import jake2.qcommon.Com; import jake2.util.Math3D; import java.io.IOException; +import java.io.RandomAccessFile; import java.nio.ByteBuffer; public class pmove_state_t { @@ -39,12 +40,15 @@ public class pmove_state_t { public short origin[] = { 0, 0, 0 }; // 12.3 public short velocity[] = { 0, 0, 0 }; // 12.3 - public byte pm_flags; // ducked, jump_held, etc - public byte pm_time; // each unit = 8 ms + /** ducked, jump_held, etc. */ + public byte pm_flags; + /** each unit = 8 ms. */ + public byte pm_time; public short gravity; - public short delta_angles[] = { 0, 0, 0 }; // add to command angles to get view direction - // changed by spawns, rotating objects, and teleporters - + /** add to command angles to get view direction. */ + public short delta_angles[] = { 0, 0, 0 }; + /** changed by spawns, rotating objects, and teleporters.*/ + private static pmove_state_t prototype = new pmove_state_t(); public void reset() @@ -81,28 +85,53 @@ public class pmove_state_t { return false; } - public void load(ByteBuffer bb) throws IOException { + /** Reads the playermove from the file.*/ + public void load(RandomAccessFile f) throws IOException { + + pm_type = f.readInt(); + + origin[0] = f.readShort(); + origin[1] = f.readShort(); + origin[2] = f.readShort(); + + velocity[0] = f.readShort(); + velocity[1] = f.readShort(); + velocity[2] = f.readShort(); + + pm_flags = f.readByte(); + pm_time = f.readByte(); + gravity = f.readShort(); - pm_type = bb.getInt(); + f.readShort(); - origin[0] = bb.getShort(); - origin[1] = bb.getShort(); - origin[2] = bb.getShort(); + delta_angles[0] = f.readShort(); + delta_angles[1] = f.readShort(); + delta_angles[2] = f.readShort(); - velocity[0] = bb.getShort(); - velocity[1] = bb.getShort(); - velocity[2] = bb.getShort(); + } + + /** Writes the playermove to the file. */ + public void write (RandomAccessFile f) throws IOException { + + f.writeInt(pm_type); - pm_flags = bb.get(); - pm_time = bb.get(); - gravity = bb.getShort(); + f.writeShort(origin[0]); + f.writeShort(origin[1]); + f.writeShort(origin[2]); - bb.getShort(); + f.writeShort(velocity[0]); + f.writeShort(velocity[1]); + f.writeShort(velocity[2]); - delta_angles[0] = bb.getShort(); - delta_angles[1] = bb.getShort(); - delta_angles[2] = bb.getShort(); + f.writeByte(pm_flags); + f.writeByte(pm_time); + f.writeShort(gravity); + f.writeShort(0); + + f.writeShort(delta_angles[0]); + f.writeShort(delta_angles[1]); + f.writeShort(delta_angles[2]); } public void dump() { @@ -124,7 +153,4 @@ public class pmove_state_t { Com.Println("delta-angle[1]: " + delta_angles[0]); Com.Println("delta-angle[2]: " + delta_angles[0]); } - - - } \ No newline at end of file diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java index a99ae28..b2233f3 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.3 2004-07-09 06:50:49 hzi Exp $ + * $Id: FS.java,v 1.4 2004-08-20 21:29:58 salomo Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -116,7 +116,7 @@ public final class FS extends Globals { if (index > 0) { File f = new File(path.substring(0, index)); if (!f.mkdirs()) { - Com.Printf("can't create path \"" + path + '"' + "\n" ); + //Com.Printf("can't create path \"" + path + '"' + "\n" ); } } } diff --git a/src/jake2/server/SV.java b/src/jake2/server/SV.java index 4792264..540e3ea 100644 --- a/src/jake2/server/SV.java +++ b/src/jake2/server/SV.java @@ -2,9 +2,9 @@ * SV.java * Copyright (C) 2003 * - * $Id: SV.java,v 1.5 2004-07-30 06:07:23 hzi Exp $ + * $Id: SV.java,v 1.6 2004-08-20 21:29:57 salomo Exp $ */ - /* +/* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or @@ -35,198 +35,219 @@ import jake2.util.Math3D; /** * SV */ -public final class SV { +public final class SV +{ //file_io //===================================================================== //g_phys - + /////////////////////////////////////// - public static edict_t[] SV_TestEntityPosition(edict_t ent) { + public static edict_t[] SV_TestEntityPosition(edict_t ent) + { trace_t trace; int mask; - + if (ent.clipmask != 0) - mask = ent.clipmask; + mask= ent.clipmask; else - mask = Defines.MASK_SOLID; - - trace = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, ent.s.origin, ent, mask); - + mask= Defines.MASK_SOLID; + + trace= GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, ent.s.origin, ent, mask); + if (trace.startsolid) return GameBase.g_edicts; - + return null; } /////////////////////////////////////// - public static void SV_CheckVelocity(edict_t ent) { + public static void SV_CheckVelocity(edict_t ent) + { int i; - + // // bound velocity // - for (i = 0; i < 3; i++) { + for (i= 0; i < 3; i++) + { if (ent.velocity[i] > GameBase.sv_maxvelocity.value) - ent.velocity[i] = GameBase.sv_maxvelocity.value; + ent.velocity[i]= GameBase.sv_maxvelocity.value; else if (ent.velocity[i] < -GameBase.sv_maxvelocity.value) - ent.velocity[i] = -GameBase.sv_maxvelocity.value; + ent.velocity[i]= -GameBase.sv_maxvelocity.value; } } /** * Runs thinking code for this frame if necessary. */ - public static boolean SV_RunThink(edict_t ent) { + public static boolean SV_RunThink(edict_t ent) + { float thinktime; - - thinktime = ent.nextthink; + + thinktime= ent.nextthink; if (thinktime <= 0) return true; if (thinktime > GameBase.level.time + 0.001) return true; - - ent.nextthink = 0; - + + ent.nextthink= 0; + if (ent.think == null) Com.Error(Defines.ERR_FATAL, "NULL ent.think"); ent.think.think(ent); - + return false; } /** * Two entities have touched, so run their touch functions. */ - public static void SV_Impact(edict_t e1, trace_t trace) { + public static void SV_Impact(edict_t e1, trace_t trace) + { edict_t e2; // cplane_t backplane; - - e2 = trace.ent; - + + e2= trace.ent; + if (e1.touch != null && e1.solid != Defines.SOLID_NOT) e1.touch.touch(e1, e2, trace.plane, trace.surface); - + if (e2.touch != null && e2.solid != Defines.SOLID_NOT) e2.touch.touch(e2, e1, null, null); } - public static int SV_FlyMove(edict_t ent, float time, int mask) { + public static int SV_FlyMove(edict_t ent, float time, int mask) + { edict_t hit; int bumpcount, numbumps; - float[] dir = { 0.0f, 0.0f, 0.0f }; + float[] dir= { 0.0f, 0.0f, 0.0f }; float d; int numplanes; - float[][] planes = new float[GameBase.MAX_CLIP_PLANES][3]; - float[] primal_velocity = { 0.0f, 0.0f, 0.0f }; - float[] original_velocity = { 0.0f, 0.0f, 0.0f }; - float[] new_velocity = { 0.0f, 0.0f, 0.0f }; + float[][] planes= new float[GameBase.MAX_CLIP_PLANES][3]; + float[] primal_velocity= { 0.0f, 0.0f, 0.0f }; + float[] original_velocity= { 0.0f, 0.0f, 0.0f }; + float[] new_velocity= { 0.0f, 0.0f, 0.0f }; int i, j; trace_t trace; - float[] end = { 0.0f, 0.0f, 0.0f }; + float[] end= { 0.0f, 0.0f, 0.0f }; float time_left; int blocked; - - numbumps = 4; - - blocked = 0; + + numbumps= 4; + + blocked= 0; Math3D.VectorCopy(ent.velocity, original_velocity); Math3D.VectorCopy(ent.velocity, primal_velocity); - numplanes = 0; - - time_left = time; - - ent.groundentity = null; - for (bumpcount = 0; bumpcount < numbumps; bumpcount++) { - for (i = 0; i < 3; i++) - end[i] = ent.s.origin[i] + time_left * ent.velocity[i]; - - trace = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, end, ent, mask); - - if (trace.allsolid) { // entity is trapped in another solid + numplanes= 0; + + time_left= time; + + ent.groundentity= null; + for (bumpcount= 0; bumpcount < numbumps; bumpcount++) + { + for (i= 0; i < 3; i++) + end[i]= ent.s.origin[i] + time_left * ent.velocity[i]; + + trace= GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, end, ent, mask); + + if (trace.allsolid) + { // entity is trapped in another solid Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity); return 3; } - - if (trace.fraction > 0) { // actually covered some distance + + if (trace.fraction > 0) + { // actually covered some distance Math3D.VectorCopy(trace.endpos, ent.s.origin); Math3D.VectorCopy(ent.velocity, original_velocity); - numplanes = 0; + numplanes= 0; } - + if (trace.fraction == 1) break; // moved the entire distance - - hit = trace.ent; - - if (trace.plane.normal[2] > 0.7) { + + hit= trace.ent; + + if (trace.plane.normal[2] > 0.7) + { blocked |= 1; // floor - if (hit.solid == Defines.SOLID_BSP) { - ent.groundentity = hit; - ent.groundentity_linkcount = hit.linkcount; + if (hit.solid == Defines.SOLID_BSP) + { + ent.groundentity= hit; + ent.groundentity_linkcount= hit.linkcount; } } - if (trace.plane.normal[2] == 0.0f) { + if (trace.plane.normal[2] == 0.0f) + { blocked |= 2; // step } - + // // run the impact function // SV_Impact(ent, trace); if (!ent.inuse) break; // removed by the impact function - + time_left -= time_left * trace.fraction; - + // cliped to another plane - if (numplanes >= GameBase.MAX_CLIP_PLANES) { // this shouldn't really happen + if (numplanes >= GameBase.MAX_CLIP_PLANES) + { // this shouldn't really happen Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity); return 3; } - + Math3D.VectorCopy(trace.plane.normal, planes[numplanes]); numplanes++; - + // // modify original_velocity so it parallels all of the clip planes // - for (i = 0; i < numplanes; i++) { + for (i= 0; i < numplanes; i++) + { GameBase.ClipVelocity(original_velocity, planes[i], new_velocity, 1); - - for (j = 0; j < numplanes; j++) - if ((j != i) && Math3D.VectorCompare(planes[i], planes[j]) == 0.0f) { + + for (j= 0; j < numplanes; j++) + if ((j != i) && Math3D.VectorCompare(planes[i], planes[j]) == 0.0f) + { if (Math3D.DotProduct(new_velocity, planes[j]) < 0) break; // not ok } if (j == numplanes) break; } - - if (i != numplanes) { // go along this plane + + if (i != numplanes) + { // go along this plane Math3D.VectorCopy(new_velocity, ent.velocity); - } else { // go along the crease - if (numplanes != 2) { + } + else + { // go along the crease + if (numplanes != 2) + { // gi.dprintf ("clip velocity, numplanes == %i\n",numplanes); Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity); return 7; } Math3D.CrossProduct(planes[0], planes[1], dir); - d = Math3D.DotProduct(dir, ent.velocity); + d= Math3D.DotProduct(dir, ent.velocity); Math3D.VectorScale(dir, d, ent.velocity); } - + // // if original velocity is against the original velocity, stop dead // to avoid tiny occilations in sloping corners // - if (Math3D.DotProduct(ent.velocity, primal_velocity) <= 0) { + if (Math3D.DotProduct(ent.velocity, primal_velocity) <= 0) + { Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity); return blocked; } } - + return blocked; } @@ -236,55 +257,61 @@ public final class SV { ============ */ - public static void SV_AddGravity(edict_t ent) { + public static void SV_AddGravity(edict_t ent) + { ent.velocity[2] -= ent.gravity * GameBase.sv_gravity.value * Defines.FRAMETIME; } /** * Does not change the entities velocity at all */ - public static trace_t SV_PushEntity(edict_t ent, float[] push) { + public static trace_t SV_PushEntity(edict_t ent, float[] push) + { trace_t trace; - float[] start = { 0, 0, 0 }; - float[] end = { 0, 0, 0 }; + float[] start= { 0, 0, 0 }; + float[] end= { 0, 0, 0 }; int mask; - + Math3D.VectorCopy(ent.s.origin, start); Math3D.VectorAdd(start, push, end); - + // FIXME: test this // a goto statement was replaced. - boolean retry; - - do { + boolean retry= false; + + do + { if (ent.clipmask != 0) - mask = ent.clipmask; + mask= ent.clipmask; else - mask = Defines.MASK_SOLID; - - trace = GameBase.gi.trace(start, ent.mins, ent.maxs, end, ent, mask); - + mask= Defines.MASK_SOLID; + + trace= GameBase.gi.trace(start, ent.mins, ent.maxs, end, ent, mask); + Math3D.VectorCopy(trace.endpos, ent.s.origin); GameBase.gi.linkentity(ent); - - retry = false; - if (trace.fraction != 1.0) { + + retry= false; + if (trace.fraction != 1.0) + { SV_Impact(ent, trace); - + // if the pushed entity went away and the pusher is still there - if (!trace.ent.inuse && ent.inuse) { + if (!trace.ent.inuse && ent.inuse) + { // move the pusher back and try again Math3D.VectorCopy(start, ent.s.origin); GameBase.gi.linkentity(ent); //goto retry; - retry = true; + retry= true; } } - } while (retry); - + } + while (retry); + if (ent.inuse) GameBase.G_TouchTriggers(ent); - + return trace; } @@ -296,61 +323,65 @@ public final class SV { otherwise riders would continue to slide. ============ */ - public static boolean SV_Push(edict_t pusher, float[] move, float[] amove) { + public static boolean SV_Push(edict_t pusher, float[] move, float[] amove) + { int i, e; edict_t check, block[]; - float[] mins = { 0, 0, 0 }; - float[] maxs = { 0, 0, 0 }; + float[] mins= { 0, 0, 0 }; + float[] maxs= { 0, 0, 0 }; pushed_t p; - float[] org = { 0, 0, 0 }; - float[] org2 = { 0, 0, 0 }; - float[] move2 = { 0, 0, 0 }; - float[] forward = { 0, 0, 0 }; - float[] right = { 0, 0, 0 }; - float[] up = { 0, 0, 0 }; - + float[] org= { 0, 0, 0 }; + float[] org2= { 0, 0, 0 }; + float[] move2= { 0, 0, 0 }; + float[] forward= { 0, 0, 0 }; + float[] right= { 0, 0, 0 }; + float[] up= { 0, 0, 0 }; + // clamp the move to 1/8 units, so the position will // be accurate for client side prediction - for (i = 0; i < 3; i++) { + for (i= 0; i < 3; i++) + { float temp; - temp = move[i] * 8.0f; + temp= move[i] * 8.0f; if (temp > 0.0) temp += 0.5; else temp -= 0.5; - move[i] = 0.125f * (int) temp; + move[i]= 0.125f * (int) temp; } - + // find the bounding box - for (i = 0; i < 3; i++) { - mins[i] = pusher.absmin[i] + move[i]; - maxs[i] = pusher.absmax[i] + move[i]; + for (i= 0; i < 3; i++) + { + mins[i]= pusher.absmin[i] + move[i]; + maxs[i]= pusher.absmax[i] + move[i]; } - + // we need this for pushing things later Math3D.VectorSubtract(GameBase.vec3_origin, amove, org); Math3D.AngleVectors(org, forward, right, up); - + // save the pusher's original position - GameBase.pushed[GameBase.pushed_p].ent = pusher; + GameBase.pushed[GameBase.pushed_p].ent= pusher; Math3D.VectorCopy(pusher.s.origin, GameBase.pushed[GameBase.pushed_p].origin); Math3D.VectorCopy(pusher.s.angles, GameBase.pushed[GameBase.pushed_p].angles); - + if (pusher.client != null) - GameBase.pushed[GameBase.pushed_p].deltayaw = pusher.client.ps.pmove.delta_angles[Defines.YAW]; - + GameBase.pushed[GameBase.pushed_p].deltayaw= pusher.client.ps.pmove.delta_angles[Defines.YAW]; + GameBase.pushed_p++; - + // move the pusher to it's final position Math3D.VectorAdd(pusher.s.origin, move, pusher.s.origin); Math3D.VectorAdd(pusher.s.angles, amove, pusher.s.angles); GameBase.gi.linkentity(pusher); - + // see if any solid entities are inside the final position - + //check= g_edicts + 1; - for (e = 1; e < GameBase.globals.num_edicts; e++) { - check = GameBase.g_edicts[e]; + for (e= 1; e < GameBase.globals.num_edicts; e++) + { + check= GameBase.g_edicts[e]; if (!check.inuse) continue; if (check.movetype == Defines.MOVETYPE_PUSH @@ -358,12 +389,13 @@ public final class SV { || check.movetype == Defines.MOVETYPE_NONE || check.movetype == Defines.MOVETYPE_NOCLIP) continue; - + if (check.area.prev == null) continue; // not linked in anywhere - + // if the entity is standing on the pusher, it will definitely be moved - if (check.groundentity != pusher) { + if (check.groundentity != pusher) + { // see if the ent needs to be tested if (check.absmin[0] >= maxs[0] || check.absmin[1] >= maxs[1] @@ -372,79 +404,85 @@ public final class SV { || check.absmax[1] <= mins[1] || check.absmax[2] <= mins[2]) continue; - + // see if the ent's bbox is inside the pusher's final position if (SV_TestEntityPosition(check) == null) continue; } - - if ((pusher.movetype == Defines.MOVETYPE_PUSH) || (check.groundentity == pusher)) { + + if ((pusher.movetype == Defines.MOVETYPE_PUSH) || (check.groundentity == pusher)) + { // move this entity - GameBase.pushed[GameBase.pushed_p].ent = check; + GameBase.pushed[GameBase.pushed_p].ent= check; Math3D.VectorCopy(check.s.origin, GameBase.pushed[GameBase.pushed_p].origin); Math3D.VectorCopy(check.s.angles, GameBase.pushed[GameBase.pushed_p].angles); GameBase.pushed_p++; - + // try moving the contacted entity Math3D.VectorAdd(check.s.origin, move, check.s.origin); - if (check.client != null) { // FIXME: doesn't rotate monsters? + if (check.client != null) + { // FIXME: doesn't rotate monsters? check.client.ps.pmove.delta_angles[Defines.YAW] += amove[Defines.YAW]; } - + // figure movement due to the pusher's amove Math3D.VectorSubtract(check.s.origin, pusher.s.origin, org); - org2[0] = Math3D.DotProduct(org, forward); - org2[1] = -Math3D.DotProduct(org, right); - org2[2] = Math3D.DotProduct(org, up); + org2[0]= Math3D.DotProduct(org, forward); + org2[1]= -Math3D.DotProduct(org, right); + org2[2]= Math3D.DotProduct(org, up); Math3D.VectorSubtract(org2, org, move2); Math3D.VectorAdd(check.s.origin, move2, check.s.origin); - + // may have pushed them off an edge if (check.groundentity != pusher) - check.groundentity = null; - - block = SV_TestEntityPosition(check); - if (block == null) { // pushed ok + check.groundentity= null; + + block= SV_TestEntityPosition(check); + if (block == null) + { // pushed ok GameBase.gi.linkentity(check); // impact? continue; } - + // if it is ok to leave in the old position, do it // this is only relevent for riding entities, not pushed // FIXME: this doesn't acount for rotation Math3D.VectorSubtract(check.s.origin, move, check.s.origin); - block = SV_TestEntityPosition(check); - - if (block == null) { + block= SV_TestEntityPosition(check); + + if (block == null) + { GameBase.pushed_p--; continue; } } - + // save off the obstacle so we can call the block function - GameBase.obstacle = check; - + GameBase.obstacle= check; + // move back any entities we already moved // go backwards, so if the same entity was pushed // twice, it goes back to the original position - for (int ip = GameBase.pushed_p - 1; ip >= 0; ip--) { - p = GameBase.pushed[ip]; + for (int ip= GameBase.pushed_p - 1; ip >= 0; ip--) + { + p= GameBase.pushed[ip]; Math3D.VectorCopy(p.origin, p.ent.s.origin); Math3D.VectorCopy(p.angles, p.ent.s.angles); - if (p.ent.client != null) { - p.ent.client.ps.pmove.delta_angles[Defines.YAW] = (short) p.deltayaw; + if (p.ent.client != null) + { + p.ent.client.ps.pmove.delta_angles[Defines.YAW]= (short) p.deltayaw; } GameBase.gi.linkentity(p.ent); } return false; } - + // FIXME: is there a better way to handle this? // see if anything we moved has touched a trigger - for (int ip = GameBase.pushed_p - 1; ip >= 0; ip--) + for (int ip= GameBase.pushed_p - 1; ip >= 0; ip--) GameBase.G_TouchTriggers(GameBase.pushed[ip].ent); - + return true; } @@ -456,57 +494,65 @@ public final class SV { push all box objects ================ */ - public static void SV_Physics_Pusher(edict_t ent) { - float[] move = { 0, 0, 0 }; - float[] amove = { 0, 0, 0 }; + public static void SV_Physics_Pusher(edict_t ent) + { + float[] move= { 0, 0, 0 }; + float[] amove= { 0, 0, 0 }; edict_t part, mv; - + // if not a team captain, so movement will be handled elsewhere if ((ent.flags & Defines.FL_TEAMSLAVE) != 0) return; - + // make sure all team slaves can move before commiting // any moves or calling any think functions // if the move is blocked, all moved objects will be backed out // retry: - GameBase.pushed_p = 0; - for (part = ent; part != null; part = part.teamchain) { + GameBase.pushed_p= 0; + for (part= ent; part != null; part= part.teamchain) + { if (part.velocity[0] != 0 || part.velocity[1] != 0 || part.velocity[2] != 0 || part.avelocity[0] != 0 || part.avelocity[1] != 0 - || part.avelocity[2] != 0) { // object is moving + || part.avelocity[2] != 0) + { // object is moving Math3D.VectorScale(part.velocity, Defines.FRAMETIME, move); Math3D.VectorScale(part.avelocity, Defines.FRAMETIME, amove); - + if (!SV_Push(part, move, amove)) break; // move was blocked } } if (GameBase.pushed_p > Defines.MAX_EDICTS) + SV_GAME.PF_error(Defines.ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted"); if (part != null) { // the move failed, bump all nextthink times and back out moves - for (mv = ent; mv != null; mv = mv.teamchain) { + for (mv= ent; mv != null; mv= mv.teamchain) + { if (mv.nextthink > 0) mv.nextthink += Defines.FRAMETIME; } - + // if the pusher has a "blocked" function, call it // otherwise, just stay in place until the obstacle is gone if (part.blocked != null) part.blocked.blocked(part, GameBase.obstacle); - } else { // the move succeeded, so call all think functions - for (part = ent; part != null; part = part.teamchain) { + } + else + { // the move succeeded, so call all think functions + for (part= ent; part != null; part= part.teamchain) + { SV_RunThink(part); } } } // ================================================================== - + /* ============= SV_Physics_None @@ -514,7 +560,8 @@ public final class SV { Non moving objects can only think ============= */ - public static void SV_Physics_None(edict_t ent) { + public static void SV_Physics_None(edict_t ent) + { // regular thinking SV_RunThink(ent); } @@ -526,14 +573,15 @@ public final class SV { A moving object that doesn't obey physics ============= */ - public static void SV_Physics_Noclip(edict_t ent) { + public static void SV_Physics_Noclip(edict_t ent) + { // regular thinking if (!SV_RunThink(ent)) return; - + Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles); Math3D.VectorMA(ent.s.origin, Defines.FRAMETIME, ent.velocity, ent.s.origin); - + GameBase.gi.linkentity(ent); } @@ -544,7 +592,7 @@ public final class SV { ============================================================================== */ - + /* ============= SV_Physics_Toss @@ -552,90 +600,96 @@ public final class SV { Toss, bounce, and fly movement. When onground, do nothing. ============= */ - public static void SV_Physics_Toss(edict_t ent) { + public static void SV_Physics_Toss(edict_t ent) + { + trace_t trace; - float[] move = { 0, 0, 0 }; + float[] move= { 0, 0, 0 }; float backoff; edict_t slave; boolean wasinwater; boolean isinwater; - float[] old_origin = { 0, 0, 0 }; - + float[] old_origin= { 0, 0, 0 }; + // regular thinking SV_RunThink(ent); - + // if not a team captain, so movement will be handled elsewhere if ((ent.flags & Defines.FL_TEAMSLAVE) != 0) return; - + if (ent.velocity[2] > 0) - ent.groundentity = null; - - // check for the groundentity going away + ent.groundentity= null; + + // check for the groundentity going away if (ent.groundentity != null) if (!ent.groundentity.inuse) - ent.groundentity = null; - + ent.groundentity= null; + // if onground, return without moving if (ent.groundentity != null) return; - + Math3D.VectorCopy(ent.s.origin, old_origin); - + SV_CheckVelocity(ent); - + // add gravity if (ent.movetype != Defines.MOVETYPE_FLY && ent.movetype != Defines.MOVETYPE_FLYMISSILE) SV_AddGravity(ent); - + // move angles Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles); - + // move origin Math3D.VectorScale(ent.velocity, Defines.FRAMETIME, move); - trace = SV_PushEntity(ent, move); + trace= SV_PushEntity(ent, move); if (!ent.inuse) return; - - if (trace.fraction < 1) { + + if (trace.fraction < 1) + { if (ent.movetype == Defines.MOVETYPE_BOUNCE) - backoff = 1.5f; + backoff= 1.5f; else - backoff = 1; - + backoff= 1; + GameBase.ClipVelocity(ent.velocity, trace.plane.normal, ent.velocity, backoff); - + // stop if on ground - if (trace.plane.normal[2] > 0.7) { - if (ent.velocity[2] < 60 || ent.movetype != Defines.MOVETYPE_BOUNCE) { - ent.groundentity = trace.ent; - ent.groundentity_linkcount = trace.ent.linkcount; + if (trace.plane.normal[2] > 0.7) + { + if (ent.velocity[2] < 60 || ent.movetype != Defines.MOVETYPE_BOUNCE) + { + ent.groundentity= trace.ent; + ent.groundentity_linkcount= trace.ent.linkcount; Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity); Math3D.VectorCopy(GameBase.vec3_origin, ent.avelocity); } } - + // if (ent.touch) // ent.touch (ent, trace.ent, &trace.plane, trace.surface); } - + // check for water transition - wasinwater = (ent.watertype & Defines.MASK_WATER) != 0; - ent.watertype = GameBase.gi.pointcontents.pointcontents(ent.s.origin); - isinwater = (ent.watertype & Defines.MASK_WATER) != 0; - + wasinwater= (ent.watertype & Defines.MASK_WATER) != 0; + ent.watertype= GameBase.gi.pointcontents.pointcontents(ent.s.origin); + isinwater= (ent.watertype & Defines.MASK_WATER) != 0; + if (isinwater) - ent.waterlevel = 1; + ent.waterlevel= 1; else - ent.waterlevel = 0; - + ent.waterlevel= 0; + if (!wasinwater && isinwater) GameBase.gi.positioned_sound(old_origin, ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/h2ohit1.wav"), 1, 1, 0); else if (wasinwater && !isinwater) GameBase.gi.positioned_sound(ent.s.origin, ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/h2ohit1.wav"), 1, 1, 0); - + // move teamslaves - for (slave = ent.teamchain; slave != null; slave = slave.teamchain) { + for (slave= ent.teamchain; slave != null; slave= slave.teamchain) + { Math3D.VectorCopy(ent.s.origin, slave.s.origin); GameBase.gi.linkentity(slave); } @@ -648,7 +702,7 @@ public final class SV { =============================================================================== */ - + /* ============= SV_Physics_Step @@ -661,128 +715,140 @@ public final class SV { FIXME: is this true? ============= */ - + // FIXME: hacked in for E3 demo - - public static void SV_AddRotationalFriction(edict_t ent) { + + public static void SV_AddRotationalFriction(edict_t ent) + { int n; float adjustment; - + Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles); - adjustment = Defines.FRAMETIME * Defines.sv_stopspeed * Defines.sv_friction; - for (n = 0; n < 3; n++) { - if (ent.avelocity[n] > 0) { + adjustment= Defines.FRAMETIME * Defines.sv_stopspeed * Defines.sv_friction; + for (n= 0; n < 3; n++) + { + if (ent.avelocity[n] > 0) + { ent.avelocity[n] -= adjustment; if (ent.avelocity[n] < 0) - ent.avelocity[n] = 0; - } else { + ent.avelocity[n]= 0; + } + else + { ent.avelocity[n] += adjustment; if (ent.avelocity[n] > 0) - ent.avelocity[n] = 0; + ent.avelocity[n]= 0; } } } - public static void SV_Physics_Step(edict_t ent) { + public static void SV_Physics_Step(edict_t ent) + { boolean wasonground; - boolean hitsound = false; + boolean hitsound= false; float vel[]; float speed, newspeed, control; float friction; edict_t groundentity; int mask; - + // airborn monsters should always check for ground if (ent.groundentity == null) M.M_CheckGround(ent); - - groundentity = ent.groundentity; - + + groundentity= ent.groundentity; + SV_CheckVelocity(ent); - + if (groundentity != null) - wasonground = true; + wasonground= true; else - wasonground = false; - + wasonground= false; + if (ent.avelocity[0] != 0 || ent.avelocity[1] != 0 || ent.avelocity[2] != 0) SV_AddRotationalFriction(ent); - + // add gravity except: // flying monsters // swimming monsters who are in the water if (!wasonground) if (0 == (ent.flags & Defines.FL_FLY)) - if (!((ent.flags & Defines.FL_SWIM) != 0 && (ent.waterlevel > 2))) { + if (!((ent.flags & Defines.FL_SWIM) != 0 && (ent.waterlevel > 2))) + { if (ent.velocity[2] < GameBase.sv_gravity.value * -0.1) - hitsound = true; + hitsound= true; if (ent.waterlevel == 0) SV_AddGravity(ent); } - + // friction for flying monsters that have been given vertical velocity - if ((ent.flags & Defines.FL_FLY) != 0 && (ent.velocity[2] != 0)) { - speed = Math.abs(ent.velocity[2]); - control = speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed; - friction = Defines.sv_friction / 3; - newspeed = speed - (Defines.FRAMETIME * control * friction); + if ((ent.flags & Defines.FL_FLY) != 0 && (ent.velocity[2] != 0)) + { + speed= Math.abs(ent.velocity[2]); + control= speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed; + friction= Defines.sv_friction / 3; + newspeed= speed - (Defines.FRAMETIME * control * friction); if (newspeed < 0) - newspeed = 0; + newspeed= 0; newspeed /= speed; ent.velocity[2] *= newspeed; } - + // friction for flying monsters that have been given vertical velocity - if ((ent.flags & Defines.FL_SWIM) != 0 && (ent.velocity[2] != 0)) { - speed = Math.abs(ent.velocity[2]); - control = speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed; - newspeed = speed - (Defines.FRAMETIME * control * Defines.sv_waterfriction * ent.waterlevel); + if ((ent.flags & Defines.FL_SWIM) != 0 && (ent.velocity[2] != 0)) + { + speed= Math.abs(ent.velocity[2]); + control= speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed; + newspeed= speed - (Defines.FRAMETIME * control * Defines.sv_waterfriction * ent.waterlevel); if (newspeed < 0) - newspeed = 0; + newspeed= 0; newspeed /= speed; ent.velocity[2] *= newspeed; } - - if (ent.velocity[2] != 0 || ent.velocity[1] != 0 || ent.velocity[0] != 0) { + + if (ent.velocity[2] != 0 || ent.velocity[1] != 0 || ent.velocity[0] != 0) + { // apply friction // let dead monsters who aren't completely onground slide if ((wasonground) || 0 != (ent.flags & (Defines.FL_SWIM | Defines.FL_FLY))) - if (!(ent.health <= 0.0 && !M.M_CheckBottom(ent))) { - vel = ent.velocity; - speed = (float) Math.sqrt(vel[0] * vel[0] + vel[1] * vel[1]); - if (speed != 0) { - friction = Defines.sv_friction; - - control = speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed; - newspeed = speed - Defines.FRAMETIME * control * friction; - + if (!(ent.health <= 0.0 && !M.M_CheckBottom(ent))) + { + vel= ent.velocity; + speed= (float) Math.sqrt(vel[0] * vel[0] + vel[1] * vel[1]); + if (speed != 0) + { + friction= Defines.sv_friction; + + control= speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed; + newspeed= speed - Defines.FRAMETIME * control * friction; + if (newspeed < 0) - newspeed = 0; + newspeed= 0; newspeed /= speed; - + vel[0] *= newspeed; vel[1] *= newspeed; } } - + if ((ent.svflags & Defines.SVF_MONSTER) != 0) - mask = Defines.MASK_MONSTERSOLID; + mask= Defines.MASK_MONSTERSOLID; else - mask = Defines.MASK_SOLID; - + mask= Defines.MASK_SOLID; + SV_FlyMove(ent, Defines.FRAMETIME, mask); - + GameBase.gi.linkentity(ent); GameBase.G_TouchTriggers(ent); if (!ent.inuse) return; - + if (ent.groundentity != null) if (!wasonground) if (hitsound) GameBase.gi.sound(ent, 0, GameBase.gi.soundindex("world/land.wav"), 1, 1, 0); } - + // regular thinking SV_RunThink(ent); } @@ -799,38 +865,45 @@ public final class SV { */ // FIXME since we need to test end position contents here, can we avoid doing // it again later in catagorize position? - public static boolean SV_movestep(edict_t ent, float[] move, boolean relink) { + public static boolean SV_movestep(edict_t ent, float[] move, boolean relink) + { float dz; - float[] oldorg = { 0, 0, 0 }; - float[] neworg = { 0, 0, 0 }; - float[] end = { 0, 0, 0 }; - - trace_t trace = null;// = new trace_t(); + float[] oldorg= { 0, 0, 0 }; + float[] neworg= { 0, 0, 0 }; + float[] end= { 0, 0, 0 }; + + trace_t trace= null; // = new trace_t(); int i; float stepsize; - float[] test = { 0, 0, 0 }; + float[] test= { 0, 0, 0 }; int contents; - + // try the move Math3D.VectorCopy(ent.s.origin, oldorg); Math3D.VectorAdd(ent.s.origin, move, neworg); - + // flying monsters don't step up - if ((ent.flags & (Defines.FL_SWIM | Defines.FL_FLY)) != 0) { + if ((ent.flags & (Defines.FL_SWIM | Defines.FL_FLY)) != 0) + { // try one move with vertical motion, then one without - for (i = 0; i < 2; i++) { + for (i= 0; i < 2; i++) + { Math3D.VectorAdd(ent.s.origin, move, neworg); - if (i == 0 && ent.enemy != null) { + if (i == 0 && ent.enemy != null) + { if (ent.goalentity == null) - ent.goalentity = ent.enemy; - dz = ent.s.origin[2] - ent.goalentity.s.origin[2]; - if (ent.goalentity.client != null) { + ent.goalentity= ent.enemy; + dz= ent.s.origin[2] - ent.goalentity.s.origin[2]; + if (ent.goalentity.client != null) + { if (dz > 40) neworg[2] -= 8; if (!((ent.flags & Defines.FL_SWIM) != 0 && (ent.waterlevel < 2))) if (dz < 30) neworg[2] += 8; - } else { + } + else + { if (dz > 8) neworg[2] -= 8; else if (dz > 0) @@ -841,104 +914,118 @@ public final class SV { neworg[2] += dz; } } - trace = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, neworg, ent, Defines.MASK_MONSTERSOLID); - + trace= GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, neworg, ent, Defines.MASK_MONSTERSOLID); + // fly monsters don't enter water voluntarily - if ((ent.flags & Defines.FL_FLY) != 0) { - if (ent.waterlevel == 0) { - test[0] = trace.endpos[0]; - test[1] = trace.endpos[1]; - test[2] = trace.endpos[2] + ent.mins[2] + 1; - contents = GameBase.gi.pointcontents.pointcontents(test); + if ((ent.flags & Defines.FL_FLY) != 0) + { + if (ent.waterlevel == 0) + { + test[0]= trace.endpos[0]; + test[1]= trace.endpos[1]; + test[2]= trace.endpos[2] + ent.mins[2] + 1; + contents= GameBase.gi.pointcontents.pointcontents(test); if ((contents & Defines.MASK_WATER) != 0) return false; } } - + // swim monsters don't exit water voluntarily - if ((ent.flags & Defines.FL_SWIM) != 0) { - if (ent.waterlevel < 2) { - test[0] = trace.endpos[0]; - test[1] = trace.endpos[1]; - test[2] = trace.endpos[2] + ent.mins[2] + 1; - contents = GameBase.gi.pointcontents.pointcontents(test); + if ((ent.flags & Defines.FL_SWIM) != 0) + { + if (ent.waterlevel < 2) + { + test[0]= trace.endpos[0]; + test[1]= trace.endpos[1]; + test[2]= trace.endpos[2] + ent.mins[2] + 1; + contents= GameBase.gi.pointcontents.pointcontents(test); if ((contents & Defines.MASK_WATER) == 0) return false; } } - - if (trace.fraction == 1) { + + if (trace.fraction == 1) + { Math3D.VectorCopy(trace.endpos, ent.s.origin); - if (relink) { + if (relink) + { GameBase.gi.linkentity(ent); GameBase.G_TouchTriggers(ent); } return true; } - + if (ent.enemy == null) break; } - + return false; } - + // push down from a step height above the wished position if ((ent.monsterinfo.aiflags & Defines.AI_NOSTEP) == 0) - stepsize = GameBase.STEPSIZE; + stepsize= GameBase.STEPSIZE; else - stepsize = 1; - + stepsize= 1; + neworg[2] += stepsize; Math3D.VectorCopy(neworg, end); end[2] -= stepsize * 2; - - trace = GameBase.gi.trace(neworg, ent.mins, ent.maxs, end, ent, Defines.MASK_MONSTERSOLID); - + + trace= GameBase.gi.trace(neworg, ent.mins, ent.maxs, end, ent, Defines.MASK_MONSTERSOLID); + if (trace.allsolid) return false; - - if (trace.startsolid) { + + if (trace.startsolid) + { neworg[2] -= stepsize; - trace = GameBase.gi.trace(neworg, ent.mins, ent.maxs, end, ent, Defines.MASK_MONSTERSOLID); + trace= GameBase.gi.trace(neworg, ent.mins, ent.maxs, end, ent, Defines.MASK_MONSTERSOLID); if (trace.allsolid || trace.startsolid) return false; } - + // don't go in to water - if (ent.waterlevel == 0) { - test[0] = trace.endpos[0]; - test[1] = trace.endpos[1]; - test[2] = trace.endpos[2] + ent.mins[2] + 1; - contents = GameBase.gi.pointcontents.pointcontents(test); - + if (ent.waterlevel == 0) + { + test[0]= trace.endpos[0]; + test[1]= trace.endpos[1]; + test[2]= trace.endpos[2] + ent.mins[2] + 1; + contents= GameBase.gi.pointcontents.pointcontents(test); + if ((contents & Defines.MASK_WATER) != 0) return false; } - - if (trace.fraction == 1) { + + if (trace.fraction == 1) + { // if monster had the ground pulled out, go ahead and fall - if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) { + if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) + { Math3D.VectorAdd(ent.s.origin, move, ent.s.origin); - if (relink) { + if (relink) + { GameBase.gi.linkentity(ent); GameBase.G_TouchTriggers(ent); } - ent.groundentity = null; + ent.groundentity= null; return true; } - + return false; // walked off an edge } - + // check point traces down for dangling corners Math3D.VectorCopy(trace.endpos, ent.s.origin); - - if (!M.M_CheckBottom(ent)) { - if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) { + + if (!M.M_CheckBottom(ent)) + { + if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) + { // entity had floor mostly pulled out from underneath it // and is trying to correct - if (relink) { + if (relink) + { GameBase.gi.linkentity(ent); GameBase.G_TouchTriggers(ent); } @@ -947,15 +1034,17 @@ public final class SV { Math3D.VectorCopy(oldorg, ent.s.origin); return false; } - - if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) { + + if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) + { ent.flags &= ~Defines.FL_PARTIALGROUND; } - ent.groundentity = trace.ent; - ent.groundentity_linkcount = trace.ent.linkcount; - + ent.groundentity= trace.ent; + ent.groundentity_linkcount= trace.ent.linkcount; + // the move is ok - if (relink) { + if (relink) + { GameBase.gi.linkentity(ent); GameBase.G_TouchTriggers(ent); } @@ -971,23 +1060,26 @@ public final class SV { ====================== */ - public static boolean SV_StepDirection(edict_t ent, float yaw, float dist) { - float[] move = { 0, 0, 0 }; - float[] oldorigin = { 0, 0, 0 }; + public static boolean SV_StepDirection(edict_t ent, float yaw, float dist) + { + float[] move= { 0, 0, 0 }; + float[] oldorigin= { 0, 0, 0 }; float delta; - - ent.ideal_yaw = yaw; + + ent.ideal_yaw= yaw; M.M_ChangeYaw(ent); - - yaw = (float) (yaw * Math.PI * 2 / 360); - move[0] = (float) Math.cos(yaw) * dist; - move[1] = (float) Math.sin(yaw) * dist; - move[2] = 0; - + + yaw= (float) (yaw * Math.PI * 2 / 360); + move[0]= (float) Math.cos(yaw) * dist; + move[1]= (float) Math.sin(yaw) * dist; + move[2]= 0; + Math3D.VectorCopy(ent.s.origin, oldorigin); - if (SV_movestep(ent, move, false)) { - delta = ent.s.angles[Defines.YAW] - ent.ideal_yaw; - if (delta > 45 && delta < 315) { // not turned far enough, so don't take the step + if (SV_movestep(ent, move, false)) + { + delta= ent.s.angles[Defines.YAW] - ent.ideal_yaw; + if (delta > 45 && delta < 315) + { // not turned far enough, so don't take the step Math3D.VectorCopy(oldorigin, ent.s.origin); } GameBase.gi.linkentity(ent); @@ -1005,86 +1097,93 @@ public final class SV { ====================== */ - public static void SV_FixCheckBottom(edict_t ent) { + public static void SV_FixCheckBottom(edict_t ent) + { ent.flags |= Defines.FL_PARTIALGROUND; } - public static void SV_NewChaseDir(edict_t actor, edict_t enemy, float dist) { + public static void SV_NewChaseDir(edict_t actor, edict_t enemy, float dist) + { float deltax, deltay; - float d[] = { 0, 0, 0 }; + float d[]= { 0, 0, 0 }; float tdir, olddir, turnaround; - + //FIXME: how did we get here with no enemy if (enemy == null) { Com.DPrintf("SV_NewChaseDir without enemy!\n"); return; } - olddir = Math3D.anglemod((int) (actor.ideal_yaw / 45) * 45); - turnaround = Math3D.anglemod(olddir - 180); - - deltax = enemy.s.origin[0] - actor.s.origin[0]; - deltay = enemy.s.origin[1] - actor.s.origin[1]; + olddir= Math3D.anglemod((int) (actor.ideal_yaw / 45) * 45); + turnaround= Math3D.anglemod(olddir - 180); + + deltax= enemy.s.origin[0] - actor.s.origin[0]; + deltay= enemy.s.origin[1] - actor.s.origin[1]; if (deltax > 10) - d[1] = 0; + d[1]= 0; else if (deltax < -10) - d[1] = 180; + d[1]= 180; else - d[1] = GameBase.DI_NODIR; + d[1]= GameBase.DI_NODIR; if (deltay < -10) - d[2] = 270; + d[2]= 270; else if (deltay > 10) - d[2] = 90; + d[2]= 90; else - d[2] = GameBase.DI_NODIR; - + d[2]= GameBase.DI_NODIR; + // try direct route - if (d[1] != GameBase.DI_NODIR && d[2] != GameBase.DI_NODIR) { + if (d[1] != GameBase.DI_NODIR && d[2] != GameBase.DI_NODIR) + { if (d[1] == 0) - tdir = d[2] == 90 ? 45 : 315; + tdir= d[2] == 90 ? 45 : 315; else - tdir = d[2] == 90 ? 135 : 215; - + tdir= d[2] == 90 ? 135 : 215; + if (tdir != turnaround && SV_StepDirection(actor, tdir, dist)) return; } - + // try other directions - if (((Lib.rand() & 3) & 1) != 0 || Math.abs(deltay) > Math.abs(deltax)) { - tdir = d[1]; - d[1] = d[2]; - d[2] = tdir; + if (((Lib.rand() & 3) & 1) != 0 || Math.abs(deltay) > Math.abs(deltax)) + { + tdir= d[1]; + d[1]= d[2]; + d[2]= tdir; } - + if (d[1] != GameBase.DI_NODIR && d[1] != turnaround && SV_StepDirection(actor, d[1], dist)) return; - + if (d[2] != GameBase.DI_NODIR && d[2] != turnaround && SV_StepDirection(actor, d[2], dist)) return; - + /* there is no direct path to the player, so pick another direction */ - + if (olddir != GameBase.DI_NODIR && SV_StepDirection(actor, olddir, dist)) return; - - if ((Lib.rand() & 1) != 0) /*randomly determine direction of search*/ { - for (tdir = 0; tdir <= 315; tdir += 45) + + if ((Lib.rand() & 1) != 0) /*randomly determine direction of search*/ + { + for (tdir= 0; tdir <= 315; tdir += 45) if (tdir != turnaround && SV_StepDirection(actor, tdir, dist)) return; - } else { - for (tdir = 315; tdir >= 0; tdir -= 45) + } + else + { + for (tdir= 315; tdir >= 0; tdir -= 45) if (tdir != turnaround && SV_StepDirection(actor, tdir, dist)) return; } - + if (turnaround != GameBase.DI_NODIR && SV_StepDirection(actor, turnaround, dist)) return; - - actor.ideal_yaw = olddir; // can't move - + + actor.ideal_yaw= olddir; // can't move + // if a bridge was pulled out from underneath a monster, it may not have // a valid standing position at all - + if (!M.M_CheckBottom(actor)) SV_FixCheckBottom(actor); } @@ -1094,11 +1193,13 @@ public final class SV { SV_CloseEnough ====================== - *///ok - public static boolean SV_CloseEnough(edict_t ent, edict_t goal, float dist) { + */ //ok + public static boolean SV_CloseEnough(edict_t ent, edict_t goal, float dist) + { int i; - - for (i = 0; i < 3; i++) { + + for (i= 0; i < 3; i++) + { if (goal.absmin[i] > ent.absmax[i] + dist) return false; if (goal.absmax[i] < ent.absmin[i] - dist) diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java index 105e156..a5b509f 100644 --- a/src/jake2/server/SV_CCMDS.java +++ b/src/jake2/server/SV_CCMDS.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.01.2004 by RST. -// $Id: SV_CCMDS.java,v 1.5 2004-07-23 10:09:01 hzi Exp $ +// $Id: SV_CCMDS.java,v 1.6 2004-08-20 21:29:57 salomo Exp $ package jake2.server; @@ -29,12 +29,14 @@ import jake2.qcommon.*; import jake2.sys.NET; import jake2.sys.Sys; import jake2.util.Lib; +import jake2.util.QuakeFile; import jake2.util.Vargs; import java.io.*; import java.util.Calendar; -public class SV_CCMDS extends SV_ENTS { +public class SV_CCMDS extends SV_ENTS +{ /* =============================================================================== @@ -52,11 +54,13 @@ public class SV_CCMDS extends SV_ENTS { Specify a list of master servers ==================== */ - public static void SV_SetMaster_f() { + public static void SV_SetMaster_f() + { int i, slot; // only dedicated servers send heartbeats - if (dedicated.value == 0) { + if (dedicated.value == 0) + { Com.Printf("Only dedicated servers use masters.\n"); return; } @@ -64,21 +68,23 @@ public class SV_CCMDS extends SV_ENTS { // make sure the server is listed public Cvar.Set("public", "1"); - for (i = 1; i < MAX_MASTERS; i++) + for (i= 1; i < MAX_MASTERS; i++) //memset (&master_adr[i], 0, sizeof(master_adr[i])); - master_adr[i] = new netadr_t(); + master_adr[i]= new netadr_t(); - slot = 1; // slot 0 will always contain the id master - for (i = 1; i < Cmd.Argc(); i++) { + slot= 1; // slot 0 will always contain the id master + for (i= 1; i < Cmd.Argc(); i++) + { if (slot == MAX_MASTERS) break; - if (!NET.StringToAdr(Cmd.Argv(i), master_adr[i])) { + if (!NET.StringToAdr(Cmd.Argv(i), master_adr[i])) + { Com.Printf("Bad address: " + Cmd.Argv(i) + "\n"); continue; } if (master_adr[slot].port == 0) - master_adr[slot].port = //BigShort (PORT_MASTER); + master_adr[slot].port= //BigShort (PORT_MASTER); PORT_MASTER; Com.Printf("Master server at " + NET.AdrToString(master_adr[slot]) + "\n"); @@ -90,7 +96,7 @@ public class SV_CCMDS extends SV_ENTS { slot++; } - svs.last_heartbeat = -9999999; + svs.last_heartbeat= -9999999; } /* @@ -100,7 +106,8 @@ public class SV_CCMDS extends SV_ENTS { Sets sv_client and sv_player to the player with idnum Cmd.Argv(1) ================== */ - public static boolean SV_SetPlayer() { + public static boolean SV_SetPlayer() + { client_t cl; int i; int idnum; @@ -109,19 +116,22 @@ public class SV_CCMDS extends SV_ENTS { if (Cmd.Argc() < 2) return false; - s = Cmd.Argv(1); + s= Cmd.Argv(1); // numeric values are just slot numbers - if (s.charAt(0) >= '0' && s.charAt(0) <= '9') { - idnum = atoi(Cmd.Argv(1)); - if (idnum < 0 || idnum >= maxclients.value) { + if (s.charAt(0) >= '0' && s.charAt(0) <= '9') + { + idnum= atoi(Cmd.Argv(1)); + if (idnum < 0 || idnum >= maxclients.value) + { Com.Printf("Bad client slot: " + idnum + "\n"); return false; } - sv_client = svs.clients[idnum]; - sv_player = sv_client.edict; - if (0 == sv_client.state) { + sv_client= svs.clients[idnum]; + sv_player= sv_client.edict; + if (0 == sv_client.state) + { Com.Printf("Client " + idnum + " is not active\n"); return false; } @@ -129,13 +139,15 @@ public class SV_CCMDS extends SV_ENTS { } // check for a name match - for (i = 0; i < maxclients.value; i++) { - cl = svs.clients[i]; + for (i= 0; i < maxclients.value; i++) + { + cl= svs.clients[i]; if (0 == cl.state) continue; - if (0 == strcmp(cl.name, s)) { - sv_client = cl; - sv_player = sv_client.edict; + if (0 == strcmp(cl.name, s)) + { + sv_client= cl; + sv_player= sv_client.edict; return true; } } @@ -152,11 +164,14 @@ public class SV_CCMDS extends SV_ENTS { =============================================================================== */ - public static void remove(String name) { - try { + public static void remove(String name) + { + try + { new File(name).delete(); } - catch (Exception e) { + catch (Exception e) + { } } @@ -167,7 +182,8 @@ public class SV_CCMDS extends SV_ENTS { Delete save// ===================== */ - public static void SV_WipeSavegame(String savename) { + public static void SV_WipeSavegame(String savename) + { //char name[MAX_OSPATH]; //char *s; @@ -175,28 +191,30 @@ public class SV_CCMDS extends SV_ENTS { Com.DPrintf("SV_WipeSaveGame(" + savename + ")\n"); - name = FS.Gamedir() + "/save/" + savename + "/server.ssv"; + name= FS.Gamedir() + "/save/" + savename + "/server.ssv"; remove(name); - name = FS.Gamedir() + "/save/" + savename + "/game.ssv"; + name= FS.Gamedir() + "/save/" + savename + "/game.ssv"; remove(name); - name = FS.Gamedir() + "/save/" + savename + "/*.sav"; + name= FS.Gamedir() + "/save/" + savename + "/*.sav"; - File f = Sys.FindFirst(name, 0, 0); - while (f != null) { + File f= Sys.FindFirst(name, 0, 0); + while (f != null) + { f.delete(); - f = Sys.FindNext(); + f= Sys.FindNext(); } Sys.FindClose(); - name = FS.Gamedir() + "/save/" + savename + "/*.sv2"; + name= FS.Gamedir() + "/save/" + savename + "/*.sv2"; - f = Sys.FindFirst(name, 0, 0); + f= Sys.FindFirst(name, 0, 0); - while (f != null) { + while (f != null) + { f.delete(); - f = Sys.FindNext(); + f= Sys.FindNext(); } Sys.FindClose(); } @@ -206,64 +224,80 @@ public class SV_CCMDS extends SV_ENTS { CopyFile ================ */ - public static void CopyFile(String src, String dst) { + public static void CopyFile(String src, String dst) + { RandomAccessFile f1, f2; - int l = -1; - byte buffer[] = new byte[65536]; + int l= -1; + byte buffer[]= new byte[65536]; Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n"); - - try { - f1 = new RandomAccessFile(src, "r"); + System.out.println("CopyFile (" + src + ", " + dst + ")\n"); + try + { + f1= new RandomAccessFile(src, "r"); } - catch (Exception e) { + catch (Exception e) + { return; } - try { + try + { - f2 = new RandomAccessFile(dst, "rw"); + f2= new RandomAccessFile(dst, "rw"); } - catch (Exception e) { - try { + catch (Exception e) + { + try + { f1.close(); } - catch (IOException e1) { + catch (IOException e1) + { e1.printStackTrace(); } return; } - while (true) { + while (true) + { - try { - l = f1.read(buffer, 0, 65536); + try + { + l= f1.read(buffer, 0, 65536); } - catch (IOException e1) { + catch (IOException e1) + { e1.printStackTrace(); } if (l == -1) break; - try { + try + { f2.write(buffer, 0, l); } - catch (IOException e2) { + catch (IOException e2) + { e2.printStackTrace(); } } - try { + try + { f1.close(); } - catch (IOException e1) { + catch (IOException e1) + { e1.printStackTrace(); } - try { + try + { f2.close(); } - catch (IOException e2) { + catch (IOException e2) + { e2.printStackTrace(); } @@ -274,7 +308,8 @@ public class SV_CCMDS extends SV_ENTS { SV_CopySaveGame ================ */ - public static void SV_CopySaveGame(String src, String dst) { + public static void SV_CopySaveGame(String src, String dst) + { //char name[MAX_OSPATH], name2[MAX_OSPATH]; int l, len; File found; @@ -286,24 +321,26 @@ public class SV_CCMDS extends SV_ENTS { SV_WipeSavegame(dst); // copy the savegame over - name = FS.Gamedir() + "/save/" + src + "/server.ssv"; - name2 = FS.Gamedir() + "/save/" + dst + "/server.ssv"; + name= FS.Gamedir() + "/save/" + src + "/server.ssv"; + name2= FS.Gamedir() + "/save/" + dst + "/server.ssv"; FS.CreatePath(name2); CopyFile(name, name2); - name = FS.Gamedir() + "/save/" + src + "/game.ssv"; - name2 = "/save/" + dst + "/game.ssv"; + name= FS.Gamedir() + "/save/" + src + "/game.ssv"; + name2= FS.Gamedir() + "/save/" + dst + "/game.ssv"; CopyFile(name, name2); - String name1 = FS.Gamedir() + "/save/" + src + "/"; - len = name1.length(); - name = FS.Gamedir() + "/save/" + src + "/*.sav"; + String name1= FS.Gamedir() + "/save/" + src + "/"; + len= name1.length(); + name= FS.Gamedir() + "/save/" + src + "/*.sav"; - found = Sys.FindFirst(name, 0, 0); + found= Sys.FindFirst(name, 0, 0); - while (found != null) { - name = name1 + '/' + found.getName(); - name2 = FS.Gamedir() + "/save/" + dst + "/" + found.getName(); + while (found != null) + { + name= name1 + found.getName(); + name2= FS.Gamedir() + "/save/" + dst + "/" + found.getName(); + CopyFile(name, name2); // change sav to sv2 @@ -311,12 +348,12 @@ public class SV_CCMDS extends SV_ENTS { //strcpy(name + l - 3, "sv2"); //l = strlen(name2); //strcpy(name2 + l - 3, "sv2"); - name = name.substring(0, name.length() - 3) + "sv2"; - name2 = name.substring(0, name2.length() - 3) + "sv2"; + name= name.substring(0, name.length() - 3) + "sv2"; + name2= name2.substring(0, name2.length() - 3) + "sv2"; CopyFile(name, name2); - found = Sys.FindNext(); + found= Sys.FindNext(); } Sys.FindClose(); } @@ -327,38 +364,33 @@ public class SV_CCMDS extends SV_ENTS { ============== */ - public static void SV_WriteLevelFile() { - //char name[MAX_OSPATH]; - //FILE * f; + public static void SV_WriteLevelFile() + { String name; - RandomAccessFile f; + QuakeFile f; Com.DPrintf("SV_WriteLevelFile()\n"); - name = FS.Gamedir() + "/save/current/" + sv.name + ".sv2"; + name= FS.Gamedir() + "/save/current/" + sv.name + ".sv2"; - try { - f = new RandomAccessFile(name, "rw"); - } - catch (Exception e) { - Com.Printf("Failed to open " + name + "\n"); - return; - } - try { - //fwrite(sv.configstrings, sizeof(sv.configstrings), 1, f); - for (int i = 0; i < sv.configstrings.length; i++) - Lib.fwriteString(sv.configstrings[i], MAX_QPATH, f); + try + { + f= new QuakeFile(name, "rw"); + + for (int i= 0; i < MAX_CONFIGSTRINGS; i++) + f.writeString(sv.configstrings[i]); CM.CM_WritePortalState(f); f.close(); } - catch (Exception e) { - Com.Printf("IOError in SV_WriteLevelFile: " + e); + catch (Exception e) + { + Com.Printf("Failed to open " + name + "\n"); e.printStackTrace(); } - name = FS.Gamedir() + "/save/current/" + sv.name + ".sav"; + name= FS.Gamedir() + "/save/current/" + sv.name + ".sav"; ge.WriteLevel(name); } @@ -368,36 +400,35 @@ public class SV_CCMDS extends SV_ENTS { ============== */ - public static void SV_ReadLevelFile() { + public static void SV_ReadLevelFile() + { //char name[MAX_OSPATH]; String name; - RandomAccessFile f; + QuakeFile f; Com.DPrintf("SV_ReadLevelFile()\n"); - name = FS.Gamedir() + "/save/current/" + sv.name + ".sv2"; - try { - f = new RandomAccessFile(name, "r"); - } - catch (Exception e) { - Com.Printf("Failed to open " + name + "\n"); - return; - } - // FS.Read(sv.configstrings, sizeof(sv.configstrings), f); - for (int n = 0; n < MAX_CONFIGSTRINGS; n++) - sv.configstrings[n] = Lib.freadString(f, MAX_QPATH); + name= FS.Gamedir() + "/save/current/" + sv.name + ".sv2"; + try + { + f= new QuakeFile(name, "r"); - CM.CM_ReadPortalState(f); + for (int n= 0; n < MAX_CONFIGSTRINGS; n++) + sv.configstrings[n]= f.readString(); + + CM.CM_ReadPortalState(f); - try { f.close(); } - catch (IOException e1) { + catch (IOException e1) + { + Com.Printf("Failed to open " + name + "\n"); e1.printStackTrace(); } - name = FS.Gamedir() + "/save/current/" + sv.name + ".sav"; + name= FS.Gamedir() + "/save/current/" + sv.name + ".sav"; ge.ReadLevel(name); + System.out.println("all done!"); } /* @@ -406,83 +437,77 @@ public class SV_CCMDS extends SV_ENTS { ============== */ - public static void SV_WriteServerFile(boolean autosave) { - RandomAccessFile f; + public static void SV_WriteServerFile(boolean autosave) + { + QuakeFile f; cvar_t var; - //char name[MAX_OSPATH], string[128]; - //char comment[32]; - //time_t aclock; - //struct tm * newtime; - String name, string, comment; + + String filename, name, string, comment; Com.DPrintf("SV_WriteServerFile(" + (autosave ? "true" : "false") + ")\n"); - name = FS.Gamedir() + "/save/current/server.ssv"; - try { - f = new RandomAccessFile(name, "rw"); - } catch (FileNotFoundException e) { - f = null; - } - if (f == null) { - Com.Printf("Couldn't write " + name + "\n"); - return; - } - // write the comment field - //memset(comment, 0, sizeof(comment)); - - if (!autosave) { - //time( aclock); - //newtime = localtime( aclock); - Calendar c = Calendar.getInstance(); - comment = - Com.sprintf( - "%2i:%2i %2i/%2i ", - new Vargs() - .add(c.get(Calendar.HOUR_OF_DAY)) - .add(c.get(Calendar.MINUTE)) - .add(c.get(Calendar.MONTH) + 1) - .add(c.get(Calendar.DAY_OF_MONTH))); - comment += sv.configstrings[CS_NAME]; - } - else { // autosaved - comment = "ENTERING " + sv.configstrings[CS_NAME]; - } + filename= FS.Gamedir() + "/save/current/server.ssv"; + try + { + f= new QuakeFile(filename, "rw"); + + if (!autosave) + { + Calendar c= Calendar.getInstance(); + comment= + Com.sprintf( + "%2i:%2i %2i/%2i ", + new Vargs().add(c.get(Calendar.HOUR_OF_DAY)).add(c.get(Calendar.MINUTE)).add(c.get(Calendar.MONTH) + 1).add( + c.get(Calendar.DAY_OF_MONTH))); + comment += sv.configstrings[CS_NAME]; + } + else + { + // autosaved + comment= "ENTERING " + sv.configstrings[CS_NAME]; + } - try { - fwriteString(comment, 32, f); - fwriteString(svs.mapcmd, MAX_TOKEN_CHARS, f); + f.writeString(comment); + f.writeString(svs.mapcmd); + + // write the mapcmd + + // write all CVAR_LATCH cvars + // these will be things like coop, skill, deathmatch, etc + for (var= Globals.cvar_vars; var != null; var= var.next) + { + if (0 == (var.flags & CVAR_LATCH)) + continue; + if (var.name.length() >= MAX_OSPATH - 1 || var.string.length() >= 128 - 1) + { + Com.Printf("Cvar too long: " + var.name + " = " + var.string + "\n"); + continue; + } - } catch (IOException e1) {} + name= var.name; + string= var.string; + try + { + f.writeString(name); + f.writeString(string); + } + catch (IOException e2) + { + } - // write the mapcmd - - // write all CVAR_LATCH cvars - // these will be things like coop, skill, deathmatch, etc - for (var = Globals.cvar_vars; var != null; var = var.next) { - if (0 == (var.flags & CVAR_LATCH)) - continue; - if (var.name.length() >= MAX_OSPATH - 1 || var.string.length() >= 128 - 1) { - Com.Printf("Cvar too long: " + var.name + " = " + var.string + "\n"); - continue; } - //memset(name, 0, sizeof(name)); - //memset(string, 0, sizeof(string)); - name = var.name; - string = var.string; - try { - fwriteString(name, MAX_OSPATH, f); - fwriteString(string, 128, f); - } catch (IOException e2) {} - - } - - try { + // rst: for termination. + f.writeString(null); f.close(); - } catch (IOException e2) {} + } + catch (Exception e) + { + Com.Printf("Couldn't write " + filename + "\n"); + } // write game state - name = FS.Gamedir() + "/save/current/game.ssv"; - ge.WriteGame(name, autosave); + filename= FS.Gamedir() + "/save/current/game.ssv"; + ge.WriteGame(filename, autosave); } /* @@ -491,58 +516,59 @@ public class SV_CCMDS extends SV_ENTS { ============== */ - public static void SV_ReadServerFile() { - RandomAccessFile f; - //char name[MAX_OSPATH], string[128]; - //char comment[32]; - //char mapcmd[MAX_TOKEN_CHARS]; + public static void SV_ReadServerFile() + { + String filename, name= "", string, comment, mapcmd; + try + { + QuakeFile f; - String name, string, comment, mapcmd; + mapcmd= ""; - Com.DPrintf("SV_ReadServerFile()\n"); + Com.DPrintf("SV_ReadServerFile()\n"); - name = FS.Gamedir() + "/save/current/server.ssv"; - try { - f = new RandomAccessFile(name, "r"); - } - catch (FileNotFoundException e1) { - Com.Printf("Couldn't read " + name + "\n"); - e1.printStackTrace(); - return; - } - // read the comment field - comment = Lib.freadString(f, 32); - - // read the mapcmd - mapcmd = Lib.freadString(f, MAX_TOKEN_CHARS); - - // read all CVAR_LATCH cvars - // these will be things like coop, skill, deathmatch, etc - while (true) { - name = Lib.freadString(f, MAX_OSPATH); - //if (!fread(name, 1, sizeof(name), f)) - if (name == null) - break; - string = Lib.freadString(f, 128); - Com.DPrintf("Set " + name + " = " + string + "\n"); - Cvar.ForceSet(name, string); - } + filename= FS.Gamedir() + "/save/current/server.ssv"; + + f= new QuakeFile(filename, "r"); + + // read the comment field + + comment= f.readString(); + + // read the mapcmd + + mapcmd= f.readString(); + + // read all CVAR_LATCH cvars + // these will be things like coop, skill, deathmatch, etc + while (true) + { + name= f.readString(); + if (name == null) + break; + string= f.readString(); + + Com.DPrintf("Set " + name + " = " + string + "\n"); + Cvar.ForceSet(name, string); + } - try { f.close(); - } - catch (IOException e) { - e.printStackTrace(); - } - // start a new game fresh with new cvars - SV_InitGame(); + // start a new game fresh with new cvars + SV_InitGame(); - svs.mapcmd = mapcmd; + svs.mapcmd= mapcmd; - // read game state - name = FS.Gamedir() + "/save/current/game.ssv"; - ge.ReadGame(name); + // read game state + filename= FS.Gamedir() + "/save/current/game.ssv"; + ge.ReadGame(filename); + } + catch (Exception e) + { + Com.Printf("Couldn't read file " + name + "\n"); + System.err.println(e); + e.printStackTrace(); + } } //========================================================= @@ -554,7 +580,8 @@ public class SV_CCMDS extends SV_ENTS { Puts the server in demo mode on a specific map/cinematic ================== */ - public static void SV_DemoMap_f() { + public static void SV_DemoMap_f() + { SV_Map(true, Cmd.Argv(1), false); } @@ -576,13 +603,15 @@ public class SV_CCMDS extends SV_ENTS { goes to map jail.bsp. ================== */ - public static void SV_GameMap_f() { + public static void SV_GameMap_f() + { String map; int i; client_t cl; boolean savedInuse[]; - if (Cmd.Argc() != 2) { + if (Cmd.Argc() != 2) + { Com.Printf("USAGE: gamemap \n"); return; } @@ -592,32 +621,37 @@ public class SV_CCMDS extends SV_ENTS { FS.CreatePath(FS.Gamedir() + "/save/current/"); // check for clearing the current savegame - map = Cmd.Argv(1); - if (map.charAt(0) == '*') { + map= Cmd.Argv(1); + if (map.charAt(0) == '*') + { // wipe all the *.sav files SV_WipeSavegame("current"); } - else { // save the map just exited - if (sv.state == ss_game) { + else + { // save the map just exited + if (sv.state == ss_game) + { // clear all the client inuse flags before saving so that // when the level is re-entered, the clients will spawn // at spawn points instead of occupying body shells - savedInuse = new boolean[(int) maxclients.value]; - for (i = 0; i < maxclients.value; i++) { - cl = svs.clients[i]; - savedInuse[i] = cl.edict.inuse; - cl.edict.inuse = false; + savedInuse= new boolean[(int) maxclients.value]; + for (i= 0; i < maxclients.value; i++) + { + cl= svs.clients[i]; + savedInuse[i]= cl.edict.inuse; + cl.edict.inuse= false; } SV_WriteLevelFile(); // we must restore these for clients to transfer over correctly - for (i = 0; i < maxclients.value; i++) { - cl = svs.clients[i]; - cl.edict.inuse = savedInuse[i]; + for (i= 0; i < maxclients.value; i++) + { + cl= svs.clients[i]; + cl.edict.inuse= savedInuse[i]; } - savedInuse = null; + savedInuse= null; } } @@ -625,15 +659,13 @@ public class SV_CCMDS extends SV_ENTS { SV_Map(false, Cmd.Argv(1), false); // archive server state - svs.mapcmd = Cmd.Argv(1); + svs.mapcmd= Cmd.Argv(1); // copy off the level to the autosave slot - if (0 == dedicated.value) { - - //TODO: SV_WriteServerFile. - //SV_WriteServerFile(true); - - //SV_CopySaveGame("current", "save0"); + if (0 == dedicated.value) + { + SV_WriteServerFile(true); + SV_CopySaveGame("current", "save0"); } } @@ -645,24 +677,34 @@ public class SV_CCMDS extends SV_ENTS { For development work ================== */ - public static void SV_Map_f() { + public static void SV_Map_f() + { String map; //char expanded[MAX_QPATH]; String expanded; // if not a pcx, demo, or cinematic, check to make sure the level exists +//<<<<<<< SV_CCMDS.java +// map= Cmd.Argv(1); +// if (!strstr(map, ".")) +// { +// expanded= "maps/" + map + ".bsp"; +// if (FS.LoadFile(expanded) == null) +// { +//======= map = Cmd.Argv(1); if (map.indexOf(".") < 0) { expanded = "maps/" + map + ".bsp"; if (FS.LoadFile(expanded) == null) { + Com.Printf("Can't find " + expanded + "\n"); return; } } - sv.state = ss_dead; // don't save current level when changing + sv.state= ss_dead; // don't save current level when changing //TODO: savegame - //SV_WipeSavegame("current"); + SV_WipeSavegame("current"); SV_GameMap_f(); } @@ -680,7 +722,8 @@ public class SV_CCMDS extends SV_ENTS { ============== */ - public static void SV_Loadgame_f() { + public static void SV_Loadgame_f() + { //char name[MAX_OSPATH]; //FILE * f; //char * dir; @@ -689,32 +732,38 @@ public class SV_CCMDS extends SV_ENTS { RandomAccessFile f; String dir; - if (Cmd.Argc() != 2) { + if (Cmd.Argc() != 2) + { Com.Printf("USAGE: loadgame \n"); return; } Com.Printf("Loading game...\n"); - dir = Cmd.Argv(1); - if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) { + dir= Cmd.Argv(1); + if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) + { Com.Printf("Bad savedir.\n"); } // make sure the server.ssv file exists - name = FS.Gamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv"; - try { - f = new RandomAccessFile(name, "r"); + name= FS.Gamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv"; + try + { + f= new RandomAccessFile(name, "r"); } - catch (FileNotFoundException e) { + catch (FileNotFoundException e) + { Com.Printf("No such savegame: " + name + "\n"); return; } - try { + try + { f.close(); } - catch (IOException e1) { + catch (IOException e1) + { e1.printStackTrace(); } @@ -723,7 +772,7 @@ public class SV_CCMDS extends SV_ENTS { SV_ReadServerFile(); // go to the map - sv.state = ss_dead; // don't save current level when changing + sv.state= ss_dead; // don't save current level when changing SV_INIT.SV_Map(false, svs.mapcmd, true); } @@ -733,36 +782,43 @@ public class SV_CCMDS extends SV_ENTS { ============== */ - public static void SV_Savegame_f() { + public static void SV_Savegame_f() + { String dir; - if (sv.state != ss_game) { + if (sv.state != ss_game) + { Com.Printf("You must be in a game to save.\n"); return; } - if (Cmd.Argc() != 2) { + if (Cmd.Argc() != 2) + { Com.Printf("USAGE: savegame \n"); return; } - if (Cvar.VariableValue("deathmatch") != 0) { + if (Cvar.VariableValue("deathmatch") != 0) + { Com.Printf("Can't savegame in a deathmatch\n"); return; } - if (0 == strcmp(Cmd.Argv(1), "current")) { + if (0 == strcmp(Cmd.Argv(1), "current")) + { Com.Printf("Can't save to 'current'\n"); return; } - if (maxclients.value == 1 && svs.clients[0].edict.client.ps.stats[STAT_HEALTH] <= 0) { + if (maxclients.value == 1 && svs.clients[0].edict.client.ps.stats[STAT_HEALTH] <= 0) + { Com.Printf("\nCan't savegame while dead!\n"); return; } - dir = Cmd.Argv(1); - if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) { + dir= Cmd.Argv(1); + if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) + { Com.Printf("Bad savedir.\n"); } @@ -774,10 +830,12 @@ public class SV_CCMDS extends SV_ENTS { SV_WriteLevelFile(); // save server state - try { + try + { SV_WriteServerFile(false); } - catch (Exception e) { + catch (Exception e) + { Com.Printf("IOError in SV_WriteServerFile: " + e); } @@ -796,13 +854,16 @@ public class SV_CCMDS extends SV_ENTS { Kick a user off of the server ================== */ - public static void SV_Kick_f() { - if (!svs.initialized) { + public static void SV_Kick_f() + { + if (!svs.initialized) + { Com.Printf("No server running.\n"); return; } - if (Cmd.Argc() != 2) { + if (Cmd.Argc() != 2) + { Com.Printf("Usage: kick \n"); return; } @@ -815,7 +876,7 @@ public class SV_CCMDS extends SV_ENTS { // SV_BroadcastPrintf message SV_ClientPrintf(sv_client, PRINT_HIGH, "You were kicked from the game\n"); SV_DropClient(sv_client); - sv_client.lastmessage = svs.realtime; // min case there is a funny zombie + sv_client.lastmessage= svs.realtime; // min case there is a funny zombie } /* @@ -823,12 +884,14 @@ public class SV_CCMDS extends SV_ENTS { SV_Status_f ================ */ - public static void SV_Status_f() { + public static void SV_Status_f() + { int i, j, l; client_t cl; String s; int ping; - if (svs.clients == null) { + if (svs.clients == null) + { Com.Printf("No server running.\n"); return; } @@ -836,8 +899,9 @@ public class SV_CCMDS extends SV_ENTS { Com.Printf("num score ping name lastmsg address qport \n"); Com.Printf("--- ----- ---- --------------- ------- --------------------- ------\n"); - for (i = 0; i < maxclients.value; i++) { - cl = svs.clients[i]; + for (i= 0; i < maxclients.value; i++) + { + cl= svs.clients[i]; if (0 == cl.state) continue; @@ -848,22 +912,23 @@ public class SV_CCMDS extends SV_ENTS { Com.Printf("CNCT "); else if (cl.state == cs_zombie) Com.Printf("ZMBI "); - else { - ping = cl.ping < 9999 ? cl.ping : 9999; + else + { + ping= cl.ping < 9999 ? cl.ping : 9999; Com.Printf("%4i ", new Vargs().add(ping)); } Com.Printf("%s", new Vargs().add(cl.name)); - l = 16 - cl.name.length(); - for (j = 0; j < l; j++) + l= 16 - cl.name.length(); + for (j= 0; j < l; j++) Com.Printf(" "); Com.Printf("%7i ", new Vargs().add(svs.realtime - cl.lastmessage)); - s = NET.AdrToString(cl.netchan.remote_address); + s= NET.AdrToString(cl.netchan.remote_address); Com.Printf(s); - l = 22 - s.length(); - for (j = 0; j < l; j++) + l= 22 - s.length(); + for (j= 0; j < l; j++) Com.Printf(" "); Com.Printf("%5i", new Vargs().add(cl.netchan.qport)); @@ -878,7 +943,8 @@ public class SV_CCMDS extends SV_ENTS { SV_ConSay_f ================== */ - public static void SV_ConSay_f() { + public static void SV_ConSay_f() + { client_t client; int j; String p; @@ -887,17 +953,19 @@ public class SV_CCMDS extends SV_ENTS { if (Cmd.Argc() < 2) return; - text = "console: "; - p = Cmd.Args(); + text= "console: "; + p= Cmd.Args(); - if (p.charAt(0) == '"') { - p = p.substring(1, p.length() - 1); + if (p.charAt(0) == '"') + { + p= p.substring(1, p.length() - 1); } text += p; - for (j = 0; j < maxclients.value; j++) { - client = svs.clients[j]; + for (j= 0; j < maxclients.value; j++) + { + client= svs.clients[j]; if (client.state != cs_spawned) continue; SV_ClientPrintf(client, PRINT_CHAT, text + "\n"); @@ -909,8 +977,9 @@ public class SV_CCMDS extends SV_ENTS { SV_Heartbeat_f ================== */ - public static void SV_Heartbeat_f() { - svs.last_heartbeat = -9999999; + public static void SV_Heartbeat_f() + { + svs.last_heartbeat= -9999999; } /* @@ -920,7 +989,8 @@ public class SV_CCMDS extends SV_ENTS { Examine or change the serverinfo string =========== */ - public static void SV_Serverinfo_f() { + public static void SV_Serverinfo_f() + { Com.Printf("Server info settings:\n"); Info.Print(Cvar.Serverinfo()); } @@ -932,8 +1002,10 @@ public class SV_CCMDS extends SV_ENTS { Examine all a users info strings =========== */ - public static void SV_DumpUser_f() { - if (Cmd.Argc() != 2) { + public static void SV_DumpUser_f() + { + if (Cmd.Argc() != 2) + { Com.Printf("Usage: info \n"); return; } @@ -955,25 +1027,29 @@ public class SV_CCMDS extends SV_ENTS { recorded, but no playerinfo will be stored. Primarily for demo merging. ============== */ - public static void SV_ServerRecord_f() { + public static void SV_ServerRecord_f() + { //char name[MAX_OSPATH]; String name; - byte buf_data[] = new byte[32768]; - sizebuf_t buf = new sizebuf_t(); + byte buf_data[]= new byte[32768]; + sizebuf_t buf= new sizebuf_t(); int len; int i; - if (Cmd.Argc() != 2) { + if (Cmd.Argc() != 2) + { Com.Printf("serverrecord \n"); return; } - if (svs.demofile != null) { + if (svs.demofile != null) + { Com.Printf("Already recording.\n"); return; } - if (sv.state != ss_game) { + if (sv.state != ss_game) + { Com.Printf("You must be in a level to record.\n"); return; } @@ -981,14 +1057,16 @@ public class SV_CCMDS extends SV_ENTS { // // open the demo file // - name = FS.Gamedir() + "/demos/" + Cmd.Argv(1) + ".dm2"; + name= FS.Gamedir() + "/demos/" + Cmd.Argv(1) + ".dm2"; Com.Printf("recording to " + name + ".\n"); FS.CreatePath(name); - try { - svs.demofile = new RandomAccessFile(name, "rw"); + try + { + svs.demofile= new RandomAccessFile(name, "rw"); } - catch (Exception e) { + catch (Exception e) + { Com.Printf("ERROR: couldn't open.\n"); return; } @@ -1016,8 +1094,9 @@ public class SV_CCMDS extends SV_ENTS { // send full levelname MSG.WriteString(buf, sv.configstrings[CS_NAME]); - for (i = 0; i < MAX_CONFIGSTRINGS; i++) - if (sv.configstrings[i].length() == 0) { + for (i= 0; i < MAX_CONFIGSTRINGS; i++) + if (sv.configstrings[i].length() == 0) + { MSG.WriteByte(buf, svc_configstring); MSG.WriteShort(buf, i); MSG.WriteString(buf, sv.configstrings[i]); @@ -1025,14 +1104,16 @@ public class SV_CCMDS extends SV_ENTS { // write it to the demo file Com.DPrintf("signon message length: " + buf.cursize + "\n"); - len = EndianHandler.swapInt(buf.cursize); + len= EndianHandler.swapInt(buf.cursize); //fwrite(len, 4, 1, svs.demofile); //fwrite(buf.data, buf.cursize, 1, svs.demofile); - try { + try + { svs.demofile.writeInt(len); svs.demofile.write(buf.data); } - catch (IOException e1) { + catch (IOException e1) + { // TODO: do quake2 error handling! e1.printStackTrace(); } @@ -1047,18 +1128,22 @@ public class SV_CCMDS extends SV_ENTS { Ends server demo recording ============== */ - public static void SV_ServerStop_f() { - if (svs.demofile == null) { + public static void SV_ServerStop_f() + { + if (svs.demofile == null) + { Com.Printf("Not doing a serverrecord.\n"); return; } - try { + try + { svs.demofile.close(); } - catch (IOException e) { + catch (IOException e) + { e.printStackTrace(); } - svs.demofile = null; + svs.demofile= null; Com.Printf("Recording completed.\n"); } @@ -1070,7 +1155,8 @@ public class SV_CCMDS extends SV_ENTS { =============== */ - public static void SV_KillServer_f() { + public static void SV_KillServer_f() + { if (!svs.initialized) return; SV_Shutdown("Server was killed.\n", false); @@ -1084,8 +1170,10 @@ public class SV_CCMDS extends SV_ENTS { Let the game dll handle a command =============== */ - public static void SV_ServerCommand_f() { - if (SV_GAME.ge == null) { + public static void SV_ServerCommand_f() + { + if (SV_GAME.ge == null) + { Com.Printf("No game loaded.\n"); return; } @@ -1100,91 +1188,124 @@ public class SV_CCMDS extends SV_ENTS { SV_InitOperatorCommands ================== */ - public static void SV_InitOperatorCommands() { - Cmd.AddCommand("heartbeat", new xcommand_t() { - public void execute() { + public static void SV_InitOperatorCommands() + { + Cmd.AddCommand("heartbeat", new xcommand_t() + { + public void execute() + { SV_Heartbeat_f(); } }); - Cmd.AddCommand("kick", new xcommand_t() { - public void execute() { + Cmd.AddCommand("kick", new xcommand_t() + { + public void execute() + { SV_Kick_f(); } }); - Cmd.AddCommand("status", new xcommand_t() { - public void execute() { + Cmd.AddCommand("status", new xcommand_t() + { + public void execute() + { SV_Status_f(); } }); - Cmd.AddCommand("serverinfo", new xcommand_t() { - public void execute() { + Cmd.AddCommand("serverinfo", new xcommand_t() + { + public void execute() + { SV_Serverinfo_f(); } }); - Cmd.AddCommand("dumpuser", new xcommand_t() { - public void execute() { + Cmd.AddCommand("dumpuser", new xcommand_t() + { + public void execute() + { SV_DumpUser_f(); } }); - Cmd.AddCommand("map", new xcommand_t() { - public void execute() { + Cmd.AddCommand("map", new xcommand_t() + { + public void execute() + { SV_Map_f(); } }); - Cmd.AddCommand("demomap", new xcommand_t() { - public void execute() { + Cmd.AddCommand("demomap", new xcommand_t() + { + public void execute() + { SV_DemoMap_f(); } }); - Cmd.AddCommand("gamemap", new xcommand_t() { - public void execute() { + Cmd.AddCommand("gamemap", new xcommand_t() + { + public void execute() + { SV_GameMap_f(); } }); - Cmd.AddCommand("setmaster", new xcommand_t() { - public void execute() { + Cmd.AddCommand("setmaster", new xcommand_t() + { + public void execute() + { SV_SetMaster_f(); } }); if (dedicated.value != 0) - Cmd.AddCommand("say", new xcommand_t() { - public void execute() { + Cmd.AddCommand("say", new xcommand_t() + { + public void execute() + { SV_ConSay_f(); } }); - Cmd.AddCommand("serverrecord", new xcommand_t() { - public void execute() { + Cmd.AddCommand("serverrecord", new xcommand_t() + { + public void execute() + { SV_ServerRecord_f(); } }); - Cmd.AddCommand("serverstop", new xcommand_t() { - public void execute() { + Cmd.AddCommand("serverstop", new xcommand_t() + { + public void execute() + { SV_ServerStop_f(); } }); - Cmd.AddCommand("save", new xcommand_t() { - public void execute() { + Cmd.AddCommand("save", new xcommand_t() + { + public void execute() + { SV_Savegame_f(); } }); - Cmd.AddCommand("load", new xcommand_t() { - public void execute() { + Cmd.AddCommand("load", new xcommand_t() + { + public void execute() + { SV_Loadgame_f(); } }); - Cmd.AddCommand("killserver", new xcommand_t() { - public void execute() { + Cmd.AddCommand("killserver", new xcommand_t() + { + public void execute() + { SV_KillServer_f(); } }); - Cmd.AddCommand("sv", new xcommand_t() { - public void execute() { + Cmd.AddCommand("sv", new xcommand_t() + { + public void execute() + { SV_ServerCommand_f(); } }); diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java index fd0823c..b8e5c90 100644 --- a/src/jake2/server/SV_INIT.java +++ b/src/jake2/server/SV_INIT.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 14.01.2004 by RST. -// $Id: SV_INIT.java,v 1.5 2004-07-30 06:07:23 hzi Exp $ +// $Id: SV_INIT.java,v 1.6 2004-08-20 21:29:57 salomo Exp $ package jake2.server; @@ -33,10 +33,11 @@ import jake2.sys.NET; import java.io.IOException; import java.io.RandomAccessFile; -public class SV_INIT extends Globals { +public class SV_INIT extends Globals +{ - public static server_static_t svs = new server_static_t(); // persistant server info - public static server_t sv = new server_t(); // local server + public static server_static_t svs= new server_static_t(); // persistant server info + public static server_t sv= new server_t(); // local server /* ================ @@ -44,13 +45,14 @@ public class SV_INIT extends Globals { ================ */ - public static int SV_FindIndex(String name, int start, int max, boolean create) { + public static int SV_FindIndex(String name, int start, int max, boolean create) + { int i; if (name == null || name.length() == 0) return 0; - for (i = 1; i < max && sv.configstrings[start + i] != null; i++) + for (i= 1; i < max && sv.configstrings[start + i] != null; i++) if (0 == strcmp(sv.configstrings[start + i], name)) return i; @@ -61,9 +63,10 @@ public class SV_INIT extends Globals { Com.Error(ERR_DROP, "*Index: overflow"); //strncpy (sv.configstrings[start+i], name, sizeof(sv.configstrings[i])); - sv.configstrings[start + i] = name; + sv.configstrings[start + i]= name; - if (sv.state != ss_loading) { // send the update to everyone + if (sv.state != ss_loading) + { // send the update to everyone SZ.Clear(sv.multicast); MSG.WriteChar(sv.multicast, svc_configstring); MSG.WriteShort(sv.multicast, start + i); @@ -74,15 +77,18 @@ public class SV_INIT extends Globals { return i; } - public static int SV_ModelIndex(String name) { + public static int SV_ModelIndex(String name) + { return SV_FindIndex(name, CS_MODELS, MAX_MODELS, true); } - public static int SV_SoundIndex(String name) { + public static int SV_SoundIndex(String name) + { return SV_FindIndex(name, CS_SOUNDS, MAX_SOUNDS, true); } - public static int SV_ImageIndex(String name) { + public static int SV_ImageIndex(String name) + { return SV_FindIndex(name, CS_IMAGES, MAX_IMAGES, true); } @@ -95,26 +101,28 @@ public class SV_INIT extends Globals { baseline will be transmitted ================ */ - public static void SV_CreateBaseline() { + public static void SV_CreateBaseline() + { edict_t svent; int entnum; - for (entnum = 1; entnum < SV_GAME.ge.num_edicts; entnum++) { + for (entnum= 1; entnum < SV_GAME.ge.num_edicts; entnum++) + { //svent = EDICT_NUM(entnum); - svent = SV_GAME.ge.edicts[entnum]; + svent= SV_GAME.ge.edicts[entnum]; if (!svent.inuse) continue; if (0 == svent.s.modelindex && 0 == svent.s.sound && 0 == svent.s.effects) continue; - svent.s.number = entnum; + svent.s.number= entnum; // // take current state as baseline // VectorCopy(svent.s.origin, svent.s.old_origin); // rst: bugfix - sv.baselines[entnum].set(svent.s);// = svent.s.getClone(); + sv.baselines[entnum].set(svent.s); // = svent.s.getClone(); } } @@ -123,7 +131,8 @@ public class SV_INIT extends Globals { SV_CheckForSavegame ================= */ - public static void SV_CheckForSavegame() { + public static void SV_CheckForSavegame() + { //char name[MAX_OSPATH]; String name; //FILE *f; @@ -137,19 +146,23 @@ public class SV_INIT extends Globals { if (Cvar.VariableValue("deathmatch") != 0) return; - name = FS.Gamedir() + "/save/current/" + sv.name + ".sav"; - try { - f = new RandomAccessFile(name, "r"); + name= FS.Gamedir() + "/save/current/" + sv.name + ".sav"; + try + { + f= new RandomAccessFile(name, "r"); } - catch (Exception e) { + catch (Exception e) + { return; // no savegame } - try { + try + { f.close(); } - catch (IOException e1) { + catch (IOException e1) + { e1.printStackTrace(); } @@ -158,7 +171,8 @@ public class SV_INIT extends Globals { // get configstrings and areaportals SV_CCMDS.SV_ReadLevelFile(); - if (!sv.loadgame) { // coming back to a level after being in a different + if (!sv.loadgame) + { // coming back to a level after being in a different // level, so run it for ten seconds // rlava2 was sending too many lightstyles, and overflowing the @@ -166,12 +180,12 @@ public class SV_INIT extends Globals { // prevents these from being passed down. int previousState; // PGM - previousState = sv.state; // PGM - sv.state = ss_loading; // PGM - for (i = 0; i < 100; i++) + previousState= sv.state; // PGM + sv.state= ss_loading; // PGM + for (i= 0; i < 100; i++) SV_GAME.ge.RunFrame(); - sv.state = previousState; // PGM + sv.state= previousState; // PGM } } @@ -184,14 +198,10 @@ public class SV_INIT extends Globals { ================ */ - public static void SV_SpawnServer( - String server, - String spawnpoint, - int serverstate, - boolean attractloop, - boolean loadgame) { + public static void SV_SpawnServer(String server, String spawnpoint, int serverstate, boolean attractloop, boolean loadgame) + { int i; - int checksum = 0; + int checksum= 0; if (attractloop) Cvar.Set("paused", "0"); @@ -200,76 +210,86 @@ public class SV_INIT extends Globals { Com.DPrintf("SpawnServer: " + server + "\n"); if (sv.demofile != null) - try { + try + { sv.demofile.close(); } - catch (Exception e) { + catch (Exception e) + { } svs.spawncount++; // any partially connected client will be // restarted + sv.state = ss_dead; Globals.server_state= sv.state; + // wipe the entire per-level structure //memset(sv, 0, sizeof(sv)); - sv = new server_t(); - - svs.realtime = 0; - sv.loadgame = loadgame; - sv.attractloop = attractloop; + sv= new server_t(); + + svs.realtime= 0; + sv.loadgame= loadgame; + sv.attractloop= attractloop; // save name for levels that don't set message sv.configstrings[CS_NAME]= server; - - if (Cvar.VariableValue("deathmatch")!=0) { - sv.configstrings[CS_AIRACCEL] = ""+SV_MAIN.sv_airaccelerate.value; - PMove.pm_airaccelerate = SV_MAIN.sv_airaccelerate.value; + + if (Cvar.VariableValue("deathmatch") != 0) + { + sv.configstrings[CS_AIRACCEL]= "" + SV_MAIN.sv_airaccelerate.value; + PMove.pm_airaccelerate= SV_MAIN.sv_airaccelerate.value; } - else { - sv.configstrings[CS_AIRACCEL] = "0"; - PMove.pm_airaccelerate = 0; + else + { + sv.configstrings[CS_AIRACCEL]= "0"; + PMove.pm_airaccelerate= 0; } SZ.Init(sv.multicast, sv.multicast_buf, sv.multicast_buf.length); - sv.name = server; + sv.name= server; // leave slots at start for clients only - for (i = 0; i < SV_MAIN.maxclients.value; i++) { + for (i= 0; i < SV_MAIN.maxclients.value; i++) + { // needs to reconnect if (svs.clients[i].state > cs_connected) - svs.clients[i].state = cs_connected; - svs.clients[i].lastframe = -1; + svs.clients[i].state= cs_connected; + svs.clients[i].lastframe= -1; } - sv.time = 1000; + sv.time= 1000; - sv.name=server; - sv.configstrings[CS_NAME] = server; - - int iw[] = {checksum}; + sv.name= server; + sv.configstrings[CS_NAME]= server; + + int iw[]= { checksum }; - if (serverstate != ss_game) { - sv.models[1] = CM.CM_LoadMap("", false, iw); // no real map + if (serverstate != ss_game) + { + sv.models[1]= CM.CM_LoadMap("", false, iw); // no real map } - else { - sv.configstrings[CS_MODELS + 1] = "maps/" + server + ".bsp"; - sv.models[1] = CM.CM_LoadMap(sv.configstrings[CS_MODELS + 1], false, iw); + else + { + sv.configstrings[CS_MODELS + 1]= "maps/" + server + ".bsp"; + sv.models[1]= CM.CM_LoadMap(sv.configstrings[CS_MODELS + 1], false, iw); } - checksum = iw[0]; - sv.configstrings[CS_MAPCHECKSUM] = "" + checksum; + checksum= iw[0]; + sv.configstrings[CS_MAPCHECKSUM]= "" + checksum; // // clear physics interaction links // SV_WORLD.SV_ClearWorld(); - for (i = 1; i < CM.CM_NumInlineModels(); i++) { - sv.configstrings[CS_MODELS + 1 + i] = "*" + i; + for (i= 1; i < CM.CM_NumInlineModels(); i++) + { + sv.configstrings[CS_MODELS + 1 + i]= "*" + i; // copy references - sv.models[i + 1] = CM.InlineModel(sv.configstrings[CS_MODELS + 1 + i]); + sv.models[i + 1]= CM.InlineModel(sv.configstrings[CS_MODELS + 1 + i]); } // @@ -278,6 +298,7 @@ public class SV_INIT extends Globals { // precache and static commands can be issued during // map initialization + sv.state = ss_loading; Globals.server_state= sv.state; @@ -311,17 +332,20 @@ public class SV_INIT extends Globals { A brand new game has been started ============== */ - public static void SV_InitGame() { + public static void SV_InitGame() + { int i; - edict_t ent; + edict_t ent; //char idmaster[32]; String idmaster; - if (svs.initialized) { + if (svs.initialized) + { // cause any connected clients to reconnect SV_MAIN.SV_Shutdown("Server restarted\n", true); } - else { + else + { // make sure the client is down CL.Drop(); SCR.BeginLoadingPlaque(); @@ -330,28 +354,32 @@ public class SV_INIT extends Globals { // get any latched variable changes (maxclients, etc) Cvar.GetLatchedVars(); - svs.initialized = true; + svs.initialized= true; - if (Cvar.VariableValue("coop")!=0 && Cvar.VariableValue("deathmatch")!=0) { + if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0) + { Com.Printf("Deathmatch and Coop both set, disabling Coop\n"); Cvar.FullSet("coop", "0", CVAR_SERVERINFO | CVAR_LATCH); } // dedicated servers are can't be single player and are usually DM // so unless they explicity set coop, force it to deathmatch - if (dedicated.value!=0) { - if (0==Cvar.VariableValue("coop")) + if (dedicated.value != 0) + { + if (0 == Cvar.VariableValue("coop")) Cvar.FullSet("deathmatch", "1", CVAR_SERVERINFO | CVAR_LATCH); } // init clients - if (Cvar.VariableValue("deathmatch")!=0) { + if (Cvar.VariableValue("deathmatch") != 0) + { if (SV_MAIN.maxclients.value <= 1) Cvar.FullSet("maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH); else if (SV_MAIN.maxclients.value > MAX_CLIENTS) - Cvar.FullSet("maxclients", "" + MAX_CLIENTS, CVAR_SERVERINFO | CVAR_LATCH); + Cvar.FullSet("maxclients", "" + MAX_CLIENTS, CVAR_SERVERINFO | CVAR_LATCH); } - else if (Cvar.VariableValue("coop")!=0) { + else if (Cvar.VariableValue("coop") != 0) + { if (SV_MAIN.maxclients.value <= 1 || SV_MAIN.maxclients.value > 4) Cvar.FullSet("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH); @@ -361,37 +389,38 @@ public class SV_INIT extends Globals { Cvar.FullSet("maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH); } - svs.spawncount = rand(); + svs.spawncount= rand(); //svs.clients = Z_Malloc(sizeof(client_t) * maxclients.value); - svs.clients = new client_t[(int) SV_MAIN.maxclients.value]; - for (int n=0; n < svs.clients.length; n++) + svs.clients= new client_t[(int) SV_MAIN.maxclients.value]; + for (int n= 0; n < svs.clients.length; n++) svs.clients[n]= new client_t(); - - svs.num_client_entities = ((int) SV_MAIN.maxclients.value) * UPDATE_BACKUP * 64; //ok. - + + svs.num_client_entities= ((int) SV_MAIN.maxclients.value) * UPDATE_BACKUP * 64; //ok. + //svs.client_entities = Z_Malloc(sizeof(entity_state_t) * svs.num_client_entities); - svs.client_entities = new entity_state_t[svs.num_client_entities]; - for (int n=0; n < svs.client_entities.length; n++) - svs.client_entities[n] = new entity_state_t(null); + svs.client_entities= new entity_state_t[svs.num_client_entities]; + for (int n= 0; n < svs.client_entities.length; n++) + svs.client_entities[n]= new entity_state_t(null); // init network stuff NET.Config((SV_MAIN.maxclients.value > 1)); //ok! // heartbeats will always be sent to the id master - svs.last_heartbeat = -99999; // send immediately - idmaster = "192.246.40.37:" + PORT_MASTER; + svs.last_heartbeat= -99999; // send immediately + idmaster= "192.246.40.37:" + PORT_MASTER; NET.StringToAdr(idmaster, SV_MAIN.master_adr[0]); // init game SV_GAME.SV_InitGameProgs(); // bis hier alles ok! - - for (i = 0; i < SV_MAIN.maxclients.value; i++) { - ent = SV_GAME.ge.edicts[i + 1]; - + + for (i= 0; i < SV_MAIN.maxclients.value; i++) + { + ent= SV_GAME.ge.edicts[i + 1]; + //ent.s.number = i + 1; //dont need this, ent.s.number already set. - svs.clients[i].edict = ent; + svs.clients[i].edict= ent; //memset(& svs.clients[i].lastcmd, 0, sizeof(svs.clients[i].lastcmd)); - svs.clients[i].lastcmd = new usercmd_t(); + svs.clients[i].lastcmd= new usercmd_t(); } } @@ -411,7 +440,8 @@ public class SV_INIT extends Globals { map tram.cin+jail_e3 ====================== */ - public static void SV_Map(boolean attractloop, String levelstring, boolean loadgame) { + public static void SV_Map(boolean attractloop, String levelstring, boolean loadgame) + { //char level[MAX_QPATH]; //char *ch; int l; @@ -419,13 +449,13 @@ public class SV_INIT extends Globals { String level, ch, spawnpoint; - sv.loadgame = loadgame; - sv.attractloop = attractloop; + sv.loadgame= loadgame; + sv.attractloop= attractloop; if (sv.state == ss_dead && !sv.loadgame) SV_InitGame(); // the game is just starting - level = levelstring; // bis hier her ok. + level= levelstring; // bis hier her ok. // if there is a + in the map, set nextserver to the remainder @@ -439,52 +469,59 @@ public class SV_INIT extends Globals { // else // Cvar_Set ("nextserver", ""); - int c = level.indexOf('+'); - if (c != -1) { - Cvar.Set("nextserver","gamemap \"" + level.substring(c+1) + "\""); - level = level.substring(0, c); + int c= level.indexOf('+'); + if (c != -1) + { + Cvar.Set("nextserver", "gamemap \"" + level.substring(c + 1) + "\""); + level= level.substring(0, c); } - else { + else + { Cvar.Set("nextserver", ""); } //ZOID special hack for end game screen in coop mode - if (Cvar.VariableValue("coop")!=0 && !level.equals( "victory.pcx")) + if (Cvar.VariableValue("coop") != 0 && !level.equals("victory.pcx")) Cvar.Set("nextserver", "gamemap \"*base1\""); // if there is a $, use the remainder as a spawnpoint - int pos = level.indexOf('$'); - if (pos!=-1) { + int pos= level.indexOf('$'); + if (pos != -1) + { //* ch = 0; - spawnpoint = level.substring(pos + 1); - level = level.substring(0,pos); - + spawnpoint= level.substring(pos + 1); + level= level.substring(0, pos); + } else //spawnpoint[0] = 0; - spawnpoint = ""; + spawnpoint= ""; // skip the end-of-unit flag if necessary if (level.charAt(0) == '*') - level = level.substring(1); + level= level.substring(1); - l = level.length(); - if (l > 4 && level.endsWith(".cin")) { + l= level.length(); + if (l > 4 && level.endsWith(".cin")) + { SCR.BeginLoadingPlaque(); // for local system SV_SEND.SV_BroadcastCommand("changing\n"); SV_SpawnServer(level, spawnpoint, ss_cinematic, attractloop, loadgame); } - else if (l > 4 && level.endsWith(".dm2")) { + else if (l > 4 && level.endsWith(".dm2")) + { SCR.BeginLoadingPlaque(); // for local system SV_SEND.SV_BroadcastCommand("changing\n"); SV_SpawnServer(level, spawnpoint, ss_demo, attractloop, loadgame); } - else if (l > 4 && level.endsWith(".pcx")) { + else if (l > 4 && level.endsWith(".pcx")) + { SCR.BeginLoadingPlaque(); // for local system SV_SEND.SV_BroadcastCommand("changing\n"); SV_SpawnServer(level, spawnpoint, ss_pic, attractloop, loadgame); } - else { + else + { SCR.BeginLoadingPlaque(); // for local system SV_SEND.SV_BroadcastCommand("changing\n"); SV_SEND.SV_SendClientMessages(); diff --git a/src/jake2/server/SV_WORLD.java b/src/jake2/server/SV_WORLD.java index 2eb2ca6..cb74e95 100644 --- a/src/jake2/server/SV_WORLD.java +++ b/src/jake2/server/SV_WORLD.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 07.01.2000 by RST. -// $Id: SV_WORLD.java,v 1.4 2004-07-09 06:50:49 hzi Exp $ +// $Id: SV_WORLD.java,v 1.5 2004-08-20 21:29:57 salomo Exp $ package jake2.server; @@ -176,6 +176,7 @@ public class SV_WORLD extends SV_CCMDS { if (null == ent.area.prev) return; // not linked in anywhere + RemoveLink(ent.area); ent.area.prev= ent.area.next= null; } @@ -212,7 +213,8 @@ public class SV_WORLD extends SV_CCMDS // encode the size into the entity_state for client prediction if (ent.solid == SOLID_BBOX && 0 == (ent.svflags & SVF_DEADMONSTER)) - { // assume that x/y are equal and symetric + { + // assume that x/y are equal and symetric int i= (int) (ent.maxs[0] / 8); if (i < 1) i= 1; @@ -244,7 +246,8 @@ public class SV_WORLD extends SV_CCMDS // set the abs box if (ent.solid == SOLID_BSP && (ent.s.angles[0] != 0 || ent.s.angles[1] != 0 || ent.s.angles[2] != 0)) - { // expand for rotation + { + // expand for rotation float max, v; max= 0; @@ -264,7 +267,8 @@ public class SV_WORLD extends SV_CCMDS } } else - { // normal + { + // normal VectorAdd(ent.s.origin, ent.mins, ent.absmin); VectorAdd(ent.s.origin, ent.maxs, ent.absmax); } @@ -284,7 +288,7 @@ public class SV_WORLD extends SV_CCMDS ent.areanum= 0; ent.areanum2= 0; - //get all leafs, including solids + // get all leafs, including solids int iw[] = {topnode}; diff --git a/src/jake2/util/QuakeFile.java b/src/jake2/util/QuakeFile.java new file mode 100644 index 0000000..9b71bb2 --- /dev/null +++ b/src/jake2/util/QuakeFile.java @@ -0,0 +1,180 @@ +/* +Copyright (C) 1997-2001 Id Software, Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +// Created on 24.07.2004 by RST. +// $Id: QuakeFile.java,v 1.1 2004-08-20 21:29:57 salomo Exp $ + +package jake2.util; + +import jake2.game.Game; +import jake2.game.SuperAdapter; +import jake2.game.edict_t; +import jake2.game.gitem_t; + +import java.io.*; + +/** RandomAccessFile, bur handles readString/WriteString specially and + * offers other helper functions */ +public class QuakeFile extends RandomAccessFile +{ + + /** Standard Constructor.*/ + public QuakeFile(String filename, String mode) throws FileNotFoundException + { + super(filename, mode); + } + + /** Writes a Vector to a RandomAccessFile. */ + public void writeVector(float v[]) throws IOException + { + for (int n= 0; n < 3; n++) + writeFloat(v[n]); + } + + /** Writes a Vector to a RandomAccessFile. */ + public float[] readVector() throws IOException + { + float res[]= { 0, 0, 0 }; + for (int n= 0; n < 3; n++) + res[n]= readFloat(); + + return res; + } + + /** Reads a length specified string from a file. */ + public String readString() throws IOException + { + int len= readInt(); + + if (len == -1) + return null; + + if (len == 0) + return ""; + + byte bb[]= new byte[len]; + + super.read(bb, 0, len); + + return new String(bb, 0, len); + } + + /** Writes a length specified string to a file. */ + public void writeString(String s) throws IOException + { + if (s == null) + { + writeInt(-1); + return; + } + + writeInt(s.length()); + if (s.length() != 0) + writeBytes(s); + } + + /** Writes the edict reference. */ + public void writeEdictRef(edict_t ent) throws IOException + { + if (ent == null) + writeInt(-1); + else + { + writeInt(ent.s.number); + } + } + + /** + * Reads an edict index from a file and returns the edict. + */ + + public edict_t readEdictRef() throws IOException + { + int i= readInt(); + + // handle -1 + if (i < 0) + return null; + + if (i > Game.g_edicts.length) + { + System.err.println("jake2: illegal edict num:" + i); + return null; + } + + // valid edict. + return Game.g_edicts[i]; + } + + /** Writes the Adapter-ID to the file. */ + public void writeAdapter(SuperAdapter a) throws IOException + { + writeInt(3988); + if (a == null) + writeString(null); + else + { + String str= a.getID(); + if (a == null) + { + System.err.println("writeAdapter: invalid Adapter id for" + a); + } + System.out.println("writing adapter:" + str); + writeString(str); + } + } + + /** Reads the adapter id and returns the adapter. */ + public SuperAdapter readAdapter() throws IOException + { + if (readInt() != 3988) + System.err.println("wrong read position: readadapter."); + + String id= readString(); + + if (id == null) + { + // null adapter. :-) + return null; + } + + return SuperAdapter.getFromID(id); + } + + /** Writes an item reference. */ + public void writeItem(gitem_t item) throws IOException + { + if (item == null) + writeInt(-1); + else + writeInt(item.index); + } + + /** Reads the item index and returns the game item. */ + public gitem_t readItem() throws IOException + { + int ndx= readInt(); + if (ndx == -1) + return null; + else + return Game.itemlist[ndx]; + } + +} -- cgit v1.2.3 From d9518e2c5da7bdf3eb8a80f882c31234d0734673 Mon Sep 17 00:00:00 2001 From: Rene Stoeckel Date: Sun, 22 Aug 2004 14:25:15 +0000 Subject: cleanups and base3 bugfix for the load and save routines. --- src/jake2/client/SCR.java | 2019 ++++++++++++++++------------------ src/jake2/game/GameBase.java | 530 ++++----- src/jake2/game/GameFuncAdapters.java | 1151 ++++++++----------- src/jake2/game/GameSave.java | 296 +++-- src/jake2/game/edict_t.java | 127 +-- src/jake2/game/game_export_t.java | 78 +- src/jake2/game/game_import_t.java | 4 +- src/jake2/qcommon/PMove.java | 4 +- src/jake2/render/fastjogl/Draw.java | 4 +- src/jake2/server/SV.java | 4 +- src/jake2/server/SV_CCMDS.java | 449 +++----- src/jake2/server/SV_GAME.java | 33 +- src/jake2/server/SV_INIT.java | 133 +-- src/jake2/server/SV_SEND.java | 143 ++- src/jake2/server/client_t.java | 5 +- 15 files changed, 2103 insertions(+), 2877 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java index 5df826c..da19b29 100644 --- a/src/jake2/client/SCR.java +++ b/src/jake2/client/SCR.java @@ -2,7 +2,7 @@ * SCR.java * Copyright (C) 2003 * - * $Id: SCR.java,v 1.5 2004-07-09 06:50:50 hzi Exp $ + * $Id: SCR.java,v 1.6 2004-08-22 14:25:15 salomo Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -39,12 +39,11 @@ import java.awt.Dimension; /** * SCR */ -public final class SCR extends Globals -{ +public final class SCR extends Globals { // cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc - static String[][] sb_nums = + static String[][] sb_nums= { { "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", "num_7", "num_8", "num_9", "num_minus" }, { "anum_0", "anum_1", "anum_2", "anum_3", "anum_4", "anum_5", "anum_6", "anum_7", "anum_8", "anum_9", "anum_minus" } }; @@ -86,28 +85,27 @@ public final class SCR extends Globals static cvar_t scr_drawall; public static cvar_t fps; - static dirty_t scr_dirty = new dirty_t(); - static dirty_t[] scr_old_dirty = { new dirty_t(), new dirty_t()}; + static dirty_t scr_dirty= new dirty_t(); + static dirty_t[] scr_old_dirty= { new dirty_t(), new dirty_t()}; static String crosshair_pic; static int crosshair_width, crosshair_height; - static class dirty_t - { + static class dirty_t { int x1; int x2; int y1; int y2; - + void set(dirty_t src) { - x1 = src.x1; - x2 = src.x2; - y1 = src.y1; - y2 = src.y2; + x1= src.x1; + x2= src.x2; + y1= src.y1; + y2= src.y2; } - + void clear() { - x1 = x2 = y1 = y2 = 0; + x1= x2= y1= y2= 0; } } @@ -124,17 +122,16 @@ public final class SCR extends Globals // float value; // int color; // } graphsamp_t; - static class graphsamp_t - { + static class graphsamp_t { float value; int color; } static int current; - static graphsamp_t[] values = new graphsamp_t[1024]; + static graphsamp_t[] values= new graphsamp_t[1024]; static { - for (int n = 0; n < 1024; n++) - values[n] = new graphsamp_t(); + for (int n= 0; n < 1024; n++) + values[n]= new graphsamp_t(); } /* @@ -142,10 +139,9 @@ public final class SCR extends Globals SCR_DebugGraph ============== */ - public static void DebugGraph(float value, int color) - { - values[current & 1023].value = value; - values[current & 1023].color = color; + public static void DebugGraph(float value, int color) { + values[current & 1023].value= value; + values[current & 1023].color= color; current++; } @@ -154,30 +150,28 @@ public final class SCR extends Globals SCR_DrawDebugGraph ============== */ - static void DrawDebugGraph() - { + static void DrawDebugGraph() { int a, x, y, w, i, h; float v; int color; // draw the graph - w = scr_vrect.width; + w= scr_vrect.width; - x = scr_vrect.x; - y = scr_vrect.y + scr_vrect.height; + x= scr_vrect.x; + y= scr_vrect.y + scr_vrect.height; re.DrawFill(x, (int) (y - scr_graphheight.value), w, (int) scr_graphheight.value, 8); - for (a = 0; a < w; a++) - { - i = (current - 1 - a + 1024) & 1023; - v = values[i].value; - color = values[i].color; - v = v * scr_graphscale.value + scr_graphshift.value; + for (a= 0; a < w; a++) { + i= (current - 1 - a + 1024) & 1023; + v= values[i].value; + color= values[i].color; + v= v * scr_graphscale.value + scr_graphshift.value; if (v < 0) v += scr_graphheight.value * (1 + (int) (-v / scr_graphheight.value)); - h = (int) v % (int) scr_graphheight.value; + h= (int) v % (int) scr_graphheight.value; re.DrawFill(x + w - 1 - a, y - h, 1, h, color); } } @@ -205,23 +199,21 @@ public final class SCR extends Globals for a few moments ============== */ - static void CenterPrint(String str) - { + static void CenterPrint(String str) { //char *s; int s; - StringBuffer line = new StringBuffer(64); + StringBuffer line= new StringBuffer(64); int i, j, l; //strncpy (scr_centerstring, str, sizeof(scr_centerstring)-1); - scr_centerstring = str; - scr_centertime_off = scr_centertime.value; - scr_centertime_start = cl.time; + scr_centerstring= str; + scr_centertime_off= scr_centertime.value; + scr_centertime_start= cl.time; // count the number of lines for centering - scr_center_lines = 1; - s = 0; - while (s < str.length()) - { + scr_center_lines= 1; + s= 0; + while (s < str.length()) { if (str.charAt(s) == '\n') scr_center_lines++; s++; @@ -231,22 +223,19 @@ public final class SCR extends Globals Com.Printf( "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); - s = 0; + s= 0; - if (str.length() != 0) - { - do - { + if (str.length() != 0) { + do { // scan the width of the line - for (l = 0; l < 40 && (l + s) < str.length(); l++) + for (l= 0; l < 40 && (l + s) < str.length(); l++) if (str.charAt(s + l) == '\n' || str.charAt(s + l) == 0) break; - for (i = 0; i < (40 - l) / 2; i++) + for (i= 0; i < (40 - l) / 2; i++) line.append(' '); - for (j = 0; j < l; j++) - { + for (j= 0; j < l; j++) { line.append(str.charAt(s + j)); } @@ -268,9 +257,8 @@ public final class SCR extends Globals Console.ClearNotify(); } - static void DrawCenterString() - { - String cs = scr_centerstring + "\0"; + static void DrawCenterString() { + String cs= scr_centerstring + "\0"; int start; int l; int j; @@ -283,26 +271,24 @@ public final class SCR extends Globals return; // the finale prints the characters one at a time - remaining = 9999; + remaining= 9999; - scr_erase_center = 0; - start = 0; + scr_erase_center= 0; + start= 0; if (scr_center_lines <= 4) - y = (int) (viddef.height * 0.35); + y= (int) (viddef.height * 0.35); else - y = 48; + y= 48; - do - { + do { // scan the width of the line - for (l = 0; l < 40; l++) + for (l= 0; l < 40; l++) if (start + l == cs.length() - 1 || cs.charAt(start + l) == '\n') break; - x = (viddef.width - l * 8) / 2; + x= (viddef.width - l * 8) / 2; SCR.AddDirtyPoint(x, y); - for (j = 0; j < l; j++, x += 8) - { + for (j= 0; j < l; j++, x += 8) { re.DrawChar(x, y, cs.charAt(start + j)); if (remaining == 0) return; @@ -322,8 +308,7 @@ public final class SCR extends Globals while (true); } - static void CheckDrawCenterString() - { + static void CheckDrawCenterString() { scr_centertime_off -= cls.frametime; if (scr_centertime_off <= 0) @@ -341,8 +326,7 @@ public final class SCR extends Globals Sets scr_vrect, the coordinates of the rendered window ================= */ - static void CalcVrect() - { + static void CalcVrect() { int size; // bound viewsize @@ -351,16 +335,16 @@ public final class SCR extends Globals if (scr_viewsize.value > 100) Cvar.Set("viewsize", "100"); - size = (int) scr_viewsize.value; + size= (int) scr_viewsize.value; - scr_vrect.width = viddef.width * size / 100; + scr_vrect.width= viddef.width * size / 100; scr_vrect.width &= ~7; - scr_vrect.height = viddef.height * size / 100; + scr_vrect.height= viddef.height * size / 100; scr_vrect.height &= ~1; - scr_vrect.x = (viddef.width - scr_vrect.width) / 2; - scr_vrect.y = (viddef.height - scr_vrect.height) / 2; + scr_vrect.x= (viddef.width - scr_vrect.width) / 2; + scr_vrect.y= (viddef.height - scr_vrect.height) / 2; } /* @@ -370,8 +354,7 @@ public final class SCR extends Globals Keybinding command ================= */ - static void SizeUp_f() - { + static void SizeUp_f() { Cvar.SetValue("viewsize", scr_viewsize.value + 10); } @@ -382,8 +365,7 @@ public final class SCR extends Globals Keybinding command ================= */ - static void SizeDown_f() - { + static void SizeDown_f() { Cvar.SetValue("viewsize", scr_viewsize.value - 10); } @@ -394,31 +376,27 @@ public final class SCR extends Globals Set a specific sky and rotation speed ================= */ - static void Sky_f() - { + static void Sky_f() { float rotate; - float[] axis = { 0, 0, 0 }; + float[] axis= { 0, 0, 0 }; - if (Cmd.Argc() < 2) - { + if (Cmd.Argc() < 2) { Com.Printf("Usage: sky \n"); return; } if (Cmd.Argc() > 2) - rotate = Float.parseFloat(Cmd.Argv(2)); + rotate= Float.parseFloat(Cmd.Argv(2)); else - rotate = 0; - if (Cmd.Argc() == 6) - { - axis[0] = Float.parseFloat(Cmd.Argv(3)); - axis[1] = Float.parseFloat(Cmd.Argv(4)); - axis[2] = Float.parseFloat(Cmd.Argv(5)); + rotate= 0; + if (Cmd.Argc() == 6) { + axis[0]= Float.parseFloat(Cmd.Argv(3)); + axis[1]= Float.parseFloat(Cmd.Argv(4)); + axis[2]= Float.parseFloat(Cmd.Argv(5)); } - else - { - axis[0] = 0; - axis[1] = 0; - axis[2] = 1; + else { + axis[0]= 0; + axis[1]= 0; + axis[2]= 1; } re.SetSky(Cmd.Argv(1), rotate, axis); @@ -431,63 +409,52 @@ public final class SCR extends Globals SCR_Init ================== */ - static void Init() - { - scr_viewsize = Cvar.Get("viewsize", "100", CVAR_ARCHIVE); - scr_conspeed = Cvar.Get("scr_conspeed", "3", 0); - scr_showturtle = Cvar.Get("scr_showturtle", "0", 0); - scr_showpause = Cvar.Get("scr_showpause", "1", 0); - scr_centertime = Cvar.Get("scr_centertime", "2.5", 0); - scr_printspeed = Cvar.Get("scr_printspeed", "8", 0); - scr_netgraph = Cvar.Get("netgraph", "1", 0); - scr_timegraph = Cvar.Get("timegraph", "1", 0); - scr_debuggraph = Cvar.Get("debuggraph", "1", 0); - scr_graphheight = Cvar.Get("graphheight", "32", 0); - scr_graphscale = Cvar.Get("graphscale", "1", 0); - scr_graphshift = Cvar.Get("graphshift", "0", 0); - scr_drawall = Cvar.Get("scr_drawall", "1", 0); - fps = Cvar.Get("fps", "0", 0); + static void Init() { + scr_viewsize= Cvar.Get("viewsize", "100", CVAR_ARCHIVE); + scr_conspeed= Cvar.Get("scr_conspeed", "3", 0); + scr_showturtle= Cvar.Get("scr_showturtle", "0", 0); + scr_showpause= Cvar.Get("scr_showpause", "1", 0); + scr_centertime= Cvar.Get("scr_centertime", "2.5", 0); + scr_printspeed= Cvar.Get("scr_printspeed", "8", 0); + scr_netgraph= Cvar.Get("netgraph", "1", 0); + scr_timegraph= Cvar.Get("timegraph", "1", 0); + scr_debuggraph= Cvar.Get("debuggraph", "1", 0); + scr_graphheight= Cvar.Get("graphheight", "32", 0); + scr_graphscale= Cvar.Get("graphscale", "1", 0); + scr_graphshift= Cvar.Get("graphshift", "0", 0); + scr_drawall= Cvar.Get("scr_drawall", "1", 0); + fps= Cvar.Get("fps", "0", 0); // // register our commands // - Cmd.AddCommand("timerefresh", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("timerefresh", new xcommand_t() { + public void execute() { TimeRefresh_f(); } }); - Cmd.AddCommand("loading", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("loading", new xcommand_t() { + public void execute() { Loading_f(); } }); - Cmd.AddCommand("sizeup", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("sizeup", new xcommand_t() { + public void execute() { SizeUp_f(); } }); - Cmd.AddCommand("sizedown", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("sizedown", new xcommand_t() { + public void execute() { SizeDown_f(); } }); - Cmd.AddCommand("sky", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("sky", new xcommand_t() { + public void execute() { Sky_f(); } }); - scr_initialized = true; + scr_initialized= true; } /* @@ -495,8 +462,7 @@ public final class SCR extends Globals SCR_DrawNet ============== */ - static void DrawNet() - { + static void DrawNet() { if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP - 1) return; @@ -508,9 +474,8 @@ public final class SCR extends Globals SCR_DrawPause ============== */ - static void DrawPause() - { - Dimension dim = new Dimension(); + static void DrawPause() { + Dimension dim= new Dimension(); if (scr_showpause.value == 0) // turn off for screenshots return; @@ -527,14 +492,13 @@ public final class SCR extends Globals SCR_DrawLoading ============== */ - static void DrawLoading() - { - Dimension dim = new Dimension(); + static void DrawLoading() { + Dimension dim= new Dimension(); if (scr_draw_loading == 0) return; - scr_draw_loading = 0; + scr_draw_loading= 0; re.DrawGetPicSize(dim, "loading"); re.DrawPic((viddef.width - dim.width) / 2, (viddef.height - dim.height) / 2, "loading"); } @@ -548,26 +512,23 @@ public final class SCR extends Globals Scroll it up or down ================== */ - static void RunConsole() - { + static void RunConsole() { // decide on the height of the console if (cls.key_dest == key_console) - scr_conlines = 0.5f; // half screen + scr_conlines= 0.5f; // half screen else - scr_conlines = 0; // none visible + scr_conlines= 0; // none visible - if (scr_conlines < scr_con_current) - { + if (scr_conlines < scr_con_current) { scr_con_current -= scr_conspeed.value * cls.frametime; if (scr_conlines > scr_con_current) - scr_con_current = scr_conlines; + scr_con_current= scr_conlines; } - else if (scr_conlines > scr_con_current) - { + else if (scr_conlines > scr_con_current) { scr_con_current += scr_conspeed.value * cls.frametime; if (scr_conlines < scr_con_current) - scr_con_current = scr_conlines; + scr_con_current= scr_conlines; } } @@ -576,29 +537,24 @@ public final class SCR extends Globals SCR_DrawConsole ================== */ - static void DrawConsole() - { + static void DrawConsole() { Console.CheckResize(); - if (cls.state == ca_disconnected || cls.state == ca_connecting) - { // forced full screen console + if (cls.state == ca_disconnected || cls.state == ca_connecting) { // forced full screen console Console.DrawConsole(1.0f); return; } - if (cls.state != ca_active || !cl.refresh_prepped) - { // connected, but can't render + if (cls.state != ca_active || !cl.refresh_prepped) { // connected, but can't render Console.DrawConsole(0.5f); re.DrawFill(0, viddef.height / 2, viddef.width, viddef.height / 2, 0); return; } - if (scr_con_current != 0) - { + if (scr_con_current != 0) { Console.DrawConsole(scr_con_current); } - else - { + else { if (cls.key_dest == key_game || cls.key_dest == key_message) Console.DrawNotify(); // only draw notify in game } @@ -611,10 +567,9 @@ public final class SCR extends Globals SCR_BeginLoadingPlaque ================ */ - public static void BeginLoadingPlaque() - { + public static void BeginLoadingPlaque() { S.StopAllSounds(); - cl.sound_prepped = false; // don't play ambients + cl.sound_prepped= false; // don't play ambients if (cls.disable_screen != 0) return; @@ -625,13 +580,13 @@ public final class SCR extends Globals if (cls.key_dest == key_console) return; if (cl.cinematictime > 0) - scr_draw_loading = 2; // clear to balack first + scr_draw_loading= 2; // clear to balack first else - scr_draw_loading = 1; + scr_draw_loading= 1; UpdateScreen(); - cls.disable_screen = Sys.Milliseconds(); - cls.disable_servercount = cl.servercount; + cls.disable_screen= Sys.Milliseconds(); + cls.disable_servercount= cl.servercount; } /* @@ -639,9 +594,8 @@ public final class SCR extends Globals SCR_EndLoadingPlaque ================ */ - public static void EndLoadingPlaque() - { - cls.disable_screen = 0; + public static void EndLoadingPlaque() { + cls.disable_screen= 0; Console.ClearNotify(); } @@ -650,8 +604,7 @@ public final class SCR extends Globals SCR_Loading_f ================ */ - static void Loading_f() - { + static void Loading_f() { BeginLoadingPlaque(); } @@ -660,8 +613,7 @@ public final class SCR extends Globals SCR_TimeRefresh_f ================ */ - static void TimeRefresh_f() - { + static void TimeRefresh_f() { int i; int start, stop; float time; @@ -669,23 +621,19 @@ public final class SCR extends Globals if (cls.state != ca_active) return; - start = Sys.Milliseconds(); + start= Sys.Milliseconds(); - if (Cmd.Argc() == 2) - { // run without page flipping + if (Cmd.Argc() == 2) { // run without page flipping re.BeginFrame(0); - for (i = 0; i < 128; i++) - { - cl.refdef.viewangles[1] = i / 128.0f * 360.0f; + for (i= 0; i < 128; i++) { + cl.refdef.viewangles[1]= i / 128.0f * 360.0f; re.RenderFrame(cl.refdef); } re.EndFrame(); } - else - { - for (i = 0; i < 128; i++) - { - cl.refdef.viewangles[1] = i / 128.0f * 360.0f; + else { + for (i= 0; i < 128; i++) { + cl.refdef.viewangles[1]= i / 128.0f * 360.0f; re.BeginFrame(0); re.RenderFrame(cl.refdef); @@ -693,13 +641,12 @@ public final class SCR extends Globals } } - stop = Sys.Milliseconds(); - time = (stop - start) / 1000.0f; + stop= Sys.Milliseconds(); + time= (stop - start) / 1000.0f; Com.Printf("%f seconds (%f fps)\n", new Vargs(2).add(time).add(128.0f / time)); } - static void DirtyScreen() - { + static void DirtyScreen() { AddDirtyPoint(0, 0); AddDirtyPoint(viddef.width - 1, viddef.height - 1); } @@ -712,10 +659,9 @@ public final class SCR extends Globals ============== */ - static dirty_t clear = new dirty_t(); + static dirty_t clear= new dirty_t(); - static void TileClear() - { + static void TileClear() { int i; int top, bottom, left, right; clear.clear(); @@ -733,74 +679,69 @@ public final class SCR extends Globals // erase rect will be the union of the past three frames // so tripple buffering works properly clear.set(scr_dirty); - for (i = 0; i < 2; i++) - { + for (i= 0; i < 2; i++) { if (scr_old_dirty[i].x1 < clear.x1) - clear.x1 = scr_old_dirty[i].x1; + clear.x1= scr_old_dirty[i].x1; if (scr_old_dirty[i].x2 > clear.x2) - clear.x2 = scr_old_dirty[i].x2; + clear.x2= scr_old_dirty[i].x2; if (scr_old_dirty[i].y1 < clear.y1) - clear.y1 = scr_old_dirty[i].y1; + clear.y1= scr_old_dirty[i].y1; if (scr_old_dirty[i].y2 > clear.y2) - clear.y2 = scr_old_dirty[i].y2; + clear.y2= scr_old_dirty[i].y2; } scr_old_dirty[1].set(scr_old_dirty[0]); scr_old_dirty[0].set(scr_dirty); - scr_dirty.x1 = 9999; - scr_dirty.x2 = -9999; - scr_dirty.y1 = 9999; - scr_dirty.y2 = -9999; + scr_dirty.x1= 9999; + scr_dirty.x2= -9999; + scr_dirty.y1= 9999; + scr_dirty.y2= -9999; // don't bother with anything convered by the console) - top = (int) (scr_con_current * viddef.height); + top= (int) (scr_con_current * viddef.height); if (top >= clear.y1) - clear.y1 = top; + clear.y1= top; if (clear.y2 <= clear.y1) return; // nothing disturbed - top = scr_vrect.y; - bottom = top + scr_vrect.height - 1; - left = scr_vrect.x; - right = left + scr_vrect.width - 1; + top= scr_vrect.y; + bottom= top + scr_vrect.height - 1; + left= scr_vrect.x; + right= left + scr_vrect.width - 1; - if (clear.y1 < top) - { // clear above view screen - i = clear.y2 < top - 1 ? clear.y2 : top - 1; + if (clear.y1 < top) { // clear above view screen + i= clear.y2 < top - 1 ? clear.y2 : top - 1; re.DrawTileClear(clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1, "backtile"); - clear.y1 = top; + clear.y1= top; } - if (clear.y2 > bottom) - { // clear below view screen - i = clear.y1 > bottom + 1 ? clear.y1 : bottom + 1; + if (clear.y2 > bottom) { // clear below view screen + i= clear.y1 > bottom + 1 ? clear.y1 : bottom + 1; re.DrawTileClear(clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1, "backtile"); - clear.y2 = bottom; + clear.y2= bottom; } - if (clear.x1 < left) - { // clear left of view screen - i = clear.x2 < left - 1 ? clear.x2 : left - 1; + if (clear.x1 < left) { // clear left of view screen + i= clear.x2 < left - 1 ? clear.x2 : left - 1; re.DrawTileClear(clear.x1, clear.y1, i - clear.x1 + 1, clear.y2 - clear.y1 + 1, "backtile"); - clear.x1 = left; + clear.x1= left; } - if (clear.x2 > right) - { // clear left of view screen - i = clear.x1 > right + 1 ? clear.x1 : right + 1; + if (clear.x2 > right) { // clear left of view screen + i= clear.x1 > right + 1 ? clear.x1 : right + 1; re.DrawTileClear(i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1, "backtile"); - clear.x2 = right; + clear.x2= right; } } // =============================================================== - static final int STAT_MINUS = 10; // num frame for '-' stats digit + static final int STAT_MINUS= 10; // num frame for '-' stats digit - static final int ICON_WIDTH = 24; - static final int ICON_HEIGHT = 24; - static final int CHAR_WIDTH = 16; - static final int ICON_SPACE = 8; + static final int ICON_WIDTH= 24; + static final int ICON_HEIGHT= 24; + static final int CHAR_WIDTH= 16; + static final int ICON_SPACE= 8; /* ================ @@ -809,64 +750,56 @@ public final class SCR extends Globals Allow embedded \n in the string ================ */ - static void SizeHUDString(String string, Dimension dim) - { + static void SizeHUDString(String string, Dimension dim) { int lines, width, current; - lines = 1; - width = 0; + lines= 1; + width= 0; - current = 0; - for (int i = 0; i < string.length(); i++) - { - if (string.charAt(i) == '\n') - { + current= 0; + for (int i= 0; i < string.length(); i++) { + if (string.charAt(i) == '\n') { lines++; - current = 0; + current= 0; } - else - { + else { current++; if (current > width) - width = current; + width= current; } } - dim.width = width * 8; - dim.height = lines * 8; + dim.width= width * 8; + dim.height= lines * 8; } - static void DrawHUDString(String string, int x, int y, int centerwidth, int xor) - { + static void DrawHUDString(String string, int x, int y, int centerwidth, int xor) { int margin; //char line[1024]; - StringBuffer line = new StringBuffer(1024); + StringBuffer line= new StringBuffer(1024); int i; - margin = x; + margin= x; - for (int l = 0; l < string.length();) - { + for (int l= 0; l < string.length();) { // scan out one line of text from the string - line = new StringBuffer(1024); + line= new StringBuffer(1024); while (string.charAt(l) != '\n') line.append(string.charAt(l)); l++; if (centerwidth != 0) - x = margin + (centerwidth - line.length() * 8) / 2; + x= margin + (centerwidth - line.length() * 8) / 2; else - x = margin; - for (i = 0; i < line.length(); i++) - { + x= margin; + for (i= 0; i < line.length(); i++) { re.DrawChar(x, y, line.charAt(i) ^ xor); x += 8; } - if (l < string.length()) - { + if (l < string.length()) { l++; // skip the \n - x = margin; + x= margin; y += 8; } } @@ -877,8 +810,7 @@ public final class SCR extends Globals SCR_DrawField ============== */ - static void DrawField(int x, int y, int color, int width, int value) - { + static void DrawField(int x, int y, int color, int width, int value) { char ptr; String num; int l; @@ -889,26 +821,25 @@ public final class SCR extends Globals // draw number string if (width > 5) - width = 5; + width= 5; AddDirtyPoint(x, y); AddDirtyPoint(x + width * CHAR_WIDTH + 2, y + 23); - num = "" + value; - l = num.length(); + num= "" + value; + l= num.length(); if (l > width) - l = width; + l= width; x += 2 + CHAR_WIDTH * (width - l); - ptr = num.charAt(0); + ptr= num.charAt(0); - for (int i = 0; i < l; i++) - { - ptr = num.charAt(i); + for (int i= 0; i < l; i++) { + ptr= num.charAt(i); if (ptr == '-') - frame = STAT_MINUS; + frame= STAT_MINUS; else - frame = ptr - '0'; + frame= ptr - '0'; re.DrawPic(x, y, sb_nums[color][frame]); x += CHAR_WIDTH; @@ -922,26 +853,24 @@ public final class SCR extends Globals Allows rendering code to cache all needed sbar graphics =============== */ - static void TouchPics() - { + static void TouchPics() { int i, j; - for (i = 0; i < 2; i++) - for (j = 0; j < 11; j++) + for (i= 0; i < 2; i++) + for (j= 0; j < 11; j++) re.RegisterPic(sb_nums[i][j]); - if (crosshair.value != 0.0f) - { + if (crosshair.value != 0.0f) { if (crosshair.value > 3.0f || crosshair.value < 0.0f) - crosshair.value = 3.0f; + crosshair.value= 3.0f; - crosshair_pic = "ch" + (int) crosshair.value; - Dimension dim = new Dimension(); + crosshair_pic= "ch" + (int) crosshair.value; + Dimension dim= new Dimension(); re.DrawGetPicSize(dim, crosshair_pic); - crosshair_width = dim.width; - crosshair_height = dim.height; + crosshair_width= dim.width; + crosshair_height= dim.height; if (crosshair_width == 0) - crosshair_pic = ""; + crosshair_pic= ""; } } @@ -951,8 +880,7 @@ public final class SCR extends Globals ================ */ - static void ExecuteLayoutString(String s) - { + static void ExecuteLayoutString(String s) { int x, y; int value; String token; @@ -967,61 +895,52 @@ public final class SCR extends Globals if (s == null || s.length() == 0) return; - x = 0; - y = 0; - width = 3; + x= 0; + y= 0; + width= 3; - Com.ParseHelp ph = new Com.ParseHelp(s); + Com.ParseHelp ph= new Com.ParseHelp(s); - while (!ph.isEof()) - { - token = Com.Parse(ph); - if (token.equals("xl")) - { - token = Com.Parse(ph); - x = atoi(token); + while (!ph.isEof()) { + token= Com.Parse(ph); + if (token.equals("xl")) { + token= Com.Parse(ph); + x= atoi(token); continue; } - if (token.equals("xr")) - { - token = Com.Parse(ph); - x = viddef.width + atoi(token); + if (token.equals("xr")) { + token= Com.Parse(ph); + x= viddef.width + atoi(token); continue; } - if (token.equals("xv")) - { - token = Com.Parse(ph); - x = viddef.width / 2 - 160 + atoi(token); + if (token.equals("xv")) { + token= Com.Parse(ph); + x= viddef.width / 2 - 160 + atoi(token); continue; } - if (token.equals("yt")) - { - token = Com.Parse(ph); - y = atoi(token); + if (token.equals("yt")) { + token= Com.Parse(ph); + y= atoi(token); continue; } - if (token.equals("yb")) - { - token = Com.Parse(ph); - y = viddef.height + atoi(token); + if (token.equals("yb")) { + token= Com.Parse(ph); + y= viddef.height + atoi(token); continue; } - if (token.equals("yv")) - { - token = Com.Parse(ph); - y = viddef.height / 2 - 120 + atoi(token); + if (token.equals("yv")) { + token= Com.Parse(ph); + y= viddef.height / 2 - 120 + atoi(token); continue; } - if (token.equals("pic")) - { // draw a pic from a stat number - token = Com.Parse(ph); - value = cl.frame.playerstate.stats[atoi(token)]; + if (token.equals("pic")) { // draw a pic from a stat number + token= Com.Parse(ph); + value= cl.frame.playerstate.stats[atoi(token)]; if (value >= MAX_IMAGES) Com.Error(ERR_DROP, "Pic >= MAX_IMAGES"); - if (cl.configstrings[CS_IMAGES + value] != null) - { + if (cl.configstrings[CS_IMAGES + value] != null) { AddDirtyPoint(x, y); AddDirtyPoint(x + 23, y + 23); re.DrawPic(x, y, cl.configstrings[CS_IMAGES + value]); @@ -1029,31 +948,30 @@ public final class SCR extends Globals continue; } - if (token.equals("client")) - { // draw a deathmatch client block + if (token.equals("client")) { // draw a deathmatch client block int score, ping, time; - token = Com.Parse(ph); - x = viddef.width / 2 - 160 + atoi(token); - token = Com.Parse(ph); - y = viddef.height / 2 - 120 + atoi(token); + token= Com.Parse(ph); + x= viddef.width / 2 - 160 + atoi(token); + token= Com.Parse(ph); + y= viddef.height / 2 - 120 + atoi(token); AddDirtyPoint(x, y); AddDirtyPoint(x + 159, y + 31); - token = Com.Parse(ph); - value = atoi(token); + token= Com.Parse(ph); + value= atoi(token); if (value >= MAX_CLIENTS || value < 0) Com.Error(ERR_DROP, "client >= MAX_CLIENTS"); - ci = cl.clientinfo[value]; + ci= cl.clientinfo[value]; - token = Com.Parse(ph); - score = atoi(token); + token= Com.Parse(ph); + score= atoi(token); - token = Com.Parse(ph); - ping = atoi(token); + token= Com.Parse(ph); + ping= atoi(token); - token = Com.Parse(ph); - time = atoi(token); + token= Com.Parse(ph); + time= atoi(token); Console.DrawAltString(x + 32, y, ci.name); Console.DrawString(x + 32, y + 8, "Score: "); @@ -1062,38 +980,37 @@ public final class SCR extends Globals Console.DrawString(x + 32, y + 24, "Time: " + time); if (ci.icon == null) - ci = cl.baseclientinfo; + ci= cl.baseclientinfo; re.DrawPic(x, y, ci.iconname); continue; } - if (token.equals("ctf")) - { // draw a ctf client block + if (token.equals("ctf")) { // draw a ctf client block int score, ping; - token = Com.Parse(ph); - x = viddef.width / 2 - 160 + atoi(token); - token = Com.Parse(ph); - y = viddef.height / 2 - 120 + atoi(token); + token= Com.Parse(ph); + x= viddef.width / 2 - 160 + atoi(token); + token= Com.Parse(ph); + y= viddef.height / 2 - 120 + atoi(token); AddDirtyPoint(x, y); AddDirtyPoint(x + 159, y + 31); - token = Com.Parse(ph); - value = atoi(token); + token= Com.Parse(ph); + value= atoi(token); if (value >= MAX_CLIENTS || value < 0) Com.Error(ERR_DROP, "client >= MAX_CLIENTS"); - ci = cl.clientinfo[value]; + ci= cl.clientinfo[value]; - token = Com.Parse(ph); - score = atoi(token); + token= Com.Parse(ph); + score= atoi(token); - token = Com.Parse(ph); - ping = atoi(token); + token= Com.Parse(ph); + ping= atoi(token); if (ping > 999) - ping = 999; + ping= 999; // sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name); - String block = Com.sprintf("%3d %3d %-12.12s", new Vargs(3).add(score).add(ping).add(ci.name)); + String block= Com.sprintf("%3d %3d %-12.12s", new Vargs(3).add(score).add(ping).add(ci.name)); if (value == cl.playernum) Console.DrawAltString(x, y, block); @@ -1102,37 +1019,34 @@ public final class SCR extends Globals continue; } - if (token.equals("picn")) - { // draw a pic from a name - token = Com.Parse(ph); + if (token.equals("picn")) { // draw a pic from a name + token= Com.Parse(ph); AddDirtyPoint(x, y); AddDirtyPoint(x + 23, y + 23); re.DrawPic(x, y, token); continue; } - if (token.equals("num")) - { // draw a number - token = Com.Parse(ph); - width = atoi(token); - token = Com.Parse(ph); - value = cl.frame.playerstate.stats[atoi(token)]; + if (token.equals("num")) { // draw a number + token= Com.Parse(ph); + width= atoi(token); + token= Com.Parse(ph); + value= cl.frame.playerstate.stats[atoi(token)]; DrawField(x, y, 0, width, value); continue; } - if (token.equals("hnum")) - { // health number + if (token.equals("hnum")) { // health number int color; - width = 3; - value = cl.frame.playerstate.stats[STAT_HEALTH]; + width= 3; + value= cl.frame.playerstate.stats[STAT_HEALTH]; if (value > 25) - color = 0; // green + color= 0; // green else if (value > 0) - color = (cl.frame.serverframe >> 2) & 1; // flash + color= (cl.frame.serverframe >> 2) & 1; // flash else - color = 1; + color= 1; if ((cl.frame.playerstate.stats[STAT_FLASHES] & 1) != 0) re.DrawPic(x, y, "field_3"); @@ -1141,16 +1055,15 @@ public final class SCR extends Globals continue; } - if (token.equals("anum")) - { // ammo number + if (token.equals("anum")) { // ammo number int color; - width = 3; - value = cl.frame.playerstate.stats[STAT_AMMO]; + width= 3; + value= cl.frame.playerstate.stats[STAT_AMMO]; if (value > 5) - color = 0; // green + color= 0; // green else if (value >= 0) - color = (cl.frame.serverframe >> 2) & 1; // flash + color= (cl.frame.serverframe >> 2) & 1; // flash else continue; // negative number = don't show @@ -1161,16 +1074,15 @@ public final class SCR extends Globals continue; } - if (token.equals("rnum")) - { // armor number + if (token.equals("rnum")) { // armor number int color; - width = 3; - value = cl.frame.playerstate.stats[STAT_ARMOR]; + width= 3; + value= cl.frame.playerstate.stats[STAT_ARMOR]; if (value < 1) continue; - color = 0; // green + color= 0; // green if ((cl.frame.playerstate.stats[STAT_FLASHES] & 2) != 0) re.DrawPic(x, y, "field_3"); @@ -1179,59 +1091,52 @@ public final class SCR extends Globals continue; } - if (token.equals("stat_string")) - { - token = Com.Parse(ph); - index = atoi(token); + if (token.equals("stat_string")) { + token= Com.Parse(ph); + index= atoi(token); if (index < 0 || index >= MAX_CONFIGSTRINGS) Com.Error(ERR_DROP, "Bad stat_string index"); - index = cl.frame.playerstate.stats[index]; + index= cl.frame.playerstate.stats[index]; if (index < 0 || index >= MAX_CONFIGSTRINGS) Com.Error(ERR_DROP, "Bad stat_string index"); Console.DrawString(x, y, cl.configstrings[index]); continue; } - if (token.equals("cstring")) - { - token = Com.Parse(ph); + if (token.equals("cstring")) { + token= Com.Parse(ph); DrawHUDString(token, x, y, 320, 0); continue; } - if (token.equals("string")) - { - token = Com.Parse(ph); + if (token.equals("string")) { + token= Com.Parse(ph); Console.DrawString(x, y, token); continue; } - if (token.equals("cstring2")) - { - token = Com.Parse(ph); + if (token.equals("cstring2")) { + token= Com.Parse(ph); DrawHUDString(token, x, y, 320, 0x80); continue; } - if (token.equals("string2")) - { - token = Com.Parse(ph); + if (token.equals("string2")) { + token= Com.Parse(ph); Console.DrawAltString(x, y, token); continue; } - if (token.equals("if")) - { // draw a number - token = Com.Parse(ph); - value = cl.frame.playerstate.stats[atoi(token)]; - if (value == 0) - { // skip to endif + if (token.equals("if")) { // draw a number + token= Com.Parse(ph); + value= cl.frame.playerstate.stats[atoi(token)]; + if (value == 0) { // skip to endif // while (s && strcmp(token, "endif") ) // { // token = Com.Parse(ph); // } - while (!ph.isEof() && !(token = Com.Parse(ph)).equals("endif")); + while (!ph.isEof() && !(token= Com.Parse(ph)).equals("endif")); } @@ -1249,8 +1154,7 @@ public final class SCR extends Globals is based on the stats array ================ */ - static void DrawStats() - { + static void DrawStats() { //TODO: SCR.ExecuteLayoutString(cl.configstrings[CS_STATUSBAR]); } @@ -1261,10 +1165,9 @@ public final class SCR extends Globals ================ */ - static final int STAT_LAYOUTS = 13; + static final int STAT_LAYOUTS= 13; - static void DrawLayout() - { + static void DrawLayout() { if (cl.frame.playerstate.stats[STAT_LAYOUTS] != 0) return; SCR.ExecuteLayoutString(cl.layout); @@ -1280,19 +1183,16 @@ public final class SCR extends Globals text to the screen. ================== */ - static void UpdateScreen2() - { + static void UpdateScreen2() { int numframes; int i; - float[] separation = { 0, 0 }; + float[] separation= { 0, 0 }; // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all - if (cls.disable_screen != 0) - { - if (Sys.Milliseconds() - cls.disable_screen > 120000) - { - cls.disable_screen = 0; + if (cls.disable_screen != 0) { + if (Sys.Milliseconds() - cls.disable_screen > 120000) { + cls.disable_screen= 0; Com.Printf("Loading plaque timed out.\n"); } return; @@ -1310,67 +1210,55 @@ public final class SCR extends Globals else if (cl_stereo_separation.value < 0) Cvar.SetValue("cl_stereo_separation", 0.0f); - if (cl_stereo.value != 0) - { - numframes = 2; - separation[0] = -cl_stereo_separation.value / 2; - separation[1] = cl_stereo_separation.value / 2; + if (cl_stereo.value != 0) { + numframes= 2; + separation[0]= -cl_stereo_separation.value / 2; + separation[1]= cl_stereo_separation.value / 2; } - else - { - separation[0] = 0; - separation[1] = 0; - numframes = 1; + else { + separation[0]= 0; + separation[1]= 0; + numframes= 1; } - for (i = 0; i < numframes; i++) - { + for (i= 0; i < numframes; i++) { re.BeginFrame(separation[i]); - if (scr_draw_loading == 2) - { // loading plaque over black screen - Dimension dim = new Dimension(); + if (scr_draw_loading == 2) { // loading plaque over black screen + Dimension dim= new Dimension(); re.CinematicSetPalette(null); - scr_draw_loading = 0; // false + scr_draw_loading= 0; // false re.DrawGetPicSize(dim, "loading"); re.DrawPic((viddef.width - dim.width) / 2, (viddef.height - dim.height) / 2, "loading"); } // if a cinematic is supposed to be running, handle menus // and console specially - else if (cl.cinematictime > 0) - { - if (cls.key_dest == key_menu) - { - if (cl.cinematicpalette_active) - { + else if (cl.cinematictime > 0) { + if (cls.key_dest == key_menu) { + if (cl.cinematicpalette_active) { re.CinematicSetPalette(null); - cl.cinematicpalette_active = false; + cl.cinematicpalette_active= false; } Menu.Draw(); } - else if (cls.key_dest == key_console) - { - if (cl.cinematicpalette_active) - { + else if (cls.key_dest == key_console) { + if (cl.cinematicpalette_active) { re.CinematicSetPalette(null); - cl.cinematicpalette_active = false; + cl.cinematicpalette_active= false; } DrawConsole(); } - else - { + else { // TODO impl: cl_cin.c for cinematics DrawCinematic(); } } - else - { + else { // make sure the game palette is active - if (cl.cinematicpalette_active) - { + if (cl.cinematicpalette_active) { re.CinematicSetPalette(null); - cl.cinematicpalette_active = false; + cl.cinematicpalette_active= false; } // do 3D refresh drawing, and then update the screen @@ -1382,7 +1270,7 @@ public final class SCR extends Globals V.RenderView(separation[i]); DrawStats(); - // TODO impl this + if ((cl.frame.playerstate.stats[STAT_LAYOUTS] & 1) != 0) DrawLayout(); if ((cl.frame.playerstate.stats[STAT_LAYOUTS] & 2) != 0) @@ -1414,14 +1302,12 @@ public final class SCR extends Globals SCR_DrawCrosshair ================= */ - static void DrawCrosshair() - { + static void DrawCrosshair() { if (crosshair.value == 0.0f) return; - if (crosshair.modified) - { - crosshair.modified = false; + if (crosshair.modified) { + crosshair.modified= false; SCR.TouchPics(); } @@ -1434,15 +1320,14 @@ public final class SCR extends Globals crosshair_pic); } - private static xcommand_t updateScreenCallback = new xcommand_t() { + private static xcommand_t updateScreenCallback= new xcommand_t() { public void execute() { UpdateScreen2(); } - }; + }; // wird anstelle von der richtigen UpdateScreen benoetigt - public static void UpdateScreen() - { + public static void UpdateScreen() { Globals.re.updateScreen(updateScreenCallback); } @@ -1451,53 +1336,49 @@ public final class SCR extends Globals SCR_AddDirtyPoint ================= */ - static void AddDirtyPoint(int x, int y) - { + static void AddDirtyPoint(int x, int y) { if (x < scr_dirty.x1) - scr_dirty.x1 = x; + scr_dirty.x1= x; if (x > scr_dirty.x2) - scr_dirty.x2 = x; + scr_dirty.x2= x; if (y < scr_dirty.y1) - scr_dirty.y1 = y; + scr_dirty.y1= y; if (y > scr_dirty.y2) - scr_dirty.y2 = y; + scr_dirty.y2= y; } - private static int lastframes = 0; - private static int lasttime = 0; - private static String fpsvalue = ""; - - static void DrawFPS() - { - if (fps.value > 0.0f) - { + private static int lastframes= 0; + private static int lasttime= 0; + private static String fpsvalue= ""; + + static void DrawFPS() { + if (fps.value > 0.0f) { if (fps.modified) { - fps.modified = false; + fps.modified= false; Cvar.SetValue("cl_maxfps", 1000); } - - int diff = cls.realtime - lasttime; - if (diff > (int) (fps.value * 1000)) - { - fpsvalue = (cls.framecount - lastframes) * 100000 / diff / 100.0f + " fps"; - lastframes = cls.framecount; - lasttime = cls.realtime; + + int diff= cls.realtime - lasttime; + if (diff > (int) (fps.value * 1000)) { + fpsvalue= (cls.framecount - lastframes) * 100000 / diff / 100.0f + " fps"; + lastframes= cls.framecount; + lasttime= cls.realtime; } - int x = viddef.width - 8 * fpsvalue.length() - 2; - for (int i = 0; i < fpsvalue.length(); i++) - { + int x= viddef.width - 8 * fpsvalue.length() - 2; + for (int i= 0; i < fpsvalue.length(); i++) { re.DrawChar(x, 2, fpsvalue.charAt(i)); x += 8; } - } else if (fps.modified){ - fps.modified = false; - Cvar.SetValue("cl_maxfps", 90); + } + else if (fps.modified) { + fps.modified= false; + Cvar.SetValue("cl_maxfps", 90); } } - + /* ================================================================= - + cl_cin.c Play Cinematics @@ -1505,130 +1386,130 @@ public final class SCR extends Globals ================================================================= */ -// typedef struct -// { -// byte *data; -// int count; -// } cblock_t; -// -// typedef struct -// { -// qboolean restart_sound; -// int s_rate; -// int s_width; -// int s_channels; -// -// int width; -// int height; -// byte *pic; -// byte *pic_pending; -// -// // order 1 huffman stuff -// int *hnodes1; // [256][256][2]; -// int numhnodes1[256]; -// -// int h_used[512]; -// int h_count[512]; -// } cinematics_t; -// -// cinematics_t cin; -// -// /* -// ================================================================= -// -// PCX LOADING -// -// ================================================================= -// */ -// -// -// /* -// ============== -// SCR_LoadPCX -// ============== -// */ -// void SCR_LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height) -// { -// byte *raw; -// pcx_t *pcx; -// int x, y; -// int len; -// int dataByte, runLength; -// byte *out, *pix; -// -// *pic = NULL; -// -// // -// // load the file -// // -// len = FS_LoadFile (filename, (void **)&raw); -// if (!raw) -// return; // Com_Printf ("Bad pcx file %s\n", filename); -// -// // -// // parse the PCX file -// // -// pcx = (pcx_t *)raw; -// raw = &pcx->data; -// -// if (pcx->manufacturer != 0x0a -// || pcx->version != 5 -// || pcx->encoding != 1 -// || pcx->bits_per_pixel != 8 -// || pcx->xmax >= 640 -// || pcx->ymax >= 480) -// { -// Com_Printf ("Bad pcx file %s\n", filename); -// return; -// } -// -// out = Z_Malloc ( (pcx->ymax+1) * (pcx->xmax+1) ); -// -// *pic = out; -// -// pix = out; -// -// if (palette) -// { -// *palette = Z_Malloc(768); -// memcpy (*palette, (byte *)pcx + len - 768, 768); -// } -// -// if (width) -// *width = pcx->xmax+1; -// if (height) -// *height = pcx->ymax+1; -// -// for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1) -// { -// for (x=0 ; x<=pcx->xmax ; ) -// { -// dataByte = *raw++; -// -// if((dataByte & 0xC0) == 0xC0) -// { -// runLength = dataByte & 0x3F; -// dataByte = *raw++; -// } -// else -// runLength = 1; -// -// while(runLength-- > 0) -// pix[x++] = dataByte; -// } -// -// } -// -// if ( raw - (byte *)pcx > len) -// { -// Com_Printf ("PCX file %s was malformed", filename); -// Z_Free (*pic); -// *pic = NULL; -// } -// -// FS_FreeFile (pcx); -// } -// + // typedef struct + // { + // byte *data; + // int count; + // } cblock_t; + // + // typedef struct + // { + // qboolean restart_sound; + // int s_rate; + // int s_width; + // int s_channels; + // + // int width; + // int height; + // byte *pic; + // byte *pic_pending; + // + // // order 1 huffman stuff + // int *hnodes1; // [256][256][2]; + // int numhnodes1[256]; + // + // int h_used[512]; + // int h_count[512]; + // } cinematics_t; + // + // cinematics_t cin; + // + // /* + // ================================================================= + // + // PCX LOADING + // + // ================================================================= + // */ + // + // + // /* + // ============== + // SCR_LoadPCX + // ============== + // */ + // void SCR_LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height) + // { + // byte *raw; + // pcx_t *pcx; + // int x, y; + // int len; + // int dataByte, runLength; + // byte *out, *pix; + // + // *pic = NULL; + // + // // + // // load the file + // // + // len = FS_LoadFile (filename, (void **)&raw); + // if (!raw) + // return; // Com_Printf ("Bad pcx file %s\n", filename); + // + // // + // // parse the PCX file + // // + // pcx = (pcx_t *)raw; + // raw = &pcx->data; + // + // if (pcx->manufacturer != 0x0a + // || pcx->version != 5 + // || pcx->encoding != 1 + // || pcx->bits_per_pixel != 8 + // || pcx->xmax >= 640 + // || pcx->ymax >= 480) + // { + // Com_Printf ("Bad pcx file %s\n", filename); + // return; + // } + // + // out = Z_Malloc ( (pcx->ymax+1) * (pcx->xmax+1) ); + // + // *pic = out; + // + // pix = out; + // + // if (palette) + // { + // *palette = Z_Malloc(768); + // memcpy (*palette, (byte *)pcx + len - 768, 768); + // } + // + // if (width) + // *width = pcx->xmax+1; + // if (height) + // *height = pcx->ymax+1; + // + // for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1) + // { + // for (x=0 ; x<=pcx->xmax ; ) + // { + // dataByte = *raw++; + // + // if((dataByte & 0xC0) == 0xC0) + // { + // runLength = dataByte & 0x3F; + // dataByte = *raw++; + // } + // else + // runLength = 1; + // + // while(runLength-- > 0) + // pix[x++] = dataByte; + // } + // + // } + // + // if ( raw - (byte *)pcx > len) + // { + // Com_Printf ("PCX file %s was malformed", filename); + // Z_Free (*pic); + // *pic = NULL; + // } + // + // FS_FreeFile (pcx); + // } + // // ============================================================= /* @@ -1636,53 +1517,50 @@ public final class SCR extends Globals SCR_StopCinematic ================== */ - static void StopCinematic() - { - cl.cinematictime = 0; // done -// if (cin.pic) -// { -// Z_Free (cin.pic); -// cin.pic = NULL; -// } -// if (cin.pic_pending) -// { -// Z_Free (cin.pic_pending); -// cin.pic_pending = NULL; -// } - if (cl.cinematicpalette_active) - { + static void StopCinematic() { + cl.cinematictime= 0; // done + // if (cin.pic) + // { + // Z_Free (cin.pic); + // cin.pic = NULL; + // } + // if (cin.pic_pending) + // { + // Z_Free (cin.pic_pending); + // cin.pic_pending = NULL; + // } + if (cl.cinematicpalette_active) { re.CinematicSetPalette(null); - cl.cinematicpalette_active = false; + cl.cinematicpalette_active= false; } -// if (cl.cinematic_file) -// { -// fclose (cl.cinematic_file); -// cl.cinematic_file = NULL; -// } -// if (cin.hnodes1) -// { -// Z_Free (cin.hnodes1); -// cin.hnodes1 = NULL; -// } -// -// // switch back down to 11 khz sound if necessary -// if (cin.restart_sound) -// { -// cin.restart_sound = false; -// CL_Snd_Restart_f (); -// } -// + // if (cl.cinematic_file) + // { + // fclose (cl.cinematic_file); + // cl.cinematic_file = NULL; + // } + // if (cin.hnodes1) + // { + // Z_Free (cin.hnodes1); + // cin.hnodes1 = NULL; + // } + // + // // switch back down to 11 khz sound if necessary + // if (cin.restart_sound) + // { + // cin.restart_sound = false; + // CL_Snd_Restart_f (); + // } + // } /* ==================== SCR_FinishCinematic - + Called when either the cinematic completes, or it is aborted ==================== */ - static void FinishCinematic() - { + static void FinishCinematic() { // tell the server to advance to the next map / cinematic MSG.WriteByte(cls.netchan.message, clc_stringcmd); SZ.Print(cls.netchan.message, "nextserver " + cl.servercount + '\n'); @@ -1690,449 +1568,444 @@ public final class SCR extends Globals // ========================================================================== -// /* -// ================== -// SmallestNode1 -// ================== -// */ -// int SmallestNode1 (int numhnodes) -// { -// int i; -// int best, bestnode; -// -// best = 99999999; -// bestnode = -1; -// for (i=0 ; i>=1; -// //----------- -// if (nodenum < 256) -// { -// hnodes = hnodesbase + (nodenum<<9); -// *out_p++ = nodenum; -// if (!--count) -// break; -// nodenum = cin.numhnodes1[nodenum]; -// } -// nodenum = hnodes[nodenum*2 + (inbyte&1)]; -// inbyte >>=1; -// //----------- -// if (nodenum < 256) -// { -// hnodes = hnodesbase + (nodenum<<9); -// *out_p++ = nodenum; -// if (!--count) -// break; -// nodenum = cin.numhnodes1[nodenum]; -// } -// nodenum = hnodes[nodenum*2 + (inbyte&1)]; -// inbyte >>=1; -// //----------- -// if (nodenum < 256) -// { -// hnodes = hnodesbase + (nodenum<<9); -// *out_p++ = nodenum; -// if (!--count) -// break; -// nodenum = cin.numhnodes1[nodenum]; -// } -// nodenum = hnodes[nodenum*2 + (inbyte&1)]; -// inbyte >>=1; -// //----------- -// if (nodenum < 256) -// { -// hnodes = hnodesbase + (nodenum<<9); -// *out_p++ = nodenum; -// if (!--count) -// break; -// nodenum = cin.numhnodes1[nodenum]; -// } -// nodenum = hnodes[nodenum*2 + (inbyte&1)]; -// inbyte >>=1; -// //----------- -// if (nodenum < 256) -// { -// hnodes = hnodesbase + (nodenum<<9); -// *out_p++ = nodenum; -// if (!--count) -// break; -// nodenum = cin.numhnodes1[nodenum]; -// } -// nodenum = hnodes[nodenum*2 + (inbyte&1)]; -// inbyte >>=1; -// //----------- -// if (nodenum < 256) -// { -// hnodes = hnodesbase + (nodenum<<9); -// *out_p++ = nodenum; -// if (!--count) -// break; -// nodenum = cin.numhnodes1[nodenum]; -// } -// nodenum = hnodes[nodenum*2 + (inbyte&1)]; -// inbyte >>=1; -// //----------- -// if (nodenum < 256) -// { -// hnodes = hnodesbase + (nodenum<<9); -// *out_p++ = nodenum; -// if (!--count) -// break; -// nodenum = cin.numhnodes1[nodenum]; -// } -// nodenum = hnodes[nodenum*2 + (inbyte&1)]; -// inbyte >>=1; -// } -// -// if (input - in.data != in.count && input - in.data != in.count+1) -// { -// Com_Printf ("Decompression overread by %i", (input - in.data) - in.count); -// } -// out.count = out_p - out.data; -// -// return out; -// } -// -// /* -// ================== -// SCR_ReadNextFrame -// ================== -// */ -// byte *SCR_ReadNextFrame (void) -// { -// int r; -// int command; -// byte samples[22050/14*4]; -// byte compressed[0x20000]; -// int size; -// byte *pic; -// cblock_t in, huf1; -// int start, end, count; -// -// // read the next frame -// r = fread (&command, 4, 1, cl.cinematic_file); -// if (r == 0) // we'll give it one more chance -// r = fread (&command, 4, 1, cl.cinematic_file); -// -// if (r != 1) -// return NULL; -// command = LittleLong(command); -// if (command == 2) -// return NULL; // last frame marker -// -// if (command == 1) -// { // read palette -// FS_Read (cl.cinematicpalette, sizeof(cl.cinematicpalette), cl.cinematic_file); -// cl.cinematicpalette_active=0; // dubious.... exposes an edge case -// } -// -// // decompress the next frame -// FS_Read (&size, 4, cl.cinematic_file); -// size = LittleLong(size); -// if (size > sizeof(compressed) || size < 1) -// Com_Error (ERR_DROP, "Bad compressed frame size"); -// FS_Read (compressed, size, cl.cinematic_file); -// -// // read sound -// start = cl.cinematicframe*cin.s_rate/14; -// end = (cl.cinematicframe+1)*cin.s_rate/14; -// count = end - start; -// -// FS_Read (samples, count*cin.s_width*cin.s_channels, cl.cinematic_file); -// -// S_RawSamples (count, cin.s_rate, cin.s_width, cin.s_channels, samples); -// -// in.data = compressed; -// in.count = size; -// -// huf1 = Huff1Decompress (in); -// -// pic = huf1.data; -// -// cl.cinematicframe++; -// -// return pic; -// } -// -// + // /* + // ================== + // SmallestNode1 + // ================== + // */ + // int SmallestNode1 (int numhnodes) + // { + // int i; + // int best, bestnode; + // + // best = 99999999; + // bestnode = -1; + // for (i=0 ; i>=1; + // //----------- + // if (nodenum < 256) + // { + // hnodes = hnodesbase + (nodenum<<9); + // *out_p++ = nodenum; + // if (!--count) + // break; + // nodenum = cin.numhnodes1[nodenum]; + // } + // nodenum = hnodes[nodenum*2 + (inbyte&1)]; + // inbyte >>=1; + // //----------- + // if (nodenum < 256) + // { + // hnodes = hnodesbase + (nodenum<<9); + // *out_p++ = nodenum; + // if (!--count) + // break; + // nodenum = cin.numhnodes1[nodenum]; + // } + // nodenum = hnodes[nodenum*2 + (inbyte&1)]; + // inbyte >>=1; + // //----------- + // if (nodenum < 256) + // { + // hnodes = hnodesbase + (nodenum<<9); + // *out_p++ = nodenum; + // if (!--count) + // break; + // nodenum = cin.numhnodes1[nodenum]; + // } + // nodenum = hnodes[nodenum*2 + (inbyte&1)]; + // inbyte >>=1; + // //----------- + // if (nodenum < 256) + // { + // hnodes = hnodesbase + (nodenum<<9); + // *out_p++ = nodenum; + // if (!--count) + // break; + // nodenum = cin.numhnodes1[nodenum]; + // } + // nodenum = hnodes[nodenum*2 + (inbyte&1)]; + // inbyte >>=1; + // //----------- + // if (nodenum < 256) + // { + // hnodes = hnodesbase + (nodenum<<9); + // *out_p++ = nodenum; + // if (!--count) + // break; + // nodenum = cin.numhnodes1[nodenum]; + // } + // nodenum = hnodes[nodenum*2 + (inbyte&1)]; + // inbyte >>=1; + // //----------- + // if (nodenum < 256) + // { + // hnodes = hnodesbase + (nodenum<<9); + // *out_p++ = nodenum; + // if (!--count) + // break; + // nodenum = cin.numhnodes1[nodenum]; + // } + // nodenum = hnodes[nodenum*2 + (inbyte&1)]; + // inbyte >>=1; + // //----------- + // if (nodenum < 256) + // { + // hnodes = hnodesbase + (nodenum<<9); + // *out_p++ = nodenum; + // if (!--count) + // break; + // nodenum = cin.numhnodes1[nodenum]; + // } + // nodenum = hnodes[nodenum*2 + (inbyte&1)]; + // inbyte >>=1; + // } + // + // if (input - in.data != in.count && input - in.data != in.count+1) + // { + // Com_Printf ("Decompression overread by %i", (input - in.data) - in.count); + // } + // out.count = out_p - out.data; + // + // return out; + // } + // + // /* + // ================== + // SCR_ReadNextFrame + // ================== + // */ + // byte *SCR_ReadNextFrame (void) + // { + // int r; + // int command; + // byte samples[22050/14*4]; + // byte compressed[0x20000]; + // int size; + // byte *pic; + // cblock_t in, huf1; + // int start, end, count; + // + // // read the next frame + // r = fread (&command, 4, 1, cl.cinematic_file); + // if (r == 0) // we'll give it one more chance + // r = fread (&command, 4, 1, cl.cinematic_file); + // + // if (r != 1) + // return NULL; + // command = LittleLong(command); + // if (command == 2) + // return NULL; // last frame marker + // + // if (command == 1) + // { // read palette + // FS_Read (cl.cinematicpalette, sizeof(cl.cinematicpalette), cl.cinematic_file); + // cl.cinematicpalette_active=0; // dubious.... exposes an edge case + // } + // + // // decompress the next frame + // FS_Read (&size, 4, cl.cinematic_file); + // size = LittleLong(size); + // if (size > sizeof(compressed) || size < 1) + // Com_Error (ERR_DROP, "Bad compressed frame size"); + // FS_Read (compressed, size, cl.cinematic_file); + // + // // read sound + // start = cl.cinematicframe*cin.s_rate/14; + // end = (cl.cinematicframe+1)*cin.s_rate/14; + // count = end - start; + // + // FS_Read (samples, count*cin.s_width*cin.s_channels, cl.cinematic_file); + // + // S_RawSamples (count, cin.s_rate, cin.s_width, cin.s_channels, samples); + // + // in.data = compressed; + // in.count = size; + // + // huf1 = Huff1Decompress (in); + // + // pic = huf1.data; + // + // cl.cinematicframe++; + // + // return pic; + // } + // + // /* ================== SCR_RunCinematic - + ================== */ - static void RunCinematic() - { - int frame; + static void RunCinematic() { + int frame; - if (cl.cinematictime <= 0) - { + if (cl.cinematictime <= 0) { StopCinematic(); return; } -// if (cl.cinematicframe == -1) -// return; // static image -// -// if (cls.key_dest != key_game) -// { // pause if menu or console is up -// cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14; -// return; -// } -// -// frame = (cls.realtime - cl.cinematictime)*14.0/1000; -// if (frame <= cl.cinematicframe) -// return; -// if (frame > cl.cinematicframe+1) -// { -// Com_Printf ("Dropped frame: %i > %i\n", frame, cl.cinematicframe+1); -// cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14; -// } -// if (cin.pic) -// Z_Free (cin.pic); -// cin.pic = cin.pic_pending; -// cin.pic_pending = NULL; -// cin.pic_pending = SCR_ReadNextFrame (); -// if (!cin.pic_pending) -// { -// SCR_StopCinematic (); -// SCR_FinishCinematic (); -// cl.cinematictime = 1; // hack to get the black screen behind loading -// SCR_BeginLoadingPlaque (); -// cl.cinematictime = 0; -// return; -// } + // if (cl.cinematicframe == -1) + // return; // static image + // + // if (cls.key_dest != key_game) + // { // pause if menu or console is up + // cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14; + // return; + // } + // + // frame = (cls.realtime - cl.cinematictime)*14.0/1000; + // if (frame <= cl.cinematicframe) + // return; + // if (frame > cl.cinematicframe+1) + // { + // Com_Printf ("Dropped frame: %i > %i\n", frame, cl.cinematicframe+1); + // cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14; + // } + // if (cin.pic) + // Z_Free (cin.pic); + // cin.pic = cin.pic_pending; + // cin.pic_pending = NULL; + // cin.pic_pending = SCR_ReadNextFrame (); + // if (!cin.pic_pending) + // { + // SCR_StopCinematic (); + // SCR_FinishCinematic (); + // cl.cinematictime = 1; // hack to get the black screen behind loading + // SCR_BeginLoadingPlaque (); + // cl.cinematictime = 0; + // return; + // } } /* ================== SCR_DrawCinematic - + Returns true if a cinematic is active, meaning the view rendering should be skipped ================== */ - static boolean DrawCinematic() - { -// if (cl.cinematictime <= 0) -// { - return false; -// } -// -// if (cls.key_dest == key_menu) -// { // blank screen and pause if menu is up -// re.CinematicSetPalette(NULL); -// cl.cinematicpalette_active = false; -// return true; -// } -// -// if (!cl.cinematicpalette_active) -// { -// re.CinematicSetPalette(cl.cinematicpalette); -// cl.cinematicpalette_active = true; -// } -// -// if (!cin.pic) -// return true; -// -// re.DrawStretchRaw (0, 0, viddef.width, viddef.height, -// cin.width, cin.height, cin.pic); -// -// return true; + static boolean DrawCinematic() { + // if (cl.cinematictime <= 0) + // { + return false; + // } + // + // if (cls.key_dest == key_menu) + // { // blank screen and pause if menu is up + // re.CinematicSetPalette(NULL); + // cl.cinematicpalette_active = false; + // return true; + // } + // + // if (!cl.cinematicpalette_active) + // { + // re.CinematicSetPalette(cl.cinematicpalette); + // cl.cinematicpalette_active = true; + // } + // + // if (!cin.pic) + // return true; + // + // re.DrawStretchRaw (0, 0, viddef.width, viddef.height, + // cin.width, cin.height, cin.pic); + // + // return true; } /* ================== SCR_PlayCinematic - + ================== */ - static void PlayCinematic(String arg) - { -// int width, height; -// byte *palette; -// char name[MAX_OSPATH], *dot; -// int old_khz; -// -// // make sure CD isn't playing music + static void PlayCinematic(String arg) { + // int width, height; + // byte *palette; + // char name[MAX_OSPATH], *dot; + // int old_khz; + // + // // make sure CD isn't playing music //CDAudio.Stop(); - cl.cinematicframe = 0; -// dot = strstr (arg, "."); -// if (dot && !strcmp (dot, ".pcx")) -// { // static pcx image -// Com_sprintf (name, sizeof(name), "pics/%s", arg); -// SCR_LoadPCX (name, &cin.pic, &palette, &cin.width, &cin.height); -// cl.cinematicframe = -1; -// cl.cinematictime = 1; -// SCR_EndLoadingPlaque (); -// cls.state = ca_active; -// if (!cin.pic) -// { -// Com_Printf ("%s not found.\n", name); -// cl.cinematictime = 0; -// } -// else -// { -// memcpy (cl.cinematicpalette, palette, sizeof(cl.cinematicpalette)); -// Z_Free (palette); -// } -// return; -// } -// -// Com_sprintf (name, sizeof(name), "video/%s", arg); -// FS_FOpenFile (name, &cl.cinematic_file); -// if (!cl.cinematic_file) -// { - // Com_Error (ERR_DROP, "Cinematic %s not found.\n", name); - FinishCinematic(); - cl.cinematictime = 0; // done - return; -// } -// -// SCR_EndLoadingPlaque (); -// -// cls.state = ca_active; -// -// FS_Read (&width, 4, cl.cinematic_file); -// FS_Read (&height, 4, cl.cinematic_file); -// cin.width = LittleLong(width); -// cin.height = LittleLong(height); -// -// FS_Read (&cin.s_rate, 4, cl.cinematic_file); -// cin.s_rate = LittleLong(cin.s_rate); -// FS_Read (&cin.s_width, 4, cl.cinematic_file); -// cin.s_width = LittleLong(cin.s_width); -// FS_Read (&cin.s_channels, 4, cl.cinematic_file); -// cin.s_channels = LittleLong(cin.s_channels); -// -// Huff1TableInit (); -// -// // switch up to 22 khz sound if necessary -// old_khz = Cvar_VariableValue ("s_khz"); -// if (old_khz != cin.s_rate/1000) -// { -// cin.restart_sound = true; -// Cvar_SetValue ("s_khz", cin.s_rate/1000); -// CL_Snd_Restart_f (); -// Cvar_SetValue ("s_khz", old_khz); -// } -// -// cl.cinematicframe = 0; -// cin.pic = SCR_ReadNextFrame (); -// cl.cinematictime = Sys_Milliseconds (); + cl.cinematicframe= 0; + // dot = strstr (arg, "."); + // if (dot && !strcmp (dot, ".pcx")) + // { // static pcx image + // Com_sprintf (name, sizeof(name), "pics/%s", arg); + // SCR_LoadPCX (name, &cin.pic, &palette, &cin.width, &cin.height); + // cl.cinematicframe = -1; + // cl.cinematictime = 1; + // SCR_EndLoadingPlaque (); + // cls.state = ca_active; + // if (!cin.pic) + // { + // Com_Printf ("%s not found.\n", name); + // cl.cinematictime = 0; + // } + // else + // { + // memcpy (cl.cinematicpalette, palette, sizeof(cl.cinematicpalette)); + // Z_Free (palette); + // } + // return; + // } + // + // Com_sprintf (name, sizeof(name), "video/%s", arg); + // FS_FOpenFile (name, &cl.cinematic_file); + // if (!cl.cinematic_file) + // { + // Com_Error (ERR_DROP, "Cinematic %s not found.\n", name); + FinishCinematic(); + cl.cinematictime= 0; // done + return; + // } + // + // SCR_EndLoadingPlaque (); + // + // cls.state = ca_active; + // + // FS_Read (&width, 4, cl.cinematic_file); + // FS_Read (&height, 4, cl.cinematic_file); + // cin.width = LittleLong(width); + // cin.height = LittleLong(height); + // + // FS_Read (&cin.s_rate, 4, cl.cinematic_file); + // cin.s_rate = LittleLong(cin.s_rate); + // FS_Read (&cin.s_width, 4, cl.cinematic_file); + // cin.s_width = LittleLong(cin.s_width); + // FS_Read (&cin.s_channels, 4, cl.cinematic_file); + // cin.s_channels = LittleLong(cin.s_channels); + // + // Huff1TableInit (); + // + // // switch up to 22 khz sound if necessary + // old_khz = Cvar_VariableValue ("s_khz"); + // if (old_khz != cin.s_rate/1000) + // { + // cin.restart_sound = true; + // Cvar_SetValue ("s_khz", cin.s_rate/1000); + // CL_Snd_Restart_f (); + // Cvar_SetValue ("s_khz", old_khz); + // } + // + // cl.cinematicframe = 0; + // cin.pic = SCR_ReadNextFrame (); + // cl.cinematictime = Sys_Milliseconds (); } - } \ No newline at end of file diff --git a/src/jake2/game/GameBase.java b/src/jake2/game/GameBase.java index db2b3f0..cdec20b 100644 --- a/src/jake2/game/GameBase.java +++ b/src/jake2/game/GameBase.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 30.11.2003 by RST. -// $Id: GameBase.java,v 1.4 2004-08-20 21:29:58 salomo Exp $ +// $Id: GameBase.java,v 1.5 2004-08-22 14:25:11 salomo Exp $ /** Father of all GameObjects. */ @@ -33,181 +33,88 @@ import jake2.qcommon.Com; import jake2.server.*; import jake2.util.*; -public class GameBase extends Globals -{ - public static cplane_t dummyplane = new cplane_t(); - public static game_locals_t game = new game_locals_t(); - public static level_locals_t level = new level_locals_t(); - public static game_import_t gi = new game_import_t(); - public static game_export_t globals = new game_export_t(); - public static spawn_temp_t st = new spawn_temp_t(); +public class GameBase extends Globals { + public static cplane_t dummyplane= new cplane_t(); + public static game_locals_t game= new game_locals_t(); + public static level_locals_t level= new level_locals_t(); + public static game_import_t gi= new game_import_t(); + public static game_export_t globals= new game_export_t(); + public static spawn_temp_t st= new spawn_temp_t(); public static int sm_meat_index; public static int snd_fry; public static int meansOfDeath; - public static edict_t g_edicts[] = new edict_t[MAX_EDICTS]; + public static edict_t g_edicts[]= new edict_t[MAX_EDICTS]; static { - for (int n = 0; n < MAX_EDICTS; n++) - g_edicts[n] = new edict_t(n); + for (int n= 0; n < MAX_EDICTS; n++) + g_edicts[n]= new edict_t(n); } - public static cvar_t deathmatch = new cvar_t(); - public static cvar_t coop = new cvar_t(); - public static cvar_t dmflags = new cvar_t(); + public static cvar_t deathmatch= new cvar_t(); + public static cvar_t coop= new cvar_t(); + public static cvar_t dmflags= new cvar_t(); public static cvar_t skill; // = new cvar_t(); - public static cvar_t fraglimit = new cvar_t(); - public static cvar_t timelimit = new cvar_t(); - public static cvar_t password = new cvar_t(); - public static cvar_t spectator_password = new cvar_t(); - public static cvar_t needpass = new cvar_t(); - public static cvar_t maxclients = new cvar_t(); - public static cvar_t maxspectators = new cvar_t(); - public static cvar_t maxentities = new cvar_t(); - public static cvar_t g_select_empty = new cvar_t(); - public static cvar_t dedicated = new cvar_t(); - - public static cvar_t filterban = new cvar_t(); - - public static cvar_t sv_maxvelocity = new cvar_t(); - public static cvar_t sv_gravity = new cvar_t(); - - public static cvar_t sv_rollspeed = new cvar_t(); - public static cvar_t sv_rollangle = new cvar_t(); - public static cvar_t gun_x = new cvar_t(); - public static cvar_t gun_y = new cvar_t(); - public static cvar_t gun_z = new cvar_t(); - - public static cvar_t run_pitch = new cvar_t(); - public static cvar_t run_roll = new cvar_t(); - public static cvar_t bob_up = new cvar_t(); - public static cvar_t bob_pitch = new cvar_t(); - public static cvar_t bob_roll = new cvar_t(); - - public static cvar_t sv_cheats = new cvar_t(); - - public static cvar_t flood_msgs = new cvar_t(); - public static cvar_t flood_persecond = new cvar_t(); - public static cvar_t flood_waitdelay = new cvar_t(); - - public static cvar_t sv_maplist = new cvar_t(); - - public final static float STOP_EPSILON = 0.1f; - - static field_t fields_ent[] = - new field_t[] { - new field_t("classname", F_LSTRING), - new field_t("model", F_LSTRING), - new field_t("spawnflags", F_INT), - new field_t("speed", F_FLOAT), - new field_t("accel", F_FLOAT), - new field_t("decel", F_FLOAT), - new field_t("target", F_LSTRING), - new field_t("targetname", F_LSTRING), - new field_t("pathtarget", F_LSTRING), - new field_t("deathtarget", F_LSTRING), - new field_t("killtarget", F_LSTRING), - new field_t("combattarget", F_LSTRING), - new field_t("message", F_LSTRING), - new field_t("team", F_LSTRING), - new field_t("wait", F_FLOAT), - new field_t("delay", F_FLOAT), - new field_t("random", F_FLOAT), - new field_t("move_origin", F_VECTOR), - new field_t("move_angles", F_VECTOR), - new field_t("style", F_INT), - new field_t("count", F_INT), - new field_t("health", F_INT), - new field_t("sounds", F_INT), - new field_t("light", F_IGNORE), - new field_t("dmg", F_INT), - new field_t("mass", F_INT), - new field_t("volume", F_FLOAT), - new field_t("attenuation", F_FLOAT), - new field_t("map", F_LSTRING), - new field_t("origin", F_VECTOR), - new field_t("angles", F_VECTOR), - new field_t("angle", F_ANGLEHACK), - new field_t("goalentity", F_EDICT, FFL_NOSPAWN), - new field_t("movetarget", F_EDICT, FFL_NOSPAWN), - new field_t("enemy", F_EDICT, FFL_NOSPAWN), - new field_t("oldenemy", F_EDICT, FFL_NOSPAWN), - new field_t("activator", F_EDICT, FFL_NOSPAWN), - new field_t("groundentity", F_EDICT, FFL_NOSPAWN), - new field_t("teamchain", F_EDICT, FFL_NOSPAWN), - new field_t("teammaster", F_EDICT, FFL_NOSPAWN), - new field_t("owner", F_EDICT, FFL_NOSPAWN), - new field_t("mynoise", F_EDICT, FFL_NOSPAWN), - new field_t("mynoise2", F_EDICT, FFL_NOSPAWN), - new field_t("target_ent", F_EDICT, FFL_NOSPAWN), - new field_t("chain", F_EDICT, FFL_NOSPAWN), - new field_t("prethink", F_FUNCTION, FFL_NOSPAWN), - new field_t("think", F_FUNCTION, FFL_NOSPAWN), - new field_t("blocked", F_FUNCTION, FFL_NOSPAWN), - new field_t("touch", F_FUNCTION, FFL_NOSPAWN), - new field_t("use", F_FUNCTION, FFL_NOSPAWN), - new field_t("pain", F_FUNCTION, FFL_NOSPAWN), - new field_t("die", F_FUNCTION, FFL_NOSPAWN), - new field_t("stand", F_FUNCTION, FFL_NOSPAWN), - new field_t("idle", F_FUNCTION, FFL_NOSPAWN), - new field_t("search", F_FUNCTION, FFL_NOSPAWN), - new field_t("walk", F_FUNCTION, FFL_NOSPAWN), - new field_t("run", F_FUNCTION, FFL_NOSPAWN), - new field_t("dodge", F_FUNCTION, FFL_NOSPAWN), - new field_t("attack", F_FUNCTION, FFL_NOSPAWN), - new field_t("melee", F_FUNCTION, FFL_NOSPAWN), - new field_t("sight", F_FUNCTION, FFL_NOSPAWN), - new field_t("checkattack", F_FUNCTION, FFL_NOSPAWN), - new field_t("currentmove", F_MMOVE, FFL_NOSPAWN), - new field_t("endfunc", F_FUNCTION, FFL_NOSPAWN), - new field_t("item", F_ITEM) - //need for item field in edict struct, FFL_SPAWNTEMP item will be skipped on saves - }; + public static cvar_t fraglimit= new cvar_t(); + public static cvar_t timelimit= new cvar_t(); + public static cvar_t password= new cvar_t(); + public static cvar_t spectator_password= new cvar_t(); + public static cvar_t needpass= new cvar_t(); + public static cvar_t maxclients= new cvar_t(); + public static cvar_t maxspectators= new cvar_t(); + public static cvar_t maxentities= new cvar_t(); + public static cvar_t g_select_empty= new cvar_t(); + public static cvar_t dedicated= new cvar_t(); + + public static cvar_t filterban= new cvar_t(); + + public static cvar_t sv_maxvelocity= new cvar_t(); + public static cvar_t sv_gravity= new cvar_t(); + + public static cvar_t sv_rollspeed= new cvar_t(); + public static cvar_t sv_rollangle= new cvar_t(); + public static cvar_t gun_x= new cvar_t(); + public static cvar_t gun_y= new cvar_t(); + public static cvar_t gun_z= new cvar_t(); + + public static cvar_t run_pitch= new cvar_t(); + public static cvar_t run_roll= new cvar_t(); + public static cvar_t bob_up= new cvar_t(); + public static cvar_t bob_pitch= new cvar_t(); + public static cvar_t bob_roll= new cvar_t(); + + public static cvar_t sv_cheats= new cvar_t(); + + public static cvar_t flood_msgs= new cvar_t(); + public static cvar_t flood_persecond= new cvar_t(); + public static cvar_t flood_waitdelay= new cvar_t(); + + public static cvar_t sv_maplist= new cvar_t(); - // temp spawn vars -- only valid when the spawn function is called - static field_t fields_st[] = - { - new field_t("lip", F_INT, FFL_SPAWNTEMP), - new field_t("distance", F_INT, FFL_SPAWNTEMP), - new field_t("height", F_INT, FFL_SPAWNTEMP), - new field_t("noise", F_LSTRING, FFL_SPAWNTEMP), - new field_t("pausetime", F_FLOAT, FFL_SPAWNTEMP), - new field_t("item", F_LSTRING, FFL_SPAWNTEMP), - new field_t("gravity", F_LSTRING, FFL_SPAWNTEMP), - new field_t("sky", F_LSTRING, FFL_SPAWNTEMP), - new field_t("skyrotate", F_FLOAT, FFL_SPAWNTEMP), - new field_t("skyaxis", F_VECTOR, FFL_SPAWNTEMP), - new field_t("minyaw", F_FLOAT, FFL_SPAWNTEMP), - new field_t("maxyaw", F_FLOAT, FFL_SPAWNTEMP), - new field_t("minpitch", F_FLOAT, FFL_SPAWNTEMP), - new field_t("maxpitch", F_FLOAT, FFL_SPAWNTEMP), - new field_t("nextmap", F_LSTRING, FFL_SPAWNTEMP), - }; + public final static float STOP_EPSILON= 0.1f; /** * Slide off of the impacting object * returns the blocked flags (1 = floor, 2 = step / wall). */ - public static int ClipVelocity(float[] in, float[] normal, float[] out, float overbounce) - { + public static int ClipVelocity(float[] in, float[] normal, float[] out, float overbounce) { float backoff; float change; int i, blocked; - blocked = 0; + blocked= 0; if (normal[2] > 0) blocked |= 1; // floor if (normal[2] == 0.0f) blocked |= 2; // step - backoff = Math3D.DotProduct(in, normal) * overbounce; + backoff= Math3D.DotProduct(in, normal) * overbounce; - for (i = 0; i < 3; i++) - { - change = normal[i] * backoff; - out[i] = in[i] - change; + for (i= 0; i < 3; i++) { + change= normal[i] * backoff; + out[i]= in[i] - change; if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) - out[i] = 0; + out[i]= 0; } return blocked; @@ -222,7 +129,7 @@ public class GameBase extends Globals 2 = wall / step 4 = dead stop */ - public final static int MAX_CLIP_PLANES = 5; + public final static int MAX_CLIP_PLANES= 5; /* ============= @@ -242,19 +149,16 @@ public class GameBase extends Globals * Call with null as from parameter to search from array beginning. */ - public static EdictIterator G_Find(EdictIterator from, EdictFindFilter eff, String s) - { + public static EdictIterator G_Find(EdictIterator from, EdictFindFilter eff, String s) { if (from == null) - from = new EdictIterator(0); + from= new EdictIterator(0); else from.i++; - for (; from.i < globals.num_edicts; from.i++) - { - from.o = g_edicts[from.i]; - if (from.o.classname == null) - { + for (; from.i < globals.num_edicts; from.i++) { + from.o= g_edicts[from.i]; + if (from.o.classname == null) { Com.Printf("edict with classname = null" + from.o.index); } @@ -269,9 +173,8 @@ public class GameBase extends Globals } // comfort version (rst) - public static edict_t G_FindEdict(EdictIterator from, EdictFindFilter eff, String s) - { - EdictIterator ei = G_Find(from, eff, s); + public static edict_t G_FindEdict(EdictIterator from, EdictFindFilter eff, String s) { + EdictIterator ei= G_Find(from, eff, s); if (ei == null) return null; else @@ -281,27 +184,25 @@ public class GameBase extends Globals /** * Returns entities that have origins within a spherical area. */ - public static EdictIterator findradius(EdictIterator from, float[] org, float rad) - { - float[] eorg = { 0, 0, 0 }; + public static EdictIterator findradius(EdictIterator from, float[] org, float rad) { + float[] eorg= { 0, 0, 0 }; int j; if (from == null) - from = new EdictIterator(0); + from= new EdictIterator(0); else from.i++; - for (; from.i < globals.num_edicts; from.i++) - { - from.o = g_edicts[from.i]; + for (; from.i < globals.num_edicts; from.i++) { + from.o= g_edicts[from.i]; if (!from.o.inuse) continue; if (from.o.solid == SOLID_NOT) continue; - for (j = 0; j < 3; j++) - eorg[j] = org[j] - (from.o.s.origin[j] + (from.o.mins[j] + from.o.maxs[j]) * 0.5f); + for (j= 0; j < 3; j++) + eorg[j]= org[j] - (from.o.s.origin[j] + (from.o.mins[j] + from.o.maxs[j]) * 0.5f); if (Math3D.VectorLength(eorg) > rad) continue; @@ -319,30 +220,26 @@ public class GameBase extends Globals * null will be returned if the end of the list is reached. */ - public static int MAXCHOICES = 8; + public static int MAXCHOICES= 8; - public static edict_t G_PickTarget(String targetname) - { - int num_choices = 0; - edict_t choice[] = new edict_t[MAXCHOICES]; + public static edict_t G_PickTarget(String targetname) { + int num_choices= 0; + edict_t choice[]= new edict_t[MAXCHOICES]; - if (targetname == null) - { + if (targetname == null) { gi.dprintf("G_PickTarget called with null targetname\n"); return null; } - EdictIterator es = null; + EdictIterator es= null; - while ((es = G_Find(es, findByTarget, targetname)) != null) - { - choice[num_choices++] = es.o; + while ((es= G_Find(es, findByTarget, targetname)) != null) { + choice[num_choices++]= es.o; if (num_choices == MAXCHOICES) break; } - if (num_choices == 0) - { + if (num_choices == 0) { gi.dprintf("G_PickTarget: target " + targetname + " not found\n"); return null; } @@ -350,31 +247,26 @@ public class GameBase extends Globals return choice[Lib.rand() % num_choices]; } - public static float[] VEC_UP = { 0, -1, 0 }; - public static float[] MOVEDIR_UP = { 0, 0, 1 }; - public static float[] VEC_DOWN = { 0, -2, 0 }; - public static float[] MOVEDIR_DOWN = { 0, 0, -1 }; + public static float[] VEC_UP= { 0, -1, 0 }; + public static float[] MOVEDIR_UP= { 0, 0, 1 }; + public static float[] VEC_DOWN= { 0, -2, 0 }; + public static float[] MOVEDIR_DOWN= { 0, 0, -1 }; - public static void G_SetMovedir(float[] angles, float[] movedir) - { - if (Math3D.VectorCompare(angles, VEC_UP) != 0) - { + public static void G_SetMovedir(float[] angles, float[] movedir) { + if (Math3D.VectorCompare(angles, VEC_UP) != 0) { Math3D.VectorCopy(MOVEDIR_UP, movedir); } - else if (Math3D.VectorCompare(angles, VEC_DOWN) != 0) - { + else if (Math3D.VectorCompare(angles, VEC_DOWN) != 0) { Math3D.VectorCopy(MOVEDIR_DOWN, movedir); } - else - { + else { Math3D.AngleVectors(angles, movedir, null, null); } Math3D.VectorClear(angles); } - public static String G_CopyString(String in) - { + public static String G_CopyString(String in) { return new String(in); } @@ -384,35 +276,42 @@ public class GameBase extends Globals ============ */ - public static void G_TouchTriggers(edict_t ent) - { + + static edict_t touch[]= new edict_t[MAX_EDICTS]; + public static void G_TouchTriggers(edict_t ent) { int i, num; - edict_t touch[] = new edict_t[MAX_EDICTS], hit; + edict_t hit; + // dead things don't activate triggers! if ((ent.client != null || (ent.svflags & SVF_MONSTER) != 0) && (ent.health <= 0)) return; - num = gi.BoxEdicts(ent.absmin, ent.absmax, touch, MAX_EDICTS, AREA_TRIGGERS); + num= gi.BoxEdicts(ent.absmin, ent.absmax, touch, MAX_EDICTS, AREA_TRIGGERS); // be careful, it is possible to have an entity in this // list removed before we get to it (killtriggered) - for (i = 0; i < num; i++) - { - hit = touch[i]; + for (i= 0; i < num; i++) { + hit= touch[i]; + if (!hit.inuse) continue; if (hit.touch == null) continue; + + //rst: just for debugging player triggers + //if (ent.index == 1) + //Com.Printf("trigger:" + hit.classname + "(" + hit.index + ")\n"); + hit.touch.touch(hit, ent, GameBase.dummyplane, null); } } - public static pushed_t pushed[] = new pushed_t[MAX_EDICTS]; + public static pushed_t pushed[]= new pushed_t[MAX_EDICTS]; static { - for (int n = 0; n < MAX_EDICTS; n++) - pushed[n] = new pushed_t(); + for (int n= 0; n < MAX_EDICTS; n++) + pushed[n]= new pushed_t(); } public static int pushed_p; @@ -430,7 +329,7 @@ public class GameBase extends Globals */ public static int c_yes, c_no; - public static int STEPSIZE = 18; + public static int STEPSIZE= 18; // ============================================================================ /* @@ -439,14 +338,12 @@ public class GameBase extends Globals ================ */ - public static void G_RunEntity(edict_t ent) - { - + public static void G_RunEntity(edict_t ent) { + if (ent.prethink != null) ent.prethink.think(ent); - switch ((int) ent.movetype) - { + switch ((int) ent.movetype) { case MOVETYPE_PUSH : case MOVETYPE_STOP : SV.SV_Physics_Pusher(ent); @@ -477,20 +374,16 @@ public class GameBase extends Globals ================ */ - public static int DI_NODIR = -1; - public static void assert1(boolean cond) - { - if (!cond) - { + public static int DI_NODIR= -1; + public static void assert1(boolean cond) { + if (!cond) { - try - { + try { - int a[] = null; - int b = a[0]; + int a[]= null; + int b= a[0]; } - catch (Exception e) - { + catch (Exception e) { System.err.println("assertion failed!"); e.printStackTrace(); } @@ -498,49 +391,41 @@ public class GameBase extends Globals } } - public static void ClearBounds(float[] mins, float[] maxs) - { - mins[0] = mins[1] = mins[2] = 99999; - maxs[0] = maxs[1] = maxs[2] = -99999; + public static void ClearBounds(float[] mins, float[] maxs) { + mins[0]= mins[1]= mins[2]= 99999; + maxs[0]= maxs[1]= maxs[2]= -99999; } - public static void AddPointToBounds(float[] v, float[] mins, float[] maxs) - { + public static void AddPointToBounds(float[] v, float[] mins, float[] maxs) { int i; float val; - for (i = 0; i < 3; i++) - { - val = v[i]; + for (i= 0; i < 3; i++) { + val= v[i]; if (val < mins[i]) - mins[i] = val; + mins[i]= val; if (val > maxs[i]) - maxs[i] = val; + maxs[i]= val; } } - public static EdictFindFilter findByTarget = new EdictFindFilter() - { - public boolean matches(edict_t e, String s) - { + public static EdictFindFilter findByTarget= new EdictFindFilter() { + public boolean matches(edict_t e, String s) { if (e.targetname == null) return false; return e.targetname.equalsIgnoreCase(s); } }; - public static EdictFindFilter findByClass = new EdictFindFilter() - { - public boolean matches(edict_t e, String s) - { + public static EdictFindFilter findByClass= new EdictFindFilter() { + public boolean matches(edict_t e, String s) { return e.classname.equalsIgnoreCase(s); } }; //=================================================================== - public static void ShutdownGame() - { + public static void ShutdownGame() { gi.dprintf("==== ShutdownGame ====\n"); //gi.FreeTags (TAG_LEVEL); @@ -554,16 +439,14 @@ public class GameBase extends Globals ClientEndServerFrames ================= */ - public static void ClientEndServerFrames() - { + public static void ClientEndServerFrames() { int i; edict_t ent; // calc the player views now that all pushing // and damage has been added - for (i = 0; i < maxclients.value; i++) - { - ent = g_edicts[1 + i]; + for (i= 0; i < maxclients.value; i++) { + ent= g_edicts[1 + i]; if (!ent.inuse || null == ent.client) continue; Game.ClientEndServerFrame(ent); @@ -578,14 +461,13 @@ public class GameBase extends Globals Returns the created target changelevel ================= */ - public static edict_t CreateTargetChangeLevel(String map) - { + public static edict_t CreateTargetChangeLevel(String map) { edict_t ent; - ent = Game.G_Spawn(); - ent.classname = "target_changelevel"; - level.nextmap = map; - ent.map = level.nextmap; + ent= Game.G_Spawn(); + ent.classname= "target_changelevel"; + level.nextmap= map; + ent.map= level.nextmap; return ent; } @@ -596,37 +478,31 @@ public class GameBase extends Globals The timelimit or fraglimit has been exceeded ================= */ - public static void EndDMLevel() - { + public static void EndDMLevel() { edict_t ent; //char * s, * t, * f; //static const char * seps = " ,\n\r"; String s, t, f; - String seps = " ,\n\r"; + String seps= " ,\n\r"; // stay on same level flag - if (((int) dmflags.value & DF_SAME_LEVEL) != 0) - { + if (((int) dmflags.value & DF_SAME_LEVEL) != 0) { Game.BeginIntermission(CreateTargetChangeLevel(level.mapname)); return; } // see if it's in the map list - if (sv_maplist.string.length() > 0) - { - s = sv_maplist.string; - f = null; - StringTokenizer tk = new StringTokenizer(s, seps); - t = tk.nextToken(); + if (sv_maplist.string.length() > 0) { + s= sv_maplist.string; + f= null; + StringTokenizer tk= new StringTokenizer(s, seps); + t= tk.nextToken(); //t = strtok(s, seps); - while (t != null) - { - if (Q_stricmp(t, level.mapname) == 0) - { + while (t != null) { + if (Q_stricmp(t, level.mapname) == 0) { // it's in the list, go to the next one - t = tk.nextToken(); - if (t == null) - { // end of list, go to first one + t= tk.nextToken(); + if (t == null) { // end of list, go to first one if (f == null) // there isn't a first one, same level Game.BeginIntermission(CreateTargetChangeLevel(level.mapname)); else @@ -637,25 +513,23 @@ public class GameBase extends Globals return; } if (f == null) - f = t; - t = tk.nextToken(); + f= t; + t= tk.nextToken(); } } if (level.nextmap.length() > 0) // go to a specific map Game.BeginIntermission(CreateTargetChangeLevel(level.nextmap)); - else - { // search for a changelevel - EdictIterator edit = null; - edit = G_Find(edit, findByClass, "target_changelevel"); - if (edit == null) - { // the map designer didn't include a changelevel, + else { // search for a changelevel + EdictIterator edit= null; + edit= G_Find(edit, findByClass, "target_changelevel"); + if (edit == null) { // the map designer didn't include a changelevel, // so create a fake ent that goes back to the same level Game.BeginIntermission(CreateTargetChangeLevel(level.mapname)); return; } - ent = edit.o; + ent= edit.o; Game.BeginIntermission(ent); } } @@ -665,17 +539,15 @@ public class GameBase extends Globals CheckNeedPass ================= */ - public static void CheckNeedPass() - { + public static void CheckNeedPass() { int need; // if password or spectator_password has changed, update needpass // as needed - if (password.modified || spectator_password.modified) - { - password.modified = spectator_password.modified = false; + if (password.modified || spectator_password.modified) { + password.modified= spectator_password.modified= false; - need = 0; + need= 0; if ((password.string.length() > 0) && 0 != Q_stricmp(password.string, "none")) need |= 1; @@ -691,8 +563,7 @@ public class GameBase extends Globals CheckDMRules ================= */ - public static void CheckDMRules() - { + public static void CheckDMRules() { int i; gclient_t cl; @@ -702,26 +573,21 @@ public class GameBase extends Globals if (0 == deathmatch.value) return; - if (timelimit.value != 0) - { - if (level.time >= timelimit.value * 60) - { + if (timelimit.value != 0) { + if (level.time >= timelimit.value * 60) { gi.bprintf(PRINT_HIGH, "Timelimit hit.\n"); EndDMLevel(); return; } } - if (fraglimit.value != 0) - { - for (i = 0; i < maxclients.value; i++) - { - cl = game.clients[i]; + if (fraglimit.value != 0) { + for (i= 0; i < maxclients.value; i++) { + cl= game.clients[i]; if (!g_edicts[i + 1].inuse) continue; - if (cl.resp.score >= fraglimit.value) - { + if (cl.resp.score >= fraglimit.value) { gi.bprintf(PRINT_HIGH, "Fraglimit hit.\n"); EndDMLevel(); return; @@ -735,28 +601,26 @@ public class GameBase extends Globals ExitLevel ============= */ - public static void ExitLevel() - { + public static void ExitLevel() { int i; edict_t ent; //char command[256]; String command; - command = "gamemap \"" + level.changemap + "\"\n"; + command= "gamemap \"" + level.changemap + "\"\n"; gi.AddCommandString(command); - level.changemap = null; - level.exitintermission = false; - level.intermissiontime = 0; + level.changemap= null; + level.exitintermission= false; + level.intermissiontime= 0; ClientEndServerFrames(); // clear some things before going to next level - for (i = 0; i < maxclients.value; i++) - { - ent = g_edicts[1 + i]; + for (i= 0; i < maxclients.value; i++) { + ent= g_edicts[1 + i]; if (!ent.inuse) continue; if (ent.health > ent.client.pers.max_health) - ent.health = ent.client.pers.max_health; + ent.health= ent.client.pers.max_health; } } @@ -768,21 +632,19 @@ public class GameBase extends Globals Advances the world by 0.1 seconds ================ */ - public static void G_RunFrame() - { + public static void G_RunFrame() { int i; edict_t ent; level.framenum++; - level.time = level.framenum * FRAMETIME; + level.time= level.framenum * FRAMETIME; // choose a client for monsters to target this frame Game.AI_SetSightClient(); // exit intermissions - if (level.exitintermission) - { + if (level.exitintermission) { ExitLevel(); return; } @@ -792,33 +654,28 @@ public class GameBase extends Globals // even the world gets a chance to think // - for (i = 0; i < globals.num_edicts; i++) - { - ent = g_edicts[i]; + for (i= 0; i < globals.num_edicts; i++) { + ent= g_edicts[i]; if (!ent.inuse) continue; - level.current_entity = ent; + level.current_entity= ent; VectorCopy(ent.s.origin, ent.s.old_origin); // if the ground entity moved, make sure we are still on it - if ((ent.groundentity != null) && (ent.groundentity.linkcount != ent.groundentity_linkcount)) - { - ent.groundentity = null; - if (0 == (ent.flags & (FL_SWIM | FL_FLY)) && (ent.svflags & SVF_MONSTER) != 0) - { + if ((ent.groundentity != null) && (ent.groundentity.linkcount != ent.groundentity_linkcount)) { + ent.groundentity= null; + if (0 == (ent.flags & (FL_SWIM | FL_FLY)) && (ent.svflags & SVF_MONSTER) != 0) { M.M_CheckGround(ent); } } - if (i > 0 && i <= maxclients.value) - { + if (i > 0 && i <= maxclients.value) { Game.ClientBeginServerFrame(ent); continue; } - G_RunEntity(ent); } @@ -841,19 +698,16 @@ public class GameBase extends Globals ================= */ - public static game_export_t GetGameApi(game_import_t imp) - { - gi = imp; + public static game_export_t GetGameApi(game_import_t imp) { + gi= imp; - gi.pointcontents = new pmove_t.PointContentsAdapter() - { - public int pointcontents(float[] o) - { + gi.pointcontents= new pmove_t.PointContentsAdapter() { + public int pointcontents(float[] o) { return SV_WORLD.SV_PointContents(o); } }; - globals.apiversion = GAME_API_VERSION; + globals.apiversion= GAME_API_VERSION; /* globals.Init = InitGame; globals.Shutdown = ShutdownGame; diff --git a/src/jake2/game/GameFuncAdapters.java b/src/jake2/game/GameFuncAdapters.java index 5d48a6e..a381091 100644 --- a/src/jake2/game/GameFuncAdapters.java +++ b/src/jake2/game/GameFuncAdapters.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 26.02.2004 by RST. -// $Id: GameFuncAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $ +// $Id: GameFuncAdapters.java,v 1.2 2004-08-22 14:25:11 salomo Exp $ package jake2.game; @@ -30,8 +30,7 @@ import jake2.Globals; import jake2.util.*; import jake2.util.*; -public class GameFuncAdapters -{ +public class GameFuncAdapters { /* ========================================================= @@ -67,66 +66,58 @@ public class GameFuncAdapters ========================================================= */ - public final static int PLAT_LOW_TRIGGER = 1; - public final static int STATE_TOP = 0; - public final static int STATE_BOTTOM = 1; - public final static int STATE_UP = 2; - public final static int STATE_DOWN = 3; - public final static int DOOR_START_OPEN = 1; - public final static int DOOR_REVERSE = 2; - public final static int DOOR_CRUSHER = 4; - public final static int DOOR_NOMONSTER = 8; - public final static int DOOR_TOGGLE = 32; - public final static int DOOR_X_AXIS = 64; - public final static int DOOR_Y_AXIS = 128; + public final static int PLAT_LOW_TRIGGER= 1; + public final static int STATE_TOP= 0; + public final static int STATE_BOTTOM= 1; + public final static int STATE_UP= 2; + public final static int STATE_DOWN= 3; + public final static int DOOR_START_OPEN= 1; + public final static int DOOR_REVERSE= 2; + public final static int DOOR_CRUSHER= 4; + public final static int DOOR_NOMONSTER= 8; + public final static int DOOR_TOGGLE= 32; + public final static int DOOR_X_AXIS= 64; + public final static int DOOR_Y_AXIS= 128; // // Support routines for movement (changes in origin using velocity) // - static EntThinkAdapter Move_Done = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter Move_Done= new EntThinkAdapter() { + public boolean think(edict_t ent) { Math3D.VectorClear(ent.velocity); ent.moveinfo.endfunc.think(ent); return true; } }; - static EntThinkAdapter Move_Final = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter Move_Final= new EntThinkAdapter() { + public boolean think(edict_t ent) { - if (ent.moveinfo.remaining_distance == 0) - { + if (ent.moveinfo.remaining_distance == 0) { Move_Done.think(ent); return true; } Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.remaining_distance / Defines.FRAMETIME, ent.velocity); - ent.think = Move_Done; - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; + ent.think= Move_Done; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; return true; } }; - static EntThinkAdapter Move_Begin = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter Move_Begin= new EntThinkAdapter() { + public boolean think(edict_t ent) { float frames; - if ((ent.moveinfo.speed * Defines.FRAMETIME) >= ent.moveinfo.remaining_distance) - { + if ((ent.moveinfo.speed * Defines.FRAMETIME) >= ent.moveinfo.remaining_distance) { Move_Final.think(ent); return true; } Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.speed, ent.velocity); - frames = (float) Math.floor((ent.moveinfo.remaining_distance / ent.moveinfo.speed) / Defines.FRAMETIME); + frames= (float) Math.floor((ent.moveinfo.remaining_distance / ent.moveinfo.speed) / Defines.FRAMETIME); ent.moveinfo.remaining_distance -= frames * ent.moveinfo.speed * Defines.FRAMETIME; - ent.nextthink = GameBase.level.time + (frames * Defines.FRAMETIME); - ent.think = Move_Final; + ent.nextthink= GameBase.level.time + (frames * Defines.FRAMETIME); + ent.think= Move_Final; return true; } }; @@ -134,44 +125,37 @@ public class GameFuncAdapters // Support routines for angular movement (changes in angle using avelocity) // - static EntThinkAdapter AngleMove_Done = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter AngleMove_Done= new EntThinkAdapter() { + public boolean think(edict_t ent) { Math3D.VectorClear(ent.avelocity); ent.moveinfo.endfunc.think(ent); return true; } }; - static EntThinkAdapter AngleMove_Final = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] move = { 0, 0, 0 }; + static EntThinkAdapter AngleMove_Final= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] move= { 0, 0, 0 }; if (ent.moveinfo.state == STATE_UP) Math3D.VectorSubtract(ent.moveinfo.end_angles, ent.s.angles, move); else Math3D.VectorSubtract(ent.moveinfo.start_angles, ent.s.angles, move); - if (Math3D.VectorCompare(move, Globals.vec3_origin) != 0) - { + if (Math3D.VectorCompare(move, Globals.vec3_origin) != 0) { AngleMove_Done.think(ent); return true; } Math3D.VectorScale(move, 1.0f / Defines.FRAMETIME, ent.avelocity); - ent.think = AngleMove_Done; - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; + ent.think= AngleMove_Done; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; return true; } }; - static EntThinkAdapter AngleMove_Begin = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] destdelta = { 0, 0, 0 }; + static EntThinkAdapter AngleMove_Begin= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] destdelta= { 0, 0, 0 }; float len; float traveltime; float frames; @@ -183,32 +167,29 @@ public class GameFuncAdapters Math3D.VectorSubtract(ent.moveinfo.start_angles, ent.s.angles, destdelta); // calculate length of vector - len = Math3D.VectorLength(destdelta); + len= Math3D.VectorLength(destdelta); // divide by speed to get time to reach dest - traveltime = len / ent.moveinfo.speed; + traveltime= len / ent.moveinfo.speed; - if (traveltime < Defines.FRAMETIME) - { + if (traveltime < Defines.FRAMETIME) { AngleMove_Final.think(ent); return true; } - frames = (float) (Math.floor(traveltime / Defines.FRAMETIME)); + frames= (float) (Math.floor(traveltime / Defines.FRAMETIME)); // scale the destdelta vector by the time spent traveling to get velocity Math3D.VectorScale(destdelta, 1.0f / traveltime, ent.avelocity); // set nextthink to trigger a think when dest is reached - ent.nextthink = GameBase.level.time + frames * Defines.FRAMETIME; - ent.think = AngleMove_Final; + ent.nextthink= GameBase.level.time + frames * Defines.FRAMETIME; + ent.think= AngleMove_Final; return true; } }; - static EntThinkAdapter Think_AccelMove = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter Think_AccelMove= new EntThinkAdapter() { + public boolean think(edict_t ent) { ent.moveinfo.remaining_distance -= ent.moveinfo.current_speed; if (ent.moveinfo.current_speed == 0) // starting or blocked @@ -217,24 +198,20 @@ public class GameFuncAdapters GameFunc.plat_Accelerate(ent.moveinfo); // will the entire move complete on next frame? - if (ent.moveinfo.remaining_distance <= ent.moveinfo.current_speed) - { + if (ent.moveinfo.remaining_distance <= ent.moveinfo.current_speed) { Move_Final.think(ent); return true; } Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.current_speed * 10, ent.velocity); - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; - ent.think = Think_AccelMove; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; + ent.think= Think_AccelMove; return true; } }; - static EntThinkAdapter plat_hit_top = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter plat_hit_top= new EntThinkAdapter() { + public boolean think(edict_t ent) { + if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) { if (ent.moveinfo.sound_end != 0) GameBase.gi.sound( ent, @@ -243,22 +220,19 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - ent.s.sound = 0; + ent.s.sound= 0; } - ent.moveinfo.state = STATE_TOP; + ent.moveinfo.state= STATE_TOP; - ent.think = plat_go_down; - ent.nextthink = GameBase.level.time + 3; + ent.think= plat_go_down; + ent.nextthink= GameBase.level.time + 3; return true; } }; - static EntThinkAdapter plat_hit_bottom = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter plat_hit_bottom= new EntThinkAdapter() { + public boolean think(edict_t ent) { - if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) - { + if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) { if (ent.moveinfo.sound_end != 0) GameBase.gi.sound( ent, @@ -267,18 +241,15 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - ent.s.sound = 0; + ent.s.sound= 0; } - ent.moveinfo.state = STATE_BOTTOM; + ent.moveinfo.state= STATE_BOTTOM; return true; } }; - static EntThinkAdapter plat_go_down = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter plat_go_down= new EntThinkAdapter() { + public boolean think(edict_t ent) { + if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) { if (ent.moveinfo.sound_start != 0) GameBase.gi.sound( ent, @@ -287,19 +258,16 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - ent.s.sound = ent.moveinfo.sound_middle; + ent.s.sound= ent.moveinfo.sound_middle; } - ent.moveinfo.state = STATE_DOWN; + ent.moveinfo.state= STATE_DOWN; GameFunc.Move_Calc(ent, ent.moveinfo.end_origin, plat_hit_bottom); return true; } }; - static EntBlockedAdapter plat_blocked = new EntBlockedAdapter() - { - public void blocked(edict_t self, edict_t other) - { - if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) - { + static EntBlockedAdapter plat_blocked= new EntBlockedAdapter() { + public void blocked(edict_t self, edict_t other) { + if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameUtil.T_Damage( other, @@ -337,31 +305,26 @@ public class GameFuncAdapters } }; - static EntUseAdapter Use_Plat = new EntUseAdapter() - { - public void use(edict_t ent, edict_t other, edict_t activator) - { + static EntUseAdapter Use_Plat= new EntUseAdapter() { + public void use(edict_t ent, edict_t other, edict_t activator) { if (ent.think != null) return; // already down plat_go_down.think(ent); } }; - static EntTouchAdapter Touch_Plat_Center = new EntTouchAdapter() - { - public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter Touch_Plat_Center= new EntTouchAdapter() { + public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) { if (other.client == null) return; if (other.health <= 0) return; - ent = ent.enemy; // now point at the plat, not the trigger + ent= ent.enemy; // now point at the plat, not the trigger if (ent.moveinfo.state == STATE_BOTTOM) GameFunc.plat_go_up(ent); - else if (ent.moveinfo.state == STATE_TOP) - { - ent.nextthink = GameBase.level.time + 1; // the player is still on the plat, so delay going down + else if (ent.moveinfo.state == STATE_TOP) { + ent.nextthink= GameBase.level.time + 1; // the player is still on the plat, so delay going down } } }; @@ -379,10 +342,8 @@ public class GameFuncAdapters STOP mean it will stop moving instead of pushing entities */ - static EntBlockedAdapter rotating_blocked = new EntBlockedAdapter() - { - public void blocked(edict_t self, edict_t other) - { + static EntBlockedAdapter rotating_blocked= new EntBlockedAdapter() { + public void blocked(edict_t self, edict_t other) { GameUtil.T_Damage( other, self, @@ -396,10 +357,8 @@ public class GameFuncAdapters Defines.MOD_CRUSH); } }; - static EntTouchAdapter rotating_touch = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter rotating_touch= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (self.avelocity[0] != 0 || self.avelocity[1] != 0 || self.avelocity[2] != 0) GameUtil.T_Damage( other, @@ -414,58 +373,52 @@ public class GameFuncAdapters Defines.MOD_CRUSH); } }; - static EntUseAdapter rotating_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - if (0 == Math3D.VectorCompare(self.avelocity, Globals.vec3_origin)) - { - self.s.sound = 0; + static EntUseAdapter rotating_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + if (0 == Math3D.VectorCompare(self.avelocity, Globals.vec3_origin)) { + self.s.sound= 0; Math3D.VectorClear(self.avelocity); - self.touch = null; + self.touch= null; } - else - { - self.s.sound = self.moveinfo.sound_middle; + else { + self.s.sound= self.moveinfo.sound_middle; Math3D.VectorScale(self.movedir, self.speed, self.avelocity); if ((self.spawnflags & 16) != 0) - self.touch = rotating_touch; + self.touch= rotating_touch; } } }; - static EntThinkAdapter SP_func_rotating = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - ent.solid = Defines.SOLID_BSP; + static EntThinkAdapter SP_func_rotating= new EntThinkAdapter() { + public boolean think(edict_t ent) { + ent.solid= Defines.SOLID_BSP; if ((ent.spawnflags & 32) != 0) - ent.movetype = Defines.MOVETYPE_STOP; + ent.movetype= Defines.MOVETYPE_STOP; else - ent.movetype = Defines.MOVETYPE_PUSH; + ent.movetype= Defines.MOVETYPE_PUSH; // set the axis of rotation Math3D.VectorClear(ent.movedir); if ((ent.spawnflags & 4) != 0) - ent.movedir[2] = 1.0f; + ent.movedir[2]= 1.0f; else if ((ent.spawnflags & 8) != 0) - ent.movedir[0] = 1.0f; + ent.movedir[0]= 1.0f; else // Z_AXIS - ent.movedir[1] = 1.0f; + ent.movedir[1]= 1.0f; // check for reverse rotation if ((ent.spawnflags & 2) != 0) Math3D.VectorNegate(ent.movedir, ent.movedir); if (0 == ent.speed) - ent.speed = 100; + ent.speed= 100; if (0 == ent.dmg) - ent.dmg = 2; + ent.dmg= 2; // ent.moveinfo.sound_middle = "doors/hydro1.wav"; - ent.use = rotating_use; + ent.use= rotating_use; if (ent.dmg != 0) - ent.blocked = rotating_blocked; + ent.blocked= rotating_blocked; if ((ent.spawnflags & 1) != 0) ent.use.use(ent, null, null); @@ -505,58 +458,49 @@ public class GameFuncAdapters 5) in-out */ - static EntThinkAdapter button_done = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter button_done= new EntThinkAdapter() { + public boolean think(edict_t self) { - self.moveinfo.state = STATE_BOTTOM; + self.moveinfo.state= STATE_BOTTOM; self.s.effects &= ~Defines.EF_ANIM23; self.s.effects |= Defines.EF_ANIM01; return true; } }; - static EntThinkAdapter button_return = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.moveinfo.state = STATE_DOWN; + static EntThinkAdapter button_return= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.moveinfo.state= STATE_DOWN; GameFunc.Move_Calc(self, self.moveinfo.start_origin, button_done); - self.s.frame = 0; + self.s.frame= 0; if (self.health != 0) - self.takedamage = Defines.DAMAGE_YES; + self.takedamage= Defines.DAMAGE_YES; return true; } }; - static EntThinkAdapter button_wait = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.moveinfo.state = STATE_TOP; + static EntThinkAdapter button_wait= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.moveinfo.state= STATE_TOP; self.s.effects &= ~Defines.EF_ANIM01; self.s.effects |= Defines.EF_ANIM23; GameUtil.G_UseTargets(self, self.activator); - self.s.frame = 1; - if (self.moveinfo.wait >= 0) - { - self.nextthink = GameBase.level.time + self.moveinfo.wait; - self.think = button_return; + self.s.frame= 1; + if (self.moveinfo.wait >= 0) { + self.nextthink= GameBase.level.time + self.moveinfo.wait; + self.think= button_return; } return true; } }; - static EntThinkAdapter button_fire = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter button_fire= new EntThinkAdapter() { + public boolean think(edict_t self) { if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP) return true; - self.moveinfo.state = STATE_UP; + self.moveinfo.state= STATE_UP; if (self.moveinfo.sound_start != 0 && 0 == (self.flags & Defines.FL_TEAMSLAVE)) GameBase.gi.sound( self, @@ -569,93 +513,84 @@ public class GameFuncAdapters return true; } }; - static EntUseAdapter button_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - self.activator = activator; + static EntUseAdapter button_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + self.activator= activator; button_fire.think(self); return; } }; - static EntTouchAdapter button_touch = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter button_touch= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (null == other.client) return; if (other.health <= 0) return; - self.activator = other; + self.activator= other; button_fire.think(self); } }; - static EntDieAdapter button_killed = new EntDieAdapter() - { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { - self.activator = attacker; - self.health = self.max_health; - self.takedamage = Defines.DAMAGE_NO; + static EntDieAdapter button_killed= new EntDieAdapter() { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { + self.activator= attacker; + self.health= self.max_health; + self.takedamage= Defines.DAMAGE_NO; button_fire.think(self); } }; - static EntThinkAdapter SP_func_button = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] abs_movedir = { 0, 0, 0 }; + static EntThinkAdapter SP_func_button= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] abs_movedir= { 0, 0, 0 }; float dist; GameBase.G_SetMovedir(ent.s.angles, ent.movedir); - ent.movetype = Defines.MOVETYPE_STOP; - ent.solid = Defines.SOLID_BSP; + ent.movetype= Defines.MOVETYPE_STOP; + ent.solid= Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); if (ent.sounds != 1) - ent.moveinfo.sound_start = GameBase.gi.soundindex("switches/butn2.wav"); + ent.moveinfo.sound_start= GameBase.gi.soundindex("switches/butn2.wav"); if (0 == ent.speed) - ent.speed = 40; + ent.speed= 40; if (0 == ent.accel) - ent.accel = ent.speed; + ent.accel= ent.speed; if (0 == ent.decel) - ent.decel = ent.speed; + ent.decel= ent.speed; if (0 == ent.wait) - ent.wait = 3; + ent.wait= 3; if (0 == GameBase.st.lip) - GameBase.st.lip = 4; + GameBase.st.lip= 4; Math3D.VectorCopy(ent.s.origin, ent.pos1); - abs_movedir[0] = (float) Math.abs(ent.movedir[0]); - abs_movedir[1] = (float) Math.abs(ent.movedir[1]); - abs_movedir[2] = (float) Math.abs(ent.movedir[2]); - dist = abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip; + abs_movedir[0]= (float) Math.abs(ent.movedir[0]); + abs_movedir[1]= (float) Math.abs(ent.movedir[1]); + abs_movedir[2]= (float) Math.abs(ent.movedir[2]); + dist= abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip; Math3D.VectorMA(ent.pos1, dist, ent.movedir, ent.pos2); - ent.use = button_use; + ent.use= button_use; ent.s.effects |= Defines.EF_ANIM01; - if (ent.health != 0) - { - ent.max_health = ent.health; - ent.die = button_killed; - ent.takedamage = Defines.DAMAGE_YES; + if (ent.health != 0) { + ent.max_health= ent.health; + ent.die= button_killed; + ent.takedamage= Defines.DAMAGE_YES; } else if (null == ent.targetname) - ent.touch = button_touch; + ent.touch= button_touch; - ent.moveinfo.state = STATE_BOTTOM; + ent.moveinfo.state= STATE_BOTTOM; - ent.moveinfo.speed = ent.speed; - ent.moveinfo.accel = ent.accel; - ent.moveinfo.decel = ent.decel; - ent.moveinfo.wait = ent.wait; + ent.moveinfo.speed= ent.speed; + ent.moveinfo.accel= ent.accel; + ent.moveinfo.decel= ent.decel; + ent.moveinfo.wait= ent.wait; Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_origin); Math3D.VectorCopy(ent.s.angles, ent.moveinfo.start_angles); Math3D.VectorCopy(ent.pos2, ent.moveinfo.end_origin); @@ -665,12 +600,9 @@ public class GameFuncAdapters return true; } }; - static EntThinkAdapter door_hit_top = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter door_hit_top= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_end != 0) GameBase.gi.sound( self, @@ -679,25 +611,21 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = 0; + self.s.sound= 0; } - self.moveinfo.state = STATE_TOP; + self.moveinfo.state= STATE_TOP; if ((self.spawnflags & DOOR_TOGGLE) != 0) return true; - if (self.moveinfo.wait >= 0) - { - self.think = door_go_down; - self.nextthink = GameBase.level.time + self.moveinfo.wait; + if (self.moveinfo.wait >= 0) { + self.think= door_go_down; + self.nextthink= GameBase.level.time + self.moveinfo.wait; } return true; } }; - static EntThinkAdapter door_hit_bottom = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter door_hit_bottom= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_end != 0) GameBase.gi.sound( self, @@ -706,19 +634,16 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = 0; + self.s.sound= 0; } - self.moveinfo.state = STATE_BOTTOM; + self.moveinfo.state= STATE_BOTTOM; GameFunc.door_use_areaportals(self, false); return true; } }; - static EntThinkAdapter door_go_down = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter door_go_down= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_start != 0) GameBase.gi.sound( self, @@ -727,15 +652,14 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = self.moveinfo.sound_middle; + self.s.sound= self.moveinfo.sound_middle; } - if (self.max_health != 0) - { - self.takedamage = Defines.DAMAGE_YES; - self.health = self.max_health; + if (self.max_health != 0) { + self.takedamage= Defines.DAMAGE_YES; + self.health= self.max_health; } - self.moveinfo.state = STATE_DOWN; + self.moveinfo.state= STATE_DOWN; if (Lib.strcmp(self.classname, "func_door") == 0) GameFunc.Move_Calc(self, self.moveinfo.start_origin, door_hit_bottom); else if (Lib.strcmp(self.classname, "func_door_rotating") == 0) @@ -743,24 +667,19 @@ public class GameFuncAdapters return true; } }; - static EntUseAdapter door_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { + static EntUseAdapter door_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { edict_t ent; if ((self.flags & Defines.FL_TEAMSLAVE) != 0) return; - if ((self.spawnflags & DOOR_TOGGLE) != 0) - { - if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP) - { + if ((self.spawnflags & DOOR_TOGGLE) != 0) { + if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP) { // trigger all paired doors - for (ent = self; ent != null; ent = ent.teamchain) - { - ent.message = null; - ent.touch = null; + for (ent= self; ent != null; ent= ent.teamchain) { + ent.message= null; + ent.touch= null; door_go_down.think(ent); } return; @@ -768,18 +687,15 @@ public class GameFuncAdapters } // trigger all paired doors - for (ent = self; ent != null; ent = ent.teamchain) - { - ent.message = null; - ent.touch = null; + for (ent= self; ent != null; ent= ent.teamchain) { + ent.message= null; + ent.touch= null; GameFunc.door_go_up(ent, activator); } } }; - static EntTouchAdapter Touch_DoorTrigger = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter Touch_DoorTrigger= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (other.health <= 0) return; @@ -791,15 +707,13 @@ public class GameFuncAdapters if (GameBase.level.time < self.touch_debounce_time) return; - self.touch_debounce_time = GameBase.level.time + 1.0f; + self.touch_debounce_time= GameBase.level.time + 1.0f; door_use.use(self.owner, other, other); } }; - static EntThinkAdapter Think_CalcMoveSpeed = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter Think_CalcMoveSpeed= new EntThinkAdapter() { + public boolean think(edict_t self) { edict_t ent; float min; float time; @@ -811,41 +725,37 @@ public class GameFuncAdapters return true; // only the team master does this // find the smallest distance any member of the team will be moving - min = Math.abs(self.moveinfo.distance); - for (ent = self.teamchain; ent != null; ent = ent.teamchain) - { - dist = Math.abs(ent.moveinfo.distance); + min= Math.abs(self.moveinfo.distance); + for (ent= self.teamchain; ent != null; ent= ent.teamchain) { + dist= Math.abs(ent.moveinfo.distance); if (dist < min) - min = dist; + min= dist; } - time = min / self.moveinfo.speed; + time= min / self.moveinfo.speed; // adjust speeds so they will all complete at the same time - for (ent = self; ent != null; ent = ent.teamchain) - { - newspeed = Math.abs(ent.moveinfo.distance) / time; - ratio = newspeed / ent.moveinfo.speed; + for (ent= self; ent != null; ent= ent.teamchain) { + newspeed= Math.abs(ent.moveinfo.distance) / time; + ratio= newspeed / ent.moveinfo.speed; if (ent.moveinfo.accel == ent.moveinfo.speed) - ent.moveinfo.accel = newspeed; + ent.moveinfo.accel= newspeed; else ent.moveinfo.accel *= ratio; if (ent.moveinfo.decel == ent.moveinfo.speed) - ent.moveinfo.decel = newspeed; + ent.moveinfo.decel= newspeed; else ent.moveinfo.decel *= ratio; - ent.moveinfo.speed = newspeed; + ent.moveinfo.speed= newspeed; } return true; } }; - - static EntThinkAdapter Think_SpawnDoorTrigger = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + + static EntThinkAdapter Think_SpawnDoorTrigger= new EntThinkAdapter() { + public boolean think(edict_t ent) { edict_t other; - float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 }; + float[] mins= { 0, 0, 0 }, maxs= { 0, 0, 0 }; if ((ent.flags & Defines.FL_TEAMSLAVE) != 0) return true; // only the team leader spawns a trigger @@ -853,8 +763,7 @@ public class GameFuncAdapters Math3D.VectorCopy(ent.absmin, mins); Math3D.VectorCopy(ent.absmax, maxs); - for (other = ent.teamchain; other != null; other = other.teamchain) - { + for (other= ent.teamchain; other != null; other= other.teamchain) { GameBase.AddPointToBounds(other.absmin, mins, maxs); GameBase.AddPointToBounds(other.absmax, mins, maxs); } @@ -865,13 +774,13 @@ public class GameFuncAdapters maxs[0] += 60; maxs[1] += 60; - other = GameUtil.G_Spawn(); + other= GameUtil.G_Spawn(); Math3D.VectorCopy(mins, other.mins); Math3D.VectorCopy(maxs, other.maxs); - other.owner = ent; - other.solid = Defines.SOLID_TRIGGER; - other.movetype = Defines.MOVETYPE_NONE; - other.touch = Touch_DoorTrigger; + other.owner= ent; + other.solid= Defines.SOLID_TRIGGER; + other.movetype= Defines.MOVETYPE_NONE; + other.touch= Touch_DoorTrigger; GameBase.gi.linkentity(other); if ((ent.spawnflags & DOOR_START_OPEN) != 0) @@ -881,14 +790,11 @@ public class GameFuncAdapters return true; } }; - static EntBlockedAdapter door_blocked = new EntBlockedAdapter() - { - public void blocked(edict_t self, edict_t other) - { + static EntBlockedAdapter door_blocked= new EntBlockedAdapter() { + public void blocked(edict_t self, edict_t other) { edict_t ent; - if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) - { + if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameUtil.T_Damage( other, @@ -924,124 +830,110 @@ public class GameFuncAdapters // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast - if (self.moveinfo.wait >= 0) - { - if (self.moveinfo.state == STATE_DOWN) - { - for (ent = self.teammaster; ent != null; ent = ent.teamchain) + if (self.moveinfo.wait >= 0) { + if (self.moveinfo.state == STATE_DOWN) { + for (ent= self.teammaster; ent != null; ent= ent.teamchain) GameFunc.door_go_up(ent, ent.activator); } - else - { - for (ent = self.teammaster; ent != null; ent = ent.teamchain) + else { + for (ent= self.teammaster; ent != null; ent= ent.teamchain) door_go_down.think(ent); } } } }; - static EntDieAdapter door_killed = new EntDieAdapter() - { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { + static EntDieAdapter door_killed= new EntDieAdapter() { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { edict_t ent; - for (ent = self.teammaster; ent != null; ent = ent.teamchain) - { - ent.health = ent.max_health; - ent.takedamage = Defines.DAMAGE_NO; + for (ent= self.teammaster; ent != null; ent= ent.teamchain) { + ent.health= ent.max_health; + ent.takedamage= Defines.DAMAGE_NO; } door_use.use(self.teammaster, attacker, attacker); } }; - static EntTouchAdapter door_touch = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter door_touch= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (null == other.client) return; if (GameBase.level.time < self.touch_debounce_time) return; - self.touch_debounce_time = GameBase.level.time + 5.0f; + self.touch_debounce_time= GameBase.level.time + 5.0f; GameBase.gi.centerprintf(other, self.message); GameBase.gi.sound(other, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0); } }; - static EntThinkAdapter SP_func_door = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] abs_movedir = { 0, 0, 0 }; - - if (ent.sounds != 1) - { - ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav"); - ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav"); - ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav"); + static EntThinkAdapter SP_func_door= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] abs_movedir= { 0, 0, 0 }; + + if (ent.sounds != 1) { + ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav"); + ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav"); + ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav"); } GameBase.G_SetMovedir(ent.s.angles, ent.movedir); - ent.movetype = Defines.MOVETYPE_PUSH; - ent.solid = Defines.SOLID_BSP; + ent.movetype= Defines.MOVETYPE_PUSH; + ent.solid= Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); - ent.blocked = door_blocked; - ent.use = door_use; + ent.blocked= door_blocked; + ent.use= door_use; if (0 == ent.speed) - ent.speed = 100; + ent.speed= 100; if (GameBase.deathmatch.value != 0) ent.speed *= 2; if (0 == ent.accel) - ent.accel = ent.speed; + ent.accel= ent.speed; if (0 == ent.decel) - ent.decel = ent.speed; + ent.decel= ent.speed; if (0 == ent.wait) - ent.wait = 3; + ent.wait= 3; if (0 == GameBase.st.lip) - GameBase.st.lip = 8; + GameBase.st.lip= 8; if (0 == ent.dmg) - ent.dmg = 2; + ent.dmg= 2; // calculate second position Math3D.VectorCopy(ent.s.origin, ent.pos1); - abs_movedir[0] = Math.abs(ent.movedir[0]); - abs_movedir[1] = Math.abs(ent.movedir[1]); - abs_movedir[2] = Math.abs(ent.movedir[2]); - ent.moveinfo.distance = + abs_movedir[0]= Math.abs(ent.movedir[0]); + abs_movedir[1]= Math.abs(ent.movedir[1]); + abs_movedir[2]= Math.abs(ent.movedir[2]); + ent.moveinfo.distance= abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip; Math3D.VectorMA(ent.pos1, ent.moveinfo.distance, ent.movedir, ent.pos2); // if it starts open, switch the positions - if ((ent.spawnflags & DOOR_START_OPEN) != 0) - { + if ((ent.spawnflags & DOOR_START_OPEN) != 0) { Math3D.VectorCopy(ent.pos2, ent.s.origin); Math3D.VectorCopy(ent.pos1, ent.pos2); Math3D.VectorCopy(ent.s.origin, ent.pos1); } - ent.moveinfo.state = STATE_BOTTOM; + ent.moveinfo.state= STATE_BOTTOM; - if (ent.health != 0) - { - ent.takedamage = Defines.DAMAGE_YES; - ent.die = door_killed; - ent.max_health = ent.health; + if (ent.health != 0) { + ent.takedamage= Defines.DAMAGE_YES; + ent.die= door_killed; + ent.max_health= ent.health; } - else if (ent.targetname != null && ent.message != null) - { + else if (ent.targetname != null && ent.message != null) { GameBase.gi.soundindex("misc/talk.wav"); - ent.touch = door_touch; + ent.touch= door_touch; } - ent.moveinfo.speed = ent.speed; - ent.moveinfo.accel = ent.accel; - ent.moveinfo.decel = ent.decel; - ent.moveinfo.wait = ent.wait; + ent.moveinfo.speed= ent.speed; + ent.moveinfo.accel= ent.accel; + ent.moveinfo.decel= ent.decel; + ent.moveinfo.wait= ent.wait; Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_origin); Math3D.VectorCopy(ent.s.angles, ent.moveinfo.start_angles); Math3D.VectorCopy(ent.pos2, ent.moveinfo.end_origin); @@ -1054,15 +946,15 @@ public class GameFuncAdapters // to simplify logic elsewhere, make non-teamed doors into a team of one if (null == ent.team) - ent.teammaster = ent; + ent.teammaster= ent; GameBase.gi.linkentity(ent); - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; if (ent.health != 0 || ent.targetname != null) - ent.think = Think_CalcMoveSpeed; + ent.think= Think_CalcMoveSpeed; else - ent.think = Think_SpawnDoorTrigger; + ent.think= Think_SpawnDoorTrigger; return true; } }; @@ -1095,88 +987,81 @@ public class GameFuncAdapters 4) heavy */ - static EntThinkAdapter SP_func_door_rotating = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter SP_func_door_rotating= new EntThinkAdapter() { + public boolean think(edict_t ent) { Math3D.VectorClear(ent.s.angles); // set the axis of rotation Math3D.VectorClear(ent.movedir); if ((ent.spawnflags & DOOR_X_AXIS) != 0) - ent.movedir[2] = 1.0f; + ent.movedir[2]= 1.0f; else if ((ent.spawnflags & DOOR_Y_AXIS) != 0) - ent.movedir[0] = 1.0f; + ent.movedir[0]= 1.0f; else // Z_AXIS - ent.movedir[1] = 1.0f; + ent.movedir[1]= 1.0f; // check for reverse rotation if ((ent.spawnflags & DOOR_REVERSE) != 0) Math3D.VectorNegate(ent.movedir, ent.movedir); - if (0 == GameBase.st.distance) - { + if (0 == GameBase.st.distance) { GameBase.gi.dprintf(ent.classname + " at " + Lib.vtos(ent.s.origin) + " with no distance set\n"); - GameBase.st.distance = 90; + GameBase.st.distance= 90; } Math3D.VectorCopy(ent.s.angles, ent.pos1); Math3D.VectorMA(ent.s.angles, GameBase.st.distance, ent.movedir, ent.pos2); - ent.moveinfo.distance = GameBase.st.distance; + ent.moveinfo.distance= GameBase.st.distance; - ent.movetype = Defines.MOVETYPE_PUSH; - ent.solid = Defines.SOLID_BSP; + ent.movetype= Defines.MOVETYPE_PUSH; + ent.solid= Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); - ent.blocked = door_blocked; - ent.use = door_use; + ent.blocked= door_blocked; + ent.use= door_use; if (0 == ent.speed) - ent.speed = 100; + ent.speed= 100; if (0 == ent.accel) - ent.accel = ent.speed; + ent.accel= ent.speed; if (0 == ent.decel) - ent.decel = ent.speed; + ent.decel= ent.speed; if (0 == ent.wait) - ent.wait = 3; + ent.wait= 3; if (0 == ent.dmg) - ent.dmg = 2; + ent.dmg= 2; - if (ent.sounds != 1) - { - ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav"); - ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav"); - ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav"); + if (ent.sounds != 1) { + ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav"); + ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav"); + ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav"); } // if it starts open, switch the positions - if ((ent.spawnflags & DOOR_START_OPEN) != 0) - { + if ((ent.spawnflags & DOOR_START_OPEN) != 0) { Math3D.VectorCopy(ent.pos2, ent.s.angles); Math3D.VectorCopy(ent.pos1, ent.pos2); Math3D.VectorCopy(ent.s.angles, ent.pos1); Math3D.VectorNegate(ent.movedir, ent.movedir); } - if (ent.health != 0) - { - ent.takedamage = Defines.DAMAGE_YES; - ent.die = door_killed; - ent.max_health = ent.health; + if (ent.health != 0) { + ent.takedamage= Defines.DAMAGE_YES; + ent.die= door_killed; + ent.max_health= ent.health; } - if (ent.targetname != null && ent.message != null) - { + if (ent.targetname != null && ent.message != null) { GameBase.gi.soundindex("misc/talk.wav"); - ent.touch = door_touch; + ent.touch= door_touch; } - ent.moveinfo.state = STATE_BOTTOM; - ent.moveinfo.speed = ent.speed; - ent.moveinfo.accel = ent.accel; - ent.moveinfo.decel = ent.decel; - ent.moveinfo.wait = ent.wait; + ent.moveinfo.state= STATE_BOTTOM; + ent.moveinfo.speed= ent.speed; + ent.moveinfo.accel= ent.accel; + ent.moveinfo.decel= ent.decel; + ent.moveinfo.wait= ent.wait; Math3D.VectorCopy(ent.s.origin, ent.moveinfo.start_origin); Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_angles); Math3D.VectorCopy(ent.s.origin, ent.moveinfo.end_origin); @@ -1187,21 +1072,21 @@ public class GameFuncAdapters // to simplify logic elsewhere, make non-teamed doors into a team of one if (ent.team == null) - ent.teammaster = ent; + ent.teammaster= ent; GameBase.gi.linkentity(ent); - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; if (ent.health != 0 || ent.targetname != null) - ent.think = Think_CalcMoveSpeed; + ent.think= Think_CalcMoveSpeed; else - ent.think = Think_SpawnDoorTrigger; + ent.think= Think_SpawnDoorTrigger; return true; } }; - public final static int TRAIN_START_ON = 1; - public final static int TRAIN_TOGGLE = 2; - public final static int TRAIN_BLOCK_STOPS = 4; + public final static int TRAIN_START_ON= 1; + public final static int TRAIN_TOGGLE= 2; + public final static int TRAIN_BLOCK_STOPS= 4; /*QUAKED func_train (0 .5 .8) ? START_ON TOGGLE BLOCK_STOPS Trains are moving platforms that players can ride. The targets origin specifies the min point of the train at each corner. @@ -1213,13 +1098,10 @@ public class GameFuncAdapters */ - static EntBlockedAdapter train_blocked = new EntBlockedAdapter() - { + static EntBlockedAdapter train_blocked= new EntBlockedAdapter() { - public void blocked(edict_t self, edict_t other) - { - if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) - { + public void blocked(edict_t self, edict_t other) { + if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameUtil.T_Damage( other, @@ -1243,7 +1125,7 @@ public class GameFuncAdapters if (self.dmg == 0) return; - self.touch_debounce_time = GameBase.level.time + 0.5f; + self.touch_debounce_time= GameBase.level.time + 0.5f; GameUtil.T_Damage( other, self, @@ -1257,43 +1139,37 @@ public class GameFuncAdapters Defines.MOD_CRUSH); } }; - static EntThinkAdapter train_wait = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (self.target_ent.pathtarget != null) - { + static EntThinkAdapter train_wait= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (self.target_ent.pathtarget != null) { String savetarget; edict_t ent; - ent = self.target_ent; - savetarget = ent.target; - ent.target = ent.pathtarget; + ent= self.target_ent; + savetarget= ent.target; + ent.target= ent.pathtarget; GameUtil.G_UseTargets(ent, self.activator); - ent.target = savetarget; + ent.target= savetarget; // make sure we didn't get killed by a killtarget if (!self.inuse) return true; } - if (self.moveinfo.wait != 0) - { - if (self.moveinfo.wait > 0) - { - self.nextthink = GameBase.level.time + self.moveinfo.wait; - self.think = train_next; + if (self.moveinfo.wait != 0) { + if (self.moveinfo.wait > 0) { + self.nextthink= GameBase.level.time + self.moveinfo.wait; + self.think= train_next; } else if (0 != (self.spawnflags & TRAIN_TOGGLE)) // && wait < 0 - { + { train_next.think(self); self.spawnflags &= ~TRAIN_START_ON; Math3D.VectorClear(self.velocity); - self.nextthink = 0; + self.nextthink= 0; } - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_end != 0) GameBase.gi.sound( self, @@ -1302,66 +1178,57 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = 0; + self.s.sound= 0; } } - else - { + else { train_next.think(self); } return true; } }; - static EntThinkAdapter train_next = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - edict_t ent = null; - float[] dest = { 0, 0, 0 }; + static EntThinkAdapter train_next= new EntThinkAdapter() { + public boolean think(edict_t self) { + edict_t ent= null; + float[] dest= { 0, 0, 0 }; boolean first; - first = true; + first= true; - boolean dogoto = true; - while (dogoto) - { - if (null == self.target) - { + boolean dogoto= true; + while (dogoto) { + if (null == self.target) { // gi.dprintf ("train_next: no next target\n"); return true; } - ent = GameBase.G_PickTarget(self.target); - if (null == ent) - { + ent= GameBase.G_PickTarget(self.target); + if (null == ent) { GameBase.gi.dprintf("train_next: bad target " + self.target + "\n"); return true; } - self.target = ent.target; - dogoto = false; + self.target= ent.target; + dogoto= false; // check for a teleport path_corner - if ((ent.spawnflags & 1) != 0) - { - if (!first) - { + if ((ent.spawnflags & 1) != 0) { + if (!first) { GameBase.gi.dprintf( "connected teleport path_corners, see " + ent.classname + " at " + Lib.vtos(ent.s.origin) + "\n"); return true; } - first = false; + first= false; Math3D.VectorSubtract(ent.s.origin, self.mins, self.s.origin); Math3D.VectorCopy(self.s.origin, self.s.old_origin); - self.s.event = Defines.EV_OTHER_TELEPORT; + self.s.event= Defines.EV_OTHER_TELEPORT; GameBase.gi.linkentity(self); - dogoto = true; + dogoto= true; } } - self.moveinfo.wait = ent.wait; - self.target_ent = ent; + self.moveinfo.wait= ent.wait; + self.target_ent= ent; - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_start != 0) GameBase.gi.sound( self, @@ -1370,11 +1237,11 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = self.moveinfo.sound_middle; + self.s.sound= self.moveinfo.sound_middle; } Math3D.VectorSubtract(ent.s.origin, self.mins, dest); - self.moveinfo.state = STATE_TOP; + self.moveinfo.state= STATE_TOP; Math3D.VectorCopy(self.s.origin, self.moveinfo.start_origin); Math3D.VectorCopy(dest, self.moveinfo.end_origin); GameFunc.Move_Calc(self, dest, train_wait); @@ -1382,24 +1249,20 @@ public class GameFuncAdapters return true; } }; - public static EntThinkAdapter func_train_find = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter func_train_find= new EntThinkAdapter() { + public boolean think(edict_t self) { edict_t ent; - if (null == self.target) - { + if (null == self.target) { GameBase.gi.dprintf("train_find: no target\n"); return true; } - ent = GameBase.G_PickTarget(self.target); - if (null == ent) - { + ent= GameBase.G_PickTarget(self.target); + if (null == ent) { GameBase.gi.dprintf("train_find: target " + self.target + " not found\n"); return true; } - self.target = ent.target; + self.target= ent.target; Math3D.VectorSubtract(ent.s.origin, self.mins, self.s.origin); GameBase.gi.linkentity(self); @@ -1408,31 +1271,26 @@ public class GameFuncAdapters if (null == self.targetname) self.spawnflags |= TRAIN_START_ON; - if ((self.spawnflags & TRAIN_START_ON) != 0) - { - self.nextthink = GameBase.level.time + Defines.FRAMETIME; - self.think = train_next; - self.activator = self; + if ((self.spawnflags & TRAIN_START_ON) != 0) { + self.nextthink= GameBase.level.time + Defines.FRAMETIME; + self.think= train_next; + self.activator= self; } return true; } }; - public static EntUseAdapter train_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - self.activator = activator; - - if ((self.spawnflags & TRAIN_START_ON) != 0) - { + public static EntUseAdapter train_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + self.activator= activator; + + if ((self.spawnflags & TRAIN_START_ON) != 0) { if (0 == (self.spawnflags & TRAIN_TOGGLE)) return; self.spawnflags &= ~TRAIN_START_ON; Math3D.VectorClear(self.velocity); - self.nextthink = 0; + self.nextthink= 0; } - else - { + else { if (self.target_ent != null) GameFunc.train_resume(self); else @@ -1442,68 +1300,56 @@ public class GameFuncAdapters }; /*QUAKED trigger_elevator (0.3 0.1 0.6) (-8 -8 -8) (8 8 8) */ - static EntUseAdapter trigger_elevator_use = new EntUseAdapter() - { + static EntUseAdapter trigger_elevator_use= new EntUseAdapter() { - public void use(edict_t self, edict_t other, edict_t activator) - { + public void use(edict_t self, edict_t other, edict_t activator) { edict_t target; - if (0 != self.movetarget.nextthink) - { + if (0 != self.movetarget.nextthink) { // gi.dprintf("elevator busy\n"); return; } - if (null == other.pathtarget) - { + if (null == other.pathtarget) { GameBase.gi.dprintf("elevator used with no pathtarget\n"); return; } - target = GameBase.G_PickTarget(other.pathtarget); - if (null == target) - { + target= GameBase.G_PickTarget(other.pathtarget); + if (null == target) { GameBase.gi.dprintf("elevator used with bad pathtarget: " + other.pathtarget + "\n"); return; } - self.movetarget.target_ent = target; + self.movetarget.target_ent= target; GameFunc.train_resume(self.movetarget); } }; - static EntThinkAdapter trigger_elevator_init = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (null == self.target) - { + static EntThinkAdapter trigger_elevator_init= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (null == self.target) { GameBase.gi.dprintf("trigger_elevator has no target\n"); return true; } - self.movetarget = GameBase.G_PickTarget(self.target); - if (null == self.movetarget) - { + self.movetarget= GameBase.G_PickTarget(self.target); + if (null == self.movetarget) { GameBase.gi.dprintf("trigger_elevator unable to find target " + self.target + "\n"); return true; } - if (Lib.strcmp(self.movetarget.classname, "func_train") != 0) - { + if (Lib.strcmp(self.movetarget.classname, "func_train") != 0) { GameBase.gi.dprintf("trigger_elevator target " + self.target + " is not a train\n"); return true; } - self.use = trigger_elevator_use; - self.svflags = Defines.SVF_NOCLIENT; + self.use= trigger_elevator_use; + self.svflags= Defines.SVF_NOCLIENT; return true; } }; - static EntThinkAdapter SP_trigger_elevator = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.think = trigger_elevator_init; - self.nextthink = GameBase.level.time + Defines.FRAMETIME; + static EntThinkAdapter SP_trigger_elevator= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.think= trigger_elevator_init; + self.nextthink= GameBase.level.time + Defines.FRAMETIME; return true; } }; @@ -1522,31 +1368,26 @@ public class GameFuncAdapters These can used but not touched. */ - static EntThinkAdapter func_timer_think = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter func_timer_think= new EntThinkAdapter() { + public boolean think(edict_t self) { GameUtil.G_UseTargets(self, self.activator); - self.nextthink = GameBase.level.time + self.wait + Lib.crandom() * self.random; + self.nextthink= GameBase.level.time + self.wait + Lib.crandom() * self.random; return true; } }; - static EntUseAdapter func_timer_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - self.activator = activator; + static EntUseAdapter func_timer_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + self.activator= activator; // if on, turn it off - if (self.nextthink != 0) - { - self.nextthink = 0; + if (self.nextthink != 0) { + self.nextthink= 0; return; } // turn it on if (self.delay != 0) - self.nextthink = GameBase.level.time + self.delay; + self.nextthink= GameBase.level.time + self.delay; else func_timer_think.think(self); } @@ -1557,43 +1398,36 @@ public class GameFuncAdapters speed default 100 */ - static EntUseAdapter func_conveyor_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - if ((self.spawnflags & 1) != 0) - { - self.speed = 0; + static EntUseAdapter func_conveyor_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + if ((self.spawnflags & 1) != 0) { + self.speed= 0; self.spawnflags &= ~1; } - else - { - self.speed = self.count; + else { + self.speed= self.count; self.spawnflags |= 1; } if (0 == (self.spawnflags & 2)) - self.count = 0; + self.count= 0; } }; - static EntThinkAdapter SP_func_conveyor = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter SP_func_conveyor= new EntThinkAdapter() { + public boolean think(edict_t self) { if (0 == self.speed) - self.speed = 100; + self.speed= 100; - if (0 == (self.spawnflags & 1)) - { - self.count = (int) self.speed; - self.speed = 0; + if (0 == (self.spawnflags & 1)) { + self.count= (int) self.speed; + self.speed= 0; } - self.use = func_conveyor_use; + self.use= func_conveyor_use; GameBase.gi.setmodel(self, self.model); - self.solid = Defines.SOLID_BSP; + self.solid= Defines.SOLID_BSP; GameBase.gi.linkentity(self); return true; } @@ -1611,14 +1445,12 @@ public class GameFuncAdapters "wait" how long to hold in the open position (default 5, -1 means hold) */ - public final static int SECRET_ALWAYS_SHOOT = 1; - public final static int SECRET_1ST_LEFT = 2; - public final static int SECRET_1ST_DOWN = 4; - static EntUseAdapter door_secret_use = new EntUseAdapter() - { + public final static int SECRET_ALWAYS_SHOOT= 1; + public final static int SECRET_1ST_LEFT= 2; + public final static int SECRET_1ST_DOWN= 4; + static EntUseAdapter door_secret_use= new EntUseAdapter() { - public void use(edict_t self, edict_t other, edict_t activator) - { + public void use(edict_t self, edict_t other, edict_t activator) { // make sure we're not already moving if (0 == Math3D.VectorCompare(self.s.origin, Globals.vec3_origin)) return; @@ -1627,80 +1459,62 @@ public class GameFuncAdapters GameFunc.door_use_areaportals(self, true); } }; - static EntThinkAdapter door_secret_move1 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.nextthink = GameBase.level.time + 1.0f; - self.think = door_secret_move2; + static EntThinkAdapter door_secret_move1= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.nextthink= GameBase.level.time + 1.0f; + self.think= door_secret_move2; return true; } }; - static EntThinkAdapter door_secret_move2 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter door_secret_move2= new EntThinkAdapter() { + public boolean think(edict_t self) { GameFunc.Move_Calc(self, self.pos2, door_secret_move3); return true; } }; - static EntThinkAdapter door_secret_move3 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter door_secret_move3= new EntThinkAdapter() { + public boolean think(edict_t self) { if (self.wait == -1) return true; - self.nextthink = GameBase.level.time + self.wait; - self.think = door_secret_move4; + self.nextthink= GameBase.level.time + self.wait; + self.think= door_secret_move4; return true; } }; - static EntThinkAdapter door_secret_move4 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter door_secret_move4= new EntThinkAdapter() { + public boolean think(edict_t self) { GameFunc.Move_Calc(self, self.pos1, door_secret_move5); return true; } }; - static EntThinkAdapter door_secret_move5 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.nextthink = GameBase.level.time + 1.0f; - self.think = door_secret_move6; + static EntThinkAdapter door_secret_move5= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.nextthink= GameBase.level.time + 1.0f; + self.think= door_secret_move6; return true; } }; - static EntThinkAdapter door_secret_move6 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter door_secret_move6= new EntThinkAdapter() { + public boolean think(edict_t self) { GameFunc.Move_Calc(self, Globals.vec3_origin, door_secret_done); return true; } }; - static EntThinkAdapter door_secret_done = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (null == (self.targetname) || 0 != (self.spawnflags & SECRET_ALWAYS_SHOOT)) - { - self.health = 0; - self.takedamage = Defines.DAMAGE_YES; + static EntThinkAdapter door_secret_done= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (null == (self.targetname) || 0 != (self.spawnflags & SECRET_ALWAYS_SHOOT)) { + self.health= 0; + self.takedamage= Defines.DAMAGE_YES; } GameFunc.door_use_areaportals(self, false); return true; } }; - static EntBlockedAdapter door_secret_blocked = new EntBlockedAdapter() - { + static EntBlockedAdapter door_secret_blocked= new EntBlockedAdapter() { - public void blocked(edict_t self, edict_t other) - { - if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) - { + public void blocked(edict_t self, edict_t other) { + if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameUtil.T_Damage( other, @@ -1721,7 +1535,7 @@ public class GameFuncAdapters if (GameBase.level.time < self.touch_debounce_time) return; - self.touch_debounce_time = GameBase.level.time + 0.5f; + self.touch_debounce_time= GameBase.level.time + 0.5f; GameUtil.T_Damage( other, @@ -1736,77 +1550,70 @@ public class GameFuncAdapters Defines.MOD_CRUSH); } }; - static EntDieAdapter door_secret_die = new EntDieAdapter() - { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { - self.takedamage = Defines.DAMAGE_NO; + static EntDieAdapter door_secret_die= new EntDieAdapter() { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { + self.takedamage= Defines.DAMAGE_NO; door_secret_use.use(self, attacker, attacker); } }; - static EntThinkAdapter SP_func_door_secret = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 }; + static EntThinkAdapter SP_func_door_secret= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] forward= { 0, 0, 0 }, right= { 0, 0, 0 }, up= { 0, 0, 0 }; float side; float width; float length; - ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav"); - ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav"); - ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav"); + ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav"); + ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav"); + ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav"); - ent.movetype = Defines.MOVETYPE_PUSH; - ent.solid = Defines.SOLID_BSP; + ent.movetype= Defines.MOVETYPE_PUSH; + ent.solid= Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); - ent.blocked = door_secret_blocked; - ent.use = door_secret_use; + ent.blocked= door_secret_blocked; + ent.use= door_secret_use; - if (null == (ent.targetname) || 0 != (ent.spawnflags & SECRET_ALWAYS_SHOOT)) - { - ent.health = 0; - ent.takedamage = Defines.DAMAGE_YES; - ent.die = door_secret_die; + if (null == (ent.targetname) || 0 != (ent.spawnflags & SECRET_ALWAYS_SHOOT)) { + ent.health= 0; + ent.takedamage= Defines.DAMAGE_YES; + ent.die= door_secret_die; } if (0 == ent.dmg) - ent.dmg = 2; + ent.dmg= 2; if (0 == ent.wait) - ent.wait = 5; + ent.wait= 5; - ent.moveinfo.accel = ent.moveinfo.decel = ent.moveinfo.speed = 50; + ent.moveinfo.accel= ent.moveinfo.decel= ent.moveinfo.speed= 50; // calculate positions Math3D.AngleVectors(ent.s.angles, forward, right, up); Math3D.VectorClear(ent.s.angles); - side = 1.0f - (ent.spawnflags & SECRET_1ST_LEFT); + side= 1.0f - (ent.spawnflags & SECRET_1ST_LEFT); if ((ent.spawnflags & SECRET_1ST_DOWN) != 0) - width = Math.abs(Math3D.DotProduct(up, ent.size)); + width= Math.abs(Math3D.DotProduct(up, ent.size)); else - width = Math.abs(Math3D.DotProduct(right, ent.size)); - length = Math.abs(Math3D.DotProduct(forward, ent.size)); + width= Math.abs(Math3D.DotProduct(right, ent.size)); + length= Math.abs(Math3D.DotProduct(forward, ent.size)); if ((ent.spawnflags & SECRET_1ST_DOWN) != 0) Math3D.VectorMA(ent.s.origin, -1 * width, up, ent.pos1); else Math3D.VectorMA(ent.s.origin, side * width, right, ent.pos1); Math3D.VectorMA(ent.pos1, length, forward, ent.pos2); - if (ent.health != 0) - { - ent.takedamage = Defines.DAMAGE_YES; - ent.die = door_killed; - ent.max_health = ent.health; + if (ent.health != 0) { + ent.takedamage= Defines.DAMAGE_YES; + ent.die= door_killed; + ent.max_health= ent.health; } - else if (ent.targetname != null && ent.message != null) - { + else if (ent.targetname != null && ent.message != null) { GameBase.gi.soundindex("misc/talk.wav"); - ent.touch = door_touch; + ent.touch= door_touch; } - ent.classname = "func_door"; + ent.classname= "func_door"; GameBase.gi.linkentity(ent); return true; @@ -1815,20 +1622,16 @@ public class GameFuncAdapters /*QUAKED func_killbox (1 0 0) ? Kills everything inside when fired, irrespective of protection. */ - static EntUseAdapter use_killbox = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { + static EntUseAdapter use_killbox= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { GameUtil.KillBox(self); } }; - static EntThinkAdapter SP_func_killbox = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter SP_func_killbox= new EntThinkAdapter() { + public boolean think(edict_t ent) { GameBase.gi.setmodel(ent, ent.model); - ent.use = use_killbox; - ent.svflags = Defines.SVF_NOCLIENT; + ent.use= use_killbox; + ent.svflags= Defines.SVF_NOCLIENT; return true; } }; diff --git a/src/jake2/game/GameSave.java b/src/jake2/game/GameSave.java index ba36e06..7db262e 100644 --- a/src/jake2/game/GameSave.java +++ b/src/jake2/game/GameSave.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 29.12.2003 by RST. -// $Id: GameSave.java,v 1.2 2004-08-20 21:29:57 salomo Exp $ +// $Id: GameSave.java,v 1.3 2004-08-22 14:25:12 salomo Exp $ package jake2.game; @@ -37,7 +37,7 @@ import jake2.util.*; public class GameSave extends GameFunc { - public static field_t levelfields[] = + public static field_t levelfields[]= { new field_t("changemap", F_LSTRING), new field_t("sight_client", F_EDICT), @@ -46,7 +46,7 @@ public class GameSave extends GameFunc { new field_t("sound2_entity", F_EDICT), new field_t(null, F_INT)}; - public static field_t clientfields[] = + public static field_t clientfields[]= { new field_t("pers.weapon", F_ITEM), new field_t("pers.lastweapon", F_ITEM), @@ -54,16 +54,16 @@ public class GameSave extends GameFunc { new field_t(null, F_INT)}; public static void CreateEdicts() { - g_edicts = new edict_t[game.maxentities]; - for (int i = 0; i < game.maxentities; i++) - g_edicts[i] = new edict_t(i); - SV_GAME.ge.edicts = g_edicts; + g_edicts= new edict_t[game.maxentities]; + for (int i= 0; i < game.maxentities; i++) + g_edicts[i]= new edict_t(i); + SV_GAME.ge.edicts= g_edicts; } public static void CreateClients() { - game.clients = new gclient_t[game.maxclients]; - for (int i = 0; i < game.maxclients; i++) - game.clients[i] = new gclient_t(i); + game.clients= new gclient_t[game.maxclients]; + for (int i= 0; i < game.maxclients; i++) + game.clients[i]= new gclient_t(i); } @@ -79,75 +79,75 @@ public class GameSave extends GameFunc { public static void InitGame() { gi.dprintf("==== InitGame ====\n"); - gun_x = gi.cvar("gun_x", "0", 0); - gun_y = gi.cvar("gun_y", "0", 0); - gun_z = gi.cvar("gun_z", "0", 0); + gun_x= gi.cvar("gun_x", "0", 0); + gun_y= gi.cvar("gun_y", "0", 0); + gun_z= gi.cvar("gun_z", "0", 0); //FIXME: sv_ prefix is wrong for these - sv_rollspeed = gi.cvar("sv_rollspeed", "200", 0); - sv_rollangle = gi.cvar("sv_rollangle", "2", 0); - sv_maxvelocity = gi.cvar("sv_maxvelocity", "2000", 0); - sv_gravity = gi.cvar("sv_gravity", "800", 0); + sv_rollspeed= gi.cvar("sv_rollspeed", "200", 0); + sv_rollangle= gi.cvar("sv_rollangle", "2", 0); + sv_maxvelocity= gi.cvar("sv_maxvelocity", "2000", 0); + sv_gravity= gi.cvar("sv_gravity", "800", 0); // noset vars - dedicated = gi.cvar("dedicated", "0", CVAR_NOSET); + dedicated= gi.cvar("dedicated", "0", CVAR_NOSET); // latched vars - sv_cheats = gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH); + sv_cheats= gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH); gi.cvar("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH); gi.cvar("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH); - maxclients = gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH); - maxspectators = gi.cvar("maxspectators", "4", CVAR_SERVERINFO); - deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH); - coop = gi.cvar("coop", "0", CVAR_LATCH); - skill = gi.cvar("skill", "0", CVAR_LATCH); - maxentities = gi.cvar("maxentities", "1024", CVAR_LATCH); + maxclients= gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH); + maxspectators= gi.cvar("maxspectators", "4", CVAR_SERVERINFO); + deathmatch= gi.cvar("deathmatch", "0", CVAR_LATCH); + coop= gi.cvar("coop", "0", CVAR_LATCH); + skill= gi.cvar("skill", "0", CVAR_LATCH); + maxentities= gi.cvar("maxentities", "1024", CVAR_LATCH); // change anytime vars - dmflags = gi.cvar("dmflags", "0", CVAR_SERVERINFO); - fraglimit = gi.cvar("fraglimit", "0", CVAR_SERVERINFO); - timelimit = gi.cvar("timelimit", "0", CVAR_SERVERINFO); - password = gi.cvar("password", "", CVAR_USERINFO); - spectator_password = gi.cvar("spectator_password", "", CVAR_USERINFO); - needpass = gi.cvar("needpass", "0", CVAR_SERVERINFO); - filterban = gi.cvar("filterban", "1", 0); - - g_select_empty = gi.cvar("g_select_empty", "0", CVAR_ARCHIVE); - - run_pitch = gi.cvar("run_pitch", "0.002", 0); - run_roll = gi.cvar("run_roll", "0.005", 0); - bob_up = gi.cvar("bob_up", "0.005", 0); - bob_pitch = gi.cvar("bob_pitch", "0.002", 0); - bob_roll = gi.cvar("bob_roll", "0.002", 0); + dmflags= gi.cvar("dmflags", "0", CVAR_SERVERINFO); + fraglimit= gi.cvar("fraglimit", "0", CVAR_SERVERINFO); + timelimit= gi.cvar("timelimit", "0", CVAR_SERVERINFO); + password= gi.cvar("password", "", CVAR_USERINFO); + spectator_password= gi.cvar("spectator_password", "", CVAR_USERINFO); + needpass= gi.cvar("needpass", "0", CVAR_SERVERINFO); + filterban= gi.cvar("filterban", "1", 0); + + g_select_empty= gi.cvar("g_select_empty", "0", CVAR_ARCHIVE); + + run_pitch= gi.cvar("run_pitch", "0.002", 0); + run_roll= gi.cvar("run_roll", "0.005", 0); + bob_up= gi.cvar("bob_up", "0.005", 0); + bob_pitch= gi.cvar("bob_pitch", "0.002", 0); + bob_roll= gi.cvar("bob_roll", "0.002", 0); // flood control - flood_msgs = gi.cvar("flood_msgs", "4", 0); - flood_persecond = gi.cvar("flood_persecond", "4", 0); - flood_waitdelay = gi.cvar("flood_waitdelay", "10", 0); + flood_msgs= gi.cvar("flood_msgs", "4", 0); + flood_persecond= gi.cvar("flood_persecond", "4", 0); + flood_waitdelay= gi.cvar("flood_waitdelay", "10", 0); // dm map list - sv_maplist = gi.cvar("sv_maplist", "", 0); + sv_maplist= gi.cvar("sv_maplist", "", 0); // items InitItems(); - game.helpmessage1 = ""; - game.helpmessage2 = ""; + game.helpmessage1= ""; + game.helpmessage2= ""; // initialize all entities for this game - game.maxentities = (int) maxentities.value; + game.maxentities= (int) maxentities.value; CreateEdicts(); - globals.edicts = g_edicts; - globals.max_edicts = game.maxentities; + globals.edicts= g_edicts; + globals.max_edicts= game.maxentities; // initialize all clients for this game - game.maxclients = (int) maxclients.value; + game.maxclients= (int) maxclients.value; CreateClients(); - - globals.num_edicts = game.maxclients + 1; + + globals.num_edicts= game.maxclients + 1; } /* @@ -164,53 +164,49 @@ public class GameSave extends GameFunc { last save position. ============ */ - public static void WriteGame (String filename, boolean autosave) - { - try - { - QuakeFile f; - + public static void WriteGame(String filename, boolean autosave) { + try { + QuakeFile f; + if (!autosave) SaveClientData(); - - f = new QuakeFile(filename, "rw"); - + + f= new QuakeFile(filename, "rw"); + if (f == null) - gi.error ("Couldn't write to " + filename); - - game.autosaved = autosave; + gi.error("Couldn't write to " + filename); + + game.autosaved= autosave; game.write(f); - game.autosaved = false; - - for (int i=0 ; i= globals.num_edicts) - globals.num_edicts = entnum + 1; - - ent = g_edicts[entnum]; - System.out.println("readint ent" + entnum); - ent.read(f); - ent.cleararealinks(); - gi.linkentity(ent); - } - - fclose (f); - - // mark all clients as unconnected - for (int i=0 ; i= globals.num_edicts) + globals.num_edicts= entnum + 1; + + ent= g_edicts[entnum]; + System.out.println("readint ent" + entnum); + ent.read(f); + ent.cleararealinks(); + gi.linkentity(ent); + } + + fclose(f); + + // mark all clients as unconnected + for (int i= 0; i < maxclients.value; i++) { + ent= g_edicts[i + 1]; + ent.client= game.clients[i]; + ent.client.pers.connected= false; + } + + // do any load time things at this point + for (int i= 0; i < globals.num_edicts; i++) { + ent= g_edicts[i]; + + if (!ent.inuse) + continue; + + // fire any cross-level triggers + if (ent.classname != null) + if (strcmp(ent.classname, "target_crosslevel_target") == 0) + ent.nextthink= level.time + ent.delay; + } } - - // do any load time things at this point - for (int i=0 ; i= '0' && s.charAt(0) <= '9') - { + if (s.charAt(0) >= '0' && s.charAt(0) <= '9') { idnum= atoi(Cmd.Argv(1)); - if (idnum < 0 || idnum >= maxclients.value) - { + if (idnum < 0 || idnum >= maxclients.value) { Com.Printf("Bad client slot: " + idnum + "\n"); return false; } sv_client= svs.clients[idnum]; sv_player= sv_client.edict; - if (0 == sv_client.state) - { + if (0 == sv_client.state) { Com.Printf("Client " + idnum + " is not active\n"); return false; } @@ -139,13 +130,11 @@ public class SV_CCMDS extends SV_ENTS } // check for a name match - for (i= 0; i < maxclients.value; i++) - { + for (i= 0; i < maxclients.value; i++) { cl= svs.clients[i]; if (0 == cl.state) continue; - if (0 == strcmp(cl.name, s)) - { + if (0 == strcmp(cl.name, s)) { sv_client= cl; sv_player= sv_client.edict; return true; @@ -164,14 +153,11 @@ public class SV_CCMDS extends SV_ENTS =============================================================================== */ - public static void remove(String name) - { - try - { + public static void remove(String name) { + try { new File(name).delete(); } - catch (Exception e) - { + catch (Exception e) { } } @@ -182,8 +168,7 @@ public class SV_CCMDS extends SV_ENTS Delete save// ===================== */ - public static void SV_WipeSavegame(String savename) - { + public static void SV_WipeSavegame(String savename) { //char name[MAX_OSPATH]; //char *s; @@ -200,8 +185,7 @@ public class SV_CCMDS extends SV_ENTS name= FS.Gamedir() + "/save/" + savename + "/*.sav"; File f= Sys.FindFirst(name, 0, 0); - while (f != null) - { + while (f != null) { f.delete(); f= Sys.FindNext(); } @@ -211,8 +195,7 @@ public class SV_CCMDS extends SV_ENTS f= Sys.FindFirst(name, 0, 0); - while (f != null) - { + while (f != null) { f.delete(); f= Sys.FindNext(); } @@ -224,80 +207,64 @@ public class SV_CCMDS extends SV_ENTS CopyFile ================ */ - public static void CopyFile(String src, String dst) - { + public static void CopyFile(String src, String dst) { RandomAccessFile f1, f2; int l= -1; byte buffer[]= new byte[65536]; Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n"); System.out.println("CopyFile (" + src + ", " + dst + ")\n"); - try - { + try { f1= new RandomAccessFile(src, "r"); } - catch (Exception e) - { + catch (Exception e) { return; } - try - { + try { f2= new RandomAccessFile(dst, "rw"); } - catch (Exception e) - { - try - { + catch (Exception e) { + try { f1.close(); } - catch (IOException e1) - { + catch (IOException e1) { e1.printStackTrace(); } return; } - while (true) - { + while (true) { - try - { + try { l= f1.read(buffer, 0, 65536); } - catch (IOException e1) - { + catch (IOException e1) { e1.printStackTrace(); } if (l == -1) break; - try - { + try { f2.write(buffer, 0, l); } - catch (IOException e2) - { + catch (IOException e2) { e2.printStackTrace(); } } - try - { + try { f1.close(); } - catch (IOException e1) - { + catch (IOException e1) { e1.printStackTrace(); } - try - { + try { f2.close(); } - catch (IOException e2) - { + catch (IOException e2) { e2.printStackTrace(); } @@ -308,8 +275,7 @@ public class SV_CCMDS extends SV_ENTS SV_CopySaveGame ================ */ - public static void SV_CopySaveGame(String src, String dst) - { + public static void SV_CopySaveGame(String src, String dst) { //char name[MAX_OSPATH], name2[MAX_OSPATH]; int l, len; File found; @@ -336,11 +302,10 @@ public class SV_CCMDS extends SV_ENTS found= Sys.FindFirst(name, 0, 0); - while (found != null) - { - name= name1 + found.getName(); + while (found != null) { + name= name1 + found.getName(); name2= FS.Gamedir() + "/save/" + dst + "/" + found.getName(); - + CopyFile(name, name2); // change sav to sv2 @@ -364,8 +329,7 @@ public class SV_CCMDS extends SV_ENTS ============== */ - public static void SV_WriteLevelFile() - { + public static void SV_WriteLevelFile() { String name; QuakeFile f; @@ -374,8 +338,7 @@ public class SV_CCMDS extends SV_ENTS name= FS.Gamedir() + "/save/current/" + sv.name + ".sv2"; - try - { + try { f= new QuakeFile(name, "rw"); for (int i= 0; i < MAX_CONFIGSTRINGS; i++) @@ -384,8 +347,7 @@ public class SV_CCMDS extends SV_ENTS CM.CM_WritePortalState(f); f.close(); } - catch (Exception e) - { + catch (Exception e) { Com.Printf("Failed to open " + name + "\n"); e.printStackTrace(); } @@ -400,8 +362,7 @@ public class SV_CCMDS extends SV_ENTS ============== */ - public static void SV_ReadLevelFile() - { + public static void SV_ReadLevelFile() { //char name[MAX_OSPATH]; String name; QuakeFile f; @@ -409,8 +370,7 @@ public class SV_CCMDS extends SV_ENTS Com.DPrintf("SV_ReadLevelFile()\n"); name= FS.Gamedir() + "/save/current/" + sv.name + ".sv2"; - try - { + try { f= new QuakeFile(name, "r"); for (int n= 0; n < MAX_CONFIGSTRINGS; n++) @@ -420,8 +380,7 @@ public class SV_CCMDS extends SV_ENTS f.close(); } - catch (IOException e1) - { + catch (IOException e1) { Com.Printf("Failed to open " + name + "\n"); e1.printStackTrace(); } @@ -437,8 +396,7 @@ public class SV_CCMDS extends SV_ENTS ============== */ - public static void SV_WriteServerFile(boolean autosave) - { + public static void SV_WriteServerFile(boolean autosave) { QuakeFile f; cvar_t var; @@ -447,12 +405,10 @@ public class SV_CCMDS extends SV_ENTS Com.DPrintf("SV_WriteServerFile(" + (autosave ? "true" : "false") + ")\n"); filename= FS.Gamedir() + "/save/current/server.ssv"; - try - { + try { f= new QuakeFile(filename, "rw"); - if (!autosave) - { + if (!autosave) { Calendar c= Calendar.getInstance(); comment= Com.sprintf( @@ -461,8 +417,7 @@ public class SV_CCMDS extends SV_ENTS c.get(Calendar.DAY_OF_MONTH))); comment += sv.configstrings[CS_NAME]; } - else - { + else { // autosaved comment= "ENTERING " + sv.configstrings[CS_NAME]; } @@ -474,25 +429,21 @@ public class SV_CCMDS extends SV_ENTS // write all CVAR_LATCH cvars // these will be things like coop, skill, deathmatch, etc - for (var= Globals.cvar_vars; var != null; var= var.next) - { + for (var= Globals.cvar_vars; var != null; var= var.next) { if (0 == (var.flags & CVAR_LATCH)) continue; - if (var.name.length() >= MAX_OSPATH - 1 || var.string.length() >= 128 - 1) - { + if (var.name.length() >= MAX_OSPATH - 1 || var.string.length() >= 128 - 1) { Com.Printf("Cvar too long: " + var.name + " = " + var.string + "\n"); continue; } name= var.name; string= var.string; - try - { + try { f.writeString(name); f.writeString(string); } - catch (IOException e2) - { + catch (IOException e2) { } } @@ -500,8 +451,7 @@ public class SV_CCMDS extends SV_ENTS f.writeString(null); f.close(); } - catch (Exception e) - { + catch (Exception e) { Com.Printf("Couldn't write " + filename + "\n"); } @@ -516,11 +466,9 @@ public class SV_CCMDS extends SV_ENTS ============== */ - public static void SV_ReadServerFile() - { + public static void SV_ReadServerFile() { String filename, name= "", string, comment, mapcmd; - try - { + try { QuakeFile f; mapcmd= ""; @@ -541,8 +489,7 @@ public class SV_CCMDS extends SV_ENTS // read all CVAR_LATCH cvars // these will be things like coop, skill, deathmatch, etc - while (true) - { + while (true) { name= f.readString(); if (name == null) break; @@ -563,8 +510,7 @@ public class SV_CCMDS extends SV_ENTS filename= FS.Gamedir() + "/save/current/game.ssv"; ge.ReadGame(filename); } - catch (Exception e) - { + catch (Exception e) { Com.Printf("Couldn't read file " + name + "\n"); System.err.println(e); e.printStackTrace(); @@ -580,8 +526,7 @@ public class SV_CCMDS extends SV_ENTS Puts the server in demo mode on a specific map/cinematic ================== */ - public static void SV_DemoMap_f() - { + public static void SV_DemoMap_f() { SV_Map(true, Cmd.Argv(1), false); } @@ -603,15 +548,13 @@ public class SV_CCMDS extends SV_ENTS goes to map jail.bsp. ================== */ - public static void SV_GameMap_f() - { + public static void SV_GameMap_f() { String map; int i; client_t cl; boolean savedInuse[]; - if (Cmd.Argc() != 2) - { + if (Cmd.Argc() != 2) { Com.Printf("USAGE: gamemap \n"); return; } @@ -622,21 +565,17 @@ public class SV_CCMDS extends SV_ENTS // check for clearing the current savegame map= Cmd.Argv(1); - if (map.charAt(0) == '*') - { + if (map.charAt(0) == '*') { // wipe all the *.sav files SV_WipeSavegame("current"); } - else - { // save the map just exited - if (sv.state == ss_game) - { + else { // save the map just exited + if (sv.state == ss_game) { // clear all the client inuse flags before saving so that // when the level is re-entered, the clients will spawn // at spawn points instead of occupying body shells savedInuse= new boolean[(int) maxclients.value]; - for (i= 0; i < maxclients.value; i++) - { + for (i= 0; i < maxclients.value; i++) { cl= svs.clients[i]; savedInuse[i]= cl.edict.inuse; cl.edict.inuse= false; @@ -645,8 +584,7 @@ public class SV_CCMDS extends SV_ENTS SV_WriteLevelFile(); // we must restore these for clients to transfer over correctly - for (i= 0; i < maxclients.value; i++) - { + for (i= 0; i < maxclients.value; i++) { cl= svs.clients[i]; cl.edict.inuse= savedInuse[i]; @@ -662,8 +600,7 @@ public class SV_CCMDS extends SV_ENTS svs.mapcmd= Cmd.Argv(1); // copy off the level to the autosave slot - if (0 == dedicated.value) - { + if (0 == dedicated.value) { SV_WriteServerFile(true); SV_CopySaveGame("current", "save0"); } @@ -677,24 +614,15 @@ public class SV_CCMDS extends SV_ENTS For development work ================== */ - public static void SV_Map_f() - { + public static void SV_Map_f() { String map; //char expanded[MAX_QPATH]; String expanded; // if not a pcx, demo, or cinematic, check to make sure the level exists -//<<<<<<< SV_CCMDS.java -// map= Cmd.Argv(1); -// if (!strstr(map, ".")) -// { -// expanded= "maps/" + map + ".bsp"; -// if (FS.LoadFile(expanded) == null) -// { -//======= - map = Cmd.Argv(1); + map= Cmd.Argv(1); if (map.indexOf(".") < 0) { - expanded = "maps/" + map + ".bsp"; + expanded= "maps/" + map + ".bsp"; if (FS.LoadFile(expanded) == null) { Com.Printf("Can't find " + expanded + "\n"); @@ -703,7 +631,7 @@ public class SV_CCMDS extends SV_ENTS } sv.state= ss_dead; // don't save current level when changing - //TODO: savegame + SV_WipeSavegame("current"); SV_GameMap_f(); } @@ -722,8 +650,7 @@ public class SV_CCMDS extends SV_ENTS ============== */ - public static void SV_Loadgame_f() - { + public static void SV_Loadgame_f() { //char name[MAX_OSPATH]; //FILE * f; //char * dir; @@ -732,8 +659,7 @@ public class SV_CCMDS extends SV_ENTS RandomAccessFile f; String dir; - if (Cmd.Argc() != 2) - { + if (Cmd.Argc() != 2) { Com.Printf("USAGE: loadgame \n"); return; } @@ -741,29 +667,24 @@ public class SV_CCMDS extends SV_ENTS Com.Printf("Loading game...\n"); dir= Cmd.Argv(1); - if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) - { + if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) { Com.Printf("Bad savedir.\n"); } // make sure the server.ssv file exists name= FS.Gamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv"; - try - { + try { f= new RandomAccessFile(name, "r"); } - catch (FileNotFoundException e) - { + catch (FileNotFoundException e) { Com.Printf("No such savegame: " + name + "\n"); return; } - try - { + try { f.close(); } - catch (IOException e1) - { + catch (IOException e1) { e1.printStackTrace(); } @@ -782,43 +703,36 @@ public class SV_CCMDS extends SV_ENTS ============== */ - public static void SV_Savegame_f() - { + public static void SV_Savegame_f() { String dir; - if (sv.state != ss_game) - { + if (sv.state != ss_game) { Com.Printf("You must be in a game to save.\n"); return; } - if (Cmd.Argc() != 2) - { + if (Cmd.Argc() != 2) { Com.Printf("USAGE: savegame \n"); return; } - if (Cvar.VariableValue("deathmatch") != 0) - { + if (Cvar.VariableValue("deathmatch") != 0) { Com.Printf("Can't savegame in a deathmatch\n"); return; } - if (0 == strcmp(Cmd.Argv(1), "current")) - { + if (0 == strcmp(Cmd.Argv(1), "current")) { Com.Printf("Can't save to 'current'\n"); return; } - if (maxclients.value == 1 && svs.clients[0].edict.client.ps.stats[STAT_HEALTH] <= 0) - { + if (maxclients.value == 1 && svs.clients[0].edict.client.ps.stats[STAT_HEALTH] <= 0) { Com.Printf("\nCan't savegame while dead!\n"); return; } dir= Cmd.Argv(1); - if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) - { + if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) { Com.Printf("Bad savedir.\n"); } @@ -830,12 +744,10 @@ public class SV_CCMDS extends SV_ENTS SV_WriteLevelFile(); // save server state - try - { + try { SV_WriteServerFile(false); } - catch (Exception e) - { + catch (Exception e) { Com.Printf("IOError in SV_WriteServerFile: " + e); } @@ -854,16 +766,13 @@ public class SV_CCMDS extends SV_ENTS Kick a user off of the server ================== */ - public static void SV_Kick_f() - { - if (!svs.initialized) - { + public static void SV_Kick_f() { + if (!svs.initialized) { Com.Printf("No server running.\n"); return; } - if (Cmd.Argc() != 2) - { + if (Cmd.Argc() != 2) { Com.Printf("Usage: kick \n"); return; } @@ -884,14 +793,12 @@ public class SV_CCMDS extends SV_ENTS SV_Status_f ================ */ - public static void SV_Status_f() - { + public static void SV_Status_f() { int i, j, l; client_t cl; String s; int ping; - if (svs.clients == null) - { + if (svs.clients == null) { Com.Printf("No server running.\n"); return; } @@ -899,8 +806,7 @@ public class SV_CCMDS extends SV_ENTS Com.Printf("num score ping name lastmsg address qport \n"); Com.Printf("--- ----- ---- --------------- ------- --------------------- ------\n"); - for (i= 0; i < maxclients.value; i++) - { + for (i= 0; i < maxclients.value; i++) { cl= svs.clients[i]; if (0 == cl.state) continue; @@ -912,8 +818,7 @@ public class SV_CCMDS extends SV_ENTS Com.Printf("CNCT "); else if (cl.state == cs_zombie) Com.Printf("ZMBI "); - else - { + else { ping= cl.ping < 9999 ? cl.ping : 9999; Com.Printf("%4i ", new Vargs().add(ping)); } @@ -943,8 +848,7 @@ public class SV_CCMDS extends SV_ENTS SV_ConSay_f ================== */ - public static void SV_ConSay_f() - { + public static void SV_ConSay_f() { client_t client; int j; String p; @@ -956,15 +860,13 @@ public class SV_CCMDS extends SV_ENTS text= "console: "; p= Cmd.Args(); - if (p.charAt(0) == '"') - { + if (p.charAt(0) == '"') { p= p.substring(1, p.length() - 1); } text += p; - for (j= 0; j < maxclients.value; j++) - { + for (j= 0; j < maxclients.value; j++) { client= svs.clients[j]; if (client.state != cs_spawned) continue; @@ -977,8 +879,7 @@ public class SV_CCMDS extends SV_ENTS SV_Heartbeat_f ================== */ - public static void SV_Heartbeat_f() - { + public static void SV_Heartbeat_f() { svs.last_heartbeat= -9999999; } @@ -989,8 +890,7 @@ public class SV_CCMDS extends SV_ENTS Examine or change the serverinfo string =========== */ - public static void SV_Serverinfo_f() - { + public static void SV_Serverinfo_f() { Com.Printf("Server info settings:\n"); Info.Print(Cvar.Serverinfo()); } @@ -1002,10 +902,8 @@ public class SV_CCMDS extends SV_ENTS Examine all a users info strings =========== */ - public static void SV_DumpUser_f() - { - if (Cmd.Argc() != 2) - { + public static void SV_DumpUser_f() { + if (Cmd.Argc() != 2) { Com.Printf("Usage: info \n"); return; } @@ -1027,8 +925,7 @@ public class SV_CCMDS extends SV_ENTS recorded, but no playerinfo will be stored. Primarily for demo merging. ============== */ - public static void SV_ServerRecord_f() - { + public static void SV_ServerRecord_f() { //char name[MAX_OSPATH]; String name; byte buf_data[]= new byte[32768]; @@ -1036,20 +933,17 @@ public class SV_CCMDS extends SV_ENTS int len; int i; - if (Cmd.Argc() != 2) - { + if (Cmd.Argc() != 2) { Com.Printf("serverrecord \n"); return; } - if (svs.demofile != null) - { + if (svs.demofile != null) { Com.Printf("Already recording.\n"); return; } - if (sv.state != ss_game) - { + if (sv.state != ss_game) { Com.Printf("You must be in a level to record.\n"); return; } @@ -1061,12 +955,10 @@ public class SV_CCMDS extends SV_ENTS Com.Printf("recording to " + name + ".\n"); FS.CreatePath(name); - try - { + try { svs.demofile= new RandomAccessFile(name, "rw"); } - catch (Exception e) - { + catch (Exception e) { Com.Printf("ERROR: couldn't open.\n"); return; } @@ -1095,8 +987,7 @@ public class SV_CCMDS extends SV_ENTS MSG.WriteString(buf, sv.configstrings[CS_NAME]); for (i= 0; i < MAX_CONFIGSTRINGS; i++) - if (sv.configstrings[i].length() == 0) - { + if (sv.configstrings[i].length() == 0) { MSG.WriteByte(buf, svc_configstring); MSG.WriteShort(buf, i); MSG.WriteString(buf, sv.configstrings[i]); @@ -1107,13 +998,11 @@ public class SV_CCMDS extends SV_ENTS len= EndianHandler.swapInt(buf.cursize); //fwrite(len, 4, 1, svs.demofile); //fwrite(buf.data, buf.cursize, 1, svs.demofile); - try - { + try { svs.demofile.writeInt(len); svs.demofile.write(buf.data); } - catch (IOException e1) - { + catch (IOException e1) { // TODO: do quake2 error handling! e1.printStackTrace(); } @@ -1128,19 +1017,15 @@ public class SV_CCMDS extends SV_ENTS Ends server demo recording ============== */ - public static void SV_ServerStop_f() - { - if (svs.demofile == null) - { + public static void SV_ServerStop_f() { + if (svs.demofile == null) { Com.Printf("Not doing a serverrecord.\n"); return; } - try - { + try { svs.demofile.close(); } - catch (IOException e) - { + catch (IOException e) { e.printStackTrace(); } svs.demofile= null; @@ -1155,8 +1040,7 @@ public class SV_CCMDS extends SV_ENTS =============== */ - public static void SV_KillServer_f() - { + public static void SV_KillServer_f() { if (!svs.initialized) return; SV_Shutdown("Server was killed.\n", false); @@ -1170,10 +1054,8 @@ public class SV_CCMDS extends SV_ENTS Let the game dll handle a command =============== */ - public static void SV_ServerCommand_f() - { - if (SV_GAME.ge == null) - { + public static void SV_ServerCommand_f() { + if (SV_GAME.ge == null) { Com.Printf("No game loaded.\n"); return; } @@ -1188,124 +1070,91 @@ public class SV_CCMDS extends SV_ENTS SV_InitOperatorCommands ================== */ - public static void SV_InitOperatorCommands() - { - Cmd.AddCommand("heartbeat", new xcommand_t() - { - public void execute() - { + public static void SV_InitOperatorCommands() { + Cmd.AddCommand("heartbeat", new xcommand_t() { + public void execute() { SV_Heartbeat_f(); } }); - Cmd.AddCommand("kick", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("kick", new xcommand_t() { + public void execute() { SV_Kick_f(); } }); - Cmd.AddCommand("status", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("status", new xcommand_t() { + public void execute() { SV_Status_f(); } }); - Cmd.AddCommand("serverinfo", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("serverinfo", new xcommand_t() { + public void execute() { SV_Serverinfo_f(); } }); - Cmd.AddCommand("dumpuser", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("dumpuser", new xcommand_t() { + public void execute() { SV_DumpUser_f(); } }); - Cmd.AddCommand("map", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("map", new xcommand_t() { + public void execute() { SV_Map_f(); } }); - Cmd.AddCommand("demomap", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("demomap", new xcommand_t() { + public void execute() { SV_DemoMap_f(); } }); - Cmd.AddCommand("gamemap", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("gamemap", new xcommand_t() { + public void execute() { SV_GameMap_f(); } }); - Cmd.AddCommand("setmaster", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("setmaster", new xcommand_t() { + public void execute() { SV_SetMaster_f(); } }); if (dedicated.value != 0) - Cmd.AddCommand("say", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("say", new xcommand_t() { + public void execute() { SV_ConSay_f(); } }); - Cmd.AddCommand("serverrecord", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("serverrecord", new xcommand_t() { + public void execute() { SV_ServerRecord_f(); } }); - Cmd.AddCommand("serverstop", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("serverstop", new xcommand_t() { + public void execute() { SV_ServerStop_f(); } }); - Cmd.AddCommand("save", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("save", new xcommand_t() { + public void execute() { SV_Savegame_f(); } }); - Cmd.AddCommand("load", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("load", new xcommand_t() { + public void execute() { SV_Loadgame_f(); } }); - Cmd.AddCommand("killserver", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("killserver", new xcommand_t() { + public void execute() { SV_KillServer_f(); } }); - Cmd.AddCommand("sv", new xcommand_t() - { - public void execute() - { + Cmd.AddCommand("sv", new xcommand_t() { + public void execute() { SV_ServerCommand_f(); } }); diff --git a/src/jake2/server/SV_GAME.java b/src/jake2/server/SV_GAME.java index 9e3d8d2..0dc5a8b 100644 --- a/src/jake2/server/SV_GAME.java +++ b/src/jake2/server/SV_GAME.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 14.01.2004 by RST. -// $Id: SV_GAME.java,v 1.5 2004-07-09 06:50:49 hzi Exp $ +// $Id: SV_GAME.java,v 1.6 2004-08-22 14:25:12 salomo Exp $ package jake2.server; @@ -32,8 +32,6 @@ import jake2.sys.Sys; public class SV_GAME extends SV_INIT { - // sv_game.c -- interface to the game dll - public static game_export_t ge; /* @@ -50,7 +48,6 @@ public class SV_GAME extends SV_INIT { if (ent == null) return; - //p = NUM_FOR_EDICT(ent); p = ent.index; if (p < 1 || p > SV_MAIN.maxclients.value) return; @@ -73,16 +70,6 @@ public class SV_GAME extends SV_INIT { =============== */ public static void PF_dprintf(String fmt) { - /* - char msg[1024]; - va_list argptr; - - va_start (argptr,fmt); - vsprintf (msg, fmt, argptr); - va_end (argptr); - - */ - Com.Printf(fmt); } @@ -94,22 +81,15 @@ public class SV_GAME extends SV_INIT { =============== */ public static void PF_cprintf(edict_t ent, int level, String fmt) { - //char msg[1024]; - //va_list argptr; + int n = 0; if (ent != null) { - - //n = NUM_FOR_EDICT(ent); n = ent.index; if (n < 1 || n > SV_MAIN.maxclients.value) Com.Error(ERR_DROP, "cprintf to a non-client"); } - // va_start (argptr,fmt); - // vsprintf (msg, fmt, argptr); - // va_end (argptr); - if (ent != null) SV_SEND.SV_ClientPrintf(svs.clients[n - 1], level, fmt); else @@ -124,20 +104,12 @@ public class SV_GAME extends SV_INIT { =============== */ public static void PF_centerprintf(edict_t ent, String fmt) { - //char msg[1024]; - //va_list argptr; int n; - //TODO: NUM_FOR_EDICT - //n = NUM_FOR_EDICT(ent); n = ent.index; if (n < 1 || n > SV_MAIN.maxclients.value) return; // Com_Error (ERR_DROP, "centerprintf to a non-client"); - // va_start (argptr,fmt); - // vsprintf (msg, fmt, argptr); - // va_end (argptr); - MSG.WriteByte(sv.multicast, svc_centerprint); MSG.WriteString(sv.multicast, fmt); PF_Unicast(ent, true); @@ -174,7 +146,6 @@ public class SV_GAME extends SV_INIT { i = SV_ModelIndex(name); - //ent.model = name; ent.s.modelindex = i; // if it is an inline model, get the size information for it diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java index b8e5c90..c036d50 100644 --- a/src/jake2/server/SV_INIT.java +++ b/src/jake2/server/SV_INIT.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 14.01.2004 by RST. -// $Id: SV_INIT.java,v 1.6 2004-08-20 21:29:57 salomo Exp $ +// $Id: SV_INIT.java,v 1.7 2004-08-22 14:25:13 salomo Exp $ package jake2.server; @@ -33,8 +33,7 @@ import jake2.sys.NET; import java.io.IOException; import java.io.RandomAccessFile; -public class SV_INIT extends Globals -{ +public class SV_INIT extends Globals { public static server_static_t svs= new server_static_t(); // persistant server info public static server_t sv= new server_t(); // local server @@ -45,8 +44,7 @@ public class SV_INIT extends Globals ================ */ - public static int SV_FindIndex(String name, int start, int max, boolean create) - { + public static int SV_FindIndex(String name, int start, int max, boolean create) { int i; if (name == null || name.length() == 0) @@ -65,8 +63,7 @@ public class SV_INIT extends Globals //strncpy (sv.configstrings[start+i], name, sizeof(sv.configstrings[i])); sv.configstrings[start + i]= name; - if (sv.state != ss_loading) - { // send the update to everyone + if (sv.state != ss_loading) { // send the update to everyone SZ.Clear(sv.multicast); MSG.WriteChar(sv.multicast, svc_configstring); MSG.WriteShort(sv.multicast, start + i); @@ -77,18 +74,15 @@ public class SV_INIT extends Globals return i; } - public static int SV_ModelIndex(String name) - { + public static int SV_ModelIndex(String name) { return SV_FindIndex(name, CS_MODELS, MAX_MODELS, true); } - public static int SV_SoundIndex(String name) - { + public static int SV_SoundIndex(String name) { return SV_FindIndex(name, CS_SOUNDS, MAX_SOUNDS, true); } - public static int SV_ImageIndex(String name) - { + public static int SV_ImageIndex(String name) { return SV_FindIndex(name, CS_IMAGES, MAX_IMAGES, true); } @@ -101,13 +95,11 @@ public class SV_INIT extends Globals baseline will be transmitted ================ */ - public static void SV_CreateBaseline() - { + public static void SV_CreateBaseline() { edict_t svent; int entnum; - for (entnum= 1; entnum < SV_GAME.ge.num_edicts; entnum++) - { + for (entnum= 1; entnum < SV_GAME.ge.num_edicts; entnum++) { //svent = EDICT_NUM(entnum); svent= SV_GAME.ge.edicts[entnum]; @@ -131,11 +123,9 @@ public class SV_INIT extends Globals SV_CheckForSavegame ================= */ - public static void SV_CheckForSavegame() - { - //char name[MAX_OSPATH]; + public static void SV_CheckForSavegame() { + String name; - //FILE *f; RandomAccessFile f; int i; @@ -147,22 +137,18 @@ public class SV_INIT extends Globals return; name= FS.Gamedir() + "/save/current/" + sv.name + ".sav"; - try - { + try { f= new RandomAccessFile(name, "r"); } - catch (Exception e) - { - return; // no savegame + catch (Exception e) { + return; } - try - { + try { f.close(); } - catch (IOException e1) - { + catch (IOException e1) { e1.printStackTrace(); } @@ -171,8 +157,7 @@ public class SV_INIT extends Globals // get configstrings and areaportals SV_CCMDS.SV_ReadLevelFile(); - if (!sv.loadgame) - { // coming back to a level after being in a different + if (!sv.loadgame) { // coming back to a level after being in a different // level, so run it for ten seconds // rlava2 was sending too many lightstyles, and overflowing the @@ -198,8 +183,7 @@ public class SV_INIT extends Globals ================ */ - public static void SV_SpawnServer(String server, String spawnpoint, int serverstate, boolean attractloop, boolean loadgame) - { + public static void SV_SpawnServer(String server, String spawnpoint, int serverstate, boolean attractloop, boolean loadgame) { int i; int checksum= 0; @@ -210,21 +194,18 @@ public class SV_INIT extends Globals Com.DPrintf("SpawnServer: " + server + "\n"); if (sv.demofile != null) - try - { + try { sv.demofile.close(); } - catch (Exception e) - { + catch (Exception e) { } svs.spawncount++; // any partially connected client will be // restarted - sv.state = ss_dead; - - Globals.server_state= sv.state; + sv.state= ss_dead; + Globals.server_state= sv.state; // wipe the entire per-level structure //memset(sv, 0, sizeof(sv)); @@ -237,13 +218,11 @@ public class SV_INIT extends Globals // save name for levels that don't set message sv.configstrings[CS_NAME]= server; - if (Cvar.VariableValue("deathmatch") != 0) - { + if (Cvar.VariableValue("deathmatch") != 0) { sv.configstrings[CS_AIRACCEL]= "" + SV_MAIN.sv_airaccelerate.value; PMove.pm_airaccelerate= SV_MAIN.sv_airaccelerate.value; } - else - { + else { sv.configstrings[CS_AIRACCEL]= "0"; PMove.pm_airaccelerate= 0; } @@ -253,8 +232,7 @@ public class SV_INIT extends Globals sv.name= server; // leave slots at start for clients only - for (i= 0; i < SV_MAIN.maxclients.value; i++) - { + for (i= 0; i < SV_MAIN.maxclients.value; i++) { // needs to reconnect if (svs.clients[i].state > cs_connected) svs.clients[i].state= cs_connected; @@ -268,12 +246,10 @@ public class SV_INIT extends Globals int iw[]= { checksum }; - if (serverstate != ss_game) - { + if (serverstate != ss_game) { sv.models[1]= CM.CM_LoadMap("", false, iw); // no real map } - else - { + else { sv.configstrings[CS_MODELS + 1]= "maps/" + server + ".bsp"; sv.models[1]= CM.CM_LoadMap(sv.configstrings[CS_MODELS + 1], false, iw); } @@ -285,8 +261,7 @@ public class SV_INIT extends Globals // SV_WORLD.SV_ClearWorld(); - for (i= 1; i < CM.CM_NumInlineModels(); i++) - { + for (i= 1; i < CM.CM_NumInlineModels(); i++) { sv.configstrings[CS_MODELS + 1 + i]= "*" + i; // copy references sv.models[i + 1]= CM.InlineModel(sv.configstrings[CS_MODELS + 1 + i]); @@ -299,7 +274,7 @@ public class SV_INIT extends Globals // precache and static commands can be issued during // map initialization - sv.state = ss_loading; + sv.state= ss_loading; Globals.server_state= sv.state; // load and spawn all other entities @@ -310,7 +285,7 @@ public class SV_INIT extends Globals SV_GAME.ge.RunFrame(); // all precaches are complete - sv.state = serverstate; + sv.state= serverstate; Globals.server_state= sv.state; // create a baseline for more efficient communications @@ -332,20 +307,17 @@ public class SV_INIT extends Globals A brand new game has been started ============== */ - public static void SV_InitGame() - { + public static void SV_InitGame() { int i; edict_t ent; //char idmaster[32]; String idmaster; - if (svs.initialized) - { + if (svs.initialized) { // cause any connected clients to reconnect SV_MAIN.SV_Shutdown("Server restarted\n", true); } - else - { + else { // make sure the client is down CL.Drop(); SCR.BeginLoadingPlaque(); @@ -356,30 +328,26 @@ public class SV_INIT extends Globals svs.initialized= true; - if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0) - { + if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0) { Com.Printf("Deathmatch and Coop both set, disabling Coop\n"); Cvar.FullSet("coop", "0", CVAR_SERVERINFO | CVAR_LATCH); } // dedicated servers are can't be single player and are usually DM // so unless they explicity set coop, force it to deathmatch - if (dedicated.value != 0) - { + if (dedicated.value != 0) { if (0 == Cvar.VariableValue("coop")) Cvar.FullSet("deathmatch", "1", CVAR_SERVERINFO | CVAR_LATCH); } // init clients - if (Cvar.VariableValue("deathmatch") != 0) - { + if (Cvar.VariableValue("deathmatch") != 0) { if (SV_MAIN.maxclients.value <= 1) Cvar.FullSet("maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH); else if (SV_MAIN.maxclients.value > MAX_CLIENTS) Cvar.FullSet("maxclients", "" + MAX_CLIENTS, CVAR_SERVERINFO | CVAR_LATCH); } - else if (Cvar.VariableValue("coop") != 0) - { + else if (Cvar.VariableValue("coop") != 0) { if (SV_MAIN.maxclients.value <= 1 || SV_MAIN.maxclients.value > 4) Cvar.FullSet("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH); @@ -413,8 +381,7 @@ public class SV_INIT extends Globals // init game SV_GAME.SV_InitGameProgs(); // bis hier alles ok! - for (i= 0; i < SV_MAIN.maxclients.value; i++) - { + for (i= 0; i < SV_MAIN.maxclients.value; i++) { ent= SV_GAME.ge.edicts[i + 1]; //ent.s.number = i + 1; //dont need this, ent.s.number already set. @@ -440,8 +407,7 @@ public class SV_INIT extends Globals map tram.cin+jail_e3 ====================== */ - public static void SV_Map(boolean attractloop, String levelstring, boolean loadgame) - { + public static void SV_Map(boolean attractloop, String levelstring, boolean loadgame) { //char level[MAX_QPATH]; //char *ch; int l; @@ -470,13 +436,11 @@ public class SV_INIT extends Globals // Cvar_Set ("nextserver", ""); int c= level.indexOf('+'); - if (c != -1) - { + if (c != -1) { Cvar.Set("nextserver", "gamemap \"" + level.substring(c + 1) + "\""); level= level.substring(0, c); } - else - { + else { Cvar.Set("nextserver", ""); } @@ -486,8 +450,7 @@ public class SV_INIT extends Globals // if there is a $, use the remainder as a spawnpoint int pos= level.indexOf('$'); - if (pos != -1) - { + if (pos != -1) { //* ch = 0; spawnpoint= level.substring(pos + 1); level= level.substring(0, pos); @@ -502,26 +465,22 @@ public class SV_INIT extends Globals level= level.substring(1); l= level.length(); - if (l > 4 && level.endsWith(".cin")) - { + if (l > 4 && level.endsWith(".cin")) { SCR.BeginLoadingPlaque(); // for local system SV_SEND.SV_BroadcastCommand("changing\n"); SV_SpawnServer(level, spawnpoint, ss_cinematic, attractloop, loadgame); } - else if (l > 4 && level.endsWith(".dm2")) - { + else if (l > 4 && level.endsWith(".dm2")) { SCR.BeginLoadingPlaque(); // for local system SV_SEND.SV_BroadcastCommand("changing\n"); SV_SpawnServer(level, spawnpoint, ss_demo, attractloop, loadgame); } - else if (l > 4 && level.endsWith(".pcx")) - { + else if (l > 4 && level.endsWith(".pcx")) { SCR.BeginLoadingPlaque(); // for local system SV_SEND.SV_BroadcastCommand("changing\n"); SV_SpawnServer(level, spawnpoint, ss_pic, attractloop, loadgame); } - else - { + else { SCR.BeginLoadingPlaque(); // for local system SV_SEND.SV_BroadcastCommand("changing\n"); SV_SEND.SV_SendClientMessages(); diff --git a/src/jake2/server/SV_SEND.java b/src/jake2/server/SV_SEND.java index 0764ce6..4fa3f45 100644 --- a/src/jake2/server/SV_SEND.java +++ b/src/jake2/server/SV_SEND.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 17.01.2004 by RST. -// $Id: SV_SEND.java,v 1.3 2004-07-08 20:56:54 hzi Exp $ +// $Id: SV_SEND.java,v 1.4 2004-08-22 14:25:13 salomo Exp $ package jake2.server; @@ -40,11 +40,11 @@ public class SV_SEND extends SV_MAIN { ============================================================================= */ - public static byte sv_outputbuf[] = new byte[SV_OUTPUTBUF_LENGTH]; + public static byte sv_outputbuf[]= new byte[SV_OUTPUTBUF_LENGTH]; public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) { if (sv_redirected == RD_PACKET) { - String s = ("print\n" + outputbuf); + String s= ("print\n" + outputbuf); Netchan.Netchan_OutOfBand(NS_SERVER, Netchan.net_from, s.length(), s.getBytes()); } else if (sv_redirected == RD_CLIENT) { @@ -103,23 +103,22 @@ public class SV_SEND extends SV_MAIN { // va_end (argptr); // echo to console - if (dedicated.value!=0) - { - - //char copy[1024]; - //int i; - - // mask off high bits - //for (i=0 ; i<1023 && string[i] ; i++) - //copy[i] = string[i]&127; - //copy[i] = 0; - //Com_Printf ("%s", copy); - - Com.Printf(s); - } + if (dedicated.value != 0) { + + //char copy[1024]; + //int i; + + // mask off high bits + //for (i=0 ; i<1023 && string[i] ; i++) + //copy[i] = string[i]&127; + //copy[i] = 0; + //Com_Printf ("%s", copy); - for (int i = 0; i < SV_MAIN.maxclients.value; i++) { - cl = SV_MAIN.svs.clients[i]; + Com.Printf(s); + } + + for (int i= 0; i < SV_MAIN.maxclients.value; i++) { + cl= SV_MAIN.svs.clients[i]; if (level < cl.messagelevel) continue; if (cl.state != cs_spawned) @@ -173,15 +172,15 @@ public class SV_SEND extends SV_MAIN { boolean reliable; int area1, area2; - reliable = false; + reliable= false; if (to != MULTICAST_ALL_R && to != MULTICAST_ALL) { - leafnum = CM.CM_PointLeafnum(origin); - area1 = CM.CM_LeafArea(leafnum); + leafnum= CM.CM_PointLeafnum(origin); + area1= CM.CM_LeafArea(leafnum); } else { - leafnum = 0; // just to avoid compiler warnings - area1 = 0; + leafnum= 0; // just to avoid compiler warnings + area1= 0; } // if doing a serverrecord, store everything @@ -190,36 +189,36 @@ public class SV_SEND extends SV_MAIN { switch (to) { case MULTICAST_ALL_R : - reliable = true; // intentional fallthrough, no break here + reliable= true; // intentional fallthrough, no break here case MULTICAST_ALL : - leafnum = 0; - mask = null; + leafnum= 0; + mask= null; break; case MULTICAST_PHS_R : - reliable = true; // intentional fallthrough + reliable= true; // intentional fallthrough case MULTICAST_PHS : - leafnum = CM.CM_PointLeafnum(origin); - cluster = CM.CM_LeafCluster(leafnum); - mask = CM.CM_ClusterPHS(cluster); + leafnum= CM.CM_PointLeafnum(origin); + cluster= CM.CM_LeafCluster(leafnum); + mask= CM.CM_ClusterPHS(cluster); break; case MULTICAST_PVS_R : - reliable = true; // intentional fallthrough + reliable= true; // intentional fallthrough case MULTICAST_PVS : - leafnum = CM.CM_PointLeafnum(origin); - cluster = CM.CM_LeafCluster(leafnum); - mask = CM.CM_ClusterPVS(cluster); + leafnum= CM.CM_PointLeafnum(origin); + cluster= CM.CM_LeafCluster(leafnum); + mask= CM.CM_ClusterPVS(cluster); break; default : - mask = null; + mask= null; Com.Error(ERR_FATAL, "SV_Multicast: bad to:" + to + "\n"); } // send the data to all relevent clients - for (j = 0; j < maxclients.value; j++) { - client = svs.clients[j]; + for (j= 0; j < maxclients.value; j++) { + client= svs.clients[j]; if (client.state == cs_free || client.state == cs_zombie) continue; @@ -227,12 +226,12 @@ public class SV_SEND extends SV_MAIN { continue; if (mask != null) { - leafnum = CM.CM_PointLeafnum(client.edict.s.origin); - cluster = CM.CM_LeafCluster(leafnum); - area2 = CM.CM_LeafArea(leafnum); + leafnum= CM.CM_PointLeafnum(client.edict.s.origin); + cluster= CM.CM_LeafCluster(leafnum); + area2= CM.CM_LeafArea(leafnum); if (!CM.CM_AreasConnected(area1, area2)) continue; - + // quake2 bugfix if (cluster == -1) continue; @@ -287,7 +286,7 @@ public class SV_SEND extends SV_MAIN { int flags; int i; int ent; - float[] origin_v = {0,0,0}; + float[] origin_v= { 0, 0, 0 }; boolean use_phs; if (volume < 0 || volume > 1.0) @@ -302,21 +301,19 @@ public class SV_SEND extends SV_MAIN { if (timeofs < 0 || timeofs > 0.255) Com.Error(ERR_FATAL, "SV_StartSound: timeofs = " + timeofs); - //ent = NUM_FOR_EDICT(entity); - //TODO: somehow risky (dont know if constant correct index) - ent = entity.index; + ent= entity.index; - if ((channel & 8) != 0) // no PHS flag - { - use_phs = false; + // no PHS flag + if ((channel & 8) != 0) { + use_phs= false; channel &= 7; } else - use_phs = true; + use_phs= true; - sendchan = (ent << 3) | (channel & 7); + sendchan= (ent << 3) | (channel & 7); - flags = 0; + flags= 0; if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME) flags |= SND_VOLUME; if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION) @@ -335,10 +332,10 @@ public class SV_SEND extends SV_MAIN { // use the entity origin unless it is a bmodel or explicitly specified if (origin == null) { - origin = origin_v; + origin= origin_v; if (entity.solid == SOLID_BSP) { - for (i = 0; i < 3; i++) - origin_v[i] = entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]); + for (i= 0; i < 3; i++) + origin_v[i]= entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]); } else { VectorCopy(entity.s.origin, origin_v); @@ -365,7 +362,7 @@ public class SV_SEND extends SV_MAIN { // if the sound doesn't attenuate,send it to everyone // (global radio chatter, voiceovers, etc) if (attenuation == ATTN_NONE) - use_phs = false; + use_phs= false; if ((channel & CHAN_RELIABLE) != 0) { if (use_phs) @@ -395,17 +392,17 @@ public class SV_SEND extends SV_MAIN { ======================= */ public static boolean SV_SendClientDatagram(client_t client) { - byte msg_buf[] = new byte[MAX_MSGLEN]; - sizebuf_t msg = new sizebuf_t(); + byte msg_buf[]= new byte[MAX_MSGLEN]; + sizebuf_t msg= new sizebuf_t(); SV_ENTS.SV_BuildClientFrame(client); SZ.Init(msg, msg_buf, msg_buf.length); - msg.allowoverflow = true; + msg.allowoverflow= true; // send over all the relevant entity_state_t // and the player_state_t - SV_CCMDS.SV_WriteFrameToClient (client, msg); + SV_CCMDS.SV_WriteFrameToClient(client, msg); // copy the accumulated multicast datagram // for this client out to the message @@ -426,7 +423,7 @@ public class SV_SEND extends SV_MAIN { Netchan.Transmit(client.netchan, msg.cursize, msg.data); // record the size for rate estimation - client.message_size[sv.framenum % RATE_MESSAGES] = msg.cursize; + client.message_size[sv.framenum % RATE_MESSAGES]= msg.cursize; return true; } @@ -444,7 +441,7 @@ public class SV_SEND extends SV_MAIN { catch (IOException e) { Com.Printf("IOError closing d9emo fiele:" + e); } - sv.demofile = null; + sv.demofile= null; } SV_ENTS.SV_Nextserver(); } @@ -465,15 +462,15 @@ public class SV_SEND extends SV_MAIN { if (c.netchan.remote_address.type == NA_LOOPBACK) return false; - total = 0; + total= 0; - for (i = 0; i < RATE_MESSAGES; i++) { + for (i= 0; i < RATE_MESSAGES; i++) { total += c.message_size[i]; } if (total > c.rate) { c.surpressCount++; - c.message_size[sv.framenum % RATE_MESSAGES] = 0; + c.message_size[sv.framenum % RATE_MESSAGES]= 0; return true; } @@ -489,20 +486,20 @@ public class SV_SEND extends SV_MAIN { int i; client_t c; int msglen; - byte msgbuf[] = new byte[MAX_MSGLEN]; + byte msgbuf[]= new byte[MAX_MSGLEN]; int r; - msglen = 0; + msglen= 0; // read the next demo message if needed if (sv.state == ss_demo && sv.demofile != null) { if (sv_paused.value != 0) - msglen = 0; + msglen= 0; else { // get the next message //r = fread (&msglen, 4, 1, sv.demofile); try { - msglen = EndianHandler.swapInt(sv.demofile.readInt()); + msglen= EndianHandler.swapInt(sv.demofile.readInt()); } catch (Exception e) { SV_DemoCompleted(); @@ -518,9 +515,9 @@ public class SV_SEND extends SV_MAIN { Com.Error(ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN"); //r = fread (msgbuf, msglen, 1, sv.demofile); - r = 0; + r= 0; try { - r = sv.demofile.read(msgbuf, 0, msglen); + r= sv.demofile.read(msgbuf, 0, msglen); } catch (IOException e1) { Com.Printf("IOError: reading demo file, " + e1); @@ -533,8 +530,8 @@ public class SV_SEND extends SV_MAIN { } // send a message to each connected client - for (i = 0; i < maxclients.value; i++) { - c = svs.clients[i]; + for (i= 0; i < maxclients.value; i++) { + c= svs.clients[i]; if (c.state == 0) continue; diff --git a/src/jake2/server/client_t.java b/src/jake2/server/client_t.java index 2bbadf9..b8ccf0e 100644 --- a/src/jake2/server/client_t.java +++ b/src/jake2/server/client_t.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 13.01.2004 by RST. -// $Id: client_t.java,v 1.1 2004-07-07 19:59:50 hzi Exp $ +// $Id: client_t.java,v 1.2 2004-08-22 14:25:13 salomo Exp $ package jake2.server; @@ -43,7 +43,6 @@ public class client_t { int state; - //char userinfo[MAX_INFO_STRING]; // name, etc String userinfo = ""; int lastframe; // for delta compression @@ -85,6 +84,6 @@ public class client_t { netchan_t netchan = new netchan_t(); - //TODO: this was introduced by rst, since java can't calculate the index out of the address. + //this was introduced by rst, since java can't calculate the index out of the address. int serverindex; } -- cgit v1.2.3 From e6917ba149aaa857c8dca342543050e22ec877f7 Mon Sep 17 00:00:00 2001 From: Rene Stoeckel Date: Sun, 22 Aug 2004 15:46:19 +0000 Subject: trigger debug messages removed --- src/jake2/game/GameAIAdapters.java | 727 +++++++++++++------------------- src/jake2/game/GameTriggerAdapters.java | 4 +- 2 files changed, 300 insertions(+), 431 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/game/GameAIAdapters.java b/src/jake2/game/GameAIAdapters.java index 465e4a3..e344318 100644 --- a/src/jake2/game/GameAIAdapters.java +++ b/src/jake2/game/GameAIAdapters.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 26.02.2004 by RST. -// $Id: GameAIAdapters.java,v 1.2 2004-07-08 20:24:29 hzi Exp $ +// $Id: GameAIAdapters.java,v 1.3 2004-08-22 15:46:19 salomo Exp $ package jake2.game; @@ -31,23 +31,19 @@ import jake2.util.*; import java.util.*; -public class GameAIAdapters -{ +public class GameAIAdapters { /** Common Boss explode animation.*/ - public static EntThinkAdapter BossExplode = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - float[] org = { 0, 0, 0 }; + public static EntThinkAdapter BossExplode= new EntThinkAdapter() { + public boolean think(edict_t self) { + float[] org= { 0, 0, 0 }; int n; - self.think = BossExplode; + self.think= BossExplode; Math3D.VectorCopy(self.s.origin, org); org[2] += 24 + (Lib.rand() & 15); - switch (self.count++) - { + switch (self.count++) { case 0 : org[0] -= 24; org[1] -= 24; @@ -81,14 +77,14 @@ public class GameAIAdapters org[1] -= 48; break; case 8 : - self.s.sound = 0; - for (n = 0; n < 4; n++) + self.s.sound= 0; + for (n= 0; n < 4; n++) GameAI.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", 500, Defines.GIB_ORGANIC); - for (n = 0; n < 8; n++) + for (n= 0; n < 8; n++) GameAI.ThrowGib(self, "models/objects/gibs/sm_metal/tris.md2", 500, Defines.GIB_METALLIC); GameAI.ThrowGib(self, "models/objects/gibs/chest/tris.md2", 500, Defines.GIB_ORGANIC); GameAI.ThrowHead(self, "models/objects/gibs/gear/tris.md2", 500, Defines.GIB_METALLIC); - self.deadflag = Defines.DEAD_DEAD; + self.deadflag= Defines.DEAD_DEAD; return true; } @@ -97,17 +93,14 @@ public class GameAIAdapters GameBase.gi.WritePosition(org); GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS); - self.nextthink = GameBase.level.time + 0.1f; + self.nextthink= GameBase.level.time + 0.1f; return true; } }; - public static EntThinkAdapter walkmonster_start_go = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter walkmonster_start_go= new EntThinkAdapter() { + public boolean think(edict_t self) { - if (0 == (self.spawnflags & 2) && GameBase.level.time < 1) - { + if (0 == (self.spawnflags & 2) && GameBase.level.time < 1) { M.M_droptofloor.think(self); if (self.groundentity != null) @@ -116,8 +109,8 @@ public class GameAIAdapters } if (0 == self.yaw_speed) - self.yaw_speed = 20; - self.viewheight = 25; + self.yaw_speed= 20; + self.viewheight= 25; Monster.monster_start_go(self); @@ -126,26 +119,22 @@ public class GameAIAdapters return true; } }; - public static EntThinkAdapter walkmonster_start = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter walkmonster_start= new EntThinkAdapter() { + public boolean think(edict_t self) { - self.think = walkmonster_start_go; + self.think= walkmonster_start_go; Monster.monster_start(self); return true; } }; - public static EntThinkAdapter flymonster_start_go = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter flymonster_start_go= new EntThinkAdapter() { + public boolean think(edict_t self) { if (!M.M_walkmove(self, 0, 0)) GameBase.gi.dprintf(self.classname + " in solid at " + Lib.vtos(self.s.origin) + "\n"); if (0 == self.yaw_speed) - self.yaw_speed = 10; - self.viewheight = 25; + self.yaw_speed= 10; + self.viewheight= 25; Monster.monster_start_go(self); @@ -154,23 +143,19 @@ public class GameAIAdapters return true; } }; - public static EntThinkAdapter flymonster_start = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter flymonster_start= new EntThinkAdapter() { + public boolean think(edict_t self) { self.flags |= Defines.FL_FLY; - self.think = flymonster_start_go; + self.think= flymonster_start_go; Monster.monster_start(self); return true; } }; - public static EntThinkAdapter swimmonster_start_go = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter swimmonster_start_go= new EntThinkAdapter() { + public boolean think(edict_t self) { if (0 == self.yaw_speed) - self.yaw_speed = 10; - self.viewheight = 10; + self.yaw_speed= 10; + self.viewheight= 10; Monster.monster_start_go(self); @@ -179,14 +164,12 @@ public class GameAIAdapters return true; } }; - public static EntThinkAdapter swimmonster_start = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter swimmonster_start= new EntThinkAdapter() { + public boolean think(edict_t self) { { self.flags |= Defines.FL_SWIM; - self.think = swimmonster_start_go; + self.think= swimmonster_start_go; Monster.monster_start(self); return true; } @@ -200,10 +183,8 @@ public class GameAIAdapters Distance is for slight position adjustments needed by the animations ============= */ - public static AIAdapter ai_turn = new AIAdapter() - { - public void ai(edict_t self, float dist) - { + public static AIAdapter ai_turn= new AIAdapter() { + public void ai(edict_t self, float dist) { if (dist != 0) M.M_walkmove(self, self.s.angles[Defines.YAW], dist); @@ -222,10 +203,8 @@ public class GameAIAdapters This replaces the QC functions: ai_forward, ai_back, ai_pain, and ai_painforward ============== */ - public static AIAdapter ai_move = new AIAdapter() - { - public void ai(edict_t self, float dist) - { + public static AIAdapter ai_move= new AIAdapter() { + public void ai(edict_t self, float dist) { M.M_walkmove(self, self.s.angles[Defines.YAW], dist); } }; @@ -236,12 +215,10 @@ public class GameAIAdapters The monster is walking it's beat ============= */ - public static AIAdapter ai_walk = new AIAdapter() - { - public void ai(edict_t self, float dist) - { + public static AIAdapter ai_walk= new AIAdapter() { + public void ai(edict_t self, float dist) { if (self.index == 312) - self.index = 312; + self.index= 312; M.M_MoveToGoal(self, dist); @@ -249,16 +226,13 @@ public class GameAIAdapters if (GameUtil.FindTarget(self)) return; - if ((self.monsterinfo.search != null) && (GameBase.level.time > self.monsterinfo.idle_time)) - { - if (self.monsterinfo.idle_time != 0) - { + if ((self.monsterinfo.search != null) && (GameBase.level.time > self.monsterinfo.idle_time)) { + if (self.monsterinfo.idle_time != 0) { self.monsterinfo.search.think(self); - self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15; + self.monsterinfo.idle_time= GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15; } - else - { - self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15; + else { + self.monsterinfo.idle_time= GameBase.level.time + Globals.rnd.nextFloat() * 15; } } } @@ -272,24 +246,19 @@ public class GameAIAdapters ============== */ - public static AIAdapter ai_stand = new AIAdapter() - { - public void ai(edict_t self, float dist) - { - float[] v = { 0, 0, 0 }; + public static AIAdapter ai_stand= new AIAdapter() { + public void ai(edict_t self, float dist) { + float[] v= { 0, 0, 0 }; if (dist != 0) M.M_walkmove(self, self.s.angles[Defines.YAW], dist); - if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) - { - if (self.enemy != null) - { + if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) { + if (self.enemy != null) { Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, v); - self.ideal_yaw = Math3D.vectoyaw(v); + self.ideal_yaw= Math3D.vectoyaw(v); if (self.s.angles[Defines.YAW] != self.ideal_yaw - && 0 != (self.monsterinfo.aiflags & Defines.AI_TEMP_STAND_GROUND)) - { + && 0 != (self.monsterinfo.aiflags & Defines.AI_TEMP_STAND_GROUND)) { self.monsterinfo.aiflags &= ~(Defines.AI_STAND_GROUND | Defines.AI_TEMP_STAND_GROUND); self.monsterinfo.run.think(self); } @@ -304,22 +273,18 @@ public class GameAIAdapters if (GameUtil.FindTarget(self)) return; - if (GameBase.level.time > self.monsterinfo.pausetime) - { + if (GameBase.level.time > self.monsterinfo.pausetime) { self.monsterinfo.walk.think(self); return; } - if (0 == (self.spawnflags & 1) && (self.monsterinfo.idle != null) && (GameBase.level.time > self.monsterinfo.idle_time)) - { - if (self.monsterinfo.idle_time != 0) - { + if (0 == (self.spawnflags & 1) && (self.monsterinfo.idle != null) && (GameBase.level.time > self.monsterinfo.idle_time)) { + if (self.monsterinfo.idle_time != 0) { self.monsterinfo.idle.think(self); - self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15; + self.monsterinfo.idle_time= GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15; } - else - { - self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15; + else { + self.monsterinfo.idle_time= GameBase.level.time + Globals.rnd.nextFloat() * 15; } } } @@ -332,15 +297,13 @@ public class GameAIAdapters Use this call with a distnace of 0 to replace ai_face ============== */ - public static AIAdapter ai_charge = new AIAdapter() - { + public static AIAdapter ai_charge= new AIAdapter() { - public void ai(edict_t self, float dist) - { - float[] v = { 0, 0, 0 }; + public void ai(edict_t self, float dist) { + float[] v= { 0, 0, 0 }; Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, v); - self.ideal_yaw = Math3D.vectoyaw(v); + self.ideal_yaw= Math3D.vectoyaw(v); M.M_ChangeYaw(self); if (dist != 0) @@ -354,11 +317,9 @@ public class GameAIAdapters The monster has an enemy it is trying to kill ============= */ //ok - public static AIAdapter ai_run = new AIAdapter() - { - public void ai(edict_t self, float dist) - { - float[] v = { 0, 0, 0 }; + public static AIAdapter ai_run= new AIAdapter() { + public void ai(edict_t self, float dist) { + float[] v= { 0, 0, 0 }; edict_t tempgoal; edict_t save; @@ -366,22 +327,19 @@ public class GameAIAdapters edict_t marker; float d1, d2; trace_t tr; // mem - float[] v_forward = { 0, 0, 0 }, v_right = { 0, 0, 0 }; + float[] v_forward= { 0, 0, 0 }, v_right= { 0, 0, 0 }; float left, center, right; - float[] left_target = { 0, 0, 0 }, right_target = { 0, 0, 0 }; + float[] left_target= { 0, 0, 0 }, right_target= { 0, 0, 0 }; // if we're going to a combat point, just proceed - if ((self.monsterinfo.aiflags & Defines.AI_COMBAT_POINT) != 0) - { + if ((self.monsterinfo.aiflags & Defines.AI_COMBAT_POINT) != 0) { M.M_MoveToGoal(self, dist); return; } - if ((self.monsterinfo.aiflags & Defines.AI_SOUND_TARGET) != 0) - { + if ((self.monsterinfo.aiflags & Defines.AI_SOUND_TARGET) != 0) { Math3D.VectorSubtract(self.s.origin, self.enemy.s.origin, v); - if (Math3D.VectorLength(v) < 64) - { + if (Math3D.VectorLength(v) < 64) { self.monsterinfo.aiflags |= (Defines.AI_STAND_GROUND | Defines.AI_TEMP_STAND_GROUND); self.monsterinfo.stand.think(self); return; @@ -396,107 +354,95 @@ public class GameAIAdapters if (GameAI.ai_checkattack(self, dist)) return; - if (self.monsterinfo.attack_state == Defines.AS_SLIDING) - { + if (self.monsterinfo.attack_state == Defines.AS_SLIDING) { GameAI.ai_run_slide(self, dist); return; } - if (GameUtilAdapters.enemy_vis) - { + if (GameUtilAdapters.enemy_vis) { // if (self.aiflags & AI_LOST_SIGHT) // dprint("regained sight\n"); M.M_MoveToGoal(self, dist); self.monsterinfo.aiflags &= ~Defines.AI_LOST_SIGHT; Math3D.VectorCopy(self.enemy.s.origin, self.monsterinfo.last_sighting); - self.monsterinfo.trail_time = GameBase.level.time; + self.monsterinfo.trail_time= GameBase.level.time; return; } // coop will change to another enemy if visible - if (GameBase.coop.value != 0) - { + if (GameBase.coop.value != 0) { // FIXME: insane guys get mad with this, which causes crashes! if (GameUtil.FindTarget(self)) return; } - if ((self.monsterinfo.search_time != 0) && (GameBase.level.time > (self.monsterinfo.search_time + 20))) - { + if ((self.monsterinfo.search_time != 0) && (GameBase.level.time > (self.monsterinfo.search_time + 20))) { M.M_MoveToGoal(self, dist); - self.monsterinfo.search_time = 0; + self.monsterinfo.search_time= 0; // dprint("search timeout\n"); return; } - save = self.goalentity; - tempgoal = GameUtil.G_Spawn(); - self.goalentity = tempgoal; + save= self.goalentity; + tempgoal= GameUtil.G_Spawn(); + self.goalentity= tempgoal; - new1 = false; + new1= false; - if (0 == (self.monsterinfo.aiflags & Defines.AI_LOST_SIGHT)) - { + if (0 == (self.monsterinfo.aiflags & Defines.AI_LOST_SIGHT)) { // just lost sight of the player, decide where to go first // dprint("lost sight of player, last seen at "); dprint(vtos(self.last_sighting)); dprint("\n"); self.monsterinfo.aiflags |= (Defines.AI_LOST_SIGHT | Defines.AI_PURSUIT_LAST_SEEN); self.monsterinfo.aiflags &= ~(Defines.AI_PURSUE_NEXT | Defines.AI_PURSUE_TEMP); - new1 = true; + new1= true; } - if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_NEXT) != 0) - { + if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_NEXT) != 0) { self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_NEXT; // dprint("reached current goal: "); dprint(vtos(self.origin)); dprint(" "); dprint(vtos(self.last_sighting)); dprint(" "); dprint(ftos(vlen(self.origin - self.last_sighting))); dprint("\n"); // give ourself more time since we got this far - self.monsterinfo.search_time = GameBase.level.time + 5; + self.monsterinfo.search_time= GameBase.level.time + 5; - if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_TEMP) != 0) - { + if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_TEMP) != 0) { // dprint("was temp goal; retrying original\n"); self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_TEMP; - marker = null; + marker= null; Math3D.VectorCopy(self.monsterinfo.saved_goal, self.monsterinfo.last_sighting); - new1 = true; + new1= true; } - else if ((self.monsterinfo.aiflags & Defines.AI_PURSUIT_LAST_SEEN) != 0) - { + else if ((self.monsterinfo.aiflags & Defines.AI_PURSUIT_LAST_SEEN) != 0) { self.monsterinfo.aiflags &= ~Defines.AI_PURSUIT_LAST_SEEN; - marker = PlayerTrail.PickFirst(self); + marker= PlayerTrail.PickFirst(self); } - else - { - marker = PlayerTrail.PickNext(self); + else { + marker= PlayerTrail.PickNext(self); } - if (marker != null) - { + if (marker != null) { Math3D.VectorCopy(marker.s.origin, self.monsterinfo.last_sighting); - self.monsterinfo.trail_time = marker.timestamp; - self.s.angles[Defines.YAW] = self.ideal_yaw = marker.s.angles[Defines.YAW]; + self.monsterinfo.trail_time= marker.timestamp; + self.s.angles[Defines.YAW]= self.ideal_yaw= marker.s.angles[Defines.YAW]; // dprint("heading is "); dprint(ftos(self.ideal_yaw)); dprint("\n"); // debug_drawline(self.origin, self.last_sighting, 52); - new1 = true; + new1= true; } } Math3D.VectorSubtract(self.s.origin, self.monsterinfo.last_sighting, v); - d1 = Math3D.VectorLength(v); - if (d1 <= dist) - { + d1= Math3D.VectorLength(v); + if (d1 <= dist) { self.monsterinfo.aiflags |= Defines.AI_PURSUE_NEXT; - dist = d1; + dist= d1; } Math3D.VectorCopy(self.monsterinfo.last_sighting, self.goalentity.s.origin); - if (new1) - { + if (new1) { // gi.dprintf("checking for course correction\n"); - tr = + tr= GameBase.gi.trace( self.s.origin, self.mins, @@ -504,30 +450,27 @@ public class GameAIAdapters self.monsterinfo.last_sighting, self, Defines.MASK_PLAYERSOLID); - if (tr.fraction < 1) - { + if (tr.fraction < 1) { Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); - d1 = Math3D.VectorLength(v); - center = tr.fraction; - d2 = d1 * ((center + 1) / 2); - self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); + d1= Math3D.VectorLength(v); + center= tr.fraction; + d2= d1 * ((center + 1) / 2); + self.s.angles[Defines.YAW]= self.ideal_yaw= Math3D.vectoyaw(v); Math3D.AngleVectors(self.s.angles, v_forward, v_right, null); Math3D.VectorSet(v, d2, -16, 0); Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target); - tr = GameBase.gi.trace(self.s.origin, self.mins, self.maxs, left_target, self, Defines.MASK_PLAYERSOLID); - left = tr.fraction; + tr= GameBase.gi.trace(self.s.origin, self.mins, self.maxs, left_target, self, Defines.MASK_PLAYERSOLID); + left= tr.fraction; Math3D.VectorSet(v, d2, 16, 0); Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, right_target); - tr = GameBase.gi.trace(self.s.origin, self.mins, self.maxs, right_target, self, Defines.MASK_PLAYERSOLID); - right = tr.fraction; - - center = (d1 * center) / d2; - if (left >= center && left > right) - { - if (left < 1) - { + tr= GameBase.gi.trace(self.s.origin, self.mins, self.maxs, right_target, self, Defines.MASK_PLAYERSOLID); + right= tr.fraction; + + center= (d1 * center) / d2; + if (left >= center && left > right) { + if (left < 1) { Math3D.VectorSet(v, d2 * left * 0.5f, -16f, 0f); Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target); // gi.dprintf("incomplete path, go part way and adjust again\n"); @@ -537,14 +480,12 @@ public class GameAIAdapters Math3D.VectorCopy(left_target, self.goalentity.s.origin); Math3D.VectorCopy(left_target, self.monsterinfo.last_sighting); Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); - self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); + self.s.angles[Defines.YAW]= self.ideal_yaw= Math3D.vectoyaw(v); // gi.dprintf("adjusted left\n"); // debug_drawline(self.origin, self.last_sighting, 152); } - else if (right >= center && right > left) - { - if (right < 1) - { + else if (right >= center && right > left) { + if (right < 1) { Math3D.VectorSet(v, d2 * right * 0.5f, 16f, 0f); Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, right_target); // gi.dprintf("incomplete path, go part way and adjust again\n"); @@ -554,7 +495,7 @@ public class GameAIAdapters Math3D.VectorCopy(right_target, self.goalentity.s.origin); Math3D.VectorCopy(right_target, self.monsterinfo.last_sighting); Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); - self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); + self.s.angles[Defines.YAW]= self.ideal_yaw= Math3D.vectoyaw(v); // gi.dprintf("adjusted right\n"); // debug_drawline(self.origin, self.last_sighting, 152); } @@ -567,35 +508,32 @@ public class GameAIAdapters GameUtil.G_FreeEdict(tempgoal); if (self != null) - self.goalentity = save; + self.goalentity= save; } }; - public static EntInteractAdapter Pickup_Ammo = new EntInteractAdapter() - { - public boolean interact(edict_t ent, edict_t other) - { + public static EntInteractAdapter Pickup_Ammo= new EntInteractAdapter() { + public boolean interact(edict_t ent, edict_t other) { int oldcount; int count; boolean weapon; - weapon = (ent.item.flags & Defines.IT_WEAPON) != 0; + weapon= (ent.item.flags & Defines.IT_WEAPON) != 0; if ((weapon) && ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO) != 0) - count = 1000; + count= 1000; else if (ent.count != 0) - count = ent.count; + count= ent.count; else - count = ent.item.quantity; + count= ent.item.quantity; - oldcount = other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]; + oldcount= other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]; if (!GameAI.Add_Ammo(other, ent.item, count)) return false; - if (weapon && 0 == oldcount) - { + if (weapon && 0 == oldcount) { if (other.client.pers.weapon != ent.item && (0 == GameBase.deathmatch.value || other.client.pers.weapon == GameUtil.FindItem("blaster"))) - other.client.newweapon = ent.item; + other.client.newweapon= ent.item; } if (0 == (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM)) && (GameBase.deathmatch.value != 0)) @@ -603,10 +541,8 @@ public class GameAIAdapters return true; } }; - public static EntInteractAdapter Pickup_Armor = new EntInteractAdapter() - { - public boolean interact(edict_t ent, edict_t other) - { + public static EntInteractAdapter Pickup_Armor= new EntInteractAdapter() { + public boolean interact(edict_t ent, edict_t other) { int old_armor_index; gitem_armor_t oldinfo; gitem_armor_t newinfo; @@ -615,90 +551,82 @@ public class GameAIAdapters int salvagecount; // get info on new armor - newinfo = (gitem_armor_t) ent.item.info; + newinfo= (gitem_armor_t) ent.item.info; - old_armor_index = GameUtil.ArmorIndex(other); + old_armor_index= GameUtil.ArmorIndex(other); // handle armor shards specially - if (ent.item.tag == Defines.ARMOR_SHARD) - { + if (ent.item.tag == Defines.ARMOR_SHARD) { if (0 == old_armor_index) - other.client.pers.inventory[GameUtilAdapters.jacket_armor_index] = 2; + other.client.pers.inventory[GameUtilAdapters.jacket_armor_index]= 2; else other.client.pers.inventory[old_armor_index] += 2; } // if player has no armor, just use it - else if (0 == old_armor_index) - { - other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)] = newinfo.base_count; + else if (0 == old_armor_index) { + other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]= newinfo.base_count; } // use the better armor - else - { + else { // get info on old armor if (old_armor_index == GameUtilAdapters.jacket_armor_index) - oldinfo = jacketarmor_info; + oldinfo= jacketarmor_info; else if (old_armor_index == GameUtilAdapters.combat_armor_index) - oldinfo = combatarmor_info; + oldinfo= combatarmor_info; else // (old_armor_index == body_armor_index) - oldinfo = bodyarmor_info; + oldinfo= bodyarmor_info; - if (newinfo.normal_protection > oldinfo.normal_protection) - { + if (newinfo.normal_protection > oldinfo.normal_protection) { // calc new armor values - salvage = oldinfo.normal_protection / newinfo.normal_protection; - salvagecount = (int) salvage * other.client.pers.inventory[old_armor_index]; - newcount = newinfo.base_count + salvagecount; + salvage= oldinfo.normal_protection / newinfo.normal_protection; + salvagecount= (int) salvage * other.client.pers.inventory[old_armor_index]; + newcount= newinfo.base_count + salvagecount; if (newcount > newinfo.max_count) - newcount = newinfo.max_count; + newcount= newinfo.max_count; // zero count of old armor so it goes away - other.client.pers.inventory[old_armor_index] = 0; + other.client.pers.inventory[old_armor_index]= 0; // change armor to new item with computed value - other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)] = newcount; + other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]= newcount; } - else - { + else { // calc new armor values - salvage = newinfo.normal_protection / oldinfo.normal_protection; - salvagecount = (int) salvage * newinfo.base_count; - newcount = other.client.pers.inventory[old_armor_index] + salvagecount; + salvage= newinfo.normal_protection / oldinfo.normal_protection; + salvagecount= (int) salvage * newinfo.base_count; + newcount= other.client.pers.inventory[old_armor_index] + salvagecount; if (newcount > oldinfo.max_count) - newcount = oldinfo.max_count; + newcount= oldinfo.max_count; // if we're already maxed out then we don't need the new armor if (other.client.pers.inventory[old_armor_index] >= newcount) return false; // update current armor value - other.client.pers.inventory[old_armor_index] = newcount; + other.client.pers.inventory[old_armor_index]= newcount; } } - if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value == 0)) + if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0)) GameUtil.SetRespawn(ent, 20); return true; } }; - public static EntInteractAdapter Pickup_PowerArmor = new EntInteractAdapter() - { - public boolean interact(edict_t ent, edict_t other) - { + public static EntInteractAdapter Pickup_PowerArmor= new EntInteractAdapter() { + public boolean interact(edict_t ent, edict_t other) { int quantity; - quantity = other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]; + quantity= other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]; other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]++; - if (GameBase.deathmatch.value != 0) - { + if (GameBase.deathmatch.value != 0) { if (0 == (ent.spawnflags & Defines.DROPPED_ITEM)) GameUtil.SetRespawn(ent, ent.item.quantity); // auto-use for DM only if we didn't already have one @@ -710,14 +638,12 @@ public class GameAIAdapters }; // ====================================================================== - public static EntInteractAdapter Pickup_Powerup = new EntInteractAdapter() - { + public static EntInteractAdapter Pickup_Powerup= new EntInteractAdapter() { - public boolean interact(edict_t ent, edict_t other) - { + public boolean interact(edict_t ent, edict_t other) { int quantity; - quantity = other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]; + quantity= other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]; if ((GameBase.skill.value == 1 && quantity >= 2) || (GameBase.skill.value >= 2 && quantity >= 1)) return false; @@ -726,15 +652,13 @@ public class GameAIAdapters other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]++; - if (GameBase.deathmatch.value != 0) - { + if (GameBase.deathmatch.value != 0) { if (0 == (ent.spawnflags & Defines.DROPPED_ITEM)) GameUtil.SetRespawn(ent, ent.item.quantity); if (((int) GameBase.dmflags.value & Defines.DF_INSTANT_ITEMS) != 0 - || ((ent.item.use == GameUtilAdapters.Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))) - { + || ((ent.item.use == GameUtilAdapters.Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))) { if ((ent.item.use == GameUtilAdapters.Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM)) - GameUtilAdapters.quad_drop_timeout_hack = (int) ((ent.nextthink - GameBase.level.time) / Defines.FRAMETIME); + GameUtilAdapters.quad_drop_timeout_hack= (int) ((ent.nextthink - GameBase.level.time) / Defines.FRAMETIME); ent.item.use.use(other, ent.item); } @@ -743,15 +667,13 @@ public class GameAIAdapters return true; } }; - public static EntInteractAdapter Pickup_Adrenaline = new EntInteractAdapter() - { - public boolean interact(edict_t ent, edict_t other) - { + public static EntInteractAdapter Pickup_Adrenaline= new EntInteractAdapter() { + public boolean interact(edict_t ent, edict_t other) { if (GameBase.deathmatch.value == 0) other.max_health += 1; if (other.health < other.max_health) - other.health = other.max_health; + other.health= other.max_health; if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0)) GameUtil.SetRespawn(ent, ent.item.quantity); @@ -760,10 +682,8 @@ public class GameAIAdapters } }; - public static EntInteractAdapter Pickup_AncientHead = new EntInteractAdapter() - { - public boolean interact(edict_t ent, edict_t other) - { + public static EntInteractAdapter Pickup_AncientHead= new EntInteractAdapter() { + public boolean interact(edict_t ent, edict_t other) { other.max_health += 2; if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0)) @@ -772,38 +692,34 @@ public class GameAIAdapters return true; } }; - public static EntInteractAdapter Pickup_Bandolier = new EntInteractAdapter() - { - public boolean interact(edict_t ent, edict_t other) - { + public static EntInteractAdapter Pickup_Bandolier= new EntInteractAdapter() { + public boolean interact(edict_t ent, edict_t other) { gitem_t item; int index; if (other.client.pers.max_bullets < 250) - other.client.pers.max_bullets = 250; + other.client.pers.max_bullets= 250; if (other.client.pers.max_shells < 150) - other.client.pers.max_shells = 150; + other.client.pers.max_shells= 150; if (other.client.pers.max_cells < 250) - other.client.pers.max_cells = 250; + other.client.pers.max_cells= 250; if (other.client.pers.max_slugs < 75) - other.client.pers.max_slugs = 75; + other.client.pers.max_slugs= 75; - item = GameUtil.FindItem("Bullets"); - if (item != null) - { - index = GameUtil.ITEM_INDEX(item); + item= GameUtil.FindItem("Bullets"); + if (item != null) { + index= GameUtil.ITEM_INDEX(item); other.client.pers.inventory[index] += item.quantity; if (other.client.pers.inventory[index] > other.client.pers.max_bullets) - other.client.pers.inventory[index] = other.client.pers.max_bullets; + other.client.pers.inventory[index]= other.client.pers.max_bullets; } - item = GameUtil.FindItem("Shells"); - if (item != null) - { - index = GameUtil.ITEM_INDEX(item); + item= GameUtil.FindItem("Shells"); + if (item != null) { + index= GameUtil.ITEM_INDEX(item); other.client.pers.inventory[index] += item.quantity; if (other.client.pers.inventory[index] > other.client.pers.max_shells) - other.client.pers.inventory[index] = other.client.pers.max_shells; + other.client.pers.inventory[index]= other.client.pers.max_shells; } if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0)) @@ -813,22 +729,18 @@ public class GameAIAdapters } }; - public static EntUseAdapter Use_Item = new EntUseAdapter() - { - public void use(edict_t ent, edict_t other, edict_t activator) - { + public static EntUseAdapter Use_Item= new EntUseAdapter() { + public void use(edict_t ent, edict_t other, edict_t activator) { ent.svflags &= ~Defines.SVF_NOCLIENT; - ent.use = null; + ent.use= null; - if ((ent.spawnflags & Defines.ITEM_NO_TOUCH) != 0) - { - ent.solid = Defines.SOLID_BBOX; - ent.touch = null; + if ((ent.spawnflags & Defines.ITEM_NO_TOUCH) != 0) { + ent.solid= Defines.SOLID_BBOX; + ent.touch= null; } - else - { - ent.solid = Defines.SOLID_TRIGGER; - ent.touch = GameUtilAdapters.Touch_Item; + else { + ent.solid= Defines.SOLID_TRIGGER; + ent.touch= GameUtilAdapters.Touch_Item; } GameBase.gi.linkentity(ent); @@ -840,36 +752,33 @@ public class GameAIAdapters ================ */ - public static EntThinkAdapter droptofloor = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + public static EntThinkAdapter droptofloor= new EntThinkAdapter() { + public boolean think(edict_t ent) { trace_t tr; - float[] dest = { 0, 0, 0 }; + float[] dest= { 0, 0, 0 }; //float v[]; //v = Lib.tv(-15, -15, -15); //Math3D.VectorCopy(v, ent.mins); - ent.mins[0] = ent.mins[1] = ent.mins[2] = -15; + ent.mins[0]= ent.mins[1]= ent.mins[2]= -15; //v = Lib.tv(15, 15, 15); //Math3D.VectorCopy(v, ent.maxs); - ent.maxs[0] = ent.maxs[1] = ent.maxs[2] = 15; + ent.maxs[0]= ent.maxs[1]= ent.maxs[2]= 15; if (ent.model != null) GameBase.gi.setmodel(ent, ent.model); else GameBase.gi.setmodel(ent, ent.item.world_model); - ent.solid = Defines.SOLID_TRIGGER; - ent.movetype = Defines.MOVETYPE_TOSS; - ent.touch = GameUtilAdapters.Touch_Item; + ent.solid= Defines.SOLID_TRIGGER; + ent.movetype= Defines.MOVETYPE_TOSS; + ent.touch= GameUtilAdapters.Touch_Item; - float v[] = {0, 0, -128}; + float v[]= { 0, 0, -128 }; Math3D.VectorAdd(ent.s.origin, v, dest); - tr = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, dest, ent, Defines.MASK_SOLID); - if (tr.startsolid) - { + tr= GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, dest, ent, Defines.MASK_SOLID); + if (tr.startsolid) { GameBase.gi.dprintf("droptofloor: " + ent.classname + " startsolid at " + Lib.vtos(ent.s.origin) + "\n"); GameUtil.G_FreeEdict(ent); return true; @@ -877,87 +786,74 @@ public class GameAIAdapters Math3D.VectorCopy(tr.endpos, ent.s.origin); - if (ent.team != null) - { + if (ent.team != null) { ent.flags &= ~Defines.FL_TEAMSLAVE; - ent.chain = ent.teamchain; - ent.teamchain = null; + ent.chain= ent.teamchain; + ent.teamchain= null; ent.svflags |= Defines.SVF_NOCLIENT; - ent.solid = Defines.SOLID_NOT; - if (ent == ent.teammaster) - { - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; - ent.think = GameUtilAdapters.DoRespawn; + ent.solid= Defines.SOLID_NOT; + if (ent == ent.teammaster) { + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; + ent.think= GameUtilAdapters.DoRespawn; } } - if ((ent.spawnflags & Defines.ITEM_NO_TOUCH) != 0) - { - ent.solid = Defines.SOLID_BBOX; - ent.touch = null; + if ((ent.spawnflags & Defines.ITEM_NO_TOUCH) != 0) { + ent.solid= Defines.SOLID_BBOX; + ent.touch= null; ent.s.effects &= ~Defines.EF_ROTATE; ent.s.renderfx &= ~Defines.RF_GLOW; } - if ((ent.spawnflags & Defines.ITEM_TRIGGER_SPAWN) != 0) - { + if ((ent.spawnflags & Defines.ITEM_TRIGGER_SPAWN) != 0) { ent.svflags |= Defines.SVF_NOCLIENT; - ent.solid = Defines.SOLID_NOT; - ent.use = Use_Item; + ent.solid= Defines.SOLID_NOT; + ent.use= Use_Item; } GameBase.gi.linkentity(ent); return true; } }; - public static EntThinkAdapter gib_think = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter gib_think= new EntThinkAdapter() { + public boolean think(edict_t self) { self.s.frame++; - self.nextthink = GameBase.level.time + Defines.FRAMETIME; + self.nextthink= GameBase.level.time + Defines.FRAMETIME; - if (self.s.frame == 10) - { - self.think = GameUtilAdapters.G_FreeEdictA; - self.nextthink = GameBase.level.time + 8 + Globals.rnd.nextFloat() * 10; + if (self.s.frame == 10) { + self.think= GameUtilAdapters.G_FreeEdictA; + self.nextthink= GameBase.level.time + 8 + Globals.rnd.nextFloat() * 10; } return true; } }; - public static EntTouchAdapter gib_touch = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { - float[] normal_angles = { 0, 0, 0 }, right = { 0, 0, 0 }; + public static EntTouchAdapter gib_touch= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { + float[] normal_angles= { 0, 0, 0 }, right= { 0, 0, 0 }; if (null == self.groundentity) return; - self.touch = null; + self.touch= null; - if (plane != null) - { + if (plane != null) { GameBase.gi.sound(self, Defines.CHAN_VOICE, GameBase.gi.soundindex("misc/fhit3.wav"), 1, Defines.ATTN_NORM, 0); Math3D.vectoangles(plane.normal, normal_angles); Math3D.AngleVectors(normal_angles, null, right, null); Math3D.vectoangles(right, self.s.angles); - if (self.s.modelindex == GameBase.sm_meat_index) - { + if (self.s.modelindex == GameBase.sm_meat_index) { self.s.frame++; - self.think = gib_think; - self.nextthink = GameBase.level.time + Defines.FRAMETIME; + self.think= gib_think; + self.nextthink= GameBase.level.time + Defines.FRAMETIME; } } } }; - public static EntDieAdapter gib_die = new EntDieAdapter() - { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { + public static EntDieAdapter gib_die= new EntDieAdapter() { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { GameUtil.G_FreeEdict(self); } }; @@ -966,49 +862,44 @@ public class GameAIAdapters debris ================= */ - public static EntDieAdapter debris_die = new EntDieAdapter() - { + public static EntDieAdapter debris_die= new EntDieAdapter() { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { GameUtil.G_FreeEdict(self); } }; - public static int player_die_i = 0; + public static int player_die_i= 0; /* ================== player_die ================== */ - static EntDieAdapter player_die = new EntDieAdapter() - { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { + static EntDieAdapter player_die= new EntDieAdapter() { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { int n; Math3D.VectorClear(self.avelocity); - self.takedamage = Defines.DAMAGE_YES; - self.movetype = Defines.MOVETYPE_TOSS; + self.takedamage= Defines.DAMAGE_YES; + self.movetype= Defines.MOVETYPE_TOSS; - self.s.modelindex2 = 0; // remove linked weapon model + self.s.modelindex2= 0; // remove linked weapon model - self.s.angles[0] = 0; - self.s.angles[2] = 0; + self.s.angles[0]= 0; + self.s.angles[2]= 0; - self.s.sound = 0; - self.client.weapon_sound = 0; + self.s.sound= 0; + self.client.weapon_sound= 0; - self.maxs[2] = -8; + self.maxs[2]= -8; // self.solid = SOLID_NOT; self.svflags |= Defines.SVF_DEADMONSTER; - if (self.deadflag == 0) - { - self.client.respawn_time = GameBase.level.time + 1.0f; + if (self.deadflag == 0) { + self.client.respawn_time= GameBase.level.time + 1.0f; GameAI.LookAtKiller(self, inflictor, attacker); - self.client.ps.pmove.pm_type = Defines.PM_DEAD; + self.client.ps.pmove.pm_type= Defines.PM_DEAD; GameAI.ClientObituary(self, inflictor, attacker); GameAI.TossClientWeapon(self); if (GameBase.deathmatch.value != 0) @@ -1016,57 +907,51 @@ public class GameAIAdapters // clear inventory // this is kind of ugly, but it's how we want to handle keys in coop - for (n = 0; n < GameBase.game.num_items; n++) - { + for (n= 0; n < GameBase.game.num_items; n++) { if (GameBase.coop.value != 0 && (GameAI.itemlist[n].flags & Defines.IT_KEY) != 0) - self.client.resp.coop_respawn.inventory[n] = self.client.pers.inventory[n]; - self.client.pers.inventory[n] = 0; + self.client.resp.coop_respawn.inventory[n]= self.client.pers.inventory[n]; + self.client.pers.inventory[n]= 0; } } // remove powerups - self.client.quad_framenum = 0; - self.client.invincible_framenum = 0; - self.client.breather_framenum = 0; - self.client.enviro_framenum = 0; + self.client.quad_framenum= 0; + self.client.invincible_framenum= 0; + self.client.breather_framenum= 0; + self.client.enviro_framenum= 0; self.flags &= ~Defines.FL_POWER_ARMOR; - if (self.health < -40) - { // gib + if (self.health < -40) { // gib GameBase.gi.sound(self, Defines.CHAN_BODY, GameBase.gi.soundindex("misc/udeath.wav"), 1, Defines.ATTN_NORM, 0); - for (n = 0; n < 4; n++) + for (n= 0; n < 4; n++) GameAI.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, Defines.GIB_ORGANIC); GameAI.ThrowClientHead(self, damage); - self.takedamage = Defines.DAMAGE_NO; + self.takedamage= Defines.DAMAGE_NO; } - else - { // normal death - if (self.deadflag == 0) - { + else { // normal death + if (self.deadflag == 0) { - player_die_i = (player_die_i + 1) % 3; + player_die_i= (player_die_i + 1) % 3; // start a death animation - self.client.anim_priority = Defines.ANIM_DEATH; - if ((self.client.ps.pmove.pm_flags & Defines.PMF_DUCKED) != 0) - { - self.s.frame = M_Player.FRAME_crdeath1 - 1; - self.client.anim_end = M_Player.FRAME_crdeath5; + self.client.anim_priority= Defines.ANIM_DEATH; + if ((self.client.ps.pmove.pm_flags & Defines.PMF_DUCKED) != 0) { + self.s.frame= M_Player.FRAME_crdeath1 - 1; + self.client.anim_end= M_Player.FRAME_crdeath5; } else - switch (player_die_i) - { + switch (player_die_i) { case 0 : - self.s.frame = M_Player.FRAME_death101 - 1; - self.client.anim_end = M_Player.FRAME_death106; + self.s.frame= M_Player.FRAME_death101 - 1; + self.client.anim_end= M_Player.FRAME_death106; break; case 1 : - self.s.frame = M_Player.FRAME_death201 - 1; - self.client.anim_end = M_Player.FRAME_death206; + self.s.frame= M_Player.FRAME_death201 - 1; + self.client.anim_end= M_Player.FRAME_death206; break; case 2 : - self.s.frame = M_Player.FRAME_death301 - 1; - self.client.anim_end = M_Player.FRAME_death308; + self.s.frame= M_Player.FRAME_death301 - 1; + self.client.anim_end= M_Player.FRAME_death308; break; } @@ -1080,20 +965,18 @@ public class GameAIAdapters } } - self.deadflag = Defines.DEAD_DEAD; + self.deadflag= Defines.DEAD_DEAD; GameBase.gi.linkentity(self); } }; - public static Comparator PlayerSort = new Comparator() - { - public int compare(Object o1, Object o2) - { - int anum = ((Integer) o1).intValue(); - int bnum = ((Integer) o2).intValue(); + public static Comparator PlayerSort= new Comparator() { + public int compare(Object o1, Object o2) { + int anum= ((Integer) o1).intValue(); + int bnum= ((Integer) o2).intValue(); - int anum1 = GameBase.game.clients[anum].ps.stats[Defines.STAT_FRAGS]; - int bnum1 = GameBase.game.clients[bnum].ps.stats[Defines.STAT_FRAGS]; + int anum1= GameBase.game.clients[anum].ps.stats[Defines.STAT_FRAGS]; + int bnum1= GameBase.game.clients[bnum].ps.stats[Defines.STAT_FRAGS]; if (anum1 < bnum1) return -1; @@ -1102,22 +985,17 @@ public class GameAIAdapters return 0; } }; - public static ItemUseAdapter Use_PowerArmor = new ItemUseAdapter() - { - public void use(edict_t ent, gitem_t item) - { + public static ItemUseAdapter Use_PowerArmor= new ItemUseAdapter() { + public void use(edict_t ent, gitem_t item) { int index; - if ((ent.flags & Defines.FL_POWER_ARMOR) != 0) - { + if ((ent.flags & Defines.FL_POWER_ARMOR) != 0) { ent.flags &= ~Defines.FL_POWER_ARMOR; GameBase.gi.sound(ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/power2.wav"), 1, Defines.ATTN_NORM, 0); } - else - { - index = GameUtil.ITEM_INDEX(GameUtil.FindItem("cells")); - if (0 == ent.client.pers.inventory[index]) - { + else { + index= GameUtil.ITEM_INDEX(GameUtil.FindItem("cells")); + if (0 == ent.client.pers.inventory[index]) { GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "No cells for power armor.\n"); return; } @@ -1126,25 +1004,22 @@ public class GameAIAdapters } } }; - public static ItemDropAdapter Drop_Ammo = new ItemDropAdapter() - { - public void drop(edict_t ent, gitem_t item) - { + public static ItemDropAdapter Drop_Ammo= new ItemDropAdapter() { + public void drop(edict_t ent, gitem_t item) { edict_t dropped; int index; - index = GameUtil.ITEM_INDEX(item); - dropped = GameUtil.Drop_Item(ent, item); + index= GameUtil.ITEM_INDEX(item); + dropped= GameUtil.Drop_Item(ent, item); if (ent.client.pers.inventory[index] >= item.quantity) - dropped.count = item.quantity; + dropped.count= item.quantity; else - dropped.count = ent.client.pers.inventory[index]; + dropped.count= ent.client.pers.inventory[index]; if (ent.client.pers.weapon != null && ent.client.pers.weapon.tag == Defines.AMMO_GRENADES && item.tag == Defines.AMMO_GRENADES - && ent.client.pers.inventory[index] - dropped.count <= 0) - { + && ent.client.pers.inventory[index] - dropped.count <= 0) { GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Can't drop current weapon\n"); GameUtil.G_FreeEdict(dropped); return; @@ -1154,25 +1029,21 @@ public class GameAIAdapters GameAI.ValidateSelectedItem(ent); } }; - public static ItemDropAdapter Drop_General = new ItemDropAdapter() - { - public void drop(edict_t ent, gitem_t item) - { + public static ItemDropAdapter Drop_General= new ItemDropAdapter() { + public void drop(edict_t ent, gitem_t item) { GameUtil.Drop_Item(ent, item); ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]--; GameAI.ValidateSelectedItem(ent); } }; - public static ItemDropAdapter Drop_PowerArmor = new ItemDropAdapter() - { - public void drop(edict_t ent, gitem_t item) - { + public static ItemDropAdapter Drop_PowerArmor= new ItemDropAdapter() { + public void drop(edict_t ent, gitem_t item) { if (0 != (ent.flags & Defines.FL_POWER_ARMOR) && (ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)] == 1)) Use_PowerArmor.use(ent, item); Drop_General.drop(ent, item); } }; - public static gitem_armor_t jacketarmor_info = new gitem_armor_t(25, 50, .30f, .00f, Defines.ARMOR_JACKET); - public static gitem_armor_t combatarmor_info = new gitem_armor_t(50, 100, .60f, .30f, Defines.ARMOR_COMBAT); - public static gitem_armor_t bodyarmor_info = new gitem_armor_t(100, 200, .80f, .60f, Defines.ARMOR_BODY); + public static gitem_armor_t jacketarmor_info= new gitem_armor_t(25, 50, .30f, .00f, Defines.ARMOR_JACKET); + public static gitem_armor_t combatarmor_info= new gitem_armor_t(50, 100, .60f, .30f, Defines.ARMOR_COMBAT); + public static gitem_armor_t bodyarmor_info= new gitem_armor_t(100, 200, .80f, .60f, Defines.ARMOR_BODY); } diff --git a/src/jake2/game/GameTriggerAdapters.java b/src/jake2/game/GameTriggerAdapters.java index 8d3622a..9fa331b 100644 --- a/src/jake2/game/GameTriggerAdapters.java +++ b/src/jake2/game/GameTriggerAdapters.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 26.02.2004 by RST. -// $Id: GameTriggerAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $ +// $Id: GameTriggerAdapters.java,v 1.2 2004-08-22 15:46:19 salomo Exp $ package jake2.game; @@ -114,7 +114,6 @@ public class GameTriggerAdapters { public void use(edict_t self, edict_t other, edict_t activator) { int index; - Com.p("trigger_key_use!"); if (self.item == null) return; if (activator.client == null) @@ -224,7 +223,6 @@ public class GameTriggerAdapters { public static int windsound; static EntTouchAdapter trigger_push_touch = new EntTouchAdapter() { public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { - Com.p("TRIGGER TOUCH!"); if (Lib.strcmp(other.classname, "grenade") == 0) { Math3D.VectorScale(self.movedir, self.speed * 10, other.velocity); } -- cgit v1.2.3 From b76459fa7321d18fedeab7cd891ce4e060b984d8 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Sun, 22 Aug 2004 18:30:15 +0000 Subject: fix comment handling in Parse() remove obsolete ServerState() --- src/jake2/qcommon/Com.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java index 3eb56d3..b7ae3b4 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.5 2004-07-28 11:54:43 hzi Exp $ + * $Id: Com.java,v 1.6 2004-08-22 18:30:15 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -205,7 +205,7 @@ public final class Com // skip // comments if (hlp.getchar() == '/') { if (hlp.nextchar() == '/') { - hlp.skipwhitestoeol(); + hlp.skiptoeol(); return ""; } else { hlp.prevchar(); @@ -431,11 +431,6 @@ public final class Com return msg; } - public static int ServerState() - { - return Globals.server_state; - } - public static int Argc() { return Com.com_argc; -- cgit v1.2.3 From 8cd699757e1ec61dd0ec85a0bf56bbdd4365cd51 Mon Sep 17 00:00:00 2001 From: Rene Stoeckel Date: Sun, 22 Aug 2004 20:39:03 +0000 Subject: bugfix in a touch call. the bug was in the original code as well !!! --- src/jake2/server/SV.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/server/SV.java b/src/jake2/server/SV.java index b8e8e7e..fa98f32 100644 --- a/src/jake2/server/SV.java +++ b/src/jake2/server/SV.java @@ -2,7 +2,7 @@ * SV.java * Copyright (C) 2003 * - * $Id: SV.java,v 1.7 2004-08-22 14:25:12 salomo Exp $ + * $Id: SV.java,v 1.8 2004-08-22 20:39:03 salomo Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -107,7 +107,6 @@ public final class SV public static void SV_Impact(edict_t e1, trace_t trace) { edict_t e2; - // cplane_t backplane; e2= trace.ent; @@ -115,7 +114,7 @@ public final class SV e1.touch.touch(e1, e2, trace.plane, trace.surface); if (e2.touch != null && e2.solid != Defines.SOLID_NOT) - e2.touch.touch(e2, e1, null, null); + e2.touch.touch(e2, e1, GameBase.dummyplane, null); } public static int SV_FlyMove(edict_t ent, float time, int mask) -- cgit v1.2.3 From eff7e24ea4852bfbc0492f88b52210fe4515fdbe Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Mon, 23 Aug 2004 20:49:12 +0000 Subject: - better vid mode selection when switching between window and fullscreen - new configurable window mode 11 vid_wdth x vid_height (CAVE!) --- src/jake2/client/VID.java | 41 ++++++++++++++++++++++++++++------------- src/jake2/render/JoglBase.java | 3 ++- 2 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java index 59c9252..b77128b 100644 --- a/src/jake2/client/VID.java +++ b/src/jake2/client/VID.java @@ -2,7 +2,7 @@ * VID.java * Copyright (C) 2003 * - * $Id: VID.java,v 1.8 2004-07-16 10:11:36 cawe Exp $ + * $Id: VID.java,v 1.9 2004-08-23 20:49:12 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -63,6 +63,8 @@ public class VID extends Globals { static cvar_t vid_ref; // Name of Refresh DLL loaded static cvar_t vid_xpos; // X coordinate of window position static cvar_t vid_ypos; // Y coordinate of window position + static cvar_t vid_width; + static cvar_t vid_height; static cvar_t vid_fullscreen; // Global variables used internally by this module @@ -101,15 +103,17 @@ public class VID extends Globals { cause the entire video mode and refresh DLL to be reset on the next frame. ============ */ - static void Restart_f() - { + static void Restart_f() { + vid_modes[11].width = (int) vid_width.value; + vid_modes[11].height = (int) vid_height.value; + vid_ref.modified = true; } /* ** VID_GetModeInfo */ - static final vidmode_t vid_modes[] = + static vidmode_t vid_modes[] = { new vidmode_t("Mode 0: 320x240", 320, 240, 0), new vidmode_t("Mode 1: 400x300", 400, 300, 1), @@ -121,7 +125,8 @@ public class VID extends Globals { new vidmode_t("Mode 7: 1152x864", 1152, 864, 7), new vidmode_t("Mode 8: 1280x1024", 1280, 1024, 8), new vidmode_t("Mode 9: 1600x1200", 1600, 1200, 9), - new vidmode_t("Mode 10: 2048x1536", 2048, 1536, 10)}; + new vidmode_t("Mode 10: 2048x1536", 2048, 1536, 10), + new vidmode_t("Mode 11: user", 640, 480, 11)}; static vidmode_t fs_modes[]; public static boolean GetModeInfo(Dimension dim, int mode) { @@ -130,11 +135,12 @@ public class VID extends Globals { vidmode_t[] modes = vid_modes; if (vid_fullscreen.value != 0.0f) modes = fs_modes; - if (mode < 0 || mode >= modes.length) + if (mode < 0 || mode >= modes.length) return false; - + dim.width = modes[mode].width; dim.height = modes[mode].height; + return true; } @@ -292,9 +298,14 @@ public class VID extends Globals { vid_ref = Cvar.Get("vid_ref", "fastjogl", CVAR_ARCHIVE); vid_xpos = Cvar.Get("vid_xpos", "3", CVAR_ARCHIVE); vid_ypos = Cvar.Get("vid_ypos", "22", CVAR_ARCHIVE); + vid_width = Cvar.Get("vid_width", "640", CVAR_ARCHIVE); + vid_height = Cvar.Get("vid_height", "480", CVAR_ARCHIVE); vid_fullscreen = Cvar.Get("vid_fullscreen", "0", CVAR_ARCHIVE); vid_gamma = Cvar.Get( "vid_gamma", "1", CVAR_ARCHIVE ); + vid_modes[11].width = (int)vid_width.value; + vid_modes[11].height = (int)vid_height.value; + /* Add some console commands that we want to handle */ Cmd.AddCommand ("vid_restart", new xcommand_t() { public void execute() { @@ -538,11 +549,11 @@ public class VID extends Globals { "[1280 1024]", "[1600 1200]", "[2048 1536]", + "user mode", null }; static String[] fs_resolutions; - static int last_fs; - static int last_win; + static int mode_x; static final String[] refs = { @@ -617,13 +628,13 @@ public class VID extends Globals { if (s_mode_list[OPENGL_MENU].curvalue >= fs_resolutions.length - 1) { s_mode_list[OPENGL_MENU].curvalue = 0; } - last_fs = s_mode_list[OPENGL_MENU].curvalue; + mode_x = fs_modes[s_mode_list[OPENGL_MENU].curvalue].width; } else { s_mode_list[OPENGL_MENU].itemnames = resolutions; if (s_mode_list[OPENGL_MENU].curvalue >= resolutions.length - 1) { s_mode_list[OPENGL_MENU].curvalue = 0; } - last_win = s_mode_list[OPENGL_MENU].curvalue; + mode_x = vid_modes[s_mode_list[OPENGL_MENU].curvalue].width; } if ( SCR.scr_viewsize == null ) @@ -727,10 +738,14 @@ public class VID extends Globals { int fs = ((Menu.menulist_s)o).curvalue; if (fs == 0) { s_mode_list[1].itemnames = resolutions; - s_mode_list[1].curvalue = last_win; + int i = vid_modes.length - 2; + while (i > 0 && vid_modes[i].width > mode_x) i--; + s_mode_list[1].curvalue = i; } else { s_mode_list[1].itemnames = fs_resolutions; - s_mode_list[1].curvalue = last_fs; + int i = fs_modes.length - 1; + while (i > 0 && fs_modes[i].width > mode_x) i--; + s_mode_list[1].curvalue = i; } } }; diff --git a/src/jake2/render/JoglBase.java b/src/jake2/render/JoglBase.java index f29b0d2..b0b3771 100644 --- a/src/jake2/render/JoglBase.java +++ b/src/jake2/render/JoglBase.java @@ -2,7 +2,7 @@ * JoglCommon.java * Copyright (C) 2004 * - * $Id: JoglBase.java,v 1.6 2004-08-19 20:49:56 hzi Exp $ + * $Id: JoglBase.java,v 1.7 2004-08-23 20:49:12 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -104,6 +104,7 @@ public abstract class JoglBase implements GLEventListener { if (m.getBitDepth() != oldDisplayMode.getBitDepth()) continue; if (m.getRefreshRate() > oldDisplayMode.getRefreshRate()) continue; + if (m.getHeight() < 240 || m.getWidth() < 320) continue; int j = 0; DisplayMode ml = null; -- cgit v1.2.3 From 609d48b41513fa442ca714c002b271cc18d1941c Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 27 Aug 2004 21:05:04 +0000 Subject: don't eat the whole cpu when not in game mode --- src/jake2/client/CL.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/jake2') diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java index 25d8ab6..2cb6128 100644 --- a/src/jake2/client/CL.java +++ b/src/jake2/client/CL.java @@ -2,7 +2,7 @@ * CL.java * Copyright (C) 2004 * - * $Id: CL.java,v 1.7 2004-08-18 20:27:35 hzi Exp $ + * $Id: CL.java,v 1.8 2004-08-27 21:05:04 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -1549,6 +1549,11 @@ public final class CL extends CL_pred { SCR.RunConsole(); cls.framecount++; + if (cls.state != ca_active || cls.key_dest != key_game) { + try { + Thread.sleep(20); + } catch (InterruptedException e) {} + } } // ============================================================================ -- cgit v1.2.3 From e2ed5030c0b03bee29a7f413c1581732333397b8 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 27 Aug 2004 21:07:01 +0000 Subject: draw help screen --- src/jake2/client/SCR.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java index da19b29..f92adcc 100644 --- a/src/jake2/client/SCR.java +++ b/src/jake2/client/SCR.java @@ -2,7 +2,7 @@ * SCR.java * Copyright (C) 2003 * - * $Id: SCR.java,v 1.6 2004-08-22 14:25:15 salomo Exp $ + * $Id: SCR.java,v 1.7 2004-08-27 21:07:01 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -785,9 +785,10 @@ public final class SCR extends Globals { for (int l= 0; l < string.length();) { // scan out one line of text from the string line= new StringBuffer(1024); - while (string.charAt(l) != '\n') + while (l < string.length() && string.charAt(l) != '\n') { line.append(string.charAt(l)); - l++; + l++; + } if (centerwidth != 0) x= margin + (centerwidth - line.length() * 8) / 2; @@ -1169,8 +1170,7 @@ public final class SCR extends Globals { static void DrawLayout() { if (cl.frame.playerstate.stats[STAT_LAYOUTS] != 0) - return; - SCR.ExecuteLayoutString(cl.layout); + SCR.ExecuteLayoutString(cl.layout); } // ======================================================= -- cgit v1.2.3 From 3e51f118a9c4d16cc56d69cff6fe3b7e29fe15b1 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 27 Aug 2004 21:57:48 +0000 Subject: strncpy(dest, src, size) !!! --- src/jake2/game/GameTargetAdapters.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/game/GameTargetAdapters.java b/src/jake2/game/GameTargetAdapters.java index 31c85a9..e02975f 100644 --- a/src/jake2/game/GameTargetAdapters.java +++ b/src/jake2/game/GameTargetAdapters.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 26.02.2004 by RST. -// $Id: GameTargetAdapters.java,v 1.1 2004-07-08 15:58:43 hzi Exp $ +// $Id: GameTargetAdapters.java,v 1.2 2004-08-27 21:57:48 hzi Exp $ package jake2.game; @@ -91,10 +91,10 @@ public class GameTargetAdapters { if ((ent.spawnflags & 1) != 0) //strncpy(game.helpmessage1, ent.message, sizeof(game.helpmessage2) - 1); - ent.message = GameBase.game.helpmessage1; + GameBase.game.helpmessage1 = ent.message; else //strncpy(game.helpmessage2, ent.message, sizeof(game.helpmessage1) - 1); - ent.message = GameBase.game.helpmessage2; + GameBase.game.helpmessage2 = ent.message; GameBase.game.helpchanged++; } -- cgit v1.2.3 From e3a8251d4ca02595f93579c907aec01e7c38ce95 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Fri, 27 Aug 2004 21:59:23 +0000 Subject: duplicate functions removed --- src/jake2/game/PlayerHud.java | 76 +------------------------------------------ 1 file changed, 1 insertion(+), 75 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/game/PlayerHud.java b/src/jake2/game/PlayerHud.java index 6226cca..17f73ce 100644 --- a/src/jake2/game/PlayerHud.java +++ b/src/jake2/game/PlayerHud.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 28.12.2003 by RST. -// $Id: PlayerHud.java,v 1.4 2004-07-20 16:14:37 cawe Exp $ +// $Id: PlayerHud.java,v 1.5 2004-08-27 21:59:23 hzi Exp $ package jake2.game; @@ -309,80 +309,6 @@ public class PlayerHud extends GameTarget { DeathmatchScoreboard(ent); } - /* - ================== - HelpComputer - - Draw help computer. - ================== - */ - public static void HelpComputer(edict_t ent) { - //char string[1024]; - String string; - - String sk; - - if (skill.value == 0) - sk = "easy"; - else if (skill.value == 1) - sk = "medium"; - else if (skill.value == 2) - sk = "hard"; - else - sk = "hard+"; - - // send the layout - - string = Com.sprintf("xv 32 yv 8 picn help " + // background - "xv 202 yv 12 string2 \"%s\" " + // skill - "xv 0 yv 24 cstring2 \"%s\" " + // level name - "xv 0 yv 54 cstring2 \"%s\" " + // help 1 - "xv 0 yv 110 cstring2 \"%s\" " + // help 2 - "xv 50 yv 164 string2 \" kills goals secrets\" " + "xv 50 yv 172 string2 \"%3i/%3i %i/%i %i/%i\" ", - new Vargs() - .add(sk) - .add(level.level_name) - .add(game.helpmessage1) - .add(game.helpmessage2) - .add(level.killed_monsters) - .add(level.total_monsters) - .add(level.found_goals) - .add(level.total_goals) - .add(level.found_secrets) - .add(level.total_secrets)); - - gi.WriteByte(svc_layout); - gi.WriteString(string); - gi.unicast(ent, true); - } - - /* - ================== - Cmd_Help_f - - Display the current help message - ================== - */ - public static void Cmd_Help_f(edict_t ent) { - // this is for backwards compatability - if (deathmatch.value != 0) { - Cmd_Score_f(ent); - return; - } - - ent.client.showinventory = false; - ent.client.showscores = false; - - if (ent.client.showhelp && (ent.client.pers.game_helpchanged == game.helpchanged)) { - ent.client.showhelp = false; - return; - } - - ent.client.showhelp = true; - ent.client.pers.helpchanged = 0; - HelpComputer(ent); - } - //======================================================================= /* -- cgit v1.2.3 From d2b627476c8ac56ebe5baf95211eac791605c94f Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Sat, 28 Aug 2004 16:40:12 +0000 Subject: layout string for the helpcomputer is now correct --- src/jake2/game/GameAI.java | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/game/GameAI.java b/src/jake2/game/GameAI.java index ae33926..fa2cdbd 100644 --- a/src/jake2/game/GameAI.java +++ b/src/jake2/game/GameAI.java @@ -19,14 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 02.11.2003 by RST. -// $Id: GameAI.java,v 1.2 2004-07-08 15:58:44 hzi Exp $ +// $Id: GameAI.java,v 1.3 2004-08-28 16:40:12 cawe Exp $ package jake2.game; import jake2.Defines; import jake2.client.M; +import jake2.qcommon.Com; import jake2.util.Lib; import jake2.util.Math3D; +import jake2.util.Vargs; import java.util.StringTokenizer; @@ -1518,7 +1520,7 @@ public class GameAI extends M_Flash */ public static void HelpComputer(edict_t ent) { - String string; + StringBuffer sb = new StringBuffer(256); String sk; if (skill.value == 0) @@ -1531,28 +1533,25 @@ public class GameAI extends M_Flash sk = "hard+"; // send the layout - string = "xv 32 yv 8 picn help " + // background - "xv 202 yv 12 string2 \"" + sk + "\" " + // skill - "xv 0 yv 24 cstring2 \"" + level.level_name + "\" " + // level name - "xv 0 yv 54 cstring2 \"" + game.helpmessage1 + "\" " + // help 1 - "xv 0 yv 110 cstring2 \"" + game.helpmessage2 + "\" " + // help 2 - "xv 50 yv 164 string2 \" kills goals secrets\" " - + "xv 50 yv 172 string2 \"" - + level.killed_monsters - + "/" - + level.total_monsters - + " " - + level.found_goals - + "/" - + level.total_goals - + " " - + level.found_secrets - + "/" - + level.total_secrets - + "\" "; + sb.append("xv 32 yv 8 picn help "); // background + sb.append("xv 202 yv 12 string2 \"").append(sk).append("\" "); // skill + sb.append("xv 0 yv 24 cstring2 \"").append(level.level_name).append("\" "); // level name + sb.append("xv 0 yv 54 cstring2 \"").append(game.helpmessage1).append("\" "); // help 1 + sb.append("xv 0 yv 110 cstring2 \"").append(game.helpmessage2).append("\" "); // help 2 + sb.append("xv 50 yv 164 string2 \" kills goals secrets\" "); + sb.append("xv 50 yv 172 string2 \""); + sb.append(Com.sprintf("%3i/%3i %i/%i %i/%i\" ", + new Vargs(6).add(level.killed_monsters) + .add(level.total_monsters) + .add(level.found_goals) + .add(level.total_goals) + .add(level.found_secrets) + .add(level.total_secrets) + ) + ); gi.WriteByte(svc_layout); - gi.WriteString(string); + gi.WriteString(sb.toString()); gi.unicast(ent, true); } -- cgit v1.2.3 From 3721d58bf33af4a83cf973590d922eadf85d71d4 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Sun, 29 Aug 2004 19:27:37 +0000 Subject: fix linebreak handling in entity strings --- src/jake2/game/GameSpawn.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/game/GameSpawn.java b/src/jake2/game/GameSpawn.java index 7dc4934..c87c330 100644 --- a/src/jake2/game/GameSpawn.java +++ b/src/jake2/game/GameSpawn.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.11.2003 by RST. -// $Id: GameSpawn.java,v 1.4 2004-07-23 10:07:14 hzi Exp $ +// $Id: GameSpawn.java,v 1.5 2004-08-29 19:27:37 hzi Exp $ package jake2.game; @@ -127,20 +127,13 @@ public class GameSpawn extends GameSave { */ static String ED_NewString(String string) { - //String newb, new_p; - int i, l; - - l = string.length() + 1; - //newb = gi.TagMalloc(l, TAG_LEVEL); - + int l = string.length(); StringBuffer newb = new StringBuffer(l); - for (i = 0; i < l - 1; i++) { - char c; - - c = string.charAt(i); + for (int i = 0; i < l; i++) { + char c = string.charAt(i); if (c == '\\' && i < l - 1) { - c = string.charAt(i++); + c = string.charAt(++i); if (c == 'n') newb.append('\n'); else -- cgit v1.2.3 From c7adb77c3b6aec488a0328dc6c2cead172589f76 Mon Sep 17 00:00:00 2001 From: Holger Zickner Date: Sun, 29 Aug 2004 21:39:26 +0000 Subject: remove game_export_t and other dll related stuff --- src/jake2/game/GameBase.java | 34 +++------ src/jake2/game/GameSave.java | 37 ++++------ src/jake2/game/GameSpawn.java | 8 +-- src/jake2/game/GameTargetAdapters.java | 11 ++- src/jake2/game/GameUtil.java | 12 ++-- src/jake2/game/game_export_t.java | 124 --------------------------------- src/jake2/server/SV.java | 4 +- src/jake2/server/SV_CCMDS.java | 17 ++--- src/jake2/server/SV_ENTS.java | 12 ++-- src/jake2/server/SV_GAME.java | 25 ++----- src/jake2/server/SV_INIT.java | 16 ++--- src/jake2/server/SV_MAIN.java | 16 ++--- src/jake2/server/SV_USER.java | 10 +-- src/jake2/server/SV_WORLD.java | 16 ++--- src/jake2/sys/Sys.java | 11 +-- 15 files changed, 81 insertions(+), 272 deletions(-) delete mode 100644 src/jake2/game/game_export_t.java (limited to 'src/jake2') diff --git a/src/jake2/game/GameBase.java b/src/jake2/game/GameBase.java index cdec20b..323f6c8 100644 --- a/src/jake2/game/GameBase.java +++ b/src/jake2/game/GameBase.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 30.11.2003 by RST. -// $Id: GameBase.java,v 1.5 2004-08-22 14:25:11 salomo Exp $ +// $Id: GameBase.java,v 1.6 2004-08-29 21:39:24 hzi Exp $ /** Father of all GameObjects. */ @@ -38,12 +38,12 @@ public class GameBase extends Globals { public static game_locals_t game= new game_locals_t(); public static level_locals_t level= new level_locals_t(); public static game_import_t gi= new game_import_t(); - public static game_export_t globals= new game_export_t(); public static spawn_temp_t st= new spawn_temp_t(); public static int sm_meat_index; public static int snd_fry; public static int meansOfDeath; + public static int num_edicts; public static edict_t g_edicts[]= new edict_t[MAX_EDICTS]; static { @@ -156,7 +156,7 @@ public class GameBase extends Globals { else from.i++; - for (; from.i < globals.num_edicts; from.i++) { + for (; from.i < num_edicts; from.i++) { from.o= g_edicts[from.i]; if (from.o.classname == null) { Com.Printf("edict with classname = null" + from.o.index); @@ -193,7 +193,7 @@ public class GameBase extends Globals { else from.i++; - for (; from.i < globals.num_edicts; from.i++) { + for (; from.i < num_edicts; from.i++) { from.o= g_edicts[from.i]; if (!from.o.inuse) continue; @@ -375,21 +375,6 @@ public class GameBase extends Globals { ================ */ public static int DI_NODIR= -1; - public static void assert1(boolean cond) { - if (!cond) { - - try { - - int a[]= null; - int b= a[0]; - } - catch (Exception e) { - System.err.println("assertion failed!"); - e.printStackTrace(); - } - - } - } public static void ClearBounds(float[] mins, float[] maxs) { mins[0]= mins[1]= mins[2]= 99999; @@ -427,9 +412,6 @@ public class GameBase extends Globals { public static void ShutdownGame() { gi.dprintf("==== ShutdownGame ====\n"); - - //gi.FreeTags (TAG_LEVEL); - //gi.FreeTags (TAG_GAME); } //====================================================================== @@ -654,7 +636,7 @@ public class GameBase extends Globals { // even the world gets a chance to think // - for (i= 0; i < globals.num_edicts; i++) { + for (i= 0; i < num_edicts; i++) { ent= g_edicts[i]; if (!ent.inuse) continue; @@ -698,7 +680,7 @@ public class GameBase extends Globals { ================= */ - public static game_export_t GetGameApi(game_import_t imp) { + public static void GetGameApi(game_import_t imp) { gi= imp; gi.pointcontents= new pmove_t.PointContentsAdapter() { @@ -707,7 +689,7 @@ public class GameBase extends Globals { } }; - globals.apiversion= GAME_API_VERSION; + //globals.apiversion= GAME_API_VERSION; /* globals.Init = InitGame; globals.Shutdown = ShutdownGame; @@ -728,6 +710,6 @@ public class GameBase extends Globals { globals.ServerCommand = ServerCommand; */ - return globals; + //return globals; } } \ No newline at end of file diff --git a/src/jake2/game/GameSave.java b/src/jake2/game/GameSave.java index 7db262e..90d9619 100644 --- a/src/jake2/game/GameSave.java +++ b/src/jake2/game/GameSave.java @@ -19,21 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 29.12.2003 by RST. -// $Id: GameSave.java,v 1.3 2004-08-22 14:25:12 salomo Exp $ +// $Id: GameSave.java,v 1.4 2004-08-29 21:39:24 hzi Exp $ package jake2.game; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.*; - -import jake2.*; -import jake2.client.*; -import jake2.qcommon.*; -import jake2.render.*; -import jake2.server.*; -import jake2.util.*; +import jake2.qcommon.Com; +import jake2.util.QuakeFile; public class GameSave extends GameFunc { @@ -57,7 +48,7 @@ public class GameSave extends GameFunc { g_edicts= new edict_t[game.maxentities]; for (int i= 0; i < game.maxentities; i++) g_edicts[i]= new edict_t(i); - SV_GAME.ge.edicts= g_edicts; + GameBase.g_edicts= g_edicts; } public static void CreateClients() { @@ -139,15 +130,15 @@ public class GameSave extends GameFunc { game.maxentities= (int) maxentities.value; CreateEdicts(); - globals.edicts= g_edicts; - globals.max_edicts= game.maxentities; +// globals.edicts= g_edicts; +// globals.max_edicts= game.maxentities; // initialize all clients for this game game.maxclients= (int) maxclients.value; CreateClients(); - globals.num_edicts= game.maxclients + 1; + num_edicts= game.maxclients + 1; } /* @@ -221,7 +212,7 @@ public class GameSave extends GameFunc { ================= */ - static void WriteLevel(String filename) { + public static void WriteLevel(String filename) { try { int i; edict_t ent; @@ -235,7 +226,7 @@ public class GameSave extends GameFunc { level.write(f); // write out all the entities - for (i= 0; i < globals.num_edicts; i++) { + for (i= 0; i < num_edicts; i++) { ent= g_edicts[i]; if (!ent.inuse) continue; @@ -270,7 +261,7 @@ public class GameSave extends GameFunc { No clients are connected yet. ================= */ - static void ReadLevel(String filename) { + public static void ReadLevel(String filename) { try { edict_t ent; @@ -282,7 +273,7 @@ public class GameSave extends GameFunc { // wipe all the entities Game.CreateEdicts(); - globals.num_edicts= (int) maxclients.value + 1; + num_edicts= (int) maxclients.value + 1; // load the level locals level.read(f); @@ -293,8 +284,8 @@ public class GameSave extends GameFunc { if (entnum == -1) break; - if (entnum >= globals.num_edicts) - globals.num_edicts= entnum + 1; + if (entnum >= num_edicts) + num_edicts= entnum + 1; ent= g_edicts[entnum]; System.out.println("readint ent" + entnum); @@ -313,7 +304,7 @@ public class GameSave extends GameFunc { } // do any load time things at this point - for (int i= 0; i < globals.num_edicts; i++) { + for (int i= 0; i < num_edicts; i++) { ent= g_edicts[i]; if (!ent.inuse) diff --git a/src/jake2/game/GameSpawn.java b/src/jake2/game/GameSpawn.java index c87c330..c93ebc0 100644 --- a/src/jake2/game/GameSpawn.java +++ b/src/jake2/game/GameSpawn.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.11.2003 by RST. -// $Id: GameSpawn.java,v 1.5 2004-08-29 19:27:37 hzi Exp $ +// $Id: GameSpawn.java,v 1.6 2004-08-29 21:39:24 hzi Exp $ package jake2.game; @@ -284,7 +284,7 @@ public class GameSpawn extends GameSave { int c, c2; c = 0; c2 = 0; - for (i = 1; i < globals.num_edicts; i++) { + for (i = 1; i < num_edicts; i++) { e = g_edicts[i]; if (!e.inuse) @@ -298,7 +298,7 @@ public class GameSpawn extends GameSave { c++; c2++; //Com.Printf("Team:" + e.team+" entity: " + e.index + "\n"); - for (j = i + 1; j < globals.num_edicts; j++) { + for (j = i + 1; j < num_edicts; j++) { e2 = g_edicts[j]; if (!e2.inuse) continue; @@ -328,7 +328,7 @@ public class GameSpawn extends GameSave { ============== */ - static void SpawnEntities(String mapname, String entities, String spawnpoint) { + public static void SpawnEntities(String mapname, String entities, String spawnpoint) { edict_t ent; int inhibit; String com_token; diff --git a/src/jake2/game/GameTargetAdapters.java b/src/jake2/game/GameTargetAdapters.java index e02975f..19a48c9 100644 --- a/src/jake2/game/GameTargetAdapters.java +++ b/src/jake2/game/GameTargetAdapters.java @@ -19,15 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 26.02.2004 by RST. -// $Id: GameTargetAdapters.java,v 1.2 2004-08-27 21:57:48 hzi Exp $ +// $Id: GameTargetAdapters.java,v 1.3 2004-08-29 21:39:24 hzi Exp $ package jake2.game; -import jake2.*; -import jake2.client.*; -import jake2.qcommon.*; -import jake2.render.*; -import jake2.server.*; +import jake2.Defines; +import jake2.Globals; import jake2.util.Lib; import jake2.util.Math3D; @@ -553,7 +550,7 @@ public class GameTargetAdapters { self.last_move_time = GameBase.level.time + 0.5f; } - for (i = 1; i < GameBase.globals.num_edicts; i++) { + for (i = 1; i < GameBase.num_edicts; i++) { e = GameBase.g_edicts[i]; if (!e.inuse) diff --git a/src/jake2/game/GameUtil.java b/src/jake2/game/GameUtil.java index 5769564..765659d 100644 --- a/src/jake2/game/GameUtil.java +++ b/src/jake2/game/GameUtil.java @@ -19,16 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 01.11.2003 by RST. -// $Id: GameUtil.java,v 1.4 2004-08-20 21:29:57 salomo Exp $ +// $Id: GameUtil.java,v 1.5 2004-08-29 21:39:24 hzi Exp $ package jake2.game; -import java.sql.Savepoint; - -import jake2.Defines; import jake2.client.M; import jake2.qcommon.Com; -import jake2.util.*; +import jake2.util.Lib; +import jake2.util.Math3D; public class GameUtil extends GameBase { @@ -165,7 +163,7 @@ public class GameUtil extends GameBase int i; edict_t e = null; - for (i = (int) maxclients.value + 1; i < globals.num_edicts; i++) + for (i = (int) maxclients.value + 1; i < num_edicts; i++) { e = g_edicts[i]; // the first couple seconds of server time can involve a lot of @@ -182,7 +180,7 @@ public class GameUtil extends GameBase gi.error("ED_Alloc: no free edicts"); e = g_edicts[i] = new edict_t(i); - globals.num_edicts++; + num_edicts++; G_InitEdict(e, i); return e; } diff --git a/src/jake2/game/game_export_t.java b/src/jake2/game/game_export_t.java deleted file mode 100644 index cfc0610..0000000 --- a/src/jake2/game/game_export_t.java +++ /dev/null @@ -1,124 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Created on 31.10.2003 by RST. -// $Id: game_export_t.java,v 1.5 2004-08-22 14:25:11 salomo Exp $ - -package jake2.game; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; - -import jake2.qcommon.Com; -import jake2.util.QuakeFile; - -// -//functions exported by the game subsystem -// - -public class game_export_t { - - public int apiversion; - - // the init function will only be called when a game starts, - // not each time a level is loaded. Persistant data for clients - // and the server can be allocated in init - public void Init() { - Game.InitGame(); - } - public void Shutdown() { - Game.ShutdownGame(); - } - - // each new level entered will cause a call to SpawnEntities - public void SpawnEntities(String mapname, String entstring, String spawnpoint) { - Game.SpawnEntities(mapname, entstring, spawnpoint); - } - - // Read/Write Game is for storing persistant cross level information - // about the world state and the clients. - // WriteGame is called every time a level is exited. - // ReadGame is called on a loadgame. - public void WriteGame(String filename, boolean autosave) { - GameSave.WriteGame(filename, autosave); - } - - public void ReadGame(String filename) { - Game.ReadGame(filename); - } - - // ReadLevel is called after the default map information has been - // loaded with SpawnEntities - public void WriteLevel(String filename) { - GameSave.WriteLevel(filename); - } - - public void ReadLevel(String filename) { - GameSave.ReadLevel(filename); - } - - public boolean ClientConnect(edict_t ent, String userinfo) { - return PlayerClient.ClientConnect(ent, userinfo); - } - - public void ClientBegin(edict_t ent) { - PlayerClient.ClientBegin(ent); - } - - public void ClientUserinfoChanged(edict_t ent, String userinfo) { - PlayerClient.ClientUserinfoChanged(ent, userinfo); - } - - public void ClientDisconnect(edict_t ent) { - PlayerClient.ClientDisconnect(ent); - } - public void ClientCommand(edict_t ent) { - PlayerClient.ClientCommand(ent); - } - - public void ClientThink(edict_t ent, usercmd_t cmd) { - PlayerClient.ClientThink(ent, cmd); - } - - public void RunFrame() { - Game.G_RunFrame(); - } - - // ServerCommand will be called when an "sv " command is issued on the - // server console. - // the game can issue gi.argc() / gi.argv() commands to get the rest - // of the parameters - public void ServerCommand() { - Game.ServerCommand(); - } - - // - // global variables shared between game and server - // - - // the edict array is allocated in the game dll so it - // can vary in size from one game to another. - - // the size will be fixed when ge.Init() is called - public edict_t edicts[]= Game.g_edicts; - public int num_edicts; // current number, <= max_edicts - public int max_edicts; -} diff --git a/src/jake2/server/SV.java b/src/jake2/server/SV.java index fa98f32..701f767 100644 --- a/src/jake2/server/SV.java +++ b/src/jake2/server/SV.java @@ -2,7 +2,7 @@ * SV.java * Copyright (C) 2003 * - * $Id: SV.java,v 1.8 2004-08-22 20:39:03 salomo Exp $ + * $Id: SV.java,v 1.9 2004-08-29 21:39:25 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -378,7 +378,7 @@ public final class SV // see if any solid entities are inside the final position //check= g_edicts + 1; - for (e= 1; e < GameBase.globals.num_edicts; e++) + for (e= 1; e < GameBase.num_edicts; e++) { check= GameBase.g_edicts[e]; if (!check.inuse) diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java index 8ab3e72..757fb0e 100644 --- a/src/jake2/server/SV_CCMDS.java +++ b/src/jake2/server/SV_CCMDS.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.01.2004 by RST. -// $Id: SV_CCMDS.java,v 1.7 2004-08-22 14:25:12 salomo Exp $ +// $Id: SV_CCMDS.java,v 1.8 2004-08-29 21:39:25 hzi Exp $ package jake2.server; @@ -28,7 +28,6 @@ import jake2.game.*; import jake2.qcommon.*; import jake2.sys.NET; import jake2.sys.Sys; -import jake2.util.Lib; import jake2.util.QuakeFile; import jake2.util.Vargs; @@ -353,7 +352,7 @@ public class SV_CCMDS extends SV_ENTS { } name= FS.Gamedir() + "/save/current/" + sv.name + ".sav"; - ge.WriteLevel(name); + GameSave.WriteLevel(name); } /* @@ -386,7 +385,7 @@ public class SV_CCMDS extends SV_ENTS { } name= FS.Gamedir() + "/save/current/" + sv.name + ".sav"; - ge.ReadLevel(name); + GameSave.ReadLevel(name); System.out.println("all done!"); } @@ -457,7 +456,7 @@ public class SV_CCMDS extends SV_ENTS { // write game state filename= FS.Gamedir() + "/save/current/game.ssv"; - ge.WriteGame(filename, autosave); + GameSave.WriteGame(filename, autosave); } /* @@ -508,7 +507,7 @@ public class SV_CCMDS extends SV_ENTS { // read game state filename= FS.Gamedir() + "/save/current/game.ssv"; - ge.ReadGame(filename); + GameSave.ReadGame(filename); } catch (Exception e) { Com.Printf("Couldn't read file " + name + "\n"); @@ -1055,12 +1054,8 @@ public class SV_CCMDS extends SV_ENTS { =============== */ public static void SV_ServerCommand_f() { - if (SV_GAME.ge == null) { - Com.Printf("No game loaded.\n"); - return; - } - SV_GAME.ge.ServerCommand(); + Game.ServerCommand(); } //=========================================================== diff --git a/src/jake2/server/SV_ENTS.java b/src/jake2/server/SV_ENTS.java index e3a5a2c..8b3db67 100644 --- a/src/jake2/server/SV_ENTS.java +++ b/src/jake2/server/SV_ENTS.java @@ -19,7 +19,7 @@ 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.3 2004-07-12 20:47:02 hzi Exp $ +// $Id: SV_ENTS.java,v 1.4 2004-08-29 21:39:25 hzi Exp $ package jake2.server; @@ -456,8 +456,8 @@ public class SV_ENTS extends SV_USER { c_fullsend = 0; - for (e = 1; e < SV_GAME.ge.num_edicts; e++) { - ent = SV_GAME.ge.edicts[e]; + for (e = 1; e < GameBase.num_edicts; e++) { + ent = GameBase.g_edicts[e]; // ignore ents without visible models if ((ent.svflags & SVF_NOCLIENT) != 0) @@ -567,9 +567,9 @@ public class SV_ENTS extends SV_USER { MSG.WriteByte(buf, svc_packetentities); e = 1; - ent = SV_GAME.ge.edicts[e]; + ent = GameBase.g_edicts[e]; - while (e < SV_GAME.ge.num_edicts) { + while (e < GameBase.num_edicts) { // ignore ents without visible models unless they have an effect if (ent.inuse && ent.s.number != 0 @@ -578,7 +578,7 @@ public class SV_ENTS extends SV_USER { MSG.WriteDeltaEntity(nostate, ent.s, buf, false, true); e++; - ent = SV_GAME.ge.edicts[e]; + ent = GameBase.g_edicts[e]; } MSG.WriteShort(buf, 0); // end of packetentities diff --git a/src/jake2/server/SV_GAME.java b/src/jake2/server/SV_GAME.java index 0dc5a8b..844aacb 100644 --- a/src/jake2/server/SV_GAME.java +++ b/src/jake2/server/SV_GAME.java @@ -19,20 +19,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 14.01.2004 by RST. -// $Id: SV_GAME.java,v 1.6 2004-08-22 14:25:12 salomo Exp $ +// $Id: SV_GAME.java,v 1.7 2004-08-29 21:39:25 hzi Exp $ package jake2.server; -import jake2.*; -import jake2.client.*; import jake2.game.*; import jake2.qcommon.*; -import jake2.render.*; -import jake2.sys.Sys; public class SV_GAME extends SV_INIT { - public static game_export_t ge; /* =============== @@ -297,11 +292,7 @@ public class SV_GAME extends SV_INIT { =============== */ public static void SV_ShutdownGameProgs() { - if (ge == null) - return; - ge.Shutdown(); - Sys.UnloadGame(); - ge = null; + Game.ShutdownGame(); } /* @@ -315,19 +306,13 @@ public class SV_GAME extends SV_INIT { public static void SV_InitGameProgs() { // unload anything we have now - if (ge != null) - SV_ShutdownGameProgs(); + SV_ShutdownGameProgs(); game_import_t gimport = new game_import_t(); // all functions set in game_export_t (rst) - ge = GameBase.GetGameApi(gimport); - - if (ge == null) - Com.Error(ERR_DROP, "failed to load game DLL"); - if (ge.apiversion != GAME_API_VERSION) - Com.Error(ERR_DROP, "game is version " + ge.apiversion + " not " + GAME_API_VERSION); + GameBase.GetGameApi(gimport); - ge.Init(); + Game.InitGame(); } } diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java index c036d50..2325f22 100644 --- a/src/jake2/server/SV_INIT.java +++ b/src/jake2/server/SV_INIT.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 14.01.2004 by RST. -// $Id: SV_INIT.java,v 1.7 2004-08-22 14:25:13 salomo Exp $ +// $Id: SV_INIT.java,v 1.8 2004-08-29 21:39:25 hzi Exp $ package jake2.server; @@ -99,9 +99,9 @@ public class SV_INIT extends Globals { edict_t svent; int entnum; - for (entnum= 1; entnum < SV_GAME.ge.num_edicts; entnum++) { + for (entnum= 1; entnum < GameBase.num_edicts; entnum++) { //svent = EDICT_NUM(entnum); - svent= SV_GAME.ge.edicts[entnum]; + svent= GameBase.g_edicts[entnum]; if (!svent.inuse) continue; @@ -168,7 +168,7 @@ public class SV_INIT extends Globals { previousState= sv.state; // PGM sv.state= ss_loading; // PGM for (i= 0; i < 100; i++) - SV_GAME.ge.RunFrame(); + Game.G_RunFrame(); sv.state= previousState; // PGM } @@ -278,11 +278,11 @@ public class SV_INIT extends Globals { Globals.server_state= sv.state; // load and spawn all other entities - SV_GAME.ge.SpawnEntities(sv.name, CM.CM_EntityString(), spawnpoint); + Game.SpawnEntities(sv.name, CM.CM_EntityString(), spawnpoint); // run two frames to allow everything to settle - SV_GAME.ge.RunFrame(); - SV_GAME.ge.RunFrame(); + Game.G_RunFrame(); + Game.G_RunFrame(); // all precaches are complete sv.state= serverstate; @@ -382,7 +382,7 @@ public class SV_INIT extends Globals { SV_GAME.SV_InitGameProgs(); // bis hier alles ok! for (i= 0; i < SV_MAIN.maxclients.value; i++) { - ent= SV_GAME.ge.edicts[i + 1]; + ent= GameBase.g_edicts[i + 1]; //ent.s.number = i + 1; //dont need this, ent.s.number already set. svs.clients[i].edict= ent; diff --git a/src/jake2/server/SV_MAIN.java b/src/jake2/server/SV_MAIN.java index 99b74e9..7beff4e 100644 --- a/src/jake2/server/SV_MAIN.java +++ b/src/jake2/server/SV_MAIN.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 13.01.2004 by RST. -// $Id: SV_MAIN.java,v 1.5 2004-07-30 06:07:23 hzi Exp $ +// $Id: SV_MAIN.java,v 1.6 2004-08-29 21:39:25 hzi Exp $ package jake2.server; @@ -89,7 +89,7 @@ public class SV_MAIN extends SV_GAME { if (drop.state == Defines.cs_spawned) { // call the prog function for removing a client // this will remove the body, among other things - SV_GAME.ge.ClientDisconnect(drop.edict); + PlayerClient.ClientDisconnect(drop.edict); } if (drop.download != null) { @@ -363,12 +363,12 @@ public class SV_MAIN extends SV_GAME { sv_client = svs.clients[i]; //edictnum = (newcl-svs.clients)+1; int edictnum = i + 1; - edict_t ent = ge.edicts[edictnum]; + edict_t ent = GameBase.g_edicts[edictnum]; svs.clients[i].edict = ent; svs.clients[i].challenge = challenge; // save challenge for checksumming // get the game a chance to reject this connection or modify the userinfo - if (!(ge.ClientConnect(ent, userinfo))) { + if (!(PlayerClient.ClientConnect(ent, userinfo))) { if (Info.Info_ValueForKey(userinfo, "rejmsg") != null) Netchan.OutOfBandPrint( NS_SERVER, @@ -670,8 +670,8 @@ public class SV_MAIN extends SV_GAME { edict_t ent; int i; - for (i = 0; i < ge.num_edicts; i++) { - ent = SV_GAME.ge.edicts[i]; + for (i = 0; i < GameBase.num_edicts; i++) { + ent = GameBase.g_edicts[i]; // events only last for a single message ent.s.event = 0; } @@ -696,7 +696,7 @@ public class SV_MAIN extends SV_GAME { // don't run if paused if (0 == sv_paused.value || maxclients.value > 1) { - ge.RunFrame(); + Game.G_RunFrame(); // never get more than one tic behind if (sv.time < svs.realtime) { @@ -862,7 +862,7 @@ public class SV_MAIN extends SV_GAME { int i; // call prog code to allow overrides - SV_GAME.ge.ClientUserinfoChanged(cl.edict, cl.userinfo); + PlayerClient.ClientUserinfoChanged(cl.edict, cl.userinfo); // name for C code cl.name = Info.Info_ValueForKey(cl.userinfo, "name"); diff --git a/src/jake2/server/SV_USER.java b/src/jake2/server/SV_USER.java index 65e5262..5a31de8 100644 --- a/src/jake2/server/SV_USER.java +++ b/src/jake2/server/SV_USER.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 17.01.2004 by RST. -// $Id: SV_USER.java,v 1.4 2004-07-09 06:50:49 hzi Exp $ +// $Id: SV_USER.java,v 1.5 2004-08-29 21:39:25 hzi Exp $ package jake2.server; @@ -124,7 +124,7 @@ public class SV_USER extends SV_SEND if (sv.state == ss_game) { // set up the entity for the client - ent= SV_GAME.ge.edicts[playernum + 1]; + ent= GameBase.g_edicts[playernum + 1]; ent.s.number= playernum + 1; sv_client.edict= ent; sv_client.lastcmd= new usercmd_t(); @@ -269,7 +269,7 @@ public class SV_USER extends SV_SEND sv_client.state= cs_spawned; // call the game begin function - SV_GAME.ge.ClientBegin(sv_player); + PlayerClient.ClientBegin(sv_player); Cbuf.InsertFromDefer(); } @@ -552,7 +552,7 @@ public class SV_USER extends SV_SEND } if (i == ucmds.length && sv.state == ss_game) - SV_GAME.ge.ClientCommand(sv_player); + PlayerClient.ClientCommand(sv_player); // SV_EndRedirect (); } @@ -575,7 +575,7 @@ public class SV_USER extends SV_SEND return; } - SV_GAME.ge.ClientThink(cl.edict, cmd); + PlayerClient.ClientThink(cl.edict, cmd); } public static final int MAX_STRINGCMDS= 8; diff --git a/src/jake2/server/SV_WORLD.java b/src/jake2/server/SV_WORLD.java index cb74e95..46caf89 100644 --- a/src/jake2/server/SV_WORLD.java +++ b/src/jake2/server/SV_WORLD.java @@ -19,19 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 07.01.2000 by RST. -// $Id: SV_WORLD.java,v 1.5 2004-08-20 21:29:57 salomo Exp $ +// $Id: SV_WORLD.java,v 1.6 2004-08-29 21:39:25 hzi Exp $ package jake2.server; -import jake2.game.edict_t; -import jake2.game.trace_t; - -import jake2.*; -import jake2.client.*; import jake2.game.*; -import jake2.qcommon.*; -import jake2.render.*; -import jake2.util.Vargs; +import jake2.qcommon.CM; +import jake2.qcommon.Com; public class SV_WORLD extends SV_CCMDS { @@ -202,7 +196,7 @@ public class SV_WORLD extends SV_CCMDS if (ent.area.prev != null) SV_UnlinkEdict(ent); // unlink from old position - if (ent == ge.edicts[0]) + if (ent == GameBase.g_edicts[0]) return; // don't add the world if (!ent.inuse) @@ -663,7 +657,7 @@ public class SV_WORLD extends SV_CCMDS // clip to world clip.trace= CM.BoxTrace(start, end, mins, maxs, 0, contentmask); - clip.trace.ent= ge.edicts[0]; + clip.trace.ent= GameBase.g_edicts[0]; if (clip.trace.fraction == 0) return clip.trace; // blocked by the world diff --git a/src/jake2/sys/Sys.java b/src/jake2/sys/Sys.java index cd09fd6..cf8e154 100644 --- a/src/jake2/sys/Sys.java +++ b/src/jake2/sys/Sys.java @@ -2,7 +2,7 @@ * Sys.java * Copyright (C) 2003 * - * $Id: Sys.java,v 1.6 2004-07-28 11:59:32 hzi Exp $ + * $Id: Sys.java,v 1.7 2004-08-29 21:39:26 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -29,7 +29,6 @@ import jake2.Defines; import jake2.Globals; import jake2.client.CL; import jake2.qcommon.Com; -import jake2.util.Lib; import java.io.File; import java.io.FilenameFilter; @@ -226,14 +225,6 @@ public final class Sys extends Defines { fdir = null; } - - - public static void UnloadGame() - { - //TODO:implement UnloadGame - //Com.Error(Defines.ERR_FATAL, "UnloadGame not implemented!"); - - } public static void SendKeyEvents() { KBD.Update(); -- cgit v1.2.3 From 5d8858f709418697651bc4211002a152dc0aceab Mon Sep 17 00:00:00 2001 From: Rene Stoeckel Date: Sat, 4 Sep 2004 09:01:01 +0000 Subject: debug messages clean up, shotgun switched back to blaster. --- src/jake2/game/PlayerClient.java | 7 ++++--- src/jake2/game/SuperAdapter.java | 13 ++++++------- src/jake2/server/SV_CCMDS.java | 5 ++--- 3 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/game/PlayerClient.java b/src/jake2/game/PlayerClient.java index 3bb09f0..980f0cb 100644 --- a/src/jake2/game/PlayerClient.java +++ b/src/jake2/game/PlayerClient.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 28.12.2003 by RST. -// $Id: PlayerClient.java,v 1.4 2004-08-20 21:29:58 salomo Exp $ +// $Id: PlayerClient.java,v 1.5 2004-09-04 09:01:01 salomo Exp $ package jake2.game; @@ -304,17 +304,18 @@ public class PlayerClient extends PlayerHud { public static void InitClientPersistant(gclient_t client) { gitem_t item; - //memset(& client.pers, 0, sizeof(client.pers)); client.pers = new client_persistant_t(); item = FindItem("Blaster"); client.pers.selected_item = ITEM_INDEX(item); client.pers.inventory[client.pers.selected_item] = 1; + /* Give shotgun. item = FindItem("Shotgun"); client.pers.selected_item = ITEM_INDEX(item); client.pers.inventory[client.pers.selected_item] = 1; - + */ + client.pers.weapon = item; client.pers.health = 100; diff --git a/src/jake2/game/SuperAdapter.java b/src/jake2/game/SuperAdapter.java index 29dcfb5..fd7e216 100644 --- a/src/jake2/game/SuperAdapter.java +++ b/src/jake2/game/SuperAdapter.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 09.01.2004 by RST. -// $Id: SuperAdapter.java,v 1.2 2004-08-20 21:29:58 salomo Exp $ +// $Id: SuperAdapter.java,v 1.3 2004-09-04 09:01:01 salomo Exp $ package jake2.game; @@ -43,13 +43,12 @@ public class SuperAdapter /** Returns the adapter from the repository given by its ID. */ public static SuperAdapter getFromID(String key) { - System.out.println("SuperAdapter.getFromID(\"" + key + "\")"); SuperAdapter sa = (SuperAdapter) adapters.get(key); // try to create the adapter if (sa == null) { - System.out.println("adapter not found:" + key); + Com.DPrintf("SuperAdapter.getFromID():adapter not found->" + key + "\n"); int pos = key.indexOf('$'); String classname = key; if (pos != -1) @@ -58,19 +57,19 @@ public class SuperAdapter // load class and instantiate try { - System.err.println("loading class " + classname); + //Com.DPrintf("SuperAdapter.getFromID():loading class->" + classname + "\n"); Class.forName(classname).newInstance(); } catch(Exception e) { - System.err.println("jake2: class not found:" + classname); + Com.DPrintf("SuperAdapter.getFromID():class not found->" + classname + "\n"); } // try it again... sa = (SuperAdapter) adapters.get(key); if (sa == null) - System.err.println("jake2: could not load adapter:" + key); + Com.DPrintf("jake2: could not load adapter:" + key + "\n"); } return sa; @@ -83,7 +82,7 @@ public class SuperAdapter adapterid= tr[2].getClassName(); if (adapterid == "") new Throwable("error in creating an adapter id!").printStackTrace(); - else + else register(this, adapterid); } diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java index 757fb0e..8398cd5 100644 --- a/src/jake2/server/SV_CCMDS.java +++ b/src/jake2/server/SV_CCMDS.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.01.2004 by RST. -// $Id: SV_CCMDS.java,v 1.8 2004-08-29 21:39:25 hzi Exp $ +// $Id: SV_CCMDS.java,v 1.9 2004-09-04 09:01:01 salomo Exp $ package jake2.server; @@ -211,8 +211,7 @@ public class SV_CCMDS extends SV_ENTS { int l= -1; byte buffer[]= new byte[65536]; - Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n"); - System.out.println("CopyFile (" + src + ", " + dst + ")\n"); + //Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n"); try { f1= new RandomAccessFile(src, "r"); } -- cgit v1.2.3 From ccdf732d72dde1cb576a6e8d1ded1cdb0dd976c2 Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Sat, 4 Sep 2004 14:25:32 +0000 Subject: fallback to dummy if the /dev/dsp is locked (linux) --- src/jake2/sound/joal/JOALSoundImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/jake2') diff --git a/src/jake2/sound/joal/JOALSoundImpl.java b/src/jake2/sound/joal/JOALSoundImpl.java index ff9f937..101814e 100644 --- a/src/jake2/sound/joal/JOALSoundImpl.java +++ b/src/jake2/sound/joal/JOALSoundImpl.java @@ -2,7 +2,7 @@ * JOALSoundImpl.java * Copyright (C) 2004 * - * $Id: JOALSoundImpl.java,v 1.2 2004-07-13 11:20:28 cawe Exp $ + * $Id: JOALSoundImpl.java,v 1.3 2004-09-04 14:25:32 cawe Exp $ */ package jake2.sound.joal; @@ -63,6 +63,9 @@ public final class JOALSoundImpl implements Sound { } catch (OpenALException e) { Com.Printf(e.getMessage() + '\n'); return false; + } catch (Exception e) { + Com.DPrintf(e.getMessage() + '\n'); + return false; } al.alGenBuffers(MAX_SFX, buffers); s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE); -- cgit v1.2.3 From 7e2f174f0dd1e9efe3b85b6c889b6a0b06dccfbb Mon Sep 17 00:00:00 2001 From: Rene Stoeckel Date: Sat, 4 Sep 2004 19:08:30 +0000 Subject: some debug messages removed. --- src/jake2/client/CL.java | 4 ++-- src/jake2/game/GameSave.java | 4 +--- src/jake2/game/GameSpawn.java | 45 +-------------------------------------- src/jake2/game/edict_t.java | 5 ++--- src/jake2/game/game_locals_t.java | 4 ++-- src/jake2/server/SV_CCMDS.java | 4 +--- src/jake2/util/QuakeFile.java | 10 ++++----- 7 files changed, 14 insertions(+), 62 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java index 2cb6128..0d5bb26 100644 --- a/src/jake2/client/CL.java +++ b/src/jake2/client/CL.java @@ -2,7 +2,7 @@ * CL.java * Copyright (C) 2004 * - * $Id: CL.java,v 1.8 2004-08-27 21:05:04 hzi Exp $ + * $Id: CL.java,v 1.9 2004-09-04 19:08:29 salomo Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -974,7 +974,7 @@ public final class CL extends CL_pred { int num_skins = pheader.num_skins; while (precache_model_skin - 1 < num_skins) { - Com.Printf("critical code section because of endian mess!"); + //Com.Printf("critical code section because of endian mess!\n"); String name = new String( diff --git a/src/jake2/game/GameSave.java b/src/jake2/game/GameSave.java index 90d9619..b89ac21 100644 --- a/src/jake2/game/GameSave.java +++ b/src/jake2/game/GameSave.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 29.12.2003 by RST. -// $Id: GameSave.java,v 1.4 2004-08-29 21:39:24 hzi Exp $ +// $Id: GameSave.java,v 1.5 2004-09-04 19:08:30 salomo Exp $ package jake2.game; @@ -188,7 +188,6 @@ public class GameSave extends GameFunc { try { f= new QuakeFile(filename, "r"); - Com.Printf("loading game:" + filename); CreateEdicts(); game.load(f); @@ -288,7 +287,6 @@ public class GameSave extends GameFunc { num_edicts= entnum + 1; ent= g_edicts[entnum]; - System.out.println("readint ent" + entnum); ent.read(f); ent.cleararealinks(); gi.linkentity(ent); diff --git a/src/jake2/game/GameSpawn.java b/src/jake2/game/GameSpawn.java index c93ebc0..233cbff 100644 --- a/src/jake2/game/GameSpawn.java +++ b/src/jake2/game/GameSpawn.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.11.2003 by RST. -// $Id: GameSpawn.java,v 1.6 2004-08-29 21:39:24 hzi Exp $ +// $Id: GameSpawn.java,v 1.7 2004-09-04 19:08:30 salomo Exp $ package jake2.game; @@ -166,49 +166,6 @@ public class GameSpawn extends GameSave { if (!ent.set(key, value)) gi.dprintf("??? The key [" + key + "] is not a field\n"); - - - /** OLD CODE, delegated to ent.set(...) and st.set(...) - - for (f = fields; f.name; f++) { - if (!(f.flags & FFL_NOSPAWN) && !Q_stricmp(f.name, key)) { - // found it - if (f.flags & FFL_SPAWNTEMP) - b = (byte *) & st; - else - b = (byte *) ent; - - switch (f.type) { - case F_LSTRING : - * (String *) (b + f.ofs) = ED_NewString(value); - break; - case F_VECTOR : - sscanf(value, "%f %f %f", & vec[0], & vec[1], & vec[2]); - ((float *) (b + f.ofs))[0] = vec[0]; - ((float *) (b + f.ofs))[1] = vec[1]; - ((float *) (b + f.ofs))[2] = vec[2]; - break; - case F_INT : - * (int *) (b + f.ofs) = atoi(value); - break; - case F_FLOAT : - * (float *) (b + f.ofs) = atof(value); - break; - case F_ANGLEHACK : - v = atof(value); - ((float *) (b + f.ofs))[0] = 0; - ((float *) (b + f.ofs))[1] = v; - ((float *) (b + f.ofs))[2] = 0; - break; - case F_IGNORE : - break; - } - return; - } - } - gi.dprintf("%s is not a field\n", key); - - */ } /* diff --git a/src/jake2/game/edict_t.java b/src/jake2/game/edict_t.java index ef2e4a6..0de35df 100644 --- a/src/jake2/game/edict_t.java +++ b/src/jake2/game/edict_t.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 04.11.2003 by RST. -// $Id: edict_t.java,v 1.4 2004-08-22 14:25:12 salomo Exp $ +// $Id: edict_t.java,v 1.5 2004-09-04 19:08:30 salomo Exp $ package jake2.game; @@ -664,8 +664,7 @@ public class edict_t { oldenemy= f.readEdictRef(); activator= f.readEdictRef(); groundentity= f.readEdictRef(); - if (index == 145) - System.out.println("loadground:" + groundentity); + groundentity_linkcount= f.readInt(); teamchain= f.readEdictRef(); teammaster= f.readEdictRef(); diff --git a/src/jake2/game/game_locals_t.java b/src/jake2/game/game_locals_t.java index cbc109f..cf9718a 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.4 2004-08-20 21:29:58 salomo Exp $ +// $Id: game_locals_t.java,v 1.5 2004-09-04 19:08:29 salomo Exp $ package jake2.game; @@ -83,7 +83,7 @@ public class game_locals_t extends Defines // rst's checker :-) if (f.readInt()!=1928) - System.err.println("error in loading game_locals."); + Com.DPrintf("error in loading game_locals, 1928\n"); } diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java index 8398cd5..2c97f31 100644 --- a/src/jake2/server/SV_CCMDS.java +++ b/src/jake2/server/SV_CCMDS.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 18.01.2004 by RST. -// $Id: SV_CCMDS.java,v 1.9 2004-09-04 09:01:01 salomo Exp $ +// $Id: SV_CCMDS.java,v 1.10 2004-09-04 19:08:30 salomo Exp $ package jake2.server; @@ -385,7 +385,6 @@ public class SV_CCMDS extends SV_ENTS { name= FS.Gamedir() + "/save/current/" + sv.name + ".sav"; GameSave.ReadLevel(name); - System.out.println("all done!"); } /* @@ -510,7 +509,6 @@ public class SV_CCMDS extends SV_ENTS { } catch (Exception e) { Com.Printf("Couldn't read file " + name + "\n"); - System.err.println(e); e.printStackTrace(); } } diff --git a/src/jake2/util/QuakeFile.java b/src/jake2/util/QuakeFile.java index 9b71bb2..969248c 100644 --- a/src/jake2/util/QuakeFile.java +++ b/src/jake2/util/QuakeFile.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 24.07.2004 by RST. -// $Id: QuakeFile.java,v 1.1 2004-08-20 21:29:57 salomo Exp $ +// $Id: QuakeFile.java,v 1.2 2004-09-04 19:08:30 salomo Exp $ package jake2.util; @@ -27,6 +27,7 @@ import jake2.game.Game; import jake2.game.SuperAdapter; import jake2.game.edict_t; import jake2.game.gitem_t; +import jake2.qcommon.Com; import java.io.*; @@ -115,7 +116,7 @@ public class QuakeFile extends RandomAccessFile if (i > Game.g_edicts.length) { - System.err.println("jake2: illegal edict num:" + i); + Com.DPrintf("jake2: illegal edict num:" + i + "\n"); return null; } @@ -134,9 +135,8 @@ public class QuakeFile extends RandomAccessFile String str= a.getID(); if (a == null) { - System.err.println("writeAdapter: invalid Adapter id for" + a); + Com.DPrintf("writeAdapter: invalid Adapter id for " + a + "\n"); } - System.out.println("writing adapter:" + str); writeString(str); } } @@ -145,7 +145,7 @@ public class QuakeFile extends RandomAccessFile public SuperAdapter readAdapter() throws IOException { if (readInt() != 3988) - System.err.println("wrong read position: readadapter."); + Com.DPrintf("wrong read position: readadapter 3988 \n"); String id= readString(); -- cgit v1.2.3