Jogamp
import of Jake2 version hannover
authorHolger Zickner <hoz@bytonic.de>
Thu, 8 Jul 2004 15:58:48 +0000 (15:58 +0000)
committerHolger Zickner <hoz@bytonic.de>
Thu, 8 Jul 2004 15:58:48 +0000 (15:58 +0000)
140 files changed:
.classpath
.cvsignore
build.xml [new file with mode: 0644]
src/jake2/Defines.java
src/jake2/Enum.java [deleted file]
src/jake2/Globals.java
src/jake2/Jake2.java
src/jake2/client/CDAudio.java [deleted file]
src/jake2/client/CL.java
src/jake2/client/CL_ents.java
src/jake2/client/CL_fx.java
src/jake2/client/CL_input.java
src/jake2/client/CL_newfx.java
src/jake2/client/CL_parse.java
src/jake2/client/CL_pred.java
src/jake2/client/Console.java
src/jake2/client/Key.java
src/jake2/client/M.java
src/jake2/client/Menu.java
src/jake2/client/SCR.java
src/jake2/client/SND_DMA.java
src/jake2/client/SND_MEM.java
src/jake2/client/VID.java
src/jake2/client/sfx_t.java
src/jake2/client/sfxcache_t.java
src/jake2/game/AIAdapter.java
src/jake2/game/BigEndianHandler.java
src/jake2/game/Cmd.java
src/jake2/game/EdictFindFilter.java
src/jake2/game/EdictIterator.java
src/jake2/game/EndianHandler.java
src/jake2/game/EntBlockedAdapter.java
src/jake2/game/EntDieAdapter.java
src/jake2/game/EntDodgeAdapter.java
src/jake2/game/EntInteractAdapter.java
src/jake2/game/EntPainAdapter.java
src/jake2/game/EntThinkAdapter.java
src/jake2/game/EntTouchAdapter.java
src/jake2/game/EntUseAdapter.java
src/jake2/game/Fire.java
src/jake2/game/Game.java
src/jake2/game/GameAI.java
src/jake2/game/GameAIAdapters.java [new file with mode: 0644]
src/jake2/game/GameBase.java
src/jake2/game/GameFunc.java
src/jake2/game/GameFuncAdapters.java [new file with mode: 0644]
src/jake2/game/GameMisc.java
src/jake2/game/GameMiscAdapters.java [new file with mode: 0644]
src/jake2/game/GamePWeapon.java
src/jake2/game/GameSpawn.java
src/jake2/game/GameSpawnAdapters.java [new file with mode: 0644]
src/jake2/game/GameTarget.java
src/jake2/game/GameTargetAdapters.java [new file with mode: 0644]
src/jake2/game/GameTrigger.java
src/jake2/game/GameTriggerAdapters.java [new file with mode: 0644]
src/jake2/game/GameTurret.java
src/jake2/game/GameTurretAdapters.java [new file with mode: 0644]
src/jake2/game/GameUtil.java
src/jake2/game/GameUtilAdapters.java [new file with mode: 0644]
src/jake2/game/GameWeapon.java
src/jake2/game/GameWeaponAdapters.java [new file with mode: 0644]
src/jake2/game/Info.java
src/jake2/game/M_Actor.java
src/jake2/game/M_Berserk.java
src/jake2/game/M_Boss2.java
src/jake2/game/M_Boss31.java
src/jake2/game/M_Boss32.java
src/jake2/game/M_Brain.java
src/jake2/game/M_Chick.java
src/jake2/game/M_Flipper.java
src/jake2/game/M_Float.java
src/jake2/game/M_Flyer.java
src/jake2/game/M_Gladiator.java
src/jake2/game/M_Gunner.java
src/jake2/game/M_Hover.java
src/jake2/game/M_Infantry.java
src/jake2/game/M_Insane.java
src/jake2/game/M_Medic.java
src/jake2/game/M_Mutant.java
src/jake2/game/M_Parasite.java
src/jake2/game/M_Soldier.java
src/jake2/game/M_SoldierAdapters.java [new file with mode: 0644]
src/jake2/game/M_Supertank.java
src/jake2/game/M_Tank.java
src/jake2/game/Monster.java
src/jake2/game/MonsterAdapters.java [new file with mode: 0644]
src/jake2/game/PlayerClient.java
src/jake2/game/PlayerClientAdapters.java [new file with mode: 0644]
src/jake2/game/PlayerHud.java
src/jake2/game/client_persistant_t.java
src/jake2/game/client_respawn_t.java
src/jake2/game/cmdalias_t.java
src/jake2/game/cmodel_t.java
src/jake2/game/cplane_t.java
src/jake2/game/csurface_t.java
src/jake2/game/cvar_t.java
src/jake2/game/edict_t.java
src/jake2/game/entity_state_t.java
src/jake2/game/field_t.java
src/jake2/game/game_export_t.java
src/jake2/game/game_import_t.java
src/jake2/game/game_locals_t.java
src/jake2/game/gclient_t.java
src/jake2/game/gitem_t.java
src/jake2/game/trace_t.java
src/jake2/game/usercmd_t.java
src/jake2/qcommon/CM.java
src/jake2/qcommon/Cbuf.java
src/jake2/qcommon/Com.java
src/jake2/qcommon/FS.java
src/jake2/qcommon/MSG.java
src/jake2/qcommon/Netchan.java
src/jake2/qcommon/PMove.java
src/jake2/qcommon/Qcommon.java
src/jake2/qcommon/SZ.java
src/jake2/qcommon/Z.java [deleted file]
src/jake2/qcommon/netadr_t.java
src/jake2/qcommon/qfiles.java
src/jake2/qcommon/texinfo_t.java
src/jake2/qcommon/zhead_t.java [deleted file]
src/jake2/render/JoglRenderer.java
src/jake2/render/jogl/Draw.java
src/jake2/render/jogl/Impl.java
src/jake2/render/jogl/Main.java
src/jake2/render/jogl/Mesh.java
src/jake2/render/jogl/Warp.java
src/jake2/render/model_t.java
src/jake2/server/SV.java
src/jake2/server/SV_CCMDS.java
src/jake2/server/SV_ENTS.java
src/jake2/server/SV_GAME.java
src/jake2/server/SV_INIT.java
src/jake2/server/SV_MAIN.java
src/jake2/server/SV_USER.java
src/jake2/server/SV_WORLD.java
src/jake2/sys/IN.java
src/jake2/sys/RW.java [deleted file]
src/jake2/sys/Sys.java
src/jake2/util/Lib.java
src/jake2/util/Math3D.java

index a4aac26..795aa4d 100644 (file)
@@ -3,5 +3,6 @@
     <classpathentry kind="src" path="src"/>
     <classpathentry kind="src" path="test"/>
     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+    <classpathentry kind="lib" path="lib/jogl/jogl.jar"/>
     <classpathentry kind="output" path="build"/>
 </classpath>
index 11ec74f..c46d6e3 100644 (file)
@@ -1,2 +1,4 @@
 build
 baseq2
+dist
+*.tar.gz
diff --git a/build.xml b/build.xml
new file mode 100644 (file)
index 0000000..de8da32
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,102 @@
+<!-- Buildfile -->
+<project name="jake2" default="jar" basedir=".">
+
+       <!-- properties -->
+       <property name="src" location="src"/>
+       <property name="build" location="build"/>
+       <property name="dist" location="dist"/>
+
+       <!-- different classpaths -->
+       <path id="build.class.path">
+               <pathelement location="lib/jogl/jogl.jar"/>
+       </path>
+       
+       <path id="test.class.path">
+               <pathelement path="${build}"/>
+       </path>
+       
+       <path id="source.path">
+               <pathelement location="src"/>
+       </path>
+       
+       <!-- initialize directories -->
+       <target name="init">
+               <mkdir dir="${build}"/>
+               <mkdir dir="${dist}"/>
+       </target>
+
+       <!-- compile -->
+       <target name="compile" depends="init">
+               <javac destdir="${build}" optimize="on" debug="off" source="1.4">
+                       <src path="${src}"/>
+                       <include name="jake2/Jake2.java"/>
+                       <classpath refid="build.class.path"/>
+               </javac>
+       </target>
+               
+       <!-- copy libs -->
+       <target name="copylibs">
+               <copy todir="${dist}">
+                       <fileset dir="lib">
+                               <include name="/jogl/jogl.jar"/>
+                       </fileset>
+               </copy>
+       </target>
+       
+       <!-- copy resources -->
+       <target name="copyres">
+               <copy todir="${build}">
+                       <fileset dir="src">
+                               <include name="jake2/*.properties"/>
+                       </fileset>
+               </copy>
+       </target>
+               
+       <!-- jar -->
+       <target name="jar" depends="compile,copyres">
+               <jar destfile="${dist}/jake2.jar" basedir="${build}">
+                       <include name="jake2/**"/>
+               </jar>
+       </target>
+                       
+       <!-- everything -->
+       <target name="all" depends="bindist,srcdist">
+       </target>
+
+       <!-- dist -->
+       <target name="dist" depends="jar,copylibs">
+       </target>
+               
+       <!-- binary distribution -->
+       <target name="bindist" depends="dist">
+               <tar destfile="jake2.tar.gz" compression="gzip">
+                       <tarfileset dir=".">
+                               <include name="dist/**"/>
+                       </tarfileset>
+               </tar>
+       </target>
+       
+       <!-- source distribution -->
+       <target name="srcdist" >
+               <tar destfile="jake2-src.tar.gz" compression="gzip">
+                       <tarfileset dir="." prefix="jake2">
+                               <include name="src/**"/>
+                               <include name="lib/**"/>
+                               <include name="build.xml"/>
+                       </tarfileset>
+               </tar>
+       </target>
+       
+       <!-- clean -->
+       <target name="clean">
+               <delete dir="${build}"/>
+               <delete dir="${gensrc}"/>
+       </target>
+       
+       <!-- distclean -->
+       <target name="distclean" depends="clean">
+               <delete dir="${dist}"/>
+               <delete file="jake2.tar.gz"/>
+               <delete file="jake2-src.tar.gz"/>
+       </target>
+</project>
\ No newline at end of file
index 8556e03..26984e9 100644 (file)
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
 // Created on 31.10.2003 by RST.
-// $Id: Defines.java,v 1.1 2004-07-07 19:58:31 hzi Exp $
+// $Id: Defines.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
 
 /** Contains the definitions for the game engine. */
 
@@ -1368,4 +1368,13 @@ public class Defines extends Math3D {
        public final static String NO_SERVER_STRING = "<no server>";
        public final static int NUM_ADDRESSBOOK_ENTRIES = 9;
 
+       //      // 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;
+
 }
diff --git a/src/jake2/Enum.java b/src/jake2/Enum.java
deleted file mode 100644 (file)
index cf489fe..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Enum.java
- * Copyright (C) 2003
- *
- * $Id: Enum.java,v 1.1 2004-07-07 19:58:31 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;
-
-/**
- * Enum
- * 
- * @author cwei
- */
-public interface 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;
-
-//     // and so on
-}
index 5b2a998..27b6e4a 100644 (file)
@@ -2,77 +2,7 @@
  * Globals.java
  * Copyright (C) 2003
  * 
- * $Id: Globals.java,v 1.1 2004-07-07 19:58:32 hzi Exp $
- * $Log: Globals.java,v $
- * Revision 1.1  2004-07-07 19:58:32  hzi
- * Initial revision
- *
- * Revision 1.1.1.1  2004/07/07 18:35:04  holger
- * import of Jake2 version sunrise
- *
- * Revision 1.46  2004/02/11 19:56:28  cwei
- * monster debug.
- *
- * Revision 1.45  2004/02/11 05:12:47  cwei
- * scr_rect wird gesetzt
- *
- * Revision 1.44  2004/02/08 13:26:13  hoz
- * - aufr?umen
- *
- * Revision 1.43  2004/02/04 11:24:15  hoz
- * - some fx functions
- * - long -> int for time variables
- *
- * Revision 1.42  2004/02/02 22:06:54  hoz
- * - some client effects
- *
- * Revision 1.41  2004/02/02 21:15:40  hoz
- * input kram
- *
- * Revision 1.40  2004/02/02 19:25:23  hoz
- * *** empty log message ***
- *
- * Revision 1.39  2004/02/02 19:13:26  rst
- * cosmetic
- *
- * Revision 1.38  2004/01/30 18:44:32  cwei
- * logfile
- *
- * Revision 1.37  2004/01/30 13:34:31  hoz
- * - client code
- *
- * Revision 1.36  2004/01/30 09:24:20  hoz
- * - client code
- *
- * Revision 1.35  2004/01/28 21:04:10  hoz
- * - client code
- *
- * Revision 1.34  2004/01/28 14:42:58  hoz
- * - client code
- *
- * Revision 1.33  2004/01/28 10:03:06  hoz
- * - client code
- *
- * Revision 1.32  2004/01/27 20:10:29  rst
- * now has a quake menu
- *
- * Revision 1.31  2004/01/18 12:36:02  hoz
- * Key.*
- *
- * Revision 1.30  2004/01/18 10:39:34  rst
- * M O N S T E R - C O M M I T
- * (network and server code)
- *
- * Revision 1.29  2004/01/18 09:41:57  hoz
- * Key.Message()
- *
- * Revision 1.28  2004/01/11 14:38:47  cwei
- * Aenderungen fuer VID impl
- *
- * Revision 1.27  2004/01/09 22:25:09  rst
- * cosmetic
- *
- * 
+ * $Id: Globals.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -103,6 +33,7 @@ import jake2.render.model_t;
 
 import java.io.FileWriter;
 import java.io.RandomAccessFile;
