aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-09 08:38:30 +0000
committerHolger Zickner <[email protected]>2004-07-09 08:38:30 +0000
commit76230d5ab9be20bfc25de6f3e50504a4287575d0 (patch)
tree8ec5a6485478c7fde8944e6477e466e3adceab36
parent1e132c95409d6a7f3baf499b50f0bc7d22969b07 (diff)
import of Jake2 version v_0_9_2v_0_9_2
-rw-r--r--.classpath2
-rw-r--r--ChangeLog9
-rw-r--r--README15
-rw-r--r--build.xml36
-rw-r--r--scripts/Jake2.bat4
-rw-r--r--scripts/Jake2.sh4
-rw-r--r--src/META-INF/services/javax.imageio.spi.ImageReaderSpi2
-rw-r--r--src/jake2/Jake2.java23
-rw-r--r--src/jake2/client/CL.java41
-rw-r--r--src/jake2/client/CL_ents.java10
-rw-r--r--src/jake2/client/CL_input.java7
-rw-r--r--src/jake2/client/CL_parse.java6
-rw-r--r--src/jake2/client/CL_view.java43
-rw-r--r--src/jake2/client/Key.java72
-rw-r--r--src/jake2/client/Menu.java87
-rw-r--r--src/jake2/client/SCR.java35
-rw-r--r--src/jake2/client/V.java37
-rw-r--r--src/jake2/client/VID.java17
-rw-r--r--src/jake2/client/client_state_t.java6
-rw-r--r--src/jake2/client/frame_t.java8
-rw-r--r--src/jake2/client/particle_t.java20
-rw-r--r--src/jake2/client/refdef_t.java4
-rw-r--r--src/jake2/game/Cmd.java740
-rw-r--r--src/jake2/game/GameBase.java20
-rw-r--r--src/jake2/game/GameFunc.java5
-rw-r--r--src/jake2/game/GameSVCmds.java12
-rw-r--r--src/jake2/game/GameSpawn.java6
-rw-r--r--src/jake2/game/GameUtil.java3
-rw-r--r--src/jake2/game/GameUtilAdapters.java14
-rw-r--r--src/jake2/game/M_Actor.java4
-rw-r--r--src/jake2/game/PlayerHud.java6
-rw-r--r--src/jake2/game/game_export_t.java14
-rw-r--r--src/jake2/game/player_state_t.java3
-rw-r--r--src/jake2/qcommon/CM.java26
-rw-r--r--src/jake2/qcommon/CRC.java2
-rw-r--r--src/jake2/qcommon/Com.java1336
-rw-r--r--src/jake2/qcommon/FS.java4
-rw-r--r--src/jake2/qcommon/MD4.java14
-rw-r--r--src/jake2/qcommon/Qcommon.java2
-rw-r--r--src/jake2/qcommon/qfiles.java19
-rw-r--r--src/jake2/render/FastJoglRenderer.java2
-rw-r--r--src/jake2/render/JoglRenderer.java57
-rw-r--r--src/jake2/render/Renderer.java7
-rw-r--r--src/jake2/render/fastjogl/Anorms.java2
-rw-r--r--src/jake2/render/fastjogl/Base.java2
-rw-r--r--src/jake2/render/fastjogl/Draw.java2
-rw-r--r--src/jake2/render/fastjogl/Image.java2
-rw-r--r--src/jake2/render/fastjogl/Impl.java2
-rw-r--r--src/jake2/render/fastjogl/Light.java2
-rw-r--r--src/jake2/render/fastjogl/Main.java2
-rw-r--r--src/jake2/render/fastjogl/Mesh.java2
-rw-r--r--src/jake2/render/fastjogl/Misc.java2
-rw-r--r--src/jake2/render/fastjogl/Model.java21
-rw-r--r--src/jake2/render/fastjogl/Surf.java2
-rw-r--r--src/jake2/render/fastjogl/Warp.java2
-rw-r--r--src/jake2/render/glpoly_t.java10
-rw-r--r--src/jake2/render/jogl/Draw.java10
-rw-r--r--src/jake2/render/jogl/Image.java56
-rw-r--r--src/jake2/render/jogl/Impl.java183
-rw-r--r--src/jake2/render/jogl/Light.java75
-rw-r--r--src/jake2/render/jogl/Main.java210
-rw-r--r--src/jake2/render/jogl/Mesh.java53
-rw-r--r--src/jake2/render/jogl/Misc.java14
-rw-r--r--src/jake2/render/jogl/Surf.java85
-rw-r--r--src/jake2/render/jogl/Warp.java6
-rw-r--r--src/jake2/render/model_t.java4
-rw-r--r--src/jake2/render/msurface_t.java15
-rw-r--r--src/jake2/render/mtexinfo_t.java15
-rw-r--r--src/jake2/server/SV_CCMDS.java7
-rw-r--r--src/jake2/server/SV_GAME.java6
-rw-r--r--src/jake2/server/SV_INIT.java14
-rw-r--r--src/jake2/server/SV_MAIN.java4
-rw-r--r--src/jake2/server/SV_USER.java344
-rw-r--r--src/jake2/server/SV_WORLD.java273
-rw-r--r--src/jake2/sound/S.java6
-rw-r--r--src/jake2/sound/WaveLoader.java2
-rw-r--r--src/jake2/sound/joal/Channel.java2
-rw-r--r--src/jake2/sound/joal/JOALSoundImpl.java2
-rw-r--r--src/jake2/sys/NET.java6
-rw-r--r--src/jake2/sys/Sys.java15
-rw-r--r--src/jake2/util/Lib.java156
81 files changed, 2874 insertions, 1526 deletions
diff --git a/.classpath b/.classpath
index 2328b53..cb3bf8c 100644
--- a/.classpath
+++ b/.classpath
@@ -3,5 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/jogl/jogl.jar"/>
+ <classpathentry kind="lib" path="lib/joal/linux/joal.jar"/>
+ <classpathentry kind="lib" path="lib/joal/windows/joal.jar"/>
<classpathentry kind="output" path="build"/>
</classpath>
diff --git a/ChangeLog b/ChangeLog
index 2ce278c..3a1dee7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
-0.9.1 2004-04-05
+0.9.2 2004-06-28
+
+ - joal sound
+ - new "fastjogl" OpenGL renderer for improved performance
+ - fullscreen support on windows
+ - bugfixes
+
+0.9.1 2004-05-04
- use a newer jogl build that works with windows2000
- minor cleanups
diff --git a/README b/README
index cfab7c1..46fa617 100644
--- a/README
+++ b/README
@@ -5,12 +5,14 @@ Jake2 is a port of the GPL'd Quake2 engine from id Software to Java. Jake2 is
distributed under the terms of the GPL (see LICENSE).
The port was done completely in Java. No native libraries are used for the
-game functionality. For graphics rendering we use the jogl Java OpenGL bindings.
+game functionality. We use the jogl Java OpenGL bindings for graphics rendering
+and Java OpenAL (joal) for sound.
Jake2 is still under development. Send bug reports and feedback to
-Currently Jake2 supports Linux and Windows2000/XP.
+Currently Jake2 supports Linux and Windows2000/XP. We have feedback that it
+works on OS X too with the right native jogl libraries.
requirements:
400 MHz CPU
@@ -23,7 +25,8 @@ Installation
from binary distribution:
- unpack jake2-version.tar.gz or jake2-version.zip
- copy the baseq2 directory from your full version of Quake2 or from the
- demo version to the Jake2 base directory
+ demo version to the Jake2 base directory, in fact You need only
+ baseq2/pak0.pak
- run the game with Jake2.sh or Jake2.bat
build from source:
@@ -32,6 +35,12 @@ build from source:
- run "build.sh bindist" or "build.bat bindist" to build the binary
distribution
+installation of Quake2 data:
+- download ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe (37 MB)
+- extract the directory Install\Data\baseq2 from q2-314-demo-x86.exe with unzip or
+ Winzip
+- copy the baseq2 directory to the Jake2 directory
+
have fun!
bytonic Software
diff --git a/build.xml b/build.xml
index 4face95..8848469 100644
--- a/build.xml
+++ b/build.xml
@@ -8,7 +8,7 @@
</taskdef>
<!-- properties -->
- <property name="version" value="0.9.1"/>
+ <property name="version" value="0.9.2"/>
<property name="src" location="src"/>
<property name="test" location="test"/>
<property name="build" location="build"/>
@@ -16,7 +16,7 @@
<!-- different classpaths -->
<path id="build.class.path">
- <pathelement location="lib/jogl/linux/jogl.jar"/>
+ <pathelement location="lib/jogl/jogl.jar"/>
<pathelement location="lib/joal/linux/joal.jar"/>
</path>
@@ -35,17 +35,28 @@
</javac>
</target>
- <!-- copy libs -->
- <target name="copylibs">
+ <!-- copy files -->
+ <target name="copy">
+ <copy todir="${dist}/lib">
+ <fileset dir="lib/jogl">
+ <include name="*.jar"/>
+ </fileset>
+ </copy>
<copy todir="${dist}/lib/linux">
<fileset dir="lib/jogl/linux">
<include name="*"/>
- </fileset>
+ </fileset>
+ <fileset dir="lib/joal/linux">
+ <include name="*"/>
+ </fileset>
</copy>
<copy todir="${dist}/lib/windows">
<fileset dir="lib/jogl/windows">
<include name="*"/>
- </fileset>
+ </fileset>
+ <fileset dir="lib/joal/windows">
+ <include name="*"/>
+ </fileset>
</copy>
<copy todir="${dist}">
<fileset dir="scripts">
@@ -63,6 +74,14 @@
<include name="*.sh"/>
</fileset>
</chmod>
+ <fixcrlf srcdir="${dist}"
+ eol="crlf"
+ includes="*.bat"
+ />
+ <fixcrlf srcdir="${dist}"
+ eol="lf"
+ includes="*.sh"
+ />
</target>
<!-- jar -->
@@ -73,7 +92,8 @@
<proguard printseeds="on" printusage="off" outjar="${dist}/lib/jake2.jar"
defaultpackage="" overloadaggressively="off">
<injar name="${dist}/lib/jake.jar"/>
- <libraryjar name="lib/jogl/linux/jogl.jar"/>
+ <libraryjar name="lib/jogl/jogl.jar"/>
+ <libraryjar name="lib/joal/linux/joal.jar"/>
<libraryjar name="${java.home}/lib/rt.jar"/>
<keep access="public" name="jake2.Jake2">
<method name="main(java.lang.String[])"/>
@@ -87,7 +107,7 @@
</target>
<!-- dist -->
- <target name="dist" depends="jar,copylibs">
+ <target name="dist" depends="jar,copy">
</target>
<!-- binary distribution -->
diff --git a/scripts/Jake2.bat b/scripts/Jake2.bat
index 6230d9e..cfcfcc0 100644
--- a/scripts/Jake2.bat
+++ b/scripts/Jake2.bat
@@ -1 +1,3 @@
-@javaw -Xmx128M -Djava.library.path=lib/windows -cp lib/jake2.jar;lib/windows/jogl.jar;lib/windows/joal.jar jake2.Jake2 \ No newline at end of file
+@echo off
+SET PATH=lib\windows;%PATH%
+java -Xmx128M -Dsun.java2d.noddraw=true -Djava.library.path=lib/windows -cp lib/jake2.jar;lib/jogl.jar;lib/windows/joal.jar jake2.Jake2 \ No newline at end of file
diff --git a/scripts/Jake2.sh b/scripts/Jake2.sh
index 1b9b29e..0c9f00d 100644
--- a/scripts/Jake2.sh
+++ b/scripts/Jake2.sh
@@ -1,6 +1,6 @@
#!/bin/bash
export LD_LIBRARY_PATH=lib/linux
-CP=lib/jake2.jar:lib/linux/jogl.jar:lib/linux/joal.jar
+CP=lib/jake2.jar:lib/jogl.jar:lib/linux/joal.jar
-exec java -Xmx128M -Djava.library.path=lib/linux -cp $CP jake2.Jake2 \ No newline at end of file
+exec java -Xmx128M -Djava.library.path=lib/linux -cp $CP jake2.Jake2
diff --git a/src/META-INF/services/javax.imageio.spi.ImageReaderSpi b/src/META-INF/services/javax.imageio.spi.ImageReaderSpi
deleted file mode 100644
index a0d3dae..0000000
--- a/src/META-INF/services/javax.imageio.spi.ImageReaderSpi
+++ /dev/null
@@ -1,2 +0,0 @@
-jake2.imageio.PCXImageReaderSpi
-jake2.imageio.WALImageReaderSpi \ No newline at end of file
diff --git a/src/jake2/Jake2.java b/src/jake2/Jake2.java
index bebd0f0..217cada 100644
--- a/src/jake2/Jake2.java
+++ b/src/jake2/Jake2.java
@@ -2,7 +2,7 @@
* Jake2.java
* Copyright (C) 2003
*
- * $Id: Jake2.java,v 1.2.2.1 2004-07-09 08:09:08 hzi Exp $
+ * $Id: Jake2.java,v 1.2.2.2 2004-07-09 08:38:30 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2;
-import java.io.IOException;
-
-import jake2.qcommon.*;
+import jake2.client.SCR;
+import jake2.qcommon.Cvar;
+import jake2.qcommon.Qcommon;
import jake2.sys.Sys;
/**
@@ -61,17 +61,16 @@ public final class Jake2 {
// find time spending rendering last frame
newtime = Sys.Milliseconds();
time = newtime - oldtime;
-
+
+ // TODO this is a timer hack for Win2000
+ // System.currentTimeMillis() resolution bug
+ if (time == 0 && (Globals.cl_timedemo.value != 0 || SCR.fps.value != 0)) {
+ time++;
+ }
+
if (time > 0)
Qcommon.Frame(time);
oldtime = newtime;
-
- // save cpu resources
-// try {
-// Thread.sleep(1);
-// }
-// catch (InterruptedException e) {
-// }
}
}
}
diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java
index 5b30e34..c758b18 100644
--- a/src/jake2/client/CL.java
+++ b/src/jake2/client/CL.java
@@ -2,7 +2,7 @@
* CL.java
* Copyright (C) 2004
*
- * $Id: CL.java,v 1.4 2004-07-08 20:56:50 hzi Exp $
+ * $Id: CL.java,v 1.4.2.1 2004-07-09 08:38:24 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -43,17 +43,6 @@ import java.nio.ByteBuffer;
*/
public final class CL extends CL_pred {
-
-// 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;
-
/*
====================
CL_WriteDemoMessage
@@ -713,7 +702,7 @@ public final class CL extends CL_pred {
c = Cmd.Argv(0);
- Com.Printf(NET.AdrToString(net_from) + ": " + c + " \n");
+ Com.Printf(NET.AdrToString(net_from) + ": " + c + "\n");
// server connection
if (c.equals("client_connect")) {
@@ -1126,17 +1115,17 @@ public final class CL extends CL_pred {
if (precache_check == ENV_CNT) {
precache_check = ENV_CNT + 1;
- CM.intwrap iw = new CM.intwrap(map_checksum);
+ int iw[] = {map_checksum};
CM.CM_LoadMap(cl.configstrings[CS_MODELS + 1], true, iw);
- map_checksum = iw.i;
-// TODO MD4 check abgeklemmt
-// if ((map_checksum ^ atoi(cl.configstrings[CS_MAPCHECKSUM])) != 0) {
-// Com.Error(
-// ERR_DROP,
-// "Local map version differs from server: " + map_checksum + " != '" + cl.configstrings[CS_MAPCHECKSUM] + "'\n");
-// return;
-// }
+ map_checksum = iw[0];
+
+ if ((map_checksum ^ atoi(cl.configstrings[CS_MAPCHECKSUM])) != 0) {
+ Com.Error(
+ ERR_DROP,
+ "Local map version differs from server: " + map_checksum + " != '" + cl.configstrings[CS_MAPCHECKSUM] + "'\n");
+ return;
+ }
}
if (precache_check > ENV_CNT && precache_check < TEXTURE_CNT) {
@@ -1201,10 +1190,11 @@ public final class CL extends CL_pred {
if (Cmd.Argc() < 2) {
- CM.intwrap iw = new CM.intwrap(0); // for detecting cheater maps
+ int iw[] ={0};// for detecting cheater maps
+
CM.CM_LoadMap(cl.configstrings[CS_MODELS + 1], true, iw);
-// int mapchecksum = iw.i ;
+ int mapchecksum = iw[0] ;
CL.RegisterSounds();
CL.PrepRefresh();
return;
@@ -1540,8 +1530,7 @@ public final class CL extends CL_pred {
VID.CheckChanges();
if (!cl.refresh_prepped && cls.state == ca_active) {
CL.PrepRefresh();
- // TODO force GC after level loading
- System.gc();
+ // force GC after level loading
System.gc();
}
diff --git a/src/jake2/client/CL_ents.java b/src/jake2/client/CL_ents.java
index d406ff2..228aec6 100644
--- a/src/jake2/client/CL_ents.java
+++ b/src/jake2/client/CL_ents.java
@@ -2,7 +2,7 @@
* CL_ents.java
* Copyright (C) 2004
*
- * $Id: CL_ents.java,v 1.3 2004-07-08 20:56:50 hzi Exp $
+ * $Id: CL_ents.java,v 1.3.2.1 2004-07-09 08:38:24 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -53,7 +53,7 @@ public class CL_ents extends CL_inv {
=================
*/
static int bitcounts[] = new int[32]; /// just for protocol profiling
- public static int ParseEntityBits(CM.intwrap bits) {
+ public static int ParseEntityBits(int bits[]) {
int b, total;
int i;
int number;
@@ -82,7 +82,7 @@ public class CL_ents extends CL_inv {
else
number = MSG.ReadByte(net_message);
- bits.i = total;
+ bits[0] = total;
return number;
}
@@ -253,9 +253,9 @@ public class CL_ents extends CL_inv {
}
while (true) {
- CM.intwrap iw = new CM.intwrap(bits);
+ int iw[] = {bits};
newnum = ParseEntityBits(iw);
- bits = iw.i;
+ bits = iw[0];
if (newnum >= MAX_EDICTS)
Com.Error(ERR_DROP, "CL_ParsePacketEntities: bad number:" + newnum);
diff --git a/src/jake2/client/CL_input.java b/src/jake2/client/CL_input.java
index b55b866..5035aa3 100644
--- a/src/jake2/client/CL_input.java
+++ b/src/jake2/client/CL_input.java
@@ -2,7 +2,7 @@
* CL_input.java
* Copyright (C) 2004
*
- * $Id: CL_input.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
+ * $Id: CL_input.java,v 1.2.2.1 2004-07-09 08:38:23 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -549,10 +549,7 @@ public class CL_input extends CL_ents {
MSG.WriteDeltaUsercmd(buf, oldcmd, cmd);
// calculate a checksum over the move commands
- buf.data[checksumIndex] = 0;
- /*COM_BlockSequenceCRCByte(
- buf.data + checksumIndex + 1, buf.cursize - checksumIndex - 1,
- cls.netchan.outgoing_sequence);*/
+ buf.data[checksumIndex] = Com.BlockSequenceCRCByte(buf.data, checksumIndex + 1, buf.cursize - checksumIndex - 1, cls.netchan.outgoing_sequence);
//
// deliver the message
diff --git a/src/jake2/client/CL_parse.java b/src/jake2/client/CL_parse.java
index ad19960..cbda346 100644
--- a/src/jake2/client/CL_parse.java
+++ b/src/jake2/client/CL_parse.java
@@ -2,7 +2,7 @@
* CL_parse.java
* Copyright (C) 2004
*
- * $Id: CL_parse.java,v 1.4 2004-07-08 20:56:49 hzi Exp $
+ * $Id: CL_parse.java,v 1.4.2.1 2004-07-09 08:38:23 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -360,10 +360,10 @@ public class CL_parse extends CL_view {
entity_state_t nullstate = new entity_state_t(null);
//memset(nullstate, 0, sizeof(nullstate));
- CM.intwrap bits = new CM.intwrap(0);
+ int bits[] = {0};
newnum = CL_ents.ParseEntityBits(bits);
es = cl_entities[newnum].baseline;
- CL_ents.ParseDelta(nullstate, es, newnum, bits.i);
+ CL_ents.ParseDelta(nullstate, es, newnum, bits[0]);
}
/*
diff --git a/src/jake2/client/CL_view.java b/src/jake2/client/CL_view.java
index 08e55c3..b82b350 100644
--- a/src/jake2/client/CL_view.java
+++ b/src/jake2/client/CL_view.java
@@ -2,7 +2,7 @@
* CL_view.java
* Copyright (C) 2004
*
- * $Id: CL_view.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+ * $Id: CL_view.java,v 1.2.2.1 2004-07-09 08:38:24 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,17 +25,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.client;
-import java.util.StringTokenizer;
-
import jake2.qcommon.CM;
import jake2.qcommon.Com;
-import jake2.qcommon.xcommand_t;
import jake2.sys.Sys;
-import jake2.util.Vargs;
-
-
-
+import java.util.StringTokenizer;
public class CL_view extends CL_input {
@@ -50,18 +44,7 @@ public class CL_view extends CL_input {
Call before entering a new level, or after changing dlls
=================
*/
-
- private static xcommand_t prepRefreshCallback = new xcommand_t() {
- public void execute() {
- PrepRefresh2();
- }
- };
-
static void PrepRefresh() {
- re.updateScreen(prepRefreshCallback);
- }
-
- static void PrepRefresh2() {
String mapname;
int i;
String name;
@@ -80,13 +63,13 @@ public class CL_view extends CL_input {
// register models, pics, and skins
Com.Printf("Map: " + mapname + "\r");
- SCR.UpdateScreen2();
+ SCR.UpdateScreen();
re.BeginRegistration(mapname);
Com.Printf(" \r");
// precache status bar pics
Com.Printf("pics\r");
- SCR.UpdateScreen2();
+ SCR.UpdateScreen();
SCR.TouchPics();
Com.Printf(" \r");
@@ -99,11 +82,11 @@ public class CL_view extends CL_input {
name = new String(cl.configstrings[CS_MODELS+i]);
if (name.length() > 37) name = name.substring(0, 36);
- /*
+
if (name.charAt(0) != '*')
- Com.Printf("name" + "\r");
- */
- SCR.UpdateScreen2();
+ Com.Printf(name + "\r");
+
+ SCR.UpdateScreen();
Sys.SendKeyEvents(); // pump message loop
if (name.charAt(0) == '#') {
// special player weapon model
@@ -123,7 +106,7 @@ public class CL_view extends CL_input {
}
Com.Printf("images\r");
- SCR.UpdateScreen2();
+ SCR.UpdateScreen();
for (i=1 ; i<MAX_IMAGES && cl.configstrings[CS_IMAGES+i].length() > 0 ; i++) {
cl.image_precache[i] = re.RegisterPic(cl.configstrings[CS_IMAGES+i]);
Sys.SendKeyEvents(); // pump message loop
@@ -133,8 +116,8 @@ public class CL_view extends CL_input {
for (i=0 ; i<MAX_CLIENTS ; i++) {
if (cl.configstrings[CS_PLAYERSKINS+i].length() == 0)
continue;
- Com.Printf("client %i\r", new Vargs(1).add(i));
- SCR.UpdateScreen2();
+ Com.Printf("client " + i + '\r');
+ SCR.UpdateScreen();
Sys.SendKeyEvents(); // pump message loop
CL.ParseClientinfo(i);
Com.Printf(" \r");
@@ -144,7 +127,7 @@ public class CL_view extends CL_input {
// set sky textures and speed
Com.Printf("sky\r");
- SCR.UpdateScreen2();
+ SCR.UpdateScreen();
rotate = Float.parseFloat(cl.configstrings[CS_SKYROTATE]);
StringTokenizer st = new StringTokenizer(cl.configstrings[CS_SKYAXIS]);
axis[0] = Float.parseFloat(st.nextToken());
@@ -159,7 +142,7 @@ public class CL_view extends CL_input {
// clear any lines of console text
Console.ClearNotify();
- SCR.UpdateScreen2();
+ SCR.UpdateScreen();
cl.refresh_prepped = true;
cl.force_refdef = true; // make sure we have a valid refdef
}
diff --git a/src/jake2/client/Key.java b/src/jake2/client/Key.java
index 0b3e82a..76f3340 100644
--- a/src/jake2/client/Key.java
+++ b/src/jake2/client/Key.java
@@ -2,7 +2,7 @@
* Key.java
* Copyright (C) 2003
*
- * $Id: Key.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: Key.java,v 1.3.2.1 2004-07-09 08:38:24 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -119,7 +119,7 @@ public class Key extends Globals {
static int history_line = 0;
static boolean shift_down = false;
static int[] key_repeats = new int[256];
- static int[] keyshift = new int[256];
+ //static int[] keyshift = new int[256];
static boolean[] menubound = new boolean[256];
static boolean[] consolekeys = new boolean[256];
@@ -241,31 +241,31 @@ public class Key extends Globals {
consolekeys['`'] = false;
consolekeys['~'] = false;
- for (int i = 0; i < 256; i++)
- keyshift[i] = i;
- for (int i = 'a'; i <= 'z'; i++)
- keyshift[i] = i - 'a' + 'A';
- keyshift['1'] = '!';
- keyshift['2'] = '@';
- keyshift['3'] = '#';
- keyshift['4'] = '$';
- keyshift['5'] = '%';
- keyshift['6'] = '^';
- keyshift['7'] = '&';
- keyshift['8'] = '*';
- keyshift['9'] = '(';
- keyshift['0'] = ')';
- keyshift['-'] = '_';
- keyshift['='] = '+';
- keyshift[','] = '<';
- keyshift['.'] = '>';
- keyshift['/'] = '?';
- keyshift[';'] = ':';
- keyshift['\''] = '"';
- keyshift['['] = '{';
- keyshift[']'] = '}';
- keyshift['`'] = '~';
- keyshift['\\'] = '|';
+// for (int i = 0; i < 256; i++)
+// keyshift[i] = i;
+// for (int i = 'a'; i <= 'z'; i++)
+// keyshift[i] = i - 'a' + 'A';
+// keyshift['1'] = '!';
+// keyshift['2'] = '@';
+// keyshift['3'] = '#';
+// keyshift['4'] = '$';
+// keyshift['5'] = '%';
+// keyshift['6'] = '^';
+// keyshift['7'] = '&';
+// keyshift['8'] = '*';
+// keyshift['9'] = '(';
+// keyshift['0'] = ')';
+// keyshift['-'] = '_';
+// keyshift['='] = '+';
+// keyshift[','] = '<';
+// keyshift['.'] = '>';
+// keyshift['/'] = '?';
+// keyshift[';'] = ':';
+// keyshift['\''] = '"';
+// keyshift['['] = '{';
+// keyshift[']'] = '}';
+// keyshift['`'] = '~';
+// keyshift['\\'] = '|';
menubound[K_ESCAPE] = true;
for (int i = 0; i < 12; i++)
@@ -386,13 +386,13 @@ public class Key extends Globals {
cmd = "-" + kb.substring(1) + " " + key + " " + time + "\n";
Cbuf.AddText(cmd);
}
- if (keyshift[key] != key) {
- kb = Globals.keybindings[keyshift[key]];
- if (kb != null && kb.length()>0 && kb.charAt(0) == '+') {
- cmd = "-" + kb.substring(1) + " " + key + " " + time + "\n";
- Cbuf.AddText(cmd);
- }
- }
+// if (keyshift[key] != key) {
+// kb = Globals.keybindings[keyshift[key]];
+// if (kb != null && kb.length()>0 && kb.charAt(0) == '+') {
+// cmd = "-" + kb.substring(1) + " " + key + " " + time + "\n";
+// Cbuf.AddText(cmd);
+// }
+// }
return;
}
@@ -419,8 +419,8 @@ public class Key extends Globals {
if (!down)
return; // other systems only care about key down events
- if (shift_down)
- key = keyshift[key];
+// if (shift_down)
+// key = keyshift[key];
switch (Globals.cls.key_dest) {
case Defines.key_message :
diff --git a/src/jake2/client/Menu.java b/src/jake2/client/Menu.java
index 00944ed..ec71ad7 100644
--- a/src/jake2/client/Menu.java
+++ b/src/jake2/client/Menu.java
@@ -2,7 +2,7 @@
* Menu.java
* Copyright (C) 2004
*
- * $Id: Menu.java,v 1.3 2004-07-08 20:56:49 hzi Exp $
+ * $Id: Menu.java,v 1.3.2.1 2004-07-09 08:38:24 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -1226,7 +1226,7 @@ public final class Menu extends Key {
static menulist_s s_options_joystick_box = new menulist_s();
static menulist_s s_options_cdvolume_box = new menulist_s();
static menulist_s s_options_quality_list = new menulist_s();
- static menulist_s s_options_compatibility_list = new menulist_s();
+ //static menulist_s s_options_compatibility_list = new menulist_s();
static menuaction_s s_options_console_action = new menuaction_s();
static void CrosshairFunc(Object unused) {
@@ -1268,7 +1268,13 @@ public final class Menu extends Key {
static void ControlsSetMenuItemValues() {
s_options_sfxvolume_slider.curvalue = Cvar.VariableValue("s_volume") * 10;
s_options_cdvolume_box.curvalue = 1 - ((int) Cvar.VariableValue("cd_nocd"));
- s_options_quality_list.curvalue = 1 - ((int) Cvar.VariableValue("s_loadas8bit"));
+ //s_options_quality_list.curvalue = 1 - ((int) Cvar.VariableValue("s_loadas8bit"));
+ if ("joal".equals(Cvar.VariableString("s_impl"))) {
+ s_options_quality_list.curvalue = 0;
+ } else {
+ s_options_quality_list.curvalue = 1;
+ }
+
s_options_sensitivity_slider.curvalue = (sensitivity.value) * 2;
Cvar.SetValue("cl_run", ClampCvar(0, 1, cl_run.value));
@@ -1339,30 +1345,41 @@ public final class Menu extends Key {
}
static void UpdateSoundQualityFunc(Object unused) {
+ boolean driverNotChanged = false;
if (s_options_quality_list.curvalue != 0) {
- Cvar.SetValue("s_khz", 22);
- Cvar.SetValue("s_loadas8bit", 0);
+// Cvar.SetValue("s_khz", 22);
+// Cvar.SetValue("s_loadas8bit", 0);
+ driverNotChanged = S.getDriverName().equals("dummy");
+ Cvar.Set("s_impl", "dummy");
}
else {
- Cvar.SetValue("s_khz", 11);
- Cvar.SetValue("s_loadas8bit", 1);
+// Cvar.SetValue("s_khz", 11);
+// Cvar.SetValue("s_loadas8bit", 1);
+ driverNotChanged = S.getDriverName().equals("joal");
+ Cvar.Set("s_impl", "joal");
}
- Cvar.SetValue("s_primary", s_options_compatibility_list.curvalue);
+ //Cvar.SetValue("s_primary", s_options_compatibility_list.curvalue);
- DrawTextBox(8, 120 - 48, 36, 3);
- Print(16 + 16, 120 - 48 + 8, "Restarting the sound system. This");
- Print(16 + 16, 120 - 48 + 16, "could take up to a minute, so");
- Print(16 + 16, 120 - 48 + 24, "please be patient.");
+ if (driverNotChanged) {
+ re.EndFrame();
+ return;
+ } else {
- // the text box won't show up unless we do a buffer swap
- re.EndFrame();
+ DrawTextBox(8, 120 - 48, 36, 3);
+ Print(16 + 16, 120 - 48 + 8, "Restarting the sound system. This");
+ Print(16 + 16, 120 - 48 + 16, "could take up to a minute, so");
+ Print(16 + 16, 120 - 48 + 24, "please be patient.");
- CL.Snd_Restart_f.execute();
+ // the text box won't show up unless we do a buffer swap
+ re.EndFrame();
+
+ CL.Snd_Restart_f.execute();
+ }
}
static String cd_music_items[] = { "disabled", "enabled", null };
- static String quality_items[] = { "low", "high", null };
+ static String soundstate_items[] = { "on", "off", null };
static String compatibility_items[] = { "max compatibility", "max performance", null };
@@ -1410,26 +1427,27 @@ public final class Menu extends Key {
s_options_quality_list.x = 0;
s_options_quality_list.y = 20;
;
- s_options_quality_list.name = "sound quality";
+ s_options_quality_list.name = "sound";
s_options_quality_list.callback = new mcallback() {
public void execute(Object o) {
UpdateSoundQualityFunc(o);
}
};
- s_options_quality_list.itemnames = quality_items;
- s_options_quality_list.curvalue = 1 - (int) Cvar.VariableValue("s_loadas8bit");
-
- s_options_compatibility_list.type = MTYPE_SPINCONTROL;
- s_options_compatibility_list.x = 0;
- s_options_compatibility_list.y = 30;
- s_options_compatibility_list.name = "sound compatibility";
- s_options_compatibility_list.callback = new mcallback() {
- public void execute(Object o) {
- UpdateSoundQualityFunc(o);
- }
- };
- s_options_compatibility_list.itemnames = compatibility_items;
- s_options_compatibility_list.curvalue = (int) Cvar.VariableValue("s_primary");
+ s_options_quality_list.itemnames = soundstate_items;
+ //s_options_quality_list.curvalue = 1 - (int) Cvar.VariableValue("s_loadas8bit");
+
+
+// s_options_compatibility_list.type = MTYPE_SPINCONTROL;
+// s_options_compatibility_list.x = 0;
+// s_options_compatibility_list.y = 30;
+// s_options_compatibility_list.name = "sound compatibility";
+// s_options_compatibility_list.callback = new mcallback() {
+// public void execute(Object o) {
+// UpdateSoundQualityFunc(o);
+// }
+// };
+// s_options_compatibility_list.itemnames = compatibility_items;
+// s_options_compatibility_list.curvalue = (int) Cvar.VariableValue("s_primary");
s_options_sensitivity_slider.type = MTYPE_SLIDER;
s_options_sensitivity_slider.x = 0;
@@ -1563,7 +1581,7 @@ public final class Menu extends Key {
Menu_AddItem(s_options_menu, s_options_cdvolume_box);
Menu_AddItem(s_options_menu, s_options_quality_list);
- Menu_AddItem(s_options_menu, s_options_compatibility_list);
+// Menu_AddItem(s_options_menu, s_options_compatibility_list);
Menu_AddItem(s_options_menu, s_options_sensitivity_slider);
Menu_AddItem(s_options_menu, s_options_alwaysrun_box);
Menu_AddItem(s_options_menu, s_options_invertmouse_box);
@@ -1653,7 +1671,7 @@ public final class Menu extends Key {
"John Cash",
"Brian Hook",
"",
- "+JAVA PORT BY JTEAM",
+ "+JAVA PORT BY BYTONIC",
"CWEI",
"HOZ",
"RST",
@@ -2945,6 +2963,7 @@ public final class Menu extends Key {
s_hostname_field.length = 12;
s_hostname_field.visible_length = 12;
s_hostname_field.buffer = new StringBuffer(Cvar.VariableString("hostname"));
+ s_hostname_field.cursor = s_hostname_field.buffer.length();
s_startserver_dmoptions_action.type = MTYPE_ACTION;
s_startserver_dmoptions_action.name = " deathmatch flags";
@@ -4464,7 +4483,7 @@ public final class Menu extends Key {
}
Menu_DrawString(f.x + f.parent.x + 24, f.y + f.parent.y, tempbuffer);
-
+
if (Menu_ItemAtCursor(f.parent) == f) {
int offset;
diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java
index 66b5c33..425250d 100644
--- a/src/jake2/client/SCR.java
+++ b/src/jake2/client/SCR.java
@@ -2,7 +2,7 @@
* SCR.java
* Copyright (C) 2003
*
- * $Id: SCR.java,v 1.4 2004-07-08 20:56:49 hzi Exp $
+ * $Id: SCR.java,v 1.4.2.1 2004-07-09 08:38:24 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -84,7 +84,7 @@ 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;
+ public static cvar_t fps;
static dirty_t scr_dirty = new dirty_t();
static dirty_t[] scr_old_dirty = { new dirty_t(), new dirty_t()};
@@ -98,6 +98,17 @@ public final class SCR extends Globals
int x2;
int y1;
int y2;
+
+ void set(dirty_t src) {
+ x1 = src.x1;
+ x2 = src.x2;
+ y1 = src.y1;
+ y2 = src.y2;
+ }
+
+ void clear() {
+ x1 = x2 = y1 = y2 = 0;
+ }
}
/*
@@ -700,11 +711,14 @@ public final class SCR extends Globals
Clear any parts of the tiled background that were drawn on last frame
==============
*/
+
+ static dirty_t clear = new dirty_t();
+
static void TileClear()
{
int i;
int top, bottom, left, right;
- dirty_t clear = new dirty_t();
+ clear.clear();
if (scr_drawall.value != 0)
DirtyScreen(); // for power vr or broken page flippers...
@@ -718,7 +732,7 @@ public final class SCR extends Globals
// erase rect will be the union of the past three frames
// so tripple buffering works properly
- clear = scr_dirty;
+ clear.set(scr_dirty);
for (i = 0; i < 2; i++)
{
if (scr_old_dirty[i].x1 < clear.x1)
@@ -731,8 +745,8 @@ public final class SCR extends Globals
clear.y2 = scr_old_dirty[i].y2;
}
- scr_old_dirty[1] = scr_old_dirty[0];
- scr_old_dirty[0] = scr_dirty;
+ scr_old_dirty[1].set(scr_old_dirty[0]);
+ scr_old_dirty[0].set(scr_dirty);
scr_dirty.x1 = 9999;
scr_dirty.x2 = -9999;
@@ -1452,10 +1466,16 @@ public final class SCR extends Globals
private static int lastframes = 0;
private static int lasttime = 0;
private static String fpsvalue = "";
+
static void DrawFPS()
{
if (fps.value > 0.0f)
{
+ if (fps.modified) {
+ fps.modified = false;
+ Cvar.SetValue("cl_maxfps", 1000);
+ }
+
int diff = cls.realtime - lasttime;
if (diff > (int) (fps.value * 1000))
{
@@ -1469,6 +1489,9 @@ public final class SCR extends Globals
re.DrawChar(x, 2, fpsvalue.charAt(i));
x += 8;
}
+ } else if (fps.modified){
+ fps.modified = false;
+ Cvar.SetValue("cl_maxfps", 90);
}
}
diff --git a/src/jake2/client/V.java b/src/jake2/client/V.java
index 3b9d139..a522360 100644
--- a/src/jake2/client/V.java
+++ b/src/jake2/client/V.java
@@ -2,7 +2,7 @@
* V.java
* Copyright (C) 2003
*
- * $Id: V.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+ * $Id: V.java,v 1.1.1.1.2.1 2004-07-09 08:38:24 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -34,6 +34,7 @@ import jake2.util.Math3D;
import jake2.util.Vargs;
import java.io.IOException;
+import java.nio.FloatBuffer;
/**
* V
@@ -53,7 +54,7 @@ public final class V extends Globals {
static entity_t[] r_entities = new entity_t[MAX_ENTITIES];
static int r_numparticles;
- static particle_t[] r_particles = new particle_t[MAX_PARTICLES];
+ //static particle_t[] r_particles = new particle_t[MAX_PARTICLES];
static lightstyle_t[] r_lightstyles = new lightstyle_t[MAX_LIGHTSTYLES];
static {
@@ -61,8 +62,6 @@ public final class V extends Globals {
r_dlights[i] = new dlight_t();
for (int i = 0; i < r_entities.length; i++)
r_entities[i] = new entity_t();
- for (int i = 0; i < r_particles.length; i++)
- r_particles[i] = new particle_t();
for (int i = 0; i < r_lightstyles.length; i++)
r_lightstyles[i] = new lightstyle_t();
}
@@ -99,16 +98,20 @@ public final class V extends Globals {
=====================
*/
static void AddParticle(float[] org, int color, float alpha) {
- particle_t p;
-
if (r_numparticles >= MAX_PARTICLES)
return;
- p = r_particles[r_numparticles++];
+ int i = r_numparticles++;
- VectorCopy(org, p.origin);
- p.color = color;
- p.alpha = alpha;
+ int c = particle_t.colorTable[color];
+ c |= (int)(alpha * 255) << 24;
+ particle_t.colorArray.put(i, c);
+
+ i *= 3;
+ FloatBuffer vertexBuf = particle_t.vertexArray;
+ vertexBuf.put(i++, org[0]);
+ vertexBuf.put(i++, org[1]);
+ vertexBuf.put(i++, org[2]);
}
/*
@@ -158,26 +161,25 @@ public final class V extends Globals {
================
*/
static void TestParticles() {
- particle_t p;
int i, j;
float d, r, u;
- r_numparticles = MAX_PARTICLES;
- for (i = 0; i < r_numparticles; i++) {
+ float[] origin = {0,0,0};
+
+ r_numparticles = 0;
+ for (i = 0; i < MAX_PARTICLES; i++) {
d = i * 0.25f;
r = 4 * ((i & 7) - 3.5f);
u = 4 * (((i >> 3) & 7) - 3.5f);
- p = r_particles[i];
for (j = 0; j < 3; j++)
- p.origin[j] =
+ origin[j] =
cl.refdef.vieworg[j]
+ cl.v_forward[j] * d
+ cl.v_right[j] * r
+ cl.v_up[j] * u;
- p.color = 8;
- p.alpha = cl_testparticles.value;
+ AddParticle(origin, 8, cl_testparticles.value);
}
}
@@ -356,7 +358,6 @@ public final class V extends Globals {
cl.refdef.num_entities = r_numentities;
cl.refdef.entities = r_entities;
cl.refdef.num_particles = r_numparticles;
- cl.refdef.particles = r_particles;
cl.refdef.num_dlights = r_numdlights;
cl.refdef.dlights = r_dlights;
cl.refdef.lightstyles = r_lightstyles;
diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java
index 53a943f..b96ac61 100644
--- a/src/jake2/client/VID.java
+++ b/src/jake2/client/VID.java
@@ -2,7 +2,7 @@
* VID.java
* Copyright (C) 2003
*
- * $Id: VID.java,v 1.4 2004-07-08 20:56:50 hzi Exp $
+ * $Id: VID.java,v 1.4.2.1 2004-07-09 08:38:24 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -370,7 +370,7 @@ public class VID extends Globals {
public static void Init()
{
/* Create the video variables so we know how to start the graphics drivers */
- vid_ref = Cvar.Get("vid_ref", "jogl", CVAR_ARCHIVE);
+ vid_ref = Cvar.Get("vid_ref", "fastjogl", CVAR_ARCHIVE);
vid_xpos = Cvar.Get("vid_xpos", "3", CVAR_ARCHIVE);
vid_ypos = Cvar.Get("vid_ypos", "22", CVAR_ARCHIVE);
vid_fullscreen = Cvar.Get("vid_fullscreen", "0", CVAR_ARCHIVE);
@@ -419,6 +419,7 @@ public class VID extends Globals {
// #define REF_3DFXGL 3
// #define REF_OPENGLX 4
static final int REF_OPENGL_JOGL = 0;
+ static final int REF_OPENGL_FASTJOGL =1;
// #define REF_MESA3DGLX 5
// extern cvar_t *vid_ref;
@@ -605,6 +606,12 @@ public class VID extends Globals {
if (gl_driver.modified)
vid_ref.modified = true;
break;
+ case REF_OPENGL_FASTJOGL :
+ Cvar.Set( "vid_ref", "fastjogl" );
+ Cvar.Set( "gl_driver", "fastjogl" );
+ if (gl_driver.modified)
+ vid_ref.modified = true;
+ break;
}
Menu.ForceMenuOff();
@@ -634,6 +641,7 @@ public class VID extends Globals {
// "[OpenGL glX ]",
// "[Mesa 3-D glX ]",
"[OpenGL jogl ]",
+ "[OpenGL fastjogl]",
null
};
static final String[] yesno_names =
@@ -686,6 +694,11 @@ public class VID extends Globals {
s_current_menu_index = OPENGL_MENU;
s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_OPENGL_JOGL;
}
+ else if ( vid_ref.string.equalsIgnoreCase("fastjogl"))
+ {
+ s_current_menu_index = OPENGL_MENU;
+ s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_OPENGL_FASTJOGL;
+ }
// else if (strcmp( vid_ref->string, "softx" ) == 0 )
// {
// s_current_menu_index = SOFTWARE_MENU;
diff --git a/src/jake2/client/client_state_t.java b/src/jake2/client/client_state_t.java
index ff86070..5421cbe 100644
--- a/src/jake2/client/client_state_t.java
+++ b/src/jake2/client/client_state_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-//$Id: client_state_t.java,v 1.2 2004-07-08 20:56:51 hzi Exp $
+//$Id: client_state_t.java,v 1.2.2.1 2004-07-09 08:38:24 hzi Exp $
package jake2.client;
@@ -57,7 +57,7 @@ public class client_state_t {
int timedemo_start;
public boolean refresh_prepped; // false if on new level or new ref dll
- boolean sound_prepped; // ambient sounds can start
+ public boolean sound_prepped; // ambient sounds can start
boolean force_refdef; // vid has changed, so we can't use a paused refdef
int parse_entities; // index (not anded off) into cl_parse_entities[]
@@ -129,7 +129,7 @@ public class client_state_t {
model_t model_draw[] = new model_t[Defines.MAX_MODELS];
cmodel_t model_clip[] = new cmodel_t[Defines.MAX_MODELS];
- sfx_t sound_precache[] = new sfx_t[Defines.MAX_SOUNDS];
+ public sfx_t sound_precache[] = new sfx_t[Defines.MAX_SOUNDS];
image_t image_precache[] = new image_t[Defines.MAX_IMAGES];
clientinfo_t clientinfo[] = new clientinfo_t[Defines.MAX_CLIENTS];
diff --git a/src/jake2/client/frame_t.java b/src/jake2/client/frame_t.java
index 1e414dc..35e40a0 100644
--- a/src/jake2/client/frame_t.java
+++ b/src/jake2/client/frame_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-// $Id: frame_t.java,v 1.2 2004-07-08 20:56:50 hzi Exp $
+// $Id: frame_t.java,v 1.2.2.1 2004-07-09 08:38:24 hzi Exp $
package jake2.client;
@@ -27,7 +27,7 @@ import jake2.game.player_state_t;
import java.util.Arrays;
-public class frame_t implements Cloneable {
+public class frame_t {
public static final int MAX_MAP_AREAS = 256;
@@ -37,8 +37,8 @@ public class frame_t implements Cloneable {
int deltaframe;
byte areabits[] = new byte [MAX_MAP_AREAS/8]; // portalarea visibility bits
public player_state_t playerstate = new player_state_t(); // mem
- int num_entities;
- int parse_entities; // non-masked index into cl_parse_entities array
+ public int num_entities;
+ public int parse_entities; // non-masked index into cl_parse_entities array
public void set(frame_t from) {
valid = from.valid;
diff --git a/src/jake2/client/particle_t.java b/src/jake2/client/particle_t.java
index 2127b5d..7de8348 100644
--- a/src/jake2/client/particle_t.java
+++ b/src/jake2/client/particle_t.java
@@ -19,12 +19,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 20.11.2003 by RST.
-// $Id: particle_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+// $Id: particle_t.java,v 1.1.1.1.2.1 2004-07-09 08:38:23 hzi Exp $
package jake2.client;
+import jake2.Defines;
+import jake2.util.Lib;
+
+import java.nio.*;
+
public class particle_t {
- public float origin[] = { 0, 0, 0 };
- public int color;
- public float alpha;
+
+ public static FloatBuffer vertexArray = Lib.newFloatBuffer(Defines.MAX_PARTICLES * 3);
+ public static IntBuffer colorArray = Lib.newIntBuffer(Defines.MAX_PARTICLES, ByteOrder.LITTLE_ENDIAN);
+ public static int[] colorTable = new int[256];
+
+ public static void setColorPalette(int[] palette) {
+ for (int i=0; i < 256; i++) {
+ colorTable[i] = palette[i] & 0x00FFFFFF;
+ }
+ }
}
diff --git a/src/jake2/client/refdef_t.java b/src/jake2/client/refdef_t.java
index a01ab06..cea75df 100644
--- a/src/jake2/client/refdef_t.java
+++ b/src/jake2/client/refdef_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 20.11.2003 by RST.
-// $Id: refdef_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+// $Id: refdef_t.java,v 1.1.1.1.2.1 2004-07-09 08:38:24 hzi Exp $
package jake2.client;
@@ -43,5 +43,5 @@ public class refdef_t {
public dlight_t dlights[];
public int num_particles;
- public particle_t particles[];
+ //public particle_t particles[];
}
diff --git a/src/jake2/game/Cmd.java b/src/jake2/game/Cmd.java
index bbb6742..0fd0105 100644
--- a/src/jake2/game/Cmd.java
+++ b/src/jake2/game/Cmd.java
@@ -2,7 +2,7 @@
* Cmd.java
* Copyright (C) 2003
*
- * $Id: Cmd.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
+ * $Id: Cmd.java,v 1.2.2.1 2004-07-09 08:38:28 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -35,32 +35,40 @@ import java.util.Arrays;
/**
* Cmd
*/
-public final class Cmd extends PlayerView {
+public final class Cmd extends PlayerView
+{
- static xcommand_t List_f = new xcommand_t() {
- public void execute() {
- cmd_function_t cmd = Cmd.cmd_functions;
- int i = 0;
+ static xcommand_t List_f= new xcommand_t()
+ {
+ public void execute()
+ {
+ cmd_function_t cmd= Cmd.cmd_functions;
+ int i= 0;
- while (cmd != null) {
+ while (cmd != null)
+ {
Com.Printf(cmd.name + '\n');
i++;
- cmd = cmd.next;
+ cmd= cmd.next;
}
Com.Printf(i + " commands\n");
}
};
- static xcommand_t Exec_f = new xcommand_t() {
- public void execute() {
- if (Cmd.Argc() != 2) {
+ static xcommand_t Exec_f= new xcommand_t()
+ {
+ public void execute()
+ {
+ if (Cmd.Argc() != 2)
+ {
Com.Printf("exec <filename> : execute a script file\n");
return;
}
- byte[] f = null;
- f = FS.LoadFile(Cmd.Argv(1));
- if (f == null) {
+ byte[] f= null;
+ f= FS.LoadFile(Cmd.Argv(1));
+ if (f == null)
+ {
Com.Printf("couldn't exec " + Cmd.Argv(1) + "\n");
return;
}
@@ -71,77 +79,93 @@ public final class Cmd extends PlayerView {
FS.FreeFile(f);
}
};
- static xcommand_t Echo_f = new xcommand_t() {
- public void execute() {
- for (int i = 1; i < Cmd.Argc(); i++) {
+
+ static xcommand_t Echo_f= new xcommand_t()
+ {
+ public void execute()
+ {
+ for (int i= 1; i < Cmd.Argc(); i++)
+ {
Com.Printf(Cmd.Argv(i) + " ");
}
Com.Printf("'\n");
}
};
- static xcommand_t Alias_f = new xcommand_t() {
- public void execute() {
- cmdalias_t a = null;
- if (Cmd.Argc() == 1) {
+ static xcommand_t Alias_f= new xcommand_t()
+ {
+ public void execute()
+ {
+ cmdalias_t a= null;
+ if (Cmd.Argc() == 1)
+ {
Com.Printf("Current alias commands:\n");
- for (a = Globals.cmd_alias; a != null; a = a.next) {
+ for (a= Globals.cmd_alias; a != null; a= a.next)
+ {
Com.Printf(a.name + " : " + a.value);
}
return;
}
- String s = Cmd.Argv(1);
- if (s.length() > Globals.MAX_ALIAS_NAME) {
+ String s= Cmd.Argv(1);
+ if (s.length() > Globals.MAX_ALIAS_NAME)
+ {
Com.Printf("Alias name is too long\n");
return;
}
// if the alias already exists, reuse it
- for (a = Globals.cmd_alias; a != null; a = a.next) {
- if (s.equalsIgnoreCase(a.name)) {
- a.value = null;
+ for (a= Globals.cmd_alias; a != null; a= a.next)
+ {
+ if (s.equalsIgnoreCase(a.name))
+ {
+ a.value= null;
break;
}
}
- if (a == null) {
- a = new cmdalias_t();
- a.next = Globals.cmd_alias;
- Globals.cmd_alias = a;
+ if (a == null)
+ {
+ a= new cmdalias_t();
+ a.next= Globals.cmd_alias;
+ Globals.cmd_alias= a;
}
- a.name = s;
+ a.name= s;
// copy the rest of the command line
- String cmd = "";
- int c = Cmd.Argc();
- for (int i = 2; i < c; i++) {
- cmd = cmd + Cmd.Argv(i);
+ String cmd= "";
+ int c= Cmd.Argc();
+ for (int i= 2; i < c; i++)
+ {
+ cmd= cmd + Cmd.Argv(i);
if (i != (c - 1))
- cmd = cmd + " ";
+ cmd= cmd + " ";
}
- cmd = cmd + "\n";
+ cmd= cmd + "\n";
- a.value = cmd;
+ a.value= cmd;
}
};
- public static xcommand_t Wait_f = new xcommand_t() {
- public void execute() {
- Globals.cmd_wait = true;
+ public static xcommand_t Wait_f= new xcommand_t()
+ {
+ public void execute()
+ {
+ Globals.cmd_wait= true;
}
};
- public static cmd_function_t cmd_functions = null;
+ public static cmd_function_t cmd_functions= null;
public static int cmd_argc;
- public static String[] cmd_argv = new String[Globals.MAX_STRING_TOKENS];
+ public static String[] cmd_argv= new String[Globals.MAX_STRING_TOKENS];
public static String cmd_args;
- public static final int ALIAS_LOOP_COUNT = 16;
+ public static final int ALIAS_LOOP_COUNT= 16;
/**
* register our commands
*/
- public static void Init() {
+ public static void Init()
+ {
Cmd.AddCommand("exec", Exec_f);
Cmd.AddCommand("echo", Echo_f);
@@ -150,34 +174,37 @@ public final class Cmd extends PlayerView {
Cmd.AddCommand("wait", Wait_f);
}
- private static char expanded[] = new char[MAX_STRING_CHARS];
- private static char temporary[] = new char[MAX_STRING_CHARS];
+ private static char expanded[]= new char[MAX_STRING_CHARS];
+ private static char temporary[]= new char[MAX_STRING_CHARS];
/*
======================
Cmd_MacroExpandString
======================
*/
- public static char[] MacroExpandString(char text[], int len) {
+ public static char[] MacroExpandString(char text[], int len)
+ {
int i, j, count;
boolean inquote;
char scan[];
String token;
- inquote = false;
+ inquote= false;
- scan = text;
+ scan= text;
- if (len >= MAX_STRING_CHARS) {
+ if (len >= MAX_STRING_CHARS)
+ {
Com.Printf("Line exceeded " + MAX_STRING_CHARS + " chars, discarded.\n");
return null;
}
- count = 0;
+ count= 0;
- for (i = 0; i < len; i++) {
+ for (i= 0; i < len; i++)
+ {
if (scan[i] == '"')
- inquote = !inquote;
+ inquote= !inquote;
if (inquote)
continue; // don't expand inside quotes
@@ -186,19 +213,20 @@ public final class Cmd extends PlayerView {
continue;
// scan out the complete macro, without $
- Com.ParseHelp ph = new Com.ParseHelp(text, i + 1);
- token = Com.Parse(ph);
+ Com.ParseHelp ph= new Com.ParseHelp(text, i + 1);
+ token= Com.Parse(ph);
if (ph.data == null)
continue;
- token = Cvar.VariableString(token);
+ token= Cvar.VariableString(token);
- j = token.length();
+ j= token.length();
len += j;
- if (len >= MAX_STRING_CHARS) {
+ if (len >= MAX_STRING_CHARS)
+ {
Com.Printf("Expanded line exceeded " + MAX_STRING_CHARS + " chars, discarded.\n");
return null;
}
@@ -214,16 +242,18 @@ public final class Cmd extends PlayerView {
//strcpy(expanded, temporary);
System.arraycopy(temporary, 0, expanded, 0, 0);
- scan = expanded;
+ scan= expanded;
i--;
- if (++count == 100) {
+ if (++count == 100)
+ {
Com.Printf("Macro expansion loop, discarded.\n");
return null;
}
}
- if (inquote) {
+ if (inquote)
+ {
Com.Printf("Line has unmatched quote, discarded.\n");
return null;
}
@@ -239,31 +269,34 @@ public final class Cmd extends PlayerView {
$Cvars will be expanded unless they are in a quoted token
============
*/
- public static void TokenizeString(char text[], boolean macroExpand) {
+ public static void TokenizeString(char text[], boolean macroExpand)
+ {
String com_token;
- cmd_argc = 0;
+ cmd_argc= 0;
- int len = strlen(text);
+ int len= strlen(text);
// macro expand the text
if (macroExpand)
- text = MacroExpandString(text, len);
+ text= MacroExpandString(text, len);
if (text == null)
return;
- len = strlen(text);
+ len= strlen(text);
- Com.ParseHelp ph = new Com.ParseHelp(text);
+ Com.ParseHelp ph= new Com.ParseHelp(text);
- while (true) {
+ while (true)
+ {
// skip whitespace up to a /n
- char c = ph.skipwhitestoeol();
+ char c= ph.skipwhitestoeol();
- if (c == '\n') { // a newline seperates commands in the buffer
- c = ph.nextchar();
+ if (c == '\n')
+ { // a newline seperates commands in the buffer
+ c= ph.nextchar();
break;
}
@@ -271,46 +304,52 @@ public final class Cmd extends PlayerView {
return;
// set cmd_args to everything after the first arg
- if (cmd_argc == 1) {
- cmd_args = new String(text, ph.index, len - ph.index);
+ if (cmd_argc == 1)
+ {
+ cmd_args= new String(text, ph.index, len - ph.index);
cmd_args.trim();
}
- com_token = Com.Parse(ph);
+ com_token= Com.Parse(ph);
if (com_token.length() == 0)
return;
- if (cmd_argc < MAX_STRING_TOKENS) {
- cmd_argv[cmd_argc] = com_token;
+ if (cmd_argc < MAX_STRING_TOKENS)
+ {
+ cmd_argv[cmd_argc]= com_token;
cmd_argc++;
}
}
}
- public static void AddCommand(String cmd_name, xcommand_t function) {
+ public static void AddCommand(String cmd_name, xcommand_t function)
+ {
cmd_function_t cmd;
//Com.DPrintf("Cmd_AddCommand: " + cmd_name + "\n");
// fail if the command is a variable name
- if ((Cvar.VariableString(cmd_name)).length() > 0) {
+ if ((Cvar.VariableString(cmd_name)).length() > 0)
+ {
Com.Printf("Cmd_AddCommand: " + cmd_name + " already defined as a var\n");
return;
}
// fail if the command already exists
- for (cmd = cmd_functions; cmd != null; cmd = cmd.next) {
- if (cmd_name.equals(cmd.name)) {
+ for (cmd= cmd_functions; cmd != null; cmd= cmd.next)
+ {
+ if (cmd_name.equals(cmd.name))
+ {
Com.Printf("Cmd_AddCommand: " + cmd_name + " already defined\n");
return;
}
}
- cmd = new cmd_function_t();
- cmd.name = cmd_name;
-
- cmd.function = function;
- cmd.next = cmd_functions;
- cmd_functions = cmd;
+ cmd= new cmd_function_t();
+ cmd.name= cmd_name;
+
+ cmd.function= function;
+ cmd.next= cmd_functions;
+ cmd_functions= cmd;
}
/*
@@ -318,26 +357,30 @@ public final class Cmd extends PlayerView {
Cmd_RemoveCommand
============
*/
- public static void RemoveCommand(String cmd_name) {
- cmd_function_t cmd, back = null;
+ public static void RemoveCommand(String cmd_name)
+ {
+ cmd_function_t cmd, back= null;
- back = cmd = cmd_functions;
+ back= cmd= cmd_functions;
- while (true) {
+ while (true)
+ {
- if (cmd == null) {
+ if (cmd == null)
+ {
Com.Printf("Cmd_RemoveCommand: " + cmd_name + " not added\n");
return;
}
- if (0 == strcmp(cmd_name, cmd.name)) {
+ if (0 == strcmp(cmd_name, cmd.name))
+ {
if (cmd == cmd_functions)
- cmd_functions = cmd.next;
+ cmd_functions= cmd.next;
else
- back.next = cmd.next;
+ back.next= cmd.next;
return;
}
- back = cmd;
- cmd = cmd.next;
+ back= cmd;
+ cmd= cmd.next;
}
}
@@ -346,10 +389,12 @@ public final class Cmd extends PlayerView {
Cmd_Exists
============
*/
- public static boolean Exists(String cmd_name) {
+ public static boolean Exists(String cmd_name)
+ {
cmd_function_t cmd;
- for (cmd = cmd_functions; cmd != null; cmd = cmd.next) {
+ for (cmd= cmd_functions; cmd != null; cmd= cmd.next)
+ {
if (0 == strcmp(cmd_name, cmd.name))
return true;
}
@@ -357,17 +402,20 @@ public final class Cmd extends PlayerView {
return false;
}
- public static int Argc() {
+ public static int Argc()
+ {
return cmd_argc;
}
- public static String Argv(int i) {
+ public static String Argv(int i)
+ {
if (i < 0 || i >= cmd_argc)
return "";
return cmd_argv[i];
}
- public static String Args() {
+ public static String Args()
+ {
return new String(cmd_args);
}
@@ -379,48 +427,49 @@ public final class Cmd extends PlayerView {
FIXME: lookupnoadd the token to speed search?
============
*/
- public static void ExecuteString(String text) {
+ public static void ExecuteString(String text)
+ {
cmd_function_t cmd;
cmdalias_t a;
TokenizeString(text.toCharArray(), true);
-// if (Argc() > 0) {
-// Com.DPrintf("tokenized:");
-// for (int xxx = 0; xxx < Argc(); xxx++)
-// Com.DPrintf("[" + Argv(xxx) + "]");
-//
-// Com.DPrintf("\n");
-// }
+ // if (Argc() > 0) {
+ // Com.DPrintf("tokenized:");
+ // for (int xxx = 0; xxx < Argc(); xxx++)
+ // Com.DPrintf("[" + Argv(xxx) + "]");
+ //
+ // Com.DPrintf("\n");
+ // }
// execute the command line
if (Argc() == 0)
return; // no tokens
// check functions
- for (cmd = cmd_functions; cmd != null; cmd = cmd.next) {
- if (cmd_argv[0].equalsIgnoreCase(cmd.name)) {
- if (null == cmd.function) { // forward to server command
+ for (cmd= cmd_functions; cmd != null; cmd= cmd.next)
+ {
+ if (cmd_argv[0].equalsIgnoreCase(cmd.name))
+ {
+ if (null == cmd.function)
+ { // forward to server command
Cmd.ExecuteString("cmd " + text);
+ } else {
+ cmd.function.execute();
}
- else
- try {
- cmd.function.execute();
- }
- catch (Exception e) {
- System.err.println("Exception in executing a command " + cmd.name + ":");
- e.printStackTrace();
- }
return;
}
}
// check alias
- for (a = cmd_alias; a != null; a = a.next) {
+ for (a= cmd_alias; a != null; a= a.next)
+ {
- if (cmd_argv[0].equalsIgnoreCase(a.name)) {
+ if (cmd_argv[0].equalsIgnoreCase(a.name))
+ {
- if (++alias_count == ALIAS_LOOP_COUNT) {
+ if (++alias_count == ALIAS_LOOP_COUNT)
+ {
Com.Printf("ALIAS_LOOP_COUNT\n");
return;
}
@@ -444,7 +493,8 @@ public final class Cmd extends PlayerView {
Give items to a client
==================
*/
- public static void Give_f(edict_t ent) {
+ public static void Give_f(edict_t ent)
+ {
String name;
gitem_t it;
int index;
@@ -452,30 +502,34 @@ public final class Cmd extends PlayerView {
boolean give_all;
edict_t it_ent;
- if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0) {
+ if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
}
- name = GameBase.gi.args();
+ name= GameBase.gi.args();
if (0 == Lib.Q_stricmp(name, "all"))
- give_all = true;
+ give_all= true;
else
- give_all = false;
+ give_all= false;
- if (give_all || 0 == Lib.Q_stricmp(GameBase.gi.argv(1), "health")) {
+ if (give_all || 0 == Lib.Q_stricmp(GameBase.gi.argv(1), "health"))
+ {
if (GameBase.gi.argc() == 3)
- ent.health = Lib.atoi(GameBase.gi.argv(2));
+ ent.health= Lib.atoi(GameBase.gi.argv(2));
else
- ent.health = ent.max_health;
+ ent.health= ent.max_health;
if (!give_all)
return;
}
- if (give_all || 0 == Lib.Q_stricmp(name, "weapons")) {
- for (i = 1; i < GameBase.game.num_items; i++) {
- it = GameAI.itemlist[i];
+ if (give_all || 0 == Lib.Q_stricmp(name, "weapons"))
+ {
+ for (i= 1; i < GameBase.game.num_items; i++)
+ {
+ it= GameAI.itemlist[i];
if (null == it.pickup)
continue;
if (0 == (it.flags & Defines.IT_WEAPON))
@@ -486,9 +540,11 @@ public final class Cmd extends PlayerView {
return;
}
- if (give_all || 0 == Lib.Q_stricmp(name, "ammo")) {
- for (i = 1; i < GameBase.game.num_items; i++) {
- it = GameAI.itemlist[i];
+ if (give_all || 0 == Lib.Q_stricmp(name, "ammo"))
+ {
+ for (i= 1; i < GameBase.game.num_items; i++)
+ {
+ it= GameAI.itemlist[i];
if (null == it.pickup)
continue;
if (0 == (it.flags & Defines.IT_AMMO))
@@ -499,27 +555,29 @@ public final class Cmd extends PlayerView {
return;
}
- if (give_all || Lib.Q_stricmp(name, "armor") == 0) {
+ if (give_all || Lib.Q_stricmp(name, "armor") == 0)
+ {
gitem_armor_t info;
- it = GameUtil.FindItem("Jacket Armor");
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)] = 0;
+ it= GameUtil.FindItem("Jacket Armor");
+ ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)]= 0;
- it = GameUtil.FindItem("Combat Armor");
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)] = 0;
+ it= GameUtil.FindItem("Combat Armor");
+ ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)]= 0;
- it = GameUtil.FindItem("Body Armor");
- info = (gitem_armor_t) it.info;
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)] = info.max_count;
+ it= GameUtil.FindItem("Body Armor");
+ info= (gitem_armor_t) it.info;
+ ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)]= info.max_count;
if (!give_all)
return;
}
- if (give_all || Lib.Q_stricmp(name, "Power Shield") == 0) {
- it = GameUtil.FindItem("Power Shield");
- it_ent = GameUtil.G_Spawn();
- it_ent.classname = it.classname;
+ if (give_all || Lib.Q_stricmp(name, "Power Shield") == 0)
+ {
+ it= GameUtil.FindItem("Power Shield");
+ it_ent= GameUtil.G_Spawn();
+ it_ent.classname= it.classname;
GameAI.SpawnItem(it_ent, it);
GameAI.Touch_Item(it_ent, ent, GameBase.dummyplane, null);
if (it_ent.inuse)
@@ -529,44 +587,51 @@ public final class Cmd extends PlayerView {
return;
}
- if (give_all) {
- for (i = 1; i < GameBase.game.num_items; i++) {
- it = GameAI.itemlist[i];
+ if (give_all)
+ {
+ for (i= 1; i < GameBase.game.num_items; i++)
+ {
+ it= GameAI.itemlist[i];
if (it.pickup != null)
continue;
if ((it.flags & (Defines.IT_ARMOR | Defines.IT_WEAPON | Defines.IT_AMMO)) != 0)
continue;
- ent.client.pers.inventory[i] = 1;
+ ent.client.pers.inventory[i]= 1;
}
return;
}
- it = GameUtil.FindItem(name);
- if (it == null) {
- name = GameBase.gi.argv(1);
- it = GameUtil.FindItem(name);
- if (it == null) {
+ it= GameUtil.FindItem(name);
+ if (it == null)
+ {
+ name= GameBase.gi.argv(1);
+ it= GameUtil.FindItem(name);
+ if (it == null)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "unknown item\n");
return;
}
}
- if (it.pickup == null) {
+ if (it.pickup == null)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "non-pickup item\n");
return;
}
- index = GameUtil.ITEM_INDEX(it);
+ index= GameUtil.ITEM_INDEX(it);
- if ((it.flags & Defines.IT_AMMO) != 0) {
+ if ((it.flags & Defines.IT_AMMO) != 0)
+ {
if (GameBase.gi.argc() == 3)
- ent.client.pers.inventory[index] = Lib.atoi(GameBase.gi.argv(2));
+ ent.client.pers.inventory[index]= Lib.atoi(GameBase.gi.argv(2));
else
ent.client.pers.inventory[index] += it.quantity;
}
- else {
- it_ent = GameUtil.G_Spawn();
- it_ent.classname = it.classname;
+ else
+ {
+ it_ent= GameUtil.G_Spawn();
+ it_ent.classname= it.classname;
GameAI.SpawnItem(it_ent, it);
GameAI.Touch_Item(it_ent, ent, GameBase.dummyplane, null);
if (it_ent.inuse)
@@ -583,19 +648,21 @@ public final class Cmd extends PlayerView {
argv(0) god
==================
*/
- public static void God_f(edict_t ent) {
+ public static void God_f(edict_t ent)
+ {
String msg;
- if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0) {
+ if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
}
ent.flags ^= Defines.FL_GODMODE;
if (0 == (ent.flags & Defines.FL_GODMODE))
- msg = "godmode OFF\n";
+ msg= "godmode OFF\n";
else
- msg = "godmode ON\n";
+ msg= "godmode ON\n";
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, msg);
}
@@ -609,19 +676,21 @@ public final class Cmd extends PlayerView {
argv(0) notarget
==================
*/
- public static void Notarget_f(edict_t ent) {
+ public static void Notarget_f(edict_t ent)
+ {
String msg;
- if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) {
+ if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
}
ent.flags ^= Defines.FL_NOTARGET;
if (0 == (ent.flags & Defines.FL_NOTARGET))
- msg = "notarget OFF\n";
+ msg= "notarget OFF\n";
else
- msg = "notarget ON\n";
+ msg= "notarget ON\n";
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, msg);
}
@@ -633,21 +702,25 @@ public final class Cmd extends PlayerView {
argv(0) noclip
==================
*/
- public static void Noclip_f(edict_t ent) {
+ public static void Noclip_f(edict_t ent)
+ {
String msg;
- if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) {
+ if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
return;
}
- if (ent.movetype == Defines.MOVETYPE_NOCLIP) {
- ent.movetype = Defines.MOVETYPE_WALK;
- msg = "noclip OFF\n";
+ if (ent.movetype == Defines.MOVETYPE_NOCLIP)
+ {
+ ent.movetype= Defines.MOVETYPE_WALK;
+ msg= "noclip OFF\n";
}
- else {
- ent.movetype = Defines.MOVETYPE_NOCLIP;
- msg = "noclip ON\n";
+ else
+ {
+ ent.movetype= Defines.MOVETYPE_NOCLIP;
+ msg= "noclip ON\n";
}
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, msg);
@@ -660,23 +733,27 @@ public final class Cmd extends PlayerView {
Use an inventory item
==================
*/
- public static void Use_f(edict_t ent) {
+ public static void Use_f(edict_t ent)
+ {
int index;
gitem_t it;
String s;
- s = GameBase.gi.args();
- it = GameUtil.FindItem(s);
- if (it == null) {
+ s= GameBase.gi.args();
+ it= GameUtil.FindItem(s);
+ if (it == null)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s + "\n");
return;
}
- if (it.use == null) {
+ if (it.use == null)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Item is not usable.\n");
return;
}
- index = GameUtil.ITEM_INDEX(it);
- if (0 == ent.client.pers.inventory[index]) {
+ index= GameUtil.ITEM_INDEX(it);
+ if (0 == ent.client.pers.inventory[index])
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Out of item: " + s + "\n");
return;
}
@@ -691,23 +768,27 @@ public final class Cmd extends PlayerView {
Drop an inventory item
==================
*/
- public static void Drop_f(edict_t ent) {
+ public static void Drop_f(edict_t ent)
+ {
int index;
gitem_t it;
String s;
- s = GameBase.gi.args();
- it = GameUtil.FindItem(s);
- if (it == null) {
+ s= GameBase.gi.args();
+ it= GameUtil.FindItem(s);
+ if (it == null)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s + "\n");
return;
}
- if (it.drop == null) {
+ if (it.drop == null)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Item is not dropable.\n");
return;
}
- index = GameUtil.ITEM_INDEX(it);
- if (0 == ent.client.pers.inventory[index]) {
+ index= GameUtil.ITEM_INDEX(it);
+ if (0 == ent.client.pers.inventory[index])
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Out of item: " + s + "\n");
return;
}
@@ -720,24 +801,27 @@ public final class Cmd extends PlayerView {
Cmd_Inven_f
=================
*/
- public static void Inven_f(edict_t ent) {
+ public static void Inven_f(edict_t ent)
+ {
int i;
gclient_t cl;
- cl = ent.client;
+ cl= ent.client;
- cl.showscores = false;
- cl.showhelp = false;
+ cl.showscores= false;
+ cl.showhelp= false;
- if (cl.showinventory) {
- cl.showinventory = false;
+ if (cl.showinventory)
+ {
+ cl.showinventory= false;
return;
}
- cl.showinventory = true;
+ cl.showinventory= true;
GameBase.gi.WriteByte(Defines.svc_inventory);
- for (i = 0; i < Defines.MAX_ITEMS; i++) {
+ for (i= 0; i < Defines.MAX_ITEMS; i++)
+ {
GameBase.gi.WriteShort(cl.pers.inventory[i]);
}
GameBase.gi.unicast(ent, true);
@@ -748,18 +832,21 @@ public final class Cmd extends PlayerView {
Cmd_InvUse_f
=================
*/
- public static void InvUse_f(edict_t ent) {
+ public static void InvUse_f(edict_t ent)
+ {
gitem_t it;
GameAI.ValidateSelectedItem(ent);
- if (ent.client.pers.selected_item == -1) {
+ if (ent.client.pers.selected_item == -1)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "No item to use.\n");
return;
}
- it = GameAI.itemlist[ent.client.pers.selected_item];
- if (it.use == null) {
+ it= GameAI.itemlist[ent.client.pers.selected_item];
+ if (it.use == null)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Item is not usable.\n");
return;
}
@@ -771,26 +858,28 @@ public final class Cmd extends PlayerView {
Cmd_WeapPrev_f
=================
*/
- public static void WeapPrev_f(edict_t ent) {
+ public static void WeapPrev_f(edict_t ent)
+ {
gclient_t cl;
int i, index;
gitem_t it;
int selected_weapon;
- cl = ent.client;
+ cl= ent.client;
if (cl.pers.weapon == null)
return;
- selected_weapon = GameUtil.ITEM_INDEX(cl.pers.weapon);
+ selected_weapon= GameUtil.ITEM_INDEX(cl.pers.weapon);
// scan for the next valid one
- for (i = 1; i <= Defines.MAX_ITEMS; i++) {
- index = (selected_weapon + i) % Defines.MAX_ITEMS;
+ for (i= 1; i <= Defines.MAX_ITEMS; i++)
+ {
+ index= (selected_weapon + i) % Defines.MAX_ITEMS;
if (0 == cl.pers.inventory[index])
continue;
- it = GameAI.itemlist[index];
+ it= GameAI.itemlist[index];
if (it.use == null)
continue;
@@ -807,27 +896,30 @@ public final class Cmd extends PlayerView {
Cmd_WeapNext_f
=================
*/
- public static void WeapNext_f(edict_t ent) {
+ public static void WeapNext_f(edict_t ent)
+ {
gclient_t cl;
int i, index;
gitem_t it;
int selected_weapon;
- cl = ent.client;
+ cl= ent.client;
if (null == cl.pers.weapon)
return;
- selected_weapon = GameUtil.ITEM_INDEX(cl.pers.weapon);
+ selected_weapon= GameUtil.ITEM_INDEX(cl.pers.weapon);
// scan for the next valid one
- for (i = 1; i <= Defines.MAX_ITEMS; i++) {
- index = (selected_weapon + Defines.MAX_ITEMS - i) % Defines.MAX_ITEMS;
+ 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 (index == 0)
+ index++;
if (0 == cl.pers.inventory[index])
continue;
- it = GameAI.itemlist[index];
+ it= GameAI.itemlist[index];
if (null == it.use)
continue;
if (0 == (it.flags & Defines.IT_WEAPON))
@@ -843,20 +935,21 @@ public final class Cmd extends PlayerView {
Cmd_WeapLast_f
=================
*/
- public static void WeapLast_f(edict_t ent) {
+ public static void WeapLast_f(edict_t ent)
+ {
gclient_t cl;
int index;
gitem_t it;
- cl = ent.client;
+ cl= ent.client;
if (null == cl.pers.weapon || null == cl.pers.lastweapon)
return;
- index = GameUtil.ITEM_INDEX(cl.pers.lastweapon);
+ index= GameUtil.ITEM_INDEX(cl.pers.lastweapon);
if (0 == cl.pers.inventory[index])
return;
- it = GameAI.itemlist[index];
+ it= GameAI.itemlist[index];
if (null == it.use)
return;
if (0 == (it.flags & Defines.IT_WEAPON))
@@ -869,18 +962,21 @@ public final class Cmd extends PlayerView {
Cmd_InvDrop_f
=================
*/
- public static void InvDrop_f(edict_t ent) {
+ public static void InvDrop_f(edict_t ent)
+ {
gitem_t it;
GameAI.ValidateSelectedItem(ent);
- if (ent.client.pers.selected_item == -1) {
+ if (ent.client.pers.selected_item == -1)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "No item to drop.\n");
return;
}
- it = GameAI.itemlist[ent.client.pers.selected_item];
- if (it.drop == null) {
+ it= GameAI.itemlist[ent.client.pers.selected_item];
+ if (it.drop == null)
+ {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Item is not dropable.\n");
return;
}
@@ -894,19 +990,21 @@ public final class Cmd extends PlayerView {
Display the scoreboard
==================
*/
- public static void Score_f(edict_t ent) {
- ent.client.showinventory = false;
- ent.client.showhelp = false;
+ public static void Score_f(edict_t ent)
+ {
+ ent.client.showinventory= false;
+ ent.client.showhelp= false;
if (0 == GameBase.deathmatch.value && 0 == GameBase.coop.value)
return;
- if (ent.client.showscores) {
- ent.client.showscores = false;
+ if (ent.client.showscores)
+ {
+ ent.client.showscores= false;
return;
}
- ent.client.showscores = true;
+ ent.client.showscores= true;
GameAI.DeathmatchScoreboard(ent);
}
@@ -917,23 +1015,26 @@ public final class Cmd extends PlayerView {
Display the current help message
==================
*/
- public static void Help_f(edict_t ent) {
+ public static void Help_f(edict_t ent)
+ {
// this is for backwards compatability
- if (GameBase.deathmatch.value != 0) {
+ if (GameBase.deathmatch.value != 0)
+ {
Score_f(ent);
return;
}
- ent.client.showinventory = false;
- ent.client.showscores = false;
+ ent.client.showinventory= false;
+ ent.client.showscores= false;
- if (ent.client.showhelp && (ent.client.pers.game_helpchanged == GameBase.game.helpchanged)) {
- ent.client.showhelp = false;
+ if (ent.client.showhelp && (ent.client.pers.game_helpchanged == GameBase.game.helpchanged))
+ {
+ ent.client.showhelp= false;
return;
}
- ent.client.showhelp = true;
- ent.client.pers.helpchanged = 0;
+ ent.client.showhelp= true;
+ ent.client.pers.helpchanged= 0;
GameAI.HelpComputer(ent);
}
@@ -944,12 +1045,13 @@ public final class Cmd extends PlayerView {
Cmd_Kill_f
=================
*/
- public static void Kill_f(edict_t ent) {
+ public static void Kill_f(edict_t ent)
+ {
if ((GameBase.level.time - ent.client.respawn_time) < 5)
return;
ent.flags &= ~Defines.FL_GODMODE;
- ent.health = 0;
- GameBase.meansOfDeath = Defines.MOD_SUICIDE;
+ ent.health= 0;
+ GameBase.meansOfDeath= Defines.MOD_SUICIDE;
GameAIAdapters.player_die.die(ent, ent, ent, 100000, GameBase.vec3_origin);
}
@@ -958,10 +1060,11 @@ public final class Cmd extends PlayerView {
Cmd_PutAway_f
=================
*/
- public static void PutAway_f(edict_t ent) {
- ent.client.showscores = false;
- ent.client.showhelp = false;
- ent.client.showinventory = false;
+ public static void PutAway_f(edict_t ent)
+ {
+ ent.client.showscores= false;
+ ent.client.showhelp= false;
+ ent.client.showinventory= false;
}
@@ -970,18 +1073,21 @@ public final class Cmd extends PlayerView {
Cmd_Players_f
=================
*/
- public static void Players_f(edict_t ent) {
+ public static void Players_f(edict_t ent)
+ {
int i;
int count;
String small;
String large;
- Integer index[] = new Integer[256];
+ Integer index[]= new Integer[256];
- count = 0;
- for (i = 0; i < GameBase.maxclients.value; i++) {
- if (GameBase.game.clients[i].pers.connected) {
- index[count] = new Integer(i);
+ count= 0;
+ for (i= 0; i < GameBase.maxclients.value; i++)
+ {
+ if (GameBase.game.clients[i].pers.connected)
+ {
+ index[count]= new Integer(i);
count++;
}
}
@@ -992,16 +1098,18 @@ public final class Cmd extends PlayerView {
Arrays.sort(index, 0, count - 1, GameAIAdapters.PlayerSort);
// print information
- large = "";
+ large= "";
- for (i = 0; i < count; i++) {
- small =
+ for (i= 0; i < count; i++)
+ {
+ small=
GameBase.game.clients[index[i].intValue()].ps.stats[Defines.STAT_FRAGS]
+ " "
+ GameBase.game.clients[index[i].intValue()].pers.netname
+ "\n";
- if (small.length() + large.length() > 1024 - 100) {
+ if (small.length() + large.length() > 1024 - 100)
+ {
// can't print all of them in one packet
large += "...\n";
break;
@@ -1017,10 +1125,11 @@ public final class Cmd extends PlayerView {
Cmd_Wave_f
=================
*/
- public static void Wave_f(edict_t ent) {
+ public static void Wave_f(edict_t ent)
+ {
int i;
- i = Lib.atoi(GameBase.gi.argv(1));
+ i= Lib.atoi(GameBase.gi.argv(1));
// can't wave when ducked
if ((ent.client.ps.pmove.pm_flags & Defines.PMF_DUCKED) != 0)
@@ -1029,34 +1138,35 @@ public final class Cmd extends PlayerView {
if (ent.client.anim_priority > Defines.ANIM_WAVE)
return;
- ent.client.anim_priority = Defines.ANIM_WAVE;
+ ent.client.anim_priority= Defines.ANIM_WAVE;
- switch (i) {
+ switch (i)
+ {
case 0 :
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "flipoff\n");
- ent.s.frame = M_Player.FRAME_flip01 - 1;
- ent.client.anim_end = M_Player.FRAME_flip12;
+ ent.s.frame= M_Player.FRAME_flip01 - 1;
+ ent.client.anim_end= M_Player.FRAME_flip12;
break;
case 1 :
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "salute\n");
- ent.s.frame = M_Player.FRAME_salute01 - 1;
- ent.client.anim_end = M_Player.FRAME_salute11;
+ ent.s.frame= M_Player.FRAME_salute01 - 1;
+ ent.client.anim_end= M_Player.FRAME_salute11;
break;
case 2 :
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "taunt\n");
- ent.s.frame = M_Player.FRAME_taunt01 - 1;
- ent.client.anim_end = M_Player.FRAME_taunt17;
+ ent.s.frame= M_Player.FRAME_taunt01 - 1;
+ ent.client.anim_end= M_Player.FRAME_taunt17;
break;
case 3 :
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "wave\n");
- ent.s.frame = M_Player.FRAME_wave01 - 1;
- ent.client.anim_end = M_Player.FRAME_wave11;
+ ent.s.frame= M_Player.FRAME_wave01 - 1;
+ ent.client.anim_end= M_Player.FRAME_wave11;
break;
case 4 :
default :
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "point\n");
- ent.s.frame = M_Player.FRAME_point01 - 1;
- ent.client.anim_end = M_Player.FRAME_point12;
+ ent.s.frame= M_Player.FRAME_point01 - 1;
+ ent.client.anim_end= M_Player.FRAME_point12;
break;
}
}
@@ -1066,7 +1176,8 @@ public final class Cmd extends PlayerView {
Cmd_Say_f
==================
*/
- public static void Say_f(edict_t ent, boolean team, boolean arg0) {
+ public static void Say_f(edict_t ent, boolean team, boolean arg0)
+ {
int i, j;
edict_t other;
@@ -1077,19 +1188,21 @@ public final class Cmd extends PlayerView {
return;
if (0 == ((int) (dmflags.value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
- team = false;
+ team= false;
if (team)
- text = "(" + ent.client.pers.netname + "): ";
+ text= "(" + ent.client.pers.netname + "): ";
else
- text = "" + ent.client.pers.netname + ": ";
+ text= "" + ent.client.pers.netname + ": ";
- if (arg0) {
+ if (arg0)
+ {
strcat(text, gi.argv(0));
strcat(text, " ");
strcat(text, gi.args());
}
- else {
+ else
+ {
if (gi.args().startsWith("\""))
text += gi.args().substring(1, gi.args().length() - 1);
else
@@ -1109,41 +1222,46 @@ public final class Cmd extends PlayerView {
// don't let text be too long for malicious reasons
if (text.length() > 150)
//text[150] = 0;
- text = text.substring(0, 150);
+ text= text.substring(0, 150);
strcat(text, "\n");
- if (flood_msgs.value != 0) {
- cl = ent.client;
+ if (flood_msgs.value != 0)
+ {
+ cl= ent.client;
- if (level.time < cl.flood_locktill) {
+ if (level.time < cl.flood_locktill)
+ {
gi.cprintf(ent, PRINT_HIGH, "You can't talk for " + (int) (cl.flood_locktill - level.time) + " more seconds\n");
return;
}
- i = (int) (cl.flood_whenhead - flood_msgs.value + 1);
+ i= (int) (cl.flood_whenhead - flood_msgs.value + 1);
if (i < 0)
//i = (sizeof(cl.flood_when) / sizeof(cl.flood_when[0])) + i;
- i = (10) + i;
- if (cl.flood_when[i] != 0 && level.time - cl.flood_when[i] < flood_persecond.value) {
- cl.flood_locktill = level.time + flood_waitdelay.value;
+ i= (10) + i;
+ if (cl.flood_when[i] != 0 && level.time - cl.flood_when[i] < flood_persecond.value)
+ {
+ cl.flood_locktill= level.time + flood_waitdelay.value;
gi.cprintf(ent, PRINT_CHAT, "Flood protection: You can't talk for " + (int) flood_waitdelay.value + " seconds.\n");
return;
}
//cl.flood_whenhead = (cl.flood_whenhead + 1) % (sizeof(cl.flood_when) / sizeof(cl.flood_when[0]));
- cl.flood_whenhead = (cl.flood_whenhead + 1) % 10;
- cl.flood_when[cl.flood_whenhead] = level.time;
+ cl.flood_whenhead= (cl.flood_whenhead + 1) % 10;
+ cl.flood_when[cl.flood_whenhead]= level.time;
}
if (dedicated.value != 0)
gi.cprintf(null, PRINT_CHAT, "" + text + "");
- for (j = 1; j <= game.maxclients; j++) {
- other = g_edicts[j];
+ for (j= 1; j <= game.maxclients; j++)
+ {
+ other= g_edicts[j];
if (!other.inuse)
continue;
if (other.client == null)
continue;
- if (team) {
+ if (team)
+ {
if (!OnSameTeam(ent, other))
continue;
}
@@ -1154,23 +1272,25 @@ public final class Cmd extends PlayerView {
/**
* Returns the playerlist.
- * TODO: The list is badly formatted at the moment, RST.
+ * TODO: The list is badly formatted at the moment.
*/
- public static void PlayerList_f(edict_t ent) {
+ public static void PlayerList_f(edict_t ent)
+ {
int i;
String st;
String text;
edict_t e2;
// connect time, ping, score, name
- text = "";
+ text= "";
- for (i = 0; i < GameBase.maxclients.value; i++) {
- e2 = GameBase.g_edicts[1 + i];
+ for (i= 0; i < GameBase.maxclients.value; i++)
+ {
+ e2= GameBase.g_edicts[1 + i];
if (!e2.inuse)
continue;
- st =
+ st=
""
+ (GameBase.level.framenum - e2.client.resp.enterframe) / 600
+ ":"
@@ -1185,7 +1305,8 @@ public final class Cmd extends PlayerView {
+ (e2.client.resp.spectator ? " (spectator)" : "")
+ "\n";
- if (text.length() + st.length() > 1024 - 50) {
+ if (text.length() + st.length() > 1024 - 50)
+ {
text += "And more...\n";
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "" + text + "");
return;
@@ -1196,7 +1317,7 @@ public final class Cmd extends PlayerView {
}
// ======================================================================
-
+
/*
===================
Cmd_ForwardToServer
@@ -1206,18 +1327,21 @@ public final class Cmd extends PlayerView {
so when they are typed in at the console, they will need to be forwarded.
===================
*/
- public static void ForwardToServer() {
+ public static void ForwardToServer()
+ {
String cmd;
-
- cmd = Cmd.Argv(0);
- if (Globals.cls.state <= Defines.ca_connected || cmd.charAt(0) == '-' || cmd.charAt(0) == '+') {
+
+ cmd= Cmd.Argv(0);
+ if (Globals.cls.state <= Defines.ca_connected || cmd.charAt(0) == '-' || cmd.charAt(0) == '+')
+ {
Com.Printf("Unknown command \"" + cmd + "\"\n");
return;
}
-
+
MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd);
SZ.Print(Globals.cls.netchan.message, cmd);
- if (Cmd.Argc() > 1) {
+ if (Cmd.Argc() > 1)
+ {
SZ.Print(Globals.cls.netchan.message, " ");
SZ.Print(Globals.cls.netchan.message, Cmd.Args());
}
diff --git a/src/jake2/game/GameBase.java b/src/jake2/game/GameBase.java
index ef1e1c9..d32c23c 100644
--- a/src/jake2/game/GameBase.java
+++ b/src/jake2/game/GameBase.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 30.11.2003 by RST.
-// $Id: GameBase.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: GameBase.java,v 1.2.2.1 2004-07-09 08:38:28 hzi Exp $
/** Father of all Objects. */
@@ -817,24 +817,8 @@ public class GameBase extends Globals
continue;
}
- //TODO: RST: disabled for debugging;
- //if (!ent.classname.startsWith("monster") || ent.index == 312)
- G_RunEntity(ent);
-
- // if (ent == g_edicts[307])
- // G_RunEntity(ent);
- // else if (ent == g_edicts[1])
- // G_RunEntity(ent);
- //
- // else if (true)
- // if (ent.classname.startsWith("monster")
- // || ent.classname.startsWith("trigger")
- // || ent.classname.startsWith("target")
- // || ent.classname.startsWith(
- // "misc_explo") //ent.classname.startsWith("func_door")
- // ) //|| ent.classname.startsWith("monster"))
- // G_RunEntity(ent);
+ G_RunEntity(ent);
}
// see if it is time to end a deathmatch
diff --git a/src/jake2/game/GameFunc.java b/src/jake2/game/GameFunc.java
index 8860b00..7056e3d 100644
--- a/src/jake2/game/GameFunc.java
+++ b/src/jake2/game/GameFunc.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 18.11.2003 by RST.
-// $Id: GameFunc.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: GameFunc.java,v 1.2.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.game;
@@ -38,9 +38,6 @@ public class GameFunc extends PlayerView
Math3D.VectorSubtract(dest, ent.s.origin, ent.moveinfo.dir);
ent.moveinfo.remaining_distance = Math3D.VectorNormalize(ent.moveinfo.dir);
- //TODO: BIG HACK !!!
- if (ent.moveinfo.remaining_distance == 2)
- ent.moveinfo.remaining_distance = 94;
ent.moveinfo.endfunc = func;
if (ent.moveinfo.speed == ent.moveinfo.accel && ent.moveinfo.speed == ent.moveinfo.decel)
diff --git a/src/jake2/game/GameSVCmds.java b/src/jake2/game/GameSVCmds.java
index dc0b4f9..6d8b623 100644
--- a/src/jake2/game/GameSVCmds.java
+++ b/src/jake2/game/GameSVCmds.java
@@ -19,22 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 01.02.2004 by RST.
-// $Id: GameSVCmds.java,v 1.1 2004-07-07 19:59:00 hzi Exp $
+// $Id: GameSVCmds.java,v 1.1.1.1.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.game;
+import jake2.qcommon.Com;
+
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.StringTokenizer;
-import com.sun.corba.se.internal.ior.ByteBuffer;
-
-import jake2.*;
-import jake2.client.*;
-import jake2.qcommon.*;
-import jake2.render.*;
-import jake2.server.*;
-
public class GameSVCmds extends GameSpawn {
public static void Svcmd_Test_f() {
diff --git a/src/jake2/game/GameSpawn.java b/src/jake2/game/GameSpawn.java
index edb8cab..071df2c 100644
--- a/src/jake2/game/GameSpawn.java
+++ b/src/jake2/game/GameSpawn.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 18.11.2003 by RST.
-// $Id: GameSpawn.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: GameSpawn.java,v 1.2.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.game;
@@ -305,7 +305,7 @@ public class GameSpawn extends GameSave {
e.teammaster = e;
c++;
c2++;
- Com.Printf("Team:" + e.team+" entity: " + e.index + "\n");
+ //Com.Printf("Team:" + e.team+" entity: " + e.index + "\n");
for (j = i + 1; j < globals.num_edicts; j++) {
e2 = g_edicts[j];
if (!e2.inuse)
@@ -427,7 +427,7 @@ public class GameSpawn extends GameSave {
ED_CallSpawn(ent);
}
//gi.dprintf("player skill level:" +skill.value + "\n");
- gi.dprintf(inhibit + " entities inhibited\n");
+ //gi.dprintf(inhibit + " entities inhibited\n");
i = 1;
G_FindTeams();
PlayerTrail.Init();
diff --git a/src/jake2/game/GameUtil.java b/src/jake2/game/GameUtil.java
index ee52a89..b74c080 100644
--- a/src/jake2/game/GameUtil.java
+++ b/src/jake2/game/GameUtil.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 01.11.2003 by RST.
-// $Id: GameUtil.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: GameUtil.java,v 1.2.2.1 2004-07-09 08:38:28 hzi Exp $
package jake2.game;
@@ -280,7 +280,6 @@ public class GameUtil extends GameBase
return false;
}
- /** TODO: test, / replaced the string operations. */
static String ClientTeam(edict_t ent)
{
String value;
diff --git a/src/jake2/game/GameUtilAdapters.java b/src/jake2/game/GameUtilAdapters.java
index 4a3c320..fed5d2f 100644
--- a/src/jake2/game/GameUtilAdapters.java
+++ b/src/jake2/game/GameUtilAdapters.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 26.02.2004 by RST.
-// $Id: GameUtilAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
+// $Id: GameUtilAdapters.java,v 1.1.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.game;
@@ -310,7 +310,7 @@ public class GameUtilAdapters
if (!taken)
return;
- Com.p("Picked up:" + ent.classname);
+ //Com.p("Picked up:" + ent.classname);
if (!((GameBase.coop.value != 0) && (ent.item.flags & Defines.IT_STAY_COOP) != 0)
|| 0 != (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM)))
@@ -322,6 +322,7 @@ public class GameUtilAdapters
}
}
};
+
static EntTouchAdapter drop_temp_touch = new EntTouchAdapter()
{
public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf)
@@ -332,6 +333,7 @@ public class GameUtilAdapters
Touch_Item.touch(ent, other, plane, surf);
}
};
+
static EntThinkAdapter drop_make_touchable = new EntThinkAdapter()
{
public boolean think(edict_t ent)
@@ -398,7 +400,7 @@ public class GameUtilAdapters
ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]--;
//TODO: remove this line
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]=0;
+ //ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]=0;
GameUtil.ValidateSelectedItem(ent);
@@ -407,7 +409,7 @@ public class GameUtilAdapters
else
ent.client.breather_framenum = GameBase.level.framenum + 300;
- // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
+ GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0);
}
};
// ======================================================================
@@ -424,7 +426,7 @@ public class GameUtilAdapters
else
ent.client.enviro_framenum = GameBase.level.framenum + 300;
- // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
+ GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0);
}
};
// ======================================================================
@@ -458,7 +460,7 @@ public class GameUtilAdapters
GameUtil.ValidateSelectedItem(ent);
ent.client.silencer_shots += 30;
- // gi.sound(ent, CHAN_ITEM, gi.soundindex("items/damage.wav"), 1, ATTN_NORM, 0);
+ GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0);
}
};
// ======================================================================
diff --git a/src/jake2/game/M_Actor.java b/src/jake2/game/M_Actor.java
index f48ff77..306204f 100644
--- a/src/jake2/game/M_Actor.java
+++ b/src/jake2/game/M_Actor.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 11.11.2003 by RST.
-// $Id: M_Actor.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: M_Actor.java,v 1.2.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.game;
@@ -731,7 +731,7 @@ public class M_Actor extends GameAI {
return;
self.pain_debounce_time= level.time + 3;
- // gi.sound (self, CHAN_VOICE, actor.sound_pain, 1, ATTN_NORM, 0);
+ //GameBase.gi.sound (self, CHAN_VOICE, actor.sound_pain, 1, ATTN_NORM, 0);
if ((other.client != null) && (Lib.random() < 0.4)) {
float v[]= { 0, 0, 0 };
diff --git a/src/jake2/game/PlayerHud.java b/src/jake2/game/PlayerHud.java
index b9622e3..fac4fc4 100644
--- a/src/jake2/game/PlayerHud.java
+++ b/src/jake2/game/PlayerHud.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 28.12.2003 by RST.
-// $Id: PlayerHud.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: PlayerHud.java,v 1.2.2.1 2004-07-09 08:38:28 hzi Exp $
package jake2.game;
@@ -100,13 +100,15 @@ public class PlayerHud extends GameTarget {
level.intermissiontime = level.time;
// TODO: BIG HACK TO IGNORE CINEMATIC
+
String xxx = targ.map;
int pos = xxx.indexOf(".cin");
if (pos != -1)
level.changemap = xxx.substring(pos + 5); // including "+"
else
level.changemap = xxx;
-
+ // ------------------------
+ //level.changemap = targ.map;
if (level.changemap.indexOf('*') > -1) {
if (coop.value != 0) {
for (i = 0; i < maxclients.value; i++) {
diff --git a/src/jake2/game/game_export_t.java b/src/jake2/game/game_export_t.java
index 792b785..3ebb297 100644
--- a/src/jake2/game/game_export_t.java
+++ b/src/jake2/game/game_export_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: game_export_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: game_export_t.java,v 1.2.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.game;
@@ -58,8 +58,8 @@ public class game_export_t
// ReadGame is called on a loadgame.
public void WriteGame(String filename, boolean autosave)
{
- // TODO WriteGame not implemnted!
- Com.Println("WriteGame not implemnted!");
+ // TODO WriteGame not implemented.
+ Com.Println("WriteGame not implemented.");
}
public void ReadGame(String filename)
@@ -71,14 +71,14 @@ public class game_export_t
// loaded with SpawnEntities
public void WriteLevel(String filename)
{
- // TODO WriteLevel not implemented!
- Com.Println("WriteLevel not implemented!");
+ // TODO WriteLevel not implemented.
+ Com.Println("WriteLevel not implemented.");
}
public void ReadLevel(String filename)
{
- // TODO ReadLevel not implemnted!
- Com.Println("ReadLevel not implemnted!");
+ // TODO ReadLevel not implemented.
+ Com.Println("ReadLevel not implemented.");
}
public boolean ClientConnect(edict_t ent, String userinfo)
diff --git a/src/jake2/game/player_state_t.java b/src/jake2/game/player_state_t.java
index 3ecc17d..772ca2b 100644
--- a/src/jake2/game/player_state_t.java
+++ b/src/jake2/game/player_state_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: player_state_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+// $Id: player_state_t.java,v 1.2.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.game;
@@ -62,7 +62,6 @@ public class player_state_t {
/**
*
*/
- // TODO bugfix cwei
private static player_state_t prototype = new player_state_t();
public void clear() {
diff --git a/src/jake2/qcommon/CM.java b/src/jake2/qcommon/CM.java
index 8c5a203..1de50da 100644
--- a/src/jake2/qcommon/CM.java
+++ b/src/jake2/qcommon/CM.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 02.01.2004 by RST.
-// $Id: CM.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
+// $Id: CM.java,v 1.2.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.qcommon;
@@ -189,7 +189,7 @@ public class CM extends Game {
Loads in the map and all submodels
==================
*/
- public static cmodel_t CM_LoadMap(String name, boolean clientload, intwrap checksum) {
+ public static cmodel_t CM_LoadMap(String name, boolean clientload, int checksum[]) {
Com.DPrintf("CM_LoadMap...\n");
byte buf[];
int i;
@@ -200,7 +200,7 @@ public class CM extends Game {
if (0 == strcmp(map_name, name) && (clientload || 0 == Cvar.VariableValue("flushmap"))) {
- checksum.i = last_checksum;
+ checksum[0] = last_checksum;
if (!clientload) {
Arrays.fill(portalopen, false);
@@ -222,7 +222,7 @@ public class CM extends Game {
numleafs = 1;
numclusters = 1;
numareas = 1;
- checksum.i = 0;
+ checksum[0] = 0;
return map_cmodels[0];
// cinematic servers won't have anything at all
}
@@ -240,7 +240,7 @@ public class CM extends Game {
ByteBuffer bbuf = ByteBuffer.wrap(buf);
last_checksum = MD4.Com_BlockChecksum(buf, length);
- checksum.i = last_checksum;
+ checksum[0] = last_checksum;
header = new qfiles.dheader_t(bbuf.slice());
@@ -796,7 +796,6 @@ public class CM extends Game {
if (l.filelen > MAX_MAP_VISIBILITY)
Com.Error(ERR_DROP, "Map has too large visibility lump");
- //was: memcpy(map_visibility, cmod_base + l.fileofs, l.filelen);
System.arraycopy(cmod_base, l.fileofs, map_visibility, 0, l.filelen);
ByteBuffer bb = ByteBuffer.wrap(map_visibility, 0, l.filelen);
@@ -1074,7 +1073,7 @@ public class CM extends Game {
}
}
- public static int CM_BoxLeafnums_headnode(float[] mins, float[] maxs, int list[], int listsize, int headnode, intwrap topnode) {
+ public static int CM_BoxLeafnums_headnode(float[] mins, float[] maxs, int list[], int listsize, int headnode, int topnode[]) {
leaf_list = list;
leaf_count = 0;
leaf_maxcount = listsize;
@@ -1086,22 +1085,23 @@ public class CM extends Game {
CM_BoxLeafnums_r(headnode);
if (topnode != null)
- topnode.i = leaf_topnode;
+ topnode[0] = leaf_topnode;
return leaf_count;
}
- public static int CM_BoxLeafnums(float[] mins, float[] maxs, int list[], int listsize, intwrap topnode) {
+ public static int CM_BoxLeafnums(float[] mins, float[] maxs, int list[], int listsize, int topnode[]) {
return CM_BoxLeafnums_headnode(mins, maxs, list, listsize, map_cmodels[0].headnode, topnode);
}
- public static class intwrap {
+ /*
+ public static class intwrap1 {
public intwrap(int i) {
this.i = i;
}
public int i;
}
-
+ */
/*
==================
CM_PointContents
@@ -1539,10 +1539,10 @@ public class CM extends Game {
c2[i] += 1;
}
- intwrap tn = new intwrap(topnode);
+ int tn[] = {topnode};
numleafs = CM_BoxLeafnums_headnode(c1, c2, leafs, 1024, headnode, tn);
- topnode = tn.i;
+ topnode = tn[0];
for (i = 0; i < numleafs; i++) {
CM_TestInLeaf(leafs[i]);
if (trace_trace.allsolid)
diff --git a/src/jake2/qcommon/CRC.java b/src/jake2/qcommon/CRC.java
index ca22d9b..fd2ca20 100644
--- a/src/jake2/qcommon/CRC.java
+++ b/src/jake2/qcommon/CRC.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 25.01.2004 by RST.
-// $Id: CRC.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+// $Id: CRC.java,v 1.1.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.qcommon;
import jake2.util.Vargs;
diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java
index c938fdb..ca9b4ec 100644
--- a/src/jake2/qcommon/Com.java
+++ b/src/jake2/qcommon/Com.java
@@ -2,7 +2,7 @@
* Com.java
* Copyright (C) 2003
*
- * $Id: Com.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
+ * $Id: Com.java,v 1.2.2.1 2004-07-09 08:38:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -38,15 +38,17 @@ import java.io.*;
/**
* Com
- * TODO complete Com interface
+ *
*/
-public final class Com {
-
+public final class Com
+{
+
static int com_argc;
- static String[] com_argv = new String[Defines.MAX_NUM_ARGVS];
-
- public abstract static class RD_Flusher {
- public abstract void rd_flush(int target, byte [] buffer);
+ static String[] com_argv= new String[Defines.MAX_NUM_ARGVS];
+
+ public abstract static class RD_Flusher
+ {
+ public abstract void rd_flush(int target, byte[] buffer);
}
static int rd_target;
@@ -54,80 +56,95 @@ public final class Com {
static int rd_buffersize;
static RD_Flusher rd_flusher;
- public static void BeginRedirect(int target, byte [] buffer, int buffersize, RD_Flusher flush) {
+ public static void BeginRedirect(int target, byte[] buffer, int buffersize, RD_Flusher flush)
+ {
if (0 == target || null == buffer || 0 == buffersize || null == flush)
return;
- rd_target = target;
- rd_buffer = buffer;
- rd_buffersize = buffersize;
- rd_flusher = flush;
+ rd_target= target;
+ rd_buffer= buffer;
+ rd_buffersize= buffersize;
+ rd_flusher= flush;
- rd_buffer = null;
+ rd_buffer= null;
}
- public static void EndRedirect() {
+ public static void EndRedirect()
+ {
rd_flusher.rd_flush(rd_target, rd_buffer);
- rd_target = 0;
- rd_buffer = null;
- rd_buffersize = 0;
- rd_flusher = null;
+ rd_target= 0;
+ rd_buffer= null;
+ rd_buffersize= 0;
+ rd_flusher= null;
}
- static boolean recursive = false;
+ static boolean recursive= false;
- static String msg = "";
+ static String msg= "";
// helper class to replace the pointer-pointer
- public static class ParseHelp {
+ public static class ParseHelp
+ {
- public ParseHelp(String in, int offset) {
+ public ParseHelp(String in, int offset)
+ {
this(in.toCharArray(), offset);
}
- public ParseHelp(String in) {
- if (in == null) {
- data = null;
+ public ParseHelp(String in)
+ {
+ if (in == null)
+ {
+ data= null;
}
- else {
- data = in.toCharArray();
+ else
+ {
+ data= in.toCharArray();
}
- index = 0;
+ index= 0;
}
- public ParseHelp(char in[]) {
+ public ParseHelp(char in[])
+ {
this(in, 0);
}
- public ParseHelp(char in[], int offset) {
+ public ParseHelp(char in[], int offset)
+ {
if (in == null || in.length == 0)
- data = null;
+ data= null;
else
- data = in;
- index = offset;
+ data= in;
+ index= offset;
}
- public char getchar() {
+ public char getchar()
+ {
// faster than if
- try {
+ try
+ {
return data[index];
}
- catch (Exception e) {
- data = null;
+ catch (Exception e)
+ {
+ data= null;
// last char
return 0;
}
}
- public char nextchar() {
+ public char nextchar()
+ {
// faster than if
- try {
+ try
+ {
index++;
return data[index];
}
- catch (Exception e) {
- data = null;
+ catch (Exception e)
+ {
+ data= null;
// avoid int wraps;
index--;
// last char
@@ -135,144 +152,170 @@ public final class Com {
}
}
- public boolean isEof() {
+ public boolean isEof()
+ {
return data == null;
}
public int index;
public char data[];
- public char skipwhites() {
+ public char skipwhites()
+ {
char c;
- while (((c = getchar()) <= ' ') && c != 0)
+ while (((c= getchar()) <= ' ') && c != 0)
index++;
return c;
}
- public char skipwhitestoeol() {
+ public char skipwhitestoeol()
+ {
char c;
- while (((c = getchar()) <= ' ') && c != '\n' && c != 0)
+ while (((c= getchar()) <= ' ') && c != '\n' && c != 0)
index++;
return c;
}
- public char skiptoeol() {
+ public char skiptoeol()
+ {
char c;
- while ((c = getchar()) != '\n' && c != 0)
+ while ((c= getchar()) != '\n' && c != 0)
index++;
return c;
}
}
- public static char com_token[] = new char[Defines.MAX_TOKEN_CHARS];
+ public static char com_token[]= new char[Defines.MAX_TOKEN_CHARS];
// See GameSpanw.ED_ParseEdict() to see how to use it now.
// works perfect !
- public static String Parse(ParseHelp hlp) {
+ public static String Parse(ParseHelp hlp)
+ {
int c;
- int len = 0;
- len = 0;
+ int len= 0;
+ len= 0;
- com_token[0] = 0;
+ com_token[0]= 0;
- if (hlp.data == null) {
+ if (hlp.data == null)
+ {
return "";
}
// skip whitespace
hlp.skipwhites();
- if (hlp.isEof()) {
+ if (hlp.isEof())
+ {
return "";
}
// skip // comments
- if (hlp.getchar() == '/') {
- if (hlp.nextchar() == '/') {
- if ((hlp.skiptoeol() == 0) || (hlp.skipwhites() == 0)) {
+ if (hlp.getchar() == '/')
+ {
+ if (hlp.nextchar() == '/')
+ {
+ if ((hlp.skiptoeol() == 0) || (hlp.skipwhites() == 0))
+ {
return "";
}
}
- else {
- com_token[len] = '/';
+ else
+ {
+ com_token[len]= '/';
len++;
}
}
// handle quoted strings specially
- if (hlp.getchar() == '\"') {
- while (true) {
- c = hlp.nextchar();
- if (c == '\"' || c == 0) {
+ if (hlp.getchar() == '\"')
+ {
+ while (true)
+ {
+ c= hlp.nextchar();
+ if (c == '\"' || c == 0)
+ {
hlp.nextchar();
- com_token[len] = '?';
+ com_token[len]= '?';
return new String(com_token, 0, len);
}
- if (len < Defines.MAX_TOKEN_CHARS) {
- com_token[len] = hlp.getchar();
+ if (len < Defines.MAX_TOKEN_CHARS)
+ {
+ com_token[len]= hlp.getchar();
len++;
}
}
}
// parse a regular word
- do {
- if (len < Defines.MAX_TOKEN_CHARS) {
- com_token[len] = hlp.getchar();
+ do
+ {
+ if (len < Defines.MAX_TOKEN_CHARS)
+ {
+ com_token[len]= hlp.getchar();
len++;
}
- c = hlp.nextchar();
+ c= hlp.nextchar();
}
while (c > 32);
- if (len == Defines.MAX_TOKEN_CHARS) {
+ if (len == Defines.MAX_TOKEN_CHARS)
+ {
Printf("Token exceeded " + Defines.MAX_TOKEN_CHARS + " chars, discarded.\n");
- len = 0;
+ len= 0;
}
// trigger the eof
hlp.skipwhites();
- com_token[len] = 0;
+ com_token[len]= 0;
return new String(com_token, 0, len);
}
- public static xcommand_t Error_f = new xcommand_t() {
- public void execute() throws longjmpException {
+ public static xcommand_t Error_f= new xcommand_t()
+ {
+ public void execute() throws longjmpException
+ {
Error(Globals.ERR_FATAL, Cmd.Argv(1));
}
};
- public static void Error(int code, String fmt) throws longjmpException {
+ public static void Error(int code, String fmt) throws longjmpException
+ {
Error(code, fmt, null);
}
- public static void Error(int code, String fmt, Vargs vargs) throws longjmpException {
+ public static void Error(int code, String fmt, Vargs vargs) throws longjmpException
+ {
// va_list argptr;
// static char msg[MAXPRINTMSG];
- if (recursive) {
+ if (recursive)
+ {
Sys.Error("recursive error after: " + msg);
}
- recursive = true;
+ recursive= true;
- msg = sprintf(fmt, vargs);
+ msg= sprintf(fmt, vargs);
- if (code == Defines.ERR_DISCONNECT) {
+ if (code == Defines.ERR_DISCONNECT)
+ {
CL.Drop();
- recursive = false;
+ recursive= false;
throw new longjmpException();
}
- else if (code == Defines.ERR_DROP) {
+ else if (code == Defines.ERR_DROP)
+ {
Com.Printf("********************\nERROR: " + msg + "\n********************\n");
SV_MAIN.SV_Shutdown("Server crashed: " + msg + "\n", false);
CL.Drop();
- recursive = false;
+ recursive= false;
throw new longjmpException();
}
- else {
+ else
+ {
SV_MAIN.SV_Shutdown("Server fatal crashed: %s" + msg + "\n", false);
CL.Shutdown();
}
@@ -284,43 +327,51 @@ public final class Com {
* Com_InitArgv checks the number of command line arguments
* and copies all arguments with valid length into com_argv.
*/
- static void InitArgv(String[] args) throws longjmpException {
+ static void InitArgv(String[] args) throws longjmpException
+ {
- if (args.length > Globals.MAX_NUM_ARGVS) {
+ if (args.length > Globals.MAX_NUM_ARGVS)
+ {
Com.Error(Globals.ERR_FATAL, "argc > MAX_NUM_ARGVS");
}
- Com.com_argc = args.length;
- for (int i = 0; i < Com.com_argc; i++) {
+ Com.com_argc= args.length;
+ for (int i= 0; i < Com.com_argc; i++)
+ {
if (args[i].length() >= Globals.MAX_TOKEN_CHARS)
- Com.com_argv[i] = "";
+ Com.com_argv[i]= "";
else
- Com.com_argv[i] = args[i];
+ Com.com_argv[i]= args[i];
}
}
- public static void DPrintf(String fmt) {
+ public static void DPrintf(String fmt)
+ {
DPrintf(fmt, null);
}
-
- public static void d(String fmt) {
+
+ public static void d(String fmt)
+ {
DPrintf(fmt + "\n", null);
}
-
- public static void Printf(String fmt) {
+
+ public static void Printf(String fmt)
+ {
Printf(fmt, null);
}
- public static void DPrintf(String fmt, Vargs vargs) {
+ public static void DPrintf(String fmt, Vargs vargs)
+ {
if (Globals.developer == null || Globals.developer.value == 0)
return; // don't confuse non-developers with techie stuff...
Printf(fmt, vargs);
}
- public static void Printf(String fmt, Vargs vargs) {
+ public static void Printf(String fmt, Vargs vargs)
+ {
// TODO Com.Printf ist nur zum testen
- String msg = sprintf(fmt, vargs);
+ String msg= sprintf(fmt, vargs);
if (rd_target != 0)
{
@@ -328,7 +379,7 @@ public final class Com {
{
rd_flusher.rd_flush(rd_target, rd_buffer);
// *rd_buffer = 0;
- rd_buffer[rd_buffersize] = '\0';
+ rd_buffer[rd_buffersize]= '\0';
}
// TODO handle rd_buffer
// strcat(rd_buffer, msg);
@@ -336,7 +387,7 @@ public final class Com {
}
Console.Print(msg);
-
+
// also echo to debugging console
Sys.ConsoleOutput(msg);
@@ -344,14 +395,14 @@ public final class Com {
if (Globals.logfile_active != null && Globals.logfile_active.value != 0)
{
String name;
-
+
if (Globals.logfile == null)
{
- name = FS.Gamedir() + "/qconsole.log";
+ name= FS.Gamedir() + "/qconsole.log";
if (Globals.logfile_active.value > 2)
try
{
- Globals.logfile = new RandomAccessFile(name, "a");
+ Globals.logfile= new RandomAccessFile(name, "a");
}
catch (FileNotFoundException e)
{
@@ -361,7 +412,7 @@ public final class Com {
else
try
{
- Globals.logfile = new RandomAccessFile(name, "rw");
+ Globals.logfile= new RandomAccessFile(name, "rw");
}
catch (FileNotFoundException e1)
{
@@ -379,58 +430,68 @@ public final class Com {
// TODO: do quake2 error handling!
e.printStackTrace();
}
- if (Globals.logfile_active.value > 1)
- ; // do nothing
- // fflush (logfile); // force it to save every time
+ if (Globals.logfile_active.value > 1); // do nothing
+ // fflush (logfile); // force it to save every time
}
}
- public static void Println(String fmt) {
+ public static void Println(String fmt)
+ {
Printf(fmt);
Printf("\n");
}
-
- public static void p(String fmt) {
+
+ public static void p(String fmt)
+ {
Printf(fmt);
Printf("\n");
}
- public static String sprintf(String fmt, Vargs vargs) {
- String msg = "";
- if (vargs == null || vargs.size() == 0) {
- msg = fmt;
+ public static String sprintf(String fmt, Vargs vargs)
+ {
+ String msg= "";
+ if (vargs == null || vargs.size() == 0)
+ {
+ msg= fmt;
}
- else {
- msg = new PrintfFormat(fmt).sprintf(vargs.toArray());
+ else
+ {
+ msg= new PrintfFormat(fmt).sprintf(vargs.toArray());
}
return msg;
}
- public static int ServerState() {
+ public static int ServerState()
+ {
return Globals.server_state;
}
- public static int Argc() {
+ public static int Argc()
+ {
return Com.com_argc;
}
- public static String Argv(int arg) {
+ public static String Argv(int arg)
+ {
if (arg < 0 || arg >= Com.com_argc || Com.com_argv[arg].length() < 1)
return "";
return Com.com_argv[arg];
}
- public static void ClearArgv(int arg) {
+ public static void ClearArgv(int arg)
+ {
if (arg < 0 || arg >= Com.com_argc || Com.com_argv[arg].length() < 1)
return;
- Com.com_argv[arg] = "";
+ Com.com_argv[arg]= "";
}
- public static void Quit() {
+ public static void Quit()
+ {
SV_MAIN.SV_Shutdown("Server quit\n", false);
CL.Shutdown();
- if (Globals.logfile != null) {
+ if (Globals.logfile != null)
+ {
try
{
Globals.logfile.close();
@@ -438,25 +499,1036 @@ public final class Com {
catch (IOException e)
{
}
- Globals.logfile = null;
+ Globals.logfile= null;
}
Sys.Quit();
}
-
public static void SetServerState(int i)
{
- Globals.server_state = i;
+ Globals.server_state= i;
}
-
public static int BlockChecksum(byte[] buf, int length)
{
return MD4.Com_BlockChecksum(buf, length);
}
- public static void StripExtension(String string, String string2) {
- // TODO implement!
+ public static void StripExtension(String string, String string2)
+ {
+ // TODO implement StripExtension
}
+
+ /**
+ * CRC table.
+ */
+
+ static int chktbl[]=
+ {
+ 0x84,
+ 0x47,
+ 0x51,
+ 0xc1,
+ 0x93,
+ 0x22,
+ 0x21,
+ 0x24,
+ 0x2f,
+ 0x66,
+ 0x60,
+ 0x4d,
+ 0xb0,
+ 0x7c,
+ 0xda,
+ 0x88,
+ 0x54,
+ 0x15,
+ 0x2b,
+ 0xc6,
+ 0x6c,
+ 0x89,
+ 0xc5,
+ 0x9d,
+ 0x48,
+ 0xee,
+ 0xe6,
+ 0x8a,
+ 0xb5,
+ 0xf4,
+ 0xcb,
+ 0xfb,
+ 0xf1,
+ 0x0c,
+ 0x2e,
+ 0xa0,
+ 0xd7,
+ 0xc9,
+ 0x1f,
+ 0xd6,
+ 0x06,
+ 0x9a,
+ 0x09,
+ 0x41,
+ 0x54,
+ 0x67,
+ 0x46,
+ 0xc7,
+ 0x74,
+ 0xe3,
+ 0xc8,
+ 0xb6,
+ 0x5d,
+ 0xa6,
+ 0x36,
+ 0xc4,
+ 0xab,
+ 0x2c,
+ 0x7e,
+ 0x85,
+ 0xa8,
+ 0xa4,
+ 0xa6,
+ 0x4d,
+ 0x96,
+ 0x19,
+ 0x19,
+ 0x9a,
+ 0xcc,
+ 0xd8,
+ 0xac,
+ 0x39,
+ 0x5e,
+ 0x3c,
+ 0xf2,
+ 0xf5,
+ 0x5a,
+ 0x72,
+ 0xe5,
+ 0xa9,
+ 0xd1,
+ 0xb3,
+ 0x23,
+ 0x82,
+ 0x6f,
+ 0x29,
+ 0xcb,
+ 0xd1,
+ 0xcc,
+ 0x71,
+ 0xfb,
+ 0xea,
+ 0x92,
+ 0xeb,
+ 0x1c,
+ 0xca,
+ 0x4c,
+ 0x70,
+ 0xfe,
+ 0x4d,
+ 0xc9,
+ 0x67,
+ 0x43,
+ 0x47,
+ 0x94,
+ 0xb9,
+ 0x47,
+ 0xbc,
+ 0x3f,
+ 0x01,
+ 0xab,
+ 0x7b,
+ 0xa6,
+ 0xe2,
+ 0x76,
+ 0xef,
+ 0x5a,
+ 0x7a,
+ 0x29,
+ 0x0b,
+ 0x51,
+ 0x54,
+ 0x67,
+ 0xd8,
+ 0x1c,
+ 0x14,
+ 0x3e,
+ 0x29,
+ 0xec,
+ 0xe9,
+ 0x2d,
+ 0x48,
+ 0x67,
+ 0xff,
+ 0xed,
+ 0x54,
+ 0x4f,
+ 0x48,
+ 0xc0,
+ 0xaa,
+ 0x61,
+ 0xf7,
+ 0x78,
+ 0x12,
+ 0x03,
+ 0x7a,
+ 0x9e,
+ 0x8b,
+ 0xcf,
+ 0x83,
+ 0x7b,
+ 0xae,
+ 0xca,
+ 0x7b,
+ 0xd9,
+ 0xe9,
+ 0x53,
+ 0x2a,
+ 0xeb,
+ 0xd2,
+ 0xd8,
+ 0xcd,
+ 0xa3,
+ 0x10,
+ 0x25,
+ 0x78,
+ 0x5a,
+ 0xb5,
+ 0x23,
+ 0x06,
+ 0x93,
+ 0xb7,
+ 0x84,
+ 0xd2,
+ 0xbd,
+ 0x96,
+ 0x75,
+ 0xa5,
+ 0x5e,
+ 0xcf,
+ 0x4e,
+ 0xe9,
+ 0x50,
+ 0xa1,
+ 0xe6,
+ 0x9d,
+ 0xb1,
+ 0xe3,
+ 0x85,
+ 0x66,
+ 0x28,
+ 0x4e,
+ 0x43,
+ 0xdc,
+ 0x6e,
+ 0xbb,
+ 0x33,
+ 0x9e,
+ 0xf3,
+ 0x0d,
+ 0x00,
+ 0xc1,
+ 0xcf,
+ 0x67,
+ 0x34,
+ 0x06,
+ 0x7c,
+ 0x71,
+ 0xe3,
+ 0x63,
+ 0xb7,
+ 0xb7,
+ 0xdf,
+ 0x92,
+ 0xc4,
+ 0xc2,
+ 0x25,
+ 0x5c,
+ 0xff,
+ 0xc3,
+ 0x6e,
+ 0xfc,
+ 0xaa,
+ 0x1e,
+ 0x2a,
+ 0x48,
+ 0x11,
+ 0x1c,
+ 0x36,
+ 0x68,
+ 0x78,
+ 0x86,
+ 0x79,
+ 0x30,
+ 0xc3,
+ 0xd6,
+ 0xde,
+ 0xbc,
+ 0x3a,
+ 0x2a,
+ 0x6d,
+ 0x1e,
+ 0x46,
+ 0xdd,
+ 0xe0,
+ 0x80,
+ 0x1e,
+ 0x44,
+ 0x3b,
+ 0x6f,
+ 0xaf,
+ 0x31,
+ 0xda,
+ 0xa2,
+ 0xbd,
+ 0x77,
+ 0x06,
+ 0x56,
+ 0xc0,
+ 0xb7,
+ 0x92,
+ 0x4b,
+ 0x37,
+ 0xc0,
+ 0xfc,
+ 0xc2,
+ 0xd5,
+ 0xfb,
+ 0xa8,
+ 0xda,
+ 0xf5,
+ 0x57,
+ 0xa8,
+ 0x18,
+ 0xc0,
+ 0xdf,
+ 0xe7,
+ 0xaa,
+ 0x2a,
+ 0xe0,
+ 0x7c,
+ 0x6f,
+ 0x77,
+ 0xb1,
+ 0x26,
+ 0xba,
+ 0xf9,
+ 0x2e,
+ 0x1d,
+ 0x16,
+ 0xcb,
+ 0xb8,
+ 0xa2,
+ 0x44,
+ 0xd5,
+ 0x2f,
+ 0x1a,
+ 0x79,
+ 0x74,
+ 0x87,
+ 0x4b,
+ 0x00,
+ 0xc9,
+ 0x4a,
+ 0x3a,
+ 0x65,
+ 0x8f,
+ 0xe6,
+ 0x5d,
+ 0xe5,
+ 0x0a,
+ 0x77,
+ 0xd8,
+ 0x1a,
+ 0x14,
+ 0x41,
+ 0x75,
+ 0xb1,
+ 0xe2,
+ 0x50,
+ 0x2c,
+ 0x93,
+ 0x38,
+ 0x2b,
+ 0x6d,
+ 0xf3,
+ 0xf6,
+ 0xdb,
+ 0x1f,
+ 0xcd,
+ 0xff,
+ 0x14,
+ 0x70,
+ 0xe7,
+ 0x16,
+ 0xe8,
+ 0x3d,
+ 0xf0,
+ 0xe3,
+ 0xbc,
+ 0x5e,
+ 0xb6,
+ 0x3f,
+ 0xcc,
+ 0x81,
+ 0x24,
+ 0x67,
+ 0xf3,
+ 0x97,
+ 0x3b,
+ 0xfe,
+ 0x3a,
+ 0x96,
+ 0x85,
+ 0xdf,
+ 0xe4,
+ 0x6e,
+ 0x3c,
+ 0x85,
+ 0x05,
+ 0x0e,
+ 0xa3,
+ 0x2b,
+ 0x07,
+ 0xc8,
+ 0xbf,
+ 0xe5,
+ 0x13,
+ 0x82,
+ 0x62,
+ 0x08,
+ 0x61,
+ 0x69,
+ 0x4b,
+ 0x47,
+ 0x62,
+ 0x73,
+ 0x44,
+ 0x64,
+ 0x8e,
+ 0xe2,
+ 0x91,
+ 0xa6,
+ 0x9a,
+ 0xb7,
+ 0xe9,
+ 0x04,
+ 0xb6,
+ 0x54,
+ 0x0c,
+ 0xc5,
+ 0xa9,
+ 0x47,
+ 0xa6,
+ 0xc9,
+ 0x08,
+ 0xfe,
+ 0x4e,
+ 0xa6,
+ 0xcc,
+ 0x8a,
+ 0x5b,
+ 0x90,
+ 0x6f,
+ 0x2b,
+ 0x3f,
+ 0xb6,
+ 0x0a,
+ 0x96,
+ 0xc0,
+ 0x78,
+ 0x58,
+ 0x3c,
+ 0x76,
+ 0x6d,
+ 0x94,
+ 0x1a,
+ 0xe4,
+ 0x4e,
+ 0xb8,
+ 0x38,
+ 0xbb,
+ 0xf5,
+ 0xeb,
+ 0x29,
+ 0xd8,
+ 0xb0,
+ 0xf3,
+ 0x15,
+ 0x1e,
+ 0x99,
+ 0x96,
+ 0x3c,
+ 0x5d,
+ 0x63,
+ 0xd5,
+ 0xb1,
+ 0xad,
+ 0x52,
+ 0xb8,
+ 0x55,
+ 0x70,
+ 0x75,
+ 0x3e,
+ 0x1a,
+ 0xd5,
+ 0xda,
+ 0xf6,
+ 0x7a,
+ 0x48,
+ 0x7d,
+ 0x44,
+ 0x41,
+ 0xf9,
+ 0x11,
+ 0xce,
+ 0xd7,
+ 0xca,
+ 0xa5,
+ 0x3d,
+ 0x7a,
+ 0x79,
+ 0x7e,
+ 0x7d,
+ 0x25,
+ 0x1b,
+ 0x77,
+ 0xbc,
+ 0xf7,
+ 0xc7,
+ 0x0f,
+ 0x84,
+ 0x95,
+ 0x10,
+ 0x92,
+ 0x67,
+ 0x15,
+ 0x11,
+ 0x5a,
+ 0x5e,
+ 0x41,
+ 0x66,
+ 0x0f,
+ 0x38,
+ 0x03,
+ 0xb2,
+ 0xf1,
+ 0x5d,
+ 0xf8,
+ 0xab,
+ 0xc0,
+ 0x02,
+ 0x76,
+ 0x84,
+ 0x28,
+ 0xf4,
+ 0x9d,
+ 0x56,
+ 0x46,
+ 0x60,
+ 0x20,
+ 0xdb,
+ 0x68,
+ 0xa7,
+ 0xbb,
+ 0xee,
+ 0xac,
+ 0x15,
+ 0x01,
+ 0x2f,
+ 0x20,
+ 0x09,
+ 0xdb,
+ 0xc0,
+ 0x16,
+ 0xa1,
+ 0x89,
+ 0xf9,
+ 0x94,
+ 0x59,
+ 0x00,
+ 0xc1,
+ 0x76,
+ 0xbf,
+ 0xc1,
+ 0x4d,
+ 0x5d,
+ 0x2d,
+ 0xa9,
+ 0x85,
+ 0x2c,
+ 0xd6,
+ 0xd3,
+ 0x14,
+ 0xcc,
+ 0x02,
+ 0xc3,
+ 0xc2,
+ 0xfa,
+ 0x6b,
+ 0xb7,
+ 0xa6,
+ 0xef,
+ 0xdd,
+ 0x12,
+ 0x26,
+ 0xa4,
+ 0x63,
+ 0xe3,
+ 0x62,
+ 0xbd,
+ 0x56,
+ 0x8a,
+ 0x52,
+ 0x2b,
+ 0xb9,
+ 0xdf,
+ 0x09,
+ 0xbc,
+ 0x0e,
+ 0x97,
+ 0xa9,
+ 0xb0,
+ 0x82,
+ 0x46,
+ 0x08,
+ 0xd5,
+ 0x1a,
+ 0x8e,
+ 0x1b,
+ 0xa7,
+ 0x90,
+ 0x98,
+ 0xb9,
+ 0xbb,
+ 0x3c,
+ 0x17,
+ 0x9a,
+ 0xf2,
+ 0x82,
+ 0xba,
+ 0x64,
+ 0x0a,
+ 0x7f,
+ 0xca,
+ 0x5a,
+ 0x8c,
+ 0x7c,
+ 0xd3,
+ 0x79,
+ 0x09,
+ 0x5b,
+ 0x26,
+ 0xbb,
+ 0xbd,
+ 0x25,
+ 0xdf,
+ 0x3d,
+ 0x6f,
+ 0x9a,
+ 0x8f,
+ 0xee,
+ 0x21,
+ 0x66,
+ 0xb0,
+ 0x8d,
+ 0x84,
+ 0x4c,
+ 0x91,
+ 0x45,
+ 0xd4,
+ 0x77,
+ 0x4f,
+ 0xb3,
+ 0x8c,
+ 0xbc,
+ 0xa8,
+ 0x99,
+ 0xaa,
+ 0x19,
+ 0x53,
+ 0x7c,
+ 0x02,
+ 0x87,
+ 0xbb,
+ 0x0b,
+ 0x7c,
+ 0x1a,
+ 0x2d,
+ 0xdf,
+ 0x48,
+ 0x44,
+ 0x06,
+ 0xd6,
+ 0x7d,
+ 0x0c,
+ 0x2d,
+ 0x35,
+ 0x76,
+ 0xae,
+ 0xc4,
+ 0x5f,
+ 0x71,
+ 0x85,
+ 0x97,
+ 0xc4,
+ 0x3d,
+ 0xef,
+ 0x52,
+ 0xbe,
+ 0x00,
+ 0xe4,
+ 0xcd,
+ 0x49,
+ 0xd1,
+ 0xd1,
+ 0x1c,
+ 0x3c,
+ 0xd0,
+ 0x1c,
+ 0x42,
+ 0xaf,
+ 0xd4,
+ 0xbd,
+ 0x58,
+ 0x34,
+ 0x07,
+ 0x32,
+ 0xee,
+ 0xb9,
+ 0xb5,
+ 0xea,
+ 0xff,
+ 0xd7,
+ 0x8c,
+ 0x0d,
+ 0x2e,
+ 0x2f,
+ 0xaf,
+ 0x87,
+ 0xbb,
+ 0xe6,
+ 0x52,
+ 0x71,
+ 0x22,
+ 0xf5,
+ 0x25,
+ 0x17,
+ 0xa1,
+ 0x82,
+ 0x04,
+ 0xc2,
+ 0x4a,
+ 0xbd,
+ 0x57,
+ 0xc6,
+ 0xab,
+ 0xc8,
+ 0x35,
+ 0x0c,
+ 0x3c,
+ 0xd9,
+ 0xc2,
+ 0x43,
+ 0xdb,
+ 0x27,
+ 0x92,
+ 0xcf,
+ 0xb8,
+ 0x25,
+ 0x60,
+ 0xfa,
+ 0x21,
+ 0x3b,
+ 0x04,
+ 0x52,
+ 0xc8,
+ 0x96,
+ 0xba,
+ 0x74,
+ 0xe3,
+ 0x67,
+ 0x3e,
+ 0x8e,
+ 0x8d,
+ 0x61,
+ 0x90,
+ 0x92,
+ 0x59,
+ 0xb6,
+ 0x1a,
+ 0x1c,
+ 0x5e,
+ 0x21,
+ 0xc1,
+ 0x65,
+ 0xe5,
+ 0xa6,
+ 0x34,
+ 0x05,
+ 0x6f,
+ 0xc5,
+ 0x60,
+ 0xb1,
+ 0x83,
+ 0xc1,
+ 0xd5,
+ 0xd5,
+ 0xed,
+ 0xd9,
+ 0xc7,
+ 0x11,
+ 0x7b,
+ 0x49,
+ 0x7a,
+ 0xf9,
+ 0xf9,
+ 0x84,
+ 0x47,
+ 0x9b,
+ 0xe2,
+ 0xa5,
+ 0x82,
+ 0xe0,
+ 0xc2,
+ 0x88,
+ 0xd0,
+ 0xb2,
+ 0x58,
+ 0x88,
+ 0x7f,
+ 0x45,
+ 0x09,
+ 0x67,
+ 0x74,
+ 0x61,
+ 0xbf,
+ 0xe6,
+ 0x40,
+ 0xe2,
+ 0x9d,
+ 0xc2,
+ 0x47,
+ 0x05,
+ 0x89,
+ 0xed,
+ 0xcb,
+ 0xbb,
+ 0xb7,
+ 0x27,
+ 0xe7,
+ 0xdc,
+ 0x7a,
+ 0xfd,
+ 0xbf,
+ 0xa8,
+ 0xd0,
+ 0xaa,
+ 0x10,
+ 0x39,
+ 0x3c,
+ 0x20,
+ 0xf0,
+ 0xd3,
+ 0x6e,
+ 0xb1,
+ 0x72,
+ 0xf8,
+ 0xe6,
+ 0x0f,
+ 0xef,
+ 0x37,
+ 0xe5,
+ 0x09,
+ 0x33,
+ 0x5a,
+ 0x83,
+ 0x43,
+ 0x80,
+ 0x4f,
+ 0x65,
+ 0x2f,
+ 0x7c,
+ 0x8c,
+ 0x6a,
+ 0xa0,
+ 0x82,
+ 0x0c,
+ 0xd4,
+ 0xd4,
+ 0xfa,
+ 0x81,
+ 0x60,
+ 0x3d,
+ 0xdf,
+ 0x06,
+ 0xf1,
+ 0x5f,
+ 0x08,
+ 0x0d,
+ 0x6d,
+ 0x43,
+ 0xf2,
+ 0xe3,
+ 0x11,
+ 0x7d,
+ 0x80,
+ 0x32,
+ 0xc5,
+ 0xfb,
+ 0xc5,
+ 0xd9,
+ 0x27,
+ 0xec,
+ 0xc6,
+ 0x4e,
+ 0x65,
+ 0x27,
+ 0x76,
+ 0x87,
+ 0xa6,
+ 0xee,
+ 0xee,
+ 0xd7,
+ 0x8b,
+ 0xd1,
+ 0xa0,
+ 0x5c,
+ 0xb0,
+ 0x42,
+ 0x13,
+ 0x0e,
+ 0x95,
+ 0x4a,
+ 0xf2,
+ 0x06,
+ 0xc6,
+ 0x43,
+ 0x33,
+ 0xf4,
+ 0xc7,
+ 0xf8,
+ 0xe7,
+ 0x1f,
+ 0xdd,
+ 0xe4,
+ 0x46,
+ 0x4a,
+ 0x70,
+ 0x39,
+ 0x6c,
+ 0xd0,
+ 0xed,
+ 0xca,
+ 0xbe,
+ 0x60,
+ 0x3b,
+ 0xd1,
+ 0x7b,
+ 0x57,
+ 0x48,
+ 0xe5,
+ 0x3a,
+ 0x79,
+ 0xc1,
+ 0x69,
+ 0x33,
+ 0x53,
+ 0x1b,
+ 0x80,
+ 0xb8,
+ 0x91,
+ 0x7d,
+ 0xb4,
+ 0xf6,
+ 0x17,
+ 0x1a,
+ 0x1d,
+ 0x5a,
+ 0x32,
+ 0xd6,
+ 0xcc,
+ 0x71,
+ 0x29,
+ 0x3f,
+ 0x28,
+ 0xbb,
+ 0xf3,
+ 0x5e,
+ 0x71,
+ 0xb8,
+ 0x43,
+ 0xaf,
+ 0xf8,
+ 0xb9,
+ 0x64,
+ 0xef,
+ 0xc4,
+ 0xa5,
+ 0x6c,
+ 0x08,
+ 0x53,
+ 0xc7,
+ 0x00,
+ 0x10,
+ 0x39,
+ 0x4f,
+ 0xdd,
+ 0xe4,
+ 0xb6,
+ 0x19,
+ 0x27,
+ 0xfb,
+ 0xb8,
+ 0xf5,
+ 0x32,
+ 0x73,
+ 0xe5,
+ 0xcb,
+ 0x32,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+ static byte chkb[] = new byte [60 + 4];
+
+ /**
+ * Calculates a crc checksum-sequence over an array.
+ */
+ public static byte BlockSequenceCRCByte(byte base[], int offset, int length, int sequence)
+ {
+ int n;
+ int p_ndx;
+ short x;
+
+ short crc;
+
+ if (sequence < 0)
+ Sys.Error("sequence < 0, this shouldn't happen\n");
+
+ //p_ndx = (sequence % (sizeof(chktbl) - 4));
+ p_ndx = (sequence % (1024 - 4));
+
+ //memcpy(chkb, base, length);
+ System.arraycopy(base, offset , chkb, 0, Math.max(60, length));
+
+ chkb[length]= (byte) chktbl[p_ndx + 0];
+ chkb[length + 1]= (byte) chktbl[p_ndx + 1];
+ chkb[length + 2]= (byte) chktbl[p_ndx + 2];
+ chkb[length + 3]= (byte) chktbl[p_ndx + 3];
+
+
+ length += 4;
+
+ crc = CRC.CRC_Block(chkb, length);
+
+ for (x= 0, n= 0; n < length; n++)
+ x += chkb[n];
+
+ crc ^= x;
+
+ return (byte)(crc & 0xFF);
+ }
+
} \ No newline at end of file
diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java
index 6a505d0..0babfe4 100644
--- a/src/jake2/qcommon/FS.java
+++ b/src/jake2/qcommon/FS.java
@@ -2,7 +2,7 @@
* FS.java
* Copyright (C) 2003
*
- * $Id: FS.java,v 1.2.2.1 2004-07-09 08:09:08 hzi Exp $
+ * $Id: FS.java,v 1.2.2.2 2004-07-09 08:38:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -116,7 +116,7 @@ public final class FS extends Globals {
if (index > 0) {
File f = new File(path.substring(0, index));
if (!f.mkdirs()) {
- Com.Printf("can't create path \"" + path + '"');
+ Com.Printf("can't create path \"" + path + '"' + "\n" );
}
}
}
diff --git a/src/jake2/qcommon/MD4.java b/src/jake2/qcommon/MD4.java
index 45fdf7c..e6a2add 100644
--- a/src/jake2/qcommon/MD4.java
+++ b/src/jake2/qcommon/MD4.java
@@ -19,11 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 02.02.2004 by RST.
-// $Id: MD4.java,v 1.1 2004-07-07 19:59:31 hzi Exp $
+// $Id: MD4.java,v 1.1.1.1.2.1 2004-07-09 08:38:29 hzi Exp $
package jake2.qcommon;
import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
import java.security.MessageDigest;
import jake2.*;
@@ -295,17 +296,18 @@ public class MD4 extends MessageDigest implements Cloneable {
return t << s | t >>> (32 - s);
}
+ /**
+ * Bugfixed, now works prima (RST).
+ */
public static int Com_BlockChecksum(byte[] buffer, int length) {
- byte digest[] = new byte[16];
+
int val;
MD4 md4 = new MD4();
md4.engineUpdate(buffer, 0, length);
- byte data[] = md4.engineDigest();
- Com.Printf("md4: " + Lib.hexDump(data, 16, false));
-
+ byte data[] = md4.engineDigest();
ByteBuffer bb = ByteBuffer.wrap(data);
- //val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];
+ bb.order(ByteOrder.LITTLE_ENDIAN);
val = bb.getInt() ^ bb.getInt() ^ bb.getInt() ^ bb.getInt();
return val;
}
diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java
index 02da212..c8d8624 100644
--- a/src/jake2/qcommon/Qcommon.java
+++ b/src/jake2/qcommon/Qcommon.java
@@ -2,7 +2,7 @@
* Qcommon.java
* Copyright 2003
*
- * $Id: Qcommon.java,v 1.3.2.1 2004-07-09 08:09:08 hzi Exp $
+ * $Id: Qcommon.java,v 1.3.2.2 2004-07-09 08:38:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/qcommon/qfiles.java b/src/jake2/qcommon/qfiles.java
index ae7fdf6..2d9cfdc 100644
--- a/src/jake2/qcommon/qfiles.java
+++ b/src/jake2/qcommon/qfiles.java
@@ -2,7 +2,7 @@
* qfiles.java
* Copyright (C) 2003
*
- * $Id: qfiles.java,v 1.3 2004-07-08 20:24:48 hzi Exp $
+ * $Id: qfiles.java,v 1.3.2.1 2004-07-09 08:38:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,14 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.qcommon;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
+import jake2.Defines;
-import jake2.*;
-import jake2.client.*;
-import jake2.game.*;
-import jake2.render.*;
-import jake2.server.*;
+import java.nio.*;
/**
* qfiles
@@ -292,6 +287,14 @@ public class qfiles {
ofs_glcmds = b.getInt();
ofs_end = b.getInt(); // end of file
}
+
+ /*
+ * new members for vertex array handling
+ */
+ public FloatBuffer textureCoordBuf = null;
+ public IntBuffer vertexIndexBuf = null;
+ public int[] counts = null;
+ public IntBuffer[] indexElements = null;
}
/*
diff --git a/src/jake2/render/FastJoglRenderer.java b/src/jake2/render/FastJoglRenderer.java
index da20bfd..fb9a5f5 100644
--- a/src/jake2/render/FastJoglRenderer.java
+++ b/src/jake2/render/FastJoglRenderer.java
@@ -2,7 +2,7 @@
* FastJoglRenderer.java
* Copyright (C) 2003
*
- * $Id: FastJoglRenderer.java,v 1.1 2004-07-09 06:50:47 hzi Exp $
+ * $Id: FastJoglRenderer.java,v 1.1.2.1 2004-07-09 08:38:23 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/JoglRenderer.java b/src/jake2/render/JoglRenderer.java
index 2829a96..c5834a1 100644
--- a/src/jake2/render/JoglRenderer.java
+++ b/src/jake2/render/JoglRenderer.java
@@ -2,7 +2,7 @@
* JoglRenderer.java
* Copyright (C) 2003
*
- * $Id: JoglRenderer.java,v 1.2 2004-07-08 15:58:48 hzi Exp $
+ * $Id: JoglRenderer.java,v 1.2.2.1 2004-07-09 08:38:23 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,15 +25,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.render;
-import java.awt.Dimension;
-
import jake2.Defines;
+import jake2.client.*;
import jake2.qcommon.xcommand_t;
-import jake2.render.jogl.*;
+import jake2.render.jogl.Impl;
-import jake2.client.refdef_t;
-import jake2.client.refexport_t;
-import jake2.client.refimport_t;
+import java.awt.Dimension;
/**
* JoglRenderer
@@ -59,11 +56,10 @@ final class JoglRenderer extends Impl implements refexport_t, Ref {
* @see jake2.client.refexport_t#Init()
*/
public boolean Init(int vid_xpos, int vid_ypos) {
-
// pre init
if (!R_Init(vid_xpos, vid_ypos)) return false;
// calls the R_Init2() internally
- updateScreen(null);
+ updateScreen();
// the result from R_Init2()
return post_init;
}
@@ -79,7 +75,18 @@ final class JoglRenderer extends Impl implements refexport_t, Ref {
* @see jake2.client.refexport_t#BeginRegistration(java.lang.String)
*/
public void BeginRegistration(String map) {
- R_BeginRegistration(map);
+ if (contextInUse) {
+ R_BeginRegistration(map);
+ return;
+ }
+
+ this.name = map;
+
+ updateScreen(new xcommand_t() {
+ public void execute() {
+ R_BeginRegistration(JoglRenderer.this.name);
+ }
+ });
}
@@ -143,18 +150,43 @@ final class JoglRenderer extends Impl implements refexport_t, Ref {
return image;
}
+ private float[] axis;
+ private float rotate;
+
/**
* @see jake2.client.refexport_t#SetSky(java.lang.String, float, float[])
*/
public void SetSky(String name, float rotate, float[] axis) {
- R_SetSky(name, rotate, axis);
+ if (contextInUse) {
+ R_SetSky(name, rotate, axis);
+ return;
+ }
+
+ this.name = name;
+ this.rotate = rotate;
+ this.axis = axis;
+
+ updateScreen(new xcommand_t() {
+ public void execute() {
+ R_SetSky(JoglRenderer.this.name, JoglRenderer.this.rotate, JoglRenderer.this.axis);
+ }
+ });
}
/**
* @see jake2.client.refexport_t#EndRegistration()
*/
public void EndRegistration() {
- R_EndRegistration();
+ if (contextInUse) {
+ R_EndRegistration();
+ return;
+ }
+
+ updateScreen(new xcommand_t() {
+ public void execute() {
+ R_EndRegistration();
+ }
+ });
}
/**
@@ -268,5 +300,4 @@ final class JoglRenderer extends Impl implements refexport_t, Ref {
this.ri = rimp;
return this;
}
-
} \ No newline at end of file
diff --git a/src/jake2/render/Renderer.java b/src/jake2/render/Renderer.java
index 4dfe99b..5ceecf6 100644
--- a/src/jake2/render/Renderer.java
+++ b/src/jake2/render/Renderer.java
@@ -2,7 +2,7 @@
* Renderer.java
* Copyright (C) 2003
*
- * $Id: Renderer.java,v 1.1.1.1.2.1 2004-07-09 08:08:44 hzi Exp $
+ * $Id: Renderer.java,v 1.1.1.1.2.2 2004-07-09 08:38:11 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -46,8 +46,8 @@ public class Renderer {
static {
try {
Class.forName("jake2.render.JoglRenderer");
+ Class.forName("jake2.render.FastJoglRenderer");
} catch (ClassNotFoundException e) {
- //logger.log(Level.SEVERE, "can't found " + DEFAULT_CLASS);
e.printStackTrace();
}
};
@@ -71,13 +71,12 @@ public class Renderer {
// find a driver
Ref driver = null;
int count = drivers.size();
- for (int i = 0; i < count && driver == null; i++) {
+ for (int i = 0; i < count; i++) {
driver = (Ref) drivers.get(i);
if (driver.getName().equals(driverName)) {
return driver.GetRefAPI(rimp);
}
}
- //logger.log(Level.INFO, "Refresh driver \"" + driverName + "\"not found");
// null if driver not found
return null;
}
diff --git a/src/jake2/render/fastjogl/Anorms.java b/src/jake2/render/fastjogl/Anorms.java
index 552b305..fa0a8fe 100644
--- a/src/jake2/render/fastjogl/Anorms.java
+++ b/src/jake2/render/fastjogl/Anorms.java
@@ -2,7 +2,7 @@
* Anorms.java
* Copyright (C) 2003
*
- * $Id: Anorms.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Anorms.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Base.java b/src/jake2/render/fastjogl/Base.java
index c5cc690..6472634 100644
--- a/src/jake2/render/fastjogl/Base.java
+++ b/src/jake2/render/fastjogl/Base.java
@@ -2,7 +2,7 @@
* Base.java
* Copyright (C) 2003
*
- * $Id: Base.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Base.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Draw.java b/src/jake2/render/fastjogl/Draw.java
index fcb48b6..d088d69 100644
--- a/src/jake2/render/fastjogl/Draw.java
+++ b/src/jake2/render/fastjogl/Draw.java
@@ -2,7 +2,7 @@
* Draw.java
* Copyright (C) 2003
*
- * $Id: Draw.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Draw.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Image.java b/src/jake2/render/fastjogl/Image.java
index de364c3..d470fc3 100644
--- a/src/jake2/render/fastjogl/Image.java
+++ b/src/jake2/render/fastjogl/Image.java
@@ -2,7 +2,7 @@
* Image.java
* Copyright (C) 2003
*
- * $Id: Image.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Image.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Impl.java b/src/jake2/render/fastjogl/Impl.java
index 03af496..7e8698f 100644
--- a/src/jake2/render/fastjogl/Impl.java
+++ b/src/jake2/render/fastjogl/Impl.java
@@ -2,7 +2,7 @@
* Impl.java
* Copyright (C) 2003
*
- * $Id: Impl.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Impl.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Light.java b/src/jake2/render/fastjogl/Light.java
index b963b21..d72accb 100644
--- a/src/jake2/render/fastjogl/Light.java
+++ b/src/jake2/render/fastjogl/Light.java
@@ -2,7 +2,7 @@
* Light.java
* Copyright (C) 2003
*
- * $Id: Light.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Light.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Main.java b/src/jake2/render/fastjogl/Main.java
index 2363db4..05a4110 100644
--- a/src/jake2/render/fastjogl/Main.java
+++ b/src/jake2/render/fastjogl/Main.java
@@ -2,7 +2,7 @@
* Main.java
* Copyright (C) 2003
*
- * $Id: Main.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Main.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Mesh.java b/src/jake2/render/fastjogl/Mesh.java
index e7da997..ad0d131 100644
--- a/src/jake2/render/fastjogl/Mesh.java
+++ b/src/jake2/render/fastjogl/Mesh.java
@@ -2,7 +2,7 @@
* Mesh.java
* Copyright (C) 2003
*
- * $Id: Mesh.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Mesh.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Misc.java b/src/jake2/render/fastjogl/Misc.java
index bcd2a5f..31568c2 100644
--- a/src/jake2/render/fastjogl/Misc.java
+++ b/src/jake2/render/fastjogl/Misc.java
@@ -2,7 +2,7 @@
* Misc.java
* Copyright (C) 2003
*
- * $Id: Misc.java,v 1.1 2004-07-09 06:50:48 hzi Exp $
+ * $Id: Misc.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Model.java b/src/jake2/render/fastjogl/Model.java
index 4b781be..fed6f81 100644
--- a/src/jake2/render/fastjogl/Model.java
+++ b/src/jake2/render/fastjogl/Model.java
@@ -2,7 +2,7 @@
* Model.java
* Copyright (C) 2003
*
- * $Id: Model.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Model.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -509,9 +509,6 @@ public abstract class Model extends Surf {
count = l.filelen / texinfo_t.SIZE;
// out = Hunk_Alloc ( count*sizeof(*out));
out = new mtexinfo_t[count];
- for ( i=0 ; i<count ; i++) {
- out[i] = new mtexinfo_t();
- }
loadmodel.texinfo = out;
loadmodel.numtexinfo = count;
@@ -519,10 +516,13 @@ public abstract class Model extends Surf {
ByteBuffer bb = ByteBuffer.wrap(mod_base, l.fileofs, l.filelen);
bb.order(ByteOrder.LITTLE_ENDIAN);
- for ( i=0 ; i<count ; i++) {
-
+ for ( i=0 ; i<count ; i++)
+ {
in = new texinfo_t(bb);
- out[i].vecs = in.vecs;
+ out[i] = new mtexinfo_t();
+ //for (j=0 ; j<8 ; j++)
+ out[i].vecs = in.vecs;
+
out[i].flags = in.flags;
next = in.nexttexinfo;
if (next > 0)
@@ -533,14 +533,17 @@ public abstract class Model extends Surf {
name = "textures/" + in.texture + ".wal";
out[i].image = GL_FindImage(name, it_wall);
- if (out[i].image == null) {
+ if (out[i].image == null)
+ {
ri.Con_Printf(Defines.PRINT_ALL, "Couldn't load " + name + '\n');
out[i].image = r_notexture;
}
}
// count animation frames
- for (i=0 ; i<count ; i++) {
+ for (i=0 ; i<count ; i++)
+ {
+ // out = &loadmodel.texinfo[i];
out[i].numframes = 1;
for (step = out[i].next ; (step != null) && (step != out[i]) ; step=step.next)
out[i].numframes++;
diff --git a/src/jake2/render/fastjogl/Surf.java b/src/jake2/render/fastjogl/Surf.java
index c7e7bc0..de0f61e 100644
--- a/src/jake2/render/fastjogl/Surf.java
+++ b/src/jake2/render/fastjogl/Surf.java
@@ -2,7 +2,7 @@
* Surf.java
* Copyright (C) 2003
*
- * $Id: Surf.java,v 1.1 2004-07-09 06:50:48 hzi Exp $
+ * $Id: Surf.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/fastjogl/Warp.java b/src/jake2/render/fastjogl/Warp.java
index f9a5b07..44ed55e 100644
--- a/src/jake2/render/fastjogl/Warp.java
+++ b/src/jake2/render/fastjogl/Warp.java
@@ -2,7 +2,7 @@
* Warp.java
* Copyright (C) 2003
*
- * $Id: Warp.java,v 1.1 2004-07-09 06:50:49 hzi Exp $
+ * $Id: Warp.java,v 1.1.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/render/glpoly_t.java b/src/jake2/render/glpoly_t.java
index 25cff9c..194c404 100644
--- a/src/jake2/render/glpoly_t.java
+++ b/src/jake2/render/glpoly_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 20.11.2003 by RST.
-// $Id: glpoly_t.java,v 1.1 2004-07-07 19:59:35 hzi Exp $
+// $Id: glpoly_t.java,v 1.1.1.1.2.1 2004-07-09 08:38:23 hzi Exp $
package jake2.render;
@@ -35,4 +35,12 @@ public class glpoly_t {
public glpoly_t(int numverts) {
this.verts = new float[numverts][VERTEXSIZE];
}
+
+ /*
+ * vertex array extension
+ */
+
+ // the array position (glDrawArrays)
+ public int pos = 0;
+
}
diff --git a/src/jake2/render/jogl/Draw.java b/src/jake2/render/jogl/Draw.java
index eac0a1e..644164f 100644
--- a/src/jake2/render/jogl/Draw.java
+++ b/src/jake2/render/jogl/Draw.java
@@ -2,7 +2,7 @@
* Draw.java
* Copyright (C) 2003
*
- * $Id: Draw.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
+ * $Id: Draw.java,v 1.2.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -257,10 +257,10 @@ public abstract class Draw extends Image {
int color = d_8to24table[colorIndex];
- gl.glColor3f(
- ((color >> 0) & 0xff)/255.0f, // r
- ((color >> 8) & 0xff)/255.0f, // g
- ((color >> 16) & 0xff)/255.0f // b
+ gl.glColor3ub(
+ (byte)((color >> 0) & 0xff), // r
+ (byte)((color >> 8) & 0xff), // g
+ (byte)((color >> 16) & 0xff) // b
);
gl.glBegin (GL.GL_QUADS);
diff --git a/src/jake2/render/jogl/Image.java b/src/jake2/render/jogl/Image.java
index 4e65481..9dc86bf 100644
--- a/src/jake2/render/jogl/Image.java
+++ b/src/jake2/render/jogl/Image.java
@@ -2,7 +2,7 @@
* Image.java
* Copyright (C) 2003
*
- * $Id: Image.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Image.java,v 1.2.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,27 +26,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.render.jogl;
import jake2.Defines;
+import jake2.client.particle_t;
import jake2.game.cvar_t;
import jake2.qcommon.longjmpException;
import jake2.qcommon.qfiles;
import jake2.render.image_t;
+import jake2.util.Lib;
import jake2.util.Vargs;
import java.awt.Dimension;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
-import java.awt.image.BufferedImageOp;
-import java.awt.image.Raster;
-import java.awt.image.SampleModel;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.IntBuffer;
+import java.nio.*;
import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
import net.java.games.jogl.GL;
@@ -128,8 +121,7 @@ public abstract class Image extends Main {
GL_TexEnv(GL.GL_REPLACE);
}
- void GL_SelectTexture(int texture /* GLenum */
- ) {
+ void GL_SelectTexture(int texture /* GLenum */) {
int tmu;
if (!qglSelectTextureSGIS && !qglActiveTextureARB)
@@ -787,9 +779,9 @@ public abstract class Image extends Main {
filledcolor = 0;
// attempt to find opaque black
for (i = 0; i < 256; ++i)
- if (d_8to24table[i] == (255 << 0)) // alpha 1.0
- // TODO check this: if ((d_8to24table[i] & 0xFF000000) == 0xFF000000) // alpha 1.0
- {
+ // TODO check this
+ if (d_8to24table[i] == 0xFF000000) { // alpha 1.0
+ //if (d_8to24table[i] == (255 << 0)) // alpha 1.0
filledcolor = i;
break;
}
@@ -1068,6 +1060,7 @@ public abstract class Image extends Main {
*/
int[] scaled = new int[256 * 256];
byte[] paletted_texture = new byte[256 * 256];
+ IntBuffer tex = Lib.newIntBuffer(512 * 256, ByteOrder.LITTLE_ENDIAN);
boolean GL_Upload32(int[] data, int width, int height, boolean mipmap) {
int samples;
@@ -1149,6 +1142,7 @@ public abstract class Image extends Main {
paletted_texture);
}
else {
+ tex.rewind(); tex.put(data);
gl.glTexImage2D(
GL.GL_TEXTURE_2D,
0,
@@ -1158,13 +1152,13 @@ public abstract class Image extends Main {
0,
GL.GL_RGBA,
GL.GL_UNSIGNED_BYTE,
- data);
+ tex);
}
//goto done;
throw new longjmpException();
}
//memcpy (scaled, data, width*height*4); were bytes
- IntBuffer.wrap(data).get(scaled, 0, width * height);
+ System.arraycopy(data, 0, scaled, 0, width * height);
}
else
@@ -1187,7 +1181,8 @@ public abstract class Image extends Main {
paletted_texture);
}
else {
- gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, scaled);
+ tex.rewind(); tex.put(scaled);
+ gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, comp, scaled_width, scaled_height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, tex);
}
if (mipmap) {
@@ -1218,6 +1213,7 @@ public abstract class Image extends Main {
paletted_texture);
}
else {
+ tex.rewind(); tex.put(scaled);
gl.glTexImage2D(
GL.GL_TEXTURE_2D,
miplevel,
@@ -1227,14 +1223,14 @@ public abstract class Image extends Main {
0,
GL.GL_RGBA,
GL.GL_UNSIGNED_BYTE,
- scaled);
+ tex);
}
}
}
// label done:
}
catch (longjmpException e) {
- ; // replaces labe done
+ ; // replaces label done
}
if (mipmap) {
@@ -1578,7 +1574,7 @@ public abstract class Image extends Main {
// free it
// TODO jogl bug
- //gl.glDeleteTextures(1, new int[] {image.texnum});
+ gl.glDeleteTextures(1, new int[] {image.texnum});
image.clear();
}
}
@@ -1590,7 +1586,6 @@ public abstract class Image extends Main {
*/
protected void Draw_GetPalette() {
int r, g, b;
- int v;
Dimension dim;
byte[] pic;
byte[][] palette = new byte[1][]; //new byte[768];
@@ -1604,15 +1599,18 @@ public abstract class Image extends Main {
byte[] pal = palette[0];
+ int j = 0;
for (int i = 0; i < 256; i++) {
- r = pal[i * 3 + 0];
- g = pal[i * 3 + 1];
- b = pal[i * 3 + 2];
+ r = pal[j++] & 0xFF;
+ g = pal[j++] & 0xFF;
+ b = pal[j++] & 0xFF;
- d_8to24table[i] = (255 << 24) + (r << 0) + (g << 8) + (b << 16);
+ d_8to24table[i] = (255 << 24) | (b << 16) | (g << 8) | (r << 0);
}
- d_8to24table[255] &= 0x00ffffff; // 255 is transparent
+ d_8to24table[255] &= 0x00FFFFFF; // 255 is transparent
+
+ particle_t.setColorPalette(d_8to24table);
}
/*
@@ -1686,7 +1684,7 @@ public abstract class Image extends Main {
continue; // free image_t slot
// free it
// TODO jogl bug
- //gl.glDeleteTextures(1, new int[] {image.texnum});
+ gl.glDeleteTextures(1, new int[] {image.texnum});
image.clear();
}
}
diff --git a/src/jake2/render/jogl/Impl.java b/src/jake2/render/jogl/Impl.java
index 991c349..cac482f 100644
--- a/src/jake2/render/jogl/Impl.java
+++ b/src/jake2/render/jogl/Impl.java
@@ -2,7 +2,7 @@
* Impl.java
* Copyright (C) 2003
*
- * $Id: Impl.java,v 1.4 2004-07-08 20:56:55 hzi Exp $
+ * $Id: Impl.java,v 1.4.2.1 2004-07-09 08:38:27 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -27,13 +27,11 @@ package jake2.render.jogl;
import jake2.Defines;
import jake2.Globals;
-import jake2.client.CL;
import jake2.qcommon.Com;
import jake2.qcommon.xcommand_t;
-import jake2.server.SV;
import jake2.sys.KBD;
-import java.awt.Dimension;
+import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -48,17 +46,34 @@ import net.java.games.jogl.*;
*/
public class Impl extends Misc implements GLEventListener {
-
-
public static final String DRIVER_NAME = "jogl";
// handles the post initialization with JoglRenderer
protected boolean post_init = false;
- // switch to updateScreen callback
- private boolean switchToCallback = false;
- private xcommand_t callback = null;
+ private final xcommand_t INIT_CALLBACK = new xcommand_t() {
+ public void execute() {
+ // only used for the first run (initialization)
+ // clear the screen
+ gl.glClearColor(0, 0, 0, 0);
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ //
+ // check the post init process
+ //
+ if (!post_init) {
+ ri.Con_Printf(Defines.PRINT_ALL, "Missing multi-texturing for FastJOGL renderer\n");
+ }
+
+ GLimp_EndFrame();
+ }
+ };
+
+ private xcommand_t callback = INIT_CALLBACK;
protected boolean contextInUse = false;
+
+ private GraphicsDevice device;
+ private DisplayMode oldDisplayMode;
GLCanvas canvas;
JFrame window;
@@ -88,13 +103,9 @@ public class Impl extends Misc implements GLEventListener {
ri.Cvar_Get("r_fakeFullscreen", "0", Globals.CVAR_ARCHIVE);
- ri.Con_Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n", null);
+ ri.Con_Printf(Defines.PRINT_ALL, "Initializing OpenGL display\n");
- if (fullscreen) {
- ri.Con_Printf(Defines.PRINT_ALL, "...setting fullscreen mode " + mode + ":");
- }
- else
- ri.Con_Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":");
+ ri.Con_Printf(Defines.PRINT_ALL, "...setting mode " + mode + ":");
if (!ri.Vid_GetModeInfo(newDim, mode)) {
ri.Con_Printf(Defines.PRINT_ALL, " invalid mode\n");
@@ -113,18 +124,12 @@ public class Impl extends Misc implements GLEventListener {
// TODO Use debug pipeline
//canvas.setGL(new DebugGL(canvas.getGL()));
- //canvas.setRenderingThread(Thread.currentThread());
-
canvas.setNoAutoRedrawMode(true);
canvas.addGLEventListener(this);
- window.getContentPane().add(canvas);
-
+ window.getContentPane().add(canvas);
canvas.setSize(newDim.width, newDim.height);
- window.setLocation(window_xpos, window_ypos);
- //window.setUndecorated(true);
- window.setResizable(false);
// register event listener
window.addWindowListener(new WindowAdapter() {
@@ -134,14 +139,57 @@ public class Impl extends Misc implements GLEventListener {
});
// D I F F E R E N T J A K E 2 E V E N T P R O C E S S I N G
+ window.addComponentListener(KBD.listener);
canvas.addKeyListener(KBD.listener);
canvas.addMouseListener(KBD.listener);
canvas.addMouseMotionListener(KBD.listener);
- window.addComponentListener(KBD.listener);
- canvas.requestFocus();
- window.pack();
- window.show();
+ /*
+ * fullscreen handling
+ */
+ GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ device = env.getDefaultScreenDevice();
+
+ if (fullscreen && !device.isFullScreenSupported()) {
+ ri.Con_Printf(Defines.PRINT_ALL, "...fullscreen not supported\n");
+ vid_fullscreen.value = 0;
+ vid_fullscreen.modified = false;
+ }
+
+ fullscreen = fullscreen && device.isFullScreenSupported();
+
+ if (oldDisplayMode == null) {
+ oldDisplayMode = device.getDisplayMode();
+ }
+
+ if (fullscreen) {
+
+ DisplayMode displayMode = findDisplayMode(newDim, oldDisplayMode.getBitDepth(), oldDisplayMode.getRefreshRate());
+
+ if (displayMode != null) {
+ newDim.width = displayMode.getWidth();
+ newDim.height = displayMode.getHeight();
+ window.setUndecorated(true);
+ window.setResizable(false);
+ device.setFullScreenWindow(window);
+ device.setDisplayMode(displayMode);
+ window.setLocation(0, 0);
+ window.setSize(displayMode.getWidth(), displayMode.getHeight());
+ canvas.setSize(displayMode.getWidth(), displayMode.getHeight());
+ ri.Con_Printf(Defines.PRINT_ALL, "...setting fullscreen " + getModeString(displayMode) + '\n');
+ }
+ } else {
+ window.setLocation(window_xpos, window_ypos);
+ window.pack();
+ window.setResizable(false);
+ window.setVisible(true);
+ }
+
+ while (!canvas.isDisplayable()) {
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {}
+ }
canvas.requestFocus();
this.canvas = canvas;
@@ -154,6 +202,38 @@ public class Impl extends Misc implements GLEventListener {
return rserr_ok;
}
+
+ DisplayMode findDisplayMode(Dimension dim, int depth, int rate) {
+ DisplayMode mode = null;
+ DisplayMode m = null;
+ DisplayMode[] modes = device.getDisplayModes();
+ int w = dim.width;
+ int h = dim.height;
+
+ for (int i = 0; i < modes.length; i++) {
+ m = modes[i];
+ if (m.getWidth() == w && m.getHeight() == h && m.getBitDepth() == depth && m.getRefreshRate() == rate) {
+ mode = m;
+ break;
+ }
+ }
+ if (mode == null) mode = oldDisplayMode;
+ Com.Printf(getModeString(mode) + '\n');
+ return mode;
+ }
+
+ String getModeString(DisplayMode m) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(m.getWidth());
+ sb.append('x');
+ sb.append(m.getHeight());
+ sb.append('x');
+ sb.append(m.getBitDepth());
+ sb.append('@');
+ sb.append(m.getRefreshRate());
+ sb.append("Hz");
+ return sb.toString();
+ }
void GLimp_BeginFrame(float camera_separation) {
// do nothing
@@ -180,11 +260,19 @@ public class Impl extends Misc implements GLEventListener {
}
void GLimp_Shutdown() {
+ if (oldDisplayMode != null && device.getFullScreenWindow() != null) {
+ try {
+ device.setDisplayMode(oldDisplayMode);
+ device.setFullScreenWindow(null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
if (this.window != null) {
window.dispose();
}
post_init = false;
- switchToCallback = false;
+ callback = INIT_CALLBACK;
}
void GLimp_EnableLogging(boolean enable) {
@@ -221,31 +309,8 @@ public class Impl extends Misc implements GLEventListener {
this.gl = drawable.getGL();
this.glu = drawable.getGLU();
- this.contextInUse = true;
-
- if (switchToCallback) {
- callback.execute();
- }
- else
- {
-
- // after the first run (initialization) switch to callback
- switchToCallback = true;
-
- // clear the screen
- gl.glClearColor(0, 0, 0, 0);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
-
- //
- // check the post init process
- //
- if (!post_init) {
- ri.Sys_Error(Defines.ERR_FATAL, "Error: can't init JOGL renderer");
- }
-
- GLimp_EndFrame();
- }
-
+ contextInUse = true;
+ callback.execute();
contextInUse = false;
}
@@ -260,20 +325,18 @@ public class Impl extends Misc implements GLEventListener {
* @see net.java.games.jogl.GLEventListener#reshape(net.java.games.jogl.GLDrawable, int, int, int, int)
*/
public void reshape(GLDrawable drawable, int x, int y, int width, int height) {
-
- vid.height = height;
- vid.width = width;
-
- ri.Vid_NewWindow(width, height);
+ // do nothing
}
/*
* @see jake2.client.refexport_t#updateScreen()
*/
+ public void updateScreen() {
+ this.callback = INIT_CALLBACK;
+ canvas.display();
+ }
+
public void updateScreen(xcommand_t callback) {
-// if (canvas == null) {
-// throw new IllegalStateException("Refresh modul \"" + DRIVER_NAME + "\" have to be initialized.");
-// }
this.callback = callback;
canvas.display();
}
diff --git a/src/jake2/render/jogl/Light.java b/src/jake2/render/jogl/Light.java
index 686884a..4e1fa49 100644
--- a/src/jake2/render/jogl/Light.java
+++ b/src/jake2/render/jogl/Light.java
@@ -2,7 +2,7 @@
* Light.java
* Copyright (C) 2003
*
- * $Id: Light.java,v 1.3 2004-07-08 20:56:55 hzi Exp $
+ * $Id: Light.java,v 1.3.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,12 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.render.jogl;
-import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-import java.util.Arrays;
-
-import net.java.games.jogl.GL;
-
import jake2.Defines;
import jake2.Globals;
import jake2.client.dlight_t;
@@ -38,12 +32,15 @@ import jake2.client.lightstyle_t;
import jake2.game.GameBase;
import jake2.game.cplane_t;
import jake2.qcommon.longjmpException;
-import jake2.render.mnode_t;
-import jake2.render.msurface_t;
-import jake2.render.mtexinfo_t;
-import jake2.util.Lib;
+import jake2.render.*;
import jake2.util.Math3D;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.util.Arrays;
+
+import net.java.games.jogl.GL;
+
/**
* Light
*
@@ -79,7 +76,7 @@ public abstract class Light extends Warp {
gl.glColor3f (light.color[0]*0.2f, light.color[1]*0.2f, light.color[2]*0.2f);
for (i=0 ; i<3 ; i++)
v[i] = light.origin[i] - vpn[i]*rad;
- gl.glVertex3fv (v);
+ gl.glVertex3f(v[0], v[1], v[2]);
gl.glColor3f (0,0,0);
for (i=16 ; i>=0 ; i--)
{
@@ -87,7 +84,7 @@ public abstract class Light extends Warp {
for (j=0 ; j<3 ; j++)
v[j] = (float)(light.origin[j] + vright[j]*Math.cos(a)*rad
+ vup[j]*Math.sin(a)*rad);
- gl.glVertex3fv (v);
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd ();
}
@@ -306,16 +303,13 @@ public abstract class Light extends Warp {
ds >>= 4;
dt >>= 4;
- //surf.samples.reset();
- lightmap = surf.samples.slice();
-
+ lightmap = surf.samples;
int lightmapIndex = 0;
+
Math3D.VectorCopy (Globals.vec3_origin, pointcolor);
if (lightmap != null)
{
float[] scale = {0, 0, 0};
-
-// lightmap += 3*(dt * ((surf.extents[0]>>4)+1) + ds);
lightmapIndex += 3 * (dt * ((surf.extents[0] >> 4) + 1) + ds);
for (maps = 0 ; maps < Defines.MAXLIGHTMAPS && surf.styles[maps] != (byte)255; maps++)
@@ -326,15 +320,11 @@ public abstract class Light extends Warp {
pointcolor[0] += (lightmap.get(lightmapIndex + 0) & 0xFF) * scale[0] * (1.0f/255);
pointcolor[1] += (lightmap.get(lightmapIndex + 1) & 0xFF) * scale[1] * (1.0f/255);
pointcolor[2] += (lightmap.get(lightmapIndex + 2) & 0xFF) * scale[2] * (1.0f/255);
-// lightmap += 3*((surf.extents[0]>>4)+1) *
-// ((surf.extents[1]>>4)+1);
lightmapIndex += 3 * ((surf.extents[0] >> 4) + 1) * ((surf.extents[1] >> 4) + 1);
}
}
-
return 1;
}
-
// go down back side
return RecursiveLightPoint (node.children[1 - sideIndex], mid, end);
}
@@ -506,7 +496,7 @@ public abstract class Light extends Warp {
Combine and scale multiple lightmaps into the floating format in blocklights
===============
*/
- void R_BuildLightMap(msurface_t surf, ByteBuffer dest, int stride)
+ void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride)
{
int smax, tmax;
int r, g, b, a, max;
@@ -549,8 +539,8 @@ public abstract class Light extends Warp {
nummaps++)
;
- //surf.samples.reset();
- lightmap = surf.samples.slice();
+ lightmap = surf.samples;
+ int lightmapIndex = 0;
// add all the lightmaps
if ( nummaps == 1 )
@@ -572,18 +562,18 @@ public abstract class Light extends Warp {
{
for (i=0 ; i<size ; i++)
{
- bl[blp++] = lightmap.get() & 0xFF;
- bl[blp++] = lightmap.get() & 0xFF;
- bl[blp++] = lightmap.get() & 0xFF;
+ bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF;
+ bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF;
+ bl[blp++] = lightmap.get(lightmapIndex++) & 0xFF;
}
}
else
{
for (i=0 ; i<size ; i++)
{
- bl[blp++] = (lightmap.get() & 0xFF) * scale[0];
- bl[blp++] = (lightmap.get() & 0xFF) * scale[1];
- bl[blp++] = (lightmap.get() & 0xFF) * scale[2];
+ bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[0];
+ bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[1];
+ bl[blp++] = (lightmap.get(lightmapIndex++) & 0xFF) * scale[2];
}
}
//lightmap += size*3; // skip to next lightmap
@@ -612,18 +602,18 @@ public abstract class Light extends Warp {
{
for (i=0 ; i<size ; i++)
{
- bl[blp++] += lightmap.get() & 0xFF;
- bl[blp++] += lightmap.get() & 0xFF;
- bl[blp++] += lightmap.get() & 0xFF;
+ bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF;
+ bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF;
+ bl[blp++] += lightmap.get(lightmapIndex++) & 0xFF;
}
}
else
{
for (i=0 ; i<size ; i++)
{
- bl[blp++] += (lightmap.get() & 0xFF) * scale[0];
- bl[blp++] += (lightmap.get() & 0xFF) * scale[1];
- bl[blp++] += (lightmap.get() & 0xFF) * scale[2];
+ bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[0];
+ bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[1];
+ bl[blp++] += (lightmap.get(lightmapIndex++) & 0xFF) * scale[2];
}
}
//lightmap += size*3; // skip to next lightmap
@@ -638,7 +628,7 @@ public abstract class Light extends Warp {
} catch (longjmpException store) {}
// put into texture format
- stride -= (smax<<2);
+ stride -= smax;
bl = s_blocklights;
int blp = 0;
@@ -697,8 +687,8 @@ public abstract class Light extends Warp {
b = (int)(b*t);
a = (int)(a*t);
}
- dest.put((byte)r).put((byte)g).put((byte)b).put((byte)a);
- destp += 4;
+ r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF;
+ dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | (r << 0));
}
}
}
@@ -778,9 +768,8 @@ public abstract class Light extends Warp {
a = 255 - a;
break;
}
-
- dest.put((byte)r).put((byte)g).put((byte)b).put((byte)a);
- destp += 4;
+ r &= 0xFF; g &= 0xFF; b &= 0xFF; a &= 0xFF;
+ dest.put(destp++, (a << 24) | (b << 16) | (g << 8) | (r << 0));
}
}
}
diff --git a/src/jake2/render/jogl/Main.java b/src/jake2/render/jogl/Main.java
index 32442ba..8ba3faf 100644
--- a/src/jake2/render/jogl/Main.java
+++ b/src/jake2/render/jogl/Main.java
@@ -2,7 +2,7 @@
* Main.java
* Copyright (C) 2003
*
- * $Id: Main.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+ * $Id: Main.java,v 1.2.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -29,6 +29,7 @@ import jake2.*;
import jake2.client.*;
import jake2.game.cplane_t;
import jake2.game.cvar_t;
+import jake2.qcommon.Cvar;
import jake2.qcommon.qfiles;
import jake2.qcommon.xcommand_t;
import jake2.render.*;
@@ -36,9 +37,12 @@ import jake2.util.Math3D;
import jake2.util.Vargs;
import java.awt.Dimension;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
import net.java.games.jogl.GL;
import net.java.games.jogl.GLU;
+import net.java.games.jogl.util.BufferUtils;
import net.java.games.jogl.util.GLUT;
/**
@@ -52,7 +56,7 @@ public abstract class Main extends Base {
GLU glu;
GLUT glut = new GLUT();
- int[] d_8to24table = new int[256];
+ public static int[] d_8to24table = new int[256];
int c_visible_lightmaps;
int c_visible_textures;
@@ -66,8 +70,8 @@ public abstract class Main extends Base {
boolean qglActiveTextureARB = false;
boolean qglPointParameterfEXT = false;
boolean qglLockArraysEXT = false;
- boolean qglUnlockArraysEXT = false;
boolean qglMTexCoord2fSGIS = false;
+ boolean qwglSwapIntervalEXT = false;
// =================
// abstract methods
@@ -323,22 +327,22 @@ public abstract class Main extends Base {
gl.glTexCoord2f(0, 1);
Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
Math3D.VectorMA(point, -frame.origin_x, vright, point);
- gl.glVertex3fv(point);
+ gl.glVertex3f(point[0], point[1], point[2]);
gl.glTexCoord2f(0, 0);
Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
Math3D.VectorMA(point, -frame.origin_x, vright, point);
- gl.glVertex3fv(point);
+ gl.glVertex3f(point[0], point[1], point[2]);
gl.glTexCoord2f(1, 0);
Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
- gl.glVertex3fv(point);
+ gl.glVertex3f(point[0], point[1], point[2]);
gl.glTexCoord2f(1, 1);
Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
- gl.glVertex3fv(point);
+ gl.glVertex3f(point[0], point[1], point[2]);
gl.glEnd();
@@ -375,7 +379,7 @@ public abstract class Main extends Base {
R_RotateForEntity(currententity);
gl.glDisable(GL.GL_TEXTURE_2D);
- gl.glColor3fv(shadelight);
+ gl.glColor3f(shadelight[0], shadelight[1], shadelight[2]);
// this replaces the TRIANGLE_FAN
glut.glutWireCube(gl, 20);
@@ -479,63 +483,63 @@ public abstract class Main extends Base {
}
gl.glDepthMask(true); // back to writing
}
-
+
/*
** GL_DrawParticles
**
*/
- void GL_DrawParticles(int num_particles, particle_t[] particles) {
- particle_t p;
- int i;
+ void GL_DrawParticles(int num_particles) {
float[] up = { 0, 0, 0 };
float[] right = { 0, 0, 0 };
float scale;
int color;
+ float origin_x, origin_y, origin_z;
+
+ Math3D.VectorScale(vup, 1.5f, up);
+ Math3D.VectorScale(vright, 1.5f, right);
+
GL_Bind(r_particletexture.texnum);
gl.glDepthMask(false); // no z buffering
gl.glEnable(GL.GL_BLEND);
GL_TexEnv(GL.GL_MODULATE);
+
gl.glBegin(GL.GL_TRIANGLES);
- Math3D.VectorScale(vup, 1.5f, up);
- Math3D.VectorScale(vright, 1.5f, right);
+ FloatBuffer sourceVertices = particle_t.vertexArray;
+ IntBuffer sourceColors = particle_t.colorArray;
+ for (int j = 0, i = 0; i < num_particles; i++) {
+ origin_x = sourceVertices.get(j++);
+ origin_y = sourceVertices.get(j++);
+ origin_z = sourceVertices.get(j++);
- for (i = 0; i < num_particles; i++) {
- p = particles[i];
// hack a scale up to keep particles from disapearing
scale =
- (p.origin[0] - r_origin[0]) * vpn[0]
- + (p.origin[1] - r_origin[1]) * vpn[1]
- + (p.origin[2] - r_origin[2]) * vpn[2];
+ (origin_x - r_origin[0]) * vpn[0]
+ + (origin_y - r_origin[1]) * vpn[1]
+ + (origin_z - r_origin[2]) * vpn[2];
- if (scale < 20)
- scale = 1;
- else
- scale = 1 + scale * 0.004f;
-
- color = d_8to24table[p.color];
+ scale = (scale < 20) ? 1 : 1 + scale * 0.004f;
+ color = sourceColors.get(i);
gl.glColor4ub(
- (byte) ((color >> 0) & 0xff),
- (byte) ((color >> 8) & 0xff),
- (byte) ((color >> 16) & 0xff),
- (byte) (p.alpha * 255));
-
+ (byte)((color >> 0) & 0xFF),
+ (byte)((color >> 8) & 0xFF),
+ (byte)((color >> 16) & 0xFF),
+ (byte)((color >> 24) & 0xFF)
+ );
+ // first vertex
gl.glTexCoord2f(0.0625f, 0.0625f);
- gl.glVertex3fv(p.origin);
-
+ gl.glVertex3f(origin_x, origin_y, origin_z);
+ // second vertex
gl.glTexCoord2f(1.0625f, 0.0625f);
- gl.glVertex3f(p.origin[0] + up[0] * scale, p.origin[1] + up[1] * scale, p.origin[2] + up[2] * scale);
-
+ gl.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale);
+ // third vertex
gl.glTexCoord2f(0.0625f, 1.0625f);
- gl.glVertex3f(
- p.origin[0] + right[0] * scale,
- p.origin[1] + right[1] * scale,
- p.origin[2] + right[2] * scale);
+ gl.glVertex3f(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale);
}
-
gl.glEnd();
+
gl.glDisable(GL.GL_BLEND);
gl.glColor4f(1, 1, 1, 1);
gl.glDepthMask(true); // back to normal Z buffering
@@ -550,29 +554,21 @@ public abstract class Main extends Base {
void R_DrawParticles() {
if (gl_ext_pointparameters.value != 0.0f && qglPointParameterfEXT) {
- int color;
- particle_t p;
+ gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
+ gl.glVertexPointer(3, GL.GL_FLOAT, 0, particle_t.vertexArray);
+ gl.glEnableClientState(GL.GL_COLOR_ARRAY);
+ gl.glColorPointer(4, GL.GL_UNSIGNED_BYTE, 0, particle_t.colorArray);
+
gl.glDepthMask(false);
gl.glEnable(GL.GL_BLEND);
gl.glDisable(GL.GL_TEXTURE_2D);
-
gl.glPointSize(gl_particle_size.value);
-
- gl.glBegin(GL.GL_POINTS);
- for (int i = 0; i < r_newrefdef.num_particles; i++) {
- p = r_newrefdef.particles[i];
- color = d_8to24table[p.color];
-
- gl.glColor4ub(
- (byte) ((color >> 0) & 0xff),
- (byte) ((color >> 8) & 0xff),
- (byte) ((color >> 16) & 0xff),
- (byte) (p.alpha * 255));
-
- gl.glVertex3fv(p.origin);
- }
- gl.glEnd();
+
+ gl.glDrawArrays(GL.GL_POINTS, 0, r_newrefdef.num_particles);
+
+ gl.glDisableClientState(GL.GL_COLOR_ARRAY);
+ gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
gl.glDisable(GL.GL_BLEND);
gl.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@@ -581,7 +577,7 @@ public abstract class Main extends Base {
}
else {
- GL_DrawParticles(r_newrefdef.num_particles, r_newrefdef.particles);
+ GL_DrawParticles(r_newrefdef.num_particles);
}
}
@@ -608,7 +604,7 @@ public abstract class Main extends Base {
gl.glRotatef(-90, 1, 0, 0); // put Z going up
gl.glRotatef(90, 0, 0, 1); // put Z going up
- gl.glColor4fv(v_blend);
+ gl.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]);
gl.glBegin(GL.GL_QUADS);
@@ -958,7 +954,7 @@ public abstract class Main extends Base {
protected void R_Register() {
r_lefthand = ri.Cvar_Get("hand", "0", Globals.CVAR_USERINFO | Globals.CVAR_ARCHIVE);
r_norefresh = ri.Cvar_Get("r_norefresh", "0", 0);
- r_fullbright = ri.Cvar_Get("r_fullbright", "1", 0);
+ r_fullbright = ri.Cvar_Get("r_fullbright", "0", 0);
r_drawentities = ri.Cvar_Get("r_drawentities", "1", 0);
r_drawworld = ri.Cvar_Get("r_drawworld", "1", 0);
r_novis = ri.Cvar_Get("r_novis", "0", 0);
@@ -1007,7 +1003,7 @@ public abstract class Main extends Base {
gl_vertex_arrays = ri.Cvar_Get("gl_vertex_arrays", "0", Globals.CVAR_ARCHIVE);
gl_ext_swapinterval = ri.Cvar_Get("gl_ext_swapinterval", "1", Globals.CVAR_ARCHIVE);
- gl_ext_palettedtexture = ri.Cvar_Get("gl_ext_palettedtexture", "1", Globals.CVAR_ARCHIVE);
+ gl_ext_palettedtexture = ri.Cvar_Get("gl_ext_palettedtexture", "0", Globals.CVAR_ARCHIVE);
gl_ext_multitexture = ri.Cvar_Get("gl_ext_multitexture", "1", Globals.CVAR_ARCHIVE);
gl_ext_pointparameters = ri.Cvar_Get("gl_ext_pointparameters", "1", Globals.CVAR_ARCHIVE);
gl_ext_compiled_vertex_array = ri.Cvar_Get("gl_ext_compiled_vertex_array", "1", Globals.CVAR_ARCHIVE);
@@ -1056,11 +1052,11 @@ public abstract class Main extends Base {
int err; // enum rserr_t
boolean fullscreen;
- if (vid_fullscreen.modified && !gl_config.allow_cds) {
- ri.Con_Printf(Defines.PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n");
- ri.Cvar_SetValue("vid_fullscreen", (vid_fullscreen.value > 0.0f) ? 0.0f : 1.0f);
- vid_fullscreen.modified = false;
- }
+// if (vid_fullscreen.modified && !gl_config.allow_cds) {
+// ri.Con_Printf(Defines.PRINT_ALL, "R_SetMode() - CDS not allowed with this driver\n");
+// ri.Cvar_SetValue("vid_fullscreen", (vid_fullscreen.value > 0.0f) ? 0.0f : 1.0f);
+// vid_fullscreen.modified = false;
+// }
fullscreen = (vid_fullscreen.value > 0.0f);
@@ -1237,25 +1233,24 @@ public abstract class Main extends Base {
|| gl_config.extensions_string.indexOf("GL_SGI_compiled_vertex_array") >= 0) {
ri.Con_Printf(Defines.PRINT_ALL, "...enabling GL_EXT_compiled_vertex_array\n");
// qglLockArraysEXT = ( void * ) qwglGetProcAddress( "glLockArraysEXT" );
- qglLockArraysEXT = true;
+ if (gl_ext_compiled_vertex_array.value != 0.0f)
+ qglLockArraysEXT = true;
+ else
+ qglLockArraysEXT = false;
// qglUnlockArraysEXT = ( void * ) qwglGetProcAddress( "glUnlockArraysEXT" );
- qglUnlockArraysEXT = true;
+ //qglUnlockArraysEXT = true;
}
else {
ri.Con_Printf(Defines.PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n");
}
- // #ifdef _WIN32
- // if ( strstr( gl_config.extensions_string, "WGL_EXT_swap_control" ) )
- // {
- // qwglSwapIntervalEXT = ( BOOL (WINAPI *)(int)) qwglGetProcAddress( "wglSwapIntervalEXT" );
- // ri.Con_Printf( Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n" );
- // }
- // else
- // {
- // ri.Con_Printf( Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n" );
- // }
- // #endif
+ if (gl_config.extensions_string.indexOf("WGL_EXT_swap_control") >= 0) {
+ qwglSwapIntervalEXT = true;
+ ri.Con_Printf(Defines.PRINT_ALL, "...enabling WGL_EXT_swap_control\n");
+ } else {
+ qwglSwapIntervalEXT = false;
+ ri.Con_Printf(Defines.PRINT_ALL, "...WGL_EXT_swap_control not found\n");
+ }
if (gl_config.extensions_string.indexOf("GL_EXT_point_parameters") >= 0) {
if (gl_ext_pointparameters.value != 0.0f) {
@@ -1301,6 +1296,7 @@ public abstract class Main extends Base {
}
else {
ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n");
+ qglColorTableEXT = false;
}
}
else {
@@ -1317,34 +1313,40 @@ public abstract class Main extends Base {
qglMTexCoord2fSGIS = true;
GL_TEXTURE0 = GL.GL_TEXTURE0_ARB;
GL_TEXTURE1 = GL.GL_TEXTURE1_ARB;
+ Cvar.SetValue("r_fullbright", 1);
}
else {
ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_ARB_multitexture\n");
+ Cvar.SetValue("r_fullbright", 0);
}
}
else {
ri.Con_Printf(Defines.PRINT_ALL, "...GL_ARB_multitexture not found\n");
+ Cvar.SetValue("r_fullbright", 0);
}
if (gl_config.extensions_string.indexOf("GL_SGIS_multitexture") >= 0) {
if (qglActiveTextureARB) {
ri.Con_Printf(Defines.PRINT_ALL, "...GL_SGIS_multitexture deprecated in favor of ARB_multitexture\n");
- }
- else if (gl_ext_multitexture.value != 0.0f) {
+ Cvar.SetValue("r_fullbright", 1);
+ } else if (gl_ext_multitexture.value != 0.0f) {
ri.Con_Printf(Defines.PRINT_ALL, "...using GL_SGIS_multitexture\n");
// qglMTexCoord2fSGIS = ( void * ) qwglGetProcAddress( "glMTexCoord2fSGIS" );
// qglSelectTextureSGIS = ( void * ) qwglGetProcAddress( "glSelectTextureSGIS" );
qglSelectTextureSGIS = true;
qglMTexCoord2fSGIS = true;
+ Cvar.SetValue("r_fullbright", 1);
// //GL_TEXTURE0 = GL.GL_TEXTURE0_SGIS;
// //GL_TEXTURE1 = GL.GL_TEXTURE1_SGIS;
- }
- else {
+ } else {
ri.Con_Printf(Defines.PRINT_ALL, "...ignoring GL_SGIS_multitexture\n");
+ Cvar.SetValue("r_fullbright", 0);
}
}
else {
ri.Con_Printf(Defines.PRINT_ALL, "...GL_SGIS_multitexture not found\n");
+ if (!qglActiveTextureARB)
+ Cvar.SetValue("r_fullbright", 0);
}
GL_SetDefaultState();
@@ -1359,7 +1361,7 @@ public abstract class Main extends Base {
ri.Con_Printf(
Defines.PRINT_ALL,
"glGetError() = 0x%x\n\t%s\n",
- new Vargs(2).add(err).add(gl.glGetString(err)));
+ new Vargs(2).add(err).add("" + gl.glGetString(err)));
return true;
}
@@ -1406,7 +1408,7 @@ public abstract class Main extends Base {
// FIXME: only restart if CDS is required
cvar_t ref;
- ref = ri.Cvar_Get("vid_ref", "gl", 0);
+ ref = ri.Cvar_Get("vid_ref", "jogl", 0);
ref.modified = true;
}
@@ -1511,26 +1513,22 @@ public abstract class Main extends Base {
=============
*/
protected void R_SetPalette(byte[] palette) {
-
- //assert(palette != null && palette.length == 768) : "byte palette[768] bug";
- // es darf auch null sein
-
+ // 256 RGB values (768 bytes)
+ // or null
int i;
int color = 0;
if (palette != null) {
-
+ int j =0;
for (i = 0; i < 256; i++) {
- color = (palette[i * 3 + 0] << 0) & 0x000000FF;
- color |= (palette[i * 3 + 1] << 8) & 0x0000FF00;
- color |= (palette[i * 3 + 2] << 8) & 0x00FF0000;
+ color = (palette[j++] & 0xFF) << 0;
+ color |= (palette[j++] & 0xFF) << 8;
+ color |= (palette[j++] & 0xFF) << 16;
color |= 0xFF000000;
r_rawpalette[i] = color;
}
-
}
else {
-
for (i = 0; i < 256; i++) {
r_rawpalette[i] = d_8to24table[i] | 0xff000000;
}
@@ -1543,6 +1541,9 @@ public abstract class Main extends Base {
}
static final int NUM_BEAM_SEGS = 6;
+ float[][] start_points = new float[NUM_BEAM_SEGS][3];
+ // array of vec3_t
+ float[][] end_points = new float[NUM_BEAM_SEGS][3]; // array of vec3_t
/*
** R_DrawBeam
@@ -1556,10 +1557,6 @@ public abstract class Main extends Base {
float[] direction = { 0, 0, 0 }; // vec3_t
float[] normalized_direction = { 0, 0, 0 }; // vec3_t
- float[][] start_points = new float[NUM_BEAM_SEGS][3];
- // array of vec3_t
- float[][] end_points = new float[NUM_BEAM_SEGS][3]; // array of vec3_t
-
float[] oldorigin = { 0, 0, 0 }; // vec3_t
float[] origin = { 0, 0, 0 }; // vec3_t
@@ -1607,11 +1604,18 @@ public abstract class Main extends Base {
gl.glColor4f(r, g, b, e.alpha);
gl.glBegin(GL.GL_TRIANGLE_STRIP);
+
+ float[] v;
+
for (i = 0; i < NUM_BEAM_SEGS; i++) {
- gl.glVertex3fv(start_points[i]);
- gl.glVertex3fv(end_points[i]);
- gl.glVertex3fv(start_points[(i + 1) % NUM_BEAM_SEGS]);
- gl.glVertex3fv(end_points[(i + 1) % NUM_BEAM_SEGS]);
+ v = start_points[i];
+ gl.glVertex3f(v[0], v[1], v[2]);
+ v = end_points[i];
+ gl.glVertex3f(v[0], v[1], v[2]);
+ v = start_points[(i + 1) % NUM_BEAM_SEGS];
+ gl.glVertex3f(v[0], v[1], v[2]);
+ v = end_points[(i + 1) % NUM_BEAM_SEGS];
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd();
diff --git a/src/jake2/render/jogl/Mesh.java b/src/jake2/render/jogl/Mesh.java
index 37e4445..ac881ee 100644
--- a/src/jake2/render/jogl/Mesh.java
+++ b/src/jake2/render/jogl/Mesh.java
@@ -2,7 +2,7 @@
* Mesh.java
* Copyright (C) 2003
*
- * $Id: Mesh.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Mesh.java,v 1.3.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -104,36 +104,36 @@ public abstract class Mesh extends Light {
{
int i;
int lerpIndex = 0;
- lerp.position(0);
//PMM -- added RF_SHELL_DOUBLE, RF_SHELL_HALF_DAM
if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0 )
{
float[] normal;
+ int j = 0;
for (i=0 ; i < nverts; i++/* , v++, ov++, lerp+=4 */)
{
normal = r_avertexnormals[verts[i].lightnormalindex];
- lerp.put(move[0] + ov[i].v[0]*backv[0] + v[i].v[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
- lerp.put(move[1] + ov[i].v[1]*backv[1] + v[i].v[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
- lerp.put(move[2] + ov[i].v[2]*backv[2] + v[i].v[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
- lerp.get();
+ lerp.put(j++, move[0] + ov[i].v[0]*backv[0] + v[i].v[0]*frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
+ lerp.put(j++, move[1] + ov[i].v[1]*backv[1] + v[i].v[1]*frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
+ lerp.put(j++, move[2] + ov[i].v[2]*backv[2] + v[i].v[2]*frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
}
}
else
{
+ int j = 0;
for (i=0 ; i < nverts; i++ /* , v++, ov++, lerp+=4 */)
{
- lerp.put(move[0] + ov[i].v[0]*backv[0] + v[i].v[0]*frontv[0]);
- lerp.put(move[1] + ov[i].v[1]*backv[1] + v[i].v[1]*frontv[1]);
- lerp.put(move[2] + ov[i].v[2]*backv[2] + v[i].v[2]*frontv[2]);
- lerp.get();
+
+ lerp.put(j++, move[0] + ov[i].v[0]*backv[0] + v[i].v[0]*frontv[0]);
+ lerp.put(j++, move[1] + ov[i].v[1]*backv[1] + v[i].v[1]*frontv[1]);
+ lerp.put(j++, move[2] + ov[i].v[2]*backv[2] + v[i].v[2]*frontv[2]);
}
}
}
FloatBuffer colorArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 4);
- FloatBuffer vertexArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 4);
+ FloatBuffer vertexArrayBuf = BufferUtils.newFloatBuffer(qfiles.MAX_VERTS * 3);
boolean isFilled = false;
float[] tmpVec = {0, 0, 0};
@@ -218,7 +218,7 @@ public abstract class Mesh extends Light {
GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, vertexArrayBuf, move, frontv, backv );
gl.glEnableClientState( GL.GL_VERTEX_ARRAY );
- gl.glVertexPointer( 3, GL.GL_FLOAT, 16, vertexArrayBuf ); // padded for SIMD
+ gl.glVertexPointer( 3, GL.GL_FLOAT, 0, vertexArrayBuf );
// PMM - added double damage shell
if ( (currententity.flags & ( Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0)
@@ -233,11 +233,15 @@ public abstract class Mesh extends Light {
//
// pre light everything
//
- colorArrayBuf.position(0);
+ FloatBuffer color = colorArrayBuf;
+ int j = 0;
for ( i = 0; i < paliashdr.num_xyz; i++ )
{
l = shadedots[verts[i].lightnormalindex];
- colorArrayBuf.put(l * shadelight[0]).put(l * shadelight[1]).put(l * shadelight[2]).put(alpha);
+ color.put(j++, l * shadelight[0]);
+ color.put(j++, l * shadelight[1]);
+ color.put(j++, l * shadelight[2]);
+ color.put(j++, alpha);
}
}
@@ -294,13 +298,15 @@ public abstract class Mesh extends Light {
gl.glEnd ();
}
- if ( qglUnlockArraysEXT )
+ if ( qglLockArraysEXT )
gl.glUnlockArraysEXT();
}
else
{
GL_LerpVerts( paliashdr.num_xyz, v, ov, verts, s_lerped, move, frontv, backv );
+ float[] tmp;
+
while (true)
{
// get the vertex count and primitive type
@@ -325,7 +331,8 @@ public abstract class Mesh extends Light {
orderIndex += 3;
gl.glColor4f( shadelight[0], shadelight[1], shadelight[2], alpha);
- gl.glVertex3fv (s_lerped[index_xyz]);
+ tmp = s_lerped[index_xyz];
+ gl.glVertex3f(tmp[0], tmp[1], tmp[2]);
} while (--count != 0);
}
@@ -344,7 +351,8 @@ public abstract class Mesh extends Light {
l = shadedots[verts[index_xyz].lightnormalindex];
gl.glColor4f (l* shadelight[0], l*shadelight[1], l*shadelight[2], alpha);
- gl.glVertex3fv (s_lerped[index_xyz]);
+ tmp = s_lerped[index_xyz];
+ gl.glVertex3f(tmp[0], tmp[1], tmp[2]);
} while (--count != 0);
}
gl.glEnd ();
@@ -384,6 +392,7 @@ public abstract class Mesh extends Light {
height = -lheight + 1.0f;
int orderIndex = 0;
+ int index = 0;
while (true)
{
@@ -410,18 +419,20 @@ public abstract class Mesh extends Light {
if ( gl_vertex_arrays.value != 0.0f )
{
- vertexArrayBuf.position(order[orderIndex + 2] * 4);
- vertexArrayBuf.get(point);
+ index = order[orderIndex + 2] * 3;
+ point[0] = vertexArrayBuf.get(index);
+ point[1] = vertexArrayBuf.get(index + 1);
+ point[2] = vertexArrayBuf.get(index + 2);
}
else
{
- System.arraycopy(s_lerped[order[orderIndex + 2]], 0, point, 0, 3);
+ Math3D.VectorCopy(s_lerped[order[orderIndex + 2]], point);
}
point[0] -= shadevector[0]*(point[2]+lheight);
point[1] -= shadevector[1]*(point[2]+lheight);
point[2] = height;
- gl.glVertex3fv (point);
+ gl.glVertex3f(point[0], point[1], point[2]);
orderIndex += 3;
diff --git a/src/jake2/render/jogl/Misc.java b/src/jake2/render/jogl/Misc.java
index 8f04a84..8197fdd 100644
--- a/src/jake2/render/jogl/Misc.java
+++ b/src/jake2/render/jogl/Misc.java
@@ -2,7 +2,7 @@
* Misc.java
* Copyright (C) 2003
*
- * $Id: Misc.java,v 1.1 2004-07-07 19:59:41 hzi Exp $
+ * $Id: Misc.java,v 1.1.1.1.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.render.jogl;
-import net.java.games.jogl.GL;
-
import jake2.Defines;
+import net.java.games.jogl.GL;
+import net.java.games.jogl.WGL;
/**
* Misc
@@ -249,13 +249,11 @@ public abstract class Misc extends Mesh {
if ( gl_swapinterval.modified )
{
gl_swapinterval.modified = false;
-
if ( !gl_state.stereo_enabled )
{
-// #ifdef _WIN32
-// if ( qwglSwapIntervalEXT )
-// qwglSwapIntervalEXT( gl_swapinterval->value );
-// #endif
+ if (qwglSwapIntervalEXT) {
+ ((WGL)gl).wglSwapIntervalEXT((int)gl_swapinterval.value);
+ }
}
}
}
diff --git a/src/jake2/render/jogl/Surf.java b/src/jake2/render/jogl/Surf.java
index 926d431..79caefa 100644
--- a/src/jake2/render/jogl/Surf.java
+++ b/src/jake2/render/jogl/Surf.java
@@ -2,7 +2,7 @@
* Surf.java
* Copyright (C) 2003
*
- * $Id: Surf.java,v 1.2.2.1 2004-07-09 08:09:07 hzi Exp $
+ * $Id: Surf.java,v 1.2.2.2 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,34 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.render.jogl;
-import java.awt.geom.AffineTransform;
-import java.awt.image.AffineTransformOp;
-import java.awt.image.BufferedImage;
-import java.nio.ByteBuffer;
+import jake2.Defines;
+import jake2.client.*;
+import jake2.game.cplane_t;
+import jake2.render.*;
+import jake2.util.Lib;
+import jake2.util.Math3D;
+
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
import net.java.games.jogl.GL;
-import net.java.games.jogl.util.BufferUtils;
-
-import jake2.Defines;
-import jake2.client.dlight_t;
-import jake2.client.entity_t;
-import jake2.client.lightstyle_t;
-import jake2.game.cplane_t;
-import jake2.render.glpoly_t;
-import jake2.render.image_t;
-import jake2.render.medge_t;
-import jake2.render.mleaf_t;
-import jake2.render.mnode_t;
-import jake2.render.model_t;
-import jake2.render.msurface_t;
-import jake2.render.mtexinfo_t;
-import jake2.util.Lib;
-import jake2.util.Math3D;
/**
* Surf
@@ -91,7 +75,7 @@ public abstract class Surf extends Draw {
// the lightmap texture data needs to be kept in
// main memory so texsubimage can update properly
- byte[] lightmap_buffer = new byte[4 * BLOCK_WIDTH * BLOCK_HEIGHT];
+ IntBuffer lightmap_buffer = Lib.newIntBuffer(BLOCK_WIDTH * BLOCK_HEIGHT, ByteOrder.LITTLE_ENDIAN);
public gllightmapstate_t() {
@@ -128,7 +112,7 @@ public abstract class Surf extends Draw {
// Light.java
abstract void R_MarkLights (dlight_t light, int bit, mnode_t node);
abstract void R_SetCacheState( msurface_t surf );
- abstract void R_BuildLightMap(msurface_t surf, ByteBuffer dest, int stride);
+ abstract void R_BuildLightMap(msurface_t surf, IntBuffer dest, int stride);
/*
=============================================================
@@ -177,7 +161,7 @@ public abstract class Surf extends Draw {
{
v = p.verts[i];
gl.glTexCoord2f(v[3], v[4]);
- gl.glVertex3fv(v);
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd();
}
@@ -207,7 +191,7 @@ public abstract class Surf extends Draw {
{
v = p.verts[i];
gl.glTexCoord2f ((v[3] + scroll), v[4]);
- gl.glVertex3fv( v );
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd ();
}
@@ -272,7 +256,7 @@ public abstract class Surf extends Draw {
{
v = p.verts[j];
gl.glTexCoord2f (v[5], v[6] );
- gl.glVertex3fv( v );
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd();
}
@@ -289,7 +273,7 @@ public abstract class Surf extends Draw {
{
v = p.verts[j];
gl.glTexCoord2f (v[5] - soffset, v[6] - toffset );
- gl.glVertex3fv( v );
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd();
}
@@ -398,7 +382,7 @@ public abstract class Surf extends Draw {
for ( surf = gl_lms.lightmap_surfaces[0]; surf != null; surf = surf.lightmapchain )
{
int smax, tmax;
- ByteBuffer base;
+ IntBuffer base;
smax = (surf.extents[0]>>4)+1;
tmax = (surf.extents[1]>>4)+1;
@@ -411,10 +395,10 @@ public abstract class Surf extends Draw {
surf.dlight_s = lightPos.x;
surf.dlight_t = lightPos.y;
- base = ByteBuffer.wrap(gl_lms.lightmap_buffer);
- base.position( ( surf.dlight_t * BLOCK_WIDTH + surf.dlight_s ) * LIGHTMAP_BYTES);
+ base = gl_lms.lightmap_buffer;
+ base.position(surf.dlight_t * BLOCK_WIDTH + surf.dlight_s );
- R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
+ R_BuildLightMap (surf, base.slice(), BLOCK_WIDTH);
}
else
{
@@ -447,10 +431,10 @@ public abstract class Surf extends Draw {
surf.dlight_s = lightPos.x;
surf.dlight_t = lightPos.y;
- base = ByteBuffer.wrap(gl_lms.lightmap_buffer);
- base.position( ( surf.dlight_t * BLOCK_WIDTH + surf.dlight_s ) * LIGHTMAP_BYTES);
+ base = gl_lms.lightmap_buffer;
+ base.position(surf.dlight_t * BLOCK_WIDTH + surf.dlight_s );
- R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
+ R_BuildLightMap (surf, base.slice(), BLOCK_WIDTH);
}
}
@@ -475,7 +459,7 @@ public abstract class Surf extends Draw {
gl.glDepthMask( true );
}
- private ByteBuffer temp2 = BufferUtils.newByteBuffer(34 * 34 * 4);
+ private IntBuffer temp2 = Lib.newIntBuffer(34 * 34, ByteOrder.LITTLE_ENDIAN);
/*
================
@@ -561,7 +545,7 @@ public abstract class Surf extends Draw {
smax = (fa.extents[0]>>4)+1;
tmax = (fa.extents[1]>>4)+1;
- R_BuildLightMap( fa, temp2, smax*4 );
+ R_BuildLightMap( fa, temp2, smax);
R_SetCacheState( fa );
GL_Bind( gl_state.lightmap_textures + fa.lightmaptexturenum );
@@ -716,7 +700,7 @@ public abstract class Surf extends Draw {
}
// direct buffer
- ByteBuffer temp = BufferUtils.newByteBuffer(128 * 128 * 4);
+ private IntBuffer temp = Lib.newIntBuffer(128 * 128, ByteOrder.LITTLE_ENDIAN);
void GL_RenderLightmappedPoly( msurface_t surf )
{
@@ -765,7 +749,7 @@ public abstract class Surf extends Draw {
smax = (surf.extents[0]>>4)+1;
tmax = (surf.extents[1]>>4)+1;
- R_BuildLightMap( surf, temp, smax*4 );
+ R_BuildLightMap( surf, temp, smax);
R_SetCacheState( surf );
GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum );
@@ -784,7 +768,7 @@ public abstract class Surf extends Draw {
smax = (surf.extents[0]>>4)+1;
tmax = (surf.extents[1]>>4)+1;
- R_BuildLightMap( surf, temp, smax*4 );
+ R_BuildLightMap( surf, temp, smax);
GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + 0 );
@@ -824,7 +808,7 @@ public abstract class Surf extends Draw {
gl.glMultiTexCoord2fARB(GL_TEXTURE1, v[5], v[6]);
//gglMTexCoord2fSGIS( GL_TEXTURE0, v[3], v[4]);
//gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]);
- gl.glVertex3fv(v);
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd ();
}
@@ -842,7 +826,7 @@ public abstract class Surf extends Draw {
gl.glMultiTexCoord2fARB(GL_TEXTURE1, v[5], v[6]);
//gglMTexCoord2fSGIS( GL_TEXTURE0, v[3], v[4]);
//gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]);
- gl.glVertex3fv(v);
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd ();
}
@@ -878,7 +862,7 @@ public abstract class Surf extends Draw {
gl.glMultiTexCoord2fARB(GL_TEXTURE1, v[5], v[6]);
// qglMTexCoord2fSGIS( GL_TEXTURE0, (v[3]+scroll), v[4]);
// qglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]);
- gl.glVertex3fv(v);
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd();
}
@@ -898,7 +882,7 @@ public abstract class Surf extends Draw {
gl.glMultiTexCoord2fARB(GL_TEXTURE1, v[5], v[6]);
//gglMTexCoord2fSGIS( GL_TEXTURE0, v[3], v[4]);
//gglMTexCoord2fSGIS( GL_TEXTURE1, v[5], v[6]);
- gl.glVertex3fv(v);
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd ();
}
@@ -1557,7 +1541,7 @@ public abstract class Surf extends Draw {
void GL_CreateSurfaceLightmap(msurface_t surf)
{
int smax, tmax;
- ByteBuffer base;
+ IntBuffer base;
if ( (surf.flags & (Defines.SURF_DRAWSKY | Defines.SURF_DRAWTURB)) != 0)
return;
@@ -1584,13 +1568,12 @@ public abstract class Surf extends Draw {
surf.lightmaptexturenum = gl_lms.current_lightmap_texture;
- // base = gl_lms.lightmap_buffer;
- base = ByteBuffer.wrap(gl_lms.lightmap_buffer);
- int basep = (surf.light_t * BLOCK_WIDTH + surf.light_s) * LIGHTMAP_BYTES;
+ int basep = (surf.light_t * BLOCK_WIDTH + surf.light_s);// * LIGHTMAP_BYTES;
+ base = gl_lms.lightmap_buffer;
base.position(basep);
R_SetCacheState( surf );
- R_BuildLightMap(surf, base.slice(), BLOCK_WIDTH * LIGHTMAP_BYTES);
+ R_BuildLightMap(surf, base.slice(), BLOCK_WIDTH);
}
lightstyle_t[] lightstyles;
diff --git a/src/jake2/render/jogl/Warp.java b/src/jake2/render/jogl/Warp.java
index 8ccb93a..d48358a 100644
--- a/src/jake2/render/jogl/Warp.java
+++ b/src/jake2/render/jogl/Warp.java
@@ -2,7 +2,7 @@
* Warp.java
* Copyright (C) 2003
*
- * $Id: Warp.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Warp.java,v 1.3.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -313,7 +313,7 @@ public abstract class Warp extends Model {
t *= (1.0f/64);
gl.glTexCoord2f (s, t);
- gl.glVertex3fv( v );
+ gl.glVertex3f(v[0], v[1], v[2]);
}
gl.glEnd ();
}
@@ -612,7 +612,7 @@ public abstract class Warp extends Model {
t = 1.0f - t;
gl.glTexCoord2f (s, t);
- gl.glVertex3fv( v );
+ gl.glVertex3f(v[0], v[1], v[2]);
}
/*
diff --git a/src/jake2/render/model_t.java b/src/jake2/render/model_t.java
index 5807568..541d3bd 100644
--- a/src/jake2/render/model_t.java
+++ b/src/jake2/render/model_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 20.11.2003 by RST.
-// $Id: model_t.java,v 1.2 2004-07-08 15:58:48 hzi Exp $
+// $Id: model_t.java,v 1.2.2.1 2004-07-09 08:38:23 hzi Exp $
package jake2.render;
@@ -119,7 +119,7 @@ public class model_t implements Cloneable {
//
Math3D.VectorClear(mins);
Math3D.VectorClear(maxs);
- radius = 0;;
+ radius = 0;
//
// solid volume for clipping
diff --git a/src/jake2/render/msurface_t.java b/src/jake2/render/msurface_t.java
index c6247d9..798ca74 100644
--- a/src/jake2/render/msurface_t.java
+++ b/src/jake2/render/msurface_t.java
@@ -19,11 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 20.11.2003 by RST.
-// $Id: msurface_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+// $Id: msurface_t.java,v 1.2.2.1 2004-07-09 08:38:23 hzi Exp $
package jake2.render;
import java.nio.ByteBuffer;
+import java.util.Arrays;
import jake2.game.*;
import jake2.qcommon.texinfo_t;
@@ -67,23 +68,25 @@ public class msurface_t
public void clear() {
visframe = 0;
- //plane = null;
+ plane = null;
+ plane = new cplane_t();
flags = 0;
firstedge = 0;
numedges = 0;
- texturemins[0] = texturemins[1] = 0;
+ texturemins[0] = texturemins[1] = -1;
extents[0] = extents[1] = 0;
light_s = light_t = 0;
dlight_s = dlight_t = 0;
- //polys = null;
+ polys = null;
texturechain = null;
lightmapchain = null;
- //texinfo = null;
+ //texinfo = new mtexinfo_t();
+ texinfo.clear();
dlightframe = 0;
dlightbits = 0;
@@ -98,6 +101,6 @@ public class msurface_t
{
cached_light[i] = 0;
}
- //samples = null;
+ if (samples != null) samples.clear();
}
}
diff --git a/src/jake2/render/mtexinfo_t.java b/src/jake2/render/mtexinfo_t.java
index a78af9f..551f7da 100644
--- a/src/jake2/render/mtexinfo_t.java
+++ b/src/jake2/render/mtexinfo_t.java
@@ -19,10 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 20.11.2003 by RST.
-// $Id: mtexinfo_t.java,v 1.1 2004-07-07 19:59:35 hzi Exp $
+// $Id: mtexinfo_t.java,v 1.1.1.1.2.1 2004-07-09 08:38:23 hzi Exp $
package jake2.render;
+import java.util.Arrays;
+
public class mtexinfo_t {
// [s/t][xyz offset]
public float vecs[][] = {
@@ -33,4 +35,15 @@ public class mtexinfo_t {
public int numframes;
public mtexinfo_t next; // animation chain
public image_t image;
+
+ public void clear() {
+ Arrays.fill(vecs[0], 0);
+ Arrays.fill(vecs[1], 0);
+
+ flags = 0;
+ numframes = 0;
+ next = null;
+ image = null;
+ }
+
}
diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java
index 6c71224..f9cbe2c 100644
--- a/src/jake2/server/SV_CCMDS.java
+++ b/src/jake2/server/SV_CCMDS.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 18.01.2004 by RST.
-// $Id: SV_CCMDS.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
+// $Id: SV_CCMDS.java,v 1.2.2.1 2004-07-09 08:38:25 hzi Exp $
package jake2.server;
@@ -228,7 +228,6 @@ public class SV_CCMDS extends SV_ENTS {
f1.close();
}
catch (IOException e1) {
- // TODO Auto-generated catch block
e1.printStackTrace();
}
return;
@@ -627,7 +626,7 @@ public class SV_CCMDS extends SV_ENTS {
// copy off the level to the autosave slot
if (0 == dedicated.value) {
- //TODO: SV_WriteServerFile!
+ //TODO: SV_WriteServerFile.
//SV_WriteServerFile(true);
//SV_CopySaveGame("current", "save0");
@@ -658,7 +657,7 @@ public class SV_CCMDS extends SV_ENTS {
}
sv.state = ss_dead; // don't save current level when changing
- //TODO: RST: disabled for debugging
+ //TODO: savegame
//SV_WipeSavegame("current");
SV_GameMap_f();
}
diff --git a/src/jake2/server/SV_GAME.java b/src/jake2/server/SV_GAME.java
index 8f6eec4..8a6e0ac 100644
--- a/src/jake2/server/SV_GAME.java
+++ b/src/jake2/server/SV_GAME.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 14.01.2004 by RST.
-// $Id: SV_GAME.java,v 1.4 2004-07-08 20:56:54 hzi Exp $
+// $Id: SV_GAME.java,v 1.4.2.1 2004-07-09 08:38:25 hzi Exp $
package jake2.server;
@@ -308,11 +308,11 @@ public class SV_GAME extends SV_INIT {
}
public static void PF_StartSound(edict_t entity, int channel, int sound_num, float volume, float attenuation, float timeofs) {
+
if (null == entity)
return;
-
- //TODO: impl SV_StartSound
SV_SEND.SV_StartSound (null, entity, channel, sound_num, volume, attenuation, timeofs);
+
}
//==============================================
diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java
index b4b4ee6..533fe8b 100644
--- a/src/jake2/server/SV_INIT.java
+++ b/src/jake2/server/SV_INIT.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 14.01.2004 by RST.
-// $Id: SV_INIT.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+// $Id: SV_INIT.java,v 1.3.2.1 2004-07-09 08:38:24 hzi Exp $
package jake2.server;
@@ -250,16 +250,16 @@ public class SV_INIT extends Globals {
sv.name=server;
sv.configstrings[CS_NAME] = server;
- CM.intwrap checksum_iw = new CM.intwrap(checksum);
+ int iw[] = {checksum};
if (serverstate != ss_game) {
- sv.models[1] = CM.CM_LoadMap("", false, checksum_iw); // no real map
+ sv.models[1] = CM.CM_LoadMap("", false, iw); // no real map
}
else {
- sv.configstrings[CS_MODELS + 1] = "maps/" + server + ".bsp";
- sv.models[1] = CM.CM_LoadMap(sv.configstrings[CS_MODELS + 1], false, checksum_iw);
+ sv.configstrings[CS_MODELS + 1] = "maps/" + server + ".bsp";
+ sv.models[1] = CM.CM_LoadMap(sv.configstrings[CS_MODELS + 1], false, iw);
}
- checksum = checksum_iw.i;
+ checksum = iw[0];
sv.configstrings[CS_MAPCHECKSUM] = "" + checksum;
//
@@ -302,7 +302,7 @@ public class SV_INIT extends Globals {
// set serverinfo variable
Cvar.FullSet("mapname", sv.name, CVAR_SERVERINFO | CVAR_NOSET);
- Com.Printf("-------------------------------------\n");
+ //Com.Printf("-------------------------------------\n");
}
/*
diff --git a/src/jake2/server/SV_MAIN.java b/src/jake2/server/SV_MAIN.java
index 464b056..15d190e 100644
--- a/src/jake2/server/SV_MAIN.java
+++ b/src/jake2/server/SV_MAIN.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 13.01.2004 by RST.
-// $Id: SV_MAIN.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
+// $Id: SV_MAIN.java,v 1.2.2.1 2004-07-09 08:38:25 hzi Exp $
package jake2.server;
@@ -476,7 +476,7 @@ public class SV_MAIN extends SV_GAME {
Cmd.TokenizeString(s.toCharArray(), false);
c = Cmd.Argv(0);
- Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c + "\n");
+ //Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c + "\n");
//Com.Printf(Lib.hexDump(net_message.data, 64, false) + "\n");
if (0 == strcmp(c, "ping"))
diff --git a/src/jake2/server/SV_USER.java b/src/jake2/server/SV_USER.java
index c6e355e..d05c2fb 100644
--- a/src/jake2/server/SV_USER.java
+++ b/src/jake2/server/SV_USER.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_USER.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+// $Id: SV_USER.java,v 1.3.2.1 2004-07-09 08:38:25 hzi Exp $
package jake2.server;
@@ -29,7 +29,8 @@ import jake2.util.Lib;
import java.io.IOException;
-public class SV_USER extends SV_SEND {
+public class SV_USER extends SV_SEND
+{
static edict_t sv_player;
@@ -47,14 +48,17 @@ public class SV_USER extends SV_SEND {
SV_BeginDemoServer
==================
*/
- public static void SV_BeginDemoserver() {
+ public static void SV_BeginDemoserver()
+ {
String name;
- name = "demos/" + sv.name;
- try {
- sv.demofile = FS.FOpenFile(name);
+ name= "demos/" + sv.name;
+ try
+ {
+ sv.demofile= FS.FOpenFile(name);
}
- catch (IOException e) {
+ catch (IOException e)
+ {
Com.Error(ERR_DROP, "Couldn't open " + name + "\n");
}
if (sv.demofile == null)
@@ -69,20 +73,23 @@ public class SV_USER extends SV_SEND {
This will be sent on the initial connection and upon each server load.
================
*/
- public static void SV_New_f() {
+ public static void SV_New_f()
+ {
String gamedir;
int playernum;
edict_t ent;
Com.DPrintf("New() from " + sv_client.name + "\n");
- if (sv_client.state != cs_connected) {
+ if (sv_client.state != cs_connected)
+ {
Com.Printf("New not valid -- already spawned\n");
return;
}
// demo servers just dump the file message
- if (sv.state == ss_demo) {
+ if (sv.state == ss_demo)
+ {
SV_BeginDemoserver();
return;
}
@@ -91,7 +98,7 @@ public class SV_USER extends SV_SEND {
// serverdata needs to go over for all types of servers
// to make sure the protocol is right, and to set the gamedir
//
- gamedir = Cvar.VariableString("gamedir");
+ gamedir= Cvar.VariableString("gamedir");
// send the serverdata
MSG.WriteByte(sv_client.netchan.message, svc_serverdata);
@@ -101,10 +108,10 @@ public class SV_USER extends SV_SEND {
MSG.WriteString(sv_client.netchan.message, gamedir);
if (sv.state == ss_cinematic || sv.state == ss_pic)
- playernum = -1;
+ playernum= -1;
else
//playernum = sv_client - svs.clients;
- playernum = sv_client.serverindex;
+ playernum= sv_client.serverindex;
MSG.WriteShort(sv_client.netchan.message, playernum);
@@ -114,12 +121,13 @@ public class SV_USER extends SV_SEND {
//
// game server
//
- if (sv.state == ss_game) {
+ if (sv.state == ss_game)
+ {
// set up the entity for the client
- ent = SV_GAME.ge.edicts[playernum + 1];
- ent.s.number = playernum + 1;
- sv_client.edict = ent;
- sv_client.lastcmd = new usercmd_t();
+ ent= SV_GAME.ge.edicts[playernum + 1];
+ ent.s.number= playernum + 1;
+ sv_client.edict= ent;
+ sv_client.lastcmd= new usercmd_t();
// begin fetching configstrings
MSG.WriteByte(sv_client.netchan.message, svc_stufftext);
@@ -133,29 +141,34 @@ public class SV_USER extends SV_SEND {
SV_Configstrings_f
==================
*/
- public static void SV_Configstrings_f() {
+ public static void SV_Configstrings_f()
+ {
int start;
Com.DPrintf("Configstrings() from " + sv_client.name + "\n");
- if (sv_client.state != cs_connected) {
+ if (sv_client.state != cs_connected)
+ {
Com.Printf("configstrings not valid -- already spawned\n");
return;
}
// handle the case of a level changing while a client was connecting
- if (atoi(Cmd.Argv(1)) != svs.spawncount) {
+ if (atoi(Cmd.Argv(1)) != svs.spawncount)
+ {
Com.Printf("SV_Configstrings_f from different level\n");
SV_New_f();
return;
}
- start = atoi(Cmd.Argv(2));
+ start= atoi(Cmd.Argv(2));
// write a packet full of data
- while (sv_client.netchan.message.cursize < MAX_MSGLEN / 2 && start < MAX_CONFIGSTRINGS) {
- if (sv.configstrings[start] != null && sv.configstrings[start].length() != 0) {
+ while (sv_client.netchan.message.cursize < MAX_MSGLEN / 2 && start < MAX_CONFIGSTRINGS)
+ {
+ if (sv.configstrings[start] != null && sv.configstrings[start].length() != 0)
+ {
MSG.WriteByte(sv_client.netchan.message, svc_configstring);
MSG.WriteShort(sv_client.netchan.message, start);
MSG.WriteString(sv_client.netchan.message, sv.configstrings[start]);
@@ -165,11 +178,13 @@ public class SV_USER extends SV_SEND {
// send next command
- if (start == MAX_CONFIGSTRINGS) {
+ if (start == MAX_CONFIGSTRINGS)
+ {
MSG.WriteByte(sv_client.netchan.message, svc_stufftext);
MSG.WriteString(sv_client.netchan.message, "cmd baselines " + svs.spawncount + " 0\n");
}
- else {
+ else
+ {
MSG.WriteByte(sv_client.netchan.message, svc_stufftext);
MSG.WriteString(sv_client.netchan.message, "cmd configstrings " + svs.spawncount + " " + start + "\n");
}
@@ -180,35 +195,40 @@ public class SV_USER extends SV_SEND {
SV_Baselines_f
==================
*/
- public static void SV_Baselines_f() {
+ public static void SV_Baselines_f()
+ {
int start;
entity_state_t nullstate;
entity_state_t base;
Com.DPrintf("Baselines() from " + sv_client.name + "\n");
- if (sv_client.state != cs_connected) {
+ if (sv_client.state != cs_connected)
+ {
Com.Printf("baselines not valid -- already spawned\n");
return;
}
// handle the case of a level changing while a client was connecting
- if (atoi(Cmd.Argv(1)) != svs.spawncount) {
+ if (atoi(Cmd.Argv(1)) != svs.spawncount)
+ {
Com.Printf("SV_Baselines_f from different level\n");
SV_New_f();
return;
}
- start = atoi(Cmd.Argv(2));
+ start= atoi(Cmd.Argv(2));
//memset (&nullstate, 0, sizeof(nullstate));
- nullstate = new entity_state_t(null);
+ nullstate= new entity_state_t(null);
// write a packet full of data
- while (sv_client.netchan.message.cursize < MAX_MSGLEN / 2 && start < MAX_EDICTS) {
- base = sv.baselines[start];
- if (base.modelindex != 0 || base.sound != 0 || base.effects != 0) {
+ while (sv_client.netchan.message.cursize < MAX_MSGLEN / 2 && start < MAX_EDICTS)
+ {
+ base= sv.baselines[start];
+ if (base.modelindex != 0 || base.sound != 0 || base.effects != 0)
+ {
MSG.WriteByte(sv_client.netchan.message, svc_spawnbaseline);
MSG.WriteDeltaEntity(nullstate, base, sv_client.netchan.message, true, true);
}
@@ -217,11 +237,13 @@ public class SV_USER extends SV_SEND {
// send next command
- if (start == MAX_EDICTS) {
+ if (start == MAX_EDICTS)
+ {
MSG.WriteByte(sv_client.netchan.message, svc_stufftext);
MSG.WriteString(sv_client.netchan.message, "precache " + svs.spawncount + "\n");
}
- else {
+ else
+ {
MSG.WriteByte(sv_client.netchan.message, svc_stufftext);
MSG.WriteString(sv_client.netchan.message, "cmd baselines " + svs.spawncount + " " + start + "\n");
}
@@ -232,17 +254,19 @@ public class SV_USER extends SV_SEND {
SV_Begin_f
==================
*/
- public static void SV_Begin_f() {
+ public static void SV_Begin_f()
+ {
Com.DPrintf("Begin() from " + sv_client.name + "\n");
// handle the case of a level changing while a client was connecting
- if (atoi(Cmd.Argv(1)) != svs.spawncount) {
+ if (atoi(Cmd.Argv(1)) != svs.spawncount)
+ {
Com.Printf("SV_Begin_f from different level\n");
SV_New_f();
return;
}
- sv_client.state = cs_spawned;
+ sv_client.state= cs_spawned;
// call the game begin function
SV_GAME.ge.ClientBegin(sv_player);
@@ -257,7 +281,8 @@ public class SV_USER extends SV_SEND {
SV_NextDownload_f
==================
*/
- public static void SV_NextDownload_f() {
+ public static void SV_NextDownload_f()
+ {
int r;
int percent;
int size;
@@ -265,18 +290,18 @@ public class SV_USER extends SV_SEND {
if (sv_client.download == null)
return;
- r = sv_client.downloadsize - sv_client.downloadcount;
+ r= sv_client.downloadsize - sv_client.downloadcount;
if (r > 1024)
- r = 1024;
+ r= 1024;
MSG.WriteByte(sv_client.netchan.message, svc_download);
MSG.WriteShort(sv_client.netchan.message, r);
sv_client.downloadcount += r;
- size = sv_client.downloadsize;
+ size= sv_client.downloadsize;
if (size == 0)
- size = 1;
- percent = sv_client.downloadcount * 100 / size;
+ size= 1;
+ percent= sv_client.downloadcount * 100 / size;
MSG.WriteByte(sv_client.netchan.message, percent);
SZ.Write(sv_client.netchan.message, sv_client.download, sv_client.downloadcount - r, r);
@@ -284,7 +309,7 @@ public class SV_USER extends SV_SEND {
return;
FS.FreeFile(sv_client.download);
- sv_client.download = null;
+ sv_client.download= null;
}
/*
@@ -292,14 +317,15 @@ public class SV_USER extends SV_SEND {
SV_BeginDownload_f
==================
*/
- public static void SV_BeginDownload_f() {
+ public static void SV_BeginDownload_f()
+ {
String name;
- int offset = 0;
+ int offset= 0;
- name = Cmd.Argv(1);
+ name= Cmd.Argv(1);
if (Cmd.Argc() > 2)
- offset = atoi(Cmd.Argv(2)); // downloaded offset
+ offset= atoi(Cmd.Argv(2)); // downloaded offset
// hacked by zoid to allow more conrol over download
// first off, no .. or global allow check
@@ -310,9 +336,11 @@ public class SV_USER extends SV_SEND {
|| name.charAt(0) == '/' // next up, skin check
|| (name.startsWith("players/") && 0 == allow_download_players.value) // now models
|| (name.startsWith("models/") && 0 == allow_download_models.value) // now sounds
- || (name.startsWith("sound/") && 0 == allow_download_sounds.value) // now maps (note special case for maps, must not be in pak)
+ || (name.startsWith("sound/")
+ && 0 == allow_download_sounds.value) // now maps (note special case for maps, must not be in pak)
|| (name.startsWith("maps/") && 0 == allow_download_maps.value) // MUST be in a subdirectory
- || name.indexOf('/') == -1) { // don't allow anything with .. path
+ || name.indexOf('/') == -1)
+ { // don't allow anything with .. path
MSG.WriteByte(sv_client.netchan.message, svc_download);
MSG.WriteShort(sv_client.netchan.message, -1);
MSG.WriteByte(sv_client.netchan.message, 0);
@@ -322,20 +350,22 @@ public class SV_USER extends SV_SEND {
if (sv_client.download != null)
FS.FreeFile(sv_client.download);
- sv_client.download = FS.LoadFile(name);
- sv_client.downloadsize = sv_client.download.length;
- sv_client.downloadcount = offset;
+ sv_client.download= FS.LoadFile(name);
+ sv_client.downloadsize= sv_client.download.length;
+ sv_client.downloadcount= offset;
if (offset > sv_client.downloadsize)
- sv_client.downloadcount = sv_client.downloadsize;
+ sv_client.downloadcount= sv_client.downloadsize;
if (sv_client.download == null // special check for maps, if it came from a pak file, don't allow
// download ZOID
- || (name.startsWith("maps/") && FS.file_from_pak != 0)) {
+ || (name.startsWith("maps/") && FS.file_from_pak != 0))
+ {
Com.DPrintf("Couldn't download " + name + " to " + sv_client.name + "\n");
- if (sv_client.download != null) {
+ if (sv_client.download != null)
+ {
FS.FreeFile(sv_client.download);
- sv_client.download = null;
+ sv_client.download= null;
}
MSG.WriteByte(sv_client.netchan.message, svc_download);
@@ -357,7 +387,8 @@ public class SV_USER extends SV_SEND {
The client is going to disconnect, so remove the connection immediately
=================
*/
- public static void SV_Disconnect_f() {
+ public static void SV_Disconnect_f()
+ {
// SV_EndRedirect ();
SV_DropClient(sv_client);
}
@@ -369,11 +400,13 @@ public class SV_USER extends SV_SEND {
Dumps the serverinfo info string
==================
*/
- public static void SV_ShowServerinfo_f() {
+ public static void SV_ShowServerinfo_f()
+ {
Info.Print(Cvar.Serverinfo());
}
- public static void SV_Nextserver() {
+ public static void SV_Nextserver()
+ {
String v;
//ZOID, ss_pic can be nextserver'd in coop mode
@@ -381,11 +414,12 @@ public class SV_USER extends SV_SEND {
return; // can't nextserver while playing a normal game
svs.spawncount++; // make sure another doesn't sneak in
- v = Cvar.VariableString("nextserver");
+ v= Cvar.VariableString("nextserver");
//if (!v[0])
if (v.length() == 0)
Cbuf.AddText("killserver\n");
- else {
+ else
+ {
Cbuf.AddText(v);
Cbuf.AddText("\n");
}
@@ -400,8 +434,10 @@ public class SV_USER extends SV_SEND {
to the next server,
==================
*/
- public static void SV_Nextserver_f() {
- if (Lib.atoi(Cmd.Argv(1)) != svs.spawncount) {
+ public static void SV_Nextserver_f()
+ {
+ if (Lib.atoi(Cmd.Argv(1)) != svs.spawncount)
+ {
Com.DPrintf("Nextserver() from wrong level, from " + sv_client.name + "\n");
return; // leftover from last server
}
@@ -411,58 +447,80 @@ public class SV_USER extends SV_SEND {
SV_Nextserver();
}
- public static class ucmd_t {
- public ucmd_t(String n, Runnable r) {
- name = n;
- this.r = r;
+ public static class ucmd_t
+ {
+ public ucmd_t(String n, Runnable r)
+ {
+ name= n;
+ this.r= r;
}
String name;
Runnable r;
}
- static ucmd_t u1 = new ucmd_t("new", new Runnable() {
- public void run() {
+ static ucmd_t u1= new ucmd_t("new", new Runnable()
+ {
+ public void run()
+ {
SV_New_f();
}
});
- static ucmd_t ucmds[] = {
+ static ucmd_t ucmds[]= {
// auto issued
- new ucmd_t("new", new Runnable() { public void run() { SV_New_f();
+ new ucmd_t("new", new Runnable()
+ { public void run()
+ { SV_New_f();
}
- }), new ucmd_t("configstrings", new Runnable() {
- public void run() {
+ }), new ucmd_t("configstrings", new Runnable()
+ {
+ public void run()
+ {
SV_Configstrings_f();
}
- }), new ucmd_t("baselines", new Runnable() {
- public void run() {
+ }), new ucmd_t("baselines", new Runnable()
+ {
+ public void run()
+ {
SV_Baselines_f();
}
- }), new ucmd_t("begin", new Runnable() {
- public void run() {
+ }), new ucmd_t("begin", new Runnable()
+ {
+ public void run()
+ {
SV_Begin_f();
}
- }), new ucmd_t("nextserver", new Runnable() {
- public void run() {
+ }), new ucmd_t("nextserver", new Runnable()
+ {
+ public void run()
+ {
SV_Nextserver_f();
}
- }), new ucmd_t("disconnect", new Runnable() {
- public void run() {
+ }), new ucmd_t("disconnect", new Runnable()
+ {
+ public void run()
+ {
SV_Disconnect_f();
}
}),
// issued by hand at client consoles
- new ucmd_t("info", new Runnable() {
- public void run() {
+ new ucmd_t("info", new Runnable()
+ {
+ public void run()
+ {
SV_ShowServerinfo_f();
}
- }), new ucmd_t("download", new Runnable() {
- public void run() {
+ }), new ucmd_t("download", new Runnable()
+ {
+ public void run()
+ {
SV_BeginDownload_f();
}
- }), new ucmd_t("nextdl", new Runnable() {
- public void run() {
+ }), new ucmd_t("nextdl", new Runnable()
+ {
+ public void run()
+ {
SV_NextDownload_f();
}
})
@@ -473,23 +531,26 @@ public class SV_USER extends SV_SEND {
SV_ExecuteUserCommand
==================
*/
- public static void SV_ExecuteUserCommand(String s) {
- ucmd_t u = null;
+ public static void SV_ExecuteUserCommand(String s)
+ {
+ ucmd_t u= null;
Cmd.TokenizeString(s.toCharArray(), true);
- sv_player = sv_client.edict;
+ sv_player= sv_client.edict;
// SV_BeginRedirect (RD_CLIENT);
- int i=0;
- for (; i < ucmds.length; i++) {
- u = ucmds[i];
- if (0 == strcmp(Cmd.Argv(0), u.name)) {
+ int i= 0;
+ for (; i < ucmds.length; i++)
+ {
+ u= ucmds[i];
+ if (0 == strcmp(Cmd.Argv(0), u.name))
+ {
u.r.run();
break;
}
}
-
+
if (i == ucmds.length && sv.state == ss_game)
SV_GAME.ge.ClientCommand(sv_player);
@@ -504,10 +565,12 @@ public class SV_USER extends SV_SEND {
===========================================================================
*/
- public static void SV_ClientThink(client_t cl, usercmd_t cmd) {
+ public static void SV_ClientThink(client_t cl, usercmd_t cmd)
+ {
cl.commandMsec -= cmd.msec & 0xFF;
- if (cl.commandMsec < 0 && sv_enforcetime.value != 0) {
+ if (cl.commandMsec < 0 && sv_enforcetime.value != 0)
+ {
Com.DPrintf("commandMsec underflow from " + cl.name + "\n");
return;
}
@@ -515,7 +578,7 @@ public class SV_USER extends SV_SEND {
SV_GAME.ge.ClientThink(cl.edict, cmd);
}
- public static final int MAX_STRINGCMDS = 8;
+ public static final int MAX_STRINGCMDS= 8;
/*
===================
SV_ExecuteClientMessage
@@ -523,12 +586,13 @@ public class SV_USER extends SV_SEND {
The current net_message is parsed for the given client
===================
*/
- public static void SV_ExecuteClientMessage(client_t cl) {
+ public static void SV_ExecuteClientMessage(client_t cl)
+ {
int c;
String s;
- usercmd_t nullcmd = new usercmd_t();
- usercmd_t oldest = new usercmd_t(), oldcmd = new usercmd_t(), newcmd = new usercmd_t();
+ usercmd_t nullcmd= new usercmd_t();
+ usercmd_t oldest= new usercmd_t(), oldcmd= new usercmd_t(), newcmd= new usercmd_t();
int net_drop;
int stringCmdCount;
int checksum, calculatedChecksum;
@@ -536,26 +600,29 @@ public class SV_USER extends SV_SEND {
boolean move_issued;
int lastframe;
- sv_client = cl;
- sv_player = sv_client.edict;
+ sv_client= cl;
+ sv_player= sv_client.edict;
// only allow one move command
- move_issued = false;
- stringCmdCount = 0;
+ move_issued= false;
+ stringCmdCount= 0;
- while (true) {
- if (net_message.readcount > net_message.cursize) {
+ while (true)
+ {
+ if (net_message.readcount > net_message.cursize)
+ {
Com.Printf("SV_ReadClientMessage: bad read:\n");
Com.Printf(Lib.hexDump(net_message.data, 32, false));
SV_DropClient(cl);
return;
}
- c = MSG.ReadByte(net_message);
+ c= MSG.ReadByte(net_message);
if (c == -1)
break;
- switch (c) {
+ switch (c)
+ {
default :
Com.Printf("SV_ReadClientMessage: unknown command char\n");
SV_DropClient(cl);
@@ -565,7 +632,7 @@ public class SV_USER extends SV_SEND {
break;
case clc_userinfo :
- cl.userinfo = MSG.ReadString(net_message);
+ cl.userinfo= MSG.ReadString(net_message);
SV_MAIN.SV_UserinfoChanged(cl);
break;
@@ -573,41 +640,43 @@ public class SV_USER extends SV_SEND {
if (move_issued)
return; // someone is trying to cheat...
- move_issued = true;
- checksumIndex = net_message.readcount;
- checksum = MSG.ReadByte(net_message);
- lastframe = MSG.ReadLong(net_message);
-
- if (lastframe != cl.lastframe) {
- cl.lastframe = lastframe;
- if (cl.lastframe > 0) {
- cl.frame_latency[cl.lastframe & (LATENCY_COUNTS - 1)] =
+ move_issued= true;
+ checksumIndex= net_message.readcount;
+ checksum= MSG.ReadByte(net_message);
+ lastframe= MSG.ReadLong(net_message);
+
+ if (lastframe != cl.lastframe)
+ {
+ cl.lastframe= lastframe;
+ if (cl.lastframe > 0)
+ {
+ cl.frame_latency[cl.lastframe & (LATENCY_COUNTS - 1)]=
svs.realtime - cl.frames[cl.lastframe & UPDATE_MASK].senttime;
}
}
//memset (nullcmd, 0, sizeof(nullcmd));
- nullcmd = new usercmd_t();
+ nullcmd= new usercmd_t();
MSG.ReadDeltaUsercmd(net_message, nullcmd, oldest);
MSG.ReadDeltaUsercmd(net_message, oldest, oldcmd);
MSG.ReadDeltaUsercmd(net_message, oldcmd, newcmd);
- if (cl.state != cs_spawned) {
- cl.lastframe = -1;
+ if (cl.state != cs_spawned)
+ {
+ cl.lastframe= -1;
break;
}
// if the checksum fails, ignore the rest of the packet
- calculatedChecksum = 0;
- /*
- = Com.BlockSequenceCRCByte(
- net_message.data + checksumIndex + 1,
+ calculatedChecksum=
+ Com.BlockSequenceCRCByte(
+ net_message.data, checksumIndex + 1,
net_message.readcount - checksumIndex - 1,
cl.netchan.incoming_sequence);
- */
- if (calculatedChecksum != checksum) {
+ if ((calculatedChecksum &0xff) != checksum)
+ {
Com.DPrintf(
"Failed command checksum for "
+ cl.name
@@ -621,14 +690,17 @@ public class SV_USER extends SV_SEND {
return;
}
- if (0 == sv_paused.value) {
- net_drop = cl.netchan.dropped;
- if (net_drop < 20) {
+ if (0 == sv_paused.value)
+ {
+ net_drop= cl.netchan.dropped;
+ if (net_drop < 20)
+ {
//if (net_drop > 2)
// Com.Printf ("drop %i\n", net_drop);
- while (net_drop > 2) {
+ while (net_drop > 2)
+ {
SV_ClientThink(cl, cl.lastcmd);
net_drop--;
@@ -648,7 +720,7 @@ public class SV_USER extends SV_SEND {
break;
case clc_stringcmd :
- s = MSG.ReadString(net_message);
+ s= MSG.ReadString(net_message);
// malicious users may try using too many string commands
if (++stringCmdCount < MAX_STRINGCMDS)
diff --git a/src/jake2/server/SV_WORLD.java b/src/jake2/server/SV_WORLD.java
index 4e78084..2015a44 100644
--- a/src/jake2/server/SV_WORLD.java
+++ b/src/jake2/server/SV_WORLD.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 07.01.2000 by RST.
-// $Id: SV_WORLD.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+// $Id: SV_WORLD.java,v 1.3.2.1 2004-07-09 08:38:25 hzi Exp $
package jake2.server;
@@ -48,14 +48,13 @@ public class SV_WORLD extends SV_CCMDS
//===============================================================================
//
-
public static void initNodes()
{
- for (int n = 0; n < AREA_NODES; n++)
- sv_areanodes[n] = new areanode_t();
+ for (int n= 0; n < AREA_NODES; n++)
+ sv_areanodes[n]= new areanode_t();
}
- public static areanode_t sv_areanodes[] = new areanode_t[AREA_NODES];
+ public static areanode_t sv_areanodes[]= new areanode_t[AREA_NODES];
static {
initNodes();
@@ -70,21 +69,21 @@ public class SV_WORLD extends SV_CCMDS
// ClearLink is used for new headnodes
public static void ClearLink(link_t l)
{
- l.prev = l.next = l;
+ l.prev= l.next= l;
}
public static void RemoveLink(link_t l)
{
- l.next.prev = l.prev;
- l.prev.next = l.next;
+ l.next.prev= l.prev;
+ l.prev.next= l.next;
}
public static void InsertLinkBefore(link_t l, link_t before)
{
- l.next = before;
- l.prev = before.prev;
- l.prev.next = l;
- l.next.prev = l;
+ l.next= before;
+ l.prev= before.prev;
+ l.prev.next= l;
+ l.next.prev= l;
}
/*
@@ -97,10 +96,10 @@ public class SV_WORLD extends SV_CCMDS
public static areanode_t SV_CreateAreaNode(int depth, float[] mins, float[] maxs)
{
areanode_t anode;
- float[] size = { 0, 0, 0 };
- float[] mins1 = { 0, 0, 0 }, maxs1 = { 0, 0, 0 }, mins2 = { 0, 0, 0 }, maxs2 = { 0, 0, 0 };
+ float[] size= { 0, 0, 0 };
+ float[] mins1= { 0, 0, 0 }, maxs1= { 0, 0, 0 }, mins2= { 0, 0, 0 }, maxs2= { 0, 0, 0 };
- anode = sv_areanodes[sv_numareanodes];
+ anode= sv_areanodes[sv_numareanodes];
// just for debugging (rst)
VectorCopy(mins, anode.mins_rst);
@@ -113,27 +112,27 @@ public class SV_WORLD extends SV_CCMDS
if (depth == AREA_DEPTH)
{
- anode.axis = -1;
- anode.children[0] = anode.children[1] = null;
+ anode.axis= -1;
+ anode.children[0]= anode.children[1]= null;
return anode;
}
VectorSubtract(maxs, mins, size);
if (size[0] > size[1])
- anode.axis = 0;
+ anode.axis= 0;
else
- anode.axis = 1;
+ anode.axis= 1;
- anode.dist = 0.5f * (maxs[anode.axis] + mins[anode.axis]);
+ anode.dist= 0.5f * (maxs[anode.axis] + mins[anode.axis]);
VectorCopy(mins, mins1);
VectorCopy(mins, mins2);
VectorCopy(maxs, maxs1);
VectorCopy(maxs, maxs2);
- maxs1[anode.axis] = mins2[anode.axis] = anode.dist;
+ maxs1[anode.axis]= mins2[anode.axis]= anode.dist;
- anode.children[0] = SV_CreateAreaNode(depth + 1, mins2, maxs2);
- anode.children[1] = SV_CreateAreaNode(depth + 1, mins1, maxs1);
+ anode.children[0]= SV_CreateAreaNode(depth + 1, mins2, maxs2);
+ anode.children[1]= SV_CreateAreaNode(depth + 1, mins1, maxs1);
return anode;
}
@@ -147,7 +146,7 @@ public class SV_WORLD extends SV_CCMDS
public static void SV_ClearWorld()
{
initNodes();
- sv_numareanodes = 0;
+ sv_numareanodes= 0;
SV_CreateAreaNode(0, sv.models[1].mins, sv.models[1].maxs);
/*
@@ -178,7 +177,7 @@ public class SV_WORLD extends SV_CCMDS
if (null == ent.area.prev)
return; // not linked in anywhere
RemoveLink(ent.area);
- ent.area.prev = ent.area.next = null;
+ ent.area.prev= ent.area.next= null;
}
/*
@@ -186,18 +185,18 @@ public class SV_WORLD extends SV_CCMDS
SV_LinkEdict
===============
*/
- public static final int MAX_TOTAL_ENT_LEAFS = 128;
-
+ public static final int MAX_TOTAL_ENT_LEAFS= 128;
+ private static int leafs[]= new int[MAX_TOTAL_ENT_LEAFS];
+ private static int clusters[]= new int[MAX_TOTAL_ENT_LEAFS];
+
public static void SV_LinkEdict(edict_t ent)
{
areanode_t node;
- // TODO: make static instead of new
- int leafs[] = new int[MAX_TOTAL_ENT_LEAFS];
- int clusters[] = new int[MAX_TOTAL_ENT_LEAFS];
+
int num_leafs;
int j, k;
int area;
- int topnode = 0;
+ int topnode= 0;
if (ent.area.prev != null)
SV_UnlinkEdict(ent); // unlink from old position
@@ -214,54 +213,54 @@ public class SV_WORLD extends SV_CCMDS
// encode the size into the entity_state for client prediction
if (ent.solid == SOLID_BBOX && 0 == (ent.svflags & SVF_DEADMONSTER))
{ // assume that x/y are equal and symetric
- int i = (int) (ent.maxs[0] / 8);
+ int i= (int) (ent.maxs[0] / 8);
if (i < 1)
- i = 1;
+ i= 1;
if (i > 31)
- i = 31;
+ i= 31;
// z is not symetric
- j = (int) ((-ent.mins[2]) / 8);
+ j= (int) ((-ent.mins[2]) / 8);
if (j < 1)
- j = 1;
+ j= 1;
if (j > 31)
- j = 31;
+ j= 31;
// and z maxs can be negative...
- k = (int) ((ent.maxs[2] + 32) / 8);
+ k= (int) ((ent.maxs[2] + 32) / 8);
if (k < 1)
- k = 1;
+ k= 1;
if (k > 63)
- k = 63;
+ k= 63;
- ent.s.solid = (k << 10) | (j << 5) | i;
+ ent.s.solid= (k << 10) | (j << 5) | i;
}
else if (ent.solid == SOLID_BSP)
{
- ent.s.solid = 31; // a solid_bbox will never create this value
+ ent.s.solid= 31; // a solid_bbox will never create this value
}
else
- ent.s.solid = 0;
+ ent.s.solid= 0;
// set the abs box
if (ent.solid == SOLID_BSP && (ent.s.angles[0] != 0 || ent.s.angles[1] != 0 || ent.s.angles[2] != 0))
{ // expand for rotation
float max, v;
- max = 0;
- for (int i = 0; i < 3; i++)
+ max= 0;
+ for (int i= 0; i < 3; i++)
{
- v = Math.abs(ent.mins[i]);
+ v= Math.abs(ent.mins[i]);
if (v > max)
- max = v;
- v = Math.abs(ent.maxs[i]);
+ max= v;
+ v= Math.abs(ent.maxs[i]);
if (v > max)
- max = v;
+ max= v;
}
- for (int i = 0; i < 3; i++)
+ for (int i= 0; i < 3; i++)
{
- ent.absmin[i] = ent.s.origin[i] - max;
- ent.absmax[i] = ent.s.origin[i] + max;
+ ent.absmin[i]= ent.s.origin[i] - max;
+ ent.absmax[i]= ent.s.origin[i] + max;
}
}
else
@@ -281,62 +280,65 @@ public class SV_WORLD extends SV_CCMDS
ent.absmax[2]++;
// link to PVS leafs
- ent.num_clusters = 0;
- ent.areanum = 0;
- ent.areanum2 = 0;
+ ent.num_clusters= 0;
+ ent.areanum= 0;
+ ent.areanum2= 0;
//get all leafs, including solids
- CM.intwrap iw = new CM.intwrap(topnode);
+ int iw[] = {topnode};
- num_leafs = CM.CM_BoxLeafnums(ent.absmin, ent.absmax, leafs, MAX_TOTAL_ENT_LEAFS, iw);
+ num_leafs= CM.CM_BoxLeafnums(ent.absmin, ent.absmax, leafs, MAX_TOTAL_ENT_LEAFS, iw);
- topnode = iw.i;
+ topnode= iw[0];
// set areas
- for (int i = 0; i < num_leafs; i++)
+ for (int i= 0; i < num_leafs; i++)
{
- clusters[i] = CM.CM_LeafCluster(leafs[i]);
- area = CM.CM_LeafArea(leafs[i]);
+ clusters[i]= CM.CM_LeafCluster(leafs[i]);
+ area= CM.CM_LeafArea(leafs[i]);
if (area != 0)
- { // doors may legally straggle two areas,
+ {
+ // doors may legally straggle two areas,
// but nothing should evern need more than that
if (ent.areanum != 0 && ent.areanum != area)
{
if (ent.areanum2 != 0 && ent.areanum2 != area && sv.state == ss_loading)
Com.DPrintf("Object touching 3 areas at " + ent.absmin[0] + " " + ent.absmin[1] + " " + ent.absmin[2] + "\n");
- ent.areanum2 = area;
+ ent.areanum2= area;
}
else
- ent.areanum = area;
+ ent.areanum= area;
}
}
if (num_leafs >= MAX_TOTAL_ENT_LEAFS)
- { // assume we missed some leafs, and mark by headnode
- ent.num_clusters = -1;
- ent.headnode = topnode;
+ {
+ // assume we missed some leafs, and mark by headnode
+ ent.num_clusters= -1;
+ ent.headnode= topnode;
}
else
{
- ent.num_clusters = 0;
- for (int i = 0; i < num_leafs; i++)
+ ent.num_clusters= 0;
+ for (int i= 0; i < num_leafs; i++)
{
if (clusters[i] == -1)
continue; // not a visible leaf
- for (j = 0; j < i; j++)
+ for (j= 0; j < i; j++)
if (clusters[j] == clusters[i])
break;
if (j == i)
{
if (ent.num_clusters == MAX_ENT_CLUSTERS)
- { // assume we missed some leafs, and mark by headnode
- ent.num_clusters = -1;
- ent.headnode = topnode;
+ {
+ // assume we missed some leafs, and mark by headnode
+ ent.num_clusters= -1;
+ ent.headnode= topnode;
break;
}
- ent.clusternums[ent.num_clusters++] = clusters[i];
+ ent.clusternums[ent.num_clusters++]= clusters[i];
}
}
}
@@ -352,16 +354,16 @@ public class SV_WORLD extends SV_CCMDS
return;
// find the first node that the ent's box crosses
- node = sv_areanodes[0];
+ node= sv_areanodes[0];
while (true)
{
if (node.axis == -1)
break;
if (ent.absmin[node.axis] > node.dist)
- node = node.children[0];
+ node= node.children[0];
else if (ent.absmax[node.axis] < node.dist)
- node = node.children[1];
+ node= node.children[1];
else
break; // crosses the node
}
@@ -386,19 +388,18 @@ public class SV_WORLD extends SV_CCMDS
edict_t check;
int count;
- count = 0;
+ count= 0;
// touch linked edicts
if (area_type == AREA_SOLID)
- start = node.solid_edicts;
+ start= node.solid_edicts;
else
- start = node.trigger_edicts;
+ start= node.trigger_edicts;
- for (l = start.next; l != start; l = next)
+ for (l= start.next; l != start; l= next)
{
- next = l.next;
- check = //EDICT_FROM_AREA(l);
- (edict_t) l.o;
+ next= l.next;
+ check= (edict_t) l.o;
if (check.solid == SOLID_NOT)
continue; // deactivated
@@ -416,7 +417,7 @@ public class SV_WORLD extends SV_CCMDS
return;
}
- area_list[area_count] = check;
+ area_list[area_count]= check;
area_count++;
}
@@ -438,57 +439,53 @@ public class SV_WORLD extends SV_CCMDS
*/
public static int SV_AreaEdicts(float[] mins, float[] maxs, edict_t list[], int maxcount, int areatype)
{
- area_mins = mins;
- area_maxs = maxs;
- area_list = list;
- area_count = 0;
- area_maxcount = maxcount;
- area_type = areatype;
+ area_mins= mins;
+ area_maxs= maxs;
+ area_list= list;
+ area_count= 0;
+ area_maxcount= maxcount;
+ area_type= areatype;
SV_AreaEdicts_r(sv_areanodes[0]);
- /*
- Com.Printf("found edicts in area:" + area_count + "\n");
- for (int n = 0; n < area_count; n++) {
- Com.Printf("%4i : %25s", new Vargs().add(n).add(list[n].classname));
- }
- */
return area_count;
}
//===========================================================================
+ private static edict_t touch[]= new edict_t[MAX_EDICTS];
/*
=============
SV_PointContents
=============
*/
+
public static int SV_PointContents(float[] p)
{
- // TODO: make static instead new
- edict_t touch[] = new edict_t[MAX_EDICTS], hit;
+ edict_t hit;
+
int i, num;
int contents, c2;
int headnode;
float angles[];
// get base contents from world
- contents = CM.PointContents(p, sv.models[1].headnode);
+ contents= CM.PointContents(p, sv.models[1].headnode);
// or in contents from all the other entities
- num = SV_AreaEdicts(p, p, touch, MAX_EDICTS, AREA_SOLID);
+ num= SV_AreaEdicts(p, p, touch, MAX_EDICTS, AREA_SOLID);
- for (i = 0; i < num; i++)
+ for (i= 0; i < num; i++)
{
- hit = touch[i];
+ hit= touch[i];
// might intersect, so do an exact clip
- headnode = SV_HullForEntity(hit);
- angles = hit.s.angles;
+ headnode= SV_HullForEntity(hit);
+ angles= hit.s.angles;
if (hit.solid != SOLID_BSP)
- angles = vec3_origin; // boxes don't rotate
+ angles= vec3_origin; // boxes don't rotate
- c2 = CM.TransformedPointContents(p, headnode, hit.s.origin, hit.s.angles);
+ c2= CM.TransformedPointContents(p, headnode, hit.s.origin, hit.s.angles);
contents |= c2;
}
@@ -514,7 +511,7 @@ public class SV_WORLD extends SV_CCMDS
// decide which clipping hull to use, based on the size
if (ent.solid == SOLID_BSP)
{ // explicit hulls in the BSP model
- model = sv.models[ent.s.modelindex];
+ model= sv.models[ent.s.modelindex];
if (null == model)
Com.Error(ERR_FATAL, "MOVETYPE_PUSH with a non bsp model");
@@ -535,23 +532,23 @@ public class SV_WORLD extends SV_CCMDS
====================
*/
+ private static edict_t touchlist[]= new edict_t[MAX_EDICTS];
public static void SV_ClipMoveToEntities(moveclip_t clip)
{
int i, num;
- // TODO: make static instead of new
- edict_t touchlist[] = new edict_t[MAX_EDICTS];
+
edict_t touch;
trace_t trace;
int headnode;
float angles[];
- num = SV_AreaEdicts(clip.boxmins, clip.boxmaxs, touchlist, MAX_EDICTS, AREA_SOLID);
+ num= SV_AreaEdicts(clip.boxmins, clip.boxmaxs, touchlist, MAX_EDICTS, AREA_SOLID);
// be careful, it is possible to have an entity in this
// list removed before we get to it (killtriggered)
- for (i = 0; i < num; i++)
+ for (i= 0; i < num; i++)
{
- touch = touchlist[i];
+ touch= touchlist[i];
if (touch.solid == SOLID_NOT)
continue;
if (touch == clip.passedict)
@@ -570,13 +567,13 @@ public class SV_WORLD extends SV_CCMDS
continue;
// might intersect, so do an exact clip
- headnode = SV_HullForEntity(touch);
- angles = touch.s.angles;
+ headnode= SV_HullForEntity(touch);
+ angles= touch.s.angles;
if (touch.solid != SOLID_BSP)
- angles = vec3_origin; // boxes don't rotate
+ angles= vec3_origin; // boxes don't rotate
if ((touch.svflags & SVF_MONSTER) != 0)
- trace =
+ trace=
CM.TransformedBoxTrace(
clip.start,
clip.end,
@@ -587,7 +584,7 @@ public class SV_WORLD extends SV_CCMDS
touch.s.origin,
angles);
else
- trace =
+ trace=
CM.TransformedBoxTrace(
clip.start,
clip.end,
@@ -600,17 +597,17 @@ public class SV_WORLD extends SV_CCMDS
if (trace.allsolid || trace.startsolid || trace.fraction < clip.trace.fraction)
{
- trace.ent = touch;
+ trace.ent= touch;
if (clip.trace.startsolid)
{
- clip.trace = trace;
- clip.trace.startsolid = true;
+ clip.trace= trace;
+ clip.trace.startsolid= true;
}
else
clip.trace.set(trace);
}
else if (trace.startsolid)
- clip.trace.startsolid = true;
+ clip.trace.startsolid= true;
}
}
@@ -623,17 +620,17 @@ public class SV_WORLD extends SV_CCMDS
{
int i;
- for (i = 0; i < 3; i++)
+ for (i= 0; i < 3; i++)
{
if (end[i] > start[i])
{
- boxmins[i] = start[i] + mins[i] - 1;
- boxmaxs[i] = end[i] + maxs[i] + 1;
+ boxmins[i]= start[i] + mins[i] - 1;
+ boxmaxs[i]= end[i] + maxs[i] + 1;
}
else
{
- boxmins[i] = end[i] + mins[i] - 1;
- boxmaxs[i] = start[i] + maxs[i] + 1;
+ boxmins[i]= end[i] + mins[i] - 1;
+ boxmaxs[i]= start[i] + maxs[i] + 1;
}
}
@@ -651,27 +648,27 @@ public class SV_WORLD extends SV_CCMDS
*/
public static trace_t SV_Trace(float[] start, float[] mins, float[] maxs, float[] end, edict_t passedict, int contentmask)
{
- moveclip_t clip = new moveclip_t();
+ moveclip_t clip= new moveclip_t();
if (mins == null)
- mins = vec3_origin;
+ mins= vec3_origin;
if (maxs == null)
- maxs = vec3_origin;
+ maxs= vec3_origin;
//memset ( clip, 0, sizeof ( moveclip_t ) );
// clip to world
- clip.trace = CM.BoxTrace(start, end, mins, maxs, 0, contentmask);
- clip.trace.ent = ge.edicts[0];
+ clip.trace= CM.BoxTrace(start, end, mins, maxs, 0, contentmask);
+ clip.trace.ent= ge.edicts[0];
if (clip.trace.fraction == 0)
return clip.trace; // blocked by the world
- clip.contentmask = contentmask;
- clip.start = start;
- clip.end = end;
- clip.mins = mins;
- clip.maxs = maxs;
- clip.passedict = passedict;
+ clip.contentmask= contentmask;
+ clip.start= start;
+ clip.end= end;
+ clip.mins= mins;
+ clip.maxs= maxs;
+ clip.passedict= passedict;
VectorCopy(mins, clip.mins2);
VectorCopy(maxs, clip.maxs2);
diff --git a/src/jake2/sound/S.java b/src/jake2/sound/S.java
index c696501..72fdb48 100644
--- a/src/jake2/sound/S.java
+++ b/src/jake2/sound/S.java
@@ -2,7 +2,7 @@
* S.java
* Copyright (C) 2003
*
- * $Id: S.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ * $Id: S.java,v 1.1.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -184,4 +184,8 @@ public class S {
public static void StopAllSounds() {
impl.StopAllSounds();
}
+
+ public static String getDriverName() {
+ return impl.getName();
+ }
}
diff --git a/src/jake2/sound/WaveLoader.java b/src/jake2/sound/WaveLoader.java
index 020ab52..865d1b9 100644
--- a/src/jake2/sound/WaveLoader.java
+++ b/src/jake2/sound/WaveLoader.java
@@ -2,7 +2,7 @@
* SND_MEM.java
* Copyright (C) 2004
*
- * $Id: WaveLoader.java,v 1.1 2004-07-09 06:50:48 hzi Exp $
+ * $Id: WaveLoader.java,v 1.1.2.1 2004-07-09 08:38:26 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/sound/joal/Channel.java b/src/jake2/sound/joal/Channel.java
index ced496f..5438a8a 100644
--- a/src/jake2/sound/joal/Channel.java
+++ b/src/jake2/sound/joal/Channel.java
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003
*
- * $Id: Channel.java,v 1.1 2004-07-09 06:50:52 hzi Exp $
+ * $Id: Channel.java,v 1.1.2.1 2004-07-09 08:38:28 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/sound/joal/JOALSoundImpl.java b/src/jake2/sound/joal/JOALSoundImpl.java
index 8a005ce..3047484 100644
--- a/src/jake2/sound/joal/JOALSoundImpl.java
+++ b/src/jake2/sound/joal/JOALSoundImpl.java
@@ -2,7 +2,7 @@
* JOALSoundImpl.java
* Copyright (C) 2004
*
- * $Id: JOALSoundImpl.java,v 1.1 2004-07-09 06:50:52 hzi Exp $
+ * $Id: JOALSoundImpl.java,v 1.1.2.1 2004-07-09 08:38:28 hzi Exp $
*/
package jake2.sound.joal;
diff --git a/src/jake2/sys/NET.java b/src/jake2/sys/NET.java
index 19a3a59..56e3c0d 100644
--- a/src/jake2/sys/NET.java
+++ b/src/jake2/sys/NET.java
@@ -2,7 +2,7 @@
* NET.java
* Copyright (C) 2003
*
- * $Id: NET.java,v 1.1 2004-07-07 19:59:51 hzi Exp $
+ * $Id: NET.java,v 1.1.1.1.2.1 2004-07-09 08:38:25 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -686,8 +686,8 @@ public final class NET extends Defines {
====================
*/
public static String NET_ErrorString() {
+
int code;
-
//code = errno;
//return strerror (code);
return "errno can not yet resolved in java";
@@ -700,7 +700,7 @@ public final class NET extends Defines {
return; // we're not a server, just run full speed
try {
- //TODO: check for
+ //TODO: check for timeout
Thread.sleep(msec);
}
catch (InterruptedException e) {
diff --git a/src/jake2/sys/Sys.java b/src/jake2/sys/Sys.java
index 8a08956..7cbfd80 100644
--- a/src/jake2/sys/Sys.java
+++ b/src/jake2/sys/Sys.java
@@ -2,7 +2,7 @@
* Sys.java
* Copyright (C) 2003
*
- * $Id: Sys.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Sys.java,v 1.3.2.1 2004-07-09 08:38:25 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -44,14 +44,6 @@ import jake2.util.Lib;
*/
public final class Sys extends Defines {
- public static void StackTrace() {
-
- StackTraceElement trace[] = new Throwable().getStackTrace();
- Com.Println("StackTrace:");
- for (int i = 0; i < trace.length; i++)
- Com.Println("" + trace[i]);
- }
-
public static void Error(String error) {
CL.Shutdown();
@@ -259,11 +251,6 @@ public final class Sys extends Defines {
Globals.sys_frame_time = Sys.Milliseconds();
}
- public static game_export_t GetGameAPI(game_import_t gimport)
- {
- return Game.GetGameApi(gimport);
- }
-
public static String GetClipboardData() {
// TODO: implement GetClipboardData
return null;
diff --git a/src/jake2/util/Lib.java b/src/jake2/util/Lib.java
index bab5ff0..a79cc1a 100644
--- a/src/jake2/util/Lib.java
+++ b/src/jake2/util/Lib.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 09.12.2003 by RST.
-// $Id: Lib.java,v 1.2 2004-07-08 15:58:48 hzi Exp $
+// $Id: Lib.java,v 1.2.2.1 2004-07-09 08:38:23 hzi Exp $
package jake2.util;
@@ -28,37 +28,17 @@ import jake2.qcommon.Com;
import jake2.qcommon.FS;
import java.io.*;
+import java.nio.*;
import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
import java.util.Arrays;
import java.util.StringTokenizer;
-public class Lib {
-
- /*
- =============
- TempVector
-
- This is just a convenience function
- for making temporary vectors for function calls
- =============
- */
- public static float tv_vecs[][] = new float[8][3];
- public static int tv_index;
- public static float[] tv(float x, float y, float z) {
+import net.java.games.jogl.util.BufferUtils;
- float[] v;
-
- // use an array so that multiple tempvectors won't collide
- // for a while
- v = tv_vecs[tv_index];
- tv_index = (tv_index++) & 7;
+public class Lib {
- v[0] = x;
- v[1] = y;
- v[2] = z;
- return v;
- }
/*
=============
VectorToString
@@ -92,9 +72,6 @@ public class Lib {
public static float crand() {
return (Globals.rnd.nextFloat() - 0.5f) * 2.0f;
}
- public static float frand() {
- return Globals.rnd.nextFloat();
- }
public static int strcmp(String in1, String in2) {
return in1.compareTo(in2);
@@ -108,25 +85,6 @@ public class Lib {
return (i1.indexOf(i2) != -1);
}
- public static int strncmp(String in1, String in2, int len) {
- int i1 = Math.min(len, in1.length());
- int i2 = Math.min(len, in2.length());
-
- if (i1 < i2)
- return -1;
- if (i1 > i2)
- return 1;
-
- for (int n = 0; n < i1; n++) {
- char c1 = in1.charAt(n);
- char c2 = in2.charAt(n);
- if (c1 < c2)
- return -1;
- if (c1 > c2)
- return 1;
- }
- return 0;
- }
public static float atof(String in) {
float res = 0;
@@ -189,17 +147,6 @@ public class Lib {
in += i;
}
- public static void strcpy(char dest[], char src[]) {
- for (int i = 0; i < dest.length && i < src.length; i++)
- if (src[i] == 0) {
- dest[i] = 0;
- return;
- }
- else
- dest[i] = src[i];
-
- }
-
public static void strcpy(byte dest[], byte src[]) {
for (int i = 0; i < dest.length && i < src.length; i++)
if (src[i] == 0) {
@@ -385,33 +332,6 @@ public class Lib {
return result;
}
- public static void main(String[] args) {
- System.out.println("testing Lib...");
-
- String linetest = "line 1\r\n line zwo\nline drei\n\r line4\n.line5";
-
- String line[] = linesplit(linetest);
-
- for (int n = 0; n < line.length; n++) {
- System.out.println("[" + line[n] + "]");
- }
-
- String v = "0.234 1.23423 7.23423";
-
- int i1 = v.indexOf(" ");
- int i2 = v.indexOf(" ", i1 + 1);
-
- System.out.println("testing substring...");
-
- System.out.println("[" + v.substring(0, i1) + "]");
- System.out.println("[" + v.substring(i1 + 1, i2) + "]");
- System.out.println("[" + v.substring(i2 + 1, v.length()) + "]");
-
- System.out.println("rightfrom[" + rightFrom("abcdefg#hijklm", '#') + "]");
- System.out.println("leftfrom[" + leftFrom("abcdefghijk#12", '#') + "]");
- System.out.println("leftfrom[" + leftFrom("abcdefghi", '#') + "]");
- }
-
public static int rename(String oldn, String newn) {
try {
File f1 = new File(oldn);
@@ -436,23 +356,6 @@ public class Lib {
public static int getInt(byte b[]) {
return (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | ((b[3] & 0xff) << 24);
}
-
- public static void sleep(int sec) {
- try {
- Thread.sleep(sec * 1000);
- }
- catch (InterruptedException e) {
- }
- }
-
- public static byte[] clone(byte in[]) {
- byte out[] = new byte[in.length];
-
- if (in.length != 0)
- System.arraycopy(in, 0, out, 0, in.length);
-
- return out;
- }
public static float[] clone(float in[]) {
float out[] = new float[in.length];
@@ -463,15 +366,6 @@ public class Lib {
return out;
}
- public static short[] clone(short in[]) {
- short out[] = new short[in.length];
-
- if (in.length != 0)
- System.arraycopy(in, 0, out, 0, in.length);
-
- return out;
- }
-
public static long[] clone(long in[]) {
long out[] = new long[in.length];
@@ -516,4 +410,44 @@ public class Lib {
return out;
}
+
+ /*
+ * java.nio.* Buffer util functions
+ */
+
+ public static final int SIZEOF_FLOAT = BufferUtils.SIZEOF_FLOAT;
+ public static final int SIZEOF_INT = BufferUtils.SIZEOF_INT;
+
+ public static FloatBuffer newFloatBuffer(int numElements) {
+ ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT);
+ return bb.asFloatBuffer();
+ }
+
+ public static FloatBuffer newFloatBuffer(int numElements, ByteOrder order) {
+ ByteBuffer bb = newByteBuffer(numElements * SIZEOF_FLOAT, order);
+ return bb.asFloatBuffer();
+ }
+
+ public static IntBuffer newIntBuffer(int numElements) {
+ ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT);
+ return bb.asIntBuffer();
+ }
+
+ public static IntBuffer newIntBuffer(int numElements, ByteOrder order) {
+ ByteBuffer bb = newByteBuffer(numElements * SIZEOF_INT, order);
+ return bb.asIntBuffer();
+ }
+
+ public static ByteBuffer newByteBuffer(int numElements) {
+ ByteBuffer bb = ByteBuffer.allocateDirect(numElements);
+ bb.order(ByteOrder.nativeOrder());
+ return bb;
+ }
+
+ public static ByteBuffer newByteBuffer(int numElements, ByteOrder order) {
+ ByteBuffer bb = ByteBuffer.allocateDirect(numElements);
+ bb.order(order);
+ return bb;
+ }
+
}