+import java.util.Random;
 
 /**
  * Globals ist the collection of global variables and constants.
@@ -113,12 +44,6 @@ import java.io.RandomAccessFile;
  */
 public class Globals extends Defines {
 
-       /*
-        * global constants
-        */
-
-       public static final String BUILDSTRING = "Java";
-       public static final String CPUSTRING = "jvm";
        public static final String __DATE__ = "2003";
 
        public static final float VERSION = 3.21f;
@@ -132,23 +57,11 @@ public class Globals extends Defines {
        public static boolean cmd_wait;
 
        public static int alias_count;
-       public static int com_argc;
        public static int c_traces;
        public static int c_brush_traces;
        public static int c_pointcontents;
        public static int server_state;
 
-       public static String[] com_argv = new String[MAX_NUM_ARGVS];
-
-       public static cvar_t adr0;
-       public static cvar_t adr1;
-       public static cvar_t adr2;
-       public static cvar_t adr3;
-       public static cvar_t adr4;
-       public static cvar_t adr5;
-       public static cvar_t adr6;
-       public static cvar_t adr7;
-       public static cvar_t adr8;
        public static cvar_t cl_add_blend;
        public static cvar_t cl_add_entities;
        public static cvar_t cl_add_lights;
@@ -171,6 +84,7 @@ public class Globals extends Defines {
        public static cvar_t cl_upspeed;
        public static cvar_t cl_yawspeed;
        public static cvar_t dedicated;
+       public static cvar_t slomo;
        public static cvar_t developer;
        public static cvar_t fixedtime;
        public static cvar_t freelook;
@@ -446,7 +360,6 @@ public class Globals extends Defines {
 
        public static String[] keybindings = new String[256];
        public static boolean[] keydown = new boolean[256];
-       public static int anykeydown = 0;
        public static boolean chat_team = false;
        public static String chat_buffer = "";
        public static byte[][] key_lines = new byte[32][];
@@ -459,7 +372,7 @@ public class Globals extends Defines {
 
        public static cvar_t crosshair;
        public static vrect_t scr_vrect = new vrect_t();
-       public static long sys_frame_time;
+       public static int sys_frame_time;
        public static int chat_bufferlen = 0;
        public static int gun_frame;
        public static model_t gun_model;
@@ -472,4 +385,6 @@ public class Globals extends Defines {
 
        public static cvar_t m_filter;
        public static int vidref_val = VIDREF_GL;
+       
+       public static Random rnd = new Random();
 }
index 8ea4111..70649b2 100644 (file)
@@ -2,7 +2,7 @@
  * Jake2.java
  * Copyright (C)  2003
  * 
- * $Id: Jake2.java,v 1.1 2004-07-07 19:58:32 hzi Exp $
+ * $Id: Jake2.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -102,7 +102,7 @@ public final class Jake2 {
 
                        // save cpu resources
 //                     try {
-//                             Thread.sleep(5);
+//                             Thread.sleep(1);
 //                     }
 //                     catch (InterruptedException e) {
 //                     }
diff --git a/src/jake2/client/CDAudio.java b/src/jake2/client/CDAudio.java
deleted file mode 100644 (file)
index 49c5c42..0000000
+++ /dev/null
@@ -1,43 +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.01.2004 by RST.
-// $Id: CDAudio.java,v 1.1 2004-07-07 19:58:32 hzi Exp $
-
-package jake2.client;
-
-
-// import jake2.*;
-// import jake2.client.*;
-// import jake2.game.*;
-// import jake2.qcommon.*;
-// import jake2.render.*;
-// import jake2.server.*;
-
-public class CDAudio {
-
-       public static void CDAudio_Play(int i, boolean b) {
-               // TODO:implement CDAudio_Play
-       }
-
-       public static void Stop()       {
-               // TODO impl: CDAudio.Stop()
-       }
-}
index 58ce048..3522aa2 100644 (file)
@@ -2,7 +2,7 @@
  * CL.java
  * Copyright (C) 2004
  * 
- * $Id: CL.java,v 1.1 2004-07-07 19:58:33 hzi Exp $
+ * $Id: CL.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -42,7 +42,16 @@ import java.nio.ByteBuffer;
  */
 public final class CL extends CL_pred {
 
-       ////       cl_main.c  -- client main loop
+
+//     static cvar_t adr0;
+//     static cvar_t adr1;
+//     static cvar_t adr2;
+//     static cvar_t adr3;
+//     static cvar_t adr4;
+//     static cvar_t adr5;
+//     static cvar_t adr6;
+//     static cvar_t adr7;
+//     static cvar_t adr8;
 
        /*
        ====================
@@ -91,7 +100,6 @@ public final class CL extends CL_pred {
                                cls.demofile = null;
                                cls.demorecording = false;
                                Com.Printf("Stopped demo.\n");
-
                        }
                        catch (IOException e) {
                        }
@@ -107,7 +115,8 @@ public final class CL extends CL_pred {
        Begins recording a demo from the current position
        ====================
        */
-       private static entity_state_t nullstate = new entity_state_t(null);
+       static entity_state_t nullstate = new entity_state_t(null);
+       
        static xcommand_t Record_f = new xcommand_t() {
                public void execute() {
                        try {
@@ -115,7 +124,6 @@ public final class CL extends CL_pred {
                                byte buf_data[] = new byte[MAX_MSGLEN];
                                sizebuf_t buf = new sizebuf_t();
                                int i;
-                               int len;
                                entity_state_t ent;
 
                                if (Cmd.Argc() != 2) {
@@ -425,7 +433,7 @@ public final class CL extends CL_pred {
                        if (cls.state >= ca_connected)
                                to = cls.netchan.remote_address;
                        else {
-                               if (strlen(rcon_address.string) == 0) {
+                               if (rcon_address.string.length() == 0) {
                                        Com.Printf(
                                                "You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n");
 
@@ -1033,7 +1041,7 @@ public final class CL extends CL_pred {
 
                                        int i, n;
                                        //char model[MAX_QPATH], skin[MAX_QPATH], * p;
-                                       String model, skin, p;
+                                       String model, skin;
 
                                        i = (precache_check - CS_PLAYERSKINS) / PLAYER_MULT;
                                        n = (precache_check - CS_PLAYERSKINS) % PLAYER_MULT;
@@ -1195,7 +1203,7 @@ public final class CL extends CL_pred {
                                CM.intwrap iw = new CM.intwrap(0); // for detecting cheater maps
 
                                CM.CM_LoadMap(cl.configstrings[CS_MODELS + 1], true, iw);
-                               int mapchecksum = iw.i ;
+//                             int mapchecksum = iw.i ;
                                CL.RegisterSounds();
                                CL.PrepRefresh();
                                return;
@@ -1221,15 +1229,16 @@ public final class CL extends CL_pred {
 
                InitInput();
 
-               adr0 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
-               adr1 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
-               adr2 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
-               adr3 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
-               adr4 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
-               adr5 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
-               adr6 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
-               adr7 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
-               adr8 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
+               // never used !!
+//             adr0 = Cvar.Get("adr0", "", CVAR_ARCHIVE);
+//             adr1 = Cvar.Get("adr1", "", CVAR_ARCHIVE);
+//             adr2 = Cvar.Get("adr2", "", CVAR_ARCHIVE);
+//             adr3 = Cvar.Get("adr3", "", CVAR_ARCHIVE);
+//             adr4 = Cvar.Get("adr4", "", CVAR_ARCHIVE);
+//             adr5 = Cvar.Get("adr5", "", CVAR_ARCHIVE);
+//             adr6 = Cvar.Get("adr6", "", CVAR_ARCHIVE);
+//             adr7 = Cvar.Get("adr7", "", CVAR_ARCHIVE);
+//             adr8 = Cvar.Get("adr8", "", CVAR_ARCHIVE);
 
                //
                // register our variables
@@ -1367,6 +1376,10 @@ public final class CL extends CL_pred {
 
                path = FS.Gamedir() + "/config.cfg";
                f = fopen(path, "rw");
+               if (f == null) {
+                       Com.Printf("Couldn't write config.cfg.\n");
+                       return;
+               }
                try
                {
                        f.seek(0);
@@ -1374,15 +1387,11 @@ public final class CL extends CL_pred {
                }
                catch (IOException e1)
                {}
-               if (f == null) {
-                       Com.Printf("Couldn't write config.cfg.\n");
-                       return;
-               }
                try {
                        f.writeBytes("// generated by quake, do not modify\n");
                }
                catch (IOException e) {}
-               //fprintf (f, "// generated by quake, do not modify\n");
+
                Key.WriteBindings(f);
                fclose(f);
                Cvar.WriteVariables(path);
@@ -1430,7 +1439,7 @@ public final class CL extends CL_pred {
                int i;
                cheatvar_t var;
 
-               if (0 == strcmp(cl.configstrings[CS_MAXCLIENTS], "1") || 0 == cl.configstrings[CS_MAXCLIENTS].length())
+               if ("1".equals(cl.configstrings[CS_MAXCLIENTS]) || 0 == cl.configstrings[CS_MAXCLIENTS].length())
                        return; // single player can cheat
 
                // find all the cvars if we haven't done it yet
@@ -1444,7 +1453,7 @@ public final class CL extends CL_pred {
                // make sure they are all set to the proper values
                for (i = 0; i < numcheatvars; i++) {
                        var = cheatvars[i];
-                       if (0 != strcmp(var.var.string, var.value)) {
+                       if (!var.var.string.equals(var.value)) {
                                Cvar.Set(var.name, var.value);
                        }
                }
@@ -1485,7 +1494,7 @@ public final class CL extends CL_pred {
        ==================
        */
        private static int extratime;
-       private static int lasttimecalled;
+//     private static int lasttimecalled;
 
        public static void Frame(int msec) {
 
@@ -1531,8 +1540,8 @@ public final class CL extends CL_pred {
                if (!cl.refresh_prepped && cls.state == ca_active) {
                        CL.PrepRefresh();
                        // TODO force GC after level loading
-                       System.gc();
-                       System.gc();
+                       //System.gc();
+                       //System.gc();
                }
 
                SCR.UpdateScreen();
index 135f3fe..4dc4330 100644 (file)
@@ -2,7 +2,7 @@
  * CL_ents.java
  * Copyright (C) 2004
  * 
- * $Id: CL_ents.java,v 1.1 2004-07-07 19:58:35 hzi Exp $
+ * $Id: CL_ents.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -36,9 +36,6 @@ import jake2.render.model_t;
 //        cl_ents.c -- entity parsing and management
 public class CL_ents extends CL_inv {
 
-       //        PGM
-       static int vidref_val;
-       //        PGM
 
        /*
        =========================================================================
@@ -591,7 +588,6 @@ public class CL_ents extends CL_inv {
 
        public static model_t S_RegisterSexedModel(entity_state_t  ent, String base) {
                int n;
-               String p;
                model_t mdl;
                String model;
                String buffer;
@@ -734,7 +730,8 @@ public class CL_ents extends CL_inv {
                        // tweak the color of beams
                        if ((renderfx & RF_BEAM)!=0) { // the four beam colors are encoded in 32 bits of skinnum (hack)
                                ent.alpha = 0.30f;
-                               ent.skinnum = (s1.skinnum >> ((rand() % 4) * 8)) & 0xff;
+                               ent.skinnum = (s1.skinnum >> ((rnd.nextInt(4)) * 8)) & 0xff;
+                               Math.random();
                                ent.model = null;
                        }
                        else {
@@ -1012,7 +1009,7 @@ public class CL_ents extends CL_inv {
                                else if ((effects & EF_TRAP)!=0) {
                                        ent.origin[2] += 32;
                                        TrapParticles( ent);
-                                       i = (rand() % 100) + 100;
+                                       i = (rnd.nextInt(100)) + 100;
                                        V.AddLight(ent.origin, i, 1, 0.8f, 0.1f);
                                }
                                else if ((effects & EF_FLAG1)!=0) {
@@ -1143,7 +1140,6 @@ public class CL_ents extends CL_inv {
        static void CalcViewValues() {
                int i;
                float lerp, backlerp;
-               centity_t   ent;
                frame_t   oldframe;
                player_state_t   ps,   ops;
 
@@ -1163,7 +1159,6 @@ public class CL_ents extends CL_inv {
                        || Math.abs(ops.pmove.origin[2] - ps.pmove.origin[2]) > 256 * 8)
                        ops = ps; // don't interpolate
 
-               ent =  cl_entities[cl.playernum + 1];
                lerp = cl.lerpfrac;
 
                // calculate the origin
index 1ce63ad..86642ee 100644 (file)
@@ -2,7 +2,7 @@
  * CL_fx.java
  * Copyright (C) 2004
  * 
- * $Id: CL_fx.java,v 1.1 2004-07-07 19:58:36 hzi Exp $
+ * $Id: CL_fx.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -125,7 +125,7 @@ public class CL_fx extends CL_tent {
 
                s = cl.configstrings[i + CS_LIGHTS];
 
-               j = strlen(s);
+               j = s.length();
                if (j >= MAX_QPATH)
                        Com.Error(ERR_DROP, "svc_lightstyle length=" + j);
 
@@ -288,9 +288,9 @@ public class CL_fx extends CL_tent {
                VectorMA(dl.origin, 18, fv, dl.origin);
                VectorMA(dl.origin, 16, rv, dl.origin);
                if (silenced != 0)
-                       dl.radius = 100 + (rand() & 31);
+                       dl.radius = 100 + (rnd.nextInt() & 31);
                else
-                       dl.radius = 200 + (rand() & 31);
+                       dl.radius = 200 + (rnd.nextInt() & 31);
                dl.minlight = 32;
                dl.die = cl.time; // + 0.1;
 
@@ -323,7 +323,7 @@ public class CL_fx extends CL_tent {
                                dl.color[1] = 1;
                                dl.color[2] = 0;
                                //Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
-                               soundname = "weapons/machgf" + ((rand() % 5) + 1) + "b.wav";
+                               soundname = "weapons/machgf" + ((rnd.nextInt(5)) + 1) + "b.wav";
                                S.StartSound(null, i, CHAN_WEAPON, S.RegisterSound(soundname), volume, ATTN_NORM, 0);
                                break;
                        case MZ_SHOTGUN :
@@ -340,41 +340,41 @@ public class CL_fx extends CL_tent {
                                S.StartSound(null, i, CHAN_WEAPON, S.RegisterSound("weapons/sshotf1b.wav"), volume, ATTN_NORM, 0);
                                break;
                        case MZ_CHAINGUN1 :
-                               dl.radius = 200 + (rand() & 31);
+                               dl.radius = 200 + (rnd.nextInt() & 31);
                                dl.color[0] = 1;
                                dl.color[1] = 0.25f;
                                dl.color[2] = 0;
                                //Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
-                               soundname = "weapons/machgf" + ((rand() % 5) + 1) + "b.wav";
+                               soundname = "weapons/machgf" + ((rnd.nextInt(5)) + 1) + "b.wav";
                                S.StartSound(null, i, CHAN_WEAPON, S.RegisterSound(soundname), volume, ATTN_NORM, 0);
                                break;
                        case MZ_CHAINGUN2 :
-                               dl.radius = 225 + (rand() & 31);
+                               dl.radius = 225 + (rnd.nextInt() & 31);
                                dl.color[0] = 1;
                                dl.color[1] = 0.5f;
                                dl.color[2] = 0;
                                dl.die = cl.time + 0.1f; // long delay
                                //Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
-                               soundname = "weapons/machgf" + ((rand() % 5) + 1) + "b.wav";
+                               soundname = "weapons/machgf" + ((rnd.nextInt(5)) + 1) + "b.wav";
                                S.StartSound(null, i, CHAN_WEAPON, S.RegisterSound(soundname), volume, ATTN_NORM, 0);
                                //Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
-                               soundname = "weapons/machgf" + ((rand() % 5) + 1) + "b.wav";
+                               soundname = "weapons/machgf" + ((rnd.nextInt(5)) + 1) + "b.wav";
                                S.StartSound(null, i, CHAN_WEAPON, S.RegisterSound(soundname), volume, ATTN_NORM, 0.05f);
                                break;
                        case MZ_CHAINGUN3 :
-                               dl.radius = 250 + (rand() & 31);
+                               dl.radius = 250 + (rnd.nextInt() & 31);
                                dl.color[0] = 1;
                                dl.color[1] = 1;
                                dl.color[2] = 0;
                                dl.die = cl.time + 0.1f; // long delay
                                //Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
-                               soundname = "weapons/machgf" + ((rand() % 5) + 1) + "b.wav";
+                               soundname = "weapons/machgf" + ((rnd.nextInt(5)) + 1) + "b.wav";
                                S.StartSound(null, i, CHAN_WEAPON, S.RegisterSound(soundname), volume, ATTN_NORM, 0);
                                //Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
-                               soundname = "weapons/machgf" + ((rand() % 5) + 1) + "b.wav";
+                               soundname = "weapons/machgf" + ((rnd.nextInt(5)) + 1) + "b.wav";
                                S.StartSound(null, i, CHAN_WEAPON, S.RegisterSound(soundname), volume, ATTN_NORM, 0.033f);
                                //Com_sprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
-                               soundname = "weapons/machgf" + ((rand() % 5) + 1) + "b.wav";
+                               soundname = "weapons/machgf" + ((rnd.nextInt(5)) + 1) + "b.wav";
                                S.StartSound(null, i, CHAN_WEAPON, S.RegisterSound(soundname), volume, ATTN_NORM, 0.066f);
                                break;
                        case MZ_RAILGUN :
@@ -545,7 +545,7 @@ public class CL_fx extends CL_tent {
 
                dl = CL.AllocDlight(ent);
                VectorCopy(origin, dl.origin);
-               dl.radius = 200 + (rand() & 31);
+               dl.radius = 200 + (rnd.nextInt() & 31);
                dl.minlight = 32;
                dl.die = cl.time; // + 0.1;
 
@@ -729,7 +729,7 @@ public class CL_fx extends CL_tent {
                                CL.ParticleEffect(origin, vec3_origin, 0, 40);
                                CL.SmokeAndFlash(origin);
                                //Com_sprintf(soundname, sizeof(soundname), "tank/tnkatk2%c.wav", 'a' + rand() % 5);
-                               soundname = "tank/tnkatk2" + (char) ('a' + rand() % 5) + ".wav";
+                               soundname = "tank/tnkatk2" + (char) ('a' + rnd.nextInt(5)) + ".wav";
                                S.StartSound(null, ent, CHAN_WEAPON, S.RegisterSound(soundname), 1, ATTN_NORM, 0);
                                break;
 
@@ -938,7 +938,7 @@ public class CL_fx extends CL_tent {
                        case MZ2_WIDOW2_BEAM_SWEEP_9 :
                        case MZ2_WIDOW2_BEAM_SWEEP_10 :
                        case MZ2_WIDOW2_BEAM_SWEEP_11 :
-                               dl.radius = 300 + (rand() & 100);
+                               dl.radius = 300 + (rnd.nextInt() & 100);
                                dl.color[0] = 1;
                                dl.color[1] = 1;
                                dl.color[2] = 0;
@@ -1848,7 +1848,7 @@ public class CL_fx extends CL_tent {
                int                     i;
                cparticle_t     p;
                float           angle;
-               float           sr, sp, sy, cr, cp, cy;
+               float           sp, sy, cp, cy;
                float []                forward= new float[3];
                float           dist = 64;
                float           ltime;
@@ -1877,8 +1877,6 @@ public class CL_fx extends CL_tent {
                        sp = (float)Math.sin(angle);
                        cp = (float)Math.cos(angle);
                        angle = ltime * avelocities[i][2];
-                       sr = (float)Math.sin(angle);
-                       cr = (float)Math.cos(angle);
        
                        forward[0] = cp*cy;
                        forward[1] = cp*sy;
@@ -1945,7 +1943,7 @@ public class CL_fx extends CL_tent {
                int i;
                cparticle_t p;
                float angle;
-               float sr, sp, sy, cr, cp, cy;
+               float sp, sy, cp, cy;
                float[] forward = new float[3];
                float dist = 64;
                float[] v = new float[3];
@@ -1968,8 +1966,6 @@ public class CL_fx extends CL_tent {
                        sp = (float)Math.sin(angle);
                        cp = (float)Math.cos(angle);
                        angle = ltime * avelocities[i][2];
-                       sr = (float)Math.sin(angle);
-                       cr = (float)Math.cos(angle);
 
                        forward[0] = cp * cy;
                        forward[1] = cp * sy;
index 1b6233c..b55b866 100644 (file)
@@ -2,7 +2,7 @@
  * CL_input.java
  * Copyright (C) 2004
  * 
- * $Id: CL_input.java,v 1.1 2004-07-07 19:58:37 hzi Exp $
+ * $Id: CL_input.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -341,7 +341,7 @@ public class CL_input extends CL_ents {
                        cmd.buttons |= BUTTON_USE;
                in_use.state &= ~2;
 
-               if (anykeydown != 0 && cls.key_dest == key_game)
+               if (Key.anykeydown != 0 && cls.key_dest == key_game)
                        cmd.buttons |= BUTTON_ANY;
 
                // send milliseconds of time to apply the move
@@ -460,8 +460,7 @@ public class CL_input extends CL_ents {
                Cmd.AddCommand("-klook", new xcommand_t() {
                        public void execute() {IN_KLookUp();}});
 
-               // TODO nodelta
-               cl_nodelta = Cvar.Get("cl_nodelta", "1",0);
+               cl_nodelta = Cvar.Get("cl_nodelta", "0",0);
        }
 
        /*
index bfa1c71..67abf81 100644 (file)
@@ -2,7 +2,7 @@
  * CL_newfx.java
  * Copyright (C) 2004
  * 
- * $Id: CL_newfx.java,v 1.1 2004-07-07 19:58:38 hzi Exp $
+ * $Id: CL_newfx.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -229,59 +229,59 @@ public class CL_newfx extends CL_fx {
                }
        }
 
-       static void FlameEffects(centity_t ent, float[] origin) {
-               int n, count;
-               int j;
-               cparticle_t p;
-
-               count = rand() & 0xF;
-
-               for (n = 0; n < count; n++) {
-                       if (free_particles == null)
-                               return;
-
-                       p = free_particles;
-                       free_particles = p.next;
-                       p.next = active_particles;
-                       active_particles = p;
-
-                       VectorClear(p.accel);
-                       p.time = cl.time;
-
-                       p.alpha = 1.0f;
-                       p.alphavel = -1.0f / (1 + frand() * 0.2f);
-                       p.color = 226 + (rand() % 4);
-                       for (j = 0; j < 3; j++) {
-                               p.org[j] = origin[j] + crand() * 5;
-                               p.vel[j] = crand() * 5;
-                       }
-                       p.vel[2] = crand() * -10;
-                       p.accel[2] = -PARTICLE_GRAVITY;
-               }
-
-               count = rand() & 0x7;
-
-               for (n = 0; n < count; n++) {
-                       if (free_particles == null)
-                               return;
-                       p = free_particles;
-                       free_particles = p.next;
-                       p.next = active_particles;
-                       active_particles = p;
-                       VectorClear(p.accel);
-
-                       p.time = cl.time;
-
-                       p.alpha = 1.0f;
-                       p.alphavel = -1.0f / (1 + frand() * 0.5f);
-                       p.color = 0 + (rand() % 4);
-                       for (j = 0; j < 3; j++) {
-                               p.org[j] = origin[j] + crand() * 3;
-                       }
-                       p.vel[2] = 20 + crand() * 5;
-               }
-
-       }
+//     static void FlameEffects(centity_t ent, float[] origin) {
+//             int n, count;
+//             int j;
+//             cparticle_t p;
+//
+//             count = rand() & 0xF;
+//
+//             for (n = 0; n < count; n++) {
+//                     if (free_particles == null)
+//                             return;
+//
+//                     p = free_particles;
+//                     free_particles = p.next;
+//                     p.next = active_particles;
+//                     active_particles = p;
+//
+//                     VectorClear(p.accel);
+//                     p.time = cl.time;
+//
+//                     p.alpha = 1.0f;
+//                     p.alphavel = -1.0f / (1 + frand() * 0.2f);
+//                     p.color = 226 + (rand() % 4);
+//                     for (j = 0; j < 3; j++) {
+//                             p.org[j] = origin[j] + crand() * 5;
+//                             p.vel[j] = crand() * 5;
+//                     }
+//                     p.vel[2] = crand() * -10;
+//                     p.accel[2] = -PARTICLE_GRAVITY;
+//             }
+//
+//             count = rand() & 0x7;
+//
+//             for (n = 0; n < count; n++) {
+//                     if (free_particles == null)
+//                             return;
+//                     p = free_particles;
+//                     free_particles = p.next;
+//                     p.next = active_particles;
+//                     active_particles = p;
+//                     VectorClear(p.accel);
+//
+//                     p.time = cl.time;
+//
+//                     p.alpha = 1.0f;
+//                     p.alphavel = -1.0f / (1 + frand() * 0.5f);
+//                     p.color = 0 + (rand() % 4);
+//                     for (j = 0; j < 3; j++) {
+//                             p.org[j] = origin[j] + crand() * 3;
+//                     }
+//                     p.vel[2] = 20 + crand() * 5;
+//             }
+//
+//     }
 
 
        /*
index e972ea6..d60de21 100644 (file)
@@ -2,7 +2,7 @@
  * CL_parse.java
  * Copyright (C) 2004
  * 
- * $Id: CL_parse.java,v 1.1 2004-07-07 19:58:38 hzi Exp $
+ * $Id: CL_parse.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -135,8 +135,7 @@ public class CL_parse extends CL_view {
                        MSG.WriteString(cls.netchan.message, "download " + cls.downloadname + " " + len);
                }
                else {
-                       // TODO bugfix cwei
-                       cls.downloadname = cls.downloadname.toLowerCase();
+                       cls.downloadname = cls.downloadname;
 
                        Com.Printf("Downloading " + cls.downloadname + "\n");
                        MSG.WriteByte(cls.netchan.message, clc_stringcmd);
@@ -166,7 +165,7 @@ public class CL_parse extends CL_view {
 
                        filename = Cmd.Argv(1);
 
-                       if (strstr(filename, "..")) {
+                       if (filename.indexOf("..") != -1) {
                                Com.Printf("Refusing to download a path with ..\n");
                                return;
                        }
@@ -183,7 +182,7 @@ public class CL_parse extends CL_view {
                        // to the real name when done, so if interrupted
                        // a runt file wont be left
                        Com.StripExtension(cls.downloadname, cls.downloadtempname);
-                       strcat(cls.downloadtempname, ".tmp");
+                       cls.downloadtempname += ".tmp";
 
                        MSG.WriteByte(cls.netchan.message, clc_stringcmd);
                        MSG.WriteString(cls.netchan.message, "download " + cls.downloadname);
@@ -546,14 +545,9 @@ public class CL_parse extends CL_view {
 
                // do something apropriate 
 
-               if (i >= CS_LIGHTS && i < CS_LIGHTS + MAX_LIGHTSTYLES)
-               {
+               if (i >= CS_LIGHTS && i < CS_LIGHTS + MAX_LIGHTSTYLES) {
                        SetLightstyle(i - CS_LIGHTS);
                }
-               else if (i == CS_CDTRACK) {
-                       if (cl.refresh_prepped)
-                               CDAudio.CDAudio_Play(atoi(cl.configstrings[CS_CDTRACK]), true);
-               }
                else if (i >= CS_MODELS && i < CS_MODELS + MAX_MODELS) {
                        if (cl.refresh_prepped) {
                                cl.model_draw[i - CS_MODELS] = re.RegisterModel(cl.configstrings[i]);
@@ -572,7 +566,7 @@ public class CL_parse extends CL_view {
                                cl.image_precache[i - CS_IMAGES] = re.RegisterPic(cl.configstrings[i]);
                }
                else if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS + MAX_CLIENTS) {
-                       if (cl.refresh_prepped && strcmp(olds, s)!=0)
+                       if (cl.refresh_prepped && !olds.equals(s))
                                ParseClientinfo(i - CS_PLAYERSKINS);
                }
        }
index cc8061f..eecf0eb 100644 (file)
@@ -2,7 +2,7 @@
  * CL_pred.java
  * Copyright (C) 2004
  * 
- * $Id: CL_pred.java,v 1.1 2004-07-07 19:58:39 hzi Exp $
+ * $Id: CL_pred.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -31,23 +31,20 @@ import jake2.qcommon.*;
 /**
  * CL_pred
  */
-public class CL_pred extends CL_parse
-{
+public class CL_pred extends CL_parse {
 
        /*
        ===================
        CL_CheckPredictionError
        ===================
        */
-       static void CheckPredictionError()
-       {
+       static void CheckPredictionError() {
                int frame;
                int[] delta = new int[3];
                int i;
                int len;
 
-               if (cl_predict.value == 0.0f
-                       || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0)
+               if (cl_predict.value == 0.0f || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0)
                        return;
 
                // calculate the last usercmd_t we sent that the server has processed
@@ -55,31 +52,19 @@ public class CL_pred extends CL_parse
                frame &= (CMD_BACKUP - 1);
 
                // compare what the server returned with what we had predicted it to be
-               VectorSubtract(
-                       cl.frame.playerstate.pmove.origin,
-                       cl.predicted_origins[frame],
-                       delta);
+               VectorSubtract(cl.frame.playerstate.pmove.origin, cl.predicted_origins[frame], delta);
 
                // save the prediction error for interpolation
                len = Math.abs(delta[0]) + Math.abs(delta[1]) + Math.abs(delta[2]);
                if (len > 640) // 80 world units
-               { // a teleport or something
+                       { // a teleport or something
                        VectorClear(cl.prediction_error);
                }
-               else
-               {
-                       if (cl_showmiss.value != 0.0f
-                               && (delta[0] != 0 || delta[1] != 0 || delta[2] != 0))
-                               Com.Printf(
-                                       "prediction miss on "
-                                               + cl.frame.serverframe
-                                               + ": "
-                                               + (delta[0] + delta[1] + delta[2])
-                                               + "\n");
-
-                       VectorCopy(
-                               cl.frame.playerstate.pmove.origin,
-                               cl.predicted_origins[frame]);
+               else {
+                       if (cl_showmiss.value != 0.0f && (delta[0] != 0 || delta[1] != 0 || delta[2] != 0))
+                               Com.Printf("prediction miss on " + cl.frame.serverframe + ": " + (delta[0] + delta[1] + delta[2]) + "\n");
+
+                       VectorCopy(cl.frame.playerstate.pmove.origin, cl.predicted_origins[frame]);
 
                        // save for error itnerpolation
                        for (i = 0; i < 3; i++)
@@ -93,13 +78,7 @@ public class CL_pred extends CL_parse
        
        ====================
        */
-       static void ClipMoveToEntities(
-               float[] start,
-               float[] mins,
-               float[] maxs,
-               float[] end,
-               trace_t tr)
-       {
+       static void ClipMoveToEntities(float[] start, float[] mins, float[] maxs, float[] end, trace_t tr) {
                int i, x, zd, zu;
                trace_t trace;
                int headnode;
@@ -110,8 +89,7 @@ public class CL_pred extends CL_parse
                float[] bmins = new float[3];
                float[] bmaxs = new float[3];
 
-               for (i = 0; i < cl.frame.num_entities; i++)
-               {
+               for (i = 0; i < cl.frame.num_entities; i++) {
                        num = (cl.frame.parse_entities + i) & (MAX_PARSE_ENTITIES - 1);
                        ent = cl_parse_entities[num];
 
@@ -121,16 +99,14 @@ public class CL_pred extends CL_parse
                        if (ent.number == cl.playernum + 1)
                                continue;
 
-                       if (ent.solid == 31)
-                       { // special value for bmodel
+                       if (ent.solid == 31) { // special value for bmodel
                                cmodel = cl.model_clip[ent.modelindex];
                                if (cmodel == null)
                                        continue;
                                headnode = cmodel.headnode;
                                angles = ent.angles;
                        }
-                       else
-                       { // encoded bbox
+                       else { // encoded bbox
                                x = 8 * (ent.solid & 31);
                                zd = 8 * ((ent.solid >>> 5) & 31);
                                zu = 8 * ((ent.solid >>> 10) & 63) - 32;
@@ -147,31 +123,16 @@ public class CL_pred extends CL_parse
                        if (tr.allsolid)
                                return;
 
-                       trace =
-                               CM.TransformedBoxTrace(
-                                       start,
-                                       end,
-                                       mins,
-                                       maxs,
-                                       headnode,
-                                       MASK_PLAYERSOLID,
-                                       ent.origin,
-                                       angles);
-
-                       if (trace.allsolid
-                               || trace.startsolid
-                               || trace.fraction < tr.fraction)
-                       {
-                               // TODO bugfix cwei
-                               //if (trace.ent == null) trace.ent = new edict_t(0);
+                       trace = CM.TransformedBoxTrace(start, end, mins, maxs, headnode, MASK_PLAYERSOLID, ent.origin, angles);
+
+                       if (trace.allsolid || trace.startsolid || trace.fraction < tr.fraction) {
                                trace.ent = ent.surrounding_ent;
-                               if (tr.startsolid)
-                               {
-                                       tr = trace;
+                               if (tr.startsolid) {
+                                       tr.set(trace); // rst: solved the Z U P P E L - P R O B L E M
                                        tr.startsolid = true;
                                }
                                else
-                                       tr = trace;
+                                       tr.set(trace); // rst: solved the Z U P P E L - P R O B L E M 
                        }
                        else if (trace.startsolid)
                                tr.startsolid = true;
@@ -183,9 +144,9 @@ public class CL_pred extends CL_parse
        CL_PMTrace
        ================
        */
-       
-       static edict_t DUMMY_ENT = new edict_t(-1);
-       
+
+       public static edict_t DUMMY_ENT = new edict_t(-1);
+
        static trace_t PMTrace(float[] start, float[] mins, float[] maxs, float[] end) {
                trace_t t;
 
@@ -202,8 +163,14 @@ public class CL_pred extends CL_parse
                return t;
        }
 
-       static int PMpointcontents(float[] point)
-       {
+       /*
+       =================
+       PMpointcontents
+       
+       Returns the content identificator of the point.
+       =================
+       */
+       static int PMpointcontents(float[] point) {
                int i;
                entity_state_t ent;
                int num;
@@ -212,8 +179,7 @@ public class CL_pred extends CL_parse
 
                contents = CM.PointContents(point, 0);
 
-               for (i = 0; i < cl.frame.num_entities; i++)
-               {
+               for (i = 0; i < cl.frame.num_entities; i++) {
                        num = (cl.frame.parse_entities + i) & (MAX_PARSE_ENTITIES - 1);
                        ent = cl_parse_entities[num];
 
@@ -224,14 +190,8 @@ public class CL_pred extends CL_parse
                        if (cmodel == null)
                                continue;
 
-                       contents
-                               |= CM.TransformedPointContents(
-                                       point,
-                                       cmodel.headnode,
-                                       ent.origin,
-                                       ent.angles);
+                       contents |= CM.TransformedPointContents(point, cmodel.headnode, ent.origin, ent.angles);
                }
-
                return contents;
        }
 
@@ -242,8 +202,7 @@ public class CL_pred extends CL_parse
        Sets cl.predicted_origin and cl.predicted_angles
        =================
        */
-       static void PredictMovement()
-       {
+       static void PredictMovement() {
                int ack, current;
                int frame;
                int oldframe;
@@ -259,14 +218,10 @@ public class CL_pred extends CL_parse
                if (cl_paused.value != 0.0f)
                        return;
 
-               if (cl_predict.value == 0.0f
-                       || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0)
-               { // just set angles
-                       for (i = 0; i < 3; i++)
-                       {
-                               cl.predicted_angles[i] =
-                                       cl.viewangles[i]
-                                               + SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[i]);
+               if (cl_predict.value == 0.0f || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) {
+                       // just set angles
+                       for (i = 0; i < 3; i++) {
+                               cl.predicted_angles[i] = cl.viewangles[i] + SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[i]);
                        }
                        return;
                }
@@ -275,8 +230,7 @@ public class CL_pred extends CL_parse
                current = cls.netchan.outgoing_sequence;
 
                // if we are too far out of date, just freeze
-               if (current - ack >= CMD_BACKUP)
-               {
+               if (current - ack >= CMD_BACKUP) {
                        if (cl_showmiss.value != 0.0f)
                                Com.Printf("exceeded CMD_BACKUP\n");
                        return;
@@ -286,41 +240,32 @@ public class CL_pred extends CL_parse
                //memset (pm, 0, sizeof(pm));
                pm = new pmove_t();
 
-               pm.trace = new pmove_t.TraceAdapter()
-               {
-                       public trace_t trace(
-                               float[] start,
-                               float[] mins,
-                               float[] maxs,
-                               float[] end)
-                       {
+               pm.trace = new pmove_t.TraceAdapter() {
+                       public trace_t trace(float[] start, float[] mins, float[] maxs, float[] end) {
                                return CL.PMTrace(start, mins, maxs, end);
                        }
                };
-               pm.pointcontents = new pmove_t.PointContentsAdapter()
-               {
-                       public int pointcontents(float[] point)
-                       {
+               pm.pointcontents = new pmove_t.PointContentsAdapter() {
+                       public int pointcontents(float[] point) {
                                return CL.PMpointcontents(point);
                        }
                };
 
                PMove.pm_airaccelerate = atof(cl.configstrings[CS_AIRACCEL]);
 
-               // bugfix (rst) yeah !!!!!!!!  found the B E W E G U N G S P R O B L E M.  
+               // 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);
 
                // SCR_DebugGraph (current - ack - 1, 0);
                frame = 0;
 
                // run frames
-               while (++ack < current)
-               {
+               while (++ack < current) {
                        frame = ack & (CMD_BACKUP - 1);
                        cmd = cl.cmds[frame];
-                       
+
                        pm.cmd.set(cmd);
-                       
+
                        PMove.Pmove(pm);
 
                        // save for debug checking
@@ -330,8 +275,7 @@ public class CL_pred extends CL_parse
                oldframe = (ack - 2) & (CMD_BACKUP - 1);
                oldz = cl.predicted_origins[oldframe][2];
                step = pm.s.origin[2] - oldz;
-               if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) != 0)
-               {
+               if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) != 0) {
                        cl.predicted_step = step * 0.125f;
                        cl.predicted_step_time = (int) (cls.realtime - cls.frametime * 500);
                }
@@ -343,5 +287,4 @@ public class CL_pred extends CL_parse
 
                VectorCopy(pm.viewangles, cl.predicted_angles);
        }
-
 }
index d37bf5c..11a7a64 100644 (file)
@@ -2,7 +2,7 @@
  * Con.java
  * Copyright (C) 2003
  * 
- * $Id: Console.java,v 1.1 2004-07-07 19:58:41 hzi Exp $
+ * $Id: Console.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -398,7 +398,6 @@ public final class Console extends Globals {
        ================
        */
        static void DrawInput() {
-               int y;
                int i;
                byte[] text;
                int start = 0;
@@ -422,7 +421,7 @@ public final class Console extends Globals {
                        start += 1 + key_linepos - con.linewidth;
                  
                // draw it
-               y = con.vislines-16;
+//             y = con.vislines-16;
  
                for (i=0 ; i<con.linewidth ; i++)
                        re.DrawChar ( (i+1)<<3, con.vislines - 22, text[i]);
@@ -574,9 +573,7 @@ public final class Console extends Globals {
                                dlbar = cls.downloadname.substring(text);
                        }
                        dlbar += ": ";
-                       i = strlen(dlbar);
                        dlbar += (char)0x80;
-                       i++;
 
                        // where's the dot go?
                        if (cls.downloadpercent == 0)
index 33b25a2..2fe8ed3 100644 (file)
@@ -2,7 +2,7 @@
  * Key.java
  * Copyright (C) 2003
  * 
- * $Id: Key.java,v 1.1 2004-07-07 19:58:42 hzi Exp $
+ * $Id: Key.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -114,6 +114,7 @@ public class Key extends Globals {
        public static final int K_MWHEELDOWN = 239;
        public static final int K_MWHEELUP = 240;
 
+       static int anykeydown = 0;
        static int key_waiting;
        static int history_line = 0;
        static boolean shift_down = false;
@@ -369,12 +370,12 @@ public class Key extends Globals {
                Globals.keydown[key] = down;
                if (down) {
                        if (key_repeats[key] == 1)
-                               Globals.anykeydown++;
+                               Key.anykeydown++;
                }
                else {
-                       Globals.anykeydown--;
-                       if (Globals.anykeydown < 0)
-                               Globals.anykeydown = 0;
+                       Key.anykeydown--;
+                       if (Key.anykeydown < 0)
+                               Key.anykeydown = 0;
                }
 
                //
@@ -586,15 +587,17 @@ public class Key extends Globals {
                                Cbuf.AddText(
                                        new String(Globals.key_lines[Globals.edit_line], 1, Lib.strlen(Globals.key_lines[Globals.edit_line]) - 1));
 
+                       
                        Cbuf.AddText("\n");
-                       Com.Printf(new String(Globals.key_lines[Globals.edit_line], 0, Lib.strlen(Globals.key_lines[Globals.edit_line])));
+               
+                       Com.Printf(new String(Globals.key_lines[Globals.edit_line], 0, Lib.strlen(Globals.key_lines[Globals.edit_line])) + "\n");
                        Globals.edit_line = (Globals.edit_line + 1) & 31;
                        history_line = Globals.edit_line;
+               
                        Globals.key_lines[Globals.edit_line][0] = ']';
                        Globals.key_linepos = 1;
                        if (Globals.cls.state == Defines.ca_disconnected)
-                               SCR.UpdateScreen(); // force an update, because the command
-                       // may take some time
+                               SCR.UpdateScreen(); // force an update, because the command may take some time
                        return;
                }
 
@@ -791,7 +794,7 @@ public class Key extends Globals {
        static void ClearStates() {
                int i;
 
-               anykeydown = 0;
+               Key.anykeydown = 0;
 
                for (i = 0; i < 256; i++) {
                        if (keydown[i] || key_repeats[i]!=0)
index ebd9ebd..86747f8 100644 (file)
@@ -2,7 +2,7 @@
  * M.java
  * Copyright (C) 2003
  * 
- * $Id: M.java,v 1.1 2004-07-07 19:58:42 hzi Exp $
+ * $Id: M.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -27,6 +27,7 @@ package jake2.client;
 
 import jake2.Defines;
 import jake2.game.*;
+import jake2.qcommon.Com;
 import jake2.server.SV;
 import jake2.util.Lib;
 import jake2.util.Math3D;
@@ -34,16 +35,19 @@ import jake2.util.Math3D;
 /**
  * M
  */
-public final class M {
+public final class M
+{
 
-       public static void M_CheckGround(edict_t ent) {
+       public static void M_CheckGround(edict_t ent)
+       {
                float[] point = { 0, 0, 0 };
                trace_t trace;
 
                if ((ent.flags & (Defines.FL_SWIM | Defines.FL_FLY)) != 0)
                        return;
 
-               if (ent.velocity[2] > 100) {
+               if (ent.velocity[2] > 100)
+               {
                        ent.groundentity = null;
                        return;
                }
@@ -56,7 +60,8 @@ public final class M {
                trace = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, point, ent, Defines.MASK_MONSTERSOLID);
 
                // check steepness
-               if (trace.plane.normal[2] < 0.7 && !trace.startsolid) {
+               if (trace.plane.normal[2] < 0.7 && !trace.startsolid)
+               {
                        ent.groundentity = null;
                        return;
                }
@@ -65,7 +70,8 @@ public final class M {
                //              ent.groundentity_linkcount = trace.ent.linkcount;
                //              if (!trace.startsolid && !trace.allsolid)
                //                      VectorCopy (trace.endpos, ent.s.origin);
-               if (!trace.startsolid && !trace.allsolid) {
+               if (!trace.startsolid && !trace.allsolid)
+               {
                        Math3D.VectorCopy(trace.endpos, ent.s.origin);
                        ent.groundentity = trace.ent;
                        ent.groundentity_linkcount = trace.ent.linkcount;
@@ -73,7 +79,8 @@ public final class M {
                }
        }
 
-       public static boolean M_CheckBottom(edict_t ent) {
+       public static boolean M_CheckBottom(edict_t ent)
+       {
                float[] mins = { 0, 0, 0 };
                float[] maxs = { 0, 0, 0 };
                float[] start = { 0, 0, 0 };
@@ -91,10 +98,12 @@ public final class M {
                //         the corners must be within 16 of the midpoint
                start[2] = mins[2] - 1;
                for (x = 0; x <= 1; x++)
-                       for (y = 0; y <= 1; y++) {
+                       for (y = 0; y <= 1; y++)
+                       {
                                start[0] = x != 0 ? maxs[0] : mins[0];
                                start[1] = y != 0 ? maxs[1] : mins[1];
-                               if (GameBase.gi.pointcontents.pointcontents(start) != Defines.CONTENTS_SOLID) {
+                               if (GameBase.gi.pointcontents.pointcontents(start) != Defines.CONTENTS_SOLID)
+                               {
                                        GameBase.c_no++;
                                        //
                                        //         check it for real...
@@ -113,7 +122,8 @@ public final class M {
 
                                        //         the corners must be within 16 of the midpoint        
                                        for (x = 0; x <= 1; x++)
-                                               for (y = 0; y <= 1; y++) {
+                                               for (y = 0; y <= 1; y++)
+                                               {
                                                        start[0] = stop[0] = x != 0 ? maxs[0] : mins[0];
                                                        start[1] = stop[1] = y != 0 ? maxs[1] : mins[1];
 
@@ -146,8 +156,9 @@ public final class M {
        M_ChangeYaw
        
        ===============
-       *///ok
-       public static void M_ChangeYaw(edict_t ent) {
+       */ //ok
+       public static void M_ChangeYaw(edict_t ent)
+       {
                float ideal;
                float current;
                float move;
@@ -161,19 +172,23 @@ public final class M {
 
                move = ideal - current;
                speed = ent.yaw_speed;
-               if (ideal > current) {
+               if (ideal > current)
+               {
                        if (move >= 180)
                                move = move - 360;
                }
-               else {
+               else
+               {
                        if (move <= -180)
                                move = move + 360;
                }
-               if (move > 0) {
+               if (move > 0)
+               {
                        if (move > speed)
                                move = speed;
                }
-               else {
+               else
+               {
                        if (move < -speed)
                                move = -speed;
                }
@@ -185,8 +200,9 @@ public final class M {
        ======================
        M_MoveToGoal
        ======================
-       */
-       public static void M_MoveToGoal(edict_t ent, float dist) {
+       */ // ok
+       public static void M_MoveToGoal(edict_t ent, float dist)
+       {
                edict_t goal = ent.goalentity;
 
                if (ent.groundentity == null && (ent.flags & (Defines.FL_FLY | Defines.FL_SWIM)) == 0)
@@ -197,7 +213,8 @@ public final class M {
                        return;
 
                //         bump around...
-               if ((Lib.rand() & 3) == 1 || !SV.SV_StepDirection(ent, ent.ideal_yaw, dist)) {
+               if ((Lib.rand() & 3) == 1 || !SV.SV_StepDirection(ent, ent.ideal_yaw, dist))
+               {
                        if (ent.inuse)
                                SV.SV_NewChaseDir(ent, goal, dist);
                }
@@ -208,7 +225,8 @@ public final class M {
        M_walkmove
        ===============
        */
-       public static boolean M_walkmove(edict_t ent, float yaw, float dist) {
+       public static boolean M_walkmove(edict_t ent, float yaw, float dist)
+       {
                float[] move = { 0, 0, 0 };
 
                if ((ent.groundentity == null) && (ent.flags & (Defines.FL_FLY | Defines.FL_SWIM)) == 0)
@@ -223,7 +241,8 @@ public final class M {
                return SV.SV_movestep(ent, move, true);
        }
 
-       public static void M_CatagorizePosition(edict_t ent) {
+       public static void M_CatagorizePosition(edict_t ent)
+       {
                float[] point = { 0, 0, 0 };
                int cont;
 
@@ -235,7 +254,8 @@ public final class M {
                point[2] = ent.s.origin[2] + ent.mins[2] + 1;
                cont = Game.gi.pointcontents.pointcontents(point);
 
-               if (0 == (cont & Defines.MASK_WATER)) {
+               if (0 == (cont & Defines.MASK_WATER))
+               {
                        ent.waterlevel = 0;
                        ent.watertype = 0;
                        return;
@@ -255,17 +275,23 @@ public final class M {
                        ent.waterlevel = 3;
        }
 
-       public static void M_WorldEffects(edict_t ent) {
+       public static void M_WorldEffects(edict_t ent)
+       {
                int dmg;
 
-               if (ent.health > 0) {
-                       if (0 == (ent.flags & Defines.FL_SWIM)) {
-                               if (ent.waterlevel < 3) {
+               if (ent.health > 0)
+               {
+                       if (0 == (ent.flags & Defines.FL_SWIM))
+                       {
+                               if (ent.waterlevel < 3)
+                               {
                                        ent.air_finished = GameBase.level.time + 12;
                                }
-                               else if (ent.air_finished < GameBase.level.time) {
+                               else if (ent.air_finished < GameBase.level.time)
+                               {
                                        // drown!
-                                       if (ent.pain_debounce_time < GameBase.level.time) {
+                                       if (ent.pain_debounce_time < GameBase.level.time)
+                                       {
                                                dmg = (int) (2f + 2f * Math.floor(GameBase.level.time - ent.air_finished));
                                                if (dmg > 15)
                                                        dmg = 15;
@@ -284,13 +310,17 @@ public final class M {
                                        }
                                }
                        }
-                       else {
-                               if (ent.waterlevel > 0) {
+                       else
+                       {
+                               if (ent.waterlevel > 0)
+                               {
                                        ent.air_finished = GameBase.level.time + 9;
                                }
-                               else if (ent.air_finished < GameBase.level.time) {
+                               else if (ent.air_finished < GameBase.level.time)
+                               {
                                        // suffocate!
-                                       if (ent.pain_debounce_time < GameBase.level.time) {
+                                       if (ent.pain_debounce_time < GameBase.level.time)
+                                       {
                                                dmg = (int) (2 + 2 * Math.floor(GameBase.level.time - ent.air_finished));
                                                if (dmg > 15)
                                                        dmg = 15;
@@ -311,16 +341,20 @@ public final class M {
                        }
                }
 
-               if (ent.waterlevel == 0) {
-                       if ((ent.flags & Defines.FL_INWATER) != 0) {
+               if (ent.waterlevel == 0)
+               {
+                       if ((ent.flags & Defines.FL_INWATER) != 0)
+                       {
                                GameBase.gi.sound(ent, Defines.CHAN_BODY, GameBase.gi.soundindex("player/watr_out.wav"), 1, Defines.ATTN_NORM, 0);
                                ent.flags &= ~Defines.FL_INWATER;
                        }
                        return;
                }
 
-               if ((ent.watertype & Defines.CONTENTS_LAVA) != 0 && 0 == (ent.flags & Defines.FL_IMMUNE_LAVA)) {
-                       if (ent.damage_debounce_time < GameBase.level.time) {
+               if ((ent.watertype & Defines.CONTENTS_LAVA) != 0 && 0 == (ent.flags & Defines.FL_IMMUNE_LAVA))
+               {
+                       if (ent.damage_debounce_time < GameBase.level.time)
+                       {
                                ent.damage_debounce_time = GameBase.level.time + 0.2f;
                                GameUtil.T_Damage(
                                        ent,
@@ -335,8 +369,10 @@ public final class M {
                                        Defines.MOD_LAVA);
                        }
                }
-               if ((ent.watertype & Defines.CONTENTS_SLIME) != 0 && 0 == (ent.flags & Defines.FL_IMMUNE_SLIME)) {
-                       if (ent.damage_debounce_time < GameBase.level.time) {
+               if ((ent.watertype & Defines.CONTENTS_SLIME) != 0 && 0 == (ent.flags & Defines.FL_IMMUNE_SLIME))
+               {
+                       if (ent.damage_debounce_time < GameBase.level.time)
+                       {
                                ent.damage_debounce_time = GameBase.level.time + 1;
                                GameUtil.T_Damage(
                                        ent,
@@ -352,8 +388,10 @@ public final class M {
                        }
                }
 
-               if (0 == (ent.flags & Defines.FL_INWATER)) {
-                       if (0 == (ent.svflags & Defines.SVF_DEADMONSTER)) {
+               if (0 == (ent.flags & Defines.FL_INWATER))
+               {
+                       if (0 == (ent.svflags & Defines.SVF_DEADMONSTER))
+                       {
                                if ((ent.watertype & Defines.CONTENTS_LAVA) != 0)
                                        if (Lib.random() <= 0.5)
                                                GameBase.gi.sound(ent, Defines.CHAN_BODY, GameBase.gi.soundindex("player/lava1.wav"), 1, Defines.ATTN_NORM, 0);
@@ -370,8 +408,10 @@ public final class M {
                }
        }
 
-       public static EntThinkAdapter M_droptofloor = new EntThinkAdapter() {
-               public boolean think(edict_t ent) {
+       public static EntThinkAdapter M_droptofloor = new EntThinkAdapter()
+       {
+               public boolean think(edict_t ent)
+               {
                        float[] end = { 0, 0, 0 };
                        trace_t trace;
 
@@ -393,11 +433,13 @@ public final class M {
                }
        };
 
-       public static void M_SetEffects(edict_t ent) {
+       public static void M_SetEffects(edict_t ent)
+       {
                ent.s.effects &= ~(Defines.EF_COLOR_SHELL | Defines.EF_POWERSCREEN);
                ent.s.renderfx &= ~(Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE);
 
-               if ((ent.monsterinfo.aiflags & Defines.AI_RESURRECTING) != 0) {
+               if ((ent.monsterinfo.aiflags & Defines.AI_RESURRECTING) != 0)
+               {
                        ent.s.effects |= Defines.EF_COLOR_SHELL;
                        ent.s.renderfx |= Defines.RF_SHELL_RED;
                }
@@ -405,19 +447,24 @@ public final class M {
                if (ent.health <= 0)
                        return;
 
-               if (ent.powerarmor_time > GameBase.level.time) {
-                       if (ent.monsterinfo.power_armor_type == Defines.POWER_ARMOR_SCREEN) {
+               if (ent.powerarmor_time > GameBase.level.time)
+               {
+                       if (ent.monsterinfo.power_armor_type == Defines.POWER_ARMOR_SCREEN)
+                       {
                                ent.s.effects |= Defines.EF_POWERSCREEN;
                        }
-                       else if (ent.monsterinfo.power_armor_type == Defines.POWER_ARMOR_SHIELD) {
+                       else if (ent.monsterinfo.power_armor_type == Defines.POWER_ARMOR_SHIELD)
+                       {
                                ent.s.effects |= Defines.EF_COLOR_SHELL;
                                ent.s.renderfx |= Defines.RF_SHELL_GREEN;
                        }
                }
        };
 
-       public static void M_MoveFrame(edict_t self) {
-               mmove_t move;
+       //ok
+       public static void M_MoveFrame(edict_t self)
+       {
+               mmove_t move; //ptr
                int index;
 
                move = self.monsterinfo.currentmove;
@@ -425,13 +472,17 @@ public final class M {
 
                if ((self.monsterinfo.nextframe != 0)
                        && (self.monsterinfo.nextframe >= move.firstframe)
-                       && (self.monsterinfo.nextframe <= move.lastframe)) {
+                       && (self.monsterinfo.nextframe <= move.lastframe))
+               {
                        self.s.frame = self.monsterinfo.nextframe;
                        self.monsterinfo.nextframe = 0;
                }
-               else {
-                       if (self.s.frame == move.lastframe) {
-                               if (move.endfunc != null) {
+               else
+               {
+                       if (self.s.frame == move.lastframe)
+                       {
+                               if (move.endfunc != null)
+                               {
                                        move.endfunc.think(self);
 
                                        // regrab move, endfunc is very likely to change it
@@ -443,12 +494,15 @@ public final class M {
                                }
                        }
 
-                       if (self.s.frame < move.firstframe || self.s.frame > move.lastframe) {
+                       if (self.s.frame < move.firstframe || self.s.frame > move.lastframe)
+                       {
                                self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME;
                                self.s.frame = move.firstframe;
                        }
-                       else {
-                               if (0 == (self.monsterinfo.aiflags & Defines.AI_HOLD_FRAME)) {
+                       else
+                       {
+                               if (0 == (self.monsterinfo.aiflags & Defines.AI_HOLD_FRAME))
+                               {
                                        self.s.frame++;
                                        if (self.s.frame > move.lastframe)
                                                self.s.frame = move.firstframe;
@@ -467,7 +521,8 @@ public final class M {
                        move.frame[index].think.think(self);
        }
 
-       public static void M_ReactToDamage(edict_t targ, edict_t attacker) {
+       public static void M_ReactToDamage(edict_t targ, edict_t attacker)
+       {
                if ((null != attacker.client) && 0 != (attacker.svflags & Defines.SVF_MONSTER))
                        return;
 
@@ -476,7 +531,8 @@ public final class M {
 
                // if we are a good guy monster and our attacker is a player
                // or another good guy, do not get mad at them
-               if (0 != (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) {
+               if (0 != (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY))
+               {
                        if (attacker.client != null || (attacker.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0)
                                return;
                }
@@ -484,20 +540,23 @@ public final class M {
                // we now know that we are not both good guys
 
                // if attacker is a client, get mad at them because he's good and we're not
-               if (attacker.client != null) {
+               if (attacker.client != null)
+               {
                        targ.monsterinfo.aiflags &= ~Defines.AI_SOUND_TARGET;
 
                        // this can only happen in coop (both new and old enemies are clients)
                        // only switch if can't see the current enemy
-                       if (targ.enemy != null && targ.enemy.client != null) {
-                               if (GameUtil.visible(targ, targ.enemy)) {
+                       if (targ.enemy != null && targ.enemy.client != null)
+                       {
+                               if (GameUtil.visible(targ, targ.enemy))
+                               {
                                        targ.oldenemy = attacker;
                                        return;
                                }
                                targ.oldenemy = targ.enemy;
                        }
                        targ.enemy = attacker;
-                       if (0 != (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
+                       if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
                                GameUtil.FoundTarget(targ);
                        return;
                }
@@ -509,7 +568,8 @@ public final class M {
                        && (Lib.strcmp(attacker.classname, "monster_tank") != 0)
                        && (Lib.strcmp(attacker.classname, "monster_supertank") != 0)
                        && (Lib.strcmp(attacker.classname, "monster_makron") != 0)
-                       && (Lib.strcmp(attacker.classname, "monster_jorg") != 0)) {
+                       && (Lib.strcmp(attacker.classname, "monster_jorg") != 0))
+               {
                        if (targ.enemy != null && targ.enemy.client != null)
                                targ.oldenemy = targ.enemy;
                        targ.enemy = attacker;
@@ -517,7 +577,8 @@ public final class M {
                                GameUtil.FoundTarget(targ);
                }
                // if they *meant* to shoot us, then shoot back
-               else if (attacker.enemy == targ) {
+               else if (attacker.enemy == targ)
+               {
                        if (targ.enemy != null && targ.enemy.client != null)
                                targ.oldenemy = targ.enemy;
                        targ.enemy = attacker;
@@ -525,7 +586,8 @@ public final class M {
                                GameUtil.FoundTarget(targ);
                }
                // otherwise get mad at whoever they are mad at (help our buddy) unless it is us!
-               else if (attacker.enemy != null && attacker.enemy != targ) {
+               else if (attacker.enemy != null && attacker.enemy != targ)
+               {
                        if (targ.enemy != null && targ.enemy.client != null)
                                targ.oldenemy = targ.enemy;
                        targ.enemy = attacker.enemy;
@@ -534,16 +596,20 @@ public final class M {
                }
        }
        /** Stops the Flies. */
-       public static EntThinkAdapter M_FliesOff = new EntThinkAdapter() {
-               public boolean think(edict_t self) {
+       public static EntThinkAdapter M_FliesOff = new EntThinkAdapter()
+       {
+               public boolean think(edict_t self)
+               {
                        self.s.effects &= ~Defines.EF_FLIES;
                        self.s.sound = 0;
                        return true;
                }
        };
        /** Starts the Flies as setting the animation flag in the entity. */
-       public static EntThinkAdapter M_FliesOn = new EntThinkAdapter() {
-               public boolean think(edict_t self) {
+       public static EntThinkAdapter M_FliesOn = new EntThinkAdapter()
+       {
+               public boolean think(edict_t self)
+               {
                        if (self.waterlevel != 0)
                                return true;
 
@@ -555,8 +621,10 @@ public final class M {
                }
        };
        /** Adds some flies after a random time */
-       public static EntThinkAdapter M_FlyCheck = new EntThinkAdapter() {
-               public boolean think(edict_t self) {
+       public static EntThinkAdapter M_FlyCheck = new EntThinkAdapter()
+       {
+               public boolean think(edict_t self)
+               {
 
                        if (self.waterlevel != 0)
                                return true;
@@ -569,5 +637,4 @@ public final class M {
                        return true;
                }
        };
-       
 }
index 264d38f..8ac689f 100644 (file)
@@ -2,7 +2,7 @@
  * Menu.java
  * Copyright (C) 2004
  * 
- * $Id: Menu.java,v 1.1 2004-07-07 19:58:51 hzi Exp $
+ * $Id: Menu.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -90,9 +90,8 @@ public final class Menu extends Key {
 
        }
 
-       static class mcallback {
-               public void execute(Object self) {
-               }
+       abstract static class mcallback {
+               abstract public void execute(Object self);
        }
 
        static class menucommon_s {
@@ -149,8 +148,6 @@ public final class Menu extends Key {
        public static int m_menudepth;
 
        static void Banner(String name) {
-               int w, h;
-
                Dimension dim = new Dimension();
                Globals.re.DrawGetPicSize(dim, name);
 
@@ -723,7 +720,6 @@ public final class Menu extends Key {
 
        static void UnbindCommand(String command) {
                int j;
-               int l;
                String b;
 
                for (j = 0; j < 256; j++) {
@@ -738,7 +734,6 @@ public final class Menu extends Key {
        static void FindKeysForCommand(String command, int twokeys[]) {
                int count;
                int j;
-               int l;
                String b;
 
                twokeys[0] = twokeys[1] = -1;
@@ -782,7 +777,7 @@ public final class Menu extends Key {
 
                        Menu_DrawString(a.x + a.parent.x + 16, a.y + a.parent.y, name);
 
-                       x = strlen(name) * 8;
+                       x = name.length() * 8;
 
                        if (keys[1] != -1) {
                                Menu_DrawString(a.x + a.parent.x + 24 + x, a.y + a.parent.y, "or");
@@ -2023,7 +2018,7 @@ public final class Menu extends Key {
                        for (j = 0; j + stringoffset < credits[i].length(); j++) {
                                int x;
 
-                               x = (viddef.width - strlen(credits[i]) * 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);
@@ -2057,8 +2052,6 @@ public final class Menu extends Key {
        };
        static void Menu_Credits_f() {
                int n;
-               int count;
-               String p;
                int isdeveloper = 0;
 
                byte b[] = FS.LoadFile("credits");
@@ -2811,10 +2804,8 @@ public final class Menu extends Key {
                //        =======
                
                byte[] buffer = null;
-               //char mapsname[1024];
                String mapsname;
                String s;
-               int length;
                int i;
                RandomAccessFile fp;
 
@@ -4061,7 +4052,7 @@ public final class Menu extends Key {
                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 = strlen(name.string);
+               s_player_name_field.cursor = name.string.length();
 
                s_player_model_title.type = MTYPE_SEPARATOR;
                s_player_model_title.name = "model";
@@ -4747,7 +4738,7 @@ public final class Menu extends Key {
 
        public static void Menu_DrawStatusBar(String string) {
                if (string != null) {
-                       int l = strlen(string);
+                       int l = string.length();
                        int maxrow = viddef.height / 8;
                        int maxcol = viddef.width / 8;
                        int col = maxcol / 2 - l / 2;
@@ -4763,7 +4754,7 @@ public final class Menu extends Key {
        public static void Menu_DrawString(int x, int y, String string) {
                int i;
 
-               for (i = 0; i < strlen(string); i++) {
+               for (i = 0; i < string.length(); i++) {
                        re.DrawChar((x + i * 8), y, string.charAt(i));
                }
        }
@@ -4771,7 +4762,7 @@ public final class Menu extends Key {
        public static void Menu_DrawStringDark(int x, int y, String string) {
                int i;
 
-               for (i = 0; i < strlen(string); i++) {
+               for (i = 0; i < string.length(); i++) {
                        re.DrawChar((x + i * 8), y, string.charAt(i) + 128);
                }
        }
@@ -4779,16 +4770,18 @@ public final class Menu extends Key {
        public static void Menu_DrawStringR2L(int x, int y, String string) {
                int i;
 
-               for (i = 0; i < strlen(string); i++) {
-                       re.DrawChar((x - i * 8), y, string.charAt(strlen(string) - i - 1));
+               int l = string.length();
+               for (i = 0; i < l; i++) {
+                       re.DrawChar((x - i * 8), y, string.charAt(l - i - 1));
                }
        }
 
        public static void Menu_DrawStringR2LDark(int x, int y, String string) {
                int i;
 
-               for (i = 0; i < strlen(string); i++) {
-                       re.DrawChar((x - i * 8), y, string.charAt(strlen(string) - i - 1) + 128);
+               int l = string.length();
+               for (i = 0; i < l; i++) {
+                       re.DrawChar((x - i * 8), y, string.charAt(l - i - 1) + 128);
                }
        }
 
index 9755008..8363f6e 100644 (file)
@@ -2,9 +2,9 @@
  * SCR.java
  * Copyright (C) 2003
  * 
- * $Id: SCR.java,v 1.1 2004-07-07 19:58:51 hzi Exp $
+ * $Id: SCR.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
- /*
+/*
 Copyright (C) 1997-2001 Id Software, Inc.
 
 This program is free software; you can redistribute it and/or
@@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 */
 
-
 package jake2.client;
 
 import jake2.Globals;
@@ -39,17 +38,15 @@ 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 = 
-               {
-                       {"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"}
-               };
+
+       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" }
+       };
 
        /*
          full screen console
@@ -58,14 +55,14 @@ public final class SCR extends Globals {
          blanked background with menu
          cinematics
          full screen image for quit and victory
-
+       
          end of unit intermissions
        */
 
-       static float scr_con_current;   // aproaches scr_conlines at scr_conspeed
-       static float scr_conlines;              // 0.0 to 1.0 lines of console to display
+       static float scr_con_current; // aproaches scr_conlines at scr_conspeed
+       static float scr_conlines; // 0.0 to 1.0 lines of console to display
 
-       static boolean scr_initialized;         // ready to draw
+       static boolean scr_initialized; // ready to draw
 
        static int scr_draw_loading;
 
@@ -86,9 +83,11 @@ public final class SCR extends Globals {
        static cvar_t scr_graphscale;
        static cvar_t scr_graphshift;
        static cvar_t scr_drawall;
+       static cvar_t fps;
+       static cvar_t fps_updates;
 
        static dirty_t scr_dirty = new dirty_t();
-       static dirty_t[] scr_old_dirty = { new dirty_t(), 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;
@@ -103,28 +102,28 @@ public final class SCR extends Globals {
 
        /*
        ===============================================================================
-
+       
        BAR GRAPHS
-
+       
        ===============================================================================
        */
 
-
-//     typedef struct
-//     {
-//             float   value;
-//             int             color;
-//     } graphsamp_t;
-       static class graphsamp_t {
+       //      typedef struct
+       //      {
+       //              float   value;
+       //              int             color;
+       //      } graphsamp_t;
+       static class graphsamp_t
+       {
                float value;
                int color;
        }
        static int current;
        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();
        }
 
        /*
@@ -132,9 +131,10 @@ 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++;
        }
 
@@ -143,7 +143,8 @@ 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;
@@ -154,9 +155,10 @@ public final class SCR extends Globals {
 
                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);
+               re.DrawFill(x, (int) (y - scr_graphheight.value), w, (int) scr_graphheight.value, 8);
 
-               for (a = 0; a < w; a++) {
+               for (a = 0; a < w; a++)
+               {
                        i = (current - 1 - a + 1024) & 1023;
                        v = values[i].value;
                        color = values[i].color;
@@ -164,22 +166,22 @@ public final class SCR extends Globals {
 
                        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);
                }
        }
 
        /*
        ===============================================================================
-
+       
        CENTER PRINTING
-
+       
        ===============================================================================
        */
 
        // char scr_centerstring[1024];
        static String scr_centerstring;
-       static float scr_centertime_start;      // for slow victory printing
+       static float scr_centertime_start; // for slow victory printing
        static float scr_centertime_off;
        static int scr_center_lines;
        static int scr_erase_center;
@@ -187,12 +189,13 @@ public final class SCR extends Globals {
        /*
        ==============
        SCR_CenterPrint
-
+       
        Called for important messages that should stay in the center of the screen
        for a few moments
        ==============
        */
-       static void CenterPrint(String str) {
+       static void CenterPrint(String str)
+       {
                //char  *s;
                int s;
                StringBuffer line = new StringBuffer(64);
@@ -206,7 +209,8 @@ public final class SCR extends Globals {
                // count the number of lines for centering
                scr_center_lines = 1;
                s = 0;
-               while (s < str.length()) {
+               while (s < str.length())
+               {
                        if (str.charAt(s) == '\n')
                                scr_center_lines++;
                        s++;
@@ -217,10 +221,11 @@ public final class SCR extends Globals {
                        "\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;
-               
+
                if (str.length() != 0)
                {
-                       do {
+                       do
+                       {
                                // scan the width of the line
 
                                for (l = 0; l < 40 && (l + s) < str.length(); l++)
@@ -228,18 +233,19 @@ public final class SCR extends Globals {
                                                break;
                                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));
                                }
-       
+
                                line.append('\n');
-       
+
                                Com.Printf(line.toString());
-       
+
                                while (s < str.length() && str.charAt(s) != '\n')
                                        s++;
-       
+
                                if (s == str.length())
                                        break;
                                s++; // skip the \n
@@ -251,8 +257,9 @@ 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;
@@ -275,15 +282,16 @@ public final class SCR extends Globals {
                else
                        y = 48;
 
-               do {
+               do
+               {
                        // scan the width of the line
                        for (l = 0; l < 40; l++)
-
                                if (start + l == cs.length() - 1 || cs.charAt(start + l) == '\n')
                                        break;
                        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;
@@ -306,19 +314,19 @@ public final class SCR extends Globals {
        static void CheckDrawCenterString()
        {
                scr_centertime_off -= cls.frametime;
-       
+
                if (scr_centertime_off <= 0)
                        return;
 
                DrawCenterString();
        }
 
-// =============================================================================
+       // =============================================================================
 
        /*
        =================
        SCR_CalcVrect
-
+       
        Sets scr_vrect, the coordinates of the rendered window
        =================
        */
@@ -328,59 +336,57 @@ public final class SCR extends Globals {
 
                // bound viewsize
                if (scr_viewsize.value < 40)
-                       Cvar.Set ("viewsize","40");
+                       Cvar.Set("viewsize", "40");
                if (scr_viewsize.value > 100)
-                       Cvar.Set ("viewsize","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;
        }
 
-
        /*
        =================
        SCR_SizeUp_f
-
+       
        Keybinding command
        =================
        */
        static void SizeUp_f()
        {
-               Cvar.SetValue("viewsize",scr_viewsize.value+10);
+               Cvar.SetValue("viewsize", scr_viewsize.value + 10);
        }
 
-
        /*
        =================
        SCR_SizeDown_f
-
+       
        Keybinding command
        =================
        */
        static void SizeDown_f()
        {
-               Cvar.SetValue("viewsize",scr_viewsize.value-10);
+               Cvar.SetValue("viewsize", scr_viewsize.value - 10);
        }
 
        /*
        =================
        SCR_Sky_f
-
+       
        Set a specific sky and rotation speed
        =================
        */
        static void Sky_f()
        {
-               float   rotate;
-               float[] axis = {0, 0, 0};
+               float rotate;
+               float[] axis = { 0, 0, 0 };
 
                if (Cmd.Argc() < 2)
                {
@@ -407,53 +413,66 @@ public final class SCR extends Globals {
                re.SetSky(Cmd.Argv(1), rotate, axis);
        }
 
-// ============================================================================
+       // ============================================================================
 
        /*
        ==================
        SCR_Init
        ==================
        */
-       static void 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);
+               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);
+               fps_updates = Cvar.Get("fps_updates", "1", 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();
                        }
                });
@@ -461,7 +480,6 @@ public final class SCR extends Globals {
                scr_initialized = true;
        }
 
-
        /*
        ==============
        SCR_DrawNet
@@ -469,11 +487,10 @@ public final class SCR extends Globals {
        */
        static void DrawNet()
        {
-               if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged 
-                       < CMD_BACKUP - 1)
+               if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP - 1)
                        return;
 
-               re.DrawPic(scr_vrect.x+64, scr_vrect.y, "net");
+               re.DrawPic(scr_vrect.x + 64, scr_vrect.y, "net");
        }
 
        /*
@@ -485,14 +502,14 @@ public final class SCR extends Globals {
        {
                Dimension dim = new Dimension();
 
-               if (scr_showpause.value == 0)   // turn off for screenshots
+               if (scr_showpause.value == 0) // turn off for screenshots
                        return;
 
                if (cl_paused.value == 0)
                        return;
 
-               re.DrawGetPicSize (dim, "pause");
-               re.DrawPic ((viddef.width - dim.width) / 2, viddef.height / 2 + 8, "pause");
+               re.DrawGetPicSize(dim, "pause");
+               re.DrawPic((viddef.width - dim.width) / 2, viddef.height / 2 + 8, "pause");
        }
 
        /*
@@ -503,41 +520,42 @@ public final class SCR extends Globals {
        static void DrawLoading()
        {
                Dimension dim = new Dimension();
-               
+
                if (scr_draw_loading == 0)
                        return;
 
                scr_draw_loading = 0;
                re.DrawGetPicSize(dim, "loading");
-               re.DrawPic ((viddef.width - dim.width)/2, (viddef.height - dim.height)/2, "loading");
+               re.DrawPic((viddef.width - dim.width) / 2, (viddef.height - dim.height) / 2, "loading");
        }
 
-// =============================================================================
+       // =============================================================================
 
        /*
        ==================
        SCR_RunConsole
-
+       
        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)
                {
-                       scr_con_current -= scr_conspeed.value*cls.frametime;
+                       scr_con_current -= scr_conspeed.value * cls.frametime;
                        if (scr_conlines > scr_con_current)
                                scr_con_current = scr_conlines;
 
                }
                else if (scr_conlines > scr_con_current)
                {
-                       scr_con_current += scr_conspeed.value*cls.frametime;
+                       scr_con_current += scr_conspeed.value * cls.frametime;
                        if (scr_conlines < scr_con_current)
                                scr_con_current = scr_conlines;
                }
@@ -551,17 +569,17 @@ public final class SCR extends Globals {
        static void DrawConsole()
        {
                Console.CheckResize();
-       
+
                if (cls.state == ca_disconnected || cls.state == ca_connecting)
-               {       // forced full screen console
+               { // forced full screen console
                        Console.DrawConsole(1.0f);
                        return;
                }
 
                if (cls.state != ca_active || !cl.refresh_prepped)
-               {       // connected, but can't render
+               { // connected, but can't render
                        Console.DrawConsole(0.5f);
-                       re.DrawFill (0, viddef.height/2, viddef.width, viddef.height/2, 0);
+                       re.DrawFill(0, viddef.height / 2, viddef.width, viddef.height / 2, 0);
                        return;
                }
 
@@ -572,33 +590,35 @@ public final class SCR extends Globals {
                else
                {
                        if (cls.key_dest == key_game || cls.key_dest == key_message)
-                       Console.DrawNotify();   // only draw notify in game
+                               Console.DrawNotify(); // only draw notify in game
                }
        }
 
-// =============================================================================
+       // =============================================================================
 
        /*
        ================
        SCR_BeginLoadingPlaque
        ================
        */
-       public static void BeginLoadingPlaque() {
-               S.StopAllSounds ();
+       public static void BeginLoadingPlaque()
+       {
+               S.StopAllSounds();
                cl.sound_prepped = false; // don't play ambients
-               CDAudio.Stop();
+
                if (cls.disable_screen != 0)
                        return;
                if (developer.value != 0)
                        return;
                if (cls.state == ca_disconnected)
-                       return; // if at console, don't bring up the plaque
+                       return; // if at console, don't bring up the plaque
                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;
+
                UpdateScreen();
                cls.disable_screen = Sys.Milliseconds();
                cls.disable_servercount = cl.servercount;
@@ -609,7 +629,8 @@ public final class SCR extends Globals {
        SCR_EndLoadingPlaque
        ================
        */
-       public static void EndLoadingPlaque() {
+       public static void EndLoadingPlaque()
+       {
                cls.disable_screen = 0;
                Console.ClearNotify();
        }
@@ -629,7 +650,8 @@ public final class SCR extends Globals {
        SCR_TimeRefresh_f
        ================
        */
-       static void TimeRefresh_f() {
+       static void TimeRefresh_f()
+       {
                int i;
                int start, stop;
                float time;
@@ -639,15 +661,20 @@ public final class SCR extends Globals {
 
                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++) {
+                       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++) {
+               }
+               else
+               {
+                       for (i = 0; i < 128; i++)
+                       {
                                cl.refdef.viewangles[1] = i / 128.0f * 360.0f;
 
                                re.BeginFrame(0);
@@ -661,15 +688,16 @@ public final class SCR extends Globals {
                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);
+               AddDirtyPoint(viddef.width - 1, viddef.height - 1);
        }
 
        /*
        ==============
        SCR_TileClear
-
+       
        Clear any parts of the tiled background that were drawn on last frame
        ==============
        */
@@ -680,19 +708,19 @@ public final class SCR extends Globals {
                dirty_t clear = new dirty_t();
 
                if (scr_drawall.value != 0)
-                       DirtyScreen (); // for power vr or broken page flippers...
+                       DirtyScreen(); // for power vr or broken page flippers...
 
                if (scr_con_current == 1.0f)
-                       return;         // full screen console
+                       return; // full screen console
                if (scr_viewsize.value == 100)
-                       return;         // full screen rendering
+                       return; // full screen rendering
                if (cl.cinematictime > 0)
-                       return;         // full screen cinematic
+                       return; // full screen cinematic
 
                // erase rect will be the union of the past three frames
                // so tripple buffering works properly
                clear = 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;
@@ -713,55 +741,50 @@ public final class SCR extends Globals {
                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;
 
                if (clear.y2 <= clear.y1)
-                       return;         // nothing disturbed
+                       return; // nothing disturbed
 
                top = scr_vrect.y;
-               bottom = top + scr_vrect.height-1;
+               bottom = top + scr_vrect.height - 1;
                left = scr_vrect.x;
-               right = left + scr_vrect.width-1;
+               right = left + scr_vrect.width - 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 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;
                }
                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 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;
                }
                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 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;
                }
                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 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;
                }
 
        }
 
-
-// ===============================================================
+       // ===============================================================
 
        static final int STAT_MINUS = 10; // num frame for '-' stats digit
 
-       static final int ICON_WIDTH     = 24;
+       static final int ICON_WIDTH = 24;
        static final int ICON_HEIGHT = 24;
        static final int CHAR_WIDTH = 16;
        static final int ICON_SPACE = 8;
@@ -769,22 +792,27 @@ public final class SCR extends Globals {
        /*
        ================
        SizeHUDString
-
+       
        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;
 
                current = 0;
-               for (int i = 0; i < string.length(); i++) {
-                       if (string.charAt(i) == '\n') {
+               for (int i = 0; i < string.length(); i++)
+               {
+                       if (string.charAt(i) == '\n')
+                       {
                                lines++;
                                current = 0;
-                       } else {
+                       }
+                       else
+                       {
                                current++;
                                if (current > width)
                                        width = current;
@@ -796,7 +824,8 @@ public final class SCR extends Globals {
                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);
@@ -804,7 +833,8 @@ public final class SCR extends Globals {
 
                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);
                        while (string.charAt(l) != '\n')
@@ -815,11 +845,13 @@ public final class SCR extends Globals {
                                x = margin + (centerwidth - line.length() * 8) / 2;
                        else
                                x = margin;
-                       for (i = 0; i < line.length(); i++) {
+                       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;
                                y += 8;
@@ -827,7 +859,6 @@ public final class SCR extends Globals {
                }
        }
 
-
        /*
        ==============
        SCR_DrawField
@@ -836,7 +867,6 @@ public final class SCR extends Globals {
        static void DrawField(int x, int y, int color, int width, int value)
        {
                char ptr;
-               int ptrp;
                String num;
                int l;
                int frame;
@@ -855,10 +885,10 @@ public final class SCR extends Globals {
                l = num.length();
                if (l > width)
                        l = width;
-               x += 2 + CHAR_WIDTH*(width - l);
+               x += 2 + CHAR_WIDTH * (width - l);
 
                ptr = num.charAt(0);
-               ptrp = 0;
+
                for (int i = 0; i < l; i++)
                {
                        ptr = num.charAt(i);
@@ -867,7 +897,7 @@ public final class SCR extends Globals {
                        else
                                frame = ptr - '0';
 
-                       re.DrawPic (x,y,sb_nums[color][frame]);
+                       re.DrawPic(x, y, sb_nums[color][frame]);
                        x += CHAR_WIDTH;
                }
        }
@@ -875,58 +905,59 @@ public final class SCR extends Globals {
        /*
        ===============
        SCR_TouchPics
-
+       
        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_pic = "ch" + (int)crosshair.value;
-               Dimension dim = new Dimension();
-               re.DrawGetPicSize(dim, crosshair_pic);
-               crosshair_width = dim.width;
-               crosshair_height = dim.height;
-               if (crosshair_width == 0)
-                       crosshair_pic = "";
+
+                       crosshair_pic = "ch" + (int) crosshair.value;
+                       Dimension dim = new Dimension();
+                       re.DrawGetPicSize(dim, crosshair_pic);
+                       crosshair_width = dim.width;
+                       crosshair_height = dim.height;
+                       if (crosshair_width == 0)
+                               crosshair_pic = "";
                }
        }
 
-
        /*
        ================
        SCR_ExecuteLayoutString 
-
+       
        ================
        */
        static void ExecuteLayoutString(String s)
        {
-               int             x, y;
-               int             value;
+               int x, y;
+               int value;
                String token;
-               int             width;
-               int             index;
-               clientinfo_t    ci;
+               int width;
+               int index;
+               clientinfo_t ci;
 
                if (cls.state != ca_active || !cl.refresh_prepped)
                        return;
 
-//             if (!s[0])
+               //              if (!s[0])
                if (s == null || s.length() == 0)
                        return;
 
                x = 0;
                y = 0;
                width = 3;
-               
+
                Com.ParseHelp ph = new Com.ParseHelp(s);
 
                while (!ph.isEof())
@@ -947,7 +978,7 @@ public final class SCR extends Globals {
                        if (token.equals("xv"))
                        {
                                token = Com.Parse(ph);
-                               x = viddef.width/2 - 160 + atoi(token);
+                               x = viddef.width / 2 - 160 + atoi(token);
                                continue;
                        }
 
@@ -966,40 +997,40 @@ public final class SCR extends Globals {
                        if (token.equals("yv"))
                        {
                                token = Com.Parse(ph);
-                               y = viddef.height/2 - 120 + atoi(token);
+                               y = viddef.height / 2 - 120 + atoi(token);
                                continue;
                        }
 
                        if (token.equals("pic"))
-                       {       // draw a pic from a stat number
+                       { // 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)
+                                       Com.Error(ERR_DROP, "Pic >= MAX_IMAGES");
+                               if (cl.configstrings[CS_IMAGES + value] != null)
                                {
-                                       AddDirtyPoint (x, y);
-                                       AddDirtyPoint (x+23, y+23);
-                                       re.DrawPic (x, y, cl.configstrings[CS_IMAGES+value]);
+                                       AddDirtyPoint(x, y);
+                                       AddDirtyPoint(x + 23, y + 23);
+                                       re.DrawPic(x, y, cl.configstrings[CS_IMAGES + value]);
                                }
                                continue;
                        }
 
                        if (token.equals("client"))
-                       {       // draw a deathmatch client block
-                               int             score, ping, time;
+                       { // draw a deathmatch client block
+                               int score, ping, time;
 
                                token = Com.Parse(ph);
-                               x = viddef.width/2 - 160 + atoi(token);
+                               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);
+                               y = viddef.height / 2 - 120 + atoi(token);
+                               AddDirtyPoint(x, y);
+                               AddDirtyPoint(x + 159, y + 31);
 
                                token = Com.Parse(ph);
                                value = atoi(token);
                                if (value >= MAX_CLIENTS || value < 0)
-                                       Com.Error (ERR_DROP, "client >= MAX_CLIENTS");
+                                       Com.Error(ERR_DROP, "client >= MAX_CLIENTS");
                                ci = cl.clientinfo[value];
 
                                token = Com.Parse(ph);
@@ -1011,33 +1042,33 @@ public final class SCR extends Globals {
                                token = Com.Parse(ph);
                                time = atoi(token);
 
-                               Console.DrawAltString (x+32, y, ci.name);
-                               Console.DrawString (x+32, y+8,  "Score: ");
-                               Console.DrawAltString (x+32+7*8, y+8,  "" + score);
-                               Console.DrawString (x+32, y+16, "Ping:  " + ping);
-                               Console.DrawString (x+32, y+24, "Time:  " + time);
+                               Console.DrawAltString(x + 32, y, ci.name);
+                               Console.DrawString(x + 32, y + 8, "Score: ");
+                               Console.DrawAltString(x + 32 + 7 * 8, y + 8, "" + score);
+                               Console.DrawString(x + 32, y + 16, "Ping:  " + ping);
+                               Console.DrawString(x + 32, y + 24, "Time:  " + time);
 
                                if (ci.icon == null)
                                        ci = cl.baseclientinfo;
-                               re.DrawPic (x, y, ci.iconname);
+                               re.DrawPic(x, y, ci.iconname);
                                continue;
                        }
 
                        if (token.equals("ctf"))
-                       {       // draw a ctf client block
-                               int             score, ping;
+                       { // draw a ctf client block
+                               int score, ping;
 
                                token = Com.Parse(ph);
-                               x = viddef.width/2 - 160 + atoi(token);
+                               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);
+                               y = viddef.height / 2 - 120 + atoi(token);
+                               AddDirtyPoint(x, y);
+                               AddDirtyPoint(x + 159, y + 31);
 
                                token = Com.Parse(ph);
                                value = atoi(token);
                                if (value >= MAX_CLIENTS || value < 0)
-                                       Com.Error (ERR_DROP, "client >= MAX_CLIENTS");
+                                       Com.Error(ERR_DROP, "client >= MAX_CLIENTS");
                                ci = cl.clientinfo[value];
 
                                token = Com.Parse(ph);
@@ -1052,142 +1083,141 @@ public final class SCR extends Globals {
                                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);
+                                       Console.DrawAltString(x, y, block);
                                else
-                                       Console.DrawString (x, y, block);
+                                       Console.DrawString(x, y, block);
                                continue;
                        }
 
                        if (token.equals("picn"))
-                       {       // draw a pic from a name
+                       { // draw a pic from a name
                                token = Com.Parse(ph);
-                               AddDirtyPoint (x, y);
-                               AddDirtyPoint (x+23, y+23);
-                               re.DrawPic (x, y, token);
+                               AddDirtyPoint(x, y);
+                               AddDirtyPoint(x + 23, y + 23);
+                               re.DrawPic(x, y, token);
                                continue;
                        }
 
                        if (token.equals("num"))
-                       {       // draw a number
+                       { // 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);
+                               DrawField(x, y, 0, width, value);
                                continue;
                        }
 
                        if (token.equals("hnum"))
-                       {       // health number
-                               int             color;
+                       { // health number
+                               int color;
 
                                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;
 
                                if ((cl.frame.playerstate.stats[STAT_FLASHES] & 1) != 0)
-                                       re.DrawPic (x, y, "field_3");
+                                       re.DrawPic(x, y, "field_3");
 
-                               DrawField (x, y, color, width, value);
+                               DrawField(x, y, color, width, value);
                                continue;
                        }
 
                        if (token.equals("anum"))
-                       {       // ammo number
-                               int             color;
+                       { // ammo number
+                               int color;
 
                                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
+                                       continue; // negative number = don't show
 
                                if ((cl.frame.playerstate.stats[STAT_FLASHES] & 4) != 0)
-                                       re.DrawPic (x, y, "field_3");
+                                       re.DrawPic(x, y, "field_3");
 
-                               DrawField (x, y, color, width, value);
+                               DrawField(x, y, color, width, value);
                                continue;
                        }
 
                        if (token.equals("rnum"))
-                       {       // armor number
-                               int             color;
+                       { // armor number
+                               int color;
 
                                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");
+                                       re.DrawPic(x, y, "field_3");
 
-                               DrawField (x, y, color, width, value);
+                               DrawField(x, y, color, width, value);
                                continue;
                        }
 
-
                        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");
+                                       Com.Error(ERR_DROP, "Bad stat_string 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]);
+                                       Com.Error(ERR_DROP, "Bad stat_string index");
+                               Console.DrawString(x, y, cl.configstrings[index]);
                                continue;
                        }
 
                        if (token.equals("cstring"))
                        {
                                token = Com.Parse(ph);
-                               DrawHUDString (token, x, y, 320, 0);
+                               DrawHUDString(token, x, y, 320, 0);
                                continue;
                        }
 
                        if (token.equals("string"))
                        {
                                token = Com.Parse(ph);
-                               Console.DrawString (x, y, token);
+                               Console.DrawString(x, y, token);
                                continue;
                        }
 
                        if (token.equals("cstring2"))
                        {
                                token = Com.Parse(ph);
-                               DrawHUDString (token, x, y, 320,0x80);
+                               DrawHUDString(token, x, y, 320, 0x80);
                                continue;
                        }
 
                        if (token.equals("string2"))
                        {
                                token = Com.Parse(ph);
-                               Console.DrawAltString (x, y, token);
+                               Console.DrawAltString(x, y, token);
                                continue;
                        }
 
                        if (token.equals("if"))
-                       {       // draw a number
+                       { // 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);
-//                                     }
-                                       
+                               { // skip to endif
+                                       //                                      while (s && strcmp(token, "endif") )
+                                       //                                      {
+                                       //                                              token = Com.Parse(ph);
+                                       //                                      }
+
                                        while (!ph.isEof() && !(token = Com.Parse(ph)).equals("endif"));
 
                                }
@@ -1195,19 +1225,19 @@ public final class SCR extends Globals {
                                continue;
                        }
 
-
                }
        }
 
        /*
        ================
        SCR_DrawStats
-
+       
        The status bar is a small layout program that
        is based on the stats array
        ================
        */
-       static void DrawStats() {
+       static void DrawStats()
+       {
                //TODO:
                SCR.ExecuteLayoutString(cl.configstrings[CS_STATUSBAR]);
        }
@@ -1215,12 +1245,13 @@ public final class SCR extends Globals {
        /*
        ================
        SCR_DrawLayout
-
+       
        ================
        */
        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);
@@ -1231,7 +1262,7 @@ public final class SCR extends Globals {
        /*
        ==================
        SCR_UpdateScreen
-
+       
        This is called every frame, and can also be called explicitly to flush
        text to the screen.
        ==================
@@ -1241,7 +1272,7 @@ public final class SCR extends Globals {
                int numframes;
                int i;
                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)
@@ -1255,23 +1286,23 @@ public final class SCR extends Globals {
                }
 
                if (!scr_initialized || !con.initialized)
-                       return;                         // not initialized yet
+                       return; // not initialized yet
 
                /*
                ** range check cl_camera_separation so we don't inadvertently fry someone's
                ** brain
                */
-               if ( cl_stereo_separation.value > 1.0 )
-                       Cvar.SetValue( "cl_stereo_separation", 1.0f );
-               else if ( cl_stereo_separation.value < 0 )
-                       Cvar.SetValue( "cl_stereo_separation", 0.0f );
+               if (cl_stereo_separation.value > 1.0)
+                       Cvar.SetValue("cl_stereo_separation", 1.0f);
+               else if (cl_stereo_separation.value < 0)
+                       Cvar.SetValue("cl_stereo_separation", 0.0f);
 
-               if ( cl_stereo.value != 0 )
+               if (cl_stereo.value != 0)
                {
                        numframes = 2;
                        separation[0] = -cl_stereo_separation.value / 2;
-                       separation[1] =  cl_stereo_separation.value / 2;
-               }               
+                       separation[1] = cl_stereo_separation.value / 2;
+               }
                else
                {
                        separation[0] = 0;
@@ -1279,19 +1310,19 @@ public final class SCR extends Globals {
                        numframes = 1;
                }
 
-               for ( i = 0; i < numframes; i++ )
+               for (i = 0; i < numframes; i++)
                {
-                       re.BeginFrame( separation[i] );
+                       re.BeginFrame(separation[i]);
 
                        if (scr_draw_loading == 2)
-                       {       //  loading plaque over black screen
+                       { //  loading plaque over black screen
                                Dimension dim = new Dimension();
 
                                re.CinematicSetPalette(null);
                                scr_draw_loading = 0; // false
-                               re.DrawGetPicSize (dim, "loading");
-                               re.DrawPic ((viddef.width-dim.width)/2, (viddef.height-dim.height)/2, "loading");
-                       } 
+                               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)
@@ -1317,10 +1348,10 @@ public final class SCR extends Globals {
                                else
                                {
                                        // TODO impl: cl_cin.c for cinematics
-                                       //DrawCinematic();
+                                       DrawCinematic();
                                }
                        }
-                       else 
+                       else
                        {
                                // make sure the game palette is active
                                if (cl.cinematicpalette_active)
@@ -1335,7 +1366,7 @@ public final class SCR extends Globals {
                                // clear any dirty part of the background
                                TileClear();
 
-                               V.RenderView( separation[i] );
+                               V.RenderView(separation[i]);
 
                                DrawStats();
                                // TODO impl this
@@ -1346,22 +1377,22 @@ public final class SCR extends Globals {
 
                                DrawNet();
                                CheckDrawCenterString();
-//
-//                             if (scr_timegraph->value)
-//                                     SCR_DebugGraph (cls.frametime*300, 0);
-//
-//                             if (scr_debuggraph->value || scr_timegraph->value || scr_netgraph->value)
-//                                     SCR_DrawDebugGraph ();
-//
+                               DrawFPS();
+
+                               //
+                               //                              if (scr_timegraph->value)
+                               //                                      SCR_DebugGraph (cls.frametime*300, 0);
+                               //
+                               //                              if (scr_debuggraph->value || scr_timegraph->value || scr_netgraph->value)
+                               //                                      SCR_DrawDebugGraph ();
+                               //
                                DrawPause();
-
                                DrawConsole();
-
-                               Menu.Draw ();
-
+                               Menu.Draw();
                                DrawLoading();
                        }
                }
+
                Globals.re.EndFrame();
        }
 
@@ -1370,11 +1401,13 @@ public final class SCR extends Globals {
        SCR_DrawCrosshair
        =================
        */
-       static void DrawCrosshair() {
+       static void DrawCrosshair()
+       {
                if (crosshair.value == 0.0f)
                        return;
 
-               if (crosshair.modified) {
+               if (crosshair.modified)
+               {
                        crosshair.modified = false;
                        SCR.TouchPics();
                }
@@ -1382,21 +1415,25 @@ public final class SCR extends Globals {
                if (crosshair_pic.length() == 0)
                        return;
 
-               re.DrawPic(scr_vrect.x + ((scr_vrect.width - crosshair_width)>>1),
-                       scr_vrect.y + ((scr_vrect.height - crosshair_height)>>1), crosshair_pic);
+               re.DrawPic(
+                       scr_vrect.x + ((scr_vrect.width - crosshair_width) >> 1),
+                       scr_vrect.y + ((scr_vrect.height - crosshair_height) >> 1),
+                       crosshair_pic);
        }
-       
+
        // wird anstelle von der richtigen UpdateScreen benoetigt
-       public static void UpdateScreen() {
+       public static void UpdateScreen()
+       {
                Globals.re.updateScreen(null);
        }
-               
+
        /*
        =================
        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;
                if (x > scr_dirty.x2)
@@ -1407,14 +1444,667 @@ public final class SCR extends Globals {
                        scr_dirty.y2 = y;
        }
 
-       
-       public static void PlayCinematic(String str) {
-               // TODO: implement PlayCinematic                
+       private static int lastframes = 0;
+       private static int lasttime = 0;
+       private static String fpsvalue = "";
+       static void DrawFPS()
+       {
+               if (fps.value > 0.0f)
+               {
+                       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++)
+                       {
+                               re.DrawChar(x, 2, fpsvalue.charAt(i));
+                               x += 8;
+                       }
+               }
        }
        
-       static void FinishCinematic() {
+       /*
+       =================================================================
+
+       cl_cin.c
+       
+       Play Cinematics
+       
+       =================================================================
+       */
+
+//     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);
+//     }
+//
+       // =============================================================
+
+       /*
+       ==================
+       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)
+               {
+                       re.CinematicSetPalette(null);
+                       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 ();
+//             }
+//
+       }
+
+       /*
+       ====================
+       SCR_FinishCinematic
+
+       Called when either the cinematic completes, or it is aborted
+       ====================
+       */
+       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');
        }
+
+       // ==========================================================================
+
+//     /*
+//     ==================
+//     SmallestNode1
+//     ==================
+//     */
+//     int     SmallestNode1 (int numhnodes)
+//     {
+//             int             i;
+//             int             best, bestnode;
+//
+//             best = 99999999;
+//             bestnode = -1;
+//             for (i=0 ; i<numhnodes ; i++)
+//             {
+//                     if (cin.h_used[i])
+//                             continue;
+//                     if (!cin.h_count[i])
+//                             continue;
+//                     if (cin.h_count[i] < best)
+//                     {
+//                             best = cin.h_count[i];
+//                             bestnode = i;
+//                     }
+//             }
+//
+//             if (bestnode == -1)
+//                     return -1;
+//
+//             cin.h_used[bestnode] = true;
+//             return bestnode;
+//     }
+//
+//
+//     /*
+//     ==================
+//     Huff1TableInit
+//
+//     Reads the 64k counts table and initializes the node trees
+//     ==================
+//     */
+//     void Huff1TableInit (void)
+//     {
+//             int             prev;
+//             int             j;
+//             int             *node, *nodebase;
+//             byte    counts[256];
+//             int             numhnodes;
+//
+//             cin.hnodes1 = Z_Malloc (256*256*2*4);
+//             memset (cin.hnodes1, 0, 256*256*2*4);
+//
+//             for (prev=0 ; prev<256 ; prev++)
+//             {
+//                     memset (cin.h_count,0,sizeof(cin.h_count));
+//                     memset (cin.h_used,0,sizeof(cin.h_used));
+//
+//                     // read a row of counts
+//                     FS_Read (counts, sizeof(counts), cl.cinematic_file);
+//                     for (j=0 ; j<256 ; j++)
+//                             cin.h_count[j] = counts[j];
+//
+//                     // build the nodes
+//                     numhnodes = 256;
+//                     nodebase = cin.hnodes1 + prev*256*2;
+//
+//                     while (numhnodes != 511)
+//                     {
+//                             node = nodebase + (numhnodes-256)*2;
+//
+//                             // pick two lowest counts
+//                             node[0] = SmallestNode1 (numhnodes);
+//                             if (node[0] == -1)
+//                                     break;  // no more
+//
+//                             node[1] = SmallestNode1 (numhnodes);
+//                             if (node[1] == -1)
+//                                     break;
+//
+//                             cin.h_count[numhnodes] = cin.h_count[node[0]] + cin.h_count[node[1]];
+//                             numhnodes++;
+//                     }
+//
+//                     cin.numhnodes1[prev] = numhnodes-1;
+//             }
+//     }
+//
+//     /*
+//     ==================
+//     Huff1Decompress
+//     ==================
+//     */
+//     cblock_t Huff1Decompress (cblock_t in)
+//     {
+//             byte            *input;
+//             byte            *out_p;
+//             int                     nodenum;
+//             int                     count;
+//             cblock_t        out;
+//             int                     inbyte;
+//             int                     *hnodes, *hnodesbase;
+////     int           i;
+//
+//             // get decompressed count
+//             count = in.data[0] + (in.data[1]<<8) + (in.data[2]<<16) + (in.data[3]<<24);
+//             input = in.data + 4;
+//             out_p = out.data = Z_Malloc (count);
+//
+//             // read bits
+//
+//             hnodesbase = cin.hnodes1 - 256*2;       // nodes 0-255 aren't stored
+//
+//             hnodes = hnodesbase;
+//             nodenum = cin.numhnodes1[0];
+//             while (count)
+//             {
+//                     inbyte = *input++;
+//                     //-----------
+//                     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 (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;
+
+               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;
+//             }
+       }
+
+       /*
+       ==================
+       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;
+       }
+
+       /*
+       ==================
+       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
+               //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 ();
+       }
+
 }
\ No newline at end of file
index fba94c1..dc487d8 100644 (file)
@@ -2,7 +2,7 @@
  * S_DMA.java
  * Copyright (C) 2004
  * 
- * $Id: SND_DMA.java,v 1.1 2004-07-07 19:58:51 hzi Exp $
+ * $Id: SND_DMA.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -117,14 +117,12 @@ public class SND_DMA extends SND_MIX {
 //        ====================================================================
 
 
-       static void SoundInfo_f()
-       {
-               if (!sound_started)
-               {
-                       Com.Printf ("sound system not started\n");
+       static void SoundInfo_f() {
+               if (!sound_started) {
+                       Com.Printf("sound system not started\n");
                        return;
                }
-       
+
                Com.Printf("%5d stereo\n", new Vargs(1).add(dma.channels - 1));
                Com.Printf("%5d samples\n", new Vargs(1).add(dma.samples));
                Com.Printf("%5d samplepos\n", new Vargs(1).add(dma.samplepos));
@@ -249,7 +247,7 @@ S.SoundInfo_f();
                if (name.length() == 0)
                        Com.Error(ERR_FATAL, "S_FindName: empty name\n");
 
-               if (strlen(name) >= MAX_QPATH)
+               if (name.length() >= MAX_QPATH)
                        Com.Error(ERR_FATAL, "Sound name too long: " + name);
 
                // see if already loaded
index a5f7671..85215d1 100644 (file)
@@ -2,7 +2,7 @@
  * SND_MEM.java
  * Copyright (C) 2004
  * 
- * $Id: SND_MEM.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+ * $Id: SND_MEM.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,6 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 package jake2.client;
 
+import jake2.qcommon.Com;
+import jake2.qcommon.FS;
+
 /**
  * SND_MEM
  */
@@ -39,52 +42,51 @@ public class SND_MEM extends SND_JAVA {
 //
 //     byte *S_Alloc (int size);
 //
-//     /*
-//     ================
-//     ResampleSfx
-//     ================
-//     */
-//     void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
-//     {
-//             int             outcount;
-//             int             srcsample;
-//             float   stepscale;
-//             int             i;
-//             int             sample, samplefrac, fracstep;
-//             sfxcache_t      *sc;
-//     
-//             sc = sfx->cache;
-//             if (!sc)
-//                     return;
-//
-//             stepscale = (float)inrate / dma.speed;  // this is usually 0.5, 1, or 2
-//
-//             outcount = sc->length / stepscale;
-//             sc->length = outcount;
-//             if (sc->loopstart != -1)
-//                     sc->loopstart = sc->loopstart / stepscale;
-//
-//             sc->speed = dma.speed;
-//             if (s_loadas8bit->value)
-//                     sc->width = 1;
-//             else
-//                     sc->width = inwidth;
-//             sc->stereo = 0;
-//
-////      resample / decimate to the current source rate
-//
-//             if (stepscale == 1 && inwidth == 1 && sc->width == 1)
-//             {
-////      fast special case
-//                     for (i=0 ; i<outcount ; i++)
-//                             ((signed char *)sc->data)[i]
-//                             = (int)( (unsigned char)(data[i]) - 128);
-//             }
-//             else
-//             {
-////      general case
-//                     samplefrac = 0;
-//                     fracstep = stepscale*256;
+       /*
+       ================
+       ResampleSfx
+       ================
+       */
+       static void ResampleSfx (sfx_t sfx, int inrate, int inwidth, byte[] data, int ofs)
+       {
+               int             outcount;
+               int             srcsample;
+               float   stepscale;
+               int             i;
+               int             sample, samplefrac, fracstep;
+               sfxcache_t      sc;
+       
+               sc = sfx.cache;
+               if (sc == null)
+                       return;
+
+               stepscale = (float)inrate / dma.speed;  // this is usually 0.5, 1, or 2
+
+               outcount = (int)(sc.length / stepscale);
+               sc.length = outcount;
+               if (sc.loopstart != -1)
+                       sc.loopstart = (int)(sc.loopstart / stepscale);
+
+               sc.speed = dma.speed;
+               if (SND_DMA.s_loadas8bit.value != 0.0f)
+                       sc.width = 1;
+               else
+                       sc.width = inwidth;
+               sc.stereo = 0;
+
+//        resample / decimate to the current source rate
+
+               if (stepscale == 1 && inwidth == 1 && sc.width == 1)
+               {
+//        fast special case
+                       for (i=0 ; i<outcount ; i++)
+                               sc.data[i+ofs] = (byte)((data[i+ofs] & 0xFF) - 128);
+               }
+               else
+               {
+//        general case
+                       samplefrac = 0;
+                       fracstep = (int)(stepscale*256);
 //                     for (i=0 ; i<outcount ; i++)
 //                     {
 //                             srcsample = samplefrac >> 8;
@@ -98,8 +100,8 @@ public class SND_MEM extends SND_JAVA {
 //                             else
 //                                     ((signed char *)sc->data)[i] = sample >> 8;
 //                     }
-//             }
-//     }
+               }
+       }
 //
 ////     =============================================================================
 //
@@ -108,77 +110,70 @@ public class SND_MEM extends SND_JAVA {
        S_LoadSound
        ==============
        */
-       static sfxcache_t LoadSound (sfx_t s)
-       {
-//             char    namebuffer[MAX_QPATH];
-//             byte    *data;
-//             wavinfo_t       info;
-//             int             len;
-//             float   stepscale;
-               sfxcache_t      sc = null;
-//             int             size;
-//             char    *name;
-//
-//             if (s->name[0] == '*')
-//                     return NULL;
-//
-////      see if still in memory
-//             sc = s->cache;
-//             if (sc)
-//                     return sc;
-//
-////     Com_Printf ("S_LoadSound: %x\n", (int)stackbuf);
-////      load it in
-//             if (s->truename)
-//                     name = s->truename;
-//             else
-//                     name = s->name;
-//
-//             if (name[0] == '#')
-//                     strcpy(namebuffer, &name[1]);
-//             else
-//                     Com_sprintf (namebuffer, sizeof(namebuffer), "sound/%s", name);
-//
-////           Com_Printf ("loading %s\n",namebuffer);
-//
-//             size = FS_LoadFile (namebuffer, (void **)&data);
-//
-//             if (!data)
-//             {
-//                     Com_DPrintf ("Couldn't load %s\n", namebuffer);
-//                     return NULL;
-//             }
-//
-//             info = GetWavinfo (s->name, data, size);
-//             if (info.channels != 1)
-//             {
-//                     Com_Printf ("%s is a stereo sample\n",s->name);
-//                     FS_FreeFile (data);
-//                     return NULL;
-//             }
-//
-//             stepscale = (float)info.rate / dma.speed;       
-//             len = info.samples / stepscale;
-//
-//             len = len * info.width * info.channels;
-//
-//             sc = s->cache = Z_Malloc (len + sizeof(sfxcache_t));
-//             if (!sc)
-//             {
-//                     FS_FreeFile (data);
-//                     return NULL;
-//             }
-//     
-//             sc->length = info.samples;
-//             sc->loopstart = info.loopstart;
-//             sc->speed = info.rate;
-//             sc->width = info.width;
-//             sc->stereo = info.channels;
-//
-//             ResampleSfx (s, sc->speed, sc->width, data + info.dataofs);
-//
-//             FS_FreeFile (data);
-//
+       static sfxcache_t LoadSound(sfx_t s) {
+               String namebuffer;
+               byte[] data;
+               wavinfo_t info;
+               int len;
+               float stepscale;
+               sfxcache_t sc = null;
+               int size;
+               String name;
+
+               if (s.name.charAt(0) == '*')
+                       return null;
+
+               // see if still in memory
+               sc = s.cache;
+               if (sc != null)
+                       return sc;
+
+               // load it in
+               if (s.truename != null)
+                       name = s.truename;
+               else
+                       name = s.name;
+
+               if (name.charAt(0) == '#')
+                       namebuffer = name.substring(1);
+               //strcpy(namebuffer, &name[1]);
+               else
+                       namebuffer = "sound/" + name;
+               //Com_sprintf (namebuffer, sizeof(namebuffer), "sound/%s", name);
+
+               data = FS.LoadFile(namebuffer);
+
+               if (data == null) {
+                       Com.DPrintf("Couldn't load " + namebuffer + "\n");
+                       return null;
+               }
+               size = data.length;
+
+               info = GetWavinfo(s.name, data, size);
+               if (info.channels != 1) {
+                       Com.Printf(s.name + " is a stereo sample\n");
+                       FS.FreeFile(data);
+                       return null;
+               }
+
+               stepscale = ((float)info.rate) / dma.speed;
+               len = (int) (info.samples / stepscale);
+
+               len = len * info.width * info.channels;
+
+               //sc = s.cache = Z_Malloc (len + sizeof(sfxcache_t));
+               sc = s.cache = new sfxcache_t(len);
+
+               sc.length = info.samples;
+               sc.loopstart = info.loopstart;
+               sc.speed = info.rate;
+               sc.width = info.width;
+               sc.stereo = info.channels;
+
+               ResampleSfx(s, sc.speed, sc.width, data, info.dataofs);
+
+               FS.FreeFile(data);
+
                return sc;
        }
 //
@@ -192,67 +187,65 @@ public class SND_MEM extends SND_JAVA {
 //     ===============================================================================
 //     */
 //
-//
-//     byte    *data_p;
-//     byte    *iff_end;
-//     byte    *last_chunk;
-//     byte    *iff_data;
-//     int     iff_chunk_len;
-//
-//
-//     short GetLittleShort(void)
-//     {
-//             short val = 0;
-//             val = *data_p;
-//             val = val + (*(data_p+1)<<8);
-//             data_p += 2;
-//             return val;
-//     }
-//
-//     int GetLittleLong(void)
-//     {
-//             int val = 0;
-//             val = *data_p;
-//             val = val + (*(data_p+1)<<8);
-//             val = val + (*(data_p+2)<<16);
-//             val = val + (*(data_p+3)<<24);
-//             data_p += 4;
-//             return val;
-//     }
-//
-//     void FindNextChunk(char *name)
-//     {
-//             while (1)
-//             {
-//                     data_p=last_chunk;
-//
-//                     if (data_p >= iff_end)
-//                     {       // didn't find the chunk
-//                             data_p = NULL;
-//                             return;
-//                     }
-//             
-//                     data_p += 4;
-//                     iff_chunk_len = GetLittleLong();
-//                     if (iff_chunk_len < 0)
-//                     {
-//                             data_p = NULL;
-//                             return;
-//                     }
-////                   if (iff_chunk_len > 1024*1024)
-////                           Sys_Error ("FindNextChunk: %i length is past the 1 meg sanity limit", iff_chunk_len);
-//                     data_p -= 8;
-//                     last_chunk = data_p + 8 + ( (iff_chunk_len + 1) & ~1 );
-//                     if (!strncmp(data_p, name, 4))
-//                             return;
-//             }
-//     }
-//
-//     void FindChunk(char *name)
-//     {
-//             last_chunk = iff_data;
-//             FindNextChunk (name);
-//     }
+       static byte[] data_b;
+       static int data_p;
+       static int iff_end;
+       static int last_chunk;
+       static int iff_data;
+       static int iff_chunk_len;
+
+
+       static short GetLittleShort() {
+               short val = 0;
+               val = data_b[data_p];
+               data_p++;
+               val |= (data_b[data_p] << 8);
+               data_p++;
+               return val;
+       }
+
+       static int GetLittleLong() {
+               int val = 0;
+               val = data_b[data_p];
+               data_p++;
+               val |= (data_b[data_p] << 8);
+               data_p++;
+               val |= (data_b[data_p] << 16);
+               data_p++;
+               val |= (data_b[data_p] << 24);
+               data_p++;
+               return val;
+       }
+
+       static void FindNextChunk(String name) {
+               while (true) {
+                       data_p = last_chunk;
+
+                       if (data_p >= iff_end) { // didn't find the chunk
+                               data_p = 0;
+                               return;
+                       }
+
+                       data_p += 4;
+                       iff_chunk_len = GetLittleLong();
+                       if (iff_chunk_len < 0) {
+                               data_p = 0;
+                               return;
+                       }
+                       //                      if (iff_chunk_len > 1024*1024)
+                       //                              Sys_Error ("FindNextChunk: %i length is past the 1 meg sanity limit", iff_chunk_len);
+                       data_p -= 8;
+                       last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1);
+                       String s = new String(data_b, data_p, 4);
+                       if (s.equals(name))
+                               return;
+               }
+       }
+
+       static void FindChunk(String name) {
+               last_chunk = iff_data;
+               FindNextChunk(name);
+       }
 //
 //
 //     void DumpChunks(void)
@@ -271,104 +264,101 @@ public class SND_MEM extends SND_JAVA {
 //             } while (data_p < iff_end);
 //     }
 //
-//     /*
-//     ============
-//     GetWavinfo
-//     ============
-//     */
-//     wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
-//     {
-//             wavinfo_t       info;
-//             int     i;
-//             int     format;
-//             int             samples;
-//
-//             memset (&info, 0, sizeof(info));
-//
-//             if (!wav)
-//                     return info;
-//             
-//             iff_data = wav;
-//             iff_end = wav + wavlength;
-//
-////      find "RIFF" chunk
-//             FindChunk("RIFF");
-//             if (!(data_p && !strncmp(data_p+8, "WAVE", 4)))
-//             {
-//                     Com_Printf("Missing RIFF/WAVE chunks\n");
-//                     return info;
-//             }
-//
-////      get "fmt " chunk
-//             iff_data = data_p + 12;
-////      DumpChunks ();
-//
-//             FindChunk("fmt ");
-//             if (!data_p)
-//             {
-//                     Com_Printf("Missing fmt chunk\n");
-//                     return info;
-//             }
-//             data_p += 8;
-//             format = GetLittleShort();
-//             if (format != 1)
-//             {
-//                     Com_Printf("Microsoft PCM format only\n");
-//                     return info;
-//             }
-//
-//             info.channels = GetLittleShort();
-//             info.rate = GetLittleLong();
-//             data_p += 4+2;
-//             info.width = GetLittleShort() / 8;
-//
-////      get cue chunk
-//             FindChunk("cue ");
-//             if (data_p)
-//             {
-//                     data_p += 32;
-//                     info.loopstart = GetLittleLong();
-////                   Com_Printf("loopstart=%d\n", sfx->loopstart);
-//
-//             // if the next chunk is a LIST chunk, look for a cue length marker
-//                     FindNextChunk ("LIST");
-//                     if (data_p)
-//                     {
-//                             if (!strncmp (data_p + 28, "mark", 4))
-//                             {       // this is not a proper parse, but it works with cooledit...
-//                                     data_p += 24;
-//                                     i = GetLittleLong ();   // samples in loop
-//                                     info.samples = info.loopstart + i;
-////                                   Com_Printf("looped length: %i\n", i);
-//                             }
-//                     }
-//             }
-//             else
-//                     info.loopstart = -1;
-//
-////      find data chunk
-//             FindChunk("data");
-//             if (!data_p)
-//             {
-//                     Com_Printf("Missing data chunk\n");
-//                     return info;
-//             }
-//
-//             data_p += 4;
-//             samples = GetLittleLong () / info.width;
-//
-//             if (info.samples)
-//             {
-//                     if (samples < info.samples)
-//                             Com_Error (ERR_DROP, "Sound %s has a bad loop length", name);
-//             }
-//             else
-//                     info.samples = samples;
-//
-//             info.dataofs = data_p - wav;
-//     
-//             return info;
-//     }
-//
+       /*
+       ============
+       GetWavinfo
+       ============
+       */
+       static wavinfo_t GetWavinfo(String name, byte[] wav, int wavlength) {
+               wavinfo_t info = new wavinfo_t();
+               int i;
+               int format;
+               int samples;
+
+               if (wav == null)
+                       return info;
+
+               iff_data = 0;
+               iff_end = wavlength;
+               data_b = wav;
+
+               // find "RIFF" chunk
+               FindChunk("RIFF");
+               String s = new String(data_b, data_p + 8, 4);
+               if (!((data_p != 0) && s.equals("WAVE"))) {
+                       Com.Printf("Missing RIFF/WAVE chunks\n");
+                       return info;
+               }
+
+               //         get "fmt " chunk
+               iff_data = data_p + 12;
+               //         DumpChunks ();
+
+               FindChunk("fmt ");
+               if (data_p == 0) {
+                       Com.Printf("Missing fmt chunk\n");
+                       return info;
+               }
+               data_p += 8;
+               format = GetLittleShort();
+               if (format != 1) {
+                       Com.Printf("Microsoft PCM format only\n");
+                       return info;
+               }
+
+               info.channels = GetLittleShort();
+               info.rate = GetLittleLong();
+               data_p += 4 + 2;
+               info.width = GetLittleShort() / 8;
+
+               //         get cue chunk
+               FindChunk("cue ");
+               if (data_p != 0) {
+                       data_p += 32;
+                       info.loopstart = GetLittleLong();
+                       //                      Com_Printf("loopstart=%d\n", sfx->loopstart);
 
+                       // if the next chunk is a LIST chunk, look for a cue length marker
+                       FindNextChunk("LIST");
+                       if (data_p != 0) {
+                               s = new String(data_b, data_p + 28, 4);
+                               if (s.equals("MARK")) { // this is not a proper parse, but it works with cooledit...
+                                       data_p += 24;
+                                       i = GetLittleLong(); // samples in loop
+                                       info.samples = info.loopstart + i;
+                                       //                                      Com_Printf("looped length: %i\n", i);
+                               }
+                       }
+               } else
+                       info.loopstart = -1;
+
+               //         find data chunk
+               FindChunk("data");
+               if (data_p == 0) {
+                       Com.Printf("Missing data chunk\n");
+                       return info;
+               }
+
+               data_p += 4;
+               samples = GetLittleLong() / info.width;
+
+               if (info.samples != 0) {
+                       if (samples < info.samples)
+                               Com.Error(ERR_DROP, "Sound " + name + " has a bad loop length");
+               } else
+                       info.samples = samples;
+
+               info.dataofs = data_p;
+
+               return info;
+       }
+
+       static class wavinfo_t {
+               int rate;
+               int width;
+               int channels;
+               int loopstart;
+               int samples;
+               int dataofs; // chunk starts this many bytes from file start
+       }
 }
index dad6fc0..7b71830 100644 (file)
@@ -2,7 +2,7 @@
  * VID.java
  * Copyright (C) 2003
  *
- * $Id: VID.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+ * $Id: VID.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -31,9 +31,8 @@ import jake2.game.Cmd;
 import jake2.game.cvar_t;
 import jake2.qcommon.*;
 import jake2.render.Renderer;
-import jake2.sys.*;
+import jake2.sys.IN;
 import jake2.sys.KBD;
-import jake2.sys.RW;
 import jake2.util.Vargs;
 
 import java.awt.Dimension;
@@ -147,7 +146,7 @@ public class VID extends Globals {
        {
                if (Globals.re != null) {
                        KBD.Close();
-                       RW.IN_Shutdown();
+                       IN.Shutdown();
                }
 
                Globals.re = null;
@@ -165,7 +164,7 @@ public class VID extends Globals {
                if ( reflib_active )
                {
                        KBD.Close();
-                       RW.IN_Shutdown();
+                       IN.Shutdown();
 
                        Globals.re.Shutdown();
                        FreeReflib();
@@ -404,7 +403,7 @@ public class VID extends Globals {
                if ( reflib_active )
                {
                        KBD.Close();
-                       RW.IN_Shutdown();
+                       IN.Shutdown();
 
                        Globals.re.Shutdown();
                        FreeReflib();
index 97431ab..359b40f 100644 (file)
@@ -2,7 +2,7 @@
  * sfx_t.java
  * Copyright (C) 2003
  * 
- * $Id: sfx_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+ * $Id: sfx_t.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 package jake2.client;
 
 public class sfx_t {
-       String name =""; //mem
+       String name; //mem
        int registration_sequence;
        sfxcache_t cache; //ptr
        String truename; //ptr
index 69fbcde..245d921 100644 (file)
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
 // Created on 28.11.2003 by RST.
-// $Id: sfxcache_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+// $Id: sfxcache_t.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
 
 package jake2.client;
 
@@ -29,6 +29,9 @@ public class sfxcache_t {
        int             speed;                  // not needed, because converted on load?
        int             width;
        int             stereo;
-       byte            data[]  = new byte[1];          // variable sized
-
+       byte            data[];         // variable sized
+       
+       public sfxcache_t(int size) {
+               data = new byte[size];
+       }
 }
index f6bd6cb..4f4a538 100644 (file)
@@ -19,11 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
 // Created on 11.11.2003 by RST.
-// $Id: AIAdapter.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+// $Id: AIAdapter.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
 
 package jake2.game;
 
-public class AIAdapter  extends SuperAdapter {
-       public void ai(edict_t self, float dist) {
-       }
+public abstract class AIAdapter extends SuperAdapter
+{
+       public abstract void ai(edict_t self, float dist);
 }
index 493410c..c9e2830 100644 (file)
@@ -1,8 +1,25 @@
 /*
- * BigEndianHandler.java
- * Copyright (C) 2003
- * 
- * $Id: BigEndianHandler.java,v 1.1 2004-07-07 19:58:52 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.
+
+*/
+
+/*
+ * $Id: BigEndianHandler.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
  */
 package jake2.game;
 
index 8292d25..bbb6742 100644 (file)
@@ -2,7 +2,7 @@
  * Cmd.java
  * Copyright (C) 2003
  * 
- * $Id: Cmd.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+ * $Id: Cmd.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
  */
 /*
 Copyright (C) 1997-2001 Id Software, Inc.
@@ -194,7 +194,7 @@ public final class Cmd extends PlayerView {
 
                        token = Cvar.VariableString(token);
 
-                       j = strlen(token);
+                       j = token.length();
 
                        len += j;
 
@@ -240,7 +240,6 @@ public final class Cmd extends PlayerView {
        ============
        */
        public static void TokenizeString(char text[], boolean macroExpand) {
-               int i;
                String com_token;
 
                cmd_argc = 0;
@@ -394,7 +393,6 @@ public final class Cmd extends PlayerView {
 //
 //                     Com.DPrintf("\n");
 //             }
-               //System.out.println("tokenized[" + Argv(0) + "]" + "[" + Argv(1) +  "]");
                // execute the command line
                if (Argc() == 0)
                        return; // no tokens
@@ -476,7 +474,7 @@ public final class Cmd extends PlayerView {
                }
 
                if (give_all || 0 == Lib.Q_stricmp(name, "weapons")) {
-                       for (i = 0; i < GameBase.game.num_items; i++) {
+                       for (i = 1; i < GameBase.game.num_items; i++) {
                                it = GameAI.itemlist[i];
                                if (null == it.pickup)
                                        continue;
@@ -489,7 +487,7 @@ public final class Cmd extends PlayerView {
                }
 
                if (give_all || 0 == Lib.Q_stricmp(name, "ammo")) {
-                       for (i = 0; i < GameBase.game.num_items; i++) {
+                       for (i = 1; i < GameBase.game.num_items; i++) {
                                it = GameAI.itemlist[i];
                                if (null == it.pickup)
                                        continue;
@@ -523,7 +521,7 @@ public final class Cmd extends PlayerView {
                        it_ent = GameUtil.G_Spawn();
                        it_ent.classname = it.classname;
                        GameAI.SpawnItem(it_ent, it);
-                       GameAI.Touch_Item(it_ent, ent, null, null);
+                       GameAI.Touch_Item(it_ent, ent, GameBase.dummyplane, null);
                        if (it_ent.inuse)
                                GameUtil.G_FreeEdict(it_ent);
 
@@ -532,7 +530,7 @@ public final class Cmd extends PlayerView {
                }
 
                if (give_all) {
-                       for (i = 0; i < GameBase.game.num_items; i++) {
+                       for (i = 1; i < GameBase.game.num_items; i++) {
                                it = GameAI.itemlist[i];
                                if (it.pickup != null)
                                        continue;
@@ -570,7 +568,7 @@ public final class Cmd extends PlayerView {
                        it_ent = GameUtil.G_Spawn();
                        it_ent.classname = it.classname;
                        GameAI.SpawnItem(it_ent, it);
-                       GameAI.Touch_Item(it_ent, ent, null, null);
+                       GameAI.Touch_Item(it_ent, ent, GameBase.dummyplane, null);
                        if (it_ent.inuse)
                                GameUtil.G_FreeEdict(it_ent);
                }
@@ -669,7 +667,7 @@ public final class Cmd extends PlayerView {
 
                s = GameBase.gi.args();
                it = GameUtil.FindItem(s);
-               if (it != null) {
+               if (it == null) {
                        GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s + "\n");
                        return;
                }
@@ -825,6 +823,8 @@ public final class Cmd extends PlayerView {
                // scan  for the next valid one
                for (i = 1; i <= Defines.MAX_ITEMS; i++) {
                        index = (selected_weapon + Defines.MAX_ITEMS - i) % Defines.MAX_ITEMS;
+                       //bugfix rst
+                       if (index == 0) index++;
                        if (0 == cl.pers.inventory[index])
                                continue;
                        it = GameAI.itemlist[index];
@@ -950,7 +950,7 @@ public final class Cmd extends PlayerView {
                ent.flags &= ~Defines.FL_GODMODE;
                ent.health = 0;
                GameBase.meansOfDeath = Defines.MOD_SUICIDE;
-               GameAI.player_die.die(ent, ent, ent, 100000, GameBase.vec3_origin);
+               GameAIAdapters.player_die.die(ent, ent, ent, 100000, GameBase.vec3_origin);
        }
 
        /*
@@ -989,7 +989,7 @@ public final class Cmd extends PlayerView {
                // sort by frags
                //qsort(index, count, sizeof(index[0]), PlayerSort);
                //replaced by:
-               Arrays.sort(index, 0, count - 1, GameAI.PlayerSort);
+               Arrays.sort(index, 0, count - 1, GameAIAdapters.PlayerSort);
 
                // print information
                large = "";
@@ -1001,7 +1001,7 @@ public final class Cmd extends PlayerView {
                                        + GameBase.game.clients[index[i].intValue()].pers.netname
                                        + "\n";
 
-                       if (Lib.strlen(small) + Lib.strlen(large) > 1024 - 100) {
+                       if (small.length() + large.length() > 1024 - 100) {
                                // can't print all of them in one packet
                                large += "...\n";
                                break;
@@ -1070,7 +1070,6 @@ public final class Cmd extends PlayerView {
 
                int i, j;
                edict_t other;
-               char p;
                String text;
                gclient_t cl;
 
@@ -1108,7 +1107,7 @@ public final class Cmd extends PlayerView {
                }
 
                // don't let text be too long for malicious reasons
-               if (strlen(text) > 150)
+               if (text.length() > 150)
                        //text[150] = 0;
                        text = text.substring(0, 150);
 
@@ -1186,7 +1185,7 @@ public final class Cmd extends PlayerView {
                                        + (e2.client.resp.spectator ? " (spectator)" : "")
                                        + "\n";
 
-                       if (Lib.strlen(text) + Lib.strlen(st) > 1024 - 50) {
+                       if (text.length() + st.length() > 1024 - 50) {
                                text += "And more...\n";
                                GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "" + text + "");
                                return;
index 53fd1de..84dddf2 100644 (file)
@@ -19,14 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
 // Created on 07.11.2003 by RST.
-// $Id: EdictFindFilter.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+// $Id: EdictFindFilter.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
 
 package jake2.game;
 
 /** Helps for filtering the iteration over the gedicts[] array, see GFind(). RST.*/
 
-public class EdictFindFilter {
-       boolean matches(edict_t e, String s) {
+public class EdictFindFilter
+{
+       boolean matches(edict_t e, String s)
+       {
                return false;
        };
 }
\ No newline at end of